summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemFishingRod.h
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-09-02 12:35:22 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-09-02 12:35:22 +0200
commit07a5bf0984559d04fce1091b82b0952217ac64cc (patch)
tree0d1eee372a782213c9e2b84deaefe717b379a04b /src/Items/ItemFishingRod.h
parentSkeletons (diff)
parentRevert "Replace ItemCallbacks with lambdas (#3948)" (diff)
downloadcuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.gz
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.bz2
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.lz
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.xz
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.zst
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.zip
Diffstat (limited to 'src/Items/ItemFishingRod.h')
-rw-r--r--src/Items/ItemFishingRod.h52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h
index 0720cb3e1..012f13a6c 100644
--- a/src/Items/ItemFishingRod.h
+++ b/src/Items/ItemFishingRod.h
@@ -20,7 +20,8 @@
////////////////////////////////////////////////////////////////////////////////
// cFloaterCallback
-class cFloaterCallback
+class cFloaterCallback :
+ public cEntityCallback
{
public:
cFloaterCallback(void) :
@@ -29,14 +30,13 @@ public:
{
}
- bool operator () (cEntity & a_Entity)
+ virtual bool Item(cEntity * a_Entity) override
{
- auto & Floater = static_cast<cFloater &>(a_Entity);
- m_CanPickup = Floater.CanPickup();
- m_Pos = Floater.GetPosition();
- m_BitePos = Floater.GetBitePos();
- m_AttachedMobID = Floater.GetAttachedMobID();
- Floater.Destroy(true);
+ m_CanPickup = reinterpret_cast<cFloater *>(a_Entity)->CanPickup();
+ m_Pos = Vector3d(a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ());
+ m_BitePos = reinterpret_cast<cFloater *>(a_Entity)->GetBitePos();
+ m_AttachedMobID = reinterpret_cast<cFloater *>(a_Entity)->GetAttachedMobID();
+ a_Entity->Destroy(true);
return true;
}
@@ -57,6 +57,33 @@ protected:
+////////////////////////////////////////////////////////////////////////////////
+// cSweepEntityCallback:
+
+class cSweepEntityCallback :
+ public cEntityCallback
+{
+public:
+ cSweepEntityCallback(Vector3d a_PlayerPos) :
+ m_PlayerPos(a_PlayerPos)
+ {
+ }
+
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ Vector3d Speed = m_PlayerPos - a_Entity->GetPosition();
+ a_Entity->AddSpeed(Speed);
+ return true;
+ }
+
+protected:
+ Vector3d m_PlayerPos;
+} ;
+
+
+
+
+
class cItemFishingRodHandler :
public cItemHandler
{
@@ -90,13 +117,8 @@ public:
if (FloaterInfo.IsAttached())
{
- a_World->DoWithEntityByID(FloaterInfo.GetAttachedMobID(), [=](cEntity & a_Entity)
- {
- Vector3d Speed = a_Player->GetPosition() - a_Entity.GetPosition();
- a_Entity.AddSpeed(Speed);
- return true;
- }
- );
+ cSweepEntityCallback SweepEntity(a_Player->GetPosition());
+ a_World->DoWithEntityByID(FloaterInfo.GetAttachedMobID(), SweepEntity);
}
else if (FloaterInfo.CanPickup())
{