diff options
author | STRWarrior <niels.breuker@hotmail.nl> | 2013-12-19 17:34:03 +0100 |
---|---|---|
committer | STRWarrior <niels.breuker@hotmail.nl> | 2013-12-19 17:34:03 +0100 |
commit | d9c8ae37cf332d4be93b7727f0c1899f40362aef (patch) | |
tree | a061e8486c37c015b099929d8203a365c5a97439 /src/Items/ItemFishingRod.h | |
parent | Implented IsFishing, SetIsFishing and GetFloaterID(). (diff) | |
download | cuberite-d9c8ae37cf332d4be93b7727f0c1899f40362aef.tar cuberite-d9c8ae37cf332d4be93b7727f0c1899f40362aef.tar.gz cuberite-d9c8ae37cf332d4be93b7727f0c1899f40362aef.tar.bz2 cuberite-d9c8ae37cf332d4be93b7727f0c1899f40362aef.tar.lz cuberite-d9c8ae37cf332d4be93b7727f0c1899f40362aef.tar.xz cuberite-d9c8ae37cf332d4be93b7727f0c1899f40362aef.tar.zst cuberite-d9c8ae37cf332d4be93b7727f0c1899f40362aef.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Items/ItemFishingRod.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h new file mode 100644 index 000000000..722c48c04 --- /dev/null +++ b/src/Items/ItemFishingRod.h @@ -0,0 +1,63 @@ + +// ItemFishingRod.h + +// Declares the various fishing rod ItemHandlers + + + + + +#pragma once + +#include "../Entities/Floater.h" +#include "../Entities/Entity.h" + + + + + +class cItemFishingRodHandler : + public cItemHandler +{ + typedef cItemHandler super; + +public: + cItemFishingRodHandler(int a_ItemType) : + super(a_ItemType) + { + } + + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + { + if (a_Player->IsFishing()) + { + class Callbacks : public cEntityCallback + { + public: + bool CanPickup; + virtual bool Item(cEntity * a_Entity) override + { + CanPickup = ((cFloater *)a_Entity)->CanPickup(); + a_Entity->Destroy(true); + return true; + } + Callbacks(void) : CanPickup(false) {} + } Callback; + a_World->DoWithEntityByID(a_Player->GetFloaterID(), Callback); + a_Player->SetIsFishing(false); + if (Callback.CanPickup) + { + a_Player->SendMessage("TODO: Spawn Items."); + // TODO: Pickups if fishing went correct. + } + + } + else + { + cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 5, a_Player->GetUniqueID()); + Floater->Initialize(a_World); + a_Player->SetIsFishing(true, Floater->GetUniqueID()); + } + return true; + } +} ;
\ No newline at end of file |