summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Behaviors
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-08-22 12:53:41 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-08-22 19:55:30 +0200
commit8b105ee51a5fcd67c861de04466e3ca2e1cacefa (patch)
tree2c7a4cb3c70cd691c943783b2ca935460bd285a7 /src/Mobs/Behaviors
parentd (diff)
downloadcuberite-8b105ee51a5fcd67c861de04466e3ca2e1cacefa.tar
cuberite-8b105ee51a5fcd67c861de04466e3ca2e1cacefa.tar.gz
cuberite-8b105ee51a5fcd67c861de04466e3ca2e1cacefa.tar.bz2
cuberite-8b105ee51a5fcd67c861de04466e3ca2e1cacefa.tar.lz
cuberite-8b105ee51a5fcd67c861de04466e3ca2e1cacefa.tar.xz
cuberite-8b105ee51a5fcd67c861de04466e3ca2e1cacefa.tar.zst
cuberite-8b105ee51a5fcd67c861de04466e3ca2e1cacefa.zip
Diffstat (limited to 'src/Mobs/Behaviors')
-rw-r--r--src/Mobs/Behaviors/BehaviorItemFollower.cpp48
-rw-r--r--src/Mobs/Behaviors/BehaviorItemFollower.h11
2 files changed, 27 insertions, 32 deletions
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<cMonster *>(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;
};