diff options
author | peterbell10 <peterbell10@live.co.uk> | 2017-09-11 23:20:49 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2017-09-11 23:20:49 +0200 |
commit | e225b7f8262df48ad4d7094bc295add3007b0649 (patch) | |
tree | a42e9afcc88cfe6e9d1258458e3ad42764083d0e /src/Items/ItemFishingRod.h | |
parent | cBlockArea: change MakeIndex to return size_t (diff) | |
download | cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar.gz cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar.bz2 cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar.lz cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar.xz cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar.zst cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Items/ItemFishingRod.h | 52 |
1 files changed, 15 insertions, 37 deletions
diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 012f13a6c..0720cb3e1 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -20,8 +20,7 @@ //////////////////////////////////////////////////////////////////////////////// // cFloaterCallback -class cFloaterCallback : - public cEntityCallback +class cFloaterCallback { public: cFloaterCallback(void) : @@ -30,13 +29,14 @@ public: { } - virtual bool Item(cEntity * a_Entity) override + bool operator () (cEntity & a_Entity) { - 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); + 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); return true; } @@ -57,33 +57,6 @@ 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 { @@ -117,8 +90,13 @@ public: if (FloaterInfo.IsAttached()) { - cSweepEntityCallback SweepEntity(a_Player->GetPosition()); - a_World->DoWithEntityByID(FloaterInfo.GetAttachedMobID(), SweepEntity); + a_World->DoWithEntityByID(FloaterInfo.GetAttachedMobID(), [=](cEntity & a_Entity) + { + Vector3d Speed = a_Player->GetPosition() - a_Entity.GetPosition(); + a_Entity.AddSpeed(Speed); + return true; + } + ); } else if (FloaterInfo.CanPickup()) { |