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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
|
2014-07-17 16:50:58 -04:00
|
|
|
class cCommandBlockEntity :
|
2015-06-26 18:24:51 -04:00
|
|
|
public cBlockEntity
|
2014-01-18 08:16:47 -05:00
|
|
|
{
|
2017-06-15 09:32:33 -04:00
|
|
|
typedef cBlockEntity Super;
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2014-01-18 08:16:47 -05:00
|
|
|
public:
|
|
|
|
|
|
|
|
// tolua_end
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2014-11-27 16:42:08 -05:00
|
|
|
BLOCKENTITY_PROTODEF(cCommandBlockEntity)
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Creates a new empty command block entity */
|
2017-06-15 09:32:33 -04:00
|
|
|
cCommandBlockEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
2014-01-18 08:16:47 -05:00
|
|
|
|
2017-06-15 09:32:33 -04:00
|
|
|
// cBlockEntity overrides:
|
|
|
|
virtual void CopyFrom(const cBlockEntity & a_Src) override;
|
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 command block to execute a command in the next tick */
|
2014-01-18 08:16:47 -05:00
|
|
|
void Activate(void);
|
2016-02-05 16:45:45 -05:00
|
|
|
|
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;
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2014-01-18 08:16:47 -05:00
|
|
|
// tolua_end
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2014-01-18 08:16:47 -05:00
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|