diff --git a/Content.Server/NodeContainer/EntitySystems/NodeContainerSystem.cs b/Content.Server/NodeContainer/EntitySystems/NodeContainerSystem.cs index 19b9de4415..ba11446302 100644 --- a/Content.Server/NodeContainer/EntitySystems/NodeContainerSystem.cs +++ b/Content.Server/NodeContainer/EntitySystems/NodeContainerSystem.cs @@ -4,6 +4,10 @@ using Robust.Shared.GameObjects; namespace Content.Server.NodeContainer.EntitySystems { + /// + /// Manages events. + /// + /// [UsedImplicitly] public class NodeContainerSystem : EntitySystem { diff --git a/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs b/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs index ca24e0f8fb..36f4d2c459 100644 --- a/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs +++ b/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs @@ -17,11 +17,13 @@ using Robust.Shared.Utility; namespace Content.Server.NodeContainer.EntitySystems { + /// + /// Entity system that manages and updating. + /// + /// [UsedImplicitly] public class NodeGroupSystem : EntitySystem { - [Dependency] private readonly IEntityManager _entityManager = default!; - [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IAdminManager _adminManager = default!; [Dependency] private readonly INodeGroupFactory _nodeGroupFactory = default!; diff --git a/Content.Server/NodeContainer/NodeGroups/BaseNodeGroup.cs b/Content.Server/NodeContainer/NodeGroups/BaseNodeGroup.cs index 133c8c3a33..81edd4e643 100644 --- a/Content.Server/NodeContainer/NodeGroups/BaseNodeGroup.cs +++ b/Content.Server/NodeContainer/NodeGroups/BaseNodeGroup.cs @@ -17,6 +17,9 @@ namespace Content.Server.NodeContainer.NodeGroups { bool Remaking { get; } + /// + /// The list of nodes currently in this group. + /// IReadOnlyList Nodes { get; } void Create(NodeGroupID groupId); @@ -41,6 +44,9 @@ namespace Content.Server.NodeContainer.NodeGroups IReadOnlyList INodeGroup.Nodes => Nodes; + /// + /// The list of nodes in this group. + /// [ViewVariables] public readonly List Nodes = new(); [ViewVariables] public int NodeCount => Nodes.Count; @@ -54,6 +60,9 @@ namespace Content.Server.NodeContainer.NodeGroups [ViewVariables] protected GridId GridId { get; private set; } + /// + /// Network ID of this group for client-side debug visualization of nodes. + /// [ViewVariables] public int NetId; @@ -71,16 +80,35 @@ namespace Content.Server.NodeContainer.NodeGroups GridId = sourceNode.Owner.Transform.GridID; } + /// + /// Called when a node has been removed from this group via deletion of the node. + /// + /// + /// Note that this always still results in a complete remake of the group later, + /// but hooking this method is good for book keeping. + /// + /// The node that was deleted. public virtual void RemoveNode(Node node) { } + /// + /// Called to load this newly created group up with new nodes. + /// + /// The new nodes for this group. public virtual void LoadNodes( List groupNodes) { Nodes.AddRange(groupNodes); } + /// + /// Called after the nodes in this group have been made into one or more new groups. + /// + /// + /// Use this to split in-group data such as pipe gas mixtures into newly split nodes. + /// + /// A list of new groups for this group's former nodes. public virtual void AfterRemake(IEnumerable> newGroups) { } public void QueueRemake() diff --git a/Content.Server/NodeContainer/Nodes/Node.cs b/Content.Server/NodeContainer/Nodes/Node.cs index e427d0d8ec..58519e5e23 100644 --- a/Content.Server/NodeContainer/Nodes/Node.cs +++ b/Content.Server/NodeContainer/Nodes/Node.cs @@ -23,8 +23,14 @@ namespace Content.Server.NodeContainer.Nodes [DataField("nodeGroupID")] public NodeGroupID NodeGroupID { get; private set; } = NodeGroupID.Default; + /// + /// The node group this node is a part of. + /// [ViewVariables] public INodeGroup? NodeGroup; + /// + /// The entity that owns this node via its . + /// [ViewVariables] public IEntity Owner { get; private set; } = default!; /// @@ -43,24 +49,49 @@ namespace Content.Server.NodeContainer.Nodes /// public bool Deleting; + /// + /// All compatible nodes that are reachable by this node. + /// Effectively, active connections out of this node. + /// public readonly HashSet ReachableNodes = new(); internal int FloodGen; internal int UndirectGen; internal bool FlaggedForFlood; internal int NetId; + + /// + /// Name of this node on the owning . + /// public string Name = default!; + /// + /// Invoked when the owning is initialized. + /// + /// The owning entity. public virtual void Initialize(IEntity owner) { Owner = owner; } + /// + /// Invoked when the owning is started. + /// public virtual void OnContainerStartup() { EntitySystem.Get().QueueReflood(this); } + /// + /// Immediately create a single-node node group for this node if it does not have one yet. + /// + /// + /// This can be useful for nodes like pipes + /// that need immediate access to their node group to set parameters like node volume. + /// The node group created by this function (if necessary) will still update and form new, + /// merged groups later if necessary. + /// Set parameters like pipe net volume should then be transferred/merged there. + /// public void CreateSingleNetImmediate() { EntitySystem.Get().CreateSingleNetImmediate(this); @@ -78,15 +109,24 @@ namespace Content.Server.NodeContainer.Nodes } } + /// + /// Called when the anchored state of the owning entity changes. + /// public virtual void AnchorStateChanged() { } + /// + /// Called after the parent node group has been rebuilt. + /// public virtual void OnPostRebuild() { } + /// + /// Called when the owning is shut down. + /// public virtual void OnContainerShutdown() { Deleting = true; @@ -97,6 +137,14 @@ namespace Content.Server.NodeContainer.Nodes /// How this node will attempt to find other reachable s to group with. /// Returns a set of s to consider grouping with. Should not return this current . /// + /// + /// + /// The set of nodes returned can be asymmetrical + /// (meaning that it can return other nodes whose does not return this node). + /// If this is used, creation of a new node may not correctly merge networks unless both sides + /// of this asymmetric relation are made to manually update with . + /// + /// public abstract IEnumerable GetReachableNodes(); } }