2013-07-29 07:13:03 -04: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 16:02:28 -05:00
|
|
|
// tolua_begin
|
|
|
|
class cDropSpenserEntity :
|
2014-08-06 08:17:05 -04:00
|
|
|
public cBlockEntityWithItems
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
typedef cBlockEntityWithItems super;
|
|
|
|
|
|
|
|
public:
|
2014-07-19 09:23:40 -04:00
|
|
|
enum
|
|
|
|
{
|
2013-07-29 07:13:03 -04:00
|
|
|
ContentsHeight = 3,
|
|
|
|
ContentsWidth = 3,
|
|
|
|
} ;
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
// tolua_end
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2014-11-27 16:42:08 -05:00
|
|
|
BLOCKENTITY_PROTODEF(cDropSpenserEntity)
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
cDropSpenserEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
|
|
|
virtual ~cDropSpenserEntity();
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
// cBlockEntity overrides:
|
2015-01-11 16:12:26 -05:00
|
|
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
2013-07-29 07:13:03 -04:00
|
|
|
virtual void SendTo(cClientHandle & a_Client) override;
|
2015-12-01 17:12:44 -05:00
|
|
|
virtual bool UsedBy(cPlayer * a_Player) override;
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
// tolua_begin
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Modifies the block coords to match the dropspenser direction given (where the dropspensed pickups should materialize) */
|
2013-07-29 07:13:03 -04:00
|
|
|
void AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction);
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Sets the dropspenser to dropspense an item in the next tick */
|
2013-07-29 07:13:03 -04:00
|
|
|
void Activate(void);
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2014-08-06 08:17:05 -04:00
|
|
|
// tolua_end
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_ShouldDropSpense; ///< If true, the dropspenser will dropspense an item in the next tick
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Does the actual work on dropspensing an item. Chooses the slot, calls DropSpenseFromSlot() and handles smoke / sound effects */
|
2013-07-29 07:13:03 -04:00
|
|
|
void DropSpense(cChunk & a_Chunk);
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...) */
|
2013-07-29 07:13:03 -04:00
|
|
|
virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) = 0;
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Helper function, drops one item from the specified slot (like a dropper) */
|
2013-07-29 07:13:03 -04:00
|
|
|
void DropFromSlot(cChunk & a_Chunk, int a_SlotNum);
|
|
|
|
} ; // tolua_export
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|