From e84203781e797bed618881ea766cb186d82d286c Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 5 Apr 2019 16:11:30 +0300 Subject: [PATCH] (e1b4346f3) Fix enemies not being able to get into the sub via vertical hatches. Removed the velocity manipulation, because it only caused issues. --- .../Source/GameSession/CrewManager.cs | 29 ++++++++++++++----- .../Source/Characters/AI/EnemyAIController.cs | 26 +++-------------- .../BarotraumaShared/Source/Map/Hull.cs | 2 +- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index a4387b521..2cce3c5f4 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -590,16 +590,23 @@ namespace Barotrauma float step = (characterListBox.Content.Children.First().Rect.Height + characterListBox.Spacing) / (characterListBox.TotalSize - characterListBox.Rect.Height); + characterListBox.BarScroll -= characterListBox.BarScroll % step; characterListBox.BarScroll += dir * step; - - //round the scroll so that we're not displaying partial character frames - float roundedPos = MathUtils.RoundTowardsClosest(characterListBox.BarScroll, step); - if (Math.Abs(roundedPos - characterListBox.BarScroll) < step / 2) - { - 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 +619,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/EnemyAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs index 3d5c95995..a30bf012b 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs @@ -568,29 +568,11 @@ namespace Barotrauma //steer through the door manually if it's open or broken if (door?.LinkedGap?.FlowTargetHull != null && !door.LinkedGap.IsRoomToRoom && (door.IsOpen || door.Item.Condition <= 0.0f)) { + LatchOntoAI?.DeattachFromBody(); + Character.AnimController.ReleaseStuckLimbs(); var velocity = Vector2.Normalize(door.LinkedGap.FlowTargetHull.WorldPosition - Character.WorldPosition); - if (door.LinkedGap.IsHorizontal) - { - if (Character.WorldPosition.Y < door.Item.WorldRect.Y && Character.WorldPosition.Y > door.Item.WorldRect.Y - door.Item.Rect.Height) - { - velocity.Y = 0; - LatchOntoAI?.DeattachFromBody(); - Character.AnimController.ReleaseStuckLimbs(); - steeringManager.SteeringManual(deltaTime, velocity); - return; - } - } - else - { - if (Character.WorldPosition.X < door.Item.WorldRect.X && Character.WorldPosition.X > door.Item.WorldRect.Right) - { - velocity.X = 0; - LatchOntoAI?.DeattachFromBody(); - Character.AnimController.ReleaseStuckLimbs(); - steeringManager.SteeringManual(deltaTime, velocity); - return; - } - } + steeringManager.SteeringManual(deltaTime, velocity); + return; } } } diff --git a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs index 5ab382995..cc1b0cbbd 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs @@ -20,7 +20,7 @@ namespace Barotrauma public static bool EditWater, EditFire; public const float OxygenDistributionSpeed = 500.0f; public const float OxygenDeteriorationSpeed = 0.3f; - public const float OxygenConsumptionSpeed = 700.0f; + public const float OxygenConsumptionSpeed = 1000.0f; public const int WaveWidth = 32; public static float WaveStiffness = 0.02f;