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); }
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); }
public void RemovePrecondition(GOAPState cond) { if (requiredStates.Exists(x => x.Equals(cond))) { requiredStates.Remove(cond); } }
public void RemovePrecon(GOAPState state) { if (Preconditions.Exists(x => x.Equals(state))) { Preconditions.Remove(state); } }
public bool Contains(string key, GOAPState state) { if (!_states.ContainsKey(key)) { return(false); } return(_states[key].Equals(state)); }
public void Set(string key, GOAPState state) { if (_states[key].Type != state.Type) { throw new ArgumentException(); } _states[key] = state; }
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)); }
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); }
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); }
public void AddPrecondition(GOAPState cond) { requiredStates.Add(cond); }
public void AddPrecon(GOAPState state) { Preconditions.Add(state); }
public void Set(string key, GOAPState state) { Set(new KeyValuePair <string, GOAPState>(key, state)); }
public void Add(string key, object value) { var goapState = new GOAPState(value); Add(key, goapState); }