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 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); } } }