diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index a4387b521..5a263c325 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -17,10 +17,9 @@ namespace Barotrauma const float ChatMessageFadeTime = 10.0f; /// - /// How long the previously selected character waits doing nothing when switching to another character + /// How long the previously selected character waits doing nothing when switching to another character. Only affects idling. /// - const float CharacterWaitOnSwitch = 20.0f; - + const float CharacterWaitOnSwitch = 10.0f; private List characterInfos = new List(); private List characters = new List(); @@ -272,6 +271,7 @@ namespace Barotrauma DebugConsole.ThrowError("Tried to add the same character info to CrewManager twice.\n" + Environment.StackTrace); return; } + } characterInfos.Add(characterInfo); } @@ -599,7 +599,20 @@ namespace Barotrauma characterListBox.BarScroll = roundedPos; } - return false; + #region Dialog + /// + /// Adds the message to the single player chatbox. + /// + public void AddSinglePlayerChatMessage(string senderName, string text, ChatMessageType messageType, Character sender) + { + if (!isSinglePlayer) + { + DebugConsole.ThrowError("Cannot add messages to single player chat box in multiplayer mode!\n" + Environment.StackTrace); + return; + } + if (string.IsNullOrEmpty(text)) { return; } + + chatBox.AddMessage(ChatMessage.Create(senderName, text, messageType, sender)); } private IEnumerable KillCharacterAnim(GUIComponent component) @@ -612,6 +625,12 @@ namespace Barotrauma { comp.Color = Color.DarkRed; } + List availableSpeakers = Character.CharacterList.FindAll(c => + c.AIController is HumanAIController && + !c.IsDead && + c.SpeechImpediment <= 100.0f); + pendingConversationLines.AddRange(NPCConversation.CreateRandom(availableSpeakers)); + } yield return new WaitForSeconds(1.0f); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs index 30248ca2e..c0bdb1a15 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs @@ -54,10 +54,17 @@ namespace Barotrauma character.SelectedConstruction = null; } + bool currentHullForbidden = IsForbidden(character.CurrentHull); + if (!currentHullForbidden && !character.AnimController.InWater && !character.IsClimbing && HumanAIController.ObjectiveManager.WaitTimer > 0) + { + SteeringManager.Reset(); + return; + } + bool currentTargetIsInvalid = currentTarget == null || IsForbidden(currentTarget) || (PathSteering.CurrentPath != null && PathSteering.CurrentPath.Nodes.Any(n => HumanAIController.UnsafeHulls.Contains(n.CurrentHull))); - if (currentTargetIsInvalid || (currentTarget == null && IsForbidden(character.CurrentHull))) + if (currentTargetIsInvalid || (currentTarget == null && currentHullForbidden)) { newTargetTimer = 0; standStillTimer = 0; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs index acafac1ed..3a08bc8e3 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs @@ -18,7 +18,7 @@ namespace Barotrauma private Character character; /// - /// When set above zero, the character will stand still doing nothing until the timer runs out (assuming they don't a high priority order active) + /// When set above zero, the character will stand still doing nothing until the timer runs out. Only affects idling. /// public float WaitTimer; @@ -134,12 +134,7 @@ namespace Barotrauma public void DoCurrentObjective(float deltaTime) { - if (CurrentObjective == null || (CurrentObjective.GetPriority(this) < OrderPriority && WaitTimer > 0.0f)) - { - WaitTimer -= deltaTime; - character.AIController.SteeringManager.Reset(); - return; - } + if (WaitTimer > 0.0f) { WaitTimer -= deltaTime; } CurrentObjective?.TryComplete(deltaTime); }