Client LuaCsForBarotrauma
ModuloComponent.cs
1 using System.Globalization;
2 using System.Xml.Linq;
3 
5 {
7  {
8  private float modulus;
9  [InGameEditable, Serialize(1.0f, IsPropertySaveable.No, description: "The modulus of the operation. Must be non-zero.", alwaysUseInstanceValues: true)]
10  public float Modulus
11  {
12  get { return modulus; }
13  set
14  {
15  modulus = MathUtils.NearlyEqual(value, 0.0f) ? 1.0f : value;
16  }
17  }
18 
19  public ModuloComponent(Item item, ContentXElement element) : base(item, element)
20  {
21  IsActive = true;
22  }
23 
24  public override void ReceiveSignal(Signal signal, Connection connection)
25  {
26  switch (connection.Name)
27  {
28  case "set_modulus":
29  case "modulus":
30  float.TryParse(signal.value, NumberStyles.Float, CultureInfo.InvariantCulture, out float newModulus);
31  Modulus = newModulus;
32  break;
33  case "signal_in":
34  float.TryParse(signal.value, NumberStyles.Float, CultureInfo.InvariantCulture, out float value);
35  signal.value = (value % modulus).ToString("G", CultureInfo.InvariantCulture);
36  item.SendSignal(signal, "signal_out");
37  break;
38  }
39 
40  }
41  }
42 }
void SendSignal(string signal, string connectionName)
The base class for components holding the different functionalities of the item
override void ReceiveSignal(Signal signal, Connection connection)
ModuloComponent(Item item, ContentXElement element)