2020-07-08 01:41:20 +02:00
|
|
|
#nullable enable
|
2020-06-24 02:21:20 +02:00
|
|
|
using Content.Shared.GameObjects.Components.Movement;
|
|
|
|
|
using Content.Shared.GameObjects.Components.Nutrition;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.GameObjects.Components.Nutrition
|
|
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
|
|
|
|
public class HungerComponent : SharedHungerComponent
|
|
|
|
|
{
|
|
|
|
|
private HungerThreshold _currentHungerThreshold;
|
|
|
|
|
public override HungerThreshold CurrentHungerThreshold => _currentHungerThreshold;
|
|
|
|
|
|
|
|
|
|
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
|
|
|
|
{
|
2020-11-26 14:33:31 +01:00
|
|
|
base.HandleComponentState(curState, nextState);
|
|
|
|
|
|
|
|
|
|
if (curState is not HungerComponentState hunger)
|
2020-06-24 02:21:20 +02:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_currentHungerThreshold = hunger.CurrentThreshold;
|
|
|
|
|
|
2020-08-20 16:48:00 +02:00
|
|
|
if (Owner.TryGetComponent(out MovementSpeedModifierComponent? movement))
|
2020-06-24 02:21:20 +02:00
|
|
|
{
|
|
|
|
|
movement.RefreshMovementSpeedModifiers();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|