From 793acd267f4a5801e2aa9e9dca7cf51c5a595a02 Mon Sep 17 00:00:00 2001 From: Lane Kolbly Date: Wed, 12 Jul 2017 05:13:27 -0500 Subject: Changing pickup lifetime and combining semantics, making these adjustable in the lua api. (#3843) --- src/Entities/Pickup.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/Entities/Pickup.h') diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h index ed5949f37..c2fcbd7f2 100644 --- a/src/Entities/Pickup.h +++ b/src/Entities/Pickup.h @@ -25,7 +25,7 @@ public: CLASS_PROTODEF(cPickup) - cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); + cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f, int a_LifetimeTicks = 6000, bool a_CanCombine = true); cItem & GetItem(void) {return m_Item; } // tolua_export const cItem & GetItem(void) const {return m_Item; } @@ -36,12 +36,24 @@ public: virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + /** Returns whether this pickup is allowed to combine with other similar pickups */ + bool CanCombine(void) const { return m_bCanCombine; } // tolua_export + + /** Sets whether this pickup is allowed to combine with other similar pickups */ + void SetCanCombine(bool a_CanCombine) { m_bCanCombine = a_CanCombine; } // tolua_export + /** Returns the number of ticks that this entity has existed */ int GetAge(void) const { return std::chrono::duration_cast(m_Timer).count(); } // tolua_export /** Set the number of ticks that this entity has existed */ void SetAge(int a_Age) { m_Timer = cTickTime(a_Age); } // tolua_export + /** Returns the number of ticks that this pickup should live for */ + int GetLifetime(void) const { return std::chrono::duration_cast(m_Lifetime).count(); } // tolua_export + + /** Set the number of ticks that this pickup should live for */ + void SetLifetime(int a_Lifetime) { m_Lifetime = cTickTime(a_Lifetime); } // tolua_export + /** Returns true if the pickup has already been collected */ bool IsCollected(void) const { return m_bCollected; } // tolua_export @@ -58,4 +70,8 @@ private: bool m_bCollected; bool m_bIsPlayerCreated; + + bool m_bCanCombine; + + std::chrono::milliseconds m_Lifetime; }; // tolua_export -- cgit v1.2.3