public bool Contains(Flow flow)
        {
            var list = flow.GetValue <IList>(this.list);
            var item = flow.GetValue <object>(this.item);

            return(list.Contains(item));
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 protected override void Process(Flow flow)
 {
     value = flow.GetValue <bool>(valueIn);
     owner.WaitWhile(
         () => flow.GetValue <bool>(conditionIn) == value,
         Finish);
 }
Exemplo n.º 6
0
        private object Get(Flow flow)
        {
            var dictionary = flow.GetValue <IDictionary>(this.dictionary);
            var key        = flow.GetValue <object>(this.key);

            return(dictionary[key]);
        }
Exemplo n.º 7
0
        private bool Contains(Flow flow)
        {
            var dictionary = flow.GetValue <IDictionary>(this.dictionary);
            var key        = flow.GetValue <object>(this.key);

            return(dictionary.Contains(key));
        }
Exemplo n.º 8
0
        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)));
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 14
0
 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>)));
     }
 }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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());
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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));
        }
Exemplo n.º 19
0
        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));
            }
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
        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);
            }
        }
Exemplo n.º 23
0
        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);
            }
        }
Exemplo n.º 24
0
        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);
            }
        }
Exemplo n.º 25
0
        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);
            }
        }
Exemplo n.º 26
0
        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());
        }
Exemplo n.º 27
0
        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));
        }
Exemplo n.º 28
0
        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);
        }
Exemplo n.º 29
0
        private ControlOutput Clear(Flow flow)
        {
            var dictionary = flow.GetValue <IDictionary>(dictionaryInput);

            flow.SetValue(dictionaryOutput, dictionary);

            dictionary.Clear();

            return(exit);
        }
Exemplo n.º 30
0
        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);
        }