From 0c42ad1572122b7bb6dc7a516478cd91e97cd7e1 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 16 Apr 2019 17:12:43 +0300 Subject: [PATCH] (22ec3a281) Add a boolean that controls whether or not the enemy attacks outposts and the characters inside it. --- .../Source/Screens/ServerListScreen.cs | 93 ++++++++++++++----- .../Source/Characters/AI/EnemyAIController.cs | 13 ++- .../BarotraumaShared/Source/Map/Hull.cs | 19 ++++ 3 files changed, 96 insertions(+), 29 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs index 7d8076f56..df3078f5f 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs @@ -82,31 +82,6 @@ namespace Barotrauma }; clientNameBox.OnTextChanged += RefreshJoinButtonState; - new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), infoHolder.RectTransform), TextManager.Get("ServerIP")); - ipBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.13f), infoHolder.RectTransform), ""); - ipBox.OnTextChanged += RefreshJoinButtonState; - ipBox.OnSelected += (sender, key) => - { - if (sender.UserData is ServerInfo) - { - sender.Text = ""; - sender.UserData = null; - } - }; - - var filterHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), leftColumn.RectTransform)) { RelativeSpacing = 0.05f }; - - new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), filterHolder.RectTransform), TextManager.Get("FilterServers")); - searchBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.13f), filterHolder.RectTransform), ""); - - var tickBoxHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), filterHolder.RectTransform)); - - searchBox.OnTextChanged += (txtBox, txt) => { FilterServers(); return true; }; - filterPassword = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.27f), tickBoxHolder.RectTransform), TextManager.Get("FilterPassword")); - filterPassword.OnSelected += (tickBox) => { FilterServers(); return true; }; - filterIncompatible = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.27f), tickBoxHolder.RectTransform), TextManager.Get("FilterIncompatibleServers")); - filterIncompatible.OnSelected += (tickBox) => { FilterServers(); return true; }; - var filterHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), leftColumn.RectTransform)) { RelativeSpacing = 0.05f }; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), filterHolder.RectTransform), TextManager.Get("FilterServers")); @@ -177,6 +152,58 @@ namespace Barotrauma Enabled = false }; + //------------------------------------------------------------------------------------- + //right column + //------------------------------------------------------------------------------------- + + var rightColumn = new GUILayoutGroup(new RectTransform(new Vector2(1.0f - leftColumn.RectTransform.RelativeSize.X - 0.017f, 1.0f), + paddedFrame.RectTransform, Anchor.CenterRight)) + { + RelativeSpacing = 0.02f, + Stretch = true + }; + + var serverListHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), rightColumn.RectTransform)) { Stretch = true, RelativeSpacing = 0.02f }; + + serverList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), serverListHolder.RectTransform, Anchor.Center)) + { + OnSelected = (btn, obj) => { + ServerInfo serverInfo = (ServerInfo)obj; + + serverInfo.CreatePreviewWindow(serverPreview); + + return true; + } + }; + + serverList.OnSelected += SelectServer; + + serverPreview = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), serverListHolder.RectTransform, Anchor.Center)); + + columnRelativeWidth = new float[] { 0.04f, 0.02f, 0.044f, 0.77f, 0.02f, 0.075f, 0.06f }; + + var buttonContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.075f), rightColumn.RectTransform), style: null); + + GUIButton button = new GUIButton(new RectTransform(new Vector2(0.25f, 0.9f), buttonContainer.RectTransform, Anchor.TopLeft), + TextManager.Get("Back"), style: "GUIButtonLarge") + { + OnClicked = GameMain.MainMenuScreen.ReturnToMainMenu + }; + + var refreshButton = new GUIButton(new RectTransform(new Vector2(buttonContainer.Rect.Height / (float)buttonContainer.Rect.Width, 0.9f), buttonContainer.RectTransform, Anchor.Center), + "", style: "GUIButtonRefresh") { + + ToolTip = TextManager.Get("ServerListRefresh"), + OnClicked = RefreshServers + }; + + joinButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.9f), buttonContainer.RectTransform, Anchor.TopRight), + TextManager.Get("ServerListJoin"), style: "GUIButtonLarge") + { + OnClicked = JoinServer, + Enabled = false + }; + //-------------------------------------------------------- button.SelectedColor = button.Color; @@ -239,6 +266,22 @@ namespace Barotrauma return true; } + private bool RefreshJoinButtonState(GUIComponent component, object obj) + { + if (obj == null || waitingForRefresh) return false; + + if (!string.IsNullOrWhiteSpace(clientNameBox.Text) && !string.IsNullOrWhiteSpace(ipBox.Text)) + { + joinButton.Enabled = true; + } + else + { + joinButton.Enabled = false; + } + + return true; + } + private bool SelectServer(GUIComponent component, object obj) { if (obj == null || waitingForRefresh) return false; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs index 965a0d4d8..dca3baa58 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs @@ -14,6 +14,11 @@ namespace Barotrauma { public static bool DisableEnemyAI; + /// + /// Enable the character to attack the outposts and the characters inside them. Disabled by default. + /// + public bool TargetOutposts; + class WallTarget { public Vector2 Position; @@ -1067,11 +1072,11 @@ namespace Barotrauma continue; } if (target.Type == AITarget.TargetType.HumanOnly) { continue; } - // Don't attack outposts. - if (target.Entity.Submarine != null && target.Entity.Submarine.IsOutpost) { continue; } - + if (!TargetOutposts) + { + if (target.Entity.Submarine != null && target.Entity.Submarine.IsOutpost) { continue; } + } Character targetCharacter = target.Entity as Character; - //ignore the aitarget if it is the Character itself if (targetCharacter == character) continue; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs index 03220257b..25ebe915b 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs @@ -128,6 +128,25 @@ namespace Barotrauma } } + public string DisplayName + { + get; + private set; + } + + private string roomName; + [Editable, Serialize("", true, translationTextTag: "RoomName.")] + public string RoomName + { + get { return roomName; } + set + { + if (roomName == value) { return; } + roomName = value; + DisplayName = TextManager.Get(roomName, returnNull: true) ?? roomName; + } + } + public override Rectangle Rect { get