public override IEnumerator Run(InstructionGraph graph, InstructionStore variables, int iteration) { if (ResolveObject(variables, Target, out Object target)) { Destroy(target); } graph.GoTo(Next, nameof(Next)); yield break; }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { var condition = Condition.Execute(this, variables, VariableType.Boolean); if (condition.Boolean && Loop != null) { graph.GoTo(Loop, variables.This, nameof(Loop)); } yield break; }
public override IEnumerator Run(InstructionGraph graph, InstructionStore variables, int iteration) { if (ResolveObject(variables, Animator, out Animator animator)) { Trigger(variables, animator); } graph.GoTo(Next, nameof(Next)); yield break; }
public override IEnumerator Run(InstructionGraph graph, InstructionStore variables, int iteration) { if (ResolveObject(variables, Object, out BindingRoot root)) { root.Value = Binding.GetValue(variables); VariableBinding.UpdateBinding(root.gameObject, null, null); } graph.GoTo(Next, nameof(Next)); yield break; }
public override IEnumerator Run(InstructionGraph graph, InstructionStore variables, int iteration) { if (ResolveObject(variables, Effect, out var effect)) { GameObject spawned = null; Resolve(variables, Position, out var position); Resolve(variables, Rotation, out var rotation); if (Positioning == ObjectPositioning.Absolute) { spawned = Instantiate(effect, position, Quaternion.Euler(rotation)); } else if (Positioning == ObjectPositioning.Relative) { if (ResolveObject(variables, Object, out GameObject obj)) { spawned = Instantiate(effect, obj.transform.position + position, Quaternion.Euler(rotation)); } } else if (Positioning == ObjectPositioning.Child) { if (ResolveObject(variables, Parent, out GameObject parent)) { spawned = Instantiate(effect, parent.transform.position + position, Quaternion.Euler(rotation), parent.transform); } } if (spawned) { if (Resolve(variables, EffectName, out var effectName) && !string.IsNullOrEmpty(effectName)) { spawned.name = effectName; } if (EffectVariable.IsAssigned) { Assign(variables, EffectVariable, VariableValue.Create(spawned)); } } if (WaitForCompletion) { yield return(WaitForFinish(spawned)); } else if (DestroyOnComplete) { CompositionManager.Instance.StartCoroutine(WaitForFinish(spawned)); } } graph.GoTo(Next, nameof(Next)); }
public override void GetInputs(List <VariableDefinition> inputs) { foreach (var node in Nodes) { if (InstructionStore.IsInput(node.This)) { inputs.Add(VariableDefinition.Create(node.This.RootName, VariableType.Empty)); } node.GetInputs(inputs); } }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { if (WaitForCompletion) { yield return(Instruction.Execute(variables.Context, variables.This)); } else { InstructionManager.Instance.RunInstruction(Instruction, variables.Context, variables.This); } graph.GoTo(Next, variables.This, nameof(Next)); }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { if (WaitForCompletion) { InstructionManager.Instance.StartCoroutine(LoadScene()); } else { yield return(LoadScene()); } graph.GoTo(Next, variables.This, nameof(Next)); }
public override IEnumerator Run(InstructionGraph graph, InstructionStore variables, int iteration) { if (WaitForCompletion) { yield return(LoadScene(variables)); } else { CompositionManager.Instance.StartCoroutine(LoadScene(variables)); } graph.GoTo(Next, nameof(Next)); }
public IEnumerator Execute(InstructionContext context, object thisObject) { if (Instruction) { var store = new InstructionStore(context, thisObject); store.WriteInputs(_inputs); store.WriteOutputs(_outputs); yield return(Instruction.Execute(store)); store.ReadOutputs(_outputs); } }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { if (Time.TryGetValue(variables, this, out var time)) { yield return(new WaitForSeconds(time)); } else { Debug.LogFormat(this, _timeNotFoundWarning, Name); } graph.GoTo(Next, variables.This, nameof(Next)); }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { if (Transition.TryGetValue(variables, this, out var transition)) { yield return(AutoFinish ? TransitionManager.Instance.RunTransition(transition, Phase) : TransitionManager.Instance.StartTransition(transition, Phase)); } else { Debug.LogWarningFormat(this, _transitionMissingWarning, Name); } graph.GoTo(Next, variables.This, nameof(Next)); }
public override void GetOutputs(IList <VariableDefinition> outputs) { if (Source == InstructionSource.Value) { foreach (var output in Instruction.Outputs) { if (InstructionStore.IsOutput(output)) { outputs.Add(Instruction.GetOutputDefinition(output)); } } } }
public override IEnumerator Run(InstructionGraph graph, InstructionStore variables, int iteration) { if (ResolveObject <Animator>(variables, Animator, out var animator)) { if (Resolve(variables, State, out var state)) { animator.Play(state); } } graph.GoTo(Next, nameof(Next)); yield break; }
private void SetValues(InstructionGraph graph, InstructionStore variables, int iteration, VariableValue item) { if (Index.IsAssigned) { Index.SetValue(variables, VariableValue.Create(iteration)); } if (Value.IsAssigned) { Value.SetValue(variables, item); } graph.GoTo(Loop, nameof(Loop)); }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { if (iteration < Sequence.Count) { if (Sequence[iteration] == null) { Debug.LogErrorFormat(this, _invalidSequenceError, Name, iteration); } graph.GoTo(Sequence[iteration], variables.This, nameof(Sequence), iteration); } yield break; }
public virtual void GetInputs(IList <VariableDefinition> inputs) { var fields = GetType().GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (var field in fields) { if (field.FieldType == typeof(VariableReference)) { var value = field.GetValue(this) as VariableReference; var constraint = field.GetCustomAttribute <VariableConstraintAttribute>(); var definition = new VariableDefinition { Name = value.RootName, Definition = constraint == null?ValueDefinition.Create(VariableType.Empty) : constraint.Definition }; if (InstructionStore.IsInput(value)) { inputs.Add(definition); } } else if (field.FieldType == typeof(Expression)) { var value = field.GetValue(this) as Expression; value.GetInputs(inputs, InstructionStore.InputStoreName); } else if (field.FieldType == typeof(Message)) { var value = field.GetValue(this) as Message; value.GetInputs(inputs); } else if (typeof(VariableSource).IsAssignableFrom(field.FieldType)) { var value = field.GetValue(this) as VariableSource; var constraint = field.GetCustomAttribute <VariableConstraintAttribute>(); if (constraint != null) { if (value.Type == VariableSourceType.Reference && InstructionStore.IsInput(value.Reference)) { inputs.Add(new VariableDefinition { Name = value.Reference.RootName, Definition = constraint.Definition }); } } else { value.GetInputs(inputs); } } } }
public IEnumerator Execute(InstructionStore variables) { if (IsRunning) { Debug.LogErrorFormat(this, _alreadyRunningError, name); } else { IsRunning = true; yield return(Run(variables)); IsRunning = false; } }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { if (variables.This is MonoBehaviour behaviour) { behaviour.enabled = true; } else { Debug.LogWarningFormat(this, _missingComponentWarning, Name); } graph.GoTo(Next, variables.This, nameof(Next)); yield break; }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { if (variables.This is Animator animator) { Trigger(variables, animator); } else { Debug.LogWarningFormat(this, _animatorNotFoundWarning, Name); } graph.GoTo(Next, variables.This, nameof(Next)); yield break; }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { if (variables.This is IVariableReset reset) { reset.ResetVariables(Variables); } else { Debug.LogWarningFormat(this, _invalidVariablesWarning, Name); } graph.GoTo(Next, variables.This, nameof(Next)); yield break; }
public IEnumerator Execute(IVariableStore store, VariableValue context) { if (Instruction) { var localStore = InstructionStore.Reserve(Instruction, context); localStore.WriteInputs(this, _inputs, store); localStore.WriteOutputs(_outputs); yield return(Instruction.Execute(localStore)); localStore.ReadOutputs(this, _outputs, store); InstructionStore.Release(localStore); } }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { if (variables.This is Object obj) { Destroy(obj); } else { Debug.LogWarningFormat(this, _objectNotFoundWarning, Name); } graph.GoTo(Next, null, nameof(Next)); yield break; }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { if (variables.This is GameObject target) { target.SetActive(false); } else { Debug.LogWarningFormat(this, _missingObjectWarning, Name); } graph.GoTo(Next, variables.This, nameof(Next)); yield break; }
public override IEnumerator Run(InstructionGraph graph, InstructionStore variables, int iteration) { var condition = Condition.Execute(this, variables, VariableType.Bool).Bool; if (condition) { graph.GoTo(OnTrue, nameof(OnTrue)); } else { graph.GoTo(OnFalse, nameof(OnFalse)); } yield break; }
protected override IEnumerator Run_(InstructionGraph graph, InstructionStore variables, int iteration) { var name = Switch.Execute(this, variables, VariableType.String).String; if (Outputs.TryGetValue(name, out var output)) { graph.GoTo(output, variables.This, nameof(Outputs), name); } else { graph.GoTo(Default, variables.This, nameof(Default)); } yield break; }
public override IEnumerator Run(InstructionGraph graph, InstructionStore variables, int iteration) { if (ResolveObject(variables, Transition, out var transition)) { if (WaitForCompletion) { yield return(AutoFinish ? TransitionManager.Instance.RunTransition(transition, Phase) : TransitionManager.Instance.StartTransition(transition, Phase)); } else { TransitionManager.Instance.StartCoroutine(AutoFinish ? TransitionManager.Instance.RunTransition(transition, Phase) : TransitionManager.Instance.StartTransition(transition, Phase)); } } graph.GoTo(Next, nameof(Next)); }
public IEnumerator Execute(InstructionStore variables) { if (IsRunning) { Debug.LogErrorFormat(this, _alreadyRunningError, name); } else { Variables = variables; IsRunning = true; yield return(CompositionManager.Track(this, Run(variables))); IsRunning = false; Variables = null; } }
public override IEnumerator Run(InstructionGraph graph, InstructionStore variables, int iteration) { var condition = Condition.Execute(this, variables, VariableType.Bool); if (condition.Bool && Loop != null) { if (Index.IsAssigned) { Index.SetValue(variables, VariableValue.Create(iteration)); } graph.GoTo(Loop, nameof(Loop)); } yield break; }
public override IEnumerator Run(InstructionGraph graph, InstructionStore variables, int iteration) { if (Resolve(variables, Time, out var time)) { if (UseScaledTime) { yield return(new WaitForSeconds(time)); } else { yield return(new WaitForSecondsRealtime(time)); } } graph.GoTo(Next, nameof(Next)); }