public bool Contains(Flow flow) { var list = flow.GetValue <IList>(this.list); var item = flow.GetValue <object>(this.item); return(list.Contains(item)); }
public object Get(Flow flow) { var list = flow.GetValue <IList>(this.list); var index = flow.GetValue <int>(this.index); return(list[index]); }
private bool IsDefined(Flow flow) { var name = flow.GetValue <string>(this.name); switch (kind) { case VariableKind.Flow: return(flow.variables.IsDefined(name)); case VariableKind.Graph: return(Variables.Graph(flow.stack).IsDefined(name)); case VariableKind.Object: return(Variables.Object(flow.GetValue <GameObject>(@object)).IsDefined(name)); case VariableKind.Scene: return(Variables.Scene(flow.stack.scene).IsDefined(name)); case VariableKind.Application: return(Variables.Application.IsDefined(name)); case VariableKind.Saved: return(Variables.Saved.IsDefined(name)); default: throw new UnexpectedEnumValueException <VariableKind>(kind); } }
private bool GreaterOrEqual(Flow flow) { var a = flow.GetValue <float>(this.a); var b = flow.GetValue <float>(this.b); return(a > b || Mathf.Approximately(a, b)); }
protected override void Process(Flow flow) { value = flow.GetValue <bool>(valueIn); owner.WaitWhile( () => flow.GetValue <bool>(conditionIn) == value, Finish); }
private object Get(Flow flow) { var dictionary = flow.GetValue <IDictionary>(this.dictionary); var key = flow.GetValue <object>(this.key); return(dictionary[key]); }
private bool Contains(Flow flow) { var dictionary = flow.GetValue <IDictionary>(this.dictionary); var key = flow.GetValue <object>(this.key); return(dictionary.Contains(key)); }
protected override bool ShouldTrigger(Flow flow, EmptyEventArgs args) { var navMeshAgent = flow.stack.gameObject.GetComponent <NavMeshAgent>(); return(navMeshAgent != null && navMeshAgent.remainingDistance <= flow.GetValue <float>(threshold) && (navMeshAgent.pathStatus == NavMeshPathStatus.PathComplete || !flow.GetValue <bool>(requireSuccess))); }
public ControlOutput Set(Flow flow) { var list = flow.GetValue <IList>(this.list); var index = flow.GetValue <int>(this.index); var item = flow.GetValue <object>(this.item); list[index] = item; return(exit); }
public ControlOutput Set(Flow flow) { var dictionary = flow.GetValue <IDictionary>(this.dictionary); var key = flow.GetValue <object>(this.key); var value = flow.GetValue <object>(this.value); dictionary[key] = value; return(exit); }
private ControlOutput Reset(Flow flow) { var data = flow.stack.GetElementData <Data>(this); data.duration = flow.GetValue <float>(duration); data.remaining = data.duration; data.unscaled = flow.GetValue <bool>(unscaledTime); return(null); }
private bool IsDefined(Flow flow) { var name = flow.GetValue <string>(this.name); if (string.IsNullOrEmpty(name)) { return(false); } GameObject @object = null; if (kind == VariableKind.Object) { @object = flow.GetValue <GameObject>(this.@object); if (@object == null) { return(false); } } var scene = flow.stack.scene; if (kind == VariableKind.Scene) { if (scene == null || !scene.Value.IsValid() || !scene.Value.isLoaded || !Variables.ExistInScene(scene)) { return(false); } } switch (kind) { case VariableKind.Flow: return(flow.variables.IsDefined(name)); case VariableKind.Graph: return(Variables.Graph(flow.stack).IsDefined(name)); case VariableKind.Object: return(Variables.Object(@object).IsDefined(name)); case VariableKind.Scene: return(Variables.Scene(scene.Value).IsDefined(name)); case VariableKind.Application: return(Variables.Application.IsDefined(name)); case VariableKind.Saved: return(Variables.Saved.IsDefined(name)); default: throw new UnexpectedEnumValueException <VariableKind>(kind); } }
public ControlOutput Remove(Flow flow) { var dictionary = flow.GetValue <IDictionary>(dictionaryInput); var key = flow.GetValue <object>(this.key); flow.SetValue(dictionaryOutput, dictionary); dictionary.Remove(key); return(exit); }
public T Operation(Flow flow) { if (inputCount == 2) { return(Operation(flow.GetValue <T>(multiInputs[0]), flow.GetValue <T>(multiInputs[1]))); } else { return(Operation(multiInputs.Select(flow.GetValue <T>))); } }
protected virtual ControlOutput Assign(Flow flow) { var input = flow.GetValue <object>(this.input); var name = flow.GetValue <string>(this.name); GetDeclarations(flow).Set(name, input); flow.SetValue(output, input); return(assigned); }
private int Start(Flow flow, out int currentIndex, out int lastIndex, out bool ascending) { var firstIndex = flow.GetValue <int>(this.firstIndex); lastIndex = flow.GetValue <int>(this.lastIndex); ascending = firstIndex <= lastIndex; currentIndex = firstIndex; flow.SetValue(this.currentIndex, currentIndex); return(flow.EnterLoop()); }
private ControlOutput Add(Flow flow) { var dictionary = flow.GetValue <IDictionary>(dictionaryInput); var key = flow.GetValue <object>(this.key); var value = flow.GetValue <object>(this.value); flow.SetValue(dictionaryOutput, dictionary); dictionary.Add(key, value); return(exit); }
public object Result(Flow flow) { var selector = flow.GetValue <T>(this.selector); foreach (var branch in branches) { if (Matches(branch.Key, selector)) { return(flow.GetValue(branch.Value)); } } return(flow.GetValue(@default)); }
public float Root(Flow flow) { var degree = flow.GetValue <float>(this.degree); var radicand = flow.GetValue <float>(this.radicand); if (degree == 2) { return(Mathf.Sqrt(radicand)); } else { return(Mathf.Pow(radicand, 1 / degree)); } }
private ControlOutput Start(Flow flow) { var data = flow.stack.GetElementData <Data>(this); data.elapsed = 0; data.duration = flow.GetValue <float>(duration); data.active = true; data.paused = false; data.unscaled = flow.GetValue <bool>(unscaledTime); AssignMetrics(flow, data); return(started); }
protected override IEnumerator Await(Flow flow) { var seconds = flow.GetValue <float>(this.seconds); if (flow.GetValue <bool>(unscaledTime)) { yield return(new WaitForSecondsRealtime(seconds)); } else { yield return(new WaitForSeconds(seconds)); } yield return(exit); }
protected override bool ShouldTrigger(Flow flow, EmptyEventArgs args) { var key = flow.GetValue <KeyCode>(this.key); var action = flow.GetValue <PressState>(this.action); switch (action) { case PressState.Down: return(Input.GetKeyDown(key)); case PressState.Up: return(Input.GetKeyUp(key)); case PressState.Hold: return(Input.GetKey(key)); default: throw new UnexpectedEnumValueException <PressState>(action); } }
public ControlOutput Enter(Flow flow) { var input = flow.GetValue(this.input); bool isNull; if (input is UnityObject) { // Required cast because of Unity's custom == operator. // ReSharper disable once ConditionIsAlwaysTrueOrFalse isNull = (UnityObject)input == null; } else { isNull = input == null; } if (isNull) { return(ifNull); } else { return(ifNotNull); } }
protected override bool ShouldTrigger(Flow flow, EmptyEventArgs args) { var buttonName = flow.GetValue <string>(this.buttonName); var action = flow.GetValue <PressState>(this.action); switch (action) { case PressState.Down: return(Input.GetButtonDown(buttonName)); case PressState.Up: return(Input.GetButtonUp(buttonName)); case PressState.Hold: return(Input.GetButton(buttonName)); default: throw new UnexpectedEnumValueException <PressState>(action); } }
public TOutput Operation(Flow flow) { switch (rounding) { case Rounding.Floor: return(Floor(flow.GetValue <TInput>(input))); case Rounding.AwayFromZero: return(AwayFromZero(flow.GetValue <TInput>(input))); case Rounding.Ceiling: return(Ceiling(flow.GetValue <TInput>(input))); default: throw new UnexpectedEnumValueException <Rounding>(rounding); } }
private int Start(Flow flow, out IEnumerator enumerator, out IDictionaryEnumerator dictionaryEnumerator, out int currentIndex) { if (dictionary) { dictionaryEnumerator = flow.GetValue <IDictionary>(collection).GetEnumerator(); enumerator = dictionaryEnumerator; } else { enumerator = flow.GetValue <IEnumerable>(collection).GetEnumerator(); dictionaryEnumerator = null; } currentIndex = -1; return(flow.EnterLoop()); }
private object Get(Flow flow) { var name = flow.GetValue <string>(this.name); VariableDeclarations variables; switch (kind) { case VariableKind.Flow: variables = flow.variables; break; case VariableKind.Graph: variables = Variables.Graph(flow.stack); break; case VariableKind.Object: variables = Variables.Object(flow.GetValue <GameObject>(@object)); break; case VariableKind.Scene: variables = Variables.Scene(flow.stack.scene); break; case VariableKind.Application: variables = Variables.Application; break; case VariableKind.Saved: variables = Variables.Saved; break; default: throw new UnexpectedEnumValueException <VariableKind>(kind); } if (specifyFallback && !variables.IsDefined(name)) { return(flow.GetValue(fallback)); } return(variables.Get(name)); }
public ControlOutput RemoveAt(Flow flow) { var list = flow.GetValue <IList>(listInput); var index = flow.GetValue <int>(this.index); if (list is Array) { var resizableList = new ArrayList(list); resizableList.RemoveAt(index); flow.SetValue(listOutput, resizableList.ToArray(list.GetType().GetElementType())); } else { list.RemoveAt(index); flow.SetValue(listOutput, list); } return(exit); }
private ControlOutput Clear(Flow flow) { var dictionary = flow.GetValue <IDictionary>(dictionaryInput); flow.SetValue(dictionaryOutput, dictionary); dictionary.Clear(); return(exit); }
public object Coalesce(Flow flow) { var input = flow.GetValue(this.input); bool isNull; if (input is UnityObject) { // Required cast because of Unity's custom == operator. // ReSharper disable once ConditionIsAlwaysTrueOrFalse isNull = (UnityObject)input == null; } else { isNull = input == null; } return(isNull ? flow.GetValue(fallback) : input); }