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

Path callback should be passed calculate() instead of constructor #2

Closed
anissen opened this issue Oct 1, 2012 · 3 comments
Closed

Comments

@anissen
Copy link

anissen commented Oct 1, 2012

I have a use case where I would like one instance of Easystar to be invoked by many different objects. In such a case, it would be very handy to be able to pass the path callback function to the calculate() function instead of the constructor.

I realize that the callback function is also used in e.g. the setPath() function for signalling an invalid start or end position. However, I feel that this is a misuse of the callback. It might be an alternative to return a status code or throw an error on invalid input.

Thanks :)

@prettymuchbryce
Copy link
Owner

I agree with you. I will look into this.

@McFunkypants
Copy link

I suppose for now we create a new object with duplicate world data for every AI badguy.

@prettymuchbryce
Copy link
Owner

I have changed the API in 0.1.4. The callback is now added to the findPath method. Adding it to the calculate method would have been troublesome as you would have had to provide the callback each tick. There shouldn't be any need to duplicate world data anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants