1 using Microsoft.Xna.Framework;
10 const float StateSwitchInterval = 1.0f;
12 private int prevSentWaterPercentageValue;
13 private string waterPercentageSignal;
15 private bool isInWater;
16 private float stateSwitchDelay;
18 private int maxOutputLength;
19 [
Editable,
Serialize(200,
IsPropertySaveable.No, description:
"The maximum length of the output strings. Warning: Large values can lead to large memory usage or networking issues.")]
22 get {
return maxOutputLength; }
25 maxOutputLength = Math.Max(value, 0);
29 private string output;
33 get {
return output; }
36 if (value ==
null) {
return; }
45 private string falseOutput;
49 get {
return falseOutput; }
52 if (value ==
null) {
return; }
80 if (stateSwitchDelay > 0.0f)
82 stateSwitchDelay -= deltaTime;
86 bool prevState = isInWater;
103 if (prevState != isInWater)
105 stateSwitchDelay = StateSwitchInterval;
110 if (!
string.IsNullOrEmpty(signalOut))
118 if (prevSentWaterPercentageValue != waterPercentage || waterPercentageSignal ==
null)
120 prevSentWaterPercentageValue = waterPercentage;
121 waterPercentageSignal = prevSentWaterPercentageValue.ToString();
void SendSignal(string signal, string connectionName)
The base class for components holding the different functionalities of the item
WaterDetector(Item item, ContentXElement element)
override void Update(float deltaTime, Camera cam)
static int GetWaterPercentage(Hull hull)