* Remove Unnecessary AnchorUpdate() call * NodeGroupManager * NodeGroupManager issues NodeGroup remake attempts * Code cleanup * NodeGroupManager only stores dirty groups, handles them on next frame * Removes unused NodeGroupManager dependency * Prevents OnRemoveNode from iterating over every connector after the first time * Revert "Prevents OnRemoveNode from iterating over every connector after the first time" This reverts commit c72af4b18d55192af789514f74bef893cf076fbc. * Dependancy warning fix Co-authored-by: py01 <pyronetics01@gmail.com>
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups
|
|
{
|
|
/// <summary>
|
|
/// Maintains a set of <see cref="INodeGroup"/>s that need to be remade with <see cref="INodeGroup.RemakeGroup"/>.
|
|
/// Defers remaking to reduce recalculations when a group is altered multiple times in a frame.
|
|
/// </summary>
|
|
public interface INodeGroupManager
|
|
{
|
|
/// <summary>
|
|
/// Queue up an <see cref="INodeGroup"/> to be remade.
|
|
/// </summary>
|
|
void AddDirtyNodeGroup(INodeGroup nodeGroup);
|
|
|
|
void Update(float frameTime);
|
|
}
|
|
|
|
public class NodeGroupManager : INodeGroupManager
|
|
{
|
|
private readonly HashSet<INodeGroup> _dirtyNodeGroups = new HashSet<INodeGroup>();
|
|
|
|
public void AddDirtyNodeGroup(INodeGroup nodeGroup)
|
|
{
|
|
_dirtyNodeGroups.Add(nodeGroup);
|
|
}
|
|
|
|
public void Update(float frameTime)
|
|
{
|
|
foreach (var group in _dirtyNodeGroups)
|
|
{
|
|
group.RemakeGroup();
|
|
}
|
|
_dirtyNodeGroups.Clear();
|
|
}
|
|
}
|
|
}
|