Files
wwdpublic/Content.Server/Limbus/Traits/VampirismSystem.cs
Raikyr0 bd1f0783be Vampirism Trait (#1943)
# Description

Ported Vampirism Trait and it's Bloodsucking Components from
Floofstation

It's working now for real.

---

# TODO

- [x] See if it Works

---

# Changelog

🆑
- add: Vampirism Trait and it's Components

---------

Signed-off-by: Raikyr0 <Kurohana@hotmail.com.au>

(cherry picked from commit 5155cc8df6c22b23fae71070dce8bb68d92526f1)
2025-03-21 17:22:08 +03:00

52 lines
1.6 KiB
C#

using Content.Server.Body.Components;
using Content.Server.Limbus.Traits.Components;
using Content.Server.Vampiric;
using Content.Shared.Body.Components;
using Content.Shared.Body.Systems;
namespace Content.Server.Limbus.Traits;
public sealed class VampirismSystem : EntitySystem
{
[Dependency] private readonly SharedBodySystem _body = default!;
public override void Initialize()
{
SubscribeLocalEvent<VampirismComponent, MapInitEvent>(OnInitVampire);
}
private void OnInitVampire(Entity<VampirismComponent> ent, ref MapInitEvent args)
{
EnsureBloodSucker(ent);
if (!TryComp<BodyComponent>(ent, out var body)
|| !_body.TryGetBodyOrganComponents<MetabolizerComponent>(ent, out var comps, body))
return;
foreach (var (metabolizer, organ) in comps)
{
if (!TryComp<StomachComponent>(organ.Owner, out var stomach))
continue;
metabolizer.MetabolizerTypes = ent.Comp.MetabolizerPrototypes;
if (ent.Comp.SpecialDigestible is {} whitelist)
stomach.SpecialDigestible = whitelist;
}
}
private void EnsureBloodSucker(Entity<VampirismComponent> uid)
{
if (HasComp<BloodSuckerComponent>(uid))
return;
AddComp(uid, new BloodSuckerComponent
{
Delay = uid.Comp.SuccDelay,
InjectWhenSucc = false, // The code for it is deprecated, might wanna make it inject something when (if?) it gets reworked
UnitsToSucc = uid.Comp.UnitsToSucc,
WebRequired = false
});
}
}