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

Listen for path calculation in FindPathToNode #18

Merged
merged 4 commits into from Aug 10, 2019

Conversation

@AndyTechGuy
Copy link
Contributor

commented Jul 11, 2019

Contains

Inside FindPathToNode, a path is requested from the pathfinding system, but the result is not saved to the character's MinionMoveComponent. This pull request adds a callback to save the generated path to the move component once the calculation is finished.

Requires Terasology/Pathfinding#39 to work!

Todo

  • Fix path saving error
  • Add test character in Terasology/TutorialBehaviors

@AndyTechGuy AndyTechGuy marked this pull request as ready for review Jul 21, 2019

} else if (path.size() > 0) {
moveComponent.path = path.get(0);
} else if (paths.size() > 0) {
moveComponent.path = paths.get(0);
}
actor.save(moveComponent);

This comment has been minimized.

Copy link
@msteiger

msteiger Jul 24, 2019

Member

Are you sure that this call is either thread-safe or always called on the main thread?

This comment has been minimized.

Copy link
@AndyTechGuy

AndyTechGuy Jul 29, 2019

Author Contributor

I believe that it is? I changed the function to explicitly use a direct executor just to be save. This way, this call either runs directly in the action, or from pathfinding when the path is calculated, as found here: https://stackoverflow.com/questions/35211331/in-which-thread-futurecallback-will-be-called-for-a-listenablefuture-in-guava (this answer is for ListenableFuture instead of SettableFuture, but they are both implementations of Future so i'm assuming the executors work the same way)

This comment has been minimized.

Copy link
@msteiger

msteiger Aug 1, 2019

Member

Ah okay, I get it now. I wondered why you even put it in a Future for the same thread if you could just call it directly. But the pathfinderSystem seems to force you to use the Future approach. A bit odd, but ok.

} else if (path.size() > 0) {
moveComponent.path = path.get(0);
} else if (paths.size() > 0) {
moveComponent.path = paths.get(0);
}
actor.save(moveComponent);

This comment has been minimized.

Copy link
@msteiger

msteiger Aug 1, 2019

Member

Ah okay, I get it now. I wondered why you even put it in a Future for the same thread if you could just call it directly. But the pathfinderSystem seems to force you to use the Future approach. A bit odd, but ok.

@AndyTechGuy

This comment has been minimized.

Copy link
Contributor Author

commented Aug 6, 2019

A test pathfinding character has been added here: Terasology/TutorialBehaviors#5

@AndyTechGuy AndyTechGuy merged commit a543403 into Terasology:master Aug 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.