using System.Collections.Generic;
namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups
{
///
/// Maintains a set of s that need to be remade with .
/// Defers remaking to reduce recalculations when a group is altered multiple times in a frame.
///
public interface INodeGroupManager
{
///
/// Queue up an to be remade.
///
void AddDirtyNodeGroup(INodeGroup nodeGroup);
void Update(float frameTime);
}
public class NodeGroupManager : INodeGroupManager
{
private readonly HashSet _dirtyNodeGroups = new();
public void AddDirtyNodeGroup(INodeGroup nodeGroup)
{
_dirtyNodeGroups.Add(nodeGroup);
}
public void Update(float frameTime)
{
foreach (var group in _dirtyNodeGroups)
{
group.RemakeGroup();
}
_dirtyNodeGroups.Clear();
}
}
}