Fix hunger damage not being applied properly (#17981)
This commit is contained in:
@@ -156,11 +156,6 @@ public sealed class HungerSystem : EntitySystem
|
|||||||
_alerts.ClearAlertCategory(uid, AlertCategory.Hunger);
|
_alerts.ClearAlertCategory(uid, AlertCategory.Hunger);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component.StarvationDamage is { } damage && !_mobState.IsDead(uid))
|
|
||||||
{
|
|
||||||
_damageable.TryChangeDamage(uid, damage, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (component.HungerThresholdDecayModifiers.TryGetValue(component.CurrentThreshold, out var modifier))
|
if (component.HungerThresholdDecayModifiers.TryGetValue(component.CurrentThreshold, out var modifier))
|
||||||
{
|
{
|
||||||
component.ActualDecayRate = component.BaseDecayRate * modifier;
|
component.ActualDecayRate = component.BaseDecayRate * modifier;
|
||||||
@@ -169,6 +164,19 @@ public sealed class HungerSystem : EntitySystem
|
|||||||
component.LastThreshold = component.CurrentThreshold;
|
component.LastThreshold = component.CurrentThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DoContinuousHungerEffects(EntityUid uid, HungerComponent? component = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref component))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (component.CurrentThreshold <= HungerThreshold.Starving &&
|
||||||
|
component.StarvationDamage is { } damage &&
|
||||||
|
!_mobState.IsDead(uid))
|
||||||
|
{
|
||||||
|
_damageable.TryChangeDamage(uid, damage, true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the hunger threshold for an entity based on the amount of food specified.
|
/// Gets the hunger threshold for an entity based on the amount of food specified.
|
||||||
/// If a specific amount isn't specified, just uses the current hunger of the entity
|
/// If a specific amount isn't specified, just uses the current hunger of the entity
|
||||||
@@ -220,6 +228,7 @@ public sealed class HungerSystem : EntitySystem
|
|||||||
hunger.NextUpdateTime = _timing.CurTime + hunger.UpdateRate;
|
hunger.NextUpdateTime = _timing.CurTime + hunger.UpdateRate;
|
||||||
|
|
||||||
ModifyHunger(uid, -hunger.ActualDecayRate, hunger);
|
ModifyHunger(uid, -hunger.ActualDecayRate, hunger);
|
||||||
|
DoContinuousHungerEffects(uid, hunger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user