Barotrauma Client Doc
CircuitBoxInputOutputNode.cs
1 #nullable enable
2 
3 using System.Collections.Generic;
4 using System.Collections.Immutable;
5 using System.Xml.Linq;
7 using Microsoft.Xna.Framework;
8 
9 namespace Barotrauma
10 {
11  internal sealed class CircuitBoxInputOutputNode : CircuitBoxNode
12  {
13  public enum Type
14  {
15  Invalid,
16  Input,
17  Output
18  }
19 
20  public Type NodeType;
21 
22  public CircuitBoxInputOutputNode(IReadOnlyList<CircuitBoxConnection> conns, Vector2 initialPosition, Type type, CircuitBox circuitBox): base(circuitBox)
23  {
24  Size = CalculateSize(conns);
25  Connectors = conns.ToImmutableArray();
26  Position = initialPosition;
27  NodeType = type;
28  UpdatePositions();
29  }
30 
31  public XElement Save() => new XElement($"{NodeType}Node", new XAttribute("pos", XMLExtensions.Vector2ToString(Position)));
32 
33  public void Load(ContentXElement element)
34  {
35  Position = element.GetAttributeVector2("pos", Vector2.Zero);
36  }
37  }
38 }