-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: properly handle NPCs directions near map borders #1940
Conversation
- Chore: Renamed the method "DirToEnemy" to "DirectionToTarget" - Adjusted the DirectionToTarget method to properly handle directions near map borders and across different maps.
- Re-adjusts and caches origin and target (MapController.Get) for better map border calculation.
Adjusted the IsFacingTarget method to properly handle direction checks near map borders and across different maps.
Intersect.Server/Entities/Entity.cs
Outdated
var originMapController = MapController.Get(MapId); | ||
var targetMapController = MapController.Get(en.MapId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use TryGet and if it fails just return Dir?
Intersect.Server/Entities/Entity.cs
Outdated
var originMapController = MapController.Get(MapId); | ||
var targetMapController = MapController.Get(mapId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing with TryGet and returning the default value if either of them fail
Intersect.Server/Entities/Entity.cs
Outdated
var originMapController = MapController.Get(MapId); | ||
var targetMapController = MapController.Get(target.MapId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost missed this -- also use TryGet and return early if either fail
…ev#1940) * fix: DirToEnemy - Chore: Renamed the method "DirToEnemy" to "DirectionToTarget" - Adjusted the DirectionToTarget method to properly handle directions near map borders and across different maps. * chore: IsOneBlockAway - Re-adjusts and caches origin and target (MapController.Get) for better map border calculation. * fix: IsFacingTarget Adjusted the IsFacingTarget method to properly handle direction checks near map borders and across different maps. * enhancement: Adds TryGet for MapController * chore: uses TryGet within IsOneBlockAway * chore: uses TryGet within DirectionToTarget * chore: uses TryGet within IsFacingTarget
Preview:
2023-10-13.00-36-09.mp4