Files
RobustToolbox/Robust.Shared/GameObjects/Systems/TimerSystem.cs
T
2021-08-15 16:45:00 +02:00

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);
}
}
}
}
}