Cuberite
A lightweight, fast and extensible game server for Minecraft
Horse.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "PassiveMonster.h"
5 #include "../UI/WindowOwner.h"
6 
7 
8 
9 
10 
11 class cHorse:
12  public cPassiveMonster,
13  public cEntityWindowOwner
14 {
16 
17 public:
18 
19  cHorse(int Type, int Color, int Style, int TameTimes);
20 
22 
23  virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
24  virtual void InStateIdle(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
25  virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override;
26  virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
27  virtual void OnRemoveFromWorld(cWorld & a_World) override;
28  virtual void OnRightClicked(cPlayer & a_Player) override;
29 
30  bool IsSaddled (void) const {return !m_Saddle.IsEmpty(); }
31  bool IsChested (void) const {return m_bHasChest; }
32  bool IsEating (void) const {return m_bIsEating; }
33  bool IsRearing (void) const {return m_bIsRearing; }
34  bool IsMthOpen (void) const {return m_bIsMouthOpen; }
35  bool IsTame (void) const override {return m_bIsTame; }
36  int GetHorseType (void) const {return m_Type; }
37  int GetHorseColor (void) const {return m_Color; }
38  int GetHorseStyle (void) const {return m_Style; }
39  int GetHorseArmour (void) const;
40 
43  void SetHorseSaddle(cItem a_SaddleItem);
44 
47  void SetHorseArmor(cItem a_ArmorItem);
48 
49  const cItem & GetHorseSaddle() const { return m_Saddle; }
50  const cItem & GetHorseArmorItem() const { return m_Armor; }
51 
52  virtual void GetBreedingItems(cItems & a_Items) override
53  {
54  a_Items.Add(E_ITEM_GOLDEN_CARROT);
55  a_Items.Add(E_ITEM_GOLDEN_APPLE);
56  }
57 
58  void PlayerOpenWindow(cPlayer & a_Player);
59 
60 private:
61 
64  float m_MaxSpeed;
67 
68 } ;
@ E_ITEM_GOLDEN_APPLE
Definition: BlockType.h:366
@ E_ITEM_GOLDEN_CARROT
Definition: BlockType.h:442
#define CLASS_PROTODEF(classname)
Definition: Entity.h:13
Definition: Chunk.h:36
Definition: Entity.h:76
Definition: Player.h:29
Definition: Item.h:37
bool IsEmpty(void) const
Returns true if the item represents an empty stack - either the type is invalid, or count is zero.
Definition: Item.h:69
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215
void Add(const cItem &a_Item)
Definition: Item.h:233
Definition: Horse.h:14
bool IsTame(void) const override
Definition: Horse.h:35
bool IsEating(void) const
Definition: Horse.h:32
const cItem & GetHorseArmorItem() const
Definition: Horse.h:50
bool IsChested(void) const
Definition: Horse.h:31
cItem m_Armor
Definition: Horse.h:66
int GetHorseArmour(void) const
Definition: Horse.cpp:233
virtual void GetBreedingItems(cItems &a_Items) override
Returns the items that make the animal breed - this is usually the same as the ones that make the ani...
Definition: Horse.h:52
cItem m_Saddle
Definition: Horse.h:65
void SetHorseSaddle(cItem a_SaddleItem)
Set the horse's saddle to the given item.
Definition: Horse.cpp:195
bool m_bIsMouthOpen
Definition: Horse.h:62
bool IsSaddled(void) const
Definition: Horse.h:30
int GetHorseType(void) const
Definition: Horse.h:36
virtual void InStateIdle(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: Horse.cpp:281
int GetHorseStyle(void) const
Definition: Horse.h:38
void PlayerOpenWindow(cPlayer &a_Player)
Definition: Horse.cpp:306
int m_RearTickCount
Definition: Horse.h:63
bool m_bIsTame
Definition: Horse.h:62
virtual void OnRemoveFromWorld(cWorld &a_World) override
Called when the entity is removed from a world.
Definition: Horse.cpp:113
bool IsMthOpen(void) const
Definition: Horse.h:34
int m_TameAttemptTimes
Definition: Horse.h:63
int GetHorseColor(void) const
Definition: Horse.h:37
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override
Definition: Horse.cpp:294
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: Horse.cpp:35
void SetHorseArmor(cItem a_ArmorItem)
Set the horse's armor slot to the given item.
Definition: Horse.cpp:214
int m_Style
Definition: Horse.h:63
cHorse(int Type, int Color, int Style, int TameTimes)
Definition: Horse.cpp:13
int m_Color
Definition: Horse.h:63
bool m_bHasChest
Definition: Horse.h:62
int m_Type
Definition: Horse.h:63
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
Definition: Horse.cpp:128
bool IsRearing(void) const
Definition: Horse.h:33
virtual void GetDrops(cItems &a_Drops, cEntity *a_Killer=nullptr) override
Returns the list of drops for this pawn when it is killed.
Definition: Horse.cpp:254
float m_MaxSpeed
Definition: Horse.h:64
bool m_bIsEating
Definition: Horse.h:62
const cItem & GetHorseSaddle() const
Definition: Horse.h:49
bool m_bIsRearing
Definition: Horse.h:62
int m_TimesToTame
Definition: Horse.h:63
cPassiveMonster(const AString &a_ConfigName, eMonsterType a_MobType, const AString &a_SoundHurt, const AString &a_SoundDeath, const AString &a_SoundAmbient, float a_Width, float a_Height)
Window owner that is associated with an entity (chest minecart etc.)
Definition: WindowOwner.h:82
Definition: World.h:53