From b0696ca6217bdcc72c22ae11f8993d3d36f1c129 Mon Sep 17 00:00:00 2001 From: LogicParrot Date: Tue, 29 Aug 2017 20:41:42 +0300 Subject: Horse --- src/Mobs/AggressiveMonster.cpp | 21 --------------------- src/Mobs/Horse.cpp | 22 ++++++++++++++++++++++ src/Mobs/Horse.h | 11 +++++++++++ 3 files changed, 33 insertions(+), 21 deletions(-) (limited to 'src/Mobs') 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(&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; -- cgit v1.2.3