diff options
author | jjesswan <jessica_wan@brown.edu> | 2024-04-22 21:56:26 -0400 |
---|---|---|
committer | jjesswan <jessica_wan@brown.edu> | 2024-04-22 21:56:26 -0400 |
commit | a556b45abf18f1bd509daaf63b66b7d55e9fd291 (patch) | |
tree | bc9b8a2d184c12aee236e7f9f276a34b84ca552d /engine-ocean/Game/Systems/AI/aibehaviorcomponent.cpp | |
parent | cd7c76017a12bb548036571c1ff13e551369d06d (diff) |
add engine version
Diffstat (limited to 'engine-ocean/Game/Systems/AI/aibehaviorcomponent.cpp')
-rw-r--r-- | engine-ocean/Game/Systems/AI/aibehaviorcomponent.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/engine-ocean/Game/Systems/AI/aibehaviorcomponent.cpp b/engine-ocean/Game/Systems/AI/aibehaviorcomponent.cpp new file mode 100644 index 0000000..b43ed07 --- /dev/null +++ b/engine-ocean/Game/Systems/AI/aibehaviorcomponent.cpp @@ -0,0 +1,46 @@ +#include "aibehaviorcomponent.h" +#include "Game/Systems/AI/Actions/walkaction.h" +#include "Game/Systems/AI/Conditions/proximitycondition.h" +#include "Game/Systems/AI/btselector.h" +#include "Game/Systems/AI/btsequence.h" + +AIBehaviorComponent::AIBehaviorComponent(std::string entity_id, + std::map<std::string, BlackboardData>& global_blackboard): + m_global_blackboard(global_blackboard) +{ + m_entity_id = entity_id; + makeBehaviorTree(); + +} + +void AIBehaviorComponent::makeBehaviorTree(){ + // leaves + //std::unique_ptr<BTNode> walk = std::make_unique<WalkAction>(m_entity_id, m_global_blackboard); + BTNode *proximCond = new ProximityCondition(m_entity_id, m_global_blackboard, 20.f); + BTNode *walk = new WalkAction(m_entity_id, m_global_blackboard); + + +// // pathfind sequence + BTNode *pathfindSeq = new BTSequence; + pathfindSeq->addChildren(proximCond); + pathfindSeq->addChildren(walk); + +// // idle sequence + +// // root + m_root = new BTSelector; + m_root->addChildren(pathfindSeq); +} + +// how might i be able to generalize the creation of the tree? +void AIBehaviorComponent::update(float seconds){ + // update root, which updates all its children + //std::cout << "---------in ai system" << std::endl; + + m_status = m_root->update(seconds); +} + +AIBehaviorComponent::~AIBehaviorComponent(){ + delete m_root; +} + |