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

72 lines
1.6 KiB
C
Raw Normal View History

2014-09-17 15:45:13 +00:00
#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);
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. */
2014-11-18 14:33:41 +00:00
short GetSpawnDelay(void) const { return m_SpawnDelay; }
/** Sets the spawn delay. */
void SetSpawnDelay(short a_Delay) { m_SpawnDelay = a_Delay; }
2014-09-19 21:00:54 +00:00
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
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
2014-11-18 14:33:41 +00:00
short m_SpawnDelay;
2014-09-17 15:45:13 +00:00
2014-09-19 21:00:54 +00:00
bool m_IsActive;
2014-09-17 15:45:13 +00:00
} ; // tolua_end