Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************
- * WorldState Classes
- *************************/
- public class WorldState
- {
- public Dictionary<int, LocationData> LocationData { get; private set; }
- public HashSet<TraversalData> TraversalData { get; private set; }
- public Dictionary<string, bool> FlagData { get; private set; }
- }
- public class LocationData
- {
- public EntityTypeEnum EntityType { get; set; }
- public Vector3 Position { get; set; }
- public float LastSeen { get; set; }
- }
- public class EnemyLocationData : LocationData
- {
- public Vector3 Direction { get; set; }
- public bool IsEliminated { get; set; }
- }
- public class TraversalData
- {
- public Vector3 FromPosition { get; set; }
- public Vector3 ToPosition { get; set; }
- public float LastSeen { get; set; }
- }
- /*************************
- * Goap Core
- *************************/
- public interface IGoapCondition
- {
- string Name { get; }
- bool Validate(WorldState worldstate);
- }
- public interface IGoapAction
- {
- float Cost { get; }
- IGoapCondition[] Preconditions{ get; }
- IGoapCondition[] Postconditions{ get; }
- void Update(WorldState worldstate);
- }
- public interface IGoapPlanner
- {
- Stack<IGoapAction> Plan(WorldState worldstate);
- }
- public class GoapPlanner :IGoapPlanner
- {
- public static Stack<IGoapAction> Plan(IGoapAgent agent)
- {
- // Needs goals access
- // Needs worldstate access
- // Needs Action // access
- }
- }
- public interface IGoapAgent
- {
- SortedList<float, IGoapCondition> Goals { get; }
- IGoapAction[] Actions { get; }
- WorldState WorldState { get; }
- }
- public class GoapAgent : Monobehaviour, IGoapAgent
- {
- public SortedList<float, IGoapCondition> Goals { get{ return _goals.Clone(??); } }
- public IGoapAction[] Actions { get{ return _actions.ToArray(); } }
- public WorldState WorldState { get{ return _worldState.Clone(); } }
- private SortedList<float, IGoapCondition> _goals;
- private List<IGoapAction> _actions;
- private WorldState _worldState;
- private Stack<IGoapAction> _acitonPlan;
- public void Update()
- {
- }
- private void Replan()
- {
- if(Time.time > _lastReplan + _replanInterval)
- {
- _actionPlan = GoapPlanner.Plan(this);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement