From 3c147c16538cb4ccc3ecfdf513f638e291a1a7c7 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 16 Apr 2019 17:13:01 +0300 Subject: [PATCH] (cb10c219e) Allow to set the vitality for a character without afflicting damage. Make a bunch of properties of Attack class publicly accessible. --- .../Source/Screens/ServerListScreen.cs | 77 ++++--------------- .../Source/Characters/Attack.cs | 12 +-- .../Characters/Health/CharacterHealth.cs | 6 ++ .../BarotraumaShared/Source/Map/Hull.cs | 19 +++++ 4 files changed, 44 insertions(+), 70 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs index df3078f5f..0dad0848e 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs @@ -95,6 +95,19 @@ namespace Barotrauma 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")); + 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; }; + filterFull = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.27f), tickBoxHolder.RectTransform), TextManager.Get("FilterFullServers")); filterFull.OnSelected += (tickBox) => { FilterServers(); return true; }; filterEmpty = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.27f), tickBoxHolder.RectTransform), TextManager.Get("FilterEmptyServers")); @@ -152,58 +165,6 @@ 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; @@ -246,18 +207,6 @@ namespace Barotrauma UserData = "noresults" }; } - - 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; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs b/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs index 0e84aa580..8e0c79593 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs @@ -80,13 +80,13 @@ namespace Barotrauma public HitDetection HitDetectionType { get; private set; } [Serialize(AIBehaviorAfterAttack.FallBack, true), Editable(ToolTip = "The preferred AI behavior after the attack.")] - public AIBehaviorAfterAttack AfterAttack { get; private set; } + public AIBehaviorAfterAttack AfterAttack { get; 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; } + public float Range { get; set; } [Serialize(0.0f, true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 2000.0f, ToolTip = "Min distance from the attack limb to the target to do damage. In distance based hit detection, the hit will be registered as soon as the target is within the damage range, unless the attack duration has expired.")] public float DamageRange { get; set; } @@ -95,19 +95,19 @@ namespace Barotrauma public float Duration { get; private set; } [Serialize(5f, true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 100.0f, DecimalCount = 2, ToolTip = "How long the AI waits between the attacks.")] - public float CoolDown { get; private set; } = 5; + public float CoolDown { get; set; } = 5; [Serialize(0f, true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 100.0f, DecimalCount = 2, ToolTip = "Used as the attack cooldown between different kind of attacks. Does not have effect, if set to 0.")] - public float SecondaryCoolDown { get; private set; } = 0; + public float SecondaryCoolDown { get; set; } = 0; [Serialize(0f, true), Editable(MinValueFloat = 0, MaxValueFloat = 1, DecimalCount = 2, ToolTip = "Random factor applied to all cooldowns. Example: 0.1 -> adds a random value between -10% and 10% of the cooldown. Min 0 (default), Max 1 (could disable or double the cooldown in extreme cases).")] public float CoolDownRandomFactor { get; private set; } = 0; [Serialize(0.0f, true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 10000.0f)] - public float StructureDamage { get; private set; } + public float StructureDamage { get; set; } [Serialize(0.0f, true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 1000.0f)] - public float ItemDamage { get; private set; } + public float ItemDamage { get; set; } /// /// Legacy support. Use Afflictions. diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs index c492667e0..8a2aa9ca9 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs @@ -612,6 +612,12 @@ namespace Barotrauma partial void UpdateBleedingProjSpecific(AfflictionBleeding affliction, Limb targetLimb, float deltaTime); + public void SetVitality(float newVitality) + { + maxVitality = newVitality; + CalculateVitality(); + } + public void CalculateVitality() { Vitality = MaxVitality; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs index 25ebe915b..b4490cfe6 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs @@ -147,6 +147,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