public void SetOrder(Order order, string option, Character orderGiver) { CurrentOrder = CreateObjective(order, option, orderGiver); if (CurrentOrder == null) { // Recreate objectives, because some of them may be removed, if impossible to complete (e.g. due to path finding) CreateAutonomousObjectives(); } else { CurrentOrder.Reset(); } }
public void SetOrder(Order order, string option, Character orderGiver, bool speak) { if (character.IsDead) { #if DEBUG DebugConsole.ThrowError("Attempted to set an order for a dead character"); #else return; #endif } ClearIgnored(); CurrentOrder = CreateObjective(order, option, orderGiver, isAutonomous: false); if (CurrentOrder == null) { // Recreate objectives, because some of them may be removed, if impossible to complete (e.g. due to path finding) CreateAutonomousObjectives(); } else { // This should be redundant, because all the objectives are reset when they are selected as active. CurrentOrder.Reset(); if (speak) { character.Speak(TextManager.Get("DialogAffirmative"), null, 1.0f); if (speakRoutine != null) { CoroutineManager.StopCoroutines(speakRoutine); } speakRoutine = CoroutineManager.InvokeAfter(() => { if (GameMain.GameSession == null || Level.Loaded == null) { return; } if (CurrentOrder != null && character.SpeechImpediment < 100.0f) { if (CurrentOrder is AIObjectiveRepairItems repairItems && repairItems.Targets.None()) { character.Speak(TextManager.Get("DialogNoRepairTargets"), null, 3.0f, "norepairtargets"); } else if (CurrentOrder is AIObjectiveChargeBatteries chargeBatteries && chargeBatteries.Targets.None()) { character.Speak(TextManager.Get("DialogNoBatteries"), null, 3.0f, "nobatteries"); } else if (CurrentOrder is AIObjectiveExtinguishFires extinguishFires && extinguishFires.Targets.None()) { character.Speak(TextManager.Get("DialogNoFire"), null, 3.0f, "nofire"); }
public void SetOrder(Order order, string option, Character orderGiver) { if (character.IsDead) { #if DEBUG DebugConsole.ThrowError("Attempted to set an order for a dead character"); #else return; #endif } ClearIgnored(); CurrentOrder = CreateObjective(order, option, orderGiver, isAutonomous: false); if (CurrentOrder == null) { // Recreate objectives, because some of them may be removed, if impossible to complete (e.g. due to path finding) CreateAutonomousObjectives(); } else { CurrentOrder.Reset(); } }