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);
|
dockingState = MathHelper.Lerp(dockingState, 0.0f, deltaTime * 10.0f);
|
||||||
if (dockingState < 0.01f) docked = false;
|
if (dockingState < 0.01f) docked = false;
|
||||||
|
|
||||||
item.SendSignal(0, "0", "state_out");
|
item.SendSignal(0, "0", "state_out", null);
|
||||||
|
item.SendSignal(0, (FindAdjacentPort() != null) ? "1" : "0", "proximity_sensor", null);
|
||||||
item.SendSignal(0, (FindAdjacentPort() != null) ? "1" : "0", "proximity_sensor");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -601,7 +600,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (joint is DistanceJoint)
|
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);
|
dockingState = MathHelper.Lerp(dockingState, 0.5f, deltaTime * 10.0f);
|
||||||
|
|
||||||
if (Vector2.Distance(joint.WorldAnchorA, joint.WorldAnchorB) < 0.05f)
|
if (Vector2.Distance(joint.WorldAnchorA, joint.WorldAnchorB) < 0.05f)
|
||||||
@@ -616,7 +615,7 @@ namespace Barotrauma.Items.Components
|
|||||||
doorBody.Enabled = dockingTarget.door.Body.Enabled;
|
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);
|
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;
|
if (GameMain.Client != null) return;
|
||||||
|
|
||||||
|
bool wasDocked = docked;
|
||||||
|
DockingPort prevDockingTarget = dockingTarget;
|
||||||
|
|
||||||
switch (connection.Name)
|
switch (connection.Name)
|
||||||
{
|
{
|
||||||
case "toggle":
|
case "toggle":
|
||||||
@@ -744,6 +746,20 @@ namespace Barotrauma.Items.Components
|
|||||||
Docked = signal != "0";
|
Docked = signal != "0";
|
||||||
break;
|
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)
|
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
|
//don't use the predicted state here, because it might set
|
||||||
//other items to an incorrect state if the prediction is wrong
|
//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)
|
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;
|
if (isStuck) return;
|
||||||
|
|
||||||
|
bool wasOpen = isOpen;
|
||||||
|
|
||||||
if (connection.Name == "toggle")
|
if (connection.Name == "toggle")
|
||||||
{
|
{
|
||||||
SetState(!isOpen, false, true);
|
SetState(!isOpen, false, true);
|
||||||
@@ -496,6 +498,11 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
SetState(signal != "0", false, true);
|
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)
|
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"
|
//called then the item is dropped or dragged out of a "limbslot"
|
||||||
public virtual void Unequip(Character character) { }
|
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)
|
switch (connection.Name)
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ namespace Barotrauma.Items.Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.SendSignal(0, "1", "trigger_out");
|
item.SendSignal(0, "1", "trigger_out", character);
|
||||||
|
|
||||||
ApplyStatusEffects(ActionType.OnUse, 1.0f, activator);
|
ApplyStatusEffects(ActionType.OnUse, 1.0f, activator);
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (focusTarget == null)
|
if (focusTarget == null)
|
||||||
{
|
{
|
||||||
item.SendSignal(0, ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out");
|
item.SendSignal(0, ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out", character);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,13 +209,13 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (!character.IsRemotePlayer || character.ViewTarget == focusTarget)
|
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)
|
public override bool Pick(Character picker)
|
||||||
{
|
{
|
||||||
item.SendSignal(0, "1", "signal_out");
|
item.SendSignal(0, "1", "signal_out", picker);
|
||||||
|
|
||||||
PlaySound(ActionType.OnUse, item.WorldPosition);
|
PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ namespace Barotrauma.Items.Components
|
|||||||
IsActive = true;
|
IsActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.SendSignal(0, "1", "signal_out");
|
item.SendSignal(0, "1", "signal_out", character);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,9 +131,9 @@ namespace Barotrauma.Items.Components
|
|||||||
force = MathHelper.Lerp(force, 0.0f, 0.1f);
|
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")
|
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;
|
if (sender == null || sender.CurrentHull == null) return;
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
case "water_data_in":
|
case "water_data_in":
|
||||||
//cheating a bit because water detectors don't actually send the water level
|
//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);
|
hullData.Water = Rand.Range(0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,9 +198,9 @@ namespace Barotrauma.Items.Components
|
|||||||
GuiFrame.Update(1.0f / 60.0f);
|
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")
|
if (connection.Name == "toggle")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ namespace Barotrauma.Items.Components
|
|||||||
ExtraCooling = 0.0f;
|
ExtraCooling = 0.0f;
|
||||||
AvailableFuel = 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);
|
sendUpdateTimer = Math.Max(sendUpdateTimer - deltaTime, 0.0f);
|
||||||
|
|
||||||
@@ -532,7 +532,7 @@ namespace Barotrauma.Items.Components
|
|||||||
GUI.DrawLine(spriteBatch, prevPoint, lastPoint, color);
|
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)
|
switch (connection.Name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -165,13 +165,13 @@ namespace Barotrauma.Items.Components
|
|||||||
UpdateAutoPilot(deltaTime);
|
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;
|
float targetLevel = -targetVelocity.Y;
|
||||||
|
|
||||||
targetLevel += (neutralBallastLevel - 0.5f) * 100.0f;
|
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;
|
voltage -= deltaTime;
|
||||||
@@ -476,7 +476,7 @@ namespace Barotrauma.Items.Components
|
|||||||
return true;
|
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")
|
if (connection.Name == "velocity_in")
|
||||||
{
|
{
|
||||||
@@ -484,7 +484,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
else
|
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;
|
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;
|
if (!connection.IsPower) return;
|
||||||
|
|
||||||
@@ -236,8 +236,6 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
outputVoltage = power;
|
outputVoltage = power;
|
||||||
}
|
}
|
||||||
//if (currPowerConsumption == 0.0f) voltage = 0.0f;
|
|
||||||
//if (connection.IsPower) voltage = power;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch spriteBatch, bool editing = false)
|
public void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
pt.powerLoad += (fullLoad - pt.powerLoad) / inertia;
|
pt.powerLoad += (fullLoad - pt.powerLoad) / inertia;
|
||||||
pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia;
|
pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia;
|
||||||
pt.Item.SendSignal(0, "", "power", fullPower / Math.Max(fullLoad, 1.0f));
|
pt.Item.SendSignal(0, "", "power", null, fullPower / Math.Max(fullLoad, 1.0f));
|
||||||
pt.Item.SendSignal(0, "", "power_out", 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
|
//damage the item if voltage is too high
|
||||||
//(except if running as a client)
|
//(except if running as a client)
|
||||||
@@ -206,13 +206,13 @@ namespace Barotrauma.Items.Components
|
|||||||
if (powerConnections.Count == 0) IsActive = false;
|
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")
|
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 (currPowerConsumption == 0.0f) voltage = 0.0f;
|
||||||
if (connection.IsPower) voltage = power;
|
if (connection.IsPower) voltage = power;
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ namespace Barotrauma.Items.Components
|
|||||||
string signalOut = sendOutput ? output : falseOutput;
|
string signalOut = sendOutput ? output : falseOutput;
|
||||||
if (string.IsNullOrEmpty(signalOut)) return;
|
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)
|
switch (connection.Name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ namespace Barotrauma.Items.Components
|
|||||||
Wires[index] = wire;
|
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++)
|
for (int i = 0; i < MaxLinked; i++)
|
||||||
{
|
{
|
||||||
@@ -163,11 +163,11 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
Connection recipient = Wires[i].OtherConnection(this);
|
Connection recipient = Wires[i].OtherConnection(this);
|
||||||
if (recipient == null) continue;
|
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)
|
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)
|
foreach (StatusEffect effect in recipient.effects)
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
var signalOut = signalQueue.Dequeue();
|
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)
|
switch (connection.Name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -193,9 +193,9 @@ namespace Barotrauma.Items.Components
|
|||||||
light.Remove();
|
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)
|
switch (connection.Name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,15 +54,15 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
if (motionDetected)
|
if (motionDetected)
|
||||||
{
|
{
|
||||||
item.SendSignal(1, output, "state_out");
|
item.SendSignal(1, output, "state_out", null);
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrWhiteSpace(falseOutput))
|
else if (!string.IsNullOrWhiteSpace(falseOutput))
|
||||||
{
|
{
|
||||||
item.SendSignal(1, falseOutput, "state_out");
|
item.SendSignal(1, falseOutput, "state_out", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTimer -= deltaTime;
|
updateTimer -= deltaTime;
|
||||||
if (updateTimer>0.0f) return;
|
if (updateTimer > 0.0f) return;
|
||||||
|
|
||||||
motionDetected = false;
|
motionDetected = false;
|
||||||
updateTimer = UpdateInterval;
|
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;
|
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;
|
string signalOut = sendOutput ? output : falseOutput;
|
||||||
if (string.IsNullOrEmpty(signalOut)) return;
|
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;
|
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
|
catch
|
||||||
{
|
{
|
||||||
item.SendSignal(0, "ERROR", "signal_out");
|
item.SendSignal(0, "ERROR", "signal_out", null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,17 +67,17 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
item.SendSignal(0, "ERROR", "signal_out");
|
item.SendSignal(0, "ERROR", "signal_out", null);
|
||||||
previousResult = false;
|
previousResult = false;
|
||||||
return;
|
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)
|
switch (connection.Name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
base.Update(deltaTime, cam);
|
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;
|
if (connection.IsPower && connection.Name.Contains("_out")) return;
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (connectionNumber > 0) outConnection += connectionNumber;
|
if (connectionNumber > 0) outConnection += connectionNumber;
|
||||||
|
|
||||||
item.SendSignal(stepsTaken, signal, outConnection, power);
|
item.SendSignal(stepsTaken, signal, outConnection, sender, power);
|
||||||
}
|
}
|
||||||
else if (connection.Name == "toggle")
|
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)
|
switch (connection.Name)
|
||||||
{
|
{
|
||||||
@@ -41,7 +41,7 @@ namespace Barotrauma.Items.Components
|
|||||||
string signalOut = (signal == targetSignal) ? output : falseOutput;
|
string signalOut = (signal == targetSignal) ? output : falseOutput;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(signalOut)) return;
|
if (string.IsNullOrWhiteSpace(signalOut)) return;
|
||||||
item.SendSignal(stepsTaken, signalOut, "signal_out");
|
item.SendSignal(stepsTaken, signalOut, "signal_out", sender);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "set_output":
|
case "set_output":
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override void Update(float deltaTime, Camera cam)
|
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);
|
return HasRequiredContainedItems(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Transmit(string signal)
|
/*public void Transmit(string signal)
|
||||||
{
|
{
|
||||||
if (!CanTransmit()) return;
|
if (!CanTransmit()) return;
|
||||||
|
|
||||||
@@ -59,9 +59,9 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
var connections = w.item.Connections;
|
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()
|
private List<WifiComponent> GetReceiversInRange()
|
||||||
{
|
{
|
||||||
@@ -77,9 +77,9 @@ namespace Barotrauma.Items.Components
|
|||||||
return Vector2.Distance(item.WorldPosition, sender.item.WorldPosition) <= sender.Range;
|
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 (senderComponent != null && !CanReceive(senderComponent)) return;
|
||||||
|
|
||||||
if (LinkToChat)
|
if (LinkToChat)
|
||||||
@@ -107,7 +107,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
foreach (WifiComponent wifiComp in receivers)
|
foreach (WifiComponent wifiComp in receivers)
|
||||||
{
|
{
|
||||||
wifiComp.item.SendSignal(stepsTaken, signal, "signal_out");
|
wifiComp.item.SendSignal(stepsTaken, signal, "signal_out", sender);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,6 +192,11 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
Launch(projectiles[0].Item);
|
Launch(projectiles[0].Item);
|
||||||
|
|
||||||
|
if (character != null)
|
||||||
|
{
|
||||||
|
GameServer.Log(character.Name + " launched " + item.Name, Color.Orange);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
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)
|
switch (connection.Name)
|
||||||
{
|
{
|
||||||
@@ -382,7 +387,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case "trigger_in":
|
case "trigger_in":
|
||||||
item.Use((float)Timing.Step, null);
|
item.Use((float)Timing.Step, sender);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -583,20 +583,34 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GameMain.Server.CreateEntityEvent(Owner as IServerSerializable, new object[] { NetEntityEvent.Type.InventoryState });
|
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 (item == null) continue;
|
||||||
if (!prevItems.Contains(item))
|
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 (item == null) continue;
|
||||||
if (!Items.Contains(item))
|
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;
|
if (connections == null) return;
|
||||||
|
|
||||||
@@ -1292,20 +1292,20 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
//use a coroutine to prevent infinite loops by creating a one
|
//use a coroutine to prevent infinite loops by creating a one
|
||||||
//frame delay if the "signal chain" gets too long
|
//frame delay if the "signal chain" gets too long
|
||||||
CoroutineManager.StartCoroutine(SendSignal(signal, c, power));
|
CoroutineManager.StartCoroutine(SendSignal(signal, c, sender, power));
|
||||||
}
|
}
|
||||||
else
|
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
|
//wait one frame
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
connection.SendSignal(0, signal, this, power);
|
connection.SendSignal(0, signal, this, sender, power);
|
||||||
|
|
||||||
yield return CoroutineStatus.Success;
|
yield return CoroutineStatus.Success;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user