public void ReplaceGoapGoalState(IGoapState <string, object> newValue) { var index = AIComponentsLookup.GoapGoalState; var component = CreateComponent <GoapGoalStateComponent>(index); component.value = newValue; ReplaceComponent(index, component); }
public void AddGoapEffect(IGoapState <string, object> newValue) { var index = AIComponentsLookup.GoapEffect; var component = CreateComponent <GoapEffectComponent>(index); component.value = newValue; AddComponent(index, component); }
public static AIEntity AddAgent(this AIContext context, IGoapState <string, object> worldState, IGoapState <string, object> goalState, IGoapPlanner <string, object> planner) { var entity = context.CreateEntity(); entity.AddGoapWorldState(worldState); entity.AddGoapGoalState(goalState); entity.AddGoapPlanner(planner); entity.isGoapAgent = true; return(entity); }
public static AIEntity AddAction(this AIContext context, int cost, IGoapState <string, object> condition, IGoapState <string, object> effect, Func <GoapActionStatus> action) { var entity = context.CreateEntity(); entity.AddCost(cost); entity.AddGoapCondition(condition); entity.AddGoapEffect(effect); entity.AddGoapAction(action); return(entity); }
public IEnumerator <int> Plan(AIContext context, IGoapState <string, object> goalState) { var goapAction = context.GetGroup(AIMatcher.AllOf(AIMatcher.GoapNodeChildren, AIMatcher.GoapEffect, AIMatcher.GoapAction)); var IDList = Search(context, goapAction.GetEntities(), goalState); if (IDList == null || IDList.Count == 0) { return(null); } var RIDList = IDList.Reverse().ToList(); return(RIDList.GetEnumerator()); }
private IList <int> Search(AIContext context, IList <AIEntity> entities, IGoapState <string, object> goalState) { AIEntity startEntity = null; foreach (var currentEntity in entities) { if (goalState.Contains(currentEntity.goapEffect.value)) { startEntity = currentEntity; } } if (startEntity == null) { return(null); } return(NextAction(context, startEntity, new List <int> ())); }
public bool Contains(IGoapState <K, V> b) { return(b.Keys.All(k => ContainsKey(k) && Equals(b[k], this [k]))); }
public static void BuildGraphBranch(this AIContext context, AIEntity currentEntity, IList <AIEntity> entities, IGoapState <string, object> targetEffect) { foreach (var e in entities) { if (targetEffect.Contains(e.goapEffect.value)) { if (currentEntity != null) { if (!currentEntity.hasGoapNodeChildren) { currentEntity.AddGoapNodeChildren(new List <int> ()); } if (!currentEntity.goapNodeChildren.value.Contains(e.iD.value)) { currentEntity.goapNodeChildren.value.Add(e.iD.value); } } context.BuildGraphBranch(e, entities, e.goapCondition.value); } } }