Cuberite
A lightweight, fast and extensible game server for Minecraft
ArrowEntity.h
Go to the documentation of this file.
1 
2 // ArrowEntity.h
3 
4 // Declares the cArrowEntity representing the arrow that has been shot by the player or by a skeleton
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "ProjectileEntity.h"
13 
14 
15 
16 
17 
18 // tolua_begin
19 
20 class cArrowEntity :
21  public cProjectileEntity
22 {
23  // tolua_end
24 
26 
27  // tolua_begin
28 
29 
30 public:
31 
34  {
38  } ;
39 
40  // tolua_end
41 
43 
44 
45  cArrowEntity(cEntity * a_Creator, Vector3d a_Pos, Vector3d a_Speed);
46 
48  cArrowEntity(cPlayer & a_Player, double a_Force);
49 
50  // tolua_begin
51 
53  ePickupState GetPickupState(void) const { return m_PickupState; }
54 
56  void SetPickupState(ePickupState a_PickupState) { m_PickupState = a_PickupState; }
57 
59  double GetDamageCoeff(void) const { return m_DamageCoeff; }
60 
62  void SetDamageCoeff(double a_DamageCoeff) { m_DamageCoeff = a_DamageCoeff; }
63 
65  bool CanPickup(const cPlayer & a_Player) const;
66 
68  bool IsCritical(void) const { return m_IsCritical; }
69 
71  void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; }
72 
74  Vector3i GetBlockHit(void) const { return m_HitBlockPos; }
75 
76  // tolua_end
77 
79  void SetBlockHit(const Vector3i & a_BlockHit) { m_HitBlockPos = a_BlockHit; }
80 
81 protected:
82 
85 
87  double m_DamageCoeff;
88 
91 
93  std::chrono::milliseconds m_Timer;
94 
96  std::chrono::milliseconds m_HitGroundTimer;
97 
98  // Whether the arrow has already been teleported into the proper position in the ground.
100 
103 
106 
107  // cProjectileEntity overrides:
108  virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
109  virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
110  virtual void CollectedBy(cPlayer & a_Player) override;
111  virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
112 
113 }; // tolua_export
void SetIsCritical(bool a_IsCritical)
Sets the IsCritical flag.
Definition: ArrowEntity.h:71
virtual void CollectedBy(cPlayer &a_Player) override
Called by Chunk when the projectile is eligible for player collection.
void SetBlockHit(const Vector3i &a_BlockHit)
Sets the block arrow is in.
Definition: ArrowEntity.h:79
Vector3i GetBlockHit(void) const
Gets the block arrow is in.
Definition: ArrowEntity.h:74
ePickupState
Determines when the arrow can be picked up (depending on player gamemode).
Definition: ArrowEntity.h:33
ePickupState m_PickupState
Determines when the arrow can be picked up by players.
Definition: ArrowEntity.h:84
bool m_IsCritical
If true, the arrow deals more damage.
Definition: ArrowEntity.h:90
Definition: Player.h:27
Vector3i m_HitBlockPos
Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air...
Definition: ArrowEntity.h:105
std::chrono::milliseconds m_Timer
Timer for pickup collection animation or five minute timeout.
Definition: ArrowEntity.h:93
Definition: Chunk.h:49
bool CanPickup(const cPlayer &a_Player) const
Returns true if the specified player can pick the arrow up.
Definition: ArrowEntity.cpp:60
bool m_HasTeleported
Definition: ArrowEntity.h:99
double m_DamageCoeff
The coefficient applied to the damage that the arrow will deal, based on the bow enchantment.
Definition: ArrowEntity.h:87
bool m_bIsCollected
If true, the arrow is in the process of being collected - don't go to anyone else.
Definition: ArrowEntity.h:102
void SetPickupState(ePickupState a_PickupState)
Sets a new pickup state.
Definition: ArrowEntity.h:56
void SetDamageCoeff(double a_DamageCoeff)
Sets the damage modifier coeff.
Definition: ArrowEntity.h:62
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
Definition: Defines.h:29
double GetDamageCoeff(void) const
Returns the damage modifier coeff.
Definition: ArrowEntity.h:59
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
std::chrono::milliseconds m_HitGroundTimer
Timer for client arrow position confirmation via TeleportEntity.
Definition: ArrowEntity.h:96
Definition: Entity.h:73
#define CLASS_PROTODEF(classname)
Definition: Entity.h:11
ePickupState GetPickupState(void) const
Returns whether the arrow can be picked up by players.
Definition: ArrowEntity.h:53
virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override
Called by the physics blocktracer when the entity hits a solid block, the hit position and the face h...
Definition: ArrowEntity.cpp:75
virtual void OnHitEntity(cEntity &a_EntityHit, Vector3d a_HitPos) override
Called by the physics blocktracer when the entity hits another entity.
cProjectileEntity(eKind a_Kind, cEntity *a_Creator, Vector3d a_Pos, double a_Width, double a_Height)
bool IsCritical(void) const
Returns true if the arrow is set as critical.
Definition: ArrowEntity.h:68