summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/MobSpawnerEntity.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/BlockEntities/MobSpawnerEntity.h')
-rw-r--r--src/BlockEntities/MobSpawnerEntity.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/BlockEntities/MobSpawnerEntity.h b/src/BlockEntities/MobSpawnerEntity.h
new file mode 100644
index 000000000..b12a97d65
--- /dev/null
+++ b/src/BlockEntities/MobSpawnerEntity.h
@@ -0,0 +1,80 @@
+
+#pragma once
+
+#include "BlockEntity.h"
+#include "../Entities/Player.h"
+
+
+
+
+
+namespace Json
+{
+ class Value;
+}
+
+
+
+
+
+// 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 who will be spawn by this mob spawner. */
+ cMonster::eType GetEntity(void) const { return m_Entity; }
+
+ /** Sets the entity type who will be spawn by this mob spawner. */
+ void SetEntity(cMonster::eType a_EntityType) { m_Entity = a_EntityType; }
+
+ /** Returns the entity name. (Required by the protocol) */
+ AString GetEntityName(void) const;
+
+ /** Returns the spawn delay. */
+ int GetSpawnDelay(void) const { return m_SpawnDelay; }
+
+ int GetNearbyPlayersNum(void);
+ int GetNearbyEntityNum(cMonster::eType a_EntityType);
+
+ // tolua_end
+
+ bool LoadFromJson(const Json::Value & a_Value);
+ virtual void SaveToJson(Json::Value & a_Value) override;
+
+ static const char * GetClassStatic(void) { return "cMobSpawnerEntity"; }
+
+private:
+ /** The entity to spawn. */
+ cMonster::eType m_Entity;
+
+ int m_SpawnDelay;
+
+ bool m_IsActive;
+} ; // tolua_end
+
+
+
+