2014-11-18 09:33:41 -05:00
|
|
|
|
2014-07-30 16:19:51 -04:00
|
|
|
// BeaconEntity.h
|
|
|
|
|
|
|
|
// Declares the cBeaconEntity class representing a single beacon in the world
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-11 18:01:15 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-07-30 15:59:35 -04:00
|
|
|
#include "BlockEntityWithItems.h"
|
2014-04-11 18:01:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-30 16:19:51 -04:00
|
|
|
// tolua_begin
|
2020-10-20 07:28:45 -04:00
|
|
|
class cBeaconEntity :
|
2014-07-30 15:59:35 -04:00
|
|
|
public cBlockEntityWithItems
|
2014-04-11 18:01:15 -04:00
|
|
|
{
|
2014-07-30 16:19:51 -04:00
|
|
|
// tolua_end
|
|
|
|
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cBlockEntityWithItems;
|
2019-09-29 08:59:24 -04:00
|
|
|
|
|
|
|
public: // tolua_export
|
|
|
|
|
|
|
|
cBeaconEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
|
2014-07-30 15:59:35 -04:00
|
|
|
|
2014-07-30 16:19:51 -04:00
|
|
|
// cBlockEntity overrides:
|
2017-06-15 09:32:33 -04:00
|
|
|
virtual void CopyFrom(const cBlockEntity & a_Src) override;
|
2021-01-02 08:50:34 -05:00
|
|
|
virtual void OnRemoveFromWorld() override;
|
2014-07-30 16:19:51 -04:00
|
|
|
virtual void SendTo(cClientHandle & a_Client) override;
|
2015-01-11 16:12:26 -05:00
|
|
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
2015-12-01 17:12:44 -05:00
|
|
|
virtual bool UsedBy(cPlayer * a_Player) override;
|
2014-07-30 16:19:51 -04:00
|
|
|
|
2014-07-30 16:50:34 -04:00
|
|
|
/** Modify the beacon level. (It is needed to load the beacon corectly) */
|
|
|
|
void SetBeaconLevel(char a_Level) { m_BeaconLevel = a_Level; }
|
|
|
|
|
2014-07-30 16:19:51 -04:00
|
|
|
// tolua_begin
|
|
|
|
|
2014-07-30 15:59:35 -04:00
|
|
|
/** Is the beacon active? */
|
|
|
|
bool IsActive(void) const { return m_IsActive; }
|
|
|
|
|
|
|
|
/** Returns the beacon level. (0 - 4) */
|
|
|
|
char GetBeaconLevel(void) const { return m_BeaconLevel; }
|
|
|
|
|
2014-07-31 06:13:11 -04:00
|
|
|
cEntityEffect::eType GetPrimaryEffect(void) const { return m_PrimaryEffect; }
|
|
|
|
cEntityEffect::eType GetSecondaryEffect(void) const { return m_SecondaryEffect; }
|
2014-07-30 15:59:35 -04:00
|
|
|
|
2014-07-31 12:15:39 -04:00
|
|
|
/** Sets the primary effect. Returns false when the effect is invalid. */
|
|
|
|
bool SetPrimaryEffect(cEntityEffect::eType a_Effect);
|
2014-07-30 15:59:35 -04:00
|
|
|
|
2014-07-31 12:15:39 -04:00
|
|
|
/** Sets the secondary effect. Returns false when the effect is invalid. */
|
|
|
|
bool SetSecondaryEffect(cEntityEffect::eType a_Effect);
|
2014-07-30 15:59:35 -04:00
|
|
|
|
|
|
|
/** 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);
|
2014-04-11 18:01:15 -04:00
|
|
|
|
2014-07-30 15:59:35 -04:00
|
|
|
/** Update the beacon. */
|
|
|
|
void UpdateBeacon(void);
|
|
|
|
|
|
|
|
/** Give the near-players the effects. */
|
|
|
|
void GiveEffects(void);
|
|
|
|
|
2014-07-30 16:19:51 -04:00
|
|
|
/** 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);
|
|
|
|
|
2014-07-31 06:15:18 -04:00
|
|
|
/** Returns true if the effect can be used. */
|
2014-07-31 06:13:11 -04:00
|
|
|
static bool IsValidEffect(cEntityEffect::eType a_Effect, char a_BeaconLevel);
|
2014-07-30 16:19:51 -04:00
|
|
|
|
|
|
|
// tolua_end
|
2014-07-30 15:59:35 -04:00
|
|
|
|
|
|
|
protected:
|
2020-10-20 07:28:45 -04:00
|
|
|
|
2014-07-30 15:59:35 -04:00
|
|
|
bool m_IsActive;
|
|
|
|
char m_BeaconLevel;
|
|
|
|
|
2014-07-31 06:13:11 -04:00
|
|
|
cEntityEffect::eType m_PrimaryEffect, m_SecondaryEffect;
|
2014-07-30 16:19:51 -04:00
|
|
|
} ; // tolua_export
|