blob: a037343f4b0bb0632468d8f756170076f85649e9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
// MobSpawnerEntity.h
// Declares the cMobSpawnerEntity class representing a single mob spawner in the world
#pragma once
#include "BlockEntity.h"
#include "../Entities/Player.h"
// tolua_begin
class cMobSpawnerEntity :
public cBlockEntity
{
// tolua_end
using Super = cBlockEntity;
public: // tolua_export
cMobSpawnerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
// cBlockEntity overrides:
virtual void CopyFrom(const cBlockEntity & a_Src) override;
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;
static const char * GetClassStatic(void) { return "cMobSpawnerEntity"; }
// tolua_begin
/** Update 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 automatically change the spawn delay! */
void SpawnEntity(void);
// Getters
int GetNearbyMonsterNum(eMonsterType a_EntityType);
int GetNearbyPlayersNum(void);
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; }
// tolua_end
private:
/** The entity to spawn. */
eMonsterType m_Entity;
/** Time in ticks until the next entity spawns */
short m_SpawnDelay;
bool m_IsActive;
/** 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;
} ; // tolua_end
|