A reference to the character who triggered a signal is passed to all the recipients of the signal. Allows more accurate server logging: using doors, docking ports or turrets is now properly logged.

This commit is contained in:
Regalis
2017-04-28 18:10:47 +03:00
parent 64c109f13b
commit 89941229f8
28 changed files with 120 additions and 81 deletions
+9 -2
View File
@@ -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)