Пример #1
0
        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;
        }
Пример #2
0
        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;
        }
Пример #3
0
        private bool AddWatch(string variable)
        {
            var reference = new ReadOnlyExpression();

            reference.Content = variable;

            foreach (var graph in CompositionManager.TrackingState.Keys)
            {
                var value = reference.Execute(graph.Variables);
                if (!value.IsEmpty)
                {
                    if (value.TryGetDictionary(out var collection))
                    {
                        AddWatch(variable, collection);
                        return(true);
                    }
                    else
                    {
                        Debug.LogWarningFormat(_invalidWatchWarning, variable, value.Type);
                        return(false);
                    }
                }
            }

            if (CompositionManager.Exists)
            {
                var value = reference.Execute(VariableContext.Default);

                if (value.TryGetDictionary(out var collection))
                {
                    AddWatch(variable, collection);
                    return(true);
                }
                else
                {
                    Debug.LogWarningFormat(_invalidWatchWarning, variable, value.Type);
                    return(false);
                }
            }

            Debug.LogWarningFormat(_missingWatchWarning, variable);
            return(false);
        }
Пример #4
0
        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;
        }
Пример #5
0
        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;
        }
Пример #6
0
        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;
        }
Пример #7
0
        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;
        }
Пример #8
0
        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;
        }
Пример #9
0
        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)));
            }
        }