private IEnumerable InvokeCoroutineDelegate(ControlInput input) { var instructions = input.coroutineAction(this); while (true) { object instruction; try { if (!instructions.MoveNext()) { break; } instruction = instructions.Current; } catch (Exception ex) { input.unit.HandleException(stack, ex); throw; } yield return(instruction); } }
protected override void Definition() { enter = ControlInput("enter", ProcessInternal); exit = ControlOutput("exit"); Succession(enter, exit); }
protected ControlInput ControlInputCoroutine(string key, Func <Flow, ControlOutput> action, Func <Flow, IEnumerator> coroutineAction) { EnsureUniqueInput(key); var port = new ControlInput(key, action, coroutineAction); controlInputs.Add(port); return(port); }
protected ControlInput ControlInput(string key, Func <Flow, ControlOutput> action) { EnsureUniqueInput(key); var port = new ControlInput(key, action); controlInputs.Add(port); return(port); }
protected override void Definition() { enterTrue = ControlInput("true", ProcessTrue); enterFalse = ControlInput("false", ProcessFalse); exit = ControlOutput("exit"); valueOut = ValueOutput("value", (flow) => m_value); Succession(enterTrue, exit); Succession(enterFalse, exit); }
private ControlOutput InvokeDelegate(ControlInput input) { try { if (input.requiresCoroutine) { throw new InvalidOperationException($"Port '{input.key}' on '{input.unit}' can only be triggered in a coroutine."); } return(input.action(this)); } catch (Exception ex) { input.unit.HandleException(stack, ex); throw; } }
/// <summary> /// Triggering the source may trigger the destination. /// </summary> protected void Succession(ControlInput source, ControlOutput destination) { Relation(source, destination); }
/// <summary> /// Triggering the source may assign the destination value on the flow. /// </summary> protected void Assignment(ControlInput source, ValueOutput destination) { Relation(source, destination); }
/// <summary> /// Triggering the destination may fetch the source value. /// </summary> protected void Requirement(ValueInput source, ControlInput destination) { Relation(source, destination); }
protected override void Definition() { trigger = ControlInput(nameof(trigger), Trigger); }
protected override void Definition() { enter = ControlInput(nameof(enter), Operation); }