diff --git a/Subsurface/Source/Items/Components/DockingPort.cs b/Subsurface/Source/Items/Components/DockingPort.cs index 27d634857..bdfbb8441 100644 --- a/Subsurface/Source/Items/Components/DockingPort.cs +++ b/Subsurface/Source/Items/Components/DockingPort.cs @@ -586,9 +586,8 @@ namespace Barotrauma.Items.Components dockingState = MathHelper.Lerp(dockingState, 0.0f, deltaTime * 10.0f); if (dockingState < 0.01f) docked = false; - item.SendSignal(0, "0", "state_out"); - - item.SendSignal(0, (FindAdjacentPort() != null) ? "1" : "0", "proximity_sensor"); + item.SendSignal(0, "0", "state_out", null); + item.SendSignal(0, (FindAdjacentPort() != null) ? "1" : "0", "proximity_sensor", null); } else @@ -601,7 +600,7 @@ namespace Barotrauma.Items.Components if (joint is DistanceJoint) { - item.SendSignal(0, "0", "state_out"); + item.SendSignal(0, "0", "state_out", null); dockingState = MathHelper.Lerp(dockingState, 0.5f, deltaTime * 10.0f); if (Vector2.Distance(joint.WorldAnchorA, joint.WorldAnchorB) < 0.05f) @@ -616,7 +615,7 @@ namespace Barotrauma.Items.Components doorBody.Enabled = dockingTarget.door.Body.Enabled; } - item.SendSignal(0, "1", "state_out"); + item.SendSignal(0, "1", "state_out", null); dockingState = MathHelper.Lerp(dockingState, 1.0f, deltaTime * 10.0f); } @@ -730,10 +729,13 @@ namespace Barotrauma.Items.Components } } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power = 0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power = 0.0f) { if (GameMain.Client != null) return; + bool wasDocked = docked; + DockingPort prevDockingTarget = dockingTarget; + switch (connection.Name) { case "toggle": @@ -744,6 +746,20 @@ namespace Barotrauma.Items.Components Docked = signal != "0"; break; } + + if (sender != null && docked != wasDocked) + { + if (docked) + { + if (item.Submarine != null && dockingTarget?.item?.Submarine != null) + GameServer.Log(sender.Name + " docked "+item.Submarine.Name+" to "+dockingTarget.item.Submarine, Color.White); + } + else + { + if (item.Submarine != null && prevDockingTarget?.item?.Submarine != null) + GameServer.Log(sender.Name + " undocked " + item.Submarine.Name + " from " + prevDockingTarget.item.Submarine, Color.White); + } + } } public void ServerWrite(Lidgren.Network.NetBuffer msg, Barotrauma.Networking.Client c, object[] extraData = null) diff --git a/Subsurface/Source/Items/Components/Door.cs b/Subsurface/Source/Items/Components/Door.cs index 30fc0135a..debb8aaed 100644 --- a/Subsurface/Source/Items/Components/Door.cs +++ b/Subsurface/Source/Items/Components/Door.cs @@ -323,7 +323,7 @@ namespace Barotrauma.Items.Components //don't use the predicted state here, because it might set //other items to an incorrect state if the prediction is wrong - item.SendSignal(0, (isOpen) ? "1" : "0", "state_out"); + item.SendSignal(0, (isOpen) ? "1" : "0", "state_out", null); } public override void UpdateBroken(float deltaTime, Camera cam) @@ -484,10 +484,12 @@ namespace Barotrauma.Items.Components } } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power = 0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power = 0.0f) { if (isStuck) return; + bool wasOpen = isOpen; + if (connection.Name == "toggle") { SetState(!isOpen, false, true); @@ -496,6 +498,11 @@ namespace Barotrauma.Items.Components { SetState(signal != "0", false, true); } + + if (sender != null && wasOpen != isOpen) + { + GameServer.Log(sender.Name + (isOpen ? " opened " : " closed ") + item.Name, Color.White); + } } public void SetState(bool open, bool isNetworkMessage, bool sendNetworkMessage = false) diff --git a/Subsurface/Source/Items/Components/ItemComponent.cs b/Subsurface/Source/Items/Components/ItemComponent.cs index 411279321..502832d43 100644 --- a/Subsurface/Source/Items/Components/ItemComponent.cs +++ b/Subsurface/Source/Items/Components/ItemComponent.cs @@ -499,7 +499,7 @@ namespace Barotrauma.Items.Components //called then the item is dropped or dragged out of a "limbslot" public virtual void Unequip(Character character) { } - public virtual void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power = 0.0f) + public virtual void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power = 0.0f) { switch (connection.Name) diff --git a/Subsurface/Source/Items/Components/Machines/Controller.cs b/Subsurface/Source/Items/Components/Machines/Controller.cs index a7a1e6384..63df851a2 100644 --- a/Subsurface/Source/Items/Components/Machines/Controller.cs +++ b/Subsurface/Source/Items/Components/Machines/Controller.cs @@ -158,8 +158,8 @@ namespace Barotrauma.Items.Components return false; } - item.SendSignal(0, "1", "trigger_out"); - + item.SendSignal(0, "1", "trigger_out", character); + ApplyStatusEffects(ActionType.OnUse, 1.0f, activator); return true; @@ -194,7 +194,7 @@ namespace Barotrauma.Items.Components if (focusTarget == null) { - item.SendSignal(0, ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out"); + item.SendSignal(0, ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out", character); return; } @@ -209,13 +209,13 @@ namespace Barotrauma.Items.Components if (!character.IsRemotePlayer || character.ViewTarget == focusTarget) { - item.SendSignal(0, ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out"); + item.SendSignal(0, ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out", character); } } public override bool Pick(Character picker) { - item.SendSignal(0, "1", "signal_out"); + item.SendSignal(0, "1", "signal_out", picker); PlaySound(ActionType.OnUse, item.WorldPosition); @@ -261,7 +261,7 @@ namespace Barotrauma.Items.Components IsActive = true; } - item.SendSignal(0, "1", "signal_out"); + item.SendSignal(0, "1", "signal_out", character); return true; } diff --git a/Subsurface/Source/Items/Components/Machines/Engine.cs b/Subsurface/Source/Items/Components/Machines/Engine.cs index 501f2673e..bb91914fb 100644 --- a/Subsurface/Source/Items/Components/Machines/Engine.cs +++ b/Subsurface/Source/Items/Components/Machines/Engine.cs @@ -131,9 +131,9 @@ namespace Barotrauma.Items.Components force = MathHelper.Lerp(force, 0.0f, 0.1f); } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f) { - base.ReceiveSignal(stepsTaken, signal, connection, sender, power); + base.ReceiveSignal(stepsTaken, signal, connection, source, sender, power); if (connection.Name == "set_force") { diff --git a/Subsurface/Source/Items/Components/Machines/MiniMap.cs b/Subsurface/Source/Items/Components/Machines/MiniMap.cs index c98f1e07d..4e504ba58 100644 --- a/Subsurface/Source/Items/Components/Machines/MiniMap.cs +++ b/Subsurface/Source/Items/Components/Machines/MiniMap.cs @@ -194,9 +194,9 @@ namespace Barotrauma.Items.Components } } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power = 0) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power = 0) { - base.ReceiveSignal(stepsTaken, signal, connection, sender, power); + base.ReceiveSignal(stepsTaken, signal, connection, source, sender, power); if (sender == null || sender.CurrentHull == null) return; @@ -213,7 +213,7 @@ namespace Barotrauma.Items.Components { case "water_data_in": //cheating a bit because water detectors don't actually send the water level - if (sender.GetComponent() == null) + if (source.GetComponent() == null) { hullData.Water = Rand.Range(0.0f, 1.0f); } diff --git a/Subsurface/Source/Items/Components/Machines/Pump.cs b/Subsurface/Source/Items/Components/Machines/Pump.cs index 2d061d5f4..bf33443b1 100644 --- a/Subsurface/Source/Items/Components/Machines/Pump.cs +++ b/Subsurface/Source/Items/Components/Machines/Pump.cs @@ -198,9 +198,9 @@ namespace Barotrauma.Items.Components GuiFrame.Update(1.0f / 60.0f); } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f) { - base.ReceiveSignal(stepsTaken, signal, connection, sender, power); + base.ReceiveSignal(stepsTaken, signal, connection, source, sender, power); if (connection.Name == "toggle") { diff --git a/Subsurface/Source/Items/Components/Machines/Reactor.cs b/Subsurface/Source/Items/Components/Machines/Reactor.cs index 8d4e62d7d..93d70805f 100644 --- a/Subsurface/Source/Items/Components/Machines/Reactor.cs +++ b/Subsurface/Source/Items/Components/Machines/Reactor.cs @@ -308,7 +308,7 @@ namespace Barotrauma.Items.Components ExtraCooling = 0.0f; AvailableFuel = 0.0f; - item.SendSignal(0, ((int)temperature).ToString(), "temperature_out"); + item.SendSignal(0, ((int)temperature).ToString(), "temperature_out", null); sendUpdateTimer = Math.Max(sendUpdateTimer - deltaTime, 0.0f); @@ -532,7 +532,7 @@ namespace Barotrauma.Items.Components GUI.DrawLine(spriteBatch, prevPoint, lastPoint, color); } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power) { switch (connection.Name) { diff --git a/Subsurface/Source/Items/Components/Machines/Steering.cs b/Subsurface/Source/Items/Components/Machines/Steering.cs index 53be9de36..7e584935a 100644 --- a/Subsurface/Source/Items/Components/Machines/Steering.cs +++ b/Subsurface/Source/Items/Components/Machines/Steering.cs @@ -165,13 +165,13 @@ namespace Barotrauma.Items.Components UpdateAutoPilot(deltaTime); } - item.SendSignal(0, targetVelocity.X.ToString(CultureInfo.InvariantCulture), "velocity_x_out"); + item.SendSignal(0, targetVelocity.X.ToString(CultureInfo.InvariantCulture), "velocity_x_out", null); float targetLevel = -targetVelocity.Y; targetLevel += (neutralBallastLevel - 0.5f) * 100.0f; - item.SendSignal(0, targetLevel.ToString(CultureInfo.InvariantCulture), "velocity_y_out"); + item.SendSignal(0, targetLevel.ToString(CultureInfo.InvariantCulture), "velocity_y_out", null); voltage -= deltaTime; @@ -476,7 +476,7 @@ namespace Barotrauma.Items.Components return true; } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f) { if (connection.Name == "velocity_in") { @@ -484,7 +484,7 @@ namespace Barotrauma.Items.Components } else { - base.ReceiveSignal(stepsTaken, signal, connection, sender, power); + base.ReceiveSignal(stepsTaken, signal, connection, source, sender, power); } } diff --git a/Subsurface/Source/Items/Components/Power/PowerContainer.cs b/Subsurface/Source/Items/Components/Power/PowerContainer.cs index 960f3eb7a..4c7c848f0 100644 --- a/Subsurface/Source/Items/Components/Power/PowerContainer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerContainer.cs @@ -224,7 +224,7 @@ namespace Barotrauma.Items.Components return true; } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power) { if (!connection.IsPower) return; @@ -236,8 +236,6 @@ namespace Barotrauma.Items.Components { outputVoltage = power; } - //if (currPowerConsumption == 0.0f) voltage = 0.0f; - //if (connection.IsPower) voltage = power; } public void Draw(SpriteBatch spriteBatch, bool editing = false) diff --git a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs index 2542019bc..ba246c616 100644 --- a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs @@ -67,8 +67,8 @@ namespace Barotrauma.Items.Components pt.powerLoad += (fullLoad - pt.powerLoad) / inertia; pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia; - pt.Item.SendSignal(0, "", "power", fullPower / Math.Max(fullLoad, 1.0f)); - pt.Item.SendSignal(0, "", "power_out", fullPower / Math.Max(fullLoad, 1.0f)); + pt.Item.SendSignal(0, "", "power", null, fullPower / Math.Max(fullLoad, 1.0f)); + pt.Item.SendSignal(0, "", "power_out", null, fullPower / Math.Max(fullLoad, 1.0f)); //damage the item if voltage is too high //(except if running as a client) @@ -206,13 +206,13 @@ namespace Barotrauma.Items.Components if (powerConnections.Count == 0) IsActive = false; } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power) { - base.ReceiveSignal(stepsTaken, signal, connection, sender, power); + base.ReceiveSignal(stepsTaken, signal, connection, source, sender, power); if (connection.Name.Length > 5 && connection.Name.Substring(0, 6).ToLowerInvariant() == "signal") { - connection.SendSignal(stepsTaken, signal, sender, 0.0f); + connection.SendSignal(stepsTaken, signal, source, sender, 0.0f); } } diff --git a/Subsurface/Source/Items/Components/Power/Powered.cs b/Subsurface/Source/Items/Components/Power/Powered.cs index 3e064315c..3f5f8aeba 100644 --- a/Subsurface/Source/Items/Components/Power/Powered.cs +++ b/Subsurface/Source/Items/Components/Power/Powered.cs @@ -83,7 +83,7 @@ namespace Barotrauma.Items.Components } } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power = 0) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power = 0) { if (currPowerConsumption == 0.0f) voltage = 0.0f; if (connection.IsPower) voltage = power; diff --git a/Subsurface/Source/Items/Components/Signal/AndComponent.cs b/Subsurface/Source/Items/Components/Signal/AndComponent.cs index bbed05bfa..83aaffc9c 100644 --- a/Subsurface/Source/Items/Components/Signal/AndComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/AndComponent.cs @@ -57,10 +57,10 @@ namespace Barotrauma.Items.Components string signalOut = sendOutput ? output : falseOutput; if (string.IsNullOrEmpty(signalOut)) return; - item.SendSignal(0, signalOut, "signal_out"); + item.SendSignal(0, signalOut, "signal_out", null); } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f) { switch (connection.Name) { diff --git a/Subsurface/Source/Items/Components/Signal/Connection.cs b/Subsurface/Source/Items/Components/Signal/Connection.cs index 80e6e6c02..ef968c749 100644 --- a/Subsurface/Source/Items/Components/Signal/Connection.cs +++ b/Subsurface/Source/Items/Components/Signal/Connection.cs @@ -155,7 +155,7 @@ namespace Barotrauma.Items.Components Wires[index] = wire; } - public void SendSignal(int stepsTaken, string signal, Item sender, float power) + public void SendSignal(int stepsTaken, string signal, Item source, Character sender, float power) { for (int i = 0; i < MaxLinked; i++) { @@ -163,11 +163,11 @@ namespace Barotrauma.Items.Components Connection recipient = Wires[i].OtherConnection(this); if (recipient == null) continue; - if (recipient.item == this.item || recipient.item == sender) continue; + if (recipient.item == this.item || recipient.item == source) continue; foreach (ItemComponent ic in recipient.item.components) { - ic.ReceiveSignal(stepsTaken, signal, recipient, this.item, power); + ic.ReceiveSignal(stepsTaken, signal, recipient, item, sender, power); } foreach (StatusEffect effect in recipient.effects) diff --git a/Subsurface/Source/Items/Components/Signal/DelayComponent.cs b/Subsurface/Source/Items/Components/Signal/DelayComponent.cs index 281555f2f..64b152583 100644 --- a/Subsurface/Source/Items/Components/Signal/DelayComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/DelayComponent.cs @@ -42,11 +42,11 @@ namespace Barotrauma.Items.Components { var signalOut = signalQueue.Dequeue(); - item.SendSignal(0, signalOut.Item1, "signal_out"); + item.SendSignal(0, signalOut.Item1, "signal_out", null); } } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f) { switch (connection.Name) { diff --git a/Subsurface/Source/Items/Components/Signal/LightComponent.cs b/Subsurface/Source/Items/Components/Signal/LightComponent.cs index 7bfa10d7e..72a50d086 100644 --- a/Subsurface/Source/Items/Components/Signal/LightComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/LightComponent.cs @@ -193,9 +193,9 @@ namespace Barotrauma.Items.Components light.Remove(); } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f) { - base.ReceiveSignal(stepsTaken, signal, connection, sender, power); + base.ReceiveSignal(stepsTaken, signal, connection, source, sender, power); switch (connection.Name) { diff --git a/Subsurface/Source/Items/Components/Signal/MotionSensor.cs b/Subsurface/Source/Items/Components/Signal/MotionSensor.cs index 982302616..ebed3e0a0 100644 --- a/Subsurface/Source/Items/Components/Signal/MotionSensor.cs +++ b/Subsurface/Source/Items/Components/Signal/MotionSensor.cs @@ -54,15 +54,15 @@ namespace Barotrauma.Items.Components { if (motionDetected) { - item.SendSignal(1, output, "state_out"); + item.SendSignal(1, output, "state_out", null); } else if (!string.IsNullOrWhiteSpace(falseOutput)) { - item.SendSignal(1, falseOutput, "state_out"); + item.SendSignal(1, falseOutput, "state_out", null); } updateTimer -= deltaTime; - if (updateTimer>0.0f) return; + if (updateTimer > 0.0f) return; motionDetected = false; updateTimer = UpdateInterval; diff --git a/Subsurface/Source/Items/Components/Signal/NotComponent.cs b/Subsurface/Source/Items/Components/Signal/NotComponent.cs index 123242d72..289f36870 100644 --- a/Subsurface/Source/Items/Components/Signal/NotComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/NotComponent.cs @@ -9,11 +9,11 @@ namespace Barotrauma.Items.Components { } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f) { if (connection.Name != "signal_in") return; - item.SendSignal(stepsTaken, signal=="0" ? "1" : "0", "signal_out"); + item.SendSignal(stepsTaken, signal=="0" ? "1" : "0", "signal_out", sender); } } } diff --git a/Subsurface/Source/Items/Components/Signal/OrComponent.cs b/Subsurface/Source/Items/Components/Signal/OrComponent.cs index 49b7c7e1c..159fb979e 100644 --- a/Subsurface/Source/Items/Components/Signal/OrComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/OrComponent.cs @@ -21,7 +21,7 @@ namespace Barotrauma.Items.Components string signalOut = sendOutput ? output : falseOutput; if (string.IsNullOrEmpty(signalOut)) return; - item.SendSignal(0, signalOut, "signal_out"); + item.SendSignal(0, signalOut, "signal_out", null); } } } diff --git a/Subsurface/Source/Items/Components/Signal/OxygenDetector.cs b/Subsurface/Source/Items/Components/Signal/OxygenDetector.cs index 559e56124..431b23f72 100644 --- a/Subsurface/Source/Items/Components/Signal/OxygenDetector.cs +++ b/Subsurface/Source/Items/Components/Signal/OxygenDetector.cs @@ -14,8 +14,7 @@ namespace Barotrauma.Items.Components { if (item.CurrentHull == null) return; - item.SendSignal(0, ((int)item.CurrentHull.OxygenPercentage).ToString(), "signal_out"); - + item.SendSignal(0, ((int)item.CurrentHull.OxygenPercentage).ToString(), "signal_out", null); } } diff --git a/Subsurface/Source/Items/Components/Signal/RegExFindComponent.cs b/Subsurface/Source/Items/Components/Signal/RegExFindComponent.cs index 401fa850b..f16ae7f5e 100644 --- a/Subsurface/Source/Items/Components/Signal/RegExFindComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/RegExFindComponent.cs @@ -40,7 +40,7 @@ namespace Barotrauma.Items.Components catch { - item.SendSignal(0, "ERROR", "signal_out"); + item.SendSignal(0, "ERROR", "signal_out", null); return; } } @@ -67,17 +67,17 @@ namespace Barotrauma.Items.Components } catch { - item.SendSignal(0, "ERROR", "signal_out"); + item.SendSignal(0, "ERROR", "signal_out", null); previousResult = false; return; } } - item.SendSignal(0, previousResult ? output : "0", "signal_out"); + item.SendSignal(0, previousResult ? output : "0", "signal_out", null); } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power = 0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power = 0.0f) { switch (connection.Name) { diff --git a/Subsurface/Source/Items/Components/Signal/RelayComponent.cs b/Subsurface/Source/Items/Components/Signal/RelayComponent.cs index a019d980f..7af937a68 100644 --- a/Subsurface/Source/Items/Components/Signal/RelayComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/RelayComponent.cs @@ -49,10 +49,10 @@ namespace Barotrauma.Items.Components { base.Update(deltaTime, cam); - item.SendSignal(0, IsOn ? "1" : "0", "state_out"); + item.SendSignal(0, IsOn ? "1" : "0", "state_out", null); } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f) { if (connection.IsPower && connection.Name.Contains("_out")) return; @@ -71,7 +71,7 @@ namespace Barotrauma.Items.Components if (connectionNumber > 0) outConnection += connectionNumber; - item.SendSignal(stepsTaken, signal, outConnection, power); + item.SendSignal(stepsTaken, signal, outConnection, sender, power); } else if (connection.Name == "toggle") { diff --git a/Subsurface/Source/Items/Components/Signal/SignalCheckComponent.cs b/Subsurface/Source/Items/Components/Signal/SignalCheckComponent.cs index 82b7fa423..8214b6279 100644 --- a/Subsurface/Source/Items/Components/Signal/SignalCheckComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/SignalCheckComponent.cs @@ -33,7 +33,7 @@ namespace Barotrauma.Items.Components { } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f) { switch (connection.Name) { @@ -41,7 +41,7 @@ namespace Barotrauma.Items.Components string signalOut = (signal == targetSignal) ? output : falseOutput; if (string.IsNullOrWhiteSpace(signalOut)) return; - item.SendSignal(stepsTaken, signalOut, "signal_out"); + item.SendSignal(stepsTaken, signalOut, "signal_out", sender); break; case "set_output": diff --git a/Subsurface/Source/Items/Components/Signal/WaterDetector.cs b/Subsurface/Source/Items/Components/Signal/WaterDetector.cs index 43487d317..b305b6bd8 100644 --- a/Subsurface/Source/Items/Components/Signal/WaterDetector.cs +++ b/Subsurface/Source/Items/Components/Signal/WaterDetector.cs @@ -12,7 +12,7 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { - item.SendSignal(0, item.InWater ? "1" : "0", "signal_out"); + item.SendSignal(0, item.InWater ? "1" : "0", "signal_out", null); } } } diff --git a/Subsurface/Source/Items/Components/Signal/WifiComponent.cs b/Subsurface/Source/Items/Components/Signal/WifiComponent.cs index 595d8d24a..d3a3762e3 100644 --- a/Subsurface/Source/Items/Components/Signal/WifiComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/WifiComponent.cs @@ -50,7 +50,7 @@ namespace Barotrauma.Items.Components return HasRequiredContainedItems(true); } - public void Transmit(string signal) + /*public void Transmit(string signal) { if (!CanTransmit()) return; @@ -59,9 +59,9 @@ namespace Barotrauma.Items.Components { var connections = w.item.Connections; - w.ReceiveSignal(1, signal, connections == null ? null : connections.Find(c => c.Name == "signal_in"), item); + w.ReceiveSignal(1, signal, connections == null ? null : connections.Find(c => c.Name == "signal_in"), item, null); } - } + }*/ private List GetReceiversInRange() { @@ -77,9 +77,9 @@ namespace Barotrauma.Items.Components return Vector2.Distance(item.WorldPosition, sender.item.WorldPosition) <= sender.Range; } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f) { - var senderComponent = sender.GetComponent(); + var senderComponent = source.GetComponent(); if (senderComponent != null && !CanReceive(senderComponent)) return; if (LinkToChat) @@ -107,7 +107,7 @@ namespace Barotrauma.Items.Components foreach (WifiComponent wifiComp in receivers) { - wifiComp.item.SendSignal(stepsTaken, signal, "signal_out"); + wifiComp.item.SendSignal(stepsTaken, signal, "signal_out", sender); } break; } diff --git a/Subsurface/Source/Items/Components/Turret.cs b/Subsurface/Source/Items/Components/Turret.cs index 6d5547a72..1ea35063c 100644 --- a/Subsurface/Source/Items/Components/Turret.cs +++ b/Subsurface/Source/Items/Components/Turret.cs @@ -192,6 +192,11 @@ namespace Barotrauma.Items.Components Launch(projectiles[0].Item); + if (character != null) + { + GameServer.Log(character.Name + " launched " + item.Name, Color.Orange); + } + return true; } @@ -364,7 +369,7 @@ namespace Barotrauma.Items.Components } } - public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power) + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power) { switch (connection.Name) { @@ -382,7 +387,7 @@ namespace Barotrauma.Items.Components break; case "trigger_in": - item.Use((float)Timing.Step, null); + item.Use((float)Timing.Step, sender); break; } } diff --git a/Subsurface/Source/Items/Inventory.cs b/Subsurface/Source/Items/Inventory.cs index f567086cc..ada0a842e 100644 --- a/Subsurface/Source/Items/Inventory.cs +++ b/Subsurface/Source/Items/Inventory.cs @@ -583,20 +583,34 @@ namespace Barotrauma GameMain.Server.CreateEntityEvent(Owner as IServerSerializable, new object[] { NetEntityEvent.Type.InventoryState }); - foreach (Item item in Items) + foreach (Item item in Items.Distinct()) { if (item == null) continue; if (!prevItems.Contains(item)) { - GameServer.Log(c.Character + " placed " + item.Name + " in " + Owner, Color.Orange); + if (Owner == c.Character) + { + GameServer.Log(c.Character + " picked up " + item.Name, Color.Orange); + } + else + { + GameServer.Log(c.Character + " placed " + item.Name + " in " + Owner, Color.Orange); + } } } - foreach (Item item in prevItems) + foreach (Item item in prevItems.Distinct()) { if (item == null) continue; if (!Items.Contains(item)) { - GameServer.Log(c.Character + " removed " + item.Name + " from " + Owner.ToString(), Color.Orange); + if (Owner == c.Character) + { + GameServer.Log(c.Character + " dropped " + item.Name, Color.Orange); + } + else + { + GameServer.Log(c.Character + " removed " + item.Name + " from " + Owner, Color.Orange); + } } } } diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 3584d6cad..225795baf 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -1279,7 +1279,7 @@ namespace Barotrauma } } - public void SendSignal(int stepsTaken, string signal, string connectionName, float power = 0.0f) + public void SendSignal(int stepsTaken, string signal, string connectionName, Character sender, float power = 0.0f) { if (connections == null) return; @@ -1292,20 +1292,20 @@ namespace Barotrauma { //use a coroutine to prevent infinite loops by creating a one //frame delay if the "signal chain" gets too long - CoroutineManager.StartCoroutine(SendSignal(signal, c, power)); + CoroutineManager.StartCoroutine(SendSignal(signal, c, sender, power)); } else { - c.SendSignal(stepsTaken, signal, this, power); + c.SendSignal(stepsTaken, signal, this, sender, power); } } - private IEnumerable SendSignal(string signal, Connection connection, float power = 0.0f) + private IEnumerable SendSignal(string signal, Connection connection, Character sender, float power = 0.0f) { //wait one frame yield return CoroutineStatus.Running; - connection.SendSignal(0, signal, this, power); + connection.SendSignal(0, signal, this, sender, power); yield return CoroutineStatus.Success; }