Client LuaCsForBarotrauma
OxygenDetector.cs
1 using System.Xml.Linq;
2 
4 {
6  {
7  public const int LowOxygenPercentage = 35;
8 
9  private int prevSentOxygenValue;
10  private string oxygenSignal;
11 
13  : base (item, element)
14  {
15  IsActive = true;
16  }
17 
18  public override void Update(float deltaTime, Camera cam)
19  {
20  if (item.CurrentHull == null) { return; }
21 
22  int currOxygenPercentage = (int)item.CurrentHull.OxygenPercentage;
23  if (prevSentOxygenValue != currOxygenPercentage || oxygenSignal == null)
24  {
25  prevSentOxygenValue = currOxygenPercentage;
26  oxygenSignal = prevSentOxygenValue.ToString();
27  }
28 
29  item.SendSignal(oxygenSignal, "signal_out");
30  item.SendSignal(currOxygenPercentage <= LowOxygenPercentage ? "1" : "0", "low_oxygen");
31  }
32 
33  }
34 }
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)