From 8b105ee51a5fcd67c861de04466e3ca2e1cacefa Mon Sep 17 00:00:00 2001 From: LogicParrot Date: Tue, 22 Aug 2017 13:53:41 +0300 Subject: d --- src/Mobs/Behaviors/BehaviorItemFollower.cpp | 48 +++++++++++++---------------- src/Mobs/Behaviors/BehaviorItemFollower.h | 11 +++---- 2 files changed, 27 insertions(+), 32 deletions(-) (limited to 'src/Mobs/Behaviors') diff --git a/src/Mobs/Behaviors/BehaviorItemFollower.cpp b/src/Mobs/Behaviors/BehaviorItemFollower.cpp index 7cc0f8dfc..89e25ed57 100644 --- a/src/Mobs/Behaviors/BehaviorItemFollower.cpp +++ b/src/Mobs/Behaviors/BehaviorItemFollower.cpp @@ -5,16 +5,12 @@ #include "../../World.h" #include "../../Entities/Player.h" -iBehaviorItemFollower::~iBehaviorItemFollower() -{ - -} -cBehaviorItemFollower::cBehaviorItemFollower(iBehaviorItemFollower * a_ParentInterface) : - m_ParentInterface(a_ParentInterface) +cBehaviorItemFollower::cBehaviorItemFollower(cMonster * a_Parent) : + m_ParentInterface(a_ParentInterface) { - m_Parent = dynamic_cast(m_ParentInterface); - ASSERT(m_Parent != nullptr); + m_Parent = a_Parent; + ASSERT(m_Parent != nullptr); } @@ -23,22 +19,22 @@ cBehaviorItemFollower::cBehaviorItemFollower(iBehaviorItemFollower * a_ParentInt bool cBehaviorItemFollower::ActiveTick() { - cWorld * World = m_Parent->GetWorld(); - cItems FollowedItems; - m_ParentInterface->GetFollowedItems(FollowedItems); - if (FollowedItems.Size() > 0) - { - cPlayer * a_Closest_Player = m_Parent->GetNearestPlayer(); - if (a_Closest_Player != nullptr) - { - cItem EquippedItem = a_Closest_Player->GetEquippedItem(); - if (FollowedItems.ContainsType(EquippedItem)) - { - Vector3d PlayerPos = a_Closest_Player->GetPosition(); - m_Parent->MoveToPosition(PlayerPos); - return true; // We took control of the monster, prevent other Behaviors from doing so - } - } - } - return false; + cWorld * World = m_Parent->GetWorld(); + cItems FollowedItems; + m_ParentInterface->GetFollowedItems(FollowedItems); + if (FollowedItems.Size() > 0) + { + cPlayer * a_Closest_Player = m_Parent->GetNearestPlayer(); + if (a_Closest_Player != nullptr) + { + cItem EquippedItem = a_Closest_Player->GetEquippedItem(); + if (FollowedItems.ContainsType(EquippedItem)) + { + Vector3d PlayerPos = a_Closest_Player->GetPosition(); + m_Parent->MoveToPosition(PlayerPos); + return true; // We took control of the monster, prevent other Behaviors from doing so + } + } + } + return false; } diff --git a/src/Mobs/Behaviors/BehaviorItemFollower.h b/src/Mobs/Behaviors/BehaviorItemFollower.h index ed47dab04..2abdeb381 100644 --- a/src/Mobs/Behaviors/BehaviorItemFollower.h +++ b/src/Mobs/Behaviors/BehaviorItemFollower.h @@ -16,14 +16,13 @@ class cItems; class cBehaviorItemFollower { public: - cBehaviorItemFollower(iBehaviorItemFollower * a_Parent); + cBehaviorItemFollower(cMonster * a_Parent); - // Functions our host Monster should invoke: - bool ActiveTick(); + // Functions our host Monster should invoke: + bool ActiveTick(); private: - /** Our parent */ - iBehaviorItemFollower * m_ParentInterface; - cMonster * m_Parent; + /** Our parent */ + cMonster * m_Parent; }; -- cgit v1.2.3