2using System.Threading.Tasks;
73 public override Task
Parse(XmlElement Xml)
78 return base.Parse(Xml);
86 base.OnChildNodesUpdated();
88 this.@
event = this.GetChildElement<EventNode>(
true);
97 if (this.newState.
IsConstant && !
this.newState.IsEmpty && !Machine.
TryGetState(
this.newState.Definition, out _))
98 throw new Exception(
"State not found: " + this.newState.
Definition);
100 if (this.failureState.
IsConstant && !
this.failureState.IsEmpty && !Machine.
TryGetState(
this.failureState.Definition, out _))
101 throw new Exception(
"State not found: " + this.failureState.
Definition);
103 base.CheckReferences(Machine,
Token);
113 if (this.newState is
null)
126 if (this.failureState is
null)
170 if (this.@event is
null)
173 return await this.@
event.Register(EventIndex, Arguments,
this);
183 return this.@
event?.Unregister(EventIndex, Arguments) ?? Task.CompletedTask;
193 if (this.@event is
null)
196 return await this.@
event.StateUpdated(Arguments);
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Abstract base class for nodes referencing an action.
bool IsEmpty
If the definition is empty.
bool IsExpression
If the attribute value is an expression.
async Task< T > Evaluate(Variables Variables)
Evaluates the attribute
bool IsConstant
If the attribute value is a constant.
string Definition
Attribute definition
Scriptable string attribute.
Contains information required for evaluating script in a state-machine.
Variables Variables
Current set of variables.
Represents an event definition.
Abstract base class for State-Machine event nodes.
Action executed when entering a state.
bool HasFailureStateExpression
If the failure state is defined by an expression
bool HasFailureStateConstant
If the failure state is defined by a constant
Task Unregister(int EventIndex, EvaluationArguments Arguments)
Registers the event
string NewStateDefinition
New State Definition
override IStateMachineNode Create()
Creates a new node of the corresponding type.
override void OnChildNodesUpdated()
Method called whenever ChildNodes is updated.
override string LocalName
Local name
bool HasNewStateConstant
If the new state is defined by a constant
async Task< bool > Register(int EventIndex, EvaluationArguments Arguments)
Registers the event
string FailureStateDefinition
Failure State Definition
bool HasFailureState
If the event defines a failure state.
bool HasNewStateExpression
If the new state is defined by an expression
override Task Parse(XmlElement Xml)
Parses the State-machine node.
async Task< string > GetFailureState(EvaluationArguments Arguments)
Gets the failure state ID when the event is triggered.
OnEvent()
Action executed when entering a state.
override void CheckReferences(StateMachine Machine, Token Token)
Checks references in the node.
bool HasNewState
If the event defines a new state.
async Task< bool > StateUpdated(EvaluationArguments Arguments)
Method called when the internal state of the state-machine has been updated.
async Task< string > GetNewState(EvaluationArguments Arguments)
Gets the new state ID when the event is triggered.
Class representing a state machine.
bool TryGetState(string Id, out State State)
Tries to get a state.
Interface for State-Machine nodes