![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Data-driven behavior tree system for AI decision making. More...
#include "../ECS_Entity.h"#include "../vector.h"#include <vector>#include <string>#include <cstdint>#include <map>#include <algorithm>#include <set>
Include dependency graph for BehaviorTree.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Classes | |
| struct | BTNode |
| Represents a single node in a behavior tree. More... | |
| struct | BTValidationMessage |
| Validation message for behavior tree structure checking. More... | |
| struct | BehaviorTreeAsset |
| struct | SubGraphCallStack |
| class | BehaviorTreeManager |
Functions | |
| BTStatus | ExecuteBTNode (const BTNode &node, EntityID entity, AIBlackboard_data &blackboard, const BehaviorTreeAsset &tree) |
| BTStatus | ExecuteBTCondition (BTConditionType condType, float param, EntityID entity, const AIBlackboard_data &blackboard) |
| BTStatus | ExecuteBTAction (BTActionType actionType, float param1, float param2, EntityID entity, AIBlackboard_data &blackboard) |
| void | TickEventRoots (class EventQueue &eventQueue, const BehaviorTreeAsset &tree, EntityID entity, AIBlackboard_data &blackboard) |
Data-driven behavior tree system for AI decision making.
This file implements a behavior tree system for creating complex AI behaviors. Behavior trees are hierarchical structures that make decisions based on conditions and execute actions based on those decisions.
Key features:
Definition in file BehaviorTree.h.
|
strong |
Built-in action types for behavior trees.
Predefined actions that can be executed during tree execution.
| Enumerator | |
|---|---|
| SetMoveGoalToLastKnownTargetPos | Move to last seen target position. |
| SetMoveGoalToTarget | Move towards current target. |
| SetMoveGoalToPatrolPoint | Move to next patrol waypoint. |
| MoveToGoal | Execute movement to goal. |
| AttackIfClose | Attack if in range. |
| PatrolPickNextPoint | Select next patrol point. |
| ClearTarget | Clear current target. |
| Idle | Do nothing. |
| WaitRandomTime | Initialize random timer (param1=min, param2=max) |
| ChooseRandomNavigablePoint | Choose navigable point (param1=searchRadius, param2=maxAttempts) |
| RequestPathfinding | Request pathfinding to moveGoal via MoveIntent. |
| FollowPath | Follow the path (check progression) |
| SendMessage | Emit event to EventQueue (param1=EventType enum) |
| MoveTo | Alias for MoveTo action. |
| AttackMelee | Alias for melee attack. |
Definition at line 111 of file BehaviorTree.h.
|
strong |
Built-in condition types for behavior trees.
Predefined conditions that can be checked during tree execution.
Definition at line 87 of file BehaviorTree.h.
|
strong |
Behavior tree node types.
Defines the different types of nodes that can exist in a behavior tree.
Definition at line 53 of file BehaviorTree.h.
Behavior tree node execution status.
Represents the current state of a behavior tree node.
Definition at line 72 of file BehaviorTree.h.
| BTStatus ExecuteBTAction | ( | BTActionType | actionType, |
| float | param1, | ||
| float | param2, | ||
| EntityID | entity, | ||
| AIBlackboard_data & | blackboard | ||
| ) |
Definition at line 636 of file BehaviorTree.cpp.
References AttackIfClose, ChooseRandomNavigablePoint, ClearTarget, Failure, GameEngine::fDt, FollowPath, Gameplay, NavigationMap::Get(), EventQueue::Get(), World::Get(), World::GetComponent(), GetComponentTypeID_Static(), NavigationMap::GetRandomNavigablePoint(), World::HasComponent(), Idle, INVALID_ENTITY_ID, Vector::Magnitude(), MoveToGoal, Message::msg_type, PatrolPickNextPoint, Position_data::position, EventQueue::Push(), RequestPathfinding, Running, SendMessage, SetMoveGoalToLastKnownTargetPos, SetMoveGoalToPatrolPoint, SetMoveGoalToTarget, Success, AttackIntent_data::targetEntity, MoveIntent_data::targetPosition, and WaitRandomTime.
Referenced by ExecuteBTNode().
Here is the call graph for this function:
Here is the caller graph for this function:| BTStatus ExecuteBTCondition | ( | BTConditionType | condType, |
| float | param, | ||
| EntityID | entity, | ||
| const AIBlackboard_data & | blackboard | ||
| ) |
Definition at line 565 of file BehaviorTree.cpp.
References MoveIntent_data::arrivalThreshold, CanAttack, Failure, World::Get(), World::GetComponent(), GetComponentTypeID_Static(), World::HasComponent(), HasMoveGoal, HasNavigableDestination, HasReachedDestination, HasValidPath, HealthBelow, HeardNoise, IsWaitTimerExpired, Vector::Magnitude(), Success, TargetInRange, and TargetVisible.
Referenced by ExecuteBTNode().
Here is the call graph for this function:
Here is the caller graph for this function:| BTStatus ExecuteBTNode | ( | const BTNode & | node, |
| EntityID | entity, | ||
| AIBlackboard_data & | blackboard, | ||
| const BehaviorTreeAsset & | tree | ||
| ) |
Definition at line 450 of file BehaviorTree.cpp.
References Action, Condition, ExecuteBTAction(), ExecuteBTCondition(), ExecuteBTNode(), Failure, GetComponentTypeID_Static(), Inverter, Repeater, Running, Selector, Sequence, and Success.
Referenced by ExecuteBTNode(), BehaviorTreeSystem::Process(), and TickEventRoots().
Here is the call graph for this function:
Here is the caller graph for this function:| void TickEventRoots | ( | class EventQueue & | eventQueue, |
| const BehaviorTreeAsset & | tree, | ||
| EntityID | entity, | ||
| AIBlackboard_data & | blackboard | ||
| ) |
Definition at line 1575 of file BehaviorTree.cpp.
References ExecuteBTNode(), GetComponentTypeID_Static(), Olympe_EventType_AI_DamageDealt, Olympe_EventType_AI_Explosion, Olympe_EventType_AI_Noise, Olympe_EventType_Object_Create, and Olympe_EventType_Object_Destroy.
Referenced by BehaviorTreeSystem::Process().
Here is the call graph for this function:
Here is the caller graph for this function: