Files
RobustToolbox/Robust.Shared/GameObjects/Systems/TimerSystem.cs
Tayrtahn 196e59b7e4 Clean up all missing EntitySystem proxy method uses (#6027)
* Clean up all missing EntitySystem proxy method uses

* Restore comment

* Fix bad change that caused closure allocation

* tuple

* Revert "tuple"

This reverts commit 14581a40aa.

* Revert "Fix bad change that caused closure allocation"

This reverts commit 215b2559ed.

* Revert "Restore comment"

This reverts commit 4a47a36557.

* Revert "Clean up all missing EntitySystem proxy method uses"

This reverts commit 3b1fe4ce7f.

* Redo with improved code fixer.
Let's see how it fares this time
2025-06-21 00:05:09 +02:00

38 lines
1.1 KiB
C#

using System.Linq;
using Robust.Shared.Collections;
using Robust.Shared.IoC;
namespace Robust.Shared.GameObjects
{
public sealed class TimerSystem : EntitySystem
{
#pragma warning disable CS0618
public override void Update(float frameTime)
{
base.Update(frameTime);
// Avoid a collection was modified while enumerating.
var timers = EntityQueryEnumerator<TimerComponent>();
var timersList = new ValueList<(EntityUid, TimerComponent)>();
while (timers.MoveNext(out var uid, out var timer))
{
timersList.Add((uid, timer));
}
foreach (var (_, timer) in timersList)
{
timer.Update(frameTime);
}
foreach (var (uid, timer) in timersList)
{
if (!timer.Deleted && !EntityManager.Deleted(uid) && timer.RemoveOnEmpty && timer.TimerCount == 0)
{
RemComp<TimerComponent>(uid);
}
}
}
#pragma warning restore CS0618
}
}