Example #1
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();
        }