summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemFishingRod.h
diff options
context:
space:
mode:
authorSTRWarrior <niels.breuker@hotmail.nl>2013-12-19 22:16:15 +0100
committerSTRWarrior <niels.breuker@hotmail.nl>2013-12-19 22:16:15 +0100
commit018c65b4e3d1e5674e3134281ced640b0e85871f (patch)
tree8daabc1f5c2cf8a6344dfd126ac1b8faed421060 /src/Items/ItemFishingRod.h
parentAdded the Floater files to MCServer.vcproj (diff)
downloadcuberite-018c65b4e3d1e5674e3134281ced640b0e85871f.tar
cuberite-018c65b4e3d1e5674e3134281ced640b0e85871f.tar.gz
cuberite-018c65b4e3d1e5674e3134281ced640b0e85871f.tar.bz2
cuberite-018c65b4e3d1e5674e3134281ced640b0e85871f.tar.lz
cuberite-018c65b4e3d1e5674e3134281ced640b0e85871f.tar.xz
cuberite-018c65b4e3d1e5674e3134281ced640b0e85871f.tar.zst
cuberite-018c65b4e3d1e5674e3134281ced640b0e85871f.zip
Diffstat (limited to '')
-rw-r--r--src/Items/ItemFishingRod.h39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h
index 722c48c04..91c0e9638 100644
--- a/src/Items/ItemFishingRod.h
+++ b/src/Items/ItemFishingRod.h
@@ -11,7 +11,7 @@
#include "../Entities/Floater.h"
#include "../Entities/Entity.h"
-
+#include "../Item.h"
@@ -31,30 +31,45 @@ public:
{
if (a_Player->IsFishing())
{
- class Callbacks : public cEntityCallback
+ class cFloaterCallback :
+ public cEntityCallback
{
public:
- bool CanPickup;
+ cFloaterCallback(void) :
+ m_CanPickup(false)
+ {
+ }
+
+ bool CanPickup(void) const { return m_CanPickup; }
+ Vector3d GetPos(void) const { return m_Pos; }
+
virtual bool Item(cEntity * a_Entity) override
{
- CanPickup = ((cFloater *)a_Entity)->CanPickup();
+ m_CanPickup = ((cFloater *)a_Entity)->CanPickup();
+ m_Pos = Vector3d(a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ());
a_Entity->Destroy(true);
return true;
}
- Callbacks(void) : CanPickup(false) {}
- } Callback;
- a_World->DoWithEntityByID(a_Player->GetFloaterID(), Callback);
+ protected:
+ bool m_CanPickup;
+ Vector3d m_Pos;
+ } Callbacks;
+ a_World->DoWithEntityByID(a_Player->GetFloaterID(), Callbacks);
a_Player->SetIsFishing(false);
- if (Callback.CanPickup)
+
+ if (Callbacks.CanPickup())
{
- a_Player->SendMessage("TODO: Spawn Items.");
- // TODO: Pickups if fishing went correct.
+ cItems Drops;
+ Drops.Add(cItem(E_ITEM_RAW_FISH));
+ Vector3d FloaterPos(Callbacks.GetPos());
+ Vector3d FlyDirection(a_Player->GetPosition() - FloaterPos);
+ a_World->SpawnItemPickups(Drops, FloaterPos.x, FloaterPos.y, FloaterPos.z, FlyDirection.x, FlyDirection.y, FlyDirection.z);
+ // TODO: More types of pickups.
}
-
}
else
{
- cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 5, a_Player->GetUniqueID());
+ cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 7, a_Player->GetUniqueID());
Floater->Initialize(a_World);
a_Player->SetIsFishing(true, Floater->GetUniqueID());
}