private void CreatePlans(Goal g, GameObject target, Precondition successCondition, PlanList plans, Plan p, List <Action> ignoreList) { List <Action> satisfyingActions = actionDirectory.FindActionsSatisfyingGoalCondition(target, successCondition); RemovePreviouslyFailedActions(satisfyingActions, currentGoal.FailedActions); foreach (Action action in satisfyingActions) { Plan newPlan = new Plan(p); newPlan.AddAction(action); if (!action.HasPrecondition() || action.IsPreconditionSatisfied()) { plans.Add(newPlan); } else { CreatePlans(g, target, action.Precondition, plans, newPlan, ignoreList); } } }