51 for (EntityID entity : m_entities)
55 AIBlackboard_data& blackboard = World::Get().GetComponent<AIBlackboard_data>(entity);
58 if (msg.targetUid == entity)
60 blackboard.lastDamageTaken = currentTime;
61 blackboard.damageAmount = msg.param1;
64 if (!blackboard.hasTarget && msg.deviceId > 0)
66 EntityID attacker = static_cast<EntityID>(msg.deviceId);
67 if (World::Get().IsEntityValid(attacker))
69 blackboard.targetEntity = attacker;
70 blackboard.hasTarget = true;
72 if (World::Get().HasComponent<Position_data>(attacker))
74 const Position_data& attackerPos = World::Get().GetComponent<Position_data>(attacker);
75 blackboard.lastKnownTargetPosition = attackerPos.position;
93 Vector noisePos(msg.param1, msg.param2, 0.0f);
94 float noiseRadius = 500.0f;
96 for (EntityID entity : m_entities)
100 if (!World::Get().HasComponent<Position_data>(entity)) continue;
101 if (!World::Get().HasComponent<AISenses_data>(entity)) continue;
103 Position_data& pos = World::Get().GetComponent<Position_data>(entity);
104 AISenses_data& senses = World::Get().GetComponent<AISenses_data>(entity);
105 AIBlackboard_data& blackboard = World::Get().GetComponent<AIBlackboard_data>(entity);
107 float distance = (pos.position - noisePos).Magnitude();
108 if (distance <= senses.hearingRadius)
110 blackboard.heardNoise = true;
111 blackboard.lastNoisePosition = noisePos;
112 blackboard.noiseCooldown = 3.0f;
254 catch (
const std::exception&
e)
256 SYSTEM_LOG <<
"AIPerceptionSystem Error for Entity " << entity <<
": " <<
e.what() <<
"\n";
310 catch (
const std::exception&
e)
312 SYSTEM_LOG <<
"AIStateTransitionSystem Error for Entity " << entity <<
": " <<
e.what() <<
"\n";
472 float thinkHz = 10.0f;
495 std::cerr <<
"[BehaviorTreeSystem] WARNING: Tree not found: "
567 <<
", Node=" <<
node->name
586 catch (
const std::exception&
e)
588 SYSTEM_LOG <<
"BehaviorTreeSystem Error for Entity " << entity <<
": " <<
e.what() <<
"\n";
643 float speed = 100.0f;
651 speed *=
intent.desiredSpeed;
655 movement.velocity = direction * speed;
657 catch (
const std::exception&
e)
659 SYSTEM_LOG <<
"AIMotionSystem Error for Entity " << entity <<
": " <<
e.what() <<
"\n";
Runtime debugger for behavior tree visualization and inspection.
BTStatus ExecuteBTNode(const BTNode &node, EntityID entity, AIBlackboard_data &blackboard, const BehaviorTreeAsset &tree)
Data-driven behavior tree system for AI decision making.
BTStatus
Behavior tree node execution status.
@ Success
Node completed successfully.
@ Running
Node is currently executing.
Core ECS component definitions.
AIMode
AI behavior modes for NPCs.
ComponentTypeID GetComponentTypeID_Static()
const EntityID INVALID_ENTITY_ID
Olympe::BehaviorTreeDebugWindow * g_btDebugWindow
World and ECS Manager for Olympe Engine.
virtual void Process() override
virtual void RenderDebug() override
virtual void Process() override
bool IsTargetVisible(EntityID entity, EntityID target, float visionRadius, float visionAngle)
void UpdateAIState(EntityID entity)
virtual void Process() override
AIStateTransitionSystem()
virtual void Process() override
static BehaviorTreeManager & Get()
const BehaviorTreeAsset * GetTreeByPath(const std::string &treePath) const
const BehaviorTreeAsset * GetTreeByAnyId(uint32_t treeId) const
virtual void Process() override
std::set< EntityID > m_entities
ComponentSignature requiredSignature
static EventQueue & Get()
static float fDt
Delta time between frames in seconds.
Main debug window for behavior tree runtime visualization.
void AddExecutionEntry(EntityID entity, uint32_t nodeId, const std::string &nodeName, BTStatus status)
Add an execution log entry.
bool IsVisible() const
Check if window is visible.
static World & Get()
Get singleton instance (short form)
bool HasComponent(EntityID entity) const
bool IsEntityValid(EntityID entity) const
T & GetComponent(EntityID entity)
std::unordered_map< EntityID, ComponentSignature > m_entitySignatures
float fleeHealthThreshold
Represents a single node in a behavior tree.
Identity component for entity identification.
Position component for spatial location.
Vector position
2D/3D position vector
@ Olympe_EventType_Game_TakeScreenshot