Docs/cleanup for node system.

This commit is contained in:
Pieter-Jan Briers
2021-07-06 21:25:04 +02:00
parent cfe4a26d1f
commit b79457dde9
4 changed files with 84 additions and 2 deletions

View File

@@ -17,6 +17,9 @@ namespace Content.Server.NodeContainer.NodeGroups
{
bool Remaking { get; }
/// <summary>
/// The list of nodes currently in this group.
/// </summary>
IReadOnlyList<Node> Nodes { get; }
void Create(NodeGroupID groupId);
@@ -41,6 +44,9 @@ namespace Content.Server.NodeContainer.NodeGroups
IReadOnlyList<Node> INodeGroup.Nodes => Nodes;
/// <summary>
/// The list of nodes in this group.
/// </summary>
[ViewVariables] public readonly List<Node> Nodes = new();
[ViewVariables] public int NodeCount => Nodes.Count;
@@ -54,6 +60,9 @@ namespace Content.Server.NodeContainer.NodeGroups
[ViewVariables]
protected GridId GridId { get; private set; }
/// <summary>
/// Network ID of this group for client-side debug visualization of nodes.
/// </summary>
[ViewVariables]
public int NetId;
@@ -71,16 +80,35 @@ namespace Content.Server.NodeContainer.NodeGroups
GridId = sourceNode.Owner.Transform.GridID;
}
/// <summary>
/// Called when a node has been removed from this group via deletion of the node.
/// </summary>
/// <remarks>
/// Note that this always still results in a complete remake of the group later,
/// but hooking this method is good for book keeping.
/// </remarks>
/// <param name="node">The node that was deleted.</param>
public virtual void RemoveNode(Node node)
{
}
/// <summary>
/// Called to load this newly created group up with new nodes.
/// </summary>
/// <param name="groupNodes">The new nodes for this group.</param>
public virtual void LoadNodes(
List<Node> groupNodes)
{
Nodes.AddRange(groupNodes);
}
/// <summary>
/// Called after the nodes in this group have been made into one or more new groups.
/// </summary>
/// <remarks>
/// Use this to split in-group data such as pipe gas mixtures into newly split nodes.
/// </remarks>
/// <param name="newGroups">A list of new groups for this group's former nodes.</param>
public virtual void AfterRemake(IEnumerable<IGrouping<INodeGroup?, Node>> newGroups) { }
public void QueueRemake()