Client LuaCsForBarotrauma
GreaterComponent.cs
1 using System.Globalization;
2 using System.Xml.Linq;
3 
5 {
7  {
8  private float val1, val2;
9 
11  : base(item, element)
12  {
13  IsActive = true;
14  }
15 
16  public override void Update(float deltaTime, Camera cam)
17  {
18  bool sendOutput = false;
19  for (int i = 0; i < timeSinceReceived.Length; i++)
20  {
21  if (timeSinceReceived[i] <= timeFrame) sendOutput = true;
22  timeSinceReceived[i] += deltaTime;
23  }
24 
25  if (sendOutput)
26  {
27  string signalOut = val1 > val2 ? output : falseOutput;
28  if (string.IsNullOrEmpty(signalOut)) return;
29 
30  item.SendSignal(signalOut, "signal_out");
31  }
32  }
33 
34  public override void ReceiveSignal(Signal signal, Connection connection)
35  {
36  //base.ReceiveSignal(signal, connection);
37  switch (connection.Name)
38  {
39  case "signal_in1":
40  float.TryParse(signal.value, NumberStyles.Float, CultureInfo.InvariantCulture, out val1);
41  timeSinceReceived[0] = 0.0f;
42  break;
43  case "signal_in2":
44  float.TryParse(signal.value, NumberStyles.Float, CultureInfo.InvariantCulture, out val2);
45  timeSinceReceived[1] = 0.0f;
46  break;
47  case "set_output":
48  output = signal.value;
49  break;
50  }
51  }
52  }
53 }
void SendSignal(string signal, string connectionName)
GreaterComponent(Item item, ContentXElement element)
override void ReceiveSignal(Signal signal, Connection connection)
override void Update(float deltaTime, Camera cam)