-
Notifications
You must be signed in to change notification settings - Fork 19
Description
As far as I can tell (please correct me if I'm wrong), there is no way to detect a cancelled action or Behavior
. For example, if you have While(Wait(5.0), Action(MyAction::Dance))
, if the 5 seconds expires, the action will be exited early. This can be problematic if your dance animation doesn't turn off automatically (perhaps it loops by default).
By the same reasoning, it could be nice to have a way to react to a whole Behavior
getting cancelled. For example, part of the tree may start with "claim a spot in a queue of agents". Leaving this subtree would ideally "release" that claim. We might be able to fake this by using something like WhenAny(the_queuing_tree, Action(MyAction::ReleaseSpotOnCancel))
. Then we just do nothing for this action normally and when it "hears" about the cancellation, it can react to it. This is quite cumbersome though, so it would be nice to somehow make a single Behavior
that does all of this.
To do this, we could add a second FnMut
that deals with cancellations. This would unfortunately separate the action logic from its cancellation logic, but it is a very easy solution.