I recently got A* Pathfinding Project Pro and am trying to use it with Pathological Games Pool Manager.
And I have a question about using A* with PoolManger.
Now before I ask my question let me give you a little bit of a background as to what is going on so you can better understand my question.
I have a large number of enemies that I use the Pool Manager to manage.
These enemies among other things have a Wonder, Vision, Auditory, Damage, Attack, Seeker, Funnel Modifier and an and AI components.
The AI component extends AIPath and is where the magic happens.
The enemies use vision/auditory/damage components to control when they have a target.
We also have spawners which also use vision/auditory components to determine when a player comes into visual or auditory range of the spawner and if so prespawn enemies using a pool manager to spawn enemies as needed.
When an enemy is killed the target, some other player, by some ai logic or because it wonders out of range of the players the AI logic uses the pool manager to despawn it.
Instantiate() and Destroy() are never directly called by our code. The pool manager calls these as needed and we do not want to change any of that logic since it’s a 3rd party component.
So once we have an enemy if the vision/auditory system sees or hears a possible target it will call something like TargetInSite(Transform target) .
Likewise if the player attacks the enemy from outside it’s visual/auditory range the Damage system will call something like OnHit(Hit hit).
So it is TargetInSite() that will be calling A* system to get a path to target and the seeker will be used to take it to the target.
Likewise OnHit will use Wonder component to look in the direction the the hit came from and also if visual/auditory target could not be find.
Basically Wonder has the enemy looking around for a target for a little bit.
Regardless if all players go out of range the AI despawns them anyways.
Q. Now that I laid it out for you the question that I have is if the enemy is killed for any reason the pool manager is called to despawn the enemy then what do I have to clean up with respect to A*.
If the enemy was using A* to seek a target I’m guessing there is a path that the Seeker was using and perhaps some coroutine or native thread doing the movement of that enemy that was just killed.
Also what if its in the middle of finding a path. How do I tell A* forget about it there is no longer a need for you to find a path and there is no longer a need to cal OnPathComplete(). In fact its not good if it did called OnPathComplete(), since its no longer valid. But the thing is I’m not handling OnPathComplete() AIPath is.
The pool manager calls OnSpawned() and OnDespawned() which I have overridden in my AI so I can clean up stuff, like A*. So my AI extends AIPath and I have a Seeker component. How do I tell them the enemy is dead, give up seeking him. Release any stuff like path that you have. Likewise if the enemy has been spawned by the pool manage how do I tell AIPath and the Seeker the enemy is alive again.
My auditory/vision/hit systems will handle calling for a path and to kick off the seeking, but what, if anything, do I have to do.
I do have a bool called isAlive which I set as needed, but A* does not have the concept.
I do notice that A* Seeker does have OnDestory() and things like ReleaseClaimedPath() and DeregisterModifier(). But if I manually call any of tem in my OnDespawned() dont I sort of have to RegisterModifier() from my OnSpawned()
And then how do I determine if OnPathComplete() is spending and stop call to it. Basically the enemy could be killed before or after or even without there being any call to even SearchPath()/StartPath()
Also it looks like there is a PathPool what if anything do I have to do with regards to any such pool of paths?
There there could be any number of questions that I have not guessed yet. So it would be nice if someone could answer in detail or even have a tutorial or a section in the documentation of how to use A* with pool manager, any pool manager is ok, since they basically do the same thing and basically have their own OnSpawned() / OnDespawned() and the same setup/cleanup would have to happen so that the object being managed by the pool manager should properly work with A*
Thanks in advance!