From ca08b803dcdd8bd0ecbc3ab4f02140edfe8b5198 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 29 Mar 2019 17:24:02 +0200 Subject: [PATCH] (891ef87c3) Fixed: CrewManager throwing errors if changing resolutions when a crewmember is dead. Added: Scaling of the objective list when changing resolutions --- .../Source/Characters/AI/EnemyAIController.cs | 8 +- .../Source/Characters/Character.cs | 7 -- Barotrauma/BarotraumaClient/Source/GUI/GUI.cs | 8 +- .../Source/GUI/HUDLayoutSettings.cs | 3 - .../BarotraumaClient/Source/GameMain.cs | 3 +- .../Source/GameSession/CrewManager.cs | 2 +- .../GameModes/Tutorials/ContextualTutorial.cs | 42 ++++++++--- .../GameModes/Tutorials/Tutorial.cs | 4 +- .../Source/Items/Components/LevelResource.cs | 2 +- .../Source/Items/Components/RepairTool.cs | 22 ------ .../Source/Items/ItemInventory.cs | 6 ++ .../BarotraumaClient/Source/Map/MapEntity.cs | 4 +- .../Source/Map/MapEntityPrefab.cs | 2 +- .../Source/Screens/CharacterEditorScreen.cs | 10 +-- .../Source/Screens/SubEditorScreen.cs | 14 ---- .../Data/ContentPackages/Vanilla 0.9.xml | 1 - .../Source/Characters/AI/EnemyAIController.cs | 73 ++++++++++--------- .../Animation/FishAnimController.cs | 15 ++-- .../Source/Characters/Attack.cs | 3 - .../Source/Characters/Character.cs | 14 ++-- .../Components/Holdable/LevelResource.cs | 29 +------- .../Items/Components/Holdable/RepairTool.cs | 3 - .../Items/Components/Machines/Reactor.cs | 72 +++--------------- .../BarotraumaShared/Source/Map/Submarine.cs | 28 ++----- .../BarotraumaShared/Source/Map/WayPoint.cs | 2 +- 25 files changed, 136 insertions(+), 241 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs index b20e0e7c8..e112d338c 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs @@ -51,19 +51,19 @@ namespace Barotrauma } GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 80.0f, State.ToString(), stateColor, Color.Black); - if (LatchOntoAI != null) + if (latchOntoAI != null) { - foreach (Joint attachJoint in LatchOntoAI.AttachJoints) + foreach (Joint attachJoint in latchOntoAI.AttachJoints) { GUI.DrawLine(spriteBatch, ConvertUnits.ToDisplayUnits(new Vector2(attachJoint.WorldAnchorA.X, -attachJoint.WorldAnchorA.Y)), ConvertUnits.ToDisplayUnits(new Vector2(attachJoint.WorldAnchorB.X, -attachJoint.WorldAnchorB.Y)), Color.Green, 0, 4); } - if (LatchOntoAI.WallAttachPos.HasValue) + if (latchOntoAI.WallAttachPos.HasValue) { GUI.DrawLine(spriteBatch, pos, - ConvertUnits.ToDisplayUnits(new Vector2(LatchOntoAI.WallAttachPos.Value.X, -LatchOntoAI.WallAttachPos.Value.Y)), Color.Green, 0, 3); + ConvertUnits.ToDisplayUnits(new Vector2(latchOntoAI.WallAttachPos.Value.X, -latchOntoAI.WallAttachPos.Value.Y)), Color.Green, 0, 3); } } diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs index 7fab0116d..87d29a9e2 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs @@ -224,13 +224,6 @@ namespace Barotrauma } } - if (SelectedConstruction != null && SelectedConstruction.ActiveHUDs.Any(ic => ic.GuiFrame != null && HUD.CloseHUD(ic.GuiFrame.Rect))) - { - //emulate a Select input to get the character to deselect the item server-side - keys[(int)InputType.Select].Hit = true; - SelectedConstruction = null; - } - DoInteractionUpdate(deltaTime, mouseSimPos); } diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs index 87ccc8154..6732dcef2 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs @@ -56,7 +56,7 @@ namespace Barotrauma private static List messages = new List(); private static Sound[] sounds; private static bool pauseMenuOpen, settingsMenuOpen; - public static GUIFrame PauseMenu { get; private set; } + private static GUIFrame pauseMenu; private static Sprite arrow, lockIcon, checkmarkIcon, timerIcon; public static KeyboardDispatcher KeyboardDispatcher { get; set; } @@ -561,7 +561,7 @@ namespace Barotrauma if (pauseMenuOpen) { - PauseMenu.AddToGUIUpdateList(); + pauseMenu.AddToGUIUpdateList(); } if (settingsMenuOpen) { @@ -1420,9 +1420,9 @@ namespace Barotrauma if (pauseMenuOpen) { - PauseMenu = new GUIFrame(new RectTransform(Vector2.One, Canvas), style: null, color: Color.Black * 0.5f); + pauseMenu = new GUIFrame(new RectTransform(Vector2.One, Canvas), style: null, color: Color.Black * 0.5f); - var pauseMenuInner = new GUIFrame(new RectTransform(new Vector2(0.13f, 0.3f), PauseMenu.RectTransform, Anchor.Center) { MinSize = new Point(200, 300) }); + var pauseMenuInner = new GUIFrame(new RectTransform(new Vector2(0.13f, 0.3f), pauseMenu.RectTransform, Anchor.Center) { MinSize = new Point(200, 300) }); var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.85f, 0.85f), pauseMenuInner.RectTransform, Anchor.Center)) { diff --git a/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs b/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs index 1a0b79cd9..e395f08c0 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs @@ -200,9 +200,6 @@ namespace Barotrauma { public static bool CloseHUD(Rectangle rect) { - // Always close when hitting escape - if (PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.Escape)) { return true; } - //don't close when the cursor is on a UI element if (GUI.MouseOn != null) return false; diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs index d08306bd4..ded8f0896 100644 --- a/Barotrauma/BarotraumaClient/Source/GameMain.cs +++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs @@ -601,9 +601,8 @@ namespace Barotrauma { ((GUIMessageBox)GUIMessageBox.VisibleBox).Close(); } - else if ((GUI.MouseOn == null || GUI.IsMouseOn(GUI.PauseMenu)) && Inventory.SelectedSlot == null && CharacterHealth.OpenHealthWindow == null) + else // Otherwise toggle pausing. { - // Otherwise toggle pausing, unless another window/interface is open. GUI.TogglePauseMenu(); } } diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index 1ef20b629..d625ef340 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -976,7 +976,7 @@ namespace Barotrauma foreach (GUIComponent c in prevCharacterListBox.Content.Children) { Character character = c.UserData as Character; - if (character == null) continue; + if (character == null || character.IsDead || character.Removed) continue; AddCharacter(character); DisplayCharacterOrder(character, character.CurrentOrder); } diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs index b0c6a86bd..58c578bf1 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs @@ -49,6 +49,9 @@ namespace Barotrauma.Tutorials private float medicalTutorialTimer = 0.0f; private const float medicalTutorialDelay = 2.0f; + private Point screenResolution; + private float prevUIScale; + private class TutorialSegment { public string Id; @@ -231,19 +234,34 @@ namespace Barotrauma.Tutorials { holderFrame = new GUIFrame(new RectTransform(new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight), GUI.Canvas, Anchor.Center)); objectiveFrame = new GUIFrame(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.ObjectiveAnchor, holderFrame.RectTransform), style: null); + + for (int i = 0; i < activeObjectives.Count; i++) + { + CreateObjectiveGUI(activeObjectives[i], i); + } + + screenResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight); + prevUIScale = GUI.Scale; } public override void AddToGUIUpdateList() { + if (videoPlayer != null) + { + videoPlayer.AddToGUIUpdateList(order: 100); + } + + if (GUI.DisableHUD) return; + if (GameMain.GraphicsWidth != screenResolution.X || GameMain.GraphicsHeight != screenResolution.Y || prevUIScale != GUI.Scale) + { + CreateObjectiveFrame(); + } + if (objectiveFrame != null && activeObjectives.Count > 0) { objectiveFrame.AddToGUIUpdateList(order: -1); } base.AddToGUIUpdateList(); - if (videoPlayer != null) - { - videoPlayer.AddToGUIUpdateList(order: 100); - } } public override void Update(float deltaTime) @@ -299,19 +317,25 @@ namespace Barotrauma.Tutorials private void AddNewObjective(TutorialSegment segment) { activeObjectives.Add(segment); + CreateObjectiveGUI(segment, activeObjectives.Count - 1); + } - Point replayButtonSize = new Point((int)GUI.ObjectiveNameFont.MeasureString(segment.Objective).X, (int)(GUI.ObjectiveNameFont.MeasureString(segment.Objective).Y * 1.45f)); + private void CreateObjectiveGUI(TutorialSegment segment, int index) + { + Point replayButtonSize = new Point((int)(GUI.ObjectiveNameFont.MeasureString(segment.Objective).X * GUI.Scale), (int)(GUI.ObjectiveNameFont.MeasureString(segment.Objective).Y * 1.45f * GUI.Scale)); - segment.ReplayButton = new GUIButton(new RectTransform(replayButtonSize, objectiveFrame.RectTransform, Anchor.TopRight, Pivot.TopRight) { AbsoluteOffset = new Point(/*(int)(-2.5f * toggleButton.Rect.Width)*/0, (replayButtonSize.Y + 20) * (activeObjectives.Count - 1)) }, style: null); + segment.ReplayButton = new GUIButton(new RectTransform(replayButtonSize, objectiveFrame.RectTransform, Anchor.TopRight, Pivot.TopRight) { AbsoluteOffset = new Point(0, (replayButtonSize.Y + (int)(20f * GUI.Scale)) * index) }, style: null); segment.ReplayButton.OnClicked += (GUIButton btn, object userdata) => { ReplaySegmentVideo(segment); return true; }; - int yOffset = (int)(GUI.ObjectiveNameFont.MeasureString(objectiveTranslated).Y / 2f) + 5; - segment.LinkedTitle = new GUITextBlock(new RectTransform(new Point(replayButtonSize.X, yOffset), segment.ReplayButton.RectTransform, Anchor.Center, Pivot.BottomCenter) { AbsoluteOffset = new Point(10, 0) }, objectiveTranslated, textColor: Color.White, font: GUI.ObjectiveTitleFont, textAlignment: Alignment.CenterRight); - segment.LinkedText = new GUITextBlock(new RectTransform(new Point(replayButtonSize.X, yOffset), segment.ReplayButton.RectTransform, Anchor.Center, Pivot.TopCenter) { AbsoluteOffset = new Point(10, 0) }, segment.Objective, textColor: new Color(4, 180, 108), font: GUI.ObjectiveNameFont, textAlignment: Alignment.CenterRight); + int yOffset = (int)((GUI.ObjectiveNameFont.MeasureString(objectiveTranslated).Y / 2f + 5) * GUI.Scale); + segment.LinkedTitle = new GUITextBlock(new RectTransform(new Point(replayButtonSize.X, yOffset), segment.ReplayButton.RectTransform, Anchor.Center, Pivot.BottomCenter) { AbsoluteOffset = new Point((int)(10 * GUI.Scale), 0) }, objectiveTranslated, textColor: Color.White, font: GUI.ObjectiveTitleFont, textAlignment: Alignment.CenterRight); + segment.LinkedText = new GUITextBlock(new RectTransform(new Point(replayButtonSize.X, yOffset), segment.ReplayButton.RectTransform, Anchor.Center, Pivot.TopCenter) { AbsoluteOffset = new Point((int)(10 * GUI.Scale), 0) }, segment.Objective, textColor: new Color(4, 180, 108), font: GUI.ObjectiveNameFont, textAlignment: Alignment.CenterRight); + + segment.LinkedTitle.TextScale = segment.LinkedText.TextScale = GUI.Scale; segment.LinkedTitle.Color = segment.LinkedTitle.HoverColor = segment.LinkedTitle.PressedColor = segment.LinkedTitle.SelectedColor = Color.Transparent; segment.LinkedText.Color = segment.LinkedText.HoverColor = segment.LinkedText.PressedColor = segment.LinkedText.SelectedColor = Color.Transparent; diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/Tutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/Tutorial.cs index 12e249cba..69a5e98c9 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/Tutorial.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/Tutorial.cs @@ -188,17 +188,19 @@ namespace Barotrauma.Tutorials Anchor anchor = Anchor.TopRight; Enum.TryParse(anchorStr, out anchor); - var infoBlock = new GUIFrame(new RectTransform(new Point(width, height), GUI.Canvas, anchor) { AbsoluteOffset = new Point(20) }); + var infoBlock = new GUIFrame(new RectTransform(new Point((int)(width * GUI.Scale), (int)(height * GUI.Scale)), GUI.Canvas, anchor) { AbsoluteOffset = new Point(20) }); infoBlock.Flash(Color.Green); if (title.Length > 0) { var titleBlock = new GUITextBlock(new RectTransform(new Vector2(1f, .35f), infoBlock.RectTransform, Anchor.TopCenter, Pivot.TopCenter), title, font: GUI.VideoTitleFont, textAlignment: Alignment.Center, textColor: new Color(253, 174, 0)); + titleBlock.TextScale = GUI.Scale; } var textBlock = new GUITextBlock(new RectTransform(new Vector2(0.9f, 1f), infoBlock.RectTransform, Anchor.BottomCenter), text, wrap: true); + textBlock.TextScale = GUI.Scale; infoBoxClosedCallback = callback; diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/LevelResource.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/LevelResource.cs index b7951ce7d..8a73e7e2e 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/LevelResource.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/LevelResource.cs @@ -7,7 +7,7 @@ namespace Barotrauma.Items.Components { public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime) { - deattachTimer = msg.ReadSingle(); + DeattachTimer = msg.ReadSingle(); if (deattachTimer >= DeattachDuration) { holdable.DeattachFromWall(); diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/RepairTool.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/RepairTool.cs index f8f82df50..9b14effac 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/RepairTool.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/RepairTool.cs @@ -1,7 +1,6 @@ using Barotrauma.Particles; using FarseerPhysics; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; using System.Linq; @@ -12,21 +11,12 @@ using System.Xml.Linq; namespace Barotrauma.Items.Components { partial class RepairTool -#if DEBUG - : IDrawableComponent -#endif { public ParticleEmitter ParticleEmitter { get; private set; } -#if DEBUG - public Vector2 DrawSize - { - get { return GameMain.DebugDraw ? Vector2.One * Range : Vector2.Zero; } - } -#endif private List ParticleEmitterHitStructure = new List(); private List ParticleEmitterHitCharacter = new List(); @@ -132,17 +122,5 @@ namespace Barotrauma.Items.Components emitter.Second.Emit(deltaTime, particlePos, item.CurrentHull, particleAngle + MathHelper.Pi, -particleAngle + MathHelper.Pi); } } -#if DEBUG - public void Draw(SpriteBatch spriteBatch, bool editing) - { - if (GameMain.DebugDraw && IsActive) - { - GUI.DrawLine(spriteBatch, - new Vector2(debugRayStartPos.X, -debugRayStartPos.Y), - new Vector2(debugRayEndPos.X, -debugRayEndPos.Y), - Color.Yellow); - } - } -#endif } } diff --git a/Barotrauma/BarotraumaClient/Source/Items/ItemInventory.cs b/Barotrauma/BarotraumaClient/Source/Items/ItemInventory.cs index 8f2aa6359..8c126470f 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/ItemInventory.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/ItemInventory.cs @@ -10,6 +10,12 @@ namespace Barotrauma protected override void ControlInput(Camera cam) { + if (draggingItem == null && HUD.CloseHUD(BackgroundFrame)) + { + // TODO: fix so that works with the server side + Character.Controlled.SelectedConstruction = null; + return; + } base.ControlInput(cam); if (BackgroundFrame.Contains(PlayerInput.MousePosition)) { diff --git a/Barotrauma/BarotraumaClient/Source/Map/MapEntity.cs b/Barotrauma/BarotraumaClient/Source/Map/MapEntity.cs index a49b60add..cd6f5624a 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/MapEntity.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/MapEntity.cs @@ -504,12 +504,12 @@ namespace Barotrauma { foreach (MapEntity e in selectedList) { - e.prefab?.DrawPlacing(spriteBatch, + e.prefab.DrawPlacing(spriteBatch, new Rectangle(e.WorldRect.Location + new Point((int)moveAmount.X, (int)-moveAmount.Y), e.WorldRect.Size)); GUI.DrawRectangle(spriteBatch, new Vector2(e.WorldRect.X, -e.WorldRect.Y) + moveAmount, new Vector2(e.rect.Width, e.rect.Height), - Color.White, false, 0, (int)Math.Max(3.0f / GameScreen.Selected.Cam.Zoom, 2.0f)); + Color.DarkRed, false, 0, (int)Math.Max(1.5f / GameScreen.Selected.Cam.Zoom, 1.0f)); } //stop dragging the "selection rectangle" diff --git a/Barotrauma/BarotraumaClient/Source/Map/MapEntityPrefab.cs b/Barotrauma/BarotraumaClient/Source/Map/MapEntityPrefab.cs index 2d2a03e2b..f8ab3faa8 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/MapEntityPrefab.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/MapEntityPrefab.cs @@ -44,7 +44,7 @@ namespace Barotrauma drawRect.Location -= Submarine.MainSub.Position.ToPoint(); } drawRect.Y = -drawRect.Y; - GUI.DrawRectangle(spriteBatch, drawRect, Color.White); + GUI.DrawRectangle(spriteBatch, drawRect, Color.DarkBlue); } public void DrawListLine(SpriteBatch spriteBatch, Vector2 pos, Color color) { diff --git a/Barotrauma/BarotraumaClient/Source/Screens/CharacterEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/CharacterEditorScreen.cs index 8dfbbdd0b..e837a65b9 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CharacterEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CharacterEditorScreen.cs @@ -1239,7 +1239,7 @@ namespace Barotrauma #if !DEBUG if (vanilla != null && contentPackage == vanilla) { - GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), Color.Red, font: GUI.LargeFont); + GUI.AddMessage($"Cannot edit the Vanilla content!", Color.Red, font: GUI.LargeFont); return false; } #endif @@ -1879,7 +1879,7 @@ namespace Barotrauma #if !DEBUG if (VanillaCharacters != null && VanillaCharacters.Contains(currentCharacterConfig)) { - GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), Color.Red, font: GUI.LargeFont); + GUI.AddMessage(GetCharacterEditorTranslation("CantEditVanillaContent"), Color.Red, font: GUI.LargeFont); return false; } #endif @@ -1894,7 +1894,7 @@ namespace Barotrauma #if !DEBUG if (VanillaCharacters != null && VanillaCharacters.Contains(currentCharacterConfig)) { - GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), Color.Red, font: GUI.LargeFont); + GUI.AddMessage(GetCharacterEditorTranslation("CantEditVanillaContent"), Color.Red, font: GUI.LargeFont); return false; } #endif @@ -1966,7 +1966,7 @@ namespace Barotrauma #if !DEBUG if (VanillaCharacters != null && VanillaCharacters.Contains(currentCharacterConfig)) { - GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), Color.Red, font: GUI.LargeFont); + GUI.AddMessage(GetCharacterEditorTranslation("CantEditVanillaContent"), Color.Red, font: GUI.LargeFont); box.Close(); return false; } @@ -2099,7 +2099,7 @@ namespace Barotrauma #if !DEBUG if (VanillaCharacters != null && VanillaCharacters.Contains(currentCharacterConfig)) { - GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), Color.Red, font: GUI.LargeFont); + GUI.AddMessage(GetCharacterEditorTranslation("CantEditVanillaContent"), Color.Red, font: GUI.LargeFont); box.Close(); return false; } diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs index 97342cb7e..fb95c2152 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs @@ -769,20 +769,6 @@ namespace Barotrauma savePath = Path.Combine(Submarine.SavePath, savePath); } -#if !DEBUG - var vanilla = GameMain.VanillaContent; - if (vanilla != null) - { - var vanillaSubs = vanilla.GetFilesOfType(ContentType.Submarine); - string pathToCompare = savePath.Replace(@"\", @"/").ToLowerInvariant(); - if (vanillaSubs.Any(sub => sub.Replace(@"\", @"/").ToLowerInvariant() == pathToCompare)) - { - GUI.AddMessage(TextManager.Get("CannotEditVanillaSubs"), Color.Red, font: GUI.LargeFont); - return false; - } - } -#endif - /*foreach (var contentPackage in GameMain.Config.SelectedContentPackages) { Submarine.MainSub.RequiredContentPackages.Add(contentPackage.Name); diff --git a/Barotrauma/BarotraumaShared/Data/ContentPackages/Vanilla 0.9.xml b/Barotrauma/BarotraumaShared/Data/ContentPackages/Vanilla 0.9.xml index 98144c0a5..7a10d5467 100644 --- a/Barotrauma/BarotraumaShared/Data/ContentPackages/Vanilla 0.9.xml +++ b/Barotrauma/BarotraumaShared/Data/ContentPackages/Vanilla 0.9.xml @@ -75,7 +75,6 @@ - diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs index 33b12d3e9..f9fc59deb 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs @@ -70,10 +70,12 @@ namespace Barotrauma private float raycastTimer; - private bool IsCoolDownRunning => AttackingLimb != null && AttackingLimb.attack.CoolDownTimer > 0; + private bool IsCoolDownRunning => attackingLimb != null && attackingLimb.attack.CoolDownTimer > 0; private bool aggressiveBoarding; + private LatchOntoAI latchOntoAI; + //a point in a wall which the Character is currently targeting private WallTarget wallTarget; @@ -114,8 +116,6 @@ namespace Barotrauma private readonly float priorityFearIncreasement = 2; private readonly float memoryFadeTime = 0.5f; - public LatchOntoAI LatchOntoAI { get; private set; } - public bool AttackHumans { get @@ -134,6 +134,11 @@ namespace Barotrauma } } + public Limb AttackingLimb + { + get { return attackingLimb; } + } + public float CombatStrength { get { return combatStrength; } @@ -144,7 +149,7 @@ namespace Barotrauma get { //can't enter a submarine when attached to something - return LatchOntoAI == null || !LatchOntoAI.IsAttached; + return latchOntoAI == null || !latchOntoAI.IsAttached; } } @@ -152,13 +157,11 @@ namespace Barotrauma { get { - //can't flip when attached to something or when reversing - return !Reverse && (LatchOntoAI == null || !LatchOntoAI.IsAttached); + //can't flip when attached to something + return latchOntoAI == null || !latchOntoAI.IsAttached; } } - public bool Reverse { get; private set; } - public EnemyAIController(Character c, string file, string seed) : base(c) { targetMemories = new Dictionary(); @@ -206,7 +209,7 @@ namespace Barotrauma switch (subElement.Name.ToString().ToLowerInvariant()) { case "latchonto": - LatchOntoAI = new LatchOntoAI(subElement, this); + latchOntoAI = new LatchOntoAI(subElement, this); break; case "targetpriority": targetingPriorities.Add(subElement.GetAttributeString("tag", "").ToLowerInvariant(), new TargetingPriority(subElement)); @@ -315,7 +318,7 @@ namespace Barotrauma } } - LatchOntoAI?.Update(this, deltaTime); + latchOntoAI?.Update(this, deltaTime); if (SelectedAiTarget != null && (SelectedAiTarget.Entity == null || SelectedAiTarget.Entity.Removed)) { @@ -571,7 +574,7 @@ namespace Barotrauma if (Character.WorldPosition.Y < door.Item.WorldRect.Y && Character.WorldPosition.Y > door.Item.WorldRect.Y - door.Item.Rect.Height) { velocity.Y = 0; - LatchOntoAI?.DeattachFromBody(); + latchOntoAI?.DeattachFromBody(); Character.AnimController.ReleaseStuckLimbs(); steeringManager.SteeringManual(deltaTime, velocity); return; @@ -582,7 +585,7 @@ namespace Barotrauma if (Character.WorldPosition.X < door.Item.WorldRect.X && Character.WorldPosition.X > door.Item.WorldRect.Right) { velocity.X = 0; - LatchOntoAI?.DeattachFromBody(); + latchOntoAI?.DeattachFromBody(); Character.AnimController.ReleaseStuckLimbs(); steeringManager.SteeringManual(deltaTime, velocity); return; @@ -595,14 +598,14 @@ namespace Barotrauma bool canAttack = true; if (IsCoolDownRunning) { - switch (AttackingLimb.attack.AfterAttack) + switch (attackingLimb.attack.AfterAttack) { case AIBehaviorAfterAttack.Pursue: case AIBehaviorAfterAttack.PursueIfCanAttack: - if (AttackingLimb.attack.SecondaryCoolDown <= 0) + if (attackingLimb.attack.SecondaryCoolDown <= 0) { // No (valid) secondary cooldown defined. - if (AttackingLimb.attack.AfterAttack == AIBehaviorAfterAttack.Pursue) + if (attackingLimb.attack.AfterAttack == AIBehaviorAfterAttack.Pursue) { canAttack = false; } @@ -614,33 +617,33 @@ namespace Barotrauma } else { - if (AttackingLimb.attack.SecondaryCoolDownTimer <= 0) + if (attackingLimb.attack.SecondaryCoolDownTimer <= 0) { // Don't allow attacking when the attack target has just changed. if (_previousAiTarget != null && SelectedAiTarget != _previousAiTarget) { canAttack = false; - if (AttackingLimb.attack.AfterAttack == AIBehaviorAfterAttack.PursueIfCanAttack) + if (attackingLimb.attack.AfterAttack == AIBehaviorAfterAttack.PursueIfCanAttack) { // Fall back if cannot attack. UpdateFallBack(attackWorldPos, deltaTime); return; } - AttackingLimb = null; + attackingLimb = null; } else { // If the secondary cooldown is defined and expired, check if we can switch the attack - var previousLimb = AttackingLimb; + var previousLimb = attackingLimb; var newLimb = GetAttackLimb(attackWorldPos, previousLimb); if (newLimb != null) { - AttackingLimb = newLimb; + attackingLimb = newLimb; } else { // No new limb was found. - if (AttackingLimb.attack.AfterAttack == AIBehaviorAfterAttack.Pursue) + if (attackingLimb.attack.AfterAttack == AIBehaviorAfterAttack.Pursue) { canAttack = false; } @@ -667,20 +670,20 @@ namespace Barotrauma } } - if (AttackingLimb == null || _previousAiTarget != SelectedAiTarget) + if (attackingLimb == null || _previousAiTarget != SelectedAiTarget) { - AttackingLimb = GetAttackLimb(attackWorldPos); + attackingLimb = GetAttackLimb(attackWorldPos); } if (canAttack) { - canAttack = AttackingLimb != null && AttackingLimb.attack.CoolDownTimer <= 0; + canAttack = attackingLimb != null && attackingLimb.attack.CoolDownTimer <= 0; } float distance = 0; if (canAttack) { // Check that we can reach the target - distance = Vector2.Distance(AttackingLimb.WorldPosition, attackWorldPos); - canAttack = distance < AttackingLimb.attack.Range; + distance = Vector2.Distance(attackingLimb.WorldPosition, attackWorldPos); + canAttack = distance < attackingLimb.attack.Range; } // If the attacking limb is a hand or claw, for example, using it as the steering limb can end in the result where the character circles around the target. For example the Hammerhead steering with the claws when it should use the torso. @@ -689,7 +692,7 @@ namespace Barotrauma Limb steeringLimb; var torso = Character.AnimController.GetLimb(LimbType.Torso); var head = Character.AnimController.GetLimb(LimbType.Head); - if (AttackingLimb == null) + if (attackingLimb == null) { steeringLimb = head ?? torso; } @@ -697,7 +700,7 @@ namespace Barotrauma { if (head != null && torso != null) { - steeringLimb = Vector2.DistanceSquared(AttackingLimb.SimPosition, head.SimPosition) < Vector2.DistanceSquared(AttackingLimb.SimPosition, torso.SimPosition) ? head : torso; + steeringLimb = Vector2.DistanceSquared(attackingLimb.SimPosition, head.SimPosition) < Vector2.DistanceSquared(attackingLimb.SimPosition, torso.SimPosition) ? head : torso; } else { @@ -748,7 +751,7 @@ namespace Barotrauma if (canAttack) { - UpdateLimbAttack(deltaTime, AttackingLimb, attackSimPos, distance); + UpdateLimbAttack(deltaTime, attackingLimb, attackSimPos, distance); } } @@ -765,7 +768,7 @@ namespace Barotrauma { targetWorldPos.X = targetHull.WorldRect.Center.X; } - LatchOntoAI?.DeattachFromBody(); + latchOntoAI?.DeattachFromBody(); Character.AnimController.ReleaseStuckLimbs(); if (steeringManager is IndoorsSteeringManager) { @@ -788,7 +791,6 @@ namespace Barotrauma .Where(l => l != ignoredLimb && l.attack != null && - l.attack.CoolDownTimer <= 0 && !l.IsSevered && !l.IsStuck && l.attack.IsValidContext(currentContext) && @@ -857,7 +859,7 @@ namespace Barotrauma attachTargetNormal = new Vector2(Math.Sign(WorldPosition.X - wall.WorldPosition.X), 0.0f); sectionPos.X += (wall.BodyWidth <= 0.0f ? wall.Rect.Width : wall.BodyWidth) / 2 * attachTargetNormal.X; } - LatchOntoAI?.SetAttachTarget(wall.Submarine.PhysicsBody.FarseerBody, wall.Submarine, ConvertUnits.ToSimUnits(sectionPos), attachTargetNormal); + latchOntoAI?.SetAttachTarget(wall.Submarine.PhysicsBody.FarseerBody, wall.Submarine, ConvertUnits.ToSimUnits(sectionPos), attachTargetNormal); wallTarget = new WallTarget(sectionPos, wall, sectionIndex); } } @@ -875,7 +877,7 @@ namespace Barotrauma } } - LatchOntoAI?.DeattachFromBody(); + latchOntoAI?.DeattachFromBody(); Character.AnimController.ReleaseStuckLimbs(); if (attacker == null || attacker.AiTarget == null) return; @@ -985,7 +987,7 @@ namespace Barotrauma #region Targeting - private bool IsProperlyLatched => LatchOntoAI != null && LatchOntoAI.IsAttached && SelectedAiTarget?.Entity == wallTarget?.Structure; + private bool IsProperlyLatched => latchOntoAI != null && latchOntoAI.IsAttached && SelectedAiTarget?.Entity == wallTarget?.Structure; //goes through all the AItargets, evaluates how preferable it is to attack the target, //whether the Character can see/hear the target and chooses the most preferable target within @@ -1243,11 +1245,10 @@ namespace Barotrauma protected override void OnStateChanged(AIState from, AIState to) { - LatchOntoAI?.DeattachFromBody(); + latchOntoAI?.DeattachFromBody(); Character.AnimController.ReleaseStuckLimbs(); escapePoint = Vector2.Zero; wallTarget = null; - AttackingLimb = null; } private int GetMinimumPassableHoleCount() diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs index d0d0016fc..a02063d4f 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs @@ -369,8 +369,8 @@ namespace Barotrauma return; } - Vector2 transformedMovement = reverse ? -movement : movement; - float movementAngle = MathUtils.VectorToAngle(transformedMovement) - MathHelper.PiOver2; + float movementAngle = MathUtils.VectorToAngle(movement) - MathHelper.PiOver2; + float mainLimbAngle = 0; if (MainLimb.type == LimbType.Torso && TorsoAngle.HasValue) { @@ -388,7 +388,7 @@ namespace Barotrauma while (MainLimb.Rotation - (movementAngle + mainLimbAngle) < -MathHelper.Pi) { movementAngle -= MathHelper.TwoPi; - } + } if (CurrentSwimParams.RotateTowardsMovement) { @@ -412,19 +412,16 @@ namespace Barotrauma if (TailAngle.HasValue) { Limb tail = GetLimb(LimbType.Tail); + //tail?.body.SmoothRotate(movementAngle + TailAngle.Value * Dir, TailTorque); if (tail != null) { SmoothRotateWithoutWrapping(tail, movementAngle + TailAngle.Value * Dir, MainLimb, TailTorque); } } } - else if (MainLimb.type == LimbType.Head && HeadAngle.HasValue) + else { movementAngle = Dir > 0 ? -MathHelper.PiOver2 : MathHelper.PiOver2; - if (reverse) - { - movementAngle = MathUtils.WrapAngleTwoPi(movementAngle - MathHelper.Pi); - } if (MainLimb.type == LimbType.Head && HeadAngle.HasValue) { Collider.SmoothRotate(HeadAngle.Value * Dir, CurrentSwimParams.SteerTorque); @@ -454,7 +451,7 @@ namespace Barotrauma var waveAmplitude = Math.Abs(CurrentSwimParams.WaveAmplitude); if (waveLength > 0 && waveAmplitude > 0) { - WalkPos -= transformedMovement.Length() / Math.Abs(waveLength); + WalkPos -= movement.Length() / Math.Abs(waveLength); WalkPos = MathUtils.WrapAngleTwoPi(WalkPos); } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs b/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs index 955ba731b..a80c796d3 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs @@ -81,9 +81,6 @@ namespace Barotrauma [Serialize(AIBehaviorAfterAttack.FallBack, true), Editable(ToolTip = "The preferred AI behavior after the attack.")] public AIBehaviorAfterAttack AfterAttack { get; private set; } - [Serialize(false, true), Editable(ToolTip = "Should the ai try to reverse when aiming with this attack?")] - public bool Reverse { get; private set; } - [Serialize(0.0f, true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 2000.0f, ToolTip = "Min distance from the attack limb to the target before the AI tries to attack.")] public float Range { get; private set; } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index 8993574a8..dc9aa2239 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -1186,10 +1186,6 @@ namespace Barotrauma if (PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.F)) { AnimController.ReleaseStuckLimbs(); - if (AIController != null && AIController is EnemyAIController enemyAI) - { - enemyAI.LatchOntoAI?.DeattachFromBody(); - } } #endif @@ -1269,7 +1265,15 @@ namespace Barotrauma if (IsKeyDown(InputType.Aim) && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this); } } - + +#if CLIENT + if (SelectedConstruction != null && SelectedConstruction.ActiveHUDs.Any(ic => ic.GuiFrame != null && HUD.CloseHUD(ic.GuiFrame.Rect))) + { + //emulate a Select input to get the character to deselect the item server-side + keys[(int)InputType.Select].Hit = true; + SelectedConstruction = null; + } +#endif if (SelectedConstruction != null) { if (IsKeyDown(InputType.Use)) SelectedConstruction.Use(deltaTime, this); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/LevelResource.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/LevelResource.cs index 90a7a0665..458bf0c57 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/LevelResource.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/LevelResource.cs @@ -2,15 +2,12 @@ using Lidgren.Network; using Microsoft.Xna.Framework; using System; -using System.Linq; using System.Xml.Linq; namespace Barotrauma.Items.Components { partial class LevelResource : ItemComponent, IServerSerializable { - private float lastSentDeattachTimer; - [Serialize(1.0f, false)] public float DeattachDuration { @@ -24,29 +21,12 @@ namespace Barotrauma.Items.Components get { return deattachTimer; } set { - //clients don't deattach the item until the server says so (handled in ClientRead) - if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) - { - return; - } deattachTimer = Math.Max(0.0f, value); -#if SERVER - if (deattachTimer >= DeattachDuration) - { - if (holdable.Attached){ item.CreateServerEvent(this); } - holdable.DeattachFromWall(); - } - else if (Math.Abs(lastSentDeattachTimer - deattachTimer) > 0.1f) - { - item.CreateServerEvent(this); - lastSentDeattachTimer = deattachTimer; - } -#else - if (deattachTimer >= DeattachDuration) + //clients don't deattach the item until the server says so (handled in ClientRead) + if ((GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient) && deattachTimer >= DeattachDuration) { holdable.DeattachFromWall(); } -#endif } } @@ -87,10 +67,7 @@ namespace Barotrauma.Items.Components return; } holdable.Reattachable = false; - if (requiredItems.Any()) - { - holdable.PickingTime = float.MaxValue; - } + holdable.PickingTime = float.MaxValue; var body = item.body ?? holdable.Body; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs index 153e694ef..5752bb1de 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs @@ -17,8 +17,6 @@ namespace Barotrauma.Items.Components private readonly List fixableEntities; private Vector2 pickedPosition; private float activeTimer; - - private Vector2 debugRayStartPos, debugRayEndPos; [Serialize(0.0f, false)] public float Range { get; set; } @@ -249,7 +247,6 @@ namespace Barotrauma.Items.Components var levelResource = targetItem.GetComponent(); if (levelResource != null && levelResource.IsActive && - levelResource.requiredItems.Any() && levelResource.HasRequiredItems(user, addMessage: false)) { levelResource.DeattachTimer += deltaTime; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Reactor.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Reactor.cs index a26222b4b..f10b4cec8 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Reactor.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Reactor.cs @@ -49,7 +49,7 @@ namespace Barotrauma.Items.Components private bool shutDown; - const float AIUpdateInterval = 0.2f; + const float AIUpdateInterval = 1.0f; private float aiUpdateTimer; private Character lastUser; @@ -209,7 +209,7 @@ namespace Barotrauma.Items.Components allowedFissionRate = Vector2.Lerp(new Vector2(20, AvailableFuel), new Vector2(10, AvailableFuel), degreeOfSuccess); allowedFissionRate.X = Math.Min(allowedFissionRate.X, allowedFissionRate.Y - 10); - float heatAmount = GetGeneratedHeat(fissionRate); + float heatAmount = fissionRate * (AvailableFuel / 100.0f) * 2.0f; float temperatureDiff = (heatAmount - turbineOutput) - Temperature; Temperature += MathHelper.Clamp(Math.Sign(temperatureDiff) * 10.0f * deltaTime, -Math.Abs(temperatureDiff), Math.Abs(temperatureDiff)); //if (item.InWater && AvailableFuel < 100.0f) Temperature -= 12.0f * deltaTime; @@ -313,48 +313,6 @@ namespace Barotrauma.Items.Components } } - private float GetGeneratedHeat(float fissionRate) - { - return fissionRate * (prevAvailableFuel / 100.0f) * 2.0f; - } - - /// - /// Do we need more fuel to generate enough power to match the current load. - /// - /// How low we allow the output/load ratio to go before loading more fuel. - /// 1.0 = always load more fuel when maximum output is too low, 0.5 = load more if max output is 50% of the load - private bool NeedMoreFuel(float minimumOutputRatio) - { - if (prevAvailableFuel <= 0.0f && load > 0.0f) - { - return true; - } - - //fission rate is clamped to the amount of available fuel - float maxFissionRate = Math.Min(prevAvailableFuel, 100.0f); - float maxTurbineOutput = 100.0f; - - //calculate the maximum output if the fission rate is cranked as high as it goes and turbine output is at max - float theoreticalMaxHeat = GetGeneratedHeat(fissionRate: maxFissionRate); - float temperatureFactor = Math.Min(theoreticalMaxHeat / 50.0f, 1.0f); - float theoreticalMaxOutput = Math.Min(maxTurbineOutput / 100.0f, temperatureFactor) * MaxPowerOutput; - - //maximum output not enough, we need more fuel - return theoreticalMaxOutput < load * minimumOutputRatio; - } - - private bool TooMuchFuel() - { - var containedItems = item.ContainedItems; - if (containedItems != null && containedItems.Count() <= 1) { return false; } - - //get the amount of heat we'd generate if the fission rate was at the low end of the optimal range - float minimumHeat = GetGeneratedHeat(optimalFissionRate.X); - - //if we need a very high turbine output to keep the engine from overheating, there's too much fuel - return minimumHeat > Math.Min(correctTurbineOutput * 1.5f, 90); - } - private void UpdateFailures(float deltaTime) { if (temperature > allowedTemperature.Y) @@ -409,11 +367,6 @@ namespace Barotrauma.Items.Components targetFissionRate = Math.Min(targetFissionRate + speed * 2 * deltaTime, 100.0f); } targetFissionRate = MathHelper.Clamp(targetFissionRate, 0.0f, 100.0f); - - //don't push the target too far from the current fission rate - //otherwise we may "overshoot", cranking the target fission rate all the way up because it takes a while - //for the actual fission rate and temperature to follow - targetFissionRate = MathHelper.Clamp(targetFissionRate, FissionRate - 5, FissionRate + 5); } public override void UpdateBroken(float deltaTime, Camera cam) @@ -488,18 +441,12 @@ namespace Barotrauma.Items.Components } } - if (aiUpdateTimer > 0.0f) - { - aiUpdateTimer -= deltaTime; - return false; - } - - //load more fuel if the current maximum output is only 50% of the current load - if (NeedMoreFuel(minimumOutputRatio: 0.5f)) + //we need more fuel + if (-currPowerConsumption < load * 0.5f && prevAvailableFuel <= 0.0f) { var containFuelObjective = new AIObjectiveContainItem(character, new string[] { "fuelrod", "reactorfuel" }, item.GetComponent()) { - MinContainedAmount = item.ContainedItems.Count(i => i != null && i.Prefab.Identifier == "fuelrod" || i.HasTag("reactorfuel")) + 1, + MinContainedAmount = containedItems.Count(i => i != null && i.Prefab.Identifier == "fuelrod" || i.HasTag("reactorfuel")) + 1, GetItemPriority = (Item fuelItem) => { if (fuelItem.ParentInventory?.Owner is Item) @@ -514,7 +461,6 @@ namespace Barotrauma.Items.Components character?.Speak(TextManager.Get("DialogReactorFuel"), null, 0.0f, "reactorfuel", 30.0f); - aiUpdateTimer = AIUpdateInterval; return false; } else if (TooMuchFuel()) @@ -533,6 +479,12 @@ namespace Barotrauma.Items.Components } } + if (aiUpdateTimer > 0.0f) + { + aiUpdateTimer -= deltaTime; + return false; + } + if (lastUser != character && lastUser != null && lastUser.SelectedConstruction == item) { character.Speak(TextManager.Get("DialogReactorTaken"), null, 0.0f, "reactortaken", 10.0f); @@ -554,7 +506,7 @@ namespace Barotrauma.Items.Components { AutoTemp = false; unsentChanges = true; - UpdateAutoTemp(MathHelper.Lerp(0.5f, 2.0f, degreeOfSuccess), 1.0f); + UpdateAutoTemp(2.0f + degreeOfSuccess * 5.0f, 1.0f); } #if CLIENT onOffSwitch.BarScroll = 0.0f; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs index 738c9fa16..1629b9bff 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs @@ -678,24 +678,17 @@ namespace Barotrauma Body closestBody = null; if (allowInsideFixture) { - var aabb = new FarseerPhysics.Collision.AABB(rayStart - Vector2.One * 0.001f, rayStart + Vector2.One * 0.001f); + var aabb = new FarseerPhysics.Collision.AABB(rayStart - Vector2.UnitY * 0.001f, rayStart + Vector2.UnitY * 0.001f); GameMain.World.QueryAABB((fixture) => { - if (!CheckFixtureCollision(fixture, ignoredBodies, collisionCategory, ignoreSensors, customPredicate)) { return true; } - - fixture.Body.GetTransform(out FarseerPhysics.Common.Transform transform); - if (!fixture.Shape.TestPoint(ref transform, ref rayStart)) { return true; } - + if (!CheckFixtureCollision(fixture, ignoredBodies, collisionCategory, ignoreSensors, customPredicate)) { return false; } closestFraction = 0.0f; closestNormal = Vector2.Normalize(rayEnd - rayStart); if (fixture.Body != null) closestBody = fixture.Body; - return false; + return true; }, ref aabb); if (closestFraction <= 0.0f) { - lastPickedPosition = rayStart; - lastPickedFraction = closestFraction; - lastPickedNormal = closestNormal; return closestBody; } } @@ -747,21 +740,14 @@ namespace Barotrauma if (allowInsideFixture) { - var aabb = new FarseerPhysics.Collision.AABB(rayStart - Vector2.One * 0.001f, rayStart + Vector2.One * 0.001f); + var aabb = new FarseerPhysics.Collision.AABB(rayStart - Vector2.UnitY * 0.001f, rayStart + Vector2.UnitY * 0.001f); GameMain.World.QueryAABB((fixture) => { - if (bodies.Contains(fixture.Body) || fixture.Body == null) { return true; } - if (!CheckFixtureCollision(fixture, ignoredBodies, collisionCategory, ignoreSensors, customPredicate)) { return true; } - - fixture.Body.GetTransform(out FarseerPhysics.Common.Transform transform); - if (!fixture.Shape.TestPoint(ref transform, ref rayStart)) { return true; } - + if (bodies.Contains(fixture.Body) || fixture.Body == null) { return false; } + if (!CheckFixtureCollision(fixture, ignoredBodies, collisionCategory, ignoreSensors, customPredicate)) { return false; } closestFraction = 0.0f; - lastPickedPosition = rayStart; - lastPickedFraction = 0.0f; - lastPickedNormal = Vector2.Normalize(rayEnd - rayStart); bodies.Add(fixture.Body); - return false; + return true; }, ref aabb); } diff --git a/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs b/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs index f932497b4..bb1a5556f 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs @@ -615,7 +615,7 @@ namespace Barotrauma ID = (ushort)int.Parse(element.Attribute("ID").Value) }; - w.spawnType = spawnType; + Enum.TryParse(element.GetAttributeString("spawn", "Path"), out w.spawnType); string idCardDescString = element.GetAttributeString("idcarddesc", ""); if (!string.IsNullOrWhiteSpace(idCardDescString))