Skip to content
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

Merged
merged 7 commits into from
Oct 13, 2023

Conversation

Arufonsu
Copy link
Contributor

- 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.
@Arufonsu Arufonsu requested review from a team October 13, 2023 03:43
@Arufonsu Arufonsu self-assigned this Oct 13, 2023
@Arufonsu Arufonsu added the bug Something isn't working label Oct 13, 2023
Comment on lines 2738 to 2739
var originMapController = MapController.Get(MapId);
var targetMapController = MapController.Get(en.MapId);
Copy link
Member

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?

Comment on lines 2780 to 2781
var originMapController = MapController.Get(MapId);
var targetMapController = MapController.Get(mapId);
Copy link
Member

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

Comment on lines 2648 to 2649
var originMapController = MapController.Get(MapId);
var targetMapController = MapController.Get(target.MapId);
Copy link
Member

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

@Arufonsu Arufonsu requested a review from lodicolo October 13, 2023 23:31
@lodicolo lodicolo merged commit 9974996 into AscensionGameDev:main Oct 13, 2023
1 check passed
Cheshire92 pushed a commit to Cheshire92/Intersect-Engine that referenced this pull request Oct 15, 2023
…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
@Arufonsu Arufonsu added bug fix Pull request that fixes a bug and removed bug Something isn't working labels May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix Pull request that fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: NPCs stop attacking the player when positioned at the edge of a map border
2 participants