Cuberite
A lightweight, fast and extensible game server for Minecraft
PassiveMonster.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Monster.h"
5 
6 
7 
8 
9 
11  public cMonster
12 {
13  typedef cMonster super;
14 
15 public:
16  cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
17 
18  virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
19  virtual void OnRightClicked(cPlayer & a_Player) override;
20 
22  virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
23 
25  virtual void GetFollowedItems(cItems & a_Items) { }
26 
28  virtual void GetBreedingItems(cItems & a_Items) { GetFollowedItems(a_Items); }
29 
31  virtual void InheritFromParents(cPassiveMonster * a_Parent1, cPassiveMonster * a_Parent2) { }
32 
34  cPassiveMonster * GetPartner(void) const { return m_LovePartner; }
35 
37  void EngageLoveMode(cPassiveMonster * a_Partner);
38 
40  void ResetLoveMode();
41 
43  bool IsInLove() const { return (m_LoveTimer > 0); }
44 
46  bool IsInLoveCooldown() const { return (m_LoveCooldown > 0); }
47 
48  virtual void Destroyed(void) override;
49 
50 protected:
53 
56 
59 
62 };
63 
64 
65 
66 
virtual void Destroyed(void) override
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
When hit by someone, run away.
Definition: Player.h:27
void EngageLoveMode(cPassiveMonster *a_Partner)
Start the mating process.
bool IsInLove() const
Returns whether the monster has just been fed and is ready to mate.
Definition: Chunk.h:49
eMonsterType
Identifies individual monster type, as well as their network type-ID.
Definition: MonsterTypes.h:10
cPassiveMonster(const AString &a_ConfigName, eMonsterType a_MobType, const AString &a_SoundHurt, const AString &a_SoundDeath, double a_Width, double a_Height)
int m_LoveTimer
If above 0, the monster is in love mode, and will breed if a nearby monster is also in love mode...
void ResetLoveMode()
Finish the mating process.
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
virtual void GetBreedingItems(cItems &a_Items)
Returns the items that make the animal breed - this is usually the same as the ones that make the ani...
virtual void InheritFromParents(cPassiveMonster *a_Parent1, cPassiveMonster *a_Parent2)
Called after the baby is born, allows the baby to inherit the parents' properties (color...
virtual void GetFollowedItems(cItems &a_Items)
Returns the items that the animal of this class follows when a player holds it in hand...
std::string AString
Definition: StringUtils.h:13
cPassiveMonster * m_LovePartner
The monster's breeding partner.
int m_LoveCooldown
If above 0, the monster is in cooldown mode and will refuse to breed.
int m_MatingTimer
The monster is engaged in mating, once this reaches zero, a baby will be born.
bool IsInLoveCooldown() const
Returns whether the monster is tired of breeding and is in the cooldown state.
cPassiveMonster * GetPartner(void) const
Returns the partner which the monster is currently mating with.
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:234