- fixed "signal loops" causing StackOverFlowExceptions (now the signals can only take 10 "steps" between components per frame)
- parameter for changing the output value of And/Or components when the input conditions aren't met - or components work properly now - a limited number of signals (100) can be queued in a delay component
This commit is contained in:
@@ -20,20 +20,23 @@ namespace Barotrauma.Items.Components
|
||||
[Editable, HasDefaultValue(false, true)]
|
||||
public bool IsOn
|
||||
{
|
||||
get { return IsActive; }
|
||||
set
|
||||
{
|
||||
IsActive = value;
|
||||
}
|
||||
get; set;
|
||||
}
|
||||
|
||||
public RelayComponent(Item item, XElement element)
|
||||
: base (item, element)
|
||||
{
|
||||
IsActive = true;
|
||||
IsOn = true;
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
|
||||
item.SendSignal(0, IsOn ? "1" : "0", "state_out");
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f)
|
||||
{
|
||||
if (item.Condition <= 0.0f) return;
|
||||
|
||||
@@ -41,7 +44,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (connection.Name.Contains("_in"))
|
||||
{
|
||||
if (!IsActive) return;
|
||||
if (!IsOn) return;
|
||||
|
||||
string outConnection = connection.Name.Contains("power_in") ? "power_out" : "signal_out";
|
||||
|
||||
@@ -50,15 +53,15 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (connectionNumber > 0) outConnection += connectionNumber;
|
||||
|
||||
item.SendSignal(signal, outConnection, power);
|
||||
item.SendSignal(stepsTaken, signal, outConnection, power);
|
||||
}
|
||||
else if (connection.Name == "toggle")
|
||||
{
|
||||
IsActive = !IsActive;
|
||||
IsOn = !IsOn;
|
||||
}
|
||||
else if (connection.Name == "set_state")
|
||||
{
|
||||
IsActive = signal == "1";
|
||||
IsOn = signal != "0";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user