Client LuaCsForBarotrauma
OxygenDetector.cs
2 {
4  {
5  public const int LowOxygenPercentage = 35;
6 
7  private int prevSentOxygenValue;
8  public string OxygenSignal { get; private set; }
9 
11  : base (item, element)
12  {
13  IsActive = true;
14  }
15 
16  public override void Update(float deltaTime, Camera cam)
17  {
18  if (item.CurrentHull == null) { return; }
19 
20  int currOxygenPercentage = (int)item.CurrentHull.OxygenPercentage;
21  if (prevSentOxygenValue != currOxygenPercentage || OxygenSignal == null)
22  {
23  prevSentOxygenValue = currOxygenPercentage;
24  OxygenSignal = prevSentOxygenValue.ToString();
25  }
26 
27  item.SendSignal(OxygenSignal, "signal_out");
28  item.SendSignal(currOxygenPercentage <= LowOxygenPercentage ? "1" : "0", "low_oxygen");
29  }
30 
31  }
32 }
void SendSignal(string signal, string connectionName)
The base class for components holding the different functionalities of the item
OxygenDetector(Item item, ContentXElement element)
override void Update(float deltaTime, Camera cam)