Probably fix thirst mispredict (#9656)
* Probably fix thirst mispredict * thanks rider
This commit is contained in:
@@ -13,8 +13,6 @@ namespace Content.Server.Nutrition.Components
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
private float _accumulatedFrameTime;
|
||||
|
||||
// Base stuff
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float BaseDecayRate
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace Content.Server.Nutrition.Components
|
||||
[RegisterComponent]
|
||||
public sealed class ThirstComponent : Component
|
||||
{
|
||||
|
||||
// Base stuff
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("baseDecayRate")]
|
||||
|
||||
@@ -16,8 +16,6 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly AlertsSystem _alerts = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly DamageableSystem _damage = default!;
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!;
|
||||
[Dependency] private readonly SharedJetpackSystem _jetpack = default!;
|
||||
|
||||
@@ -78,12 +76,28 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
component.CurrentThirst = component.ThirstThresholds[ThirstThreshold.Okay];
|
||||
}
|
||||
|
||||
private bool IsMovementThreshold(ThirstThreshold threshold)
|
||||
{
|
||||
switch (threshold)
|
||||
{
|
||||
case ThirstThreshold.Dead:
|
||||
case ThirstThreshold.Parched:
|
||||
return true;
|
||||
case ThirstThreshold.Thirsty:
|
||||
case ThirstThreshold.Okay:
|
||||
case ThirstThreshold.OverHydrated:
|
||||
return false;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(threshold), threshold, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEffects(ThirstComponent component)
|
||||
{
|
||||
if (component.LastThirstThreshold == ThirstThreshold.Parched && component.CurrentThirstThreshold != ThirstThreshold.Dead &&
|
||||
EntityManager.TryGetComponent(component.Owner, out MovementSpeedModifierComponent? movementSlowdownComponent))
|
||||
if (IsMovementThreshold(component.LastThirstThreshold) != IsMovementThreshold(component.CurrentThirstThreshold) &&
|
||||
TryComp(component.Owner, out MovementSpeedModifierComponent? movementSlowdownComponent))
|
||||
{
|
||||
_movement.RefreshMovementSpeedModifiers(component.Owner);
|
||||
_movement.RefreshMovementSpeedModifiers(component.Owner, movementSlowdownComponent);
|
||||
}
|
||||
|
||||
// Update UI
|
||||
|
||||
Reference in New Issue
Block a user