Files
tbd-station-14/Content.Server/Body/Mechanisms/Behaviors/StomachBehavior.cs
Pieter-Jan Briers ed1a96e536 Nullability fixes.
2020-08-20 16:48:15 +02:00

37 lines
985 B
C#

#nullable enable
using System;
using Content.Server.Body.Network;
using Content.Server.GameObjects.Components.Body.Digestive;
using JetBrains.Annotations;
namespace Content.Server.Body.Mechanisms.Behaviors
{
[UsedImplicitly]
public class StomachBehavior : MechanismBehavior
{
private float _accumulatedFrameTime;
protected override Type? Network => typeof(DigestiveNetwork);
public override void PreMetabolism(float frameTime)
{
base.PreMetabolism(frameTime);
if (Mechanism.Body == null ||
!Mechanism.Body.Owner.TryGetComponent(out StomachComponent? stomach))
{
return;
}
// Update at most once per second
_accumulatedFrameTime += frameTime;
if (_accumulatedFrameTime >= 1)
{
stomach.Update(_accumulatedFrameTime);
_accumulatedFrameTime -= 1;
}
}
}
}