Files
wwdpublic/Content.Server/Traits/BloodDeficiencySystem.cs
Mnemotechnican 520a0dcc7f Blood Regeneration Affects Hunger/Thirst (#1007)
# Description
Makes natural blood regeneration use up some hunger and thirst, and halt
completely when you are starving/dying of thirst.

This is necessary to fix two issues:
1. It being possible to feed off of your own blood, by repeatedly
drawing your blood and injecting it back with a syringe. (I actually
know a few people on floof who do that on a daily basis)
2. Hunger and thirst having no real impact on gameplay, besides giving
you a mildly annoying depression overlay when low.

This PR also slightly refactors the blood deficiency trait so that it's
no longer completely hardcoded in the bloodstream system.

<details><summary><h1>Media</h1></summary>
<p>

https://github.com/user-attachments/assets/f8634de5-19bd-44a5-ada2-62f4504bf3d4

</p>
</details>

# Changelog
🆑
- add: Blood regeneration now uses up hunger and thirst, and comes to a
halt when you are very hungry or thirst.
- fix: It is no longer feasible to drink your own blood to satiate your
own hunger.
# Conflicts:
#	Content.Server/Body/Systems/BloodstreamSystem.cs
2024-10-19 13:35:50 +07:00

25 lines
868 B
C#

using Content.Server.Body.Components;
using Content.Server.Body.Events;
using Content.Server.Traits.Assorted;
using Content.Shared.FixedPoint;
namespace Content.Server.Traits;
public sealed class BloodDeficiencySystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BloodDeficiencyComponent, NaturalBloodRegenerationAttemptEvent>(OnBloodRegen);
}
private void OnBloodRegen(Entity<BloodDeficiencyComponent> ent, ref NaturalBloodRegenerationAttemptEvent args)
{
if (!ent.Comp.Active || !TryComp<BloodstreamComponent>(ent.Owner, out var bloodstream))
return;
args.Amount = FixedPoint2.Min(args.Amount, 0) // If the blood regen amount already was negative, we keep it.
- bloodstream.BloodMaxVolume * ent.Comp.BloodLossPercentage;
}
}