BehaviorTreeActionHandler
Behavior Tree-specific event handlers that allow an ActionResult to be returned from the handler.
Declaration
protocol BehaviorTreeActionHandler : ActionHandlerProtocolOverview
Behavior trees send Started, Updated and Ended events. Optionally subscribe directly to any of these events in order to override default event handling in cases when conforming a new, custom event handler type.
Example:
struct MyAction: BehaviorTreeAction, Codable {
// ...
}
struct MyActionHandler: BehaviorTreeActionHandler {
typealias ActionType = MyAction
//... add some optional state data here.
// Action updated event handler.
public mutating func actionUpdatedWithResult(event: EventType) -> ActionResult? {
// ... handle the 'updated' event.
// Return the action result.
return .success
}
}
// The handler must be registered in order to receive events:
MyActionHandler.register { event in
return MyActionHandler()
}Topics
Responding to action progress
actionStartedWithResult(event:)actionUpdatedWithResult(event:)actionPausedWithResult(event:)actionResumedWithResult(event:)