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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
{
|
||||
|
||||
@@ -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<WaterDetector>() == null)
|
||||
if (source.GetComponent<WaterDetector>() == null)
|
||||
{
|
||||
hullData.Water = Rand.Range(0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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")
|
||||
{
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<WifiComponent> 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<WifiComponent>();
|
||||
var senderComponent = source.GetComponent<WifiComponent>();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<object> SendSignal(string signal, Connection connection, float power = 0.0f)
|
||||
private IEnumerable<object> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user