Cuberite
A lightweight, fast and extensible game server for Minecraft
Boat.h
Go to the documentation of this file.
1 
2 // Boat.h
3 
4 // Declares the cBoat class representing a boat in the world
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "Entity.h"
13 
14 
15 
16 // tolua_begin
17 
18 class cBoat:
19  public cEntity
20 {
21  // tolua_end
22 
23  using Super = cEntity;
24 
25  // tolua_begin
26 
27 public:
28  enum eMaterial
29  {
35  bmDarkOak
36  };
37 
38  // tolua_end
39 
41 
42  cBoat(Vector3d a_Pos, eMaterial a_Material);
43 
44  // cEntity overrides:
45  virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
46  virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = nullptr) override;
47  virtual void OnRightClicked(cPlayer & a_Player) override;
48  virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
49  virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
50  virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override;
51  virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
52 
53  int GetLastDamage(void) const { return m_LastDamage; }
54  int GetForwardDirection(void) const { return m_ForwardDirection; }
55 
56  float GetDamageTaken(void) const { return m_DamageTaken; }
57 
58  // tolua_begin
59 
61  eMaterial GetMaterial(void) const { return m_Material; }
62 
64  void SetMaterial(cBoat::eMaterial a_Material) { m_Material = a_Material; }
65 
67  static eMaterial ItemToMaterial(const cItem & a_Item);
68 
70  static cItem MaterialToItem(eMaterial a_Material);
71 
73  static AString MaterialToString(const eMaterial a_Material);
74 
76  static eMaterial StringToMaterial(const AString & a_Material);
77 
78  // tolua_end
79 
80  bool IsRightPaddleUsed(void) const { return m_RightPaddleUsed; }
81  bool IsLeftPaddleUsed(void) const { return m_LeftPaddleUsed; }
82 
83  void SetLastDamage(int TimeSinceLastHit);
84 
85  void UpdatePaddles(bool rightPaddleUsed, bool leftPaddleUsed);
86 private:
89 
91 
93 
96 } ; // tolua_export
#define CLASS_PROTODEF(classname)
Definition: Entity.h:13
std::string AString
Definition: StringUtils.h:11
Definition: Chunk.h:36
Definition: Boat.h:20
virtual void BroadcastMovementUpdate(const cClientHandle *a_Exclude=nullptr) override
Updates clients of changes in the entity.
Definition: Boat.cpp:76
int GetForwardDirection(void) const
Definition: Boat.h:54
cBoat(Vector3d a_Pos, eMaterial a_Material)
Definition: Boat.cpp:49
virtual void SpawnOn(cClientHandle &a_ClientHandle) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
Definition: Boat.cpp:66
bool m_LeftPaddleUsed
Definition: Boat.h:95
static AString MaterialToString(const eMaterial a_Material)
Returns the eMaterial as string.
Definition: Boat.cpp:275
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: Boat.cpp:171
static eMaterial ItemToMaterial(const cItem &a_Item)
Returns the eMaterial that should be used for a boat created from the specified item.
Definition: Boat.cpp:253
virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Handles the physics of the entity - updates position based on speed, updates speed based on environme...
Definition: Boat.cpp:347
static eMaterial StringToMaterial(const AString &a_Material)
Returns the boat material for the passed string.
Definition: Boat.cpp:293
bool m_RightPaddleUsed
Definition: Boat.h:94
void UpdatePaddles(bool rightPaddleUsed, bool leftPaddleUsed)
Definition: Boat.cpp:235
int m_LastDamage
Definition: Boat.h:87
int GetLastDamage(void) const
Definition: Boat.h:53
eMaterial m_Material
Definition: Boat.h:92
virtual bool DoTakeDamage(TakeDamageInfo &TDI) override
Makes this entity take damage specified in the a_TDI.
Definition: Boat.cpp:100
float m_DamageTaken
Definition: Boat.h:90
void SetLastDamage(int TimeSinceLastHit)
Definition: Boat.cpp:223
bool IsLeftPaddleUsed(void) const
Definition: Boat.h:81
void SetMaterial(cBoat::eMaterial a_Material)
Sets the eMaterial of the boat.
Definition: Boat.h:64
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
Definition: Boat.cpp:140
float GetDamageTaken(void) const
Definition: Boat.h:56
eMaterial GetMaterial(void) const
Returns the eMaterial of the boat.
Definition: Boat.h:61
eMaterial
Definition: Boat.h:29
@ bmAcacia
Definition: Boat.h:34
@ bmOak
Definition: Boat.h:30
@ bmBirch
Definition: Boat.h:32
@ bmDarkOak
Definition: Boat.h:35
@ bmJungle
Definition: Boat.h:33
@ bmSpruce
Definition: Boat.h:31
int m_ForwardDirection
Definition: Boat.h:88
bool IsRightPaddleUsed(void) const
Definition: Boat.h:80
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override
Definition: Boat.cpp:206
static cItem MaterialToItem(eMaterial a_Material)
Returns the boat item of the boat material.
Definition: Boat.cpp:329
Definition: Entity.h:76
cEntity(eEntityType a_EntityType, Vector3d a_Pos, float a_Width, float a_Height)
Definition: Entity.cpp:37
Definition: Player.h:29
Definition: Item.h:37