diff options
author | madmaxoft <github@xoft.cz> | 2013-08-25 21:31:35 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-08-25 21:31:35 +0200 |
commit | da3e24863274a80f4bda0251e678ec354c8d59e6 (patch) | |
tree | be1b541ba6ba5008700b3938364174fc9c5ab7de /source/Entities | |
parent | Moved entity spawning into cEntity::Initialize(). (diff) | |
download | cuberite-da3e24863274a80f4bda0251e678ec354c8d59e6.tar cuberite-da3e24863274a80f4bda0251e678ec354c8d59e6.tar.gz cuberite-da3e24863274a80f4bda0251e678ec354c8d59e6.tar.bz2 cuberite-da3e24863274a80f4bda0251e678ec354c8d59e6.tar.lz cuberite-da3e24863274a80f4bda0251e678ec354c8d59e6.tar.xz cuberite-da3e24863274a80f4bda0251e678ec354c8d59e6.tar.zst cuberite-da3e24863274a80f4bda0251e678ec354c8d59e6.zip |
Diffstat (limited to 'source/Entities')
-rw-r--r-- | source/Entities/ProjectileEntity.cpp | 17 | ||||
-rw-r--r-- | source/Entities/ProjectileEntity.h | 8 |
2 files changed, 25 insertions, 0 deletions
diff --git a/source/Entities/ProjectileEntity.cpp b/source/Entities/ProjectileEntity.cpp index e87f72eed..66d9409f5 100644 --- a/source/Entities/ProjectileEntity.cpp +++ b/source/Entities/ProjectileEntity.cpp @@ -6,6 +6,7 @@ #include "Globals.h" #include "ProjectileEntity.h" #include "../ClientHandle.h" +#include "Player.h" @@ -98,6 +99,22 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a +bool cArrowEntity::CanPickup(const cPlayer & a_Player) const +{ + switch (m_PickupState) + { + case psNoPickup: return false; + case psInSurvivalOrCreative: return (a_Player.IsGameModeSurvival() || a_Player.IsGameModeCreative()); + case psInCreative: return a_Player.IsGameModeCreative(); + } + ASSERT(!"Unhandled pickup state"); + return false; +} + + + + + void cArrowEntity::SpawnOn(cClientHandle & a_Client) { a_Client.SendSpawnObject(*this, pkArrow, 0, 0, 0); diff --git a/source/Entities/ProjectileEntity.h b/source/Entities/ProjectileEntity.h index 8c6791e2e..cf107e15b 100644 --- a/source/Entities/ProjectileEntity.h +++ b/source/Entities/ProjectileEntity.h @@ -40,6 +40,8 @@ public: // tolua_end + CLASS_PROTODEF(cProjectileEntity); + cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height); @@ -92,9 +94,13 @@ public: // tolua_end + CLASS_PROTODEF(cArrowEntity); + /// Creates a new arrow with psNoPickup state and default damage modifier coeff cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d a_Speed); + // tolua_begin + /// Returns whether the arrow can be picked up by players ePickupState GetPickupState(void) const { return m_PickupState; } @@ -110,6 +116,8 @@ public: /// Returns true if the specified player can pick the arrow up bool CanPickup(const cPlayer & a_Player) const; + // tolua_end + protected: /// Determines when the arrow can be picked up by players |