mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
Fix hunger + thirst mispredicts (#36549)
* Fix hunger + thirst mispredicts * Review
This commit is contained in:
parent
a85370cc81
commit
9b7af5dfcf
2 changed files with 12 additions and 1 deletions
|
|
@ -123,6 +123,7 @@ public sealed class HungerSystem : EntitySystem
|
|||
entity.Comp.LastAuthoritativeHungerChangeTime = _timing.CurTime;
|
||||
entity.Comp.LastAuthoritativeHungerValue = ClampHungerWithinThresholds(entity.Comp, value);
|
||||
DirtyField(entity.Owner, entity.Comp, nameof(HungerComponent.LastAuthoritativeHungerChangeTime));
|
||||
DirtyField(entity.Owner, entity.Comp, nameof(HungerComponent.LastAuthoritativeHungerValue));
|
||||
}
|
||||
|
||||
private void UpdateCurrentThreshold(EntityUid uid, HungerComponent? component = null)
|
||||
|
|
@ -135,6 +136,7 @@ public sealed class HungerSystem : EntitySystem
|
|||
return;
|
||||
|
||||
component.CurrentThreshold = calculatedHungerThreshold;
|
||||
DirtyField(uid, component, nameof(HungerComponent.CurrentThreshold));
|
||||
DoHungerThresholdEffects(uid, component);
|
||||
}
|
||||
|
||||
|
|
@ -163,10 +165,12 @@ public sealed class HungerSystem : EntitySystem
|
|||
if (component.HungerThresholdDecayModifiers.TryGetValue(component.CurrentThreshold, out var modifier))
|
||||
{
|
||||
component.ActualDecayRate = component.BaseDecayRate * modifier;
|
||||
DirtyField(uid, component, nameof(HungerComponent.ActualDecayRate));
|
||||
SetAuthoritativeHungerValue((uid, component), GetHunger(component));
|
||||
}
|
||||
|
||||
component.LastThreshold = component.CurrentThreshold;
|
||||
DirtyField(uid, component, nameof(HungerComponent.LastThreshold));
|
||||
}
|
||||
|
||||
private void DoContinuousHungerEffects(EntityUid uid, HungerComponent? component = null)
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public sealed class ThirstSystem : EntitySystem
|
|||
component.CurrentThirst = _random.Next(
|
||||
(int) component.ThirstThresholds[ThirstThreshold.Thirsty] + 10,
|
||||
(int) component.ThirstThresholds[ThirstThreshold.Okay] - 1);
|
||||
|
||||
DirtyField(uid, component, nameof(ThirstComponent.CurrentThirst));
|
||||
}
|
||||
component.NextUpdateTime = _timing.CurTime;
|
||||
component.CurrentThirstThreshold = GetThirstThreshold(component, component.CurrentThirst);
|
||||
|
|
@ -56,6 +58,8 @@ public sealed class ThirstSystem : EntitySystem
|
|||
// TODO: Check all thresholds make sense and throw if they don't.
|
||||
UpdateEffects(uid, component);
|
||||
|
||||
DirtyFields(uid, component, null, nameof(ThirstComponent.NextUpdateTime), nameof(ThirstComponent.CurrentThirstThreshold), nameof(ThirstComponent.LastThirstThreshold));
|
||||
|
||||
TryComp(uid, out MovementSpeedModifierComponent? moveMod);
|
||||
_movement.RefreshMovementSpeedModifiers(uid, moveMod);
|
||||
}
|
||||
|
|
@ -103,7 +107,7 @@ public sealed class ThirstSystem : EntitySystem
|
|||
component.ThirstThresholds[ThirstThreshold.OverHydrated]
|
||||
);
|
||||
|
||||
EntityManager.DirtyField(uid, component, nameof(ThirstComponent.CurrentThirst));
|
||||
DirtyField(uid, component, nameof(ThirstComponent.CurrentThirst));
|
||||
}
|
||||
|
||||
private bool IsMovementThreshold(ThirstThreshold threshold)
|
||||
|
|
@ -164,6 +168,9 @@ public sealed class ThirstSystem : EntitySystem
|
|||
_alerts.ClearAlertCategory(uid, component.ThirstyCategory);
|
||||
}
|
||||
|
||||
DirtyField(uid, component, nameof(ThirstComponent.LastThirstThreshold));
|
||||
DirtyField(uid, component, nameof(ThirstComponent.ActualDecayRate));
|
||||
|
||||
switch (component.CurrentThirstThreshold)
|
||||
{
|
||||
case ThirstThreshold.OverHydrated:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue