GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
|
An instruction is a member of an event: It can be a condition or an action. More...
#include <Instruction.h>
Public Member Functions | |
Instruction (gd::String type_="") | |
Default constructor. More... | |
Instruction (gd::String type_, const std::vector< gd::Expression > ¶meters_, bool inverted=false) | |
Constructor. More... | |
const gd::String & | GetType () const |
Return the type of the instruction. More... | |
void | SetType (const gd::String &newType) |
Change the instruction type. More... | |
bool | IsInverted () const |
Return true if the condition is inverted. More... | |
void | SetInverted (bool inverted_) |
Set if the instruction is inverted or not. More... | |
bool | IsAwaited () const |
Return true if the async instruction should be awaited. This is not relevant if the instruction is not optionally asynchronous. More... | |
void | SetAwaited (bool awaited) |
Set if the async instruction is to be awaited or not. This is not relevant if the instruction is not optionally asynchronous. More... | |
std::size_t | GetParametersCount () const |
Return the number of parameters of the instruction. | |
void | SetParametersCount (std::size_t size) |
Change the number of parameter of the instruction. More... | |
const gd::Expression & | GetParameter (std::size_t index) const |
Get the value of a parameter. More... | |
gd::Expression & | GetParameter (std::size_t index) |
Get the value of a parameter. More... | |
void | SetParameter (std::size_t nb, const gd::Expression &val) |
void | AddParameter (const gd::Expression &val) |
const std::vector< gd::Expression > & | GetParameters () const |
Get a reference to the std::vector containing the parameters. More... | |
void | SetParameters (const std::vector< gd::Expression > &val) |
Replace all the parameters by new ones. More... | |
const gd::InstructionsList & | GetSubInstructions () const |
Return a reference to the vector containing sub instructions. | |
gd::InstructionsList & | GetSubInstructions () |
Return a reference to the vector containing sub instructions. | |
std::weak_ptr< Instruction > | GetOriginalInstruction () |
Return the original instruction this instruction was copied from. More... | |
Friends | |
std::shared_ptr< Instruction > | CloneRememberingOriginalElement (std::shared_ptr< Instruction > instruction) |
An instruction is a member of an event: It can be a condition or an action.
An instruction has a type, which define what it does, and some parameters. It can also be set as inverted (when the instruction is a condition) and it can have sub instructions. This class does nothing particular except storing these data.
gd::Instruction::Instruction | ( | gd::String | type_ = "" | ) |
Default constructor.
type | The type of the instruction |
gd::Instruction::Instruction | ( | gd::String | type_, |
const std::vector< gd::Expression > & | parameters_, | ||
bool | inverted = false |
||
) |
Constructor.
type | The type of the instruction |
parameters | A vector containing the parameters of the instruction |
inverted | true to set the instruction as inverted (used for condition instructions). |
void gd::Instruction::AddParameter | ( | const gd::Expression & | val | ) |
Add a parameter at the end
val | The new value of the parameter |
|
inline |
Return the original instruction this instruction was copied from.
Useful to get reference to the original instruction in memory during code generation, to ensure stable unique identifiers.
gd::Expression & gd::Instruction::GetParameter | ( | std::size_t | index | ) |
Get the value of a parameter.
Return an empty expression if the parameter requested does not exists.
const gd::Expression & gd::Instruction::GetParameter | ( | std::size_t | index | ) | const |
Get the value of a parameter.
Return an empty expression if the parameter requested does not exists.
|
inline |
Get a reference to the std::vector containing the parameters.
|
inline |
Return the type of the instruction.
|
inline |
Return true if the async instruction should be awaited. This is not relevant if the instruction is not optionally asynchronous.
|
inline |
Return true if the condition is inverted.
|
inline |
Set if the async instruction is to be awaited or not. This is not relevant if the instruction is not optionally asynchronous.
inverted | true if the instruction must be awaited |
|
inline |
Set if the instruction is inverted or not.
inverted | true if the condition must be set as inverted |
void gd::Instruction::SetParameter | ( | std::size_t | nb, |
const gd::Expression & | val | ||
) |
Change the specified parameter
nb | The parameter number |
val | The new value of the parameter |
|
inline |
Replace all the parameters by new ones.
val | A vector containing the new parameters. |
void gd::Instruction::SetParametersCount | ( | std::size_t | size | ) |
Change the number of parameter of the instruction.
If the new size if larger than the previous, new blank parameters are added.
|
inline |
Change the instruction type.
val | The new type of the instruction |
|
friend |
Clone the given instruction, returning an instruction for which GetOriginalInstruction()
returns the originally copied instruction.