ecspresso
    Preparing search index...

    Function createBehaviorTreeHelpers

    • Create typed behavior tree helpers bound to a specific world type.

      Type Parameters

      Parameters

      • Optional_world: W

      Returns BehaviorTreeHelpers<W>

      const ecs = ECSpresso.create()
      .withPlugin(createBehaviorTreePlugin())
      .withComponentTypes<{ enemy: { hp: number } }>()
      .build();

      const { defineBehaviorTree, action, condition, guard } = ecs.getHelpers(createBehaviorTreeHelpers);

      action('read enemy', ({ ecs, entityId }) => {
      const enemy = ecs.getComponent(entityId, 'enemy');
      return enemy ? NodeStatus.Success : NodeStatus.Failure;
      });