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