Support for returning false by costCallback option of Room.findPath. #113
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently
roomCallback
inPathFinder.search
has an option to return false instead of cost matrix to efficiently avoid the room entirely. There is no easy way to do that fromCreep.moveTo
efficiently, since it would require replacingroomCallback
in_findPath2
. One could usePathFinder
directly, but that results in losing much ofCreep.moveTo
utility such as path caching, at least without knowledge ofmoveTo
internals such as_move
.roomCallback
creates the cost matrix and passes it tocostCallback
to modify it. WhencostCallback
returns something else, it is ignored. No exception or anything. I propose that at least whencostCallback
returnsfalse
, it should be treated as ifroomCallback
returned false. This isn't as efficient as coding customroomCallback
, since the cost matrix is still created, but at least it is fully compatible with existing code and will not require the player to code all functionality betweenCreeps.moveTo
andRoom.findPath
if they just want to avoid certain rooms, e.g., rooms owned enemies.