Cuberite
A lightweight, fast and extensible game server for Minecraft
ExpOrb.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Entity.h"
5 
6 
7 
8 
9 
10 // tolua_begin
11 class cExpOrb:
12  public cEntity
13 {
14  // tolua_end
15 
16  using Super = cEntity;
17 
18 public: // tolua_export
19 
21 
22  cExpOrb(Vector3d a_Pos, int a_Reward);
23 
24  // Override functions
25  virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
26 
27  virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
28 
29  virtual void SpawnOn(cClientHandle & a_Client) override;
30 
31  // tolua_begin
32 
34  int GetAge(void) const { return std::chrono::duration_cast<cTickTime>(m_Timer).count(); }
35 
37  void SetAge(int a_Age) { m_Timer = cTickTime(a_Age); }
38 
40  int GetReward(void) const { return m_Reward; }
41 
43  void SetReward(int a_Reward) { m_Reward = a_Reward; }
44 
45  // tolua_end
46 
48  static std::vector<int> Split(int a_Reward);
49 
50 protected:
51  int m_Reward;
52 
54  std::chrono::milliseconds m_Timer;
55 } ; // tolua_export
#define CLASS_PROTODEF(classname)
Definition: Entity.h:13
std::chrono::duration< signed int, std::ratio_multiply< std::chrono::milliseconds::period, std::ratio< 50 > >> cTickTime
Definition: Globals.h:364
Definition: Chunk.h:36
Definition: Entity.h:76
cEntity(eEntityType a_EntityType, Vector3d a_Pos, float a_Width, float a_Height)
Definition: Entity.cpp:37
Definition: ExpOrb.h:13
cExpOrb(Vector3d a_Pos, int a_Reward)
Definition: ExpOrb.cpp:8
int m_Reward
Definition: ExpOrb.h:51
static std::vector< int > Split(int a_Reward)
Split reward into small values according to regular Minecraft rules.
Definition: ExpOrb.cpp:110
void SetAge(int a_Age)
Set the number of ticks that this entity has existed.
Definition: ExpOrb.h:37
std::chrono::milliseconds m_Timer
The number of ticks that the entity has existed / timer between collect and destroy; in msec.
Definition: ExpOrb.h:54
int GetReward(void) const
Get the exp amount.
Definition: ExpOrb.h:40
int GetAge(void) const
Returns the number of ticks that this entity has existed.
Definition: ExpOrb.h:34
void SetReward(int a_Reward)
Set the exp amount.
Definition: ExpOrb.h:43
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: ExpOrb.cpp:34
virtual void SpawnOn(cClientHandle &a_Client) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
Definition: ExpOrb.cpp:23
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
Makes this entity take damage specified in the a_TDI.
Definition: ExpOrb.cpp:95