feat: added UpdateManager.CallFirstActiveFrameImmediately method for early calls of behaviours

This commit is contained in:
2026-03-06 11:39:46 +03:00
parent 7ae8b4feb0
commit 6ca3f22b17

View File

@@ -44,6 +44,17 @@ public class UpdateManager : Behaviour, IEnterUniverse, IExitUniverse
universe.OnPostUpdate.RemoveListener(OnPostUpdate); universe.OnPostUpdate.RemoveListener(OnPostUpdate);
} }
/// <summary>
/// Call the <see cref="IFirstFrameUpdate"/> early if it's in queue to be called by this the <see cref="UpdateManager"/>.
/// It will not be called in the next natural cycle.
/// </summary>
/// <param name="instance">The instance that will be called now rather than later.</param>
public void CallFirstActiveFrameImmediately(IFirstFrameUpdate instance)
{
if (toCallFirstFrameUpdates.Remove(instance))
instance.FirstActiveFrame();
}
private void OnFirstUpdate(IUniverse sender, IUniverse.UpdateArguments args) private void OnFirstUpdate(IUniverse sender, IUniverse.UpdateArguments args)
{ {
for (int i = toCallFirstFrameUpdates.Count - 1; i >= 0; i--) for (int i = toCallFirstFrameUpdates.Count - 1; i >= 0; i--)