Optimize pipe net appearance updating. (#6469)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Leon Friedrich
2022-02-09 16:10:55 +13:00
committed by GitHub
parent 544a892348
commit 21e0cd4256
9 changed files with 193 additions and 278 deletions

View File

@@ -245,14 +245,22 @@ namespace Content.Server.NodeContainer.EntitySystems
_toRemake.Clear();
_toRemove.Clear();
// notify entities that node groups have been updated, so they can do things like update their visuals.
HashSet<EntityUid> entities = new();
foreach (var group in newGroups)
{
foreach (var node in group.Nodes)
{
node.OnPostRebuild();
entities.Add(node.Owner);
}
}
foreach (var uid in entities)
{
var ev = new NodeGroupsRebuilt(uid);
RaiseLocalEvent(uid, ref ev, true);
}
_sawmill.Debug($"Updated node groups in {sw.Elapsed.TotalMilliseconds}ms. {newGroups.Count} new groups, {refloodCount} nodes processed.");
}
@@ -402,4 +410,19 @@ namespace Content.Server.NodeContainer.EntitySystems
};
}
}
/// <summary>
/// Event raised after node groups have been updated. Directed at any entity with a <see
/// cref="NodeContainerComponent"/> that had a relevant node.
/// </summary>
[ByRefEvent]
public readonly struct NodeGroupsRebuilt
{
public readonly EntityUid NodeOwner;
public NodeGroupsRebuilt(EntityUid nodeOwner)
{
NodeOwner = nodeOwner;
}
}
}