Fix hunger not updating thresholds correctly from rejuvenate.

This commit is contained in:
Pieter-Jan Briers
2021-01-12 21:24:11 +01:00
parent ec492a0d6a
commit af1838c641
4 changed files with 36 additions and 23 deletions

View File

@@ -178,14 +178,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
public void OnUpdate(float frametime)
{
_currentHunger -= frametime * ActualDecayRate;
var calculatedHungerThreshold = GetHungerThreshold(_currentHunger);
// _trySound(calculatedThreshold);
if (calculatedHungerThreshold != _currentHungerThreshold)
{
_currentHungerThreshold = calculatedHungerThreshold;
HungerThresholdEffect();
Dirty();
}
UpdateCurrentThreshold();
if (_currentHungerThreshold != HungerThreshold.Dead)
return;
@@ -202,11 +195,22 @@ namespace Content.Server.GameObjects.Components.Nutrition
}
}
private void UpdateCurrentThreshold()
{
var calculatedHungerThreshold = GetHungerThreshold(_currentHunger);
// _trySound(calculatedThreshold);
if (calculatedHungerThreshold != _currentHungerThreshold)
{
_currentHungerThreshold = calculatedHungerThreshold;
HungerThresholdEffect();
Dirty();
}
}
public void ResetFood()
{
_currentHungerThreshold = HungerThreshold.Okay;
_currentHunger = HungerThresholds[_currentHungerThreshold];
HungerThresholdEffect();
_currentHunger = HungerThresholds[HungerThreshold.Okay];
UpdateCurrentThreshold();
}
public override ComponentState GetComponentState()