Reduce node resolves (#6435)

This commit is contained in:
Leon Friedrich
2022-02-07 01:10:33 +13:00
committed by GitHub
parent b82926e324
commit 1e10314900
12 changed files with 195 additions and 147 deletions

View File

@@ -3,6 +3,7 @@ using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.NodeGroups;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -36,7 +37,20 @@ namespace Content.Server.NodeContainer.Nodes
/// <summary>
/// If this node should be considered for connection by other nodes.
/// </summary>
public bool Connectable => !Deleting && Anchored;
public virtual bool Connectable(IEntityManager entMan, TransformComponent? xform = null)
{
if (Deleting)
return false;
if (entMan.IsQueuedForDeletion(Owner))
return false;
if (!NeedAnchored)
return true;
xform ??= entMan.GetComponent<TransformComponent>(Owner);
return xform.Anchored;
}
protected bool Anchored => !NeedAnchored || IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Anchored;
@@ -145,6 +159,10 @@ namespace Content.Server.NodeContainer.Nodes
/// of this asymmetric relation are made to manually update with <see cref="NodeGroupSystem.QueueReflood"/>.
/// </para>
/// </remarks>
public abstract IEnumerable<Node> GetReachableNodes();
public abstract IEnumerable<Node> GetReachableNodes(TransformComponent xform,
EntityQuery<NodeContainerComponent> nodeQuery,
EntityQuery<TransformComponent> xformQuery,
IMapGrid? grid,
IEntityManager entMan);
}
}