Cuberite
A lightweight, fast and extensible game server for Minecraft
Pawn.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Entity.h"
5 #include "EntityEffect.h"
6 
7 // fwd cMonster
8 class cMonster;
9 
10 
11 
12 
13 
14 // tolua_begin
15 class cPawn:
16  public cEntity
17 {
18  // tolua_end
19  using Super = cEntity;
20 
21 public:
22 
24 
25  cPawn(eEntityType a_EntityType, float a_Width, float a_Height);
26 
27  virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
28  virtual void KilledBy(TakeDamageInfo & a_TDI) override;
29 
30  virtual bool IsFireproof(void) const override;
31  virtual bool IsInvisible() const override;
32  virtual void HandleAir(void) override;
33  virtual void HandleFalling(void);
34  virtual void OnRemoveFromWorld(cWorld & a_World) override;
35 
45  void HandleFarmlandTrampling(double a_FallHeight, BLOCKTYPE a_BlockAtFoot, BLOCKTYPE a_BlockBelow);
46 
49 
50 
51 
52  // tolua_begin
53 
59  void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier = 1);
60 
62  void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
63 
65  bool HasEntityEffect(cEntityEffect::eType a_EffectType) const;
66 
68  void ClearEntityEffects(void);
69 
70  // tolua_end
71 
73  void NoLongerTargetingMe(cMonster * a_Monster);
74 
76  void TargetingMe(cMonster * a_Monster);
77 
79  std::map<cEntityEffect::eType, cEntityEffect *> GetEntityEffects() const;
80 
83 
84  // tolua_begin
85 
86  static bool FindTeleportDestination(cWorld & a_World, const int a_HeightRequired, const unsigned int a_NumTries, Vector3d & a_Destination, const Vector3i a_MinBoxCorner, const Vector3i a_MaxBoxCorner);
87 
88  static bool FindTeleportDestination(cWorld & a_World, const int a_HeightRequired, const unsigned int a_NumTries, Vector3d & a_Destination, const cBoundingBox a_BoundingBox);
89 
95  static bool FindTeleportDestination(cWorld & a_World, const int a_HeightRequired, const unsigned int a_NumTries, Vector3d & a_Destination, Vector3i a_Centre, const int a_HalfCubeWidth);
96 
97  // tolua_end
98 
99 protected:
100 
101  typedef std::map<cEntityEffect::eType, std::unique_ptr<cEntityEffect>> tEffectMap;
103 
106 
107  virtual void ResetPosition(Vector3d a_NewPosition) override;
108 
109 private:
110 
112  std::vector<cMonster*> m_TargetingMe;
113 
116  bool DeductTotem(eDamageType a_DamageType);
117 } ; // tolua_export
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
eDamageType
Damage type, used in the TakeDamageInfo structure and related functions.
Definition: Defines.h:244
#define CLASS_PROTODEF(classname)
Definition: Entity.h:13
Represents two sets of coords, minimum and maximum for each direction.
Definition: BoundingBox.h:24
Definition: Chunk.h:36
Definition: Entity.h:76
cEntity(eEntityType a_EntityType, Vector3d a_Pos, float a_Width, float a_Height)
Definition: Entity.cpp:37
eEntityType
Definition: Entity.h:89
eType
All types of entity effects (numbers correspond to protocol / storage types)
Definition: EntityEffect.h:12
Definition: Pawn.h:17
void HandleFarmlandTrampling(double a_FallHeight, BLOCKTYPE a_BlockAtFoot, BLOCKTYPE a_BlockBelow)
Handles farmland trampling when hitting the ground.
Definition: Pawn.cpp:490
void ClearEntityEffects(void)
Removes all currently applied entity effects (used when drinking milk)
Definition: Pawn.cpp:245
bool DeductTotem(eDamageType a_DamageType)
Attempt to activate a Totem of Undying.
Definition: Pawn.cpp:617
tEffectMap m_EntityEffects
Definition: Pawn.h:102
std::map< cEntityEffect::eType, std::unique_ptr< cEntityEffect > > tEffectMap
Definition: Pawn.h:101
virtual bool IsInvisible() const override
Definition: Pawn.cpp:162
cEntityEffect * GetEntityEffect(cEntityEffect::eType a_EffectType) const
Returns the entity effect, if it is currently applied or nullptr if not.
Definition: Pawn.cpp:597
virtual void ResetPosition(Vector3d a_NewPosition) override
Set the entities position and last sent position.
Definition: Pawn.cpp:607
virtual void HandleFalling(void)
Definition: Pawn.cpp:297
void TargetingMe(cMonster *a_Monster)
Add the monster to the list of monsters targeting this pawn.
Definition: Pawn.cpp:285
void StopEveryoneFromTargetingMe()
Tells all pawns which are targeting us to stop targeting us.
Definition: Pawn.cpp:566
std::map< cEntityEffect::eType, cEntityEffect * > GetEntityEffects() const
Returns all entity effects.
Definition: Pawn.cpp:583
std::vector< cMonster * > m_TargetingMe
A list of all monsters that are targeting this pawn.
Definition: Pawn.h:112
bool HasEntityEffect(cEntityEffect::eType a_EffectType) const
Returns true, if the entity effect is currently applied.
Definition: Pawn.cpp:236
virtual void HandleAir(void) override
Called in each tick to handle air-related processing i.e.
Definition: Pawn.cpp:171
void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier=1)
Applies an entity effect.
Definition: Pawn.cpp:186
double m_LastGroundHeight
Definition: Pawn.h:104
void RemoveEntityEffect(cEntityEffect::eType a_EffectType)
Removes a currently applied entity effect.
Definition: Pawn.cpp:219
static bool FindTeleportDestination(cWorld &a_World, const int a_HeightRequired, const unsigned int a_NumTries, Vector3d &a_Destination, const Vector3i a_MinBoxCorner, const Vector3i a_MaxBoxCorner)
Definition: Pawn.cpp:652
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: Pawn.cpp:32
bool m_bTouchGround
Definition: Pawn.h:105
virtual void OnRemoveFromWorld(cWorld &a_World) override
Called when the entity is removed from a world.
Definition: Pawn.cpp:556
cPawn(eEntityType a_EntityType, float a_Width, float a_Height)
Definition: Pawn.cpp:18
virtual bool IsFireproof(void) const override
Definition: Pawn.cpp:153
void NoLongerTargetingMe(cMonster *a_Monster)
Remove the monster from the list of monsters targeting this pawn.
Definition: Pawn.cpp:265
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
Definition: Pawn.cpp:129
Definition: World.h:53