Beispiel #1
0
        public bool Equals(GOAPState obj)
        {
            bool listEq = true;

            for (int i = 0; i < Items.Count; ++i)
            {
                if (obj.Items.Count != Items.Count)
                {
                    listEq = false;
                    break;
                }
                if (!ReferenceEquals(Items[i].GetType(), obj.Items[i].GetType()))
                {
                    listEq = false;
                    break;
                }
                if (!Items[i].Equals(obj.Items[i]))
                {
                    listEq = false;
                    break;
                }
            }

            return((Name == obj.Name) && listEq);
        }
Beispiel #2
0
        List <GOAPState> CreateNewState(List <GOAPState> current, List <GOAPState> changes)
        {
            List <GOAPState> state = new List <GOAPState>();

            foreach (GOAPState contains in current)
            {
                state.Add(contains);
            }

            for (int i = 0; i < changes.Count; i++)
            {
                bool exists = false;
                foreach (GOAPState check in state)
                {
                    if (check.Equals(changes[i]))
                    {
                        exists = true;
                        break;
                    }
                }


                if (exists)
                {
                    state.RemoveAt(i);
                    GOAPState updated = changes[i];
                    state.Add(updated);
                }
            }

            return(state);
        }
Beispiel #3
0
 public void RemovePrecondition(GOAPState cond)
 {
     if (requiredStates.Exists(x => x.Equals(cond)))
     {
         requiredStates.Remove(cond);
     }
 }
Beispiel #4
0
 public void RemovePrecon(GOAPState state)
 {
     if (Preconditions.Exists(x => x.Equals(state)))
     {
         Preconditions.Remove(state);
     }
 }
Beispiel #5
0
        public bool Contains(string key, GOAPState state)
        {
            if (!_states.ContainsKey(key))
            {
                return(false);
            }

            return(_states[key].Equals(state));
        }
Beispiel #6
0
        public void Set(string key, GOAPState state)
        {
            if (_states[key].Type != state.Type)
            {
                throw new ArgumentException();
            }

            _states[key] = state;
        }
Beispiel #7
0
        public bool Contains(string key, GOAPState state)
        {
            if (!_state.HasValue)
            {
                return(false);
            }

            if (_state.Value.Key != key)
            {
                return(false);
            }

            return(_state.Value.Value.Equals(state));
        }
Beispiel #8
0
        public void Add(string key, GOAPState state)
        {
            if (!GOAPBlanksManager.Instance.Contains(key))
            {
                throw new Exception($"Нет элемента с ключом {key}");
            }

            if (GOAPBlanksManager.Instance.Blanks[key] != state.Type)
            {
                throw new Exception($"Нет элемента \"{key}\" с типом {state.Type}");
            }

            _states.Add(key, state);
        }
Beispiel #9
0
 internal GOAPPlan(IEnumerable <IGOAPAction> actions, Map <GOAPKeyEnum, object> initialState, Map <GOAPKeyEnum, Func <object, bool> > goalState, Func <IGraphNode <GOAPState>, float> heuristic)
 {
     this.initialState = new GOAPState(actions, initialState, goalState, null, heuristic);
 }
Beispiel #10
0
 public void AddPrecondition(GOAPState cond)
 {
     requiredStates.Add(cond);
 }
Beispiel #11
0
 public void AddPrecon(GOAPState state)
 {
     Preconditions.Add(state);
 }
Beispiel #12
0
 public void Set(string key, GOAPState state)
 {
     Set(new KeyValuePair <string, GOAPState>(key, state));
 }
Beispiel #13
0
        public void Add(string key, object value)
        {
            var goapState = new GOAPState(value);

            Add(key, goapState);
        }