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-01-18 08:16:47 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Json
|
|
|
|
{
|
|
|
|
class Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
|
|
|
|
class cCommandBlockEntity :
|
2014-01-18 14:27:54 -05:00
|
|
|
public cBlockEntity
|
2014-01-18 08:16:47 -05:00
|
|
|
{
|
|
|
|
typedef cBlockEntity super;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// tolua_end
|
|
|
|
|
|
|
|
/// Creates a new empty command block entity
|
|
|
|
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
|
|
|
|
|
|
|
|
bool LoadFromJson( const Json::Value& a_Value );
|
|
|
|
virtual void SaveToJson(Json::Value& a_Value ) override;
|
|
|
|
|
|
|
|
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
|
|
|
virtual void SendTo(cClientHandle & a_Client) override;
|
|
|
|
virtual void UsedBy(cPlayer * a_Player) override;
|
|
|
|
|
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
|
|
|
|
|
|
|
|
/// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate
|
|
|
|
void SetRedstonePower(bool a_IsPowered);
|
|
|
|
|
|
|
|
/// Sets the command block to execute a command in the next tick
|
|
|
|
void Activate(void);
|
|
|
|
|
|
|
|
/// Sets the command
|
|
|
|
void SetCommand(const AString & a_Cmd);
|
|
|
|
|
|
|
|
/// Retrieves stored command
|
|
|
|
const AString & GetCommand(void) const;
|
|
|
|
|
|
|
|
/// Retrieves the last line of output generated by the command block
|
|
|
|
const AString & GetLastOutput(void) const;
|
2014-01-18 08:40:47 -05:00
|
|
|
|
|
|
|
/// Retrieves the result (signal strength) of the last operation
|
|
|
|
NIBBLETYPE GetResult(void) const;
|
2014-01-18 08:16:47 -05:00
|
|
|
|
|
|
|
// tolua_end
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/// Executes the associated command
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|