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 
42  static constexpr float ARROW_WATER_FRICTION = 50.0f;
43 
45 
46 
47  cArrowEntity(cEntity * a_Creator, Vector3d a_Pos, Vector3d a_Speed);
48 
50  cArrowEntity(cPlayer & a_Player, double a_Force);
51 
52  // tolua_begin
53 
55  ePickupState GetPickupState(void) const { return m_PickupState; }
56 
58  void SetPickupState(ePickupState a_PickupState) { m_PickupState = a_PickupState; }
59 
61  double GetDamageCoeff(void) const { return m_DamageCoeff; }
62 
64  void SetDamageCoeff(double a_DamageCoeff) { m_DamageCoeff = a_DamageCoeff; }
65 
67  bool CanPickup(const cPlayer & a_Player) const;
68 
70  bool IsCritical(void) const { return m_IsCritical; }
71 
73  void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; }
74 
76  Vector3i GetBlockHit(void) const { return m_HitBlockPos; }
77 
78  // tolua_end
79 
81  void SetBlockHit(const Vector3i & a_BlockHit) { m_HitBlockPos = a_BlockHit; }
82 
83 protected:
84 
87 
89  double m_DamageCoeff;
90 
93 
95  std::chrono::milliseconds m_Timer;
96 
99 
102 
103  // cProjectileEntity overrides:
104  virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
105  virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
106  virtual void CollectedBy(cPlayer & a_Player) override;
107  virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
108 
109  // cEntity overrides:
110  virtual bool DoesPreventBlockPlacement(void) const override;
111 
112 }; // tolua_export
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
#define CLASS_PROTODEF(classname)
Definition: Entity.h:13
Definition: Chunk.h:36
double m_DamageCoeff
The coefficient applied to the damage that the arrow will deal, based on the bow enchantment.
Definition: ArrowEntity.h:89
bool m_IsCritical
If true, the arrow deals more damage.
Definition: ArrowEntity.h:92
ePickupState m_PickupState
Determines when the arrow can be picked up by players.
Definition: ArrowEntity.h:86
virtual bool DoesPreventBlockPlacement(void) const override
Returns whether blocks can be placed intersecting this entities' hitbox.
cArrowEntity(cEntity *a_Creator, Vector3d a_Pos, Vector3d a_Speed)
Creates a new arrow with psNoPickup state and default damage modifier coeff.
Definition: ArrowEntity.cpp:12
std::chrono::milliseconds m_Timer
Timer for pickup collection animation or five minute timeout.
Definition: ArrowEntity.h:95
bool CanPickup(const cPlayer &a_Player) const
Returns true if the specified player can pick the arrow up.
Definition: ArrowEntity.cpp:43
bool m_bIsCollected
If true, the arrow is in the process of being collected - don't go to anyone else.
Definition: ArrowEntity.h:98
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:58
void SetPickupState(ePickupState a_PickupState)
Sets a new pickup state.
Definition: ArrowEntity.h:58
void SetIsCritical(bool a_IsCritical)
Sets the IsCritical flag.
Definition: ArrowEntity.h:73
ePickupState GetPickupState(void) const
Returns whether the arrow can be picked up by players.
Definition: ArrowEntity.h:55
virtual void OnHitEntity(cEntity &a_EntityHit, Vector3d a_HitPos) override
Called by the physics blocktracer when the entity hits another entity.
void SetDamageCoeff(double a_DamageCoeff)
Sets the damage modifier coeff.
Definition: ArrowEntity.h:64
bool IsCritical(void) const
Returns true if the arrow is set as critical.
Definition: ArrowEntity.h:70
double GetDamageCoeff(void) const
Returns the damage modifier coeff.
Definition: ArrowEntity.h:61
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
ePickupState
Determines when the arrow can be picked up (depending on player gamemode).
Definition: ArrowEntity.h:34
@ psInSurvivalOrCreative
Definition: ArrowEntity.h:36
Vector3i GetBlockHit(void) const
Gets the block arrow is in.
Definition: ArrowEntity.h:76
virtual void CollectedBy(cPlayer &a_Player) override
Called by Chunk when the projectile is eligible for player collection.
static constexpr float ARROW_WATER_FRICTION
Value used to calculate arrow speed in water.
Definition: ArrowEntity.h:42
Vector3i m_HitBlockPos
Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air.
Definition: ArrowEntity.h:101
void SetBlockHit(const Vector3i &a_BlockHit)
Sets the block arrow is in.
Definition: ArrowEntity.h:81
Definition: Entity.h:76
Definition: Player.h:29
cProjectileEntity(eKind a_Kind, cEntity *a_Creator, Vector3d a_Pos, float a_Width, float a_Height)