diff options
author | Mattes D <github@xoft.cz> | 2014-12-04 22:04:16 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-12-04 22:04:16 +0100 |
commit | c014f5624c1eda400c08c305978bbcef3f554ff3 (patch) | |
tree | fd15deecb2e9afa17443f9b8a8c51676ad6e0145 /src/BlockEntities/MobSpawnerEntity.h | |
parent | Fixed indent. (diff) | |
parent | Merge pull request #1645 from jonfabe/SpectatorModeFixes (diff) | |
download | cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar.gz cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar.bz2 cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar.lz cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar.xz cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar.zst cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.zip |
Diffstat (limited to '')
-rw-r--r-- | src/BlockEntities/MobSpawnerEntity.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/BlockEntities/MobSpawnerEntity.h b/src/BlockEntities/MobSpawnerEntity.h new file mode 100644 index 000000000..594b5301e --- /dev/null +++ b/src/BlockEntities/MobSpawnerEntity.h @@ -0,0 +1,78 @@ +// MobSpawnerEntity.h + +// Declares the cMobSpawnerEntity class representing a single mob spawner in the world + + + + + +#pragma once + +#include "BlockEntity.h" +#include "../Entities/Player.h" + + + + + +// tolua_begin + +class cMobSpawnerEntity : + public cBlockEntity +{ + typedef cBlockEntity super; +public: + + // tolua_end + + cMobSpawnerEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); + + virtual void SendTo(cClientHandle & a_Client) override; + virtual void UsedBy(cPlayer * a_Player) override; + virtual bool Tick(float a_Dt, cChunk & a_Chunk) override; + + // tolua_begin + + /** Upate the active flag from the mob spawner. This function will called every 5 seconds from the Tick() function. */ + void UpdateActiveState(void); + + /** Sets the spawn delay to a new random value. */ + void ResetTimer(void); + + /** Spawns the entity. This function automaticly change the spawn delay! */ + void SpawnEntity(void); + + /** Returns the entity type that will be spawn by this mob spawner. */ + eMonsterType GetEntity(void) const { return m_Entity; } + + /** Sets the entity type who will be spawn by this mob spawner. */ + void SetEntity(eMonsterType a_EntityType) { m_Entity = a_EntityType; } + + /** Returns the spawn delay. This is the tick delay that is needed to spawn new monsters. */ + short GetSpawnDelay(void) const { return m_SpawnDelay; } + + /** Sets the spawn delay. */ + void SetSpawnDelay(short a_Delay) { m_SpawnDelay = a_Delay; } + + /** Returns the amount of the nearby players in a 16-block radius. */ + int GetNearbyPlayersNum(void); + + /** Returns the amount of this monster type in a 8-block radius (Y: 4-block radius). */ + int GetNearbyMonsterNum(eMonsterType a_EntityType); + + // tolua_end + + static const char * GetClassStatic(void) { return "cMobSpawnerEntity"; } + +private: + /** The entity to spawn. */ + eMonsterType m_Entity; + + short m_SpawnDelay; + + bool m_IsActive; +} ; // tolua_end + + + + |