1
0
Fork 0
cuberite-2a/src/BlockEntities/CommandBlockEntity.h

84 lines
1.6 KiB
C
Raw Normal View History

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