Fix hunger not updating thresholds correctly from rejuvenate.
This commit is contained in:
@@ -178,14 +178,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
public void OnUpdate(float frametime)
|
public void OnUpdate(float frametime)
|
||||||
{
|
{
|
||||||
_currentHunger -= frametime * ActualDecayRate;
|
_currentHunger -= frametime * ActualDecayRate;
|
||||||
var calculatedHungerThreshold = GetHungerThreshold(_currentHunger);
|
UpdateCurrentThreshold();
|
||||||
// _trySound(calculatedThreshold);
|
|
||||||
if (calculatedHungerThreshold != _currentHungerThreshold)
|
|
||||||
{
|
|
||||||
_currentHungerThreshold = calculatedHungerThreshold;
|
|
||||||
HungerThresholdEffect();
|
|
||||||
Dirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_currentHungerThreshold != HungerThreshold.Dead)
|
if (_currentHungerThreshold != HungerThreshold.Dead)
|
||||||
return;
|
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()
|
public void ResetFood()
|
||||||
{
|
{
|
||||||
_currentHungerThreshold = HungerThreshold.Okay;
|
_currentHunger = HungerThresholds[HungerThreshold.Okay];
|
||||||
_currentHunger = HungerThresholds[_currentHungerThreshold];
|
UpdateCurrentThreshold();
|
||||||
HungerThresholdEffect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ComponentState GetComponentState()
|
public override ComponentState GetComponentState()
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Content.Server.GameObjects.Components.Mobs;
|
|||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.GameObjects.Components.Damage;
|
using Content.Shared.GameObjects.Components.Damage;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
|
||||||
using Content.Shared.GameObjects.Components.Mobs.State;
|
using Content.Shared.GameObjects.Components.Mobs.State;
|
||||||
using Content.Shared.GameObjects.Components.Movement;
|
using Content.Shared.GameObjects.Components.Movement;
|
||||||
using Content.Shared.GameObjects.Components.Nutrition;
|
using Content.Shared.GameObjects.Components.Nutrition;
|
||||||
@@ -175,14 +174,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
public void OnUpdate(float frametime)
|
public void OnUpdate(float frametime)
|
||||||
{
|
{
|
||||||
_currentThirst -= frametime * ActualDecayRate;
|
_currentThirst -= frametime * ActualDecayRate;
|
||||||
var calculatedThirstThreshold = GetThirstThreshold(_currentThirst);
|
UpdateCurrentThreshold();
|
||||||
// _trySound(calculatedThreshold);
|
|
||||||
if (calculatedThirstThreshold != _currentThirstThreshold)
|
|
||||||
{
|
|
||||||
_currentThirstThreshold = calculatedThirstThreshold;
|
|
||||||
ThirstThresholdEffect();
|
|
||||||
Dirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_currentThirstThreshold != ThirstThreshold.Dead)
|
if (_currentThirstThreshold != ThirstThreshold.Dead)
|
||||||
return;
|
return;
|
||||||
@@ -199,11 +191,22 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateCurrentThreshold()
|
||||||
|
{
|
||||||
|
var calculatedThirstThreshold = GetThirstThreshold(_currentThirst);
|
||||||
|
// _trySound(calculatedThreshold);
|
||||||
|
if (calculatedThirstThreshold != _currentThirstThreshold)
|
||||||
|
{
|
||||||
|
_currentThirstThreshold = calculatedThirstThreshold;
|
||||||
|
ThirstThresholdEffect();
|
||||||
|
Dirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ResetThirst()
|
public void ResetThirst()
|
||||||
{
|
{
|
||||||
_currentThirstThreshold = ThirstThreshold.Okay;
|
_currentThirst = ThirstThresholds[ThirstThreshold.Okay];
|
||||||
_currentThirst = ThirstThresholds[_currentThirstThreshold];
|
UpdateCurrentThreshold();
|
||||||
ThirstThresholdEffect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ComponentState GetComponentState()
|
public override ComponentState GetComponentState()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using Content.Shared.GameObjects.Components.Movement;
|
using Content.Shared.GameObjects.Components.Movement;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.Components.Nutrition
|
namespace Content.Shared.GameObjects.Components.Nutrition
|
||||||
{
|
{
|
||||||
@@ -11,6 +12,7 @@ namespace Content.Shared.GameObjects.Components.Nutrition
|
|||||||
|
|
||||||
public sealed override uint? NetID => ContentNetIDs.HUNGER;
|
public sealed override uint? NetID => ContentNetIDs.HUNGER;
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
public abstract HungerThreshold CurrentHungerThreshold { get; }
|
public abstract HungerThreshold CurrentHungerThreshold { get; }
|
||||||
|
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ namespace Content.Shared.GameObjects.Components.Nutrition
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
public enum HungerThreshold : byte
|
public enum HungerThreshold : byte
|
||||||
{
|
{
|
||||||
Overfed,
|
Overfed,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using Content.Shared.GameObjects.Components.Movement;
|
using Content.Shared.GameObjects.Components.Movement;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.Components.Nutrition
|
namespace Content.Shared.GameObjects.Components.Nutrition
|
||||||
{
|
{
|
||||||
@@ -11,6 +12,7 @@ namespace Content.Shared.GameObjects.Components.Nutrition
|
|||||||
|
|
||||||
public sealed override uint? NetID => ContentNetIDs.THIRST;
|
public sealed override uint? NetID => ContentNetIDs.THIRST;
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
public abstract ThirstThreshold CurrentThirstThreshold { get; }
|
public abstract ThirstThreshold CurrentThirstThreshold { get; }
|
||||||
|
|
||||||
float IMoveSpeedModifier.SprintSpeedModifier
|
float IMoveSpeedModifier.SprintSpeedModifier
|
||||||
@@ -49,6 +51,7 @@ namespace Content.Shared.GameObjects.Components.Nutrition
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NetSerializable, Serializable]
|
||||||
public enum ThirstThreshold : byte
|
public enum ThirstThreshold : byte
|
||||||
{
|
{
|
||||||
// Hydrohomies
|
// Hydrohomies
|
||||||
|
|||||||
Reference in New Issue
Block a user