- 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:
@@ -986,18 +986,42 @@ namespace Barotrauma
|
||||
return connectedComponents;
|
||||
}
|
||||
|
||||
public void SendSignal(string signal, string connectionName, float power = 0.0f)
|
||||
public void SendSignal(int stepsTaken, string signal, string connectionName, float power = 0.0f)
|
||||
{
|
||||
stepsTaken++;
|
||||
|
||||
ConnectionPanel panel = GetComponent<ConnectionPanel>();
|
||||
if (panel == null) return;
|
||||
foreach (Connection c in panel.Connections)
|
||||
{
|
||||
if (c.Name != connectionName) continue;
|
||||
|
||||
c.SendSignal(signal, this, power);
|
||||
|
||||
if (stepsTaken > 10)
|
||||
{
|
||||
//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));
|
||||
}
|
||||
else
|
||||
{
|
||||
c.SendSignal(stepsTaken, signal, this, power);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<object> SendSignal(string signal, Connection connection, float power = 0.0f)
|
||||
{
|
||||
//wait one frame
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
ConnectionPanel panel = GetComponent<ConnectionPanel>();
|
||||
if (panel == null) yield return CoroutineStatus.Success;
|
||||
|
||||
connection.SendSignal(0, signal, this, power);
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
/// <param name="position">Position of the Character doing the pick, only items that are close enough to this are checked</param>
|
||||
/// <param name="pickPosition">the item closest to pickPosition is returned</param>
|
||||
/// <param name="hull">If a hull is specified, only items within that hull are checked</param>
|
||||
|
||||
Reference in New Issue
Block a user