Cuberite
A lightweight, fast and extensible game server for Minecraft
MobSpawnerEntity.h
Go to the documentation of this file.
1 // MobSpawnerEntity.h
2 
3 // Declares the cMobSpawnerEntity class representing a single mob spawner in the world
4 
5 
6 
7 
8 
9 #pragma once
10 
11 #include "BlockEntity.h"
12 #include "../Entities/Player.h"
13 
14 
15 
16 
17 
18 // tolua_begin
20  public cBlockEntity
21 {
22  // tolua_end
23 
25 
26 public: // tolua_export
27 
28  cMobSpawnerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
29 
30  // cBlockEntity overrides:
31  virtual void CopyFrom(const cBlockEntity & a_Src) override;
32  virtual void SendTo(cClientHandle & a_Client) override;
33  virtual bool UsedBy(cPlayer * a_Player) override;
34  virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
35 
36  // tolua_begin
37 
39  void UpdateActiveState(void);
40 
42  void ResetTimer(void);
43 
45  void SpawnEntity(void);
46 
48  eMonsterType GetEntity(void) const { return m_Entity; }
49 
51  void SetEntity(eMonsterType a_EntityType) { m_Entity = a_EntityType; }
52 
54  short GetSpawnDelay(void) const { return m_SpawnDelay; }
55 
57  void SetSpawnDelay(short a_Delay) { m_SpawnDelay = a_Delay; }
58 
60  int GetNearbyPlayersNum(void);
61 
63  int GetNearbyMonsterNum(eMonsterType a_EntityType);
64 
65  // tolua_end
66 
67  static const char * GetClassStatic(void) { return "cMobSpawnerEntity"; }
68 
69 private:
72 
73  short m_SpawnDelay;
74 
75  bool m_IsActive;
76 } ; // tolua_end
77 
78 
79 
80 
void ResetTimer(void)
Sets the spawn delay to a new random value.
int GetNearbyPlayersNum(void)
Returns the amount of the nearby players in a 16-block radius.
eMonsterType GetEntity(void) const
Returns the entity type that will be spawn by this mob spawner.
static const char * GetClassStatic(void)
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
Definition: Player.h:27
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
Definition: Chunk.h:49
eMonsterType
Identifies individual monster type, as well as their network type-ID.
Definition: MonsterTypes.h:10
void SetSpawnDelay(short a_Delay)
Sets the spawn delay.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
cMobSpawnerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking...
Definition: World.h:65
void UpdateActiveState(void)
Upate the active flag from the mob spawner.
eMonsterType m_Entity
The entity to spawn.
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
void SpawnEntity(void)
Spawns the entity.
void SetEntity(eMonsterType a_EntityType)
Sets the entity type who will be spawn by this mob spawner.
cBlockEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
Definition: BlockEntity.h:43
short GetSpawnDelay(void) const
Returns the spawn delay.
int GetNearbyMonsterNum(eMonsterType a_EntityType)
Returns the amount of this monster type in a 8-block radius (Y: 4-block radius).