diff options
author | Mattes D <github@xoft.cz> | 2014-08-01 17:43:02 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-08-01 17:43:02 +0200 |
commit | 35cfbfd51a15233bb0860804c525597d95260300 (patch) | |
tree | b11052934d85badc24e2d17ef1e51b5ea64040ec /src/BlockEntities/BeaconEntity.h | |
parent | Merge pull request #1270 from Howaner/Options (diff) | |
parent | Use "default:" in switch. (diff) | |
download | cuberite-35cfbfd51a15233bb0860804c525597d95260300.tar cuberite-35cfbfd51a15233bb0860804c525597d95260300.tar.gz cuberite-35cfbfd51a15233bb0860804c525597d95260300.tar.bz2 cuberite-35cfbfd51a15233bb0860804c525597d95260300.tar.lz cuberite-35cfbfd51a15233bb0860804c525597d95260300.tar.xz cuberite-35cfbfd51a15233bb0860804c525597d95260300.tar.zst cuberite-35cfbfd51a15233bb0860804c525597d95260300.zip |
Diffstat (limited to 'src/BlockEntities/BeaconEntity.h')
-rw-r--r-- | src/BlockEntities/BeaconEntity.h | 79 |
1 files changed, 64 insertions, 15 deletions
diff --git a/src/BlockEntities/BeaconEntity.h b/src/BlockEntities/BeaconEntity.h index ee1eda391..0d7150aef 100644 --- a/src/BlockEntities/BeaconEntity.h +++ b/src/BlockEntities/BeaconEntity.h @@ -1,7 +1,14 @@ +// BeaconEntity.h + +// Declares the cBeaconEntity class representing a single beacon in the world + + + + #pragma once -#include "BlockEntity.h" +#include "BlockEntityWithItems.h" @@ -16,28 +23,70 @@ namespace Json +// tolua_begin class cBeaconEntity : - public cBlockEntity + public cBlockEntityWithItems { - typedef cBlockEntity super; + typedef cBlockEntityWithItems super; public: - - /** The initial constructor */ + // tolua_end + cBeaconEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); - - /** Returns the amount of layers the pyramid below the beacon has. */ - int GetPyramidLevel(void); + + bool LoadFromJson(const Json::Value & a_Value); + // cBlockEntity overrides: + virtual void SaveToJson(Json::Value& a_Value) override; + virtual void SendTo(cClientHandle & a_Client) override; + virtual bool Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void UsedBy(cPlayer * a_Player) override; + + /** Modify the beacon level. (It is needed to load the beacon corectly) */ + void SetBeaconLevel(char a_Level) { m_BeaconLevel = a_Level; } + + // tolua_begin + + /** Is the beacon active? */ + bool IsActive(void) const { return m_IsActive; } + + /** Returns the beacon level. (0 - 4) */ + char GetBeaconLevel(void) const { return m_BeaconLevel; } + + cEntityEffect::eType GetPrimaryEffect(void) const { return m_PrimaryEffect; } + cEntityEffect::eType GetSecondaryEffect(void) const { return m_SecondaryEffect; } + + /** Sets the primary effect. Returns false when the effect is invalid. */ + bool SetPrimaryEffect(cEntityEffect::eType a_Effect); + + /** Sets the secondary effect. Returns false when the effect is invalid. */ + bool SetSecondaryEffect(cEntityEffect::eType a_Effect); + + /** Calculate the amount of layers the pyramid below the beacon has. */ + char CalculatePyramidLevel(void); + + /** Is the beacon blocked by non-transparent blocks that are higher than the beacon? */ + bool IsBeaconBlocked(void); + + /** Update the beacon. */ + void UpdateBeacon(void); + + /** Give the near-players the effects. */ + void GiveEffects(void); /** Returns true if the block is a diamond block, a golden block, an iron block or an emerald block. */ static bool IsMineralBlock(BLOCKTYPE a_BlockType); - - // cBlockEntity overrides: - virtual void SaveToJson(Json::Value& a_Value) override; - virtual void SendTo(cClientHandle & a_Client) override; - virtual void UsedBy(cPlayer * a_Player) override; - virtual bool Tick(float a_Dt, cChunk & /* a_Chunk */) override; -} ; + + /** Returns true if the effect can be used. */ + static bool IsValidEffect(cEntityEffect::eType a_Effect, char a_BeaconLevel); + + // tolua_end + +protected: + bool m_IsActive; + char m_BeaconLevel; + + cEntityEffect::eType m_PrimaryEffect, m_SecondaryEffect; +} ; // tolua_export |