private void ActionFailure() { AILogger.CreateMessage("Action failed: " + currentAction.ToString(), agent); Stop(); if (OnFinishedPlan != null) { OnFinishedPlan(); } }
public void Unpause() { if (state == States.Paused) { state = States.Running; // TODO Unpause state machine } else { AILogger.CreateMessage("Error, cannot unpause from non-paused state. Current state = " + state.ToString(), agent); } }
public void Pause() { if (state == States.Running) { state = States.Paused; stateMachine.Pause(); } else { AILogger.CreateMessage("Cannot Pause when not running. Current state = " + state.ToString(), agent); } }
public void Stop() { if (state == States.Stopped) { AILogger.CreateMessage("Already stopped", agent); } else { state = States.Stopped; stateMachine.Stop(); actionPlan = null; currentAction = null; } }
public void CalculateNewGoal() { AILogger.CreateMessage("Calculating new goal.", agent); List <AIGoal> goals = new List <AIGoal>(agent.GetGoals()); goals.Sort((x, y) => x.Priority.CompareTo(y.Priority)); if (goals.Count == 0) { return; } for (int i = 0; i < goals.Count; i++) { currentGoal = goals[i]; if (!GoalAchieveableByActions(currentGoal)) { continue; } if (aStar.FindActionPlan(agent, this)) { actions = aStar.GetActionPlan(); } else { AILogger.CreateMessage("failed to find action plan.", agent); } } if (actions.Count > 0 && OnActionPlanFound != null) { OnActionPlanFound(); } }