private void Run(InstructionCaller graph)
 {
     if (graph.Instruction && !graph.IsRunning)
     {
         CompositionManager.Instance.RunInstruction(graph, CompositionManager.Instance.DefaultStore, VariableValue.Create(gameObject));
     }
 }
        public void ReadOutputs(InstructionCaller instruction, IList <InstructionOutput> outputs, IVariableStore caller)
        {
            foreach (var output in outputs)
            {
                if (output.Type == InstructionOutputType.Reference)
                {
                    var value = Output.GetVariable(output.Name);

                    if (value.Type != VariableType.Empty)
                    {
                        var result = output.Reference.SetValue(caller, value);

                        switch (result)
                        {
                        case SetVariableResult.Success: break;

                        case SetVariableResult.NotFound: Debug.LogWarningFormat(_missingOutputError, output.Name, instruction.Instruction, output.Reference); break;

                        case SetVariableResult.ReadOnly: Debug.LogWarningFormat(_readOnlyOutputError, output.Name, instruction.Instruction, output.Reference); break;

                        case SetVariableResult.TypeMismatch: Debug.LogWarningFormat(_invalidOutputError, output.Name, instruction.Instruction, output.Reference); break;
                        }
                    }
                }
            }
        }
        public void WriteInputs(InstructionCaller instruction, IList <InstructionInput> inputs, IVariableStore caller)
        {
            foreach (var input in inputs)
            {
                if (input.Type == InstructionInputType.Reference)
                {
                    var value      = input.Reference.GetValue(caller);
                    var definition = instruction.GetInputDefinition(input);

                    value = ResolveValue(definition.Definition, value, instruction.Instruction, _invalidInputError, definition.Name);

                    if (value.Type != VariableType.Empty)
                    {
                        Input.AddVariable(input.Name, value);
                    }
                    else
                    {
                        Debug.LogWarningFormat(_missingInputError, input.Name, instruction.Instruction, input.Reference);
                    }
                }
                else if (input.Type == InstructionInputType.Value)
                {
                    Input.AddVariable(input.Name, input.Value);
                }
            }
        }
Esempio n. 4
0
        public void RunInstruction(InstructionCaller caller, InstructionContext context, object thisObject)
        {
            var enumerator = caller.Execute(context, thisObject);

            StartCoroutine(new JoinEnumerator(enumerator));
        }
        public void RunInstruction(InstructionCaller caller, IVariableStore store, VariableValue context)
        {
            var enumerator = caller.Execute(store, context);

            StartCoroutine(new JoinEnumerator(enumerator, caller.Instruction));
        }