diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-22 12:23:03 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-22 19:55:30 +0200 |
commit | 80d9c26c12a5be619a757d0251525664bf7065a6 (patch) | |
tree | 66d4f553ae12fd90dd94ffde9b85f595319ba5cb /src/Mobs/Behaviors/BehaviorAggressive.cpp | |
parent | Added check in cEntity::TickBurning for whether the entity is planning to change worlds. (#3943) (diff) | |
download | cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar.gz cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar.bz2 cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar.lz cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar.xz cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar.zst cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/Behaviors/BehaviorAggressive.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/Mobs/Behaviors/BehaviorAggressive.cpp b/src/Mobs/Behaviors/BehaviorAggressive.cpp new file mode 100644 index 000000000..74eee0e17 --- /dev/null +++ b/src/Mobs/Behaviors/BehaviorAggressive.cpp @@ -0,0 +1,49 @@ +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "BehaviorAggressive.h" +#include "BehaviorChaser.h" +#include "../Monster.h" +#include "../../Chunk.h" +#include "../../Entities/Player.h" + + + +cBehaviorAggressive::cBehaviorAggressive(cMonster * a_Parent) : m_Parent(a_Parent) +{ + ASSERT(m_Parent != nullptr); + m_ParentChaser = m_Parent->GetBehaviorChaser(); + ASSERT(m_ParentChaser != nullptr); +} + + + + + +bool cBehaviorAggressive::ActiveTick() +{ + // Target something new if we have no target + if (m_ParentChaser->GetTarget() == nullptr) + { + m_ParentChaser->SetTarget(FindNewTarget()); + } + return false; +} + + + + + +void cBehaviorAggressive::Destroyed() +{ + m_Target = nullptr; +} + + + + + +bool cBehaviorAggressive::FindNewTarget() +{ + cPlayer * Closest = m_Parent->GetNearestPlayer(); + return Closest; // May be null +} |