2020-02-23 19:47:33 -05:00
|
|
|
|
using Content.Server.GameObjects.Components.Metabolism;
|
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
using Robust.Shared.GameObjects.Systems;
|
|
|
|
|
|
|
2020-08-13 14:40:27 +02:00
|
|
|
|
namespace Content.Server.GameObjects.EntitySystems
|
2020-02-23 19:47:33 -05:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2020-08-13 22:17:12 +10:00
|
|
|
|
/// Triggers metabolism updates for <see cref="BloodstreamComponent"/>
|
2020-02-23 19:47:33 -05:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[UsedImplicitly]
|
2020-08-13 22:17:12 +10:00
|
|
|
|
internal sealed class BloodstreamSystem : EntitySystem
|
2020-02-23 19:47:33 -05:00
|
|
|
|
{
|
|
|
|
|
|
private float _accumulatedFrameTime;
|
|
|
|
|
|
|
|
|
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Trigger metabolism updates at most once per second
|
|
|
|
|
|
_accumulatedFrameTime += frameTime;
|
|
|
|
|
|
if (_accumulatedFrameTime > 1.0f)
|
|
|
|
|
|
{
|
2020-08-13 22:17:12 +10:00
|
|
|
|
foreach (var component in ComponentManager.EntityQuery<BloodstreamComponent>())
|
2020-02-23 19:47:33 -05:00
|
|
|
|
{
|
2020-08-13 22:17:12 +10:00
|
|
|
|
component.OnUpdate(_accumulatedFrameTime);
|
2020-02-23 19:47:33 -05:00
|
|
|
|
}
|
2020-08-13 22:17:12 +10:00
|
|
|
|
_accumulatedFrameTime -= 1.0f;
|
2020-02-23 19:47:33 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|