Cuberite
A lightweight, fast and extensible game server for Minecraft
PassiveMonster.cpp
Go to the documentation of this file.
1 
2 #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
3 
4 #include "PassiveMonster.h"
5 #include "../World.h"
6 #include "../Entities/Player.h"
7 #include "../BoundingBox.h"
8 #include "../Items/ItemSpawnEgg.h"
9 
10 
11 
12 
13 cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, const AString & a_SoundAmbient, float a_Width, float a_Height) :
14  Super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_SoundAmbient, a_Width, a_Height)
15 {
17 }
18 
19 
20 
21 
22 
24 {
25  if (!Super::DoTakeDamage(a_TDI))
26  {
27  return false;
28  }
29  if ((a_TDI.Attacker != this) && (a_TDI.Attacker != nullptr))
30  {
32  }
33  return true;
34 }
35 
36 
37 
38 
39 
40 void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
41 {
42  Super::Tick(a_Dt, a_Chunk);
43  if (!IsTicking())
44  {
45  // The base class tick destroyed us
46  return;
47  }
48 
49  if (m_EMState == ESCAPING)
50  {
52  }
53 
55 }
56 
57 
58 
59 
60 
62 {
63  Super::OnRightClicked(a_Player);
64  Super::RightClickFeed(a_Player);
65 }
66 
67 
68 
eMonsterType
Identifies individual monster type.
Definition: MonsterTypes.h:11
std::string AString
Definition: StringUtils.h:11
Definition: Chunk.h:36
cEntity * Attacker
Definition: Entity.h:62
Definition: Entity.h:76
bool IsTicking(void) const
Returns true if the entity is valid and ticking.
Definition: Entity.cpp:2259
Definition: Player.h:29
virtual void CheckEventLostPlayer(std::chrono::milliseconds a_Dt)
Definition: Monster.cpp:784
void LoveTick(void)
Does the whole love and breeding processing.
Definition: Monster.cpp:1354
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
Makes this entity take damage specified in the a_TDI.
Definition: Monster.cpp:572
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
Definition: Monster.cpp:697
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: Monster.cpp:264
@ ESCAPING
Definition: Monster.h:40
enum cMonster::MState m_EMState
@ PASSIVE
Definition: Monster.h:41
void RightClickFeed(cPlayer &a_Player)
Right click call to process feeding.
Definition: Monster.cpp:1474
enum cMonster::MPersonality m_EMPersonality
cPassiveMonster(const AString &a_ConfigName, eMonsterType a_MobType, const AString &a_SoundHurt, const AString &a_SoundDeath, const AString &a_SoundAmbient, float a_Width, float a_Height)
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
When hit by someone, run away.