diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-29 19:41:42 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-29 19:41:42 +0200 |
commit | b0696ca6217bdcc72c22ae11f8993d3d36f1c129 (patch) | |
tree | 7be48a4c5d9a81b1a9da49ac98d9bb5d181541fa /src/Mobs | |
parent | Implemented sheep, mooshroom, rabbit, chicken, pig, villager (diff) | |
download | cuberite-b0696ca6217bdcc72c22ae11f8993d3d36f1c129.tar cuberite-b0696ca6217bdcc72c22ae11f8993d3d36f1c129.tar.gz cuberite-b0696ca6217bdcc72c22ae11f8993d3d36f1c129.tar.bz2 cuberite-b0696ca6217bdcc72c22ae11f8993d3d36f1c129.tar.lz cuberite-b0696ca6217bdcc72c22ae11f8993d3d36f1c129.tar.xz cuberite-b0696ca6217bdcc72c22ae11f8993d3d36f1c129.tar.zst cuberite-b0696ca6217bdcc72c22ae11f8993d3d36f1c129.zip |
Diffstat (limited to 'src/Mobs')
-rw-r--r-- | src/Mobs/AggressiveMonster.cpp | 21 | ||||
-rw-r--r-- | src/Mobs/Horse.cpp | 22 | ||||
-rw-r--r-- | src/Mobs/Horse.h | 11 |
3 files changed, 33 insertions, 21 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index 0e6911305..f06412e49 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -27,25 +27,4 @@ cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eMonsterTyp void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - - /* cBehaviorChaser * BehaviorChaser = GetBehaviorChaser(); - cBehaviorWanderer * BehaviorWanderer = GetBehaviorWanderer(); - - for (;;) - { - m_BehaviorAggressive.Tick(); - if (BehaviorChaser->Tick()) - { - break; - } - if ((BehaviorWanderer != nullptr) && BehaviorWanderer->ActiveTick(a_Dt, a_Chunk)) - { - break; - } - - ASSERT(!"Not a single Behavior took control, this is not normal. "); - break; - } - - BehaviorChaser->Tick();*/ } diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp index 484864afe..247de9699 100644 --- a/src/Mobs/Horse.cpp +++ b/src/Mobs/Horse.cpp @@ -28,6 +28,10 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) : m_MaxSpeed(14.0) { m_EMPersonality = PASSIVE; + m_BehaviorBreeder.AttachToMonster(*this); + m_BehaviorCoward.AttachToMonster(*this); + m_BehaviorItemFollower.AttachToMonster(*this); + m_BehaviorWanderer.AttachToMonster(*this); } @@ -193,3 +197,21 @@ void cHorse::HandleSpeedFromAttachee(float a_Forward, float a_Sideways) super::HandleSpeedFromAttachee(a_Forward * m_MaxSpeed, a_Sideways * m_MaxSpeed); } } + + + + + +cBehaviorBreeder * cHorse::GetBehaviorBreeder() +{ + return &m_BehaviorBreeder; +} + + + + + +const cBehaviorBreeder * cHorse::GetBehaviorBreeder() const +{ + return static_cast<const cBehaviorBreeder *>(&m_BehaviorBreeder); +} diff --git a/src/Mobs/Horse.h b/src/Mobs/Horse.h index 60e9c5b71..3c5a50671 100644 --- a/src/Mobs/Horse.h +++ b/src/Mobs/Horse.h @@ -1,6 +1,10 @@ #pragma once +#include "Behaviors/BehaviorBreeder.h" +#include "Behaviors/BehaviorItemFollower.h" +#include "Behaviors/BehaviorCoward.h" +#include "Behaviors/BehaviorWanderer.h" #include "Monster.h" @@ -39,7 +43,14 @@ public: a_Items.Add(E_ITEM_GOLDEN_APPLE); } + virtual cBehaviorBreeder * GetBehaviorBreeder() override; + virtual const cBehaviorBreeder * GetBehaviorBreeder() const override; private: + // Tick controlling behaviors + cBehaviorBreeder m_BehaviorBreeder; + cBehaviorItemFollower m_BehaviorItemFollower; + cBehaviorCoward m_BehaviorCoward; + cBehaviorWanderer m_BehaviorWanderer; bool m_bHasChest, m_bIsEating, m_bIsRearing, m_bIsMouthOpen, m_bIsTame, m_bIsSaddled; int m_Type, m_Color, m_Style, m_Armour, m_TimesToTame, m_TameAttemptTimes, m_RearTickCount; |