public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { for (var i = 0; i < Nodes.Count; i++) { var node = Nodes[i]; if (node != null) { var state = new NodeState(); var enumerator = Run(graph, variables, node, GetConnectionName(nameof(Nodes), i), state); CompositionManager.Instance.RunEnumerator(enumerator); _states.Add(state); } } while (_states.Count > 0) { for (var i = 0; i < _states.Count; i++) { var state = _states[i]; if (state.IsFinished) { _states.RemoveAt(i--); } } yield return(null); } }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { if (Loop != null) { var variable = Container.Execute(variables); if (variable.TryGetList(out var list)) { for (var i = 0; i < list.VariableCount; i++) { var item = list.GetVariable(i); yield return(SetValues(graph, variables, i, item)); } } else if (variable.TryGetDictionary(out var dictionary)) { var i = 0; var names = dictionary.VariableNames; foreach (var name in names) { var item = dictionary.GetVariable(name); yield return(SetValues(graph, variables, i++, item)); } } else { throw new VariableSourceException(); } } yield break; }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { if (Target.IsValid) { var target = Target.Execute <Object>(variables); if (target is GameObject gameObject) { gameObject.SetActive(true); } else if (target is Behaviour behaviour) { behaviour.enabled = true; } else if (target is Renderer renderer) { renderer.enabled = true; } else { Debug.LogWarningFormat(this, _invalidObjectWarning, name, Target); } } graph.GoTo(Next, nameof(Next)); yield break; }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { var text = Message.Execute(variables, VariableType.String); Debug.Log(text.AsString); graph.GoTo(Next, nameof(Next)); yield break; }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { if (Target.IsValid) { var target = Target.Execute <Object>(variables); Destroy(target); } graph.GoTo(Next, nameof(Next)); yield break; }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { for (var i = 0; i < Sequence.Count; i++) { var node = Sequence[i]; if (node) { yield return(graph.Run(node, variables, GetConnectionName(nameof(Sequence), i))); } } }
private IEnumerator SetValues(IGraphRunner graph, IVariableDictionary variables, int iteration, Variable item) { if (Index.IsValid) { Index.Execute(variables); // Variable.Int(iteration) } if (Value.IsValid) { Value.Execute(variables); // item } yield return(graph.Run(Loop, variables, nameof(Loop))); }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { var prefabVariable = Prefab.Resolve(variables); if (prefabVariable.TryGetObject(out GameObject prefab)) { GameObject spawned = null; var position = Position.Resolve(variables, VariableType.Vector3); var rotation = Rotation.Resolve(variables, VariableType.Quaternion); if (Positioning == ObjectPositioning.Absolute) { spawned = Instantiate(prefab, position.AsVector3, rotation.AsQuaternion); } else if (Positioning == ObjectPositioning.Relative) { if (Object.IsValid) { var obj = Object.Execute <GameObject>(variables); spawned = Instantiate(prefab, obj.transform.position + position.AsVector3, rotation.AsQuaternion); } } else if (Positioning == ObjectPositioning.Child) { if (Parent.IsValid) { var parent = Parent.Execute <GameObject>(variables); spawned = Instantiate(prefab, parent.transform.position + position.AsVector3, rotation.AsQuaternion, parent.transform); } } if (spawned) { var objectName = ObjectName.Resolve(variables, VariableType.String).AsString; if (!string.IsNullOrEmpty(objectName)) { spawned.name = objectName; } if (ObjectVariable.IsValid) { ObjectVariable.Assign(variables, Variable.Object(spawned)); } } } graph.GoTo(Next, nameof(Next)); yield break; }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { if (WaitForCompletion) { yield return(LoadScene(variables)); } else { CompositionManager.Instance.StartCoroutine(LoadScene(variables)); } graph.GoTo(Next, nameof(Next)); }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { var type = Type.GetType(ScriptableObjectType, false); var obj = CreateInstance(type); if (ObjectVariable.IsValid) { ObjectVariable.Assign(variables, Variable.Object(obj)); } graph.GoTo(Next, nameof(Next)); yield break; }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { var condition = Condition.Execute(variables, VariableType.Bool); if (condition.AsBool) { graph.GoTo(OnTrue, nameof(OnTrue)); } else { graph.GoTo(OnFalse, nameof(OnFalse)); } yield break; }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { var name = Switch.Execute(variables, VariableType.String).AsString; if (Outputs.TryGetValue(name, out var output)) { graph.GoTo(output, GetConnectionName(nameof(Outputs), name)); } else { graph.GoTo(Default, nameof(Default)); } yield break; }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { var variable = Time.Resolve(variables, VariableType.Float); if (UseScaledTime) { yield return(new WaitForSeconds(variable.AsFloat)); } else { yield return(new WaitForSecondsRealtime(variable.AsFloat)); } graph.GoTo(Next, nameof(Next)); }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { var index = Switch.Execute(variables, VariableType.Int).AsInt; if (index >= 0 && index < Outputs.Count) { graph.GoTo(Outputs[index], GetConnectionName(nameof(Outputs), index)); } else { graph.GoTo(Default, nameof(Default)); } yield break; }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { // TODO: inputs // TODO: add a RunParallel to IGraphRunner instead of CompositionManager.Instance.StartCoroutine var target = TargetGraph.Resolve <Graph>(variables); if (WaitForCompletion) { yield return(target.Execute()); } else { CompositionManager.Instance.StartCoroutine(target.Execute()); } graph.GoTo(Next, nameof(Next)); }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { var index = 0; while (true) { if (Index.IsValid) { Index.Assign(variables, Variable.Int(index++)); } var condition = Condition.Execute(variables, VariableType.Bool); if (!condition.AsBool || Loop == null) { break; } yield return(graph.Run(Loop, variables, nameof(Loop))); } }
private IEnumerator ProcessNode(IGraphRunner runner, GraphNode node, IVariableDictionary variables, string source) { if (node.IsBreakpoint && IsDebugBreakEnabled) { DebugPause(); OnBreakpointHit?.Invoke(this, node); } if (DebugState == PlaybackState.Paused && IsDebugLoggingEnabled) { Debug.Log($"(Frame {Time.frameCount}) Graph {name}: pausing at node '{node.name}'"); } while (DebugState == PlaybackState.Paused) { yield return(null); } if (DebugState == PlaybackState.Stopped) { yield break; } if (IsDebugLoggingEnabled) { Debug.Log($"(Frame {Time.frameCount}) Graph {name}: following '{source}' to node '{node.name}'"); } OnProcessFrame?.Invoke(node); yield return(node.Run(runner, variables)); if (DebugState == PlaybackState.Step) { DebugPause(); } }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { yield break; }
public abstract IEnumerator Run(IGraphRunner graph, IVariableDictionary variables);
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { Expression.Execute(variables); graph.GoTo(Next, nameof(Next)); yield break; }
public override IEnumerator Run(IGraphRunner graph, IVariableDictionary variables) { yield return(null); graph.GoTo(Next, nameof(Next)); }
private IEnumerator Run(IGraphRunner graph, IVariableDictionary variables, GraphNode node, string source, NodeState state) { yield return(graph.Run(node, variables, source)); state.IsFinished = true; }