From c02da46ef5b346110f95b6e5adc1ea5f2c62f7c6 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sun, 16 Jun 2019 18:07:18 +0300 Subject: [PATCH] (79cd545fb) Switched send out a continuous 0/1 signal that can be flipped by interacting with the switch (as opposed to working like buttons which send out a pulse when interacted with). Closes #1657 --- .../Source/Networking/GameClient.cs | 9 ------ .../Items/Components/Machines/Controller.cs | 31 ++++++++++++++++--- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index 527c58aa2..de39d215b 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -1900,15 +1900,6 @@ namespace Barotrauma.Networking chatBox.AddMessage(message); } - public override void AddChatMessage(ChatMessage message) - { - base.AddChatMessage(message); - - if (string.IsNullOrEmpty(message.Text)) { return; } - GameMain.NetLobbyScreen.NewChatMessage(message); - chatBox.AddMessage(message); - } - public override void KickPlayer(string kickedName, string reason) { NetOutgoingMessage msg = client.CreateMessage(); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs index ba73f2cf5..9c2a10c9e 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs @@ -37,6 +37,8 @@ namespace Barotrauma.Items.Components private Item focusTarget; private float targetRotation; + private bool state; + public Vector2 UserPos { get { return userPos; } @@ -48,6 +50,13 @@ namespace Barotrauma.Items.Components get { return user; } } + [Serialize(false, false), Editable(ToolTip = "When enabled, the item will continuously send out a 0/1 signal and interacting with it will flip the signal (making the item behave like a switch). When disabled, the item will simply send out 1 when interacted with.")] + public bool IsToggle + { + get; + set; + } + public Controller(Item item, XElement element) : base(item, element) { @@ -55,7 +64,7 @@ namespace Barotrauma.Items.Components userPos = element.GetAttributeVector2("UserPos", Vector2.Zero); - Enum.TryParse(element.GetAttributeString("direction", "None"), out dir); + Enum.TryParse(element.GetAttributeString("direction", "None"), out dir); foreach (XElement el in element.Elements()) { @@ -83,7 +92,12 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { this.cam = cam; - + + if (IsToggle) + { + item.SendSignal(0, state ? "1" : "0", "signal_out", sender: null); + } + if (user == null || user.Removed || user.SelectedConstruction != item @@ -94,7 +108,7 @@ namespace Barotrauma.Items.Components CancelUsing(user); user = null; } - IsActive = false; + if (!IsToggle) { IsActive = false; } return; } @@ -169,7 +183,7 @@ namespace Barotrauma.Items.Components } item.SendSignal(0, "1", "trigger_out", user); - + ApplyStatusEffects(ActionType.OnUse, 1.0f, activator); return true; @@ -254,7 +268,14 @@ namespace Barotrauma.Items.Components public override bool Pick(Character picker) { - item.SendSignal(0, "1", "signal_out", picker); + if (IsToggle) + { + state = !state; + } + else + { + item.SendSignal(0, "1", "signal_out", picker); + } #if CLIENT PlaySound(ActionType.OnUse, item.WorldPosition, picker);