Optimize pipe net appearance updating. (#6469)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user