2014-01-18 08:16:47 -05:00
|
|
|
|
|
|
|
// CommandBlockEntity.h
|
|
|
|
|
|
|
|
// Declares the cCommandBlockEntity class representing a single command block in the world
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-01-18 14:27:54 -05:00
|
|
|
#include "BlockEntity.h"
|
2014-09-11 12:48:21 -04:00
|
|
|
#include "RedstonePoweredEntity.h"
|
2014-01-18 08:16:47 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
|
2014-07-17 16:50:58 -04:00
|
|
|
class cCommandBlockEntity :
|
2014-09-11 12:48:21 -04:00
|
|
|
public cBlockEntity,
|
|
|
|
public cRedstonePoweredEntity
|
2014-01-18 08:16:47 -05:00
|
|
|
{
|
|
|
|
typedef cBlockEntity super;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// tolua_end
|
|
|
|
|
2014-11-27 16:42:08 -05:00
|
|
|
BLOCKENTITY_PROTODEF(cCommandBlockEntity)
|
2014-10-19 06:46:25 -04:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Creates a new empty command block entity */
|
2014-01-18 08:16:47 -05:00
|
|
|
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
|
|
|
|
|
2015-01-11 16:12:26 -05:00
|
|
|
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
2014-01-18 08:16:47 -05:00
|
|
|
virtual void SendTo(cClientHandle & a_Client) override;
|
2015-12-01 17:12:44 -05:00
|
|
|
virtual bool UsedBy(cPlayer * a_Player) override;
|
2014-01-18 08:16:47 -05:00
|
|
|
|
2014-01-18 08:40:47 -05:00
|
|
|
void SetLastOutput(const AString & a_LastOut);
|
|
|
|
|
|
|
|
void SetResult(const NIBBLETYPE a_Result);
|
|
|
|
|
2014-01-18 08:16:47 -05:00
|
|
|
// tolua_begin
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate */
|
2014-09-11 12:48:21 -04:00
|
|
|
virtual void SetRedstonePower(bool a_IsPowered) override;
|
2014-01-18 08:16:47 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Sets the command block to execute a command in the next tick */
|
2014-01-18 08:16:47 -05:00
|
|
|
void Activate(void);
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Sets the command */
|
2014-01-18 08:16:47 -05:00
|
|
|
void SetCommand(const AString & a_Cmd);
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Retrieves stored command */
|
2014-01-18 08:16:47 -05:00
|
|
|
const AString & GetCommand(void) const;
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Retrieves the last line of output generated by the command block */
|
2014-01-18 08:16:47 -05:00
|
|
|
const AString & GetLastOutput(void) const;
|
2014-01-18 08:40:47 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Retrieves the result (signal strength) of the last operation */
|
2014-01-18 08:40:47 -05:00
|
|
|
NIBBLETYPE GetResult(void) const;
|
2014-01-18 08:16:47 -05:00
|
|
|
|
|
|
|
// tolua_end
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Executes the associated command */
|
2014-01-18 08:16:47 -05:00
|
|
|
void Execute();
|
|
|
|
|
|
|
|
bool m_ShouldExecute;
|
|
|
|
bool m_IsPowered;
|
|
|
|
|
2014-01-18 08:40:47 -05:00
|
|
|
AString m_Command;
|
|
|
|
|
|
|
|
AString m_LastOutput;
|
2014-01-18 08:16:47 -05:00
|
|
|
|
2014-01-18 08:40:47 -05:00
|
|
|
NIBBLETYPE m_Result;
|
2014-01-18 08:16:47 -05:00
|
|
|
} ; // tolua_export
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|