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
|
|
|
|
{
|
|
|
|
// tolua_end
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cBlockEntity;
|
2019-09-29 08:59:24 -04:00
|
|
|
|
|
|
|
public: // tolua_export
|
|
|
|
|
|
|
|
cMobSpawnerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
|
2014-09-17 11:45:13 -04:00
|
|
|
|
2017-06-15 09:32:33 -04:00
|
|
|
// cBlockEntity overrides:
|
|
|
|
virtual void CopyFrom(const cBlockEntity & a_Src) override;
|
2014-09-19 17:00:54 -04:00
|
|
|
virtual void SendTo(cClientHandle & a_Client) override;
|
2015-12-01 17:12:44 -05:00
|
|
|
virtual bool 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
|
|
|
|
|
2020-10-10 15:31:44 -04:00
|
|
|
/** Update the active flag from the mob spawner. This function will called every 5 seconds from the Tick() function. */
|
2014-09-19 17:00:54 -04:00
|
|
|
void UpdateActiveState(void);
|
|
|
|
|
|
|
|
/** Sets the spawn delay to a new random value. */
|
|
|
|
void ResetTimer(void);
|
|
|
|
|
2020-10-10 15:31:44 -04:00
|
|
|
/** Spawns the entity. This function automatically change the spawn delay! */
|
2014-09-19 17:00:54 -04:00
|
|
|
void SpawnEntity(void);
|
|
|
|
|
2020-10-10 15:31:44 -04:00
|
|
|
// Getters
|
|
|
|
int GetNearbyMonsterNum(eMonsterType a_EntityType);
|
2014-09-19 17:00:54 -04:00
|
|
|
int GetNearbyPlayersNum(void);
|
2014-11-29 09:20:44 -05:00
|
|
|
|
2020-10-10 15:31:44 -04:00
|
|
|
eMonsterType GetEntity(void) const { return m_Entity; }
|
|
|
|
short GetSpawnCount(void) const { return m_SpawnCount; }
|
|
|
|
short GetSpawnRange(void) const { return m_SpawnRange; }
|
|
|
|
short GetSpawnDelay(void) const { return m_SpawnDelay; }
|
|
|
|
short GetMinSpawnDelay(void) const { return m_MinSpawnDelay; }
|
|
|
|
short GetMaxSpawnDelay(void) const { return m_MaxSpawnDelay; }
|
|
|
|
short GetMaxNearbyEntities(void) const { return m_MaxNearbyEntities; }
|
|
|
|
short GetRequiredPlayerRange(void) const { return m_RequiredPlayerRange; }
|
|
|
|
|
|
|
|
// Setters
|
|
|
|
void SetEntity(eMonsterType a_EntityType) { m_Entity = a_EntityType; }
|
|
|
|
void SetSpawnDelay(short a_Delay) { m_SpawnDelay = a_Delay; }
|
|
|
|
void SetSpawnCount(short a_SpawnCount) { m_SpawnCount = a_SpawnCount; }
|
|
|
|
void SetSpawnRange(short a_SpawnRange) { m_SpawnRange = a_SpawnRange; }
|
|
|
|
void SetMinSpawnDelay(short a_Min) { m_MinSpawnDelay = a_Min; }
|
|
|
|
void SetMaxSpawnDelay(short a_Max) { m_MaxSpawnDelay = a_Max; }
|
|
|
|
void SetMaxNearbyEntities(short a_MaxNearbyEntities) { m_MaxNearbyEntities = a_MaxNearbyEntities; }
|
|
|
|
void SetRequiredPlayerRange(short a_RequiredPlayerRange) { m_RequiredPlayerRange = a_RequiredPlayerRange; }
|
2014-09-17 11:45:13 -04:00
|
|
|
|
|
|
|
// tolua_end
|
|
|
|
|
|
|
|
private:
|
2020-10-20 07:28:45 -04:00
|
|
|
|
2014-09-17 11:45:13 -04:00
|
|
|
/** The entity to spawn. */
|
2014-09-26 18:07:17 -04:00
|
|
|
eMonsterType m_Entity;
|
2014-09-17 11:45:13 -04:00
|
|
|
|
2020-10-10 15:31:44 -04:00
|
|
|
/** Time in ticks until the next entity spawns */
|
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;
|
2020-10-10 15:31:44 -04:00
|
|
|
|
|
|
|
/** Number of entities the spawner tries to spawn each activation. */
|
|
|
|
short m_SpawnCount = 4;
|
|
|
|
|
|
|
|
/** Diameter of the square the new monsters are spawned in */
|
|
|
|
short m_SpawnRange = 8;
|
|
|
|
|
|
|
|
short m_MinSpawnDelay = 200;
|
|
|
|
|
|
|
|
short m_MaxSpawnDelay = 800;
|
|
|
|
|
|
|
|
/** Maximum amount of the same entity type in proximity. */
|
|
|
|
short m_MaxNearbyEntities = 6;
|
|
|
|
|
|
|
|
/** Maximum distance to player for activation */
|
|
|
|
short m_RequiredPlayerRange = 16;
|
|
|
|
|
2014-09-17 11:45:13 -04:00
|
|
|
} ; // tolua_end
|