Cuberite
A lightweight, fast and extensible game server for Minecraft
Endermite.cpp
Go to the documentation of this file.
1 
2 #include "Globals.h"
3 
4 #include "Endermite.h"
5 
6 #include "../World.h"
7 #include "../Chunk.h"
8 #include "../Blocks/BlockHandler.h"
9 #include "../Blocks/BlockInfested.h"
10 
11 
12 
13 
14 
16  Super("Endermite", mtEndermite, "entity.endermite.hurt", "entity.endermite.death", "entity.endermite.ambient", 0.4f, 0.3f),
17  m_Timer(0),
18  m_Lifetime(2 * 1000 * 60) // 2 minutes (2 * 1000 (mili to sec) * 60 (sec to min) * 2 because tick = 0.5 sec)
19 {
20 }
21 
22 
23 
24 
25 
26 void cEndermite::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
27 {
28  Super::Tick(a_Dt, a_Chunk);
29 
30  // Not destroying the endermite if a name is set
31  if (m_CustomName.empty())
32  {
33  m_Timer += a_Dt;
34  // Destroy the endermite after 2 minutes
35  if (m_Timer > m_Lifetime)
36  {
37  Destroy();
38  }
39 
40  }
41 }
@ mtEndermite
Definition: MonsterTypes.h:28
Definition: Chunk.h:36
Definition: Entity.h:76
void Destroy()
Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet.
Definition: Entity.cpp:243
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: Endermite.cpp:26
std::chrono::milliseconds m_Timer
Definition: Endermite.h:14
std::chrono::milliseconds m_Lifetime
Definition: Endermite.h:15
AString m_CustomName
Definition: Monster.h:303