Example #1
0
        private void DoCheckContainsValue()
        {
            value.UpdateValue();

            int _id = -1;

            if (value.GetValue() == null || value.GetValue().Equals(null))
            {
                _id = Array.FindIndex(array.Values, x => x == null || x.Equals(null));
            }
            else
            {
                _id = Array.IndexOf(array.Values, value.GetValue());
            }

            var _iscontained = _id != -1;

            isContained.Value = _iscontained;
            index.Value       = _id;
            if (_iscontained)
            {
                Fsm.Event(isContainedEvent);
            }
            else
            {
                Fsm.Event(isNotContainedEvent);
            }
        }
        private void DoGetNearestValue()
        {
            if (array.ElementType == VariableType.Float)
            {
                float closest = array.floatValues.OrderBy(v => Mathf.Abs(v - (float)value.GetValue())).First();

                if (!result.IsNone)
                {
                    result.SetValue(closest);
                }

                if (!index.IsNone)
                {
                    index.Value = System.Array.IndexOf(this.array.floatValues, closest);
                }
                return;
            }

            if (array.ElementType == VariableType.Int)
            {
                int closest = array.intValues.OrderBy(v => Mathf.Abs(v - (int)value.GetValue())).First();

                if (!result.IsNone)
                {
                    result.SetValue(closest);
                }

                if (!index.IsNone)
                {
                    index.Value = System.Array.IndexOf(this.array.intValues, closest);
                }
                return;
            }
        }
Example #3
0
 public override void Enter()
 {
     defaultValue.UpdateValue();
     if (defaultValue.GetValue() != null && !defaultValue.IsNone)
     {
         value.SetValue(ES3.Load <object>(key.Value, defaultValue.GetValue(), GetSettings()));
     }
     else
     {
         value.SetValue(ES3.Load <object>(key.Value, GetSettings()));
     }
 }
Example #4
0
 public override void Enter()
 {
     value.UpdateValue();
     if (value.IsNone || value.GetValue() == null)
     {
         HandleError("The 'Load Into' action requires an object to load the data into, but none was specified in the 'Value' field.");
     }
     else
     {
         ES3.LoadInto <object>(key.Value, value.GetValue(), GetSettings());
     }
 }
Example #5
0
 public override void Enter()
 {
     defaultValue.UpdateValue();
     if (defaultValue.GetValue() != null && !defaultValue.IsNone)
     {
         value.SetValue(es3File.Load <object>(key.Value, defaultValue.GetValue()));
     }
     else
     {
         value.SetValue(es3File.Load <object>(key.Value));
     }
 }
Example #6
0
        public void ExecuteAction()
        {
            if (!UpdateCache(Fsm.GetOwnerDefaultTarget(gameObject)))
            {
                Debug.Log("ArrayListTable not found for " + PlayMakerUtils.LogFullPathToAction(this));
                Fsm.Event(failureEvent);
                return;
            }

            ArrayListTable _at = this.cachedComponent as ArrayListTable;

            PlayMakerUtils.RefreshValueFromFsmVar(this.Fsm, value);

            int _column_i = 0;

            foreach (PlayMakerArrayListProxy _p in _at.ColumnData)
            {
                if (_p.arrayList.Contains(value.GetValue()))
                {
                    if (!rowIndexResult.IsNone)
                    {
                        rowIndexResult.Value = _p.arrayList.IndexOf(value.GetValue());
                    }
                    if (!columnIndexResult.IsNone)
                    {
                        columnIndexResult.Value = _column_i;
                    }
                    if (!columnNameResult.IsNone)
                    {
                        columnNameResult.Value = _at.GetColumnHeader(_column_i);
                    }

                    if (!isContained.IsNone)
                    {
                        isContained.Value = true;
                    }

                    Fsm.Event(isContainedEvent);

                    return;
                }
                _column_i++;
            }

            if (!isContained.IsNone)
            {
                isContained.Value = true;
            }

            Fsm.Event(isNotContainedEvent);
        }
Example #7
0
        private void DoMethodCall()
        {
            if (behaviour.Value == null)
            {
                Finish();
                return;
            }
            if (NeedToUpdateCache() && !DoCache())
            {
                Debug.LogError(errorString);
                Finish();
                return;
            }
            object value;

            if (cachedParameterInfo.Length == 0)
            {
                value = cachedMethodInfo.Invoke(cachedBehaviour.Value, null);
            }
            else
            {
                for (int i = 0; i < parameters.Length; i++)
                {
                    FsmVar fsmVar = parameters[i];
                    fsmVar.UpdateValue();
                    if (fsmVar.Type == VariableType.Array)
                    {
                        fsmVar.UpdateValue();
                        object[] array       = fsmVar.GetValue() as object[];
                        Type     elementType = cachedParameterInfo[i].ParameterType.GetElementType();
                        Array    array2      = Array.CreateInstance(elementType, array.Length);
                        for (int j = 0; j < array.Length; j++)
                        {
                            array2.SetValue(array[j], j);
                        }
                        parametersArray[i] = array2;
                    }
                    else
                    {
                        fsmVar.UpdateValue();
                        parametersArray[i] = fsmVar.GetValue();
                    }
                }
                value = cachedMethodInfo.Invoke(cachedBehaviour.Value, parametersArray);
            }
            if (storeResult != null && !storeResult.IsNone && storeResult.Type != VariableType.Unknown)
            {
                storeResult.SetValue(value);
            }
        }
Example #8
0
        private void DoSetFsmArray()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (!UpdateCache(go, fsmName.Value))
            {
                return;
            }

            var fsmArray = fsm.FsmVariables.GetFsmArray(variableName.Value);

            if (fsmArray != null)
            {
                if (index.Value < 0 || index.Value >= fsmArray.Length)
                {
                    Fsm.Event(indexOutOfRange);
                    Finish();
                    return;
                }

                if (fsmArray.ElementType == value.NamedVar.VariableType)
                {
                    fsmArray.Set(index.Value, value.GetValue());
                }
                else
                {
                    LogWarning("Incompatible variable type: " + variableName.Value);
                }
            }
            else
            {
                DoVariableNotFound(variableName.Value);
            }
        }
Example #9
0
        private void DoMethodCall()
        {
            if (this.behaviour.Value == null)
            {
                base.Finish();
                return;
            }
            if (this.cachedBehaviour != this.behaviour.Value)
            {
                this.errorString = string.Empty;
                if (!this.DoCache())
                {
                    Debug.LogError(this.errorString);
                    base.Finish();
                    return;
                }
            }
            object value;

            if (this.cachedParameterInfo.Length == 0)
            {
                value = this.cachedMethodInfo.Invoke(this.cachedBehaviour, null);
            }
            else
            {
                for (int i = 0; i < this.parameters.Length; i++)
                {
                    FsmVar fsmVar = this.parameters[i];
                    fsmVar.UpdateValue();
                    this.parametersArray[i] = fsmVar.GetValue();
                }
                value = this.cachedMethodInfo.Invoke(this.cachedBehaviour, this.parametersArray);
            }
            this.storeResult.SetValue(value);
        }
Example #10
0
        private void ggop()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (!UpdateCache(go, fsmName.Value))
            {
                return;
            }

            var fsmArray = fsm.FsmVariables.GetFsmArray(variableName.Value);

            int count = fsmArray.Length;

            fsmArray.Reset();
            fsmArray.Resize(count);

            if (!resetValue.IsNone)
            {
                resetValue.UpdateValue();
                object _val = resetValue.GetValue();
                for (int i = 0; i < count; i++)
                {
                    fsmArray.Set(i, _val);
                }
            }
            Finish();
        }
        private void DoMethodCall()
        {
            if (className == null || string.IsNullOrEmpty(className.Value))
            {
                Finish();
                return;
            }
            if (cachedClassName != className.Value || cachedMethodName != methodName.Value)
            {
                errorString = string.Empty;
                if (!DoCache())
                {
                    Debug.LogError(errorString);
                    Finish();
                    return;
                }
            }
            object obj = null;

            if (cachedParameterInfo.Length == 0)
            {
                obj = cachedMethodInfo.Invoke(null, null);
            }
            else
            {
                for (int i = 0; i < parameters.Length; i++)
                {
                    FsmVar fsmVar = parameters[i];
                    fsmVar.UpdateValue();
                    parametersArray[i] = fsmVar.GetValue();
                }
                obj = cachedMethodInfo.Invoke(null, parametersArray);
            }
            storeResult.SetValue(obj);
        }
        void ggop()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (!UpdateCache(go, fsmName.Value))
            {
                return;
            }

            var fsmArray = fsm.FsmVariables.GetFsmArray(variableName.Value);

            value.UpdateValue();

            List <object> _new = new List <object>();

            int i = 0;

            foreach (object _obj in fsmArray.Values)
            {
                if (!_obj.Equals(value.GetValue()))
                {
                    _new.Add(_obj);
                }

                i++;
            }
            fsmArray.Values = _new.ToArray();
        }
Example #13
0
        private void DoRemoveValue()
        {
            value.UpdateValue();

            var list = new List <object>(array.Values);

            if (allMatches.Value)
            {
                list.RemoveAll(x => x == value.GetValue());
            }
            else
            {
                list.Remove(value.GetValue());
            }

            array.Values = list.ToArray();
            array.SaveChanges();
        }
Example #14
0
        public override void OnEnter()
        {
            if (ifEmpty.Value)
            {
                if (value.IsNone && value.GetValue() == null)
                {
                    DoAddValue();
                }
            }
            else
            {
                if (!value.IsNone && value.GetValue() != null)
                {
                    DoAddValue();
                }
            }

            Finish();
        }
        private void ggop()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (!UpdateCache(go, fsmName.Value))
            {
                return;
            }

            var fsmArray = fsm.FsmVariables.GetFsmArray(variableName.Value);

            fsmArray.Resize(fsmArray.Length + 1);
            value.UpdateValue();
            fsmArray.Set(fsmArray.Length - 1, value.GetValue());
        }
Example #16
0
 private void DoGetValue()
 {
     if (!array.IsNone)
     {
         if (index.Value >= 0 && index.Value < array.Length)
         {
             value.UpdateValue();
             array.Set(index.Value, value.GetValue());
         }
         else
         {
             base.Fsm.Event(indexOutOfRange);
         }
     }
 }
Example #17
0
        public override void OnEnter()
        {
            result.Reset();

            List <string> tmpValues      = GDEHelpers.ListAllBy(GDEDataType.Item, searchInSchema.Value);
            List <string> matchingValues = new List <string>();

            foreach (var tmp in tmpValues)
            {
                if (string.IsNullOrEmpty(itemNameContains.Value) && !itemNameContains.IsNone && !tmp.Contains(itemNameContains.Value))
                {
                    continue;
                }

                List <string> fieldNames = string.IsNullOrEmpty(searchInField.Value) || searchInField.IsNone ? null : new List <string> {
                    searchInField.Value
                };
                List <object> fieldValues = GDEHelpers.GetFieldValues(tmp, fieldNames);

                foreach (var fieldValue in fieldValues)
                {
                    value.UpdateValue();
                    if (fieldValue.GetType() != value.GetType())
                    {
                        UnityEngine.Debug.LogError("Given value type doesn't match result type!");
                    }
                    if (fieldValue != value.GetValue())
                    {
                        continue;
                    }

                    matchingValues.Add(tmp);
                    break;
                }
            }

            if (matchingValues.Count == 0)
            {
                Fsm.Event(noneFoundEvent);
            }
            else
            {
                result.SetArrayContents(matchingValues);
            }

            Finish();
        }
Example #18
0
        private void DoCheckContainsValue()
        {
            value.UpdateValue();
            int  num  = Array.IndexOf(array.Values, value.GetValue());
            bool flag = num != -1;

            isContained.Value = flag;
            index.Value       = num;
            if (flag)
            {
                base.Fsm.Event(isContainedEvent);
            }
            else
            {
                base.Fsm.Event(isNotContainedEvent);
            }
        }
Example #19
0
        public override void OnEnter()
        {
            int count = array.Length;

            array.Reset();
            array.Resize(count);

            if (!resetValue.IsNone)
            {
                object _val = resetValue.GetValue();
                for (int i = 0; i < count; i++)
                {
                    array.Set(i, _val);
                }
            }
            Finish();
        }
Example #20
0
        public override void OnEnter()
        {
            int length = array.Length;

            array.Reset();
            array.Resize(length);
            if (!resetValue.IsNone)
            {
                resetValue.UpdateValue();
                object value = resetValue.GetValue();
                for (int i = 0; i < length; i++)
                {
                    array.Set(i, value);
                }
            }
            Finish();
        }
Example #21
0
        private void DoCheckContainsValue()
        {
            value.UpdateValue();
            var _id = Array.IndexOf(array.Values, value.GetValue());

            var _iscontained = _id != -1;

            isContained.Value = _iscontained;
            index.Value       = _id;
            if (_iscontained)
            {
                Fsm.Event(isContainedEvent);
            }
            else
            {
                Fsm.Event(isNotContainedEvent);
            }
        }
Example #22
0
        private void DoGetValue()
        {
            if (array.IsNone)
            {
                return;
            }

            if (index.Value >= 0 && index.Value < array.Length)
            {
                value.UpdateValue();
                array.Set(index.Value, value.GetValue());
            }
            else
            {
                //LogError("Index out of Range: " + index.Value);
                Fsm.Event(indexOutOfRange);
            }
        }
Example #23
0
        private void DoRemoveValue()
        {
            value.UpdateValue();

            List <object> _new = new List <object>();

            int i = 0;

            foreach (object _obj in array.Values)
            {
                if (!_obj.Equals(value.GetValue()))
                {
                    _new.Add(_obj);
                }

                i++;
            }


            array.Values = _new.ToArray();
            array.SaveChanges();
        }
Example #24
0
        private void DoSetStaticValue()
        {
            if (className == null || string.IsNullOrEmpty(className.Value))
            {
                Finish();
                return;
            }

            if (cachedClassName != className.Value || cachedPropertyName != propertyName.Value)
            {
                errorString = string.Empty;
                if (!DoCache())
                {
                    Debug.LogError(errorString);
                    Finish();
                    return;
                }
            }

            propertyValue.UpdateValue();
            cachedFieldInfo.SetValue(null, propertyValue.GetValue());
        }
Example #25
0
 private void DoInsertValue()
 {
     value.UpdateValue();
     array.InsertItem(value.GetValue(), atIndex.Value);
 }
Example #26
0
 public override void Enter()
 {
     value.UpdateValue();
     es3File.Save <object>(key.Value, value.GetValue());
 }
Example #27
0
 public override void Enter()
 {
     value.UpdateValue();
     es3Spreadsheet.SetCell <object>(col.Value, row.Value, value.GetValue());
 }
Example #28
0
 public override void Enter()
 {
     value.UpdateValue();
     ES3.Save <object>(key.Value, value.GetValue(), GetSettings());
 }
Example #29
0
 private void DoAddValue()
 {
     array.Resize(array.Length + 1);
     value.UpdateValue();
     array.Set(array.Length - 1, value.GetValue());
 }