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

81 lines
2.0 KiB
C
Raw Normal View History

2014-12-01 13:58:13 +00:00
// MobSpawnerEntity.h
// Declares the cMobSpawnerEntity class representing a single mob spawner in the world
2014-09-17 15:45:13 +00:00
#pragma once
#include "BlockEntity.h"
#include "../Entities/Player.h"
// tolua_begin
class cMobSpawnerEntity :
public cBlockEntity
{
// tolua_end
2016-02-05 21:45:45 +00:00
2020-04-13 16:38:06 +00:00
using Super = cBlockEntity;
public: // tolua_export
cMobSpawnerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
2014-09-17 15:45:13 +00:00
2017-06-15 13:32:33 +00:00
// cBlockEntity overrides:
virtual void CopyFrom(const cBlockEntity & a_Src) override;
2014-09-19 21:00:54 +00:00
virtual void SendTo(cClientHandle & a_Client) override;
virtual bool UsedBy(cPlayer * a_Player) override;
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
2014-09-17 15:45:13 +00:00
// 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 that 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 spawn delay. This is the tick delay that is needed to spawn new monsters. */
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
/** Returns the amount of the nearby players in a 16-block radius. */
2014-09-19 21:00:54 +00:00
int GetNearbyPlayersNum(void);
/** Returns the amount of this monster type in a 8-block radius (Y: 4-block radius). */
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