Files
tbd-station-14/Content.Server/GameObjects/EntitySystems/StomachSystem.cs
metalgearsloth 480d3b26c4 Make nutrition less harsh (#439)
* Make nutrition less harsh

Also fix the accumulator because why did I put that in the loop.
Decay rates decreased and made drink thirst levels same as hunger for now.

* Also fix stomach frametime accumulation
2019-11-17 02:26:31 +01:00

33 lines
1.0 KiB
C#

using Content.Server.GameObjects.Components.Nutrition;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class StomachSystem : EntitySystem
{
private float _accumulatedFrameTime;
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(StomachComponent));
}
public override void Update(float frameTime)
{
_accumulatedFrameTime += frameTime;
// TODO: Potential performance improvement (e.g. going through say 1/5th the entities every tick)
if (_accumulatedFrameTime > 1.0f)
{
foreach (var entity in RelevantEntities)
{
var comp = entity.GetComponent<StomachComponent>();
comp.OnUpdate(_accumulatedFrameTime);
}
_accumulatedFrameTime = 0.0f;
}
}
}
}