1
0
cuberite-2a/src/BlockEntities/MobSpawnerEntity.h

81 lines
1.7 KiB
C
Raw Normal View History

2014-09-17 15:45:13 +00:00
#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);
2014-09-19 21:00:54 +00:00
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
2014-09-17 15:45:13 +00:00
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
// tolua_begin
2014-09-19 21:00:54 +00:00
/** 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. */
2014-09-26 22:07:17 +00:00
eMonsterType GetEntity(void) const { return m_Entity; }
2014-09-19 21:00:54 +00:00
/** Sets the entity type who will be spawn by this mob spawner. */
2014-09-26 22:07:17 +00:00
void SetEntity(eMonsterType a_EntityType) { m_Entity = a_EntityType; }
2014-09-19 21:00:54 +00:00
/** 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);
2014-09-26 22:07:17 +00:00
int GetNearbyMonsterNum(eMonsterType a_EntityType);
2014-09-17 15:45:13 +00:00
// tolua_end
2014-09-19 21:00:54 +00:00
bool LoadFromJson(const Json::Value & a_Value);
virtual void SaveToJson(Json::Value & a_Value) override;
2014-09-17 15:45:13 +00:00
static const char * GetClassStatic(void) { return "cMobSpawnerEntity"; }
private:
/** The entity to spawn. */
2014-09-26 22:07:17 +00:00
eMonsterType m_Entity;
2014-09-17 15:45:13 +00:00
int m_SpawnDelay;
2014-09-19 21:00:54 +00:00
bool m_IsActive;
2014-09-17 15:45:13 +00:00
} ; // tolua_end