2013-07-29 11:13:03 +00:00
|
|
|
|
|
|
|
// DropSpenser.h
|
|
|
|
|
|
|
|
// Declares the cDropSpenser class representing a common ancestor to the cDispenserEntity and cDropperEntity
|
|
|
|
// The dropper and dispenser only needs to override the DropSpenseFromSlot() function to provide the specific item behavior
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BlockEntityWithItems.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cClientHandle;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-16 21:02:28 +00:00
|
|
|
// tolua_begin
|
|
|
|
class cDropSpenserEntity :
|
2014-08-06 12:17:05 +00:00
|
|
|
public cBlockEntityWithItems
|
2013-07-29 11:13:03 +00:00
|
|
|
{
|
2019-09-29 12:59:24 +00:00
|
|
|
// tolua_end
|
|
|
|
|
|
|
|
using super = cBlockEntityWithItems;
|
|
|
|
|
|
|
|
// tolua_begin
|
2013-07-29 11:13:03 +00:00
|
|
|
|
|
|
|
public:
|
2019-09-29 12:59:24 +00:00
|
|
|
|
2014-07-19 13:23:40 +00:00
|
|
|
enum
|
|
|
|
{
|
2013-07-29 11:13:03 +00:00
|
|
|
ContentsHeight = 3,
|
|
|
|
ContentsWidth = 3,
|
|
|
|
} ;
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2013-07-29 11:13:03 +00:00
|
|
|
// tolua_end
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2014-11-27 21:42:08 +00:00
|
|
|
BLOCKENTITY_PROTODEF(cDropSpenserEntity)
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2019-09-29 12:59:24 +00:00
|
|
|
cDropSpenserEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
|
2017-05-20 06:16:28 +00:00
|
|
|
virtual ~cDropSpenserEntity() override;
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2013-07-29 11:13:03 +00:00
|
|
|
// cBlockEntity overrides:
|
2017-06-16 14:20:33 +00:00
|
|
|
virtual void CopyFrom(const cBlockEntity & a_Src) override;
|
2015-01-11 21:12:26 +00:00
|
|
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
2013-07-29 11:13:03 +00:00
|
|
|
virtual void SendTo(cClientHandle & a_Client) override;
|
2015-12-01 22:12:44 +00:00
|
|
|
virtual bool UsedBy(cPlayer * a_Player) override;
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2013-07-29 11:13:03 +00:00
|
|
|
// tolua_begin
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2015-07-31 14:49:10 +00:00
|
|
|
/** Modifies the block coords to match the dropspenser direction given (where the dropspensed pickups should materialize) */
|
2019-09-29 12:59:24 +00:00
|
|
|
void AddDropSpenserDir(Vector3i & a_RelCoord, NIBBLETYPE a_Direction);
|
2013-07-29 11:13:03 +00:00
|
|
|
|
2015-07-31 14:49:10 +00:00
|
|
|
/** Sets the dropspenser to dropspense an item in the next tick */
|
2013-07-29 11:13:03 +00:00
|
|
|
void Activate(void);
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2014-08-06 12:17:05 +00:00
|
|
|
// tolua_end
|
2013-07-29 11:13:03 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_ShouldDropSpense; ///< If true, the dropspenser will dropspense an item in the next tick
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2015-07-31 14:49:10 +00:00
|
|
|
/** Does the actual work on dropspensing an item. Chooses the slot, calls DropSpenseFromSlot() and handles smoke / sound effects */
|
2013-07-29 11:13:03 +00:00
|
|
|
void DropSpense(cChunk & a_Chunk);
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2015-07-31 14:49:10 +00:00
|
|
|
/** Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...) */
|
2013-07-29 11:13:03 +00:00
|
|
|
virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) = 0;
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2015-07-31 14:49:10 +00:00
|
|
|
/** Helper function, drops one item from the specified slot (like a dropper) */
|
2013-07-29 11:13:03 +00:00
|
|
|
void DropFromSlot(cChunk & a_Chunk, int a_SlotNum);
|
|
|
|
} ; // tolua_export
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|