mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Clean up all missing EntitySystem proxy method uses * Restore comment * Fix bad change that caused closure allocation * tuple * Revert "tuple" This reverts commit14581a40aa. * Revert "Fix bad change that caused closure allocation" This reverts commit215b2559ed. * Revert "Restore comment" This reverts commit4a47a36557. * Revert "Clean up all missing EntitySystem proxy method uses" This reverts commit3b1fe4ce7f. * Redo with improved code fixer. Let's see how it fares this time
38 lines
1.1 KiB
C#
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
|
|
}
|
|
}
|