Class ActionBehavior

Base class of behavior tree implementation

Hierarchy (view full)

Constructors

  • Parameters

    • func: ((context) => void | BehaviorStatus)
        • (context): void | BehaviorStatus
        • Parameters

          • context: {
                elapsed: number;
                entity: Entity;
                timeDelta: number;
                [key: string]: any;
            }
            • [key: string]: any
            • elapsed: number
            • entity: Entity
            • timeDelta: number

          Returns void | BehaviorStatus

    • Optional options: {
          context?: any;
          isRepeat?: boolean;
      }
      • Optional context?: any
      • Optional isRepeat?: boolean

    Returns ActionBehavior

Properties

__action: ((context) => void | BehaviorStatus)

Type declaration

    • (context): void | BehaviorStatus
    • Parameters

      • context: {
            elapsed: number;
            entity: Entity;
            timeDelta: number;
            [key: string]: any;
        }
        • [key: string]: any
        • elapsed: number
        • entity: Entity
        • timeDelta: number

      Returns void | BehaviorStatus

__context: any
context: BehaviorContext = null

Any internal state used by the behavior This provides a way to interact with the outside as well as to pass data between themselves

isBehavior: boolean
onFinalized: Signal = ...

Dispatched after finalization is complete

onInitialized: Signal = ...

Dispatched after initialization is complete

typeName: string

Methods

  • Called when behavior is finished, or interrupted Used to clean up any resources You can think of it as "stop"

    Returns void

  • Called before behavior gets executed via tick for the first time Used to prepare the behavior for execution You can think of it as "start"

    Parameters

    Returns void

  • Main update function. Every behavior executes some logic, some behaviors are long-running and some are instantaneous

    Parameters

    • timeDelta: number

      time step in seconds

    Returns BehaviorStatus

    signals status of the behavior, "success" or "failure" are used to signal completion of the behavior