2012-06-14 13:06:06 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-09-23 22:09:57 +00:00
|
|
|
#include "Entity.h"
|
2013-08-19 09:39:13 +00:00
|
|
|
#include "../Item.h"
|
2012-12-28 02:45:20 +00:00
|
|
|
|
2012-06-14 13:06:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cPlayer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-24 07:58:26 +00:00
|
|
|
// tolua_begin
|
|
|
|
class cPickup :
|
|
|
|
public cEntity
|
|
|
|
{
|
2014-02-03 22:51:26 +00:00
|
|
|
// tolua_end
|
|
|
|
|
2020-04-13 16:38:06 +00:00
|
|
|
using Super = cEntity;
|
2019-09-29 12:59:24 +00:00
|
|
|
|
|
|
|
public: // tolua_export
|
|
|
|
|
2014-07-22 22:36:13 +00:00
|
|
|
CLASS_PROTODEF(cPickup)
|
2012-06-14 13:06:06 +00:00
|
|
|
|
2019-09-29 12:59:24 +00:00
|
|
|
cPickup(Vector3d a_Pos, const cItem & a_Item, bool IsPlayerCreated, Vector3f a_Speed = Vector3f(), int a_LifetimeTicks = 6000, bool a_CanCombine = true);
|
2014-03-14 23:43:38 +00:00
|
|
|
|
2014-07-17 20:15:34 +00:00
|
|
|
cItem & GetItem(void) {return m_Item; } // tolua_export
|
2012-12-28 02:45:20 +00:00
|
|
|
const cItem & GetItem(void) const {return m_Item; }
|
2012-06-14 13:06:06 +00:00
|
|
|
|
2012-08-24 07:58:26 +00:00
|
|
|
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
2014-03-14 23:43:38 +00:00
|
|
|
|
2014-10-15 17:01:55 +00:00
|
|
|
bool CollectedBy(cPlayer & a_Dest); // tolua_export
|
2012-06-14 13:06:06 +00:00
|
|
|
|
2015-01-11 21:12:26 +00:00
|
|
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
2014-03-14 23:43:38 +00:00
|
|
|
|
2018-01-16 19:13:17 +00:00
|
|
|
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
|
|
|
|
2017-07-28 16:59:21 +00:00
|
|
|
virtual bool DoesPreventBlockPlacement(void) const override { return false; }
|
|
|
|
|
2017-07-12 10:13:27 +00:00
|
|
|
/** 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
|
|
|
|
|
2014-03-14 23:43:38 +00:00
|
|
|
/** Returns the number of ticks that this entity has existed */
|
2015-01-16 13:49:22 +00:00
|
|
|
int GetAge(void) const { return std::chrono::duration_cast<cTickTime>(m_Timer).count(); } // tolua_export
|
2014-03-14 23:43:38 +00:00
|
|
|
|
|
|
|
/** Set the number of ticks that this entity has existed */
|
2015-01-16 13:49:22 +00:00
|
|
|
void SetAge(int a_Age) { m_Timer = cTickTime(a_Age); } // tolua_export
|
2014-03-14 23:43:38 +00:00
|
|
|
|
2017-07-12 10:13:27 +00:00
|
|
|
/** Returns the number of ticks that this pickup should live for */
|
|
|
|
int GetLifetime(void) const { return std::chrono::duration_cast<cTickTime>(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
|
|
|
|
|
2014-03-14 23:43:38 +00:00
|
|
|
/** Returns true if the pickup has already been collected */
|
2013-08-19 09:58:20 +00:00
|
|
|
bool IsCollected(void) const { return m_bCollected; } // tolua_export
|
2013-10-23 23:30:20 +00:00
|
|
|
|
2014-03-14 23:43:38 +00:00
|
|
|
/** Returns true if created by player (i.e. vomiting), used for determining picking-up delay time */
|
2014-07-17 20:15:34 +00:00
|
|
|
bool IsPlayerCreated(void) const { return m_bIsPlayerCreated; } // tolua_export
|
2014-03-14 23:43:38 +00:00
|
|
|
|
2012-06-14 13:06:06 +00:00
|
|
|
private:
|
|
|
|
|
2014-03-14 23:43:38 +00:00
|
|
|
/** The number of ticks that the entity has existed / timer between collect and destroy; in msec */
|
2015-01-16 13:49:22 +00:00
|
|
|
std::chrono::milliseconds m_Timer;
|
2012-06-14 13:06:06 +00:00
|
|
|
|
2012-12-28 02:45:20 +00:00
|
|
|
cItem m_Item;
|
2012-06-14 13:06:06 +00:00
|
|
|
|
|
|
|
bool m_bCollected;
|
2013-10-23 23:30:20 +00:00
|
|
|
|
|
|
|
bool m_bIsPlayerCreated;
|
2017-07-12 10:13:27 +00:00
|
|
|
|
|
|
|
bool m_bCanCombine;
|
|
|
|
|
|
|
|
std::chrono::milliseconds m_Lifetime;
|
2013-01-12 04:46:01 +00:00
|
|
|
}; // tolua_export
|