diff options
Diffstat (limited to 'src/Mobs/Behaviors')
-rw-r--r-- | src/Mobs/Behaviors/Behavior.cpp | 24 | ||||
-rw-r--r-- | src/Mobs/Behaviors/Behavior.h | 15 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorAggressive.h | 2 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorBreeder.h | 6 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorChaser.cpp | 15 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorChaser.h | 6 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorCoward.h | 4 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorDayLightBurner.cpp | 3 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorDayLightBurner.h | 7 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorItemFollower.h | 4 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorWanderer.h | 1 |
11 files changed, 60 insertions, 27 deletions
diff --git a/src/Mobs/Behaviors/Behavior.cpp b/src/Mobs/Behaviors/Behavior.cpp index 7b54a3340..695343732 100644 --- a/src/Mobs/Behaviors/Behavior.cpp +++ b/src/Mobs/Behaviors/Behavior.cpp @@ -6,8 +6,10 @@ -bool cBehavior::IsControlDesired() +bool cBehavior::IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { + UNUSED(a_Dt); + UNUSED(a_Chunk); LOGD("ERROR: Probably forgot to implement cBehavior::IsControlDesired but implement cBehavior::Tick"); return false; } @@ -16,8 +18,10 @@ bool cBehavior::IsControlDesired() -bool cBehavior::ControlStarting() +bool cBehavior::ControlStarting(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { + UNUSED(a_Dt); + UNUSED(a_Chunk); return true; } @@ -25,8 +29,10 @@ bool cBehavior::ControlStarting() -bool cBehavior::ControlEnding() +bool cBehavior::ControlEnding(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { + UNUSED(a_Dt); + UNUSED(a_Chunk); return true; } @@ -34,8 +40,10 @@ bool cBehavior::ControlEnding() -void cBehavior::Tick() +void cBehavior::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { + UNUSED(a_Dt); + UNUSED(a_Chunk); LOGD("ERROR: Called a TICK on a behavior that doesn't have one."); ASSERT(1 == 0); } @@ -44,8 +52,10 @@ void cBehavior::Tick() -void cBehavior::PostTick() +void cBehavior::PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { + UNUSED(a_Dt); + UNUSED(a_Chunk); LOGD("ERROR: Called a PostTick on a behavior that doesn't have one."); ASSERT(1 == 0); } @@ -54,8 +64,10 @@ void cBehavior::PostTick() -void cBehavior::PreTick() +void cBehavior::PreTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { + UNUSED(a_Dt); + UNUSED(a_Chunk); LOGD("ERROR: Called a PreTick on a behavior that doesn't have one."); ASSERT(1 == 0); } diff --git a/src/Mobs/Behaviors/Behavior.h b/src/Mobs/Behaviors/Behavior.h index 81499eade..989addf8d 100644 --- a/src/Mobs/Behaviors/Behavior.h +++ b/src/Mobs/Behaviors/Behavior.h @@ -1,15 +1,18 @@ #pragma once struct TakeDamageInfo; +class cChunk; +#include <chrono> + class cBehavior { public: - virtual bool IsControlDesired(); - virtual bool ControlStarting(); - virtual bool ControlEnding(); - virtual void Tick(); - virtual void PostTick(); - virtual void PreTick(); + virtual bool IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); + virtual bool ControlStarting(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); + virtual bool ControlEnding(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); + virtual void PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); + virtual void PreTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); virtual void onRightClicked(); diff --git a/src/Mobs/Behaviors/BehaviorAggressive.h b/src/Mobs/Behaviors/BehaviorAggressive.h index 14dfc1ab0..5bf86b23f 100644 --- a/src/Mobs/Behaviors/BehaviorAggressive.h +++ b/src/Mobs/Behaviors/BehaviorAggressive.h @@ -26,7 +26,7 @@ public: // Agression under specific conditions (nighttime, etc) // Functions our host Monster should invoke: - void PreTick() override; + void PreTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; private: cPawn * FindNewTarget(); diff --git a/src/Mobs/Behaviors/BehaviorBreeder.h b/src/Mobs/Behaviors/BehaviorBreeder.h index d95840f5e..cf030b8f3 100644 --- a/src/Mobs/Behaviors/BehaviorBreeder.h +++ b/src/Mobs/Behaviors/BehaviorBreeder.h @@ -21,9 +21,9 @@ public: cBehaviorBreeder(cMonster * a_Parent); // Functions our host Monster should invoke: - bool IsControlDesired() override; - void Tick() override; - void PostTick() override; + bool IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + void PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; void OnRightClicked(cPlayer & a_Player); void Destroyed() override; diff --git a/src/Mobs/Behaviors/BehaviorChaser.cpp b/src/Mobs/Behaviors/BehaviorChaser.cpp index 71a50c55b..c486c049a 100644 --- a/src/Mobs/Behaviors/BehaviorChaser.cpp +++ b/src/Mobs/Behaviors/BehaviorChaser.cpp @@ -36,6 +36,21 @@ bool cBehaviorChaser::IsControlDesired() void cBehaviorChaser::Tick() { + /* + * if ((GetTarget() != nullptr)) + { + ASSERT(GetTarget()->IsTicking()); + + if (GetTarget()->IsPlayer()) + { + if (!static_cast<cPlayer *>(GetTarget())->CanMobsTarget()) + { + SetTarget(nullptr); + } + } + } //mobTodo copied from monster.cpp + * */ + ASSERT((GetTarget() == nullptr) || (GetTarget()->IsPawn() && (GetTarget()->GetWorld() == m_Parent->GetWorld()))); // Stop targeting out of range targets if (GetTarget() != nullptr) diff --git a/src/Mobs/Behaviors/BehaviorChaser.h b/src/Mobs/Behaviors/BehaviorChaser.h index b71d503b3..d0910e11e 100644 --- a/src/Mobs/Behaviors/BehaviorChaser.h +++ b/src/Mobs/Behaviors/BehaviorChaser.h @@ -20,10 +20,10 @@ public: cBehaviorChaser(cMonster * a_Parent); // Functions our host Monster should invoke: - bool IsControlDesired() override; - void Tick() override; + bool IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; void Destroyed() override; - void PostTick() override; + void PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; void DoTakeDamage(TakeDamageInfo & a_TDI) override; // Our host monster will call these once it loads its config file diff --git a/src/Mobs/Behaviors/BehaviorCoward.h b/src/Mobs/Behaviors/BehaviorCoward.h index 13deece61..048101d5d 100644 --- a/src/Mobs/Behaviors/BehaviorCoward.h +++ b/src/Mobs/Behaviors/BehaviorCoward.h @@ -16,8 +16,8 @@ public: cBehaviorCoward(cMonster * a_Parent); // Functions our host Monster should invoke: - bool IsControlDesired() override; - void Tick() override; + bool IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; void DoTakeDamage(TakeDamageInfo & a_TDI) override; diff --git a/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp b/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp index 062d60bae..81307f36a 100644 --- a/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp +++ b/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp @@ -12,8 +12,9 @@ cBehaviorDayLightBurner::cBehaviorDayLightBurner(cMonster * a_Parent) : m_Parent ASSERT(m_Parent != nullptr); } -void cBehaviorDayLightBurner::PostTick(cChunk & a_Chunk, bool WouldBurn) +void cBehaviorDayLightBurner::PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { + // mobTodo WouldBurn int RelY = static_cast<int>(m_Parent->GetPosY()); if ((RelY < 0) || (RelY >= cChunkDef::Height)) { diff --git a/src/Mobs/Behaviors/BehaviorDayLightBurner.h b/src/Mobs/Behaviors/BehaviorDayLightBurner.h index f059965c5..77fcce281 100644 --- a/src/Mobs/Behaviors/BehaviorDayLightBurner.h +++ b/src/Mobs/Behaviors/BehaviorDayLightBurner.h @@ -1,6 +1,7 @@ #pragma once // mobTodo I just need vector3d +#include "Behavior.h" #include "../../World.h" // fwds @@ -8,16 +9,16 @@ class cMonster; class cEntity; class cChunk; -class cBehaviorDayLightBurner +class cBehaviorDayLightBurner : cBehavior { public: cBehaviorDayLightBurner(cMonster * a_Parent); - void PostTick(cChunk & a_Chunk, bool WouldBurn); + void PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); bool WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk); // Functions our host Monster should invoke: - void Tick(); + void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); private: cMonster * m_Parent; // Our Parent diff --git a/src/Mobs/Behaviors/BehaviorItemFollower.h b/src/Mobs/Behaviors/BehaviorItemFollower.h index ab33de65f..94f8bda15 100644 --- a/src/Mobs/Behaviors/BehaviorItemFollower.h +++ b/src/Mobs/Behaviors/BehaviorItemFollower.h @@ -17,8 +17,8 @@ public: void GetBreedingItems(cItems & a_Items); // Functions our host Monster should invoke: - bool IsControlDesired() override; - void Tick() override; + bool IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; private: diff --git a/src/Mobs/Behaviors/BehaviorWanderer.h b/src/Mobs/Behaviors/BehaviorWanderer.h index 23d86f0d2..258bf5f59 100644 --- a/src/Mobs/Behaviors/BehaviorWanderer.h +++ b/src/Mobs/Behaviors/BehaviorWanderer.h @@ -1,6 +1,7 @@ #pragma once // The mob will wander around +#include <chrono> class cMonster; class cEntity; |