From 65a914e5edbd795c9ca2448321f370ade3259f5d Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sat, 18 May 2019 17:34:53 +0300 Subject: [PATCH] (0b29f1236) Added: Scaling to mouse cursor size --- .../Source/Characters/CharacterHUD.cs | 9 +--- Barotrauma/BarotraumaClient/Source/GUI/GUI.cs | 2 +- .../Source/GUI/GUITextBlock.cs | 7 +-- .../BarotraumaClient/Source/GameMain.cs | 2 +- .../Source/GameSession/CrewManager.cs | 4 +- .../GameModes/Tutorials/DoctorTutorial.cs | 12 ++--- .../Source/Items/Components/ItemLabel.cs | 3 +- .../Source/Items/Components/Machines/Sonar.cs | 4 +- .../Source/Networking/ChatMessage.cs | 4 +- .../Source/Screens/CreditsPlayer.cs | 35 ++----------- .../Source/Screens/MainMenuScreen.cs | 12 ----- .../Source/Networking/GameServer.cs | 12 ++--- .../Source/Characters/AI/HumanAIController.cs | 25 +++------- .../Characters/AI/IndoorsSteeringManager.cs | 8 +-- .../AI/Objectives/AIObjectiveFindSafety.cs | 41 +++++---------- .../AI/Objectives/AIObjectiveGoTo.cs | 16 ++---- .../AI/Objectives/AIObjectiveManager.cs | 10 +--- .../Source/Characters/AI/Order.cs | 7 +-- .../Source/Characters/AI/PathFinder.cs | 11 ++-- .../BarotraumaShared/Source/GameSettings.cs | 50 ++++++++++++++++++- .../Items/Components/Holdable/RepairTool.cs | 6 +-- .../Source/Map/Levels/Level.cs | 3 +- 22 files changed, 114 insertions(+), 169 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs b/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs index 0ee4b4bdf..53c504da4 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs @@ -332,6 +332,7 @@ namespace Barotrauma CharacterInventory.Layout.Right; } } + } if (!character.IsUnconscious && character.Stun <= 0.0f) { @@ -370,13 +371,7 @@ namespace Barotrauma private static void DrawOrderIndicator(SpriteBatch spriteBatch, Camera cam, Character character, Order order, float iconAlpha = 1.0f) { - if (order.TargetAllCharacters) - { - if (order.OrderGiver != character && !order.HasAppropriateJob(character)) - { - return; - } - } + if (order.TargetAllCharacters && !order.HasAppropriateJob(character)) { return; } Entity target = order.ConnectedController != null ? order.ConnectedController.Item : order.TargetEntity; if (target == null) { return; } diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs index 34de3d244..ba490a398 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs @@ -397,7 +397,7 @@ namespace Barotrauma MouseOn.DrawToolTip(spriteBatch); } - Cursor.Draw(spriteBatch, PlayerInput.LatestMousePosition); + Cursor.Draw(spriteBatch, PlayerInput.LatestMousePosition, 0, Scale); } public static void DrawBackgroundSprite(SpriteBatch spriteBatch, Sprite backgroundSprite, float blurAmount = 1.0f, float aberrationStrength = 1.0f) diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs index 5192c5a0f..bf80ea025 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs @@ -331,11 +331,8 @@ namespace Barotrauma if (!string.IsNullOrEmpty(text)) { Vector2 pos = rect.Location.ToVector2() + textPos + TextOffset; - if (RoundToNearestPixel) - { - pos.X = (int)pos.X; - pos.Y = (int)pos.Y; - } + pos.X = (int)pos.X; + pos.Y = (int)pos.Y; Font.DrawString(spriteBatch, Wrap ? wrappedText : text, diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs index 0b751a12b..28a8f28a7 100644 --- a/Barotrauma/BarotraumaClient/Source/GameMain.cs +++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs @@ -334,7 +334,7 @@ namespace Barotrauma SoundManager.SetCategoryGainMultiplier("ui", Config.SoundVolume); SoundManager.SetCategoryGainMultiplier("waterambience", Config.SoundVolume); SoundManager.SetCategoryGainMultiplier("music", Config.MusicVolume); - SoundManager.SetCategoryGainMultiplier("voip", Config.VoiceChatVolume * 5.0f); + SoundManager.SetCategoryGainMultiplier("voip", Config.VoiceChatVolume); if (Config.EnableSplashScreen) { var pendingSplashScreens = TitleScreen.PendingSplashScreens; diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index f85cd2475..c3871b3d1 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -747,7 +747,7 @@ namespace Barotrauma { if (orderGiver == null || orderGiver.CurrentHull == null) { return; } var hull = orderGiver.CurrentHull; - AddOrder(new Order(order.Prefab, hull, null, orderGiver), order.Prefab.FadeOutTime); + AddOrder(new Order(order.Prefab, hull, null), order.Prefab.FadeOutTime); if (IsSinglePlayer) { orderGiver.Speak( @@ -1350,7 +1350,7 @@ namespace Barotrauma bool hasFires = Character.Controlled.CurrentHull.FireSources.Count > 0; ToggleReportButton("reportfire", hasFires); - bool hasLeaks = Character.Controlled.CurrentHull.Submarine != null && Character.Controlled.CurrentHull.ConnectedGaps.Any(g => !g.IsRoomToRoom && g.Open > 0.0f); + bool hasLeaks = Character.Controlled.CurrentHull.ConnectedGaps.Any(g => !g.IsRoomToRoom && g.Open > 0.0f); ToggleReportButton("reportbreach", hasLeaks); bool hasIntruders = Character.CharacterList.Any(c => c.CurrentHull == Character.Controlled.CurrentHull && AIObjectiveFightIntruders.IsValidTarget(Character.Controlled, c)); diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs index f5259472d..011867366 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs @@ -233,9 +233,9 @@ namespace Barotrauma.Tutorials //patient 1 requests first aid patient1.CanSpeak = true; - var newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), patient1.CurrentHull, null, orderGiver: patient1); + var newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), patient1.CurrentHull, null); GameMain.GameSession.CrewManager.AddOrder(newOrder, newOrder.FadeOutTime); - patient1.Speak(newOrder.GetChatMessage("", patient1.CurrentHull?.DisplayName, givingOrderToSelf: false), ChatMessageType.Order); + patient1.Speak(newOrder.GetChatMessage("", patient1.CurrentHull?.RoomName, givingOrderToSelf: false), ChatMessageType.Order); patient1.AIController.Enabled = true; while (doctor.CurrentHull != patient1.CurrentHull) @@ -317,9 +317,9 @@ namespace Barotrauma.Tutorials //patient calls for help patient2.CanSpeak = true; - newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), patient2.CurrentHull, null, orderGiver: patient2); + newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), patient2.CurrentHull, null); GameMain.GameSession.CrewManager.AddOrder(newOrder, newOrder.FadeOutTime); - patient2.Speak(newOrder.GetChatMessage("", patient1.CurrentHull?.DisplayName, givingOrderToSelf: false), ChatMessageType.Order); + patient2.Speak(newOrder.GetChatMessage("", patient1.CurrentHull?.RoomName, givingOrderToSelf: false), ChatMessageType.Order); patient2.AIController.Enabled = true; patient2.Oxygen = -50; CoroutineManager.StartCoroutine(KeepPatientAlive(patient2), "KeepPatient2Alive"); @@ -378,10 +378,10 @@ namespace Barotrauma.Tutorials //(within 1 minute intervals of entering the sub) if (!patientCalledHelp[i] && Timing.TotalTime > subEnterTime + 60 * (i + 1)) { - newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), subPatients[i].CurrentHull, null, orderGiver: subPatients[i]); + newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), subPatients[i].CurrentHull, null); GameMain.GameSession.CrewManager.AddOrder(newOrder, newOrder.FadeOutTime); - string message = newOrder.GetChatMessage("", subPatients[i].CurrentHull?.DisplayName, givingOrderToSelf: false); + string message = newOrder.GetChatMessage("", subPatients[i].CurrentHull?.RoomName, givingOrderToSelf: false); if (subPatients[i].CanSpeak) { subPatients[i].Speak(message, ChatMessageType.Order); diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/ItemLabel.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/ItemLabel.cs index c837950c7..512abe647 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/ItemLabel.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/ItemLabel.cs @@ -105,8 +105,7 @@ namespace Barotrauma.Items.Components textBlock = new GUITextBlock(new RectTransform(item.Rect.Size), "", textColor: textColor, font: GUI.UnscaledSmallFont, textAlignment: Alignment.Center, wrap: true, style: null) { - TextDepth = item.SpriteDepth - 0.00001f, - RoundToNearestPixel = false, + TextDepth = item.SpriteDepth - 0.0001f, TextScale = TextScale }; } diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs index 840f47fb3..035c833a1 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs @@ -441,8 +441,8 @@ namespace Barotrauma.Items.Components { Vector2 sector1 = MathUtils.RotatePointAroundTarget(pingDirection * DisplayRadius, Vector2.Zero, DirectionalPingSector * 0.5f); Vector2 sector2 = MathUtils.RotatePointAroundTarget(pingDirection * DisplayRadius, Vector2.Zero, -DirectionalPingSector * 0.5f); - DrawLine(spriteBatch, Vector2.Zero, sector1, Color.LightCyan * 0.2f * directionalPingVisibility, width: 3); - DrawLine(spriteBatch, Vector2.Zero, sector2, Color.LightCyan * 0.2f * directionalPingVisibility, width: 3); + DrawLine(spriteBatch, center, center + sector1, Color.LightCyan * 0.2f * directionalPingVisibility, width: 3); + DrawLine(spriteBatch, center, center + sector2, Color.LightCyan * 0.2f * directionalPingVisibility, width: 3); } if (GameMain.DebugDraw) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/ChatMessage.cs b/Barotrauma/BarotraumaClient/Source/Networking/ChatMessage.cs index 32c8d5a98..4a560e126 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/ChatMessage.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/ChatMessage.cs @@ -66,13 +66,13 @@ namespace Barotrauma.Networking if (order.TargetAllCharacters) { GameMain.GameSession?.CrewManager?.AddOrder( - new Order(order.Prefab, targetEntity, (targetEntity as Item)?.Components.FirstOrDefault(ic => ic.GetType() == order.ItemComponentType), orderGiver: senderCharacter), + new Order(order.Prefab, targetEntity, (targetEntity as Item)?.Components.FirstOrDefault(ic => ic.GetType() == order.ItemComponentType)), order.Prefab.FadeOutTime); } else if (targetCharacter != null) { targetCharacter.SetOrder( - new Order(order.Prefab, targetEntity, (targetEntity as Item)?.Components.FirstOrDefault(ic => ic.GetType() == order.ItemComponentType), orderGiver: senderCharacter), + new Order(order.Prefab, targetEntity, (targetEntity as Item)?.Components.FirstOrDefault(ic => ic.GetType() == order.ItemComponentType)), orderOption, senderCharacter); } diff --git a/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs b/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs index 718c7c116..edd14786a 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs @@ -27,9 +27,6 @@ namespace Barotrauma case "text": AddTextElement(subElement, listBox.Content.RectTransform); break; - case "gridtext": - AddGridTextElement(subElement, listBox.Content.RectTransform); - break; case "spacing": AddSpacingElement(subElement, listBox.Content.RectTransform); break; @@ -41,9 +38,9 @@ namespace Barotrauma listBox.UpdateScrollBarSize(); } - private GUIComponent AddTextElement(XElement element, RectTransform parent, string overrideText = null, Anchor anchor = Anchor.Center) + private void AddTextElement(XElement element, RectTransform parent) { - var text = overrideText ?? element.ElementInnerText().Replace(@"\n", "\n"); + var text = element.ElementInnerText().Replace(@"\n", "\n"); Color color = element.GetAttributeColor("color", Color.White); float scale = element.GetAttributeFloat("scale", 1.0f); Alignment alignment = Alignment.Center; @@ -72,7 +69,7 @@ namespace Barotrauma } var textHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.0f), parent), style: null); - var textBlock = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), textHolder.RectTransform, anchor), + var textBlock = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), textHolder.RectTransform, Anchor.Center), text, color, font, @@ -84,32 +81,6 @@ namespace Barotrauma textBlock.RectTransform.IsFixedSize = textHolder.RectTransform.IsFixedSize = true; textBlock.RectTransform.NonScaledSize = new Point(textBlock.Rect.Width, textBlock.Rect.Height); textHolder.RectTransform.NonScaledSize = new Point(textHolder.Rect.Width, textBlock.Rect.Height); - return textHolder; - } - - private void AddGridTextElement(XElement element, RectTransform parent) - { - var text = element.ElementInnerText().Replace(@"\n", "\n"); - string[] elements = text.Split(','); - RectTransform lineContainer = null; - for (int i = 0; i < elements.Length; i++) - { - switch (i % 3) - { - case 0: - lineContainer = AddTextElement(element, parent, elements[i], Anchor.CenterLeft).RectTransform; - lineContainer.Anchor = Anchor.TopCenter; - lineContainer.Pivot = Pivot.TopCenter; - lineContainer.NonScaledSize = new Point((int)(parent.NonScaledSize.X * 0.7f), lineContainer.NonScaledSize.Y); - break; - case 1: - AddTextElement(element, lineContainer, elements[i], Anchor.Center).GetChild().TextAlignment = Alignment.Center; - break; - case 2: - AddTextElement(element, lineContainer, elements[i], Anchor.CenterRight).GetChild().TextAlignment = Alignment.CenterRight; - break; - } - } } private void AddSpacingElement(XElement element, RectTransform parent) diff --git a/Barotrauma/BarotraumaClient/Source/Screens/MainMenuScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/MainMenuScreen.cs index 6351ab8a4..208b9d5b4 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/MainMenuScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/MainMenuScreen.cs @@ -440,21 +440,9 @@ namespace Barotrauma GameMain.Config.SettingsFrame.RectTransform.RelativeSize = Vector2.One; break; case Tab.JoinServer: - if (!GameMain.Config.CampaignDisclaimerShown) - { - selectedTab = 0; - GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.JoinServer); }); - return true; - } GameMain.ServerListScreen.Select(); break; case Tab.HostServer: - if (!GameMain.Config.CampaignDisclaimerShown) - { - selectedTab = 0; - GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.HostServer); }); - return true; - } break; case Tab.Tutorials: if (!GameMain.Config.CampaignDisclaimerShown) diff --git a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs index b4cdb82cc..5ee4d596f 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs @@ -2408,10 +2408,7 @@ namespace Barotrauma.Networking if (senderCharacter != null && client.Character != null && !client.Character.IsDead) { - if (senderCharacter != client.Character) - { - modifiedMessage = ChatMessage.ApplyDistanceEffect(message, (ChatMessageType)type, senderCharacter, client.Character); - } + modifiedMessage = ChatMessage.ApplyDistanceEffect(message, (ChatMessageType)type, senderCharacter, client.Character); //too far to hear the msg -> don't send if (string.IsNullOrWhiteSpace(modifiedMessage)) continue; @@ -2460,16 +2457,13 @@ namespace Barotrauma.Networking if (message.Sender != null && client.Character != null && !client.Character.IsDead) { - if (message.Sender != client.Character) - { - modifiedMessage = ChatMessage.ApplyDistanceEffect(message.Text, messageType, message.Sender, client.Character); - } + modifiedMessage = ChatMessage.ApplyDistanceEffect(message.Text, messageType, message.Sender, client.Character); //too far to hear the msg -> don't send if (string.IsNullOrWhiteSpace(modifiedMessage)) continue; } - SendDirectChatMessage(new OrderChatMessage(message.Order, message.OrderOption, message.TargetEntity, message.TargetCharacter, message.Sender), client); + SendDirectChatMessage(message, client); } string myReceivedMessage = message.Text; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index 81cb836b6..593e5a714 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -85,18 +85,12 @@ namespace Barotrauma if (Character.Submarine != null || SelectedAiTarget?.Entity?.Submarine != null) { - if (steeringManager != insideSteering) - { - insideSteering.Reset(); - } + if (steeringManager != insideSteering) insideSteering.Reset(); steeringManager = insideSteering; } else { - if (steeringManager != outsideSteering) - { - outsideSteering.Reset(); - } + if (steeringManager != outsideSteering) outsideSteering.Reset(); steeringManager = outsideSteering; } @@ -301,7 +295,7 @@ namespace Barotrauma if (newOrder == null) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportintruders"); - newOrder = new Order(orderPrefab, c.CurrentHull, null, orderGiver: Character); + newOrder = new Order(orderPrefab, c.CurrentHull, null); } } } @@ -311,7 +305,7 @@ namespace Barotrauma if (newOrder == null) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportfire"); - newOrder = new Order(orderPrefab, hull, null, orderGiver: Character); + newOrder = new Order(orderPrefab, hull, null); } } foreach (Character c in Character.CharacterList) @@ -323,7 +317,7 @@ namespace Barotrauma if (newOrder == null) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "requestfirstaid"); - newOrder = new Order(orderPrefab, c.CurrentHull, null, orderGiver: Character); + newOrder = new Order(orderPrefab, c.CurrentHull, null); } } } @@ -335,7 +329,7 @@ namespace Barotrauma if (newOrder == null) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportbreach"); - newOrder = new Order(orderPrefab, hull, null, orderGiver: Character); + newOrder = new Order(orderPrefab, hull, null); } } } @@ -349,7 +343,7 @@ namespace Barotrauma if (newOrder == null) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportbrokendevices"); - newOrder = new Order(orderPrefab, item.CurrentHull, item.Repairables?.FirstOrDefault(), orderGiver: Character); + newOrder = new Order(orderPrefab, item.CurrentHull, item.Repairables?.FirstOrDefault()); } } } @@ -360,9 +354,6 @@ namespace Barotrauma if (GameMain.GameSession?.CrewManager != null && GameMain.GameSession.CrewManager.AddOrder(newOrder, newOrder.FadeOutTime)) { Character.Speak(newOrder.GetChatMessage("", Character.CurrentHull?.DisplayName, givingOrderToSelf: false), ChatMessageType.Order); -#if SERVER - GameMain.Server.SendOrderChatMessage(new OrderChatMessage(newOrder, "", Character.CurrentHull, null, Character)); -#endif } } } @@ -666,7 +657,7 @@ namespace Barotrauma { CurrentHullSafety = 0; } - return CurrentHullSafety; + return 0; } if (character == Character) { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs index 40ebc5006..60b6ddc79 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs @@ -144,9 +144,9 @@ namespace Barotrauma protected override Vector2 DoSteeringSeek(Vector2 target, float weight) { - bool needsNewPath = currentPath != null && currentPath.Unreachable || Vector2.DistanceSquared(target, currentTarget) > 1; + bool isDifferentTarget = Vector2.DistanceSquared(target, currentTarget) > 1; //find a new path if one hasn't been found yet or the target is different from the current target - if (currentPath == null || needsNewPath || findPathTimer < -1.0f) + if (currentPath == null || isDifferentTarget || findPathTimer < -1.0f) { IsPathDirty = true; @@ -164,7 +164,7 @@ namespace Barotrauma } var newPath = pathFinder.FindPath(pos, target, "(Character: " + character.Name + ")"); - if (currentPath == null || needsNewPath || !newPath.Unreachable && newPath.Cost < currentPath.Cost) + if (currentPath == null || isDifferentTarget || newPath.Cost < currentPath.Cost) { currentPath = newPath; } @@ -424,7 +424,7 @@ namespace Barotrauma // It's possible that we could reach another buttons. // If this becomes an issue, we could go through them here and check if any of them are reachable // (would have to cache a collection of buttons instead of a single reference in the CanAccess filter method above) - //currentPath.Unreachable = true; + currentPath.Unreachable = true; return; } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs index 851a0cd01..b7b1e13c4 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs @@ -46,7 +46,7 @@ namespace Barotrauma if (character.CurrentHull == null) { currenthullSafety = 0; - Priority = objectiveManager.CurrentOrder is AIObjectiveGoTo ? 0 : 100; + Priority = 100; return; } if (character.OxygenAvailable < CharacterHealth.LowOxygenThreshold) { Priority = 100; } @@ -68,8 +68,6 @@ namespace Barotrauma } } - private Hull currentSafeHull; - private Hull previousSafeHull; protected override void Act(float deltaTime) { var currentHull = character.AnimController.CurrentHull; @@ -109,20 +107,15 @@ namespace Barotrauma else { searchHullTimer = SearchHullInterval; - previousSafeHull = currentSafeHull; - currentSafeHull = FindBestHull(); - if (currentSafeHull == null) + var bestHull = FindBestHull(); + if (bestHull != null && bestHull != currentHull) { - currentSafeHull = previousSafeHull; - } - if (currentSafeHull != null && currentSafeHull != currentHull) - { - if (goToObjective?.Target != currentSafeHull) + if (goToObjective?.Target != bestHull) { goToObjective = null; } TryAddSubObjective(ref goToObjective, - constructor: () => new AIObjectiveGoTo(currentSafeHull, character, objectiveManager, getDivingGearIfNeeded: false) + constructor: () => new AIObjectiveGoTo(bestHull, character, objectiveManager, getDivingGearIfNeeded: false) { // If we need diving gear, we should already have it, if possible. AllowGoingOutside = HumanAIController.HasDivingSuit(character) @@ -134,15 +127,7 @@ namespace Barotrauma goToObjective = null; } } - if (goToObjective != null) - { - if (goToObjective.IsCompleted()) - { - objectiveManager.GetObjective()?.Wander(deltaTime); - } - Priority = 0; - return; - } + if (goToObjective != null) { return; } if (currentHull == null) { return; } //goto objective doesn't exist (a safe hull not found, or a path to a safe hull not found) // -> attempt to manually steer away from hazards @@ -181,8 +166,7 @@ namespace Barotrauma } else { - Priority = 0; - objectiveManager.GetObjective()?.Wander(deltaTime); + character.AIController.SteeringManager.Reset(); } } } @@ -195,11 +179,11 @@ namespace Barotrauma { if (hull.Submarine == null) { continue; } if (ignoredHulls != null && ignoredHulls.Contains(hull)) { continue; } - if (unreachable.Contains(hull)) { continue; } float hullSafety = 0; - if (character.CurrentHull != null) + if (character.Submarine != null && SteeringManager == PathSteering) { - // Inside + // Inside or outside near the sub + if (unreachable.Contains(hull)) { continue; } if (!character.Submarine.IsConnectedTo(hull.Submarine)) { continue; } hullSafety = HumanAIController.GetHullSafety(hull, character); // Vertical distance matters more than horizontal (climbing up/down is harder than moving horizontally) @@ -228,7 +212,7 @@ namespace Barotrauma else { // Outside - if (hull.RoomName != null && hull.RoomName.ToLowerInvariant().Contains("airlock")) + if (hull.RoomName?.ToLowerInvariant() == "airlock") { hullSafety = 100; } @@ -237,14 +221,13 @@ namespace Barotrauma // TODO: could also target gaps that get us inside? foreach (Item item in Item.ItemList) { - if (item.CurrentHull != hull && item.HasTag("airlock")) + if (item.CurrentHull == hull && item.HasTag("airlock")) { hullSafety = 100; break; } } } - // TODO: could we get a closest door to the outside and target the flowing hull if no airlock is found? // Huge preference for closer targets float distance = Vector2.DistanceSquared(character.WorldPosition, hull.WorldPosition); float distanceFactor = MathHelper.Lerp(1, 0.2f, MathUtils.InverseLerp(0, MathUtils.Pow(100000, 2), distance)); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs index 1a5874252..7fe272a64 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs @@ -117,7 +117,7 @@ namespace Barotrauma // Take the sub position into account in the sim pos if (character.Submarine == null && Target.Submarine != null) { - //currTargetSimPos += Target.Submarine.SimPosition; + currTargetSimPos += Target.Submarine.SimPosition; } else if (character.Submarine != null && Target.Submarine == null) { @@ -159,6 +159,7 @@ namespace Barotrauma // First check the distance // Then the custom condition // And finally check if can interact (heaviest) + if (repeat) { return false; } if (isCompleted) { return true; } if (Target == null) { @@ -166,16 +167,7 @@ namespace Barotrauma return false; } bool closeEnough = Vector2.DistanceSquared(Target.WorldPosition, character.WorldPosition) < CloseEnough * CloseEnough; - if (repeat) - { - if (closeEnough) - { - character.AIController.SteeringManager.Reset(); - character.AnimController.TargetDir = Target.WorldPosition.X > character.WorldPosition.X ? Direction.Right : Direction.Left; - } - return false; - } - else if (closeEnough) + if (closeEnough) { if (customCondition == null || customCondition()) { @@ -183,7 +175,7 @@ namespace Barotrauma { if (character.CanInteractWith(item, out _, checkLinked: false)) { isCompleted = true; } } - else if (Target is Character targetCharacter) + else if (Target is Character targetCharacter && !FollowControlledCharacter) { if (character.CanInteractWith(targetCharacter, CloseEnough)) { isCompleted = true; } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs index 8aae67958..aa296d02c 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs @@ -81,11 +81,7 @@ namespace Barotrauma Item.ItemList.FindAll(it => it.Components.Any(ic => ic.GetType() == orderPrefab.ItemComponentType)); matchingItems.RemoveAll(it => it.Submarine != character.Submarine); var item = matchingItems.GetRandom(); - var order = new Order( - orderPrefab, - item ?? character.CurrentHull as Entity, - item?.Components.FirstOrDefault(ic => ic.GetType() == orderPrefab.ItemComponentType), - orderGiver: character); + var order = new Order(orderPrefab, item ?? character.CurrentHull as Entity, item?.Components.FirstOrDefault(ic => ic.GetType() == orderPrefab.ItemComponentType)); if (order == null) { continue; } var objective = CreateObjective(order, automaticOrder.option, character, automaticOrder.priorityModifier); if (objective != null) @@ -202,10 +198,6 @@ namespace Barotrauma { CurrentObjective?.TryComplete(deltaTime); } - else - { - character.AIController.SteeringManager.Reset(); - } } public void SetOrder(AIObjective objective) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs index 6391147f5..b7986dcff 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs @@ -39,9 +39,7 @@ namespace Barotrauma public Entity TargetEntity; public ItemComponent TargetItemComponent; public readonly bool UseController; - public Controller ConnectedController; - - public Character OrderGiver; + public Controller ConnectedController; public readonly string[] AppropriateJobs; public readonly string[] Options; @@ -122,7 +120,7 @@ namespace Barotrauma } } - public Order(Order prefab, Entity targetEntity, ItemComponent targetItem, Character orderGiver = null) + public Order(Order prefab, Entity targetEntity, ItemComponent targetItem) { Prefab = prefab; @@ -136,7 +134,6 @@ namespace Barotrauma TargetAllCharacters = prefab.TargetAllCharacters; AppropriateJobs = prefab.AppropriateJobs; FadeOutTime = prefab.FadeOutTime; - OrderGiver = orderGiver; TargetEntity = targetEntity; if (targetItem != null) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/PathFinder.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/PathFinder.cs index 967a0b9d8..45adac1ec 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/PathFinder.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/PathFinder.cs @@ -165,8 +165,8 @@ namespace Barotrauma { Vector2 nodePos = node.Position; - float xDiff = Math.Abs(start.X - nodePos.X); - float yDiff = Math.Abs(start.Y - nodePos.Y); + float xDiff = System.Math.Abs(start.X - nodePos.X); + float yDiff = System.Math.Abs(start.Y - nodePos.Y); if (yDiff > 1.0f && node.Waypoint.Ladders == null && node.Waypoint.Stairs == null) { @@ -190,7 +190,7 @@ namespace Barotrauma if (body != null) { - //if (body.UserData is Submarine) continue; + if (body.UserData is Submarine) continue; if (body.UserData is Structure && !((Structure)body.UserData).IsPlatform) continue; if (body.UserData is Item && body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall)) continue; } @@ -216,7 +216,8 @@ namespace Barotrauma { Vector2 nodePos = node.Position; - float dist = Vector2.DistanceSquared(end, nodePos); + // TODO: use squared distance + float dist = Vector2.Distance(end, nodePos); if (insideSubmarine) { //much higher cost to waypoints that are outside @@ -234,7 +235,7 @@ namespace Barotrauma if (body != null) { - //if (body.UserData is Submarine) continue; + if (body.UserData is Submarine) continue; if (body.UserData is Structure && !((Structure)body.UserData).IsPlatform) continue; if (body.UserData is Item && body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall)) continue; diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index 9c16fcc29..64b8a8358 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -206,7 +206,7 @@ namespace Barotrauma { voiceChatVolume = MathHelper.Clamp(value, 0.0f, 1.0f); #if CLIENT - GameMain.SoundManager?.SetCategoryGainMultiplier("voip", voiceChatVolume * 5.0f); + GameMain.SoundManager?.SetCategoryGainMultiplier("voip", voiceChatVolume); #endif } } @@ -821,6 +821,54 @@ namespace Barotrauma VoiceSetting = voiceSetting; } } + if (!SelectedContentPackages.Any()) + { + var availablePackage = ContentPackage.List.FirstOrDefault(cp => cp.IsCompatible() && cp.CorePackage); + if (availablePackage != null) + { + SelectedContentPackages.Add(availablePackage); + } + } + + //save to get rid of the invalid selected packages in the config file + if (missingPackagePaths.Count > 0 || incompatiblePackages.Count > 0) { SaveNewPlayerConfig(); } + } + #endregion + + #region Save DefaultConfig + private void SaveNewDefaultConfig() + { + XDocument doc = new XDocument(); + + if (doc.Root == null) + { + doc.Add(new XElement("config")); + } + + doc.Root.Add( + new XAttribute("language", TextManager.Language), + new XAttribute("masterserverurl", MasterServerUrl), + new XAttribute("autocheckupdates", AutoCheckUpdates), + new XAttribute("musicvolume", musicVolume), + new XAttribute("soundvolume", soundVolume), + new XAttribute("voicechatvolume", voiceChatVolume), + new XAttribute("verboselogging", VerboseLogging), + new XAttribute("savedebugconsolelogs", SaveDebugConsoleLogs), + new XAttribute("enablesplashscreen", EnableSplashScreen), + new XAttribute("usesteammatchmaking", useSteamMatchmaking), + new XAttribute("quickstartsub", QuickStartSubmarineName), + new XAttribute("requiresteamauthentication", requireSteamAuthentication), + new XAttribute("aimassistamount", aimAssistAmount)); + + if (!ShowUserStatisticsPrompt) + { + doc.Root.Add(new XAttribute("senduserstatistics", sendUserStatistics)); + } + + if (WasGameUpdated) + { + doc.Root.Add(new XAttribute("wasgameupdated", true)); + } useSteamMatchmaking = doc.Root.GetAttributeBool("usesteammatchmaking", useSteamMatchmaking); requireSteamAuthentication = doc.Root.GetAttributeBool("requiresteamauthentication", requireSteamAuthentication); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs index 0b70d6e8a..b24f8bf79 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs @@ -168,11 +168,7 @@ namespace Barotrauma.Items.Components } else { - FixBody(user, deltaTime, degreeOfSuccess, - Submarine.PickBody(rayStart, rayEnd, - ignoredBodies, collisionCategories, ignoreSensors: false, - customPredicate: (Fixture f) => { return f?.Body?.UserData != null; }, - allowInsideFixture: true)); + FixBody(user, deltaTime, degreeOfSuccess, Submarine.PickBody(rayStart, rayEnd, ignoredBodies, collisionCategories, ignoreSensors: false, allowInsideFixture: true)); } if (ExtinguishAmount > 0.0f && item.CurrentHull != null) diff --git a/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs b/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs index 68b5ca6df..695b56df0 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs @@ -609,7 +609,8 @@ namespace Barotrauma foreach (InterestingPosition pos in positionsOfInterest) { if (pos.PositionType != PositionType.MainPath || pos.Position.X < 5000 || pos.Position.X > Size.X - 5000) continue; - if (Math.Abs(pos.Position.X - StartPosition.X) < minWidth * 2 || Math.Abs(pos.Position.X - EndPosition.X) < minWidth * 2) continue; + if (Math.Abs(pos.Position.X - StartPosition.X) < 10000) continue; + if (Math.Abs(pos.Position.Y - StartPosition.Y) < 10000) continue; if (GetTooCloseCells(pos.Position.ToVector2(), minWidth * 0.7f).Count > 0) continue; iceChunkPositions.Add(pos.Position); }