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  typedef cEntity super;
20 
21 public:
23 
24  cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
25  virtual ~cPawn() override;
26  virtual void Destroyed() override;
27 
28  virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
29  virtual void KilledBy(TakeDamageInfo & a_TDI) override;
30 
31  virtual bool IsFireproof(void) const override;
32  virtual bool IsInvisible() const override;
33  virtual void HandleAir(void) override;
34  virtual void HandleFalling(void);
35 
38 
39 
40 
41  // tolua_begin
42 
48  void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier = 1);
49 
51  void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
52 
54  bool HasEntityEffect(cEntityEffect::eType a_EffectType) const;
55 
57  void ClearEntityEffects(void);
58 
59  // tolua_end
60 
62  void NoLongerTargetingMe(cMonster * a_Monster);
63 
65  void TargetingMe(cMonster * a_Monster);
66 
69 
71  cEntityEffect * GetEntityEffect(cEntityEffect::eType a_EffectType);
72 
73 protected:
74  typedef std::map<cEntityEffect::eType, std::unique_ptr<cEntityEffect>> tEffectMap;
75  tEffectMap m_EntityEffects;
76 
79 
80  virtual void ResetPosition(Vector3d a_NewPosition) override;
81 
82 private:
83 
86 } ; // tolua_export
87 
88 
89 
90 
Definition: FastNBT.h:131
virtual bool IsFireproof(void) const override
Definition: Pawn.cpp:139
double m_LastGroundHeight
Definition: Pawn.h:77
void RemoveEntityEffect(cEntityEffect::eType a_EffectType)
Removes a currently applied entity effect.
Definition: Pawn.cpp:205
Definition: Chunk.h:49
virtual void Destroyed() override
Definition: Pawn.cpp:39
void NoLongerTargetingMe(cMonster *a_Monster)
Remove the monster from the list of monsters targeting this pawn.
Definition: Pawn.cpp:251
bool HasEntityEffect(cEntityEffect::eType a_EffectType) const
Returns true, if the entity effect is currently applied.
Definition: Pawn.cpp:222
void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier=1)
Applies an entity effect.
Definition: Pawn.cpp:172
cEntityEffect * GetEntityEffect(cEntityEffect::eType a_EffectType)
Returns the entity effect, if it is currently applied or nullptr if not.
Definition: Pawn.cpp:489
virtual void HandleAir(void) override
Called in each tick to handle air-related processing i.e.
Definition: Pawn.cpp:157
virtual void HandleFalling(void)
Definition: Pawn.cpp:283
bool m_bTouchGround
Definition: Pawn.h:78
virtual void ResetPosition(Vector3d a_NewPosition) override
Set the entities position and last sent position.
Definition: Pawn.cpp:499
virtual bool IsInvisible() const override
Definition: Pawn.cpp:148
Definition: Pawn.h:15
eEntityType
Definition: Entity.h:77
std::map< cEntityEffect::eType, std::unique_ptr< cEntityEffect > > tEffectMap
Definition: Pawn.h:74
cEntity super
Definition: Pawn.h:19
tEffectMap m_EntityEffects
Definition: Pawn.h:75
std::vector< cMonster * > m_TargetingMe
A list of all monsters that are targeting this pawn.
Definition: Pawn.h:85
Definition: Entity.h:73
#define CLASS_PROTODEF(classname)
Definition: Entity.h:11
void TargetingMe(cMonster *a_Monster)
Add the monster to the list of monsters targeting this pawn.
Definition: Pawn.cpp:271
void StopEveryoneFromTargetingMe()
Tells all pawns which are targeting us to stop targeting us.
Definition: Pawn.cpp:458
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: Pawn.cpp:49
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
Definition: Pawn.cpp:129
std::map< cEntityEffect::eType, cEntityEffect * > GetEntityEffects()
Returns all entity effects.
Definition: Pawn.cpp:475
void ClearEntityEffects(void)
Removes all currently applied entity effects (used when drinking milk)
Definition: Pawn.cpp:231