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  typedef cEntity super;
15 
16 public:
17  // tolua_end
18 
20 
21  cExpOrb(Vector3d a_Pos, int a_Reward);
22 
23  // Override functions
24  virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
25 
26  virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
27 
28  virtual void SpawnOn(cClientHandle & a_Client) override;
29 
30  // tolua_begin
31 
33  int GetAge(void) const { return std::chrono::duration_cast<cTickTime>(m_Timer).count(); }
34 
36  void SetAge(int a_Age) { m_Timer = cTickTime(a_Age); }
37 
39  int GetReward(void) const { return m_Reward; }
40 
42  void SetReward(int a_Reward) { m_Reward = a_Reward; }
43 
44  // tolua_end
45 
47  static std::vector<int> Split(int a_Reward);
48 
49 protected:
50  int m_Reward;
51 
53  std::chrono::milliseconds m_Timer;
54 } ; // tolua_export
Definition: FastNBT.h:131
std::chrono::duration< int, std::ratio_multiply< std::chrono::milliseconds::period, std::ratio< 50 >>> cTickTime
Definition: Globals.h:388
Definition: ExpOrb.h:11
static std::vector< int > Split(int a_Reward)
Split reward into small values according to regular Minecraft rules.
Definition: ExpOrb.cpp:110
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
Makes this entity take damage specified in the a_TDI.
Definition: ExpOrb.cpp:95
Definition: Chunk.h:49
void SetAge(int a_Age)
Set the number of ticks that this entity has existed.
Definition: ExpOrb.h:36
void SetReward(int a_Reward)
Set the exp amount.
Definition: ExpOrb.h:42
cEntity super
Definition: ExpOrb.h:14
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: ExpOrb.cpp:34
Definition: Entity.h:73
int GetAge(void) const
Returns the number of ticks that this entity has existed.
Definition: ExpOrb.h:33
#define CLASS_PROTODEF(classname)
Definition: Entity.h:11
std::chrono::milliseconds m_Timer
The number of ticks that the entity has existed / timer between collect and destroy; in msec...
Definition: ExpOrb.h:53
int m_Reward
Definition: ExpOrb.h:50
int GetReward(void) const
Get the exp amount.
Definition: ExpOrb.h:39
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