summaryrefslogtreecommitdiffstats
path: root/src/Entities/Floater.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Entities/Floater.cpp45
1 files changed, 8 insertions, 37 deletions
diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp
index eeaa6cf3d..de5824068 100644
--- a/src/Entities/Floater.cpp
+++ b/src/Entities/Floater.cpp
@@ -13,8 +13,7 @@
////////////////////////////////////////////////////////////////////////////////
// cFloaterEntityCollisionCallback
-class cFloaterEntityCollisionCallback :
- public cEntityCallback
+class cFloaterEntityCollisionCallback
{
public:
cFloaterEntityCollisionCallback(cFloater * a_Floater, const Vector3d & a_Pos, const Vector3d & a_NextPos) :
@@ -25,14 +24,14 @@ public:
m_HitEntity(nullptr)
{
}
- virtual bool Item(cEntity * a_Entity) override
+ bool operator () (cEntity & a_Entity)
{
- if (!a_Entity->IsMob()) // Floaters can only pull mobs not other entities.
+ if (!a_Entity.IsMob()) // Floaters can only pull mobs not other entities.
{
return false;
}
- cBoundingBox EntBox(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight());
+ cBoundingBox EntBox(a_Entity.GetPosition(), a_Entity.GetWidth() / 2, a_Entity.GetHeight());
double LineCoeff;
eBlockFace Face;
@@ -47,7 +46,7 @@ public:
{
// The entity is closer than anything we've stored so far, replace it as the potential victim
m_MinCoeff = LineCoeff;
- m_HitEntity = a_Entity;
+ m_HitEntity = &a_Entity;
}
// Don't break the enumeration, we want all the entities
@@ -75,32 +74,6 @@ protected:
-////////////////////////////////////////////////////////////////////////////////
-// cFloaterCheckEntityExist
-class cFloaterCheckEntityExist :
- public cEntityCallback
-{
-public:
- cFloaterCheckEntityExist(void) :
- m_EntityExists(false)
- {
- }
-
- bool Item(cEntity * a_Entity) override
- {
- m_EntityExists = true;
- return false;
- }
-
- bool DoesExist(void) const { return m_EntityExists; }
-protected:
- bool m_EntityExists;
-} ;
-
-
-
-
-
cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, UInt32 a_PlayerID, int a_CountDownTime) :
cEntity(etFloater, a_X, a_Y, a_Z, 0.2, 0.2),
m_BitePos(Vector3d(a_X, a_Y, a_Z)),
@@ -200,18 +173,16 @@ void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
}
- cFloaterCheckEntityExist EntityCallback;
- m_World->DoWithEntityByID(m_PlayerID, EntityCallback);
- if (!EntityCallback.DoesExist()) // The owner doesn't exist anymore. Destroy the floater entity.
+ if (!m_World->DoWithEntityByID(m_PlayerID, [](cEntity &) { return true; })) // The owner doesn't exist anymore. Destroy the floater entity.
{
Destroy(true);
}
if (m_AttachedMobID != cEntity::INVALID_ID)
{
- m_World->DoWithEntityByID(m_AttachedMobID, EntityCallback); // The mob the floater was attached to doesn't exist anymore.
- if (!EntityCallback.DoesExist())
+ if (!m_World->DoWithEntityByID(m_AttachedMobID, [](cEntity &) { return true; }))
{
+ // The mob the floater was attached to doesn't exist anymore.
m_AttachedMobID = cEntity::INVALID_ID;
}
}