2014-12-01 08:58:13 -05:00
|
|
|
// MobSpawnerEntity.h
|
|
|
|
|
|
|
|
// Declares the cMobSpawnerEntity class representing a single mob spawner in the world
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 11:45:13 -04: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 17:00:54 -04:00
|
|
|
virtual void SendTo(cClientHandle & a_Client) override;
|
|
|
|
virtual void UsedBy(cPlayer * a_Player) override;
|
2015-01-11 16:12:26 -05:00
|
|
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
2014-09-17 11:45:13 -04:00
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
|
2014-09-19 17:00:54 -04: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);
|
|
|
|
|
2014-11-29 09:20:44 -05:00
|
|
|
/** Returns the entity type that will be spawn by this mob spawner. */
|
2014-09-26 18:07:17 -04:00
|
|
|
eMonsterType GetEntity(void) const { return m_Entity; }
|
2014-09-19 17:00:54 -04:00
|
|
|
|
|
|
|
/** Sets the entity type who will be spawn by this mob spawner. */
|
2014-09-26 18:07:17 -04:00
|
|
|
void SetEntity(eMonsterType a_EntityType) { m_Entity = a_EntityType; }
|
2014-09-19 17:00:54 -04:00
|
|
|
|
2014-11-29 09:20:44 -05:00
|
|
|
/** Returns the spawn delay. This is the tick delay that is needed to spawn new monsters. */
|
2014-11-18 09:33:41 -05:00
|
|
|
short GetSpawnDelay(void) const { return m_SpawnDelay; }
|
|
|
|
|
|
|
|
/** Sets the spawn delay. */
|
|
|
|
void SetSpawnDelay(short a_Delay) { m_SpawnDelay = a_Delay; }
|
2014-09-19 17:00:54 -04:00
|
|
|
|
2014-11-29 09:20:44 -05:00
|
|
|
/** Returns the amount of the nearby players in a 16-block radius. */
|
2014-09-19 17:00:54 -04:00
|
|
|
int GetNearbyPlayersNum(void);
|
2014-11-29 09:20:44 -05:00
|
|
|
|
|
|
|
/** Returns the amount of this monster type in a 8-block radius (Y: 4-block radius). */
|
2014-09-26 18:07:17 -04:00
|
|
|
int GetNearbyMonsterNum(eMonsterType a_EntityType);
|
2014-09-17 11:45:13 -04:00
|
|
|
|
|
|
|
// tolua_end
|
|
|
|
|
|
|
|
static const char * GetClassStatic(void) { return "cMobSpawnerEntity"; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
/** The entity to spawn. */
|
2014-09-26 18:07:17 -04:00
|
|
|
eMonsterType m_Entity;
|
2014-09-17 11:45:13 -04:00
|
|
|
|
2014-11-18 09:33:41 -05:00
|
|
|
short m_SpawnDelay;
|
2014-09-17 11:45:13 -04:00
|
|
|
|
2014-09-19 17:00:54 -04:00
|
|
|
bool m_IsActive;
|
2014-09-17 11:45:13 -04:00
|
|
|
} ; // tolua_end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|