diff options
author | madmaxoft <github@xoft.cz> | 2013-08-30 18:10:58 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-08-30 18:10:58 +0200 |
commit | d7a52870003e46858bec65cc76880cecc5de7bb8 (patch) | |
tree | 67d10f543dc8ed0b49da5ecb61cc0d989a246309 /source/Items/ItemThrowable.h | |
parent | Moved throw pos and speed calculation from cProjectileEntity into cPlayer. (diff) | |
download | cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar.gz cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar.bz2 cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar.lz cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar.xz cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar.zst cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Items/ItemThrowable.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/source/Items/ItemThrowable.h b/source/Items/ItemThrowable.h new file mode 100644 index 000000000..dacdb6157 --- /dev/null +++ b/source/Items/ItemThrowable.h @@ -0,0 +1,90 @@ + +// ItemThrowable.h + +// Declares the itemhandlers for throwable items: eggs, snowballs and ender pearls + + + + + +#pragma once + + + + + +class cItemThrowableHandler : + public cItemHandler +{ + typedef cItemHandler super; +public: + cItemThrowableHandler(int a_ItemType, cProjectileEntity::eKind a_ProjectileKind, double a_SpeedCoeff) : + super(a_ItemType), + m_ProjectileKind(a_ProjectileKind), + m_SpeedCoeff(a_SpeedCoeff) + { + } + + + 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 + { + Vector3d Pos = a_Player->GetThrowStartPos(); + Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff; + a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, &Speed); + return true; + } + +protected: + cProjectileEntity::eKind m_ProjectileKind; + double m_SpeedCoeff; +} ; + + + + + +class cItemEggHandler : + public cItemThrowableHandler +{ + typedef cItemThrowableHandler super; +public: + cItemEggHandler(void) : + super(E_ITEM_EGG, cProjectileEntity::pkEgg, 30) + { + } +} ; + + + + +class cItemSnowballHandler : + public cItemThrowableHandler +{ + typedef cItemThrowableHandler super; + +public: + cItemSnowballHandler(void) : + super(E_ITEM_SNOWBALL, cProjectileEntity::pkSnowball, 30) + { + } +} ; + + + + + +class cItemEnderPearlHandler : + public cItemThrowableHandler +{ + typedef cItemThrowableHandler super; + +public: + cItemEnderPearlHandler(void) : + super(E_ITEM_ENDER_PEARL, cProjectileEntity::pkEnderPearl, 30) + { + } +} ; + + + + |