mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-03 18:47:10 +02:00
28 lines
766 B
C#
28 lines
766 B
C#
using System.Linq;
|
|
|
|
namespace Robust.Shared.GameObjects
|
|
{
|
|
public class TimerSystem : EntitySystem
|
|
{
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
// Avoid a collection was modified while enumerating.
|
|
var timers = ComponentManager.EntityQuery<TimerComponent>().ToList();
|
|
|
|
foreach (var timer in timers)
|
|
{
|
|
timer.Update(frameTime);
|
|
}
|
|
|
|
foreach (var timer in timers)
|
|
{
|
|
if (!timer.Deleted && timer.RemoveOnEmpty && timer.TimerCount == 0)
|
|
{
|
|
ComponentManager.RemoveComponent<TimerComponent>(timer.Owner.Uid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|