HealingSystem: check blood restoration, staunching (#33526)

* HealingSystem: check blood restoration, staunching

* Milon's suggestions

* beck-thompson's requests
This commit is contained in:
Whatstone 2025-02-04 22:23:30 -05:00 committed by deltanedas
parent 64dc206970
commit ad57d70ada
1 changed files with 21 additions and 12 deletions

View File

@ -126,15 +126,15 @@ public sealed class HealingSystem : EntitySystem
_audio.PlayPvs(healing.HealingEndSound, entity.Owner, AudioHelpers.WithVariation(0.125f, _random).WithVolume(-5f));
// Logic to determine the whether or not to repeat the healing action
args.Repeat = HasDamage(entity.Comp, healing) && !dontRepeat || IsPartDamaged(args.User, entity); // Shitmed Change
args.Repeat = (HasDamage(entity, healing) && !dontRepeat) || IsPartDamaged(args.User, entity); // Shitmed Change
if (!args.Repeat && !dontRepeat)
_popupSystem.PopupEntity(Loc.GetString("medical-item-finished-using", ("item", args.Used)), entity.Owner, args.User);
args.Handled = true;
}
private bool HasDamage(DamageableComponent component, HealingComponent healing)
private bool HasDamage(Entity<DamageableComponent> ent, HealingComponent healing)
{
var damageableDict = component.Damage.DamageDict;
var damageableDict = ent.Comp.Damage.DamageDict;
var healingDict = healing.Damage.DamageDict;
foreach (var type in healingDict)
{
@ -144,6 +144,23 @@ public sealed class HealingSystem : EntitySystem
}
}
if (TryComp<BloodstreamComponent>(ent, out var bloodstream))
{
// Is ent missing blood that we can restore?
if (healing.ModifyBloodLevel > 0
&& _solutionContainerSystem.ResolveSolution(ent.Owner, bloodstream.BloodSolutionName, ref bloodstream.BloodSolution, out var bloodSolution)
&& bloodSolution.Volume < bloodSolution.MaxVolume)
{
return true;
}
// Is ent bleeding and can we stop it?
if (healing.BloodlossModifier < 0 && bloodstream.BleedAmount > 0)
{
return true;
}
}
return false;
}
@ -200,15 +217,7 @@ public sealed class HealingSystem : EntitySystem
if (TryComp<StackComponent>(uid, out var stack) && stack.Count < 1)
return false;
var anythingToDo =
HasDamage(targetDamage, component) ||
IsPartDamaged(user, target) || // Shitmed Change
component.ModifyBloodLevel > 0 // Special case if healing item can restore lost blood...
&& TryComp<BloodstreamComponent>(target, out var bloodstream)
&& _solutionContainerSystem.ResolveSolution(target, bloodstream.BloodSolutionName, ref bloodstream.BloodSolution, out var bloodSolution)
&& bloodSolution.Volume < bloodSolution.MaxVolume; // ...and there is lost blood to restore.
if (!anythingToDo)
if (!HasDamage((target, targetDamage), component) && !IsPartDamaged(user, target)) // Shitmed Change
{
_popupSystem.PopupEntity(Loc.GetString("medical-item-cant-use", ("item", uid)), uid, user);
return false;