mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
# Description Adds two new IPC-exclusive negative traits. For 3 points, Faulty Waterproofing makes you take shock damage when splashed with or slipping in water, similarly to slimes. For 4 points, Fragile Circuits makes you shut down whenever you take shock damage. (yes, you can make it so that you instantly die for slipping in a puddle) --- <details><summary><h1>Media</h1></summary> <p>      </p> </details> --- # Changelog 🆑 - add: Added Faulty Waterproofing trait - add: Added Fragile Circuits trait --------- Signed-off-by: GNUtopia <93669372+GNUtopia@users.noreply.github.com> (cherry picked from commit 1bb6518b24a9f939686db0d08908ec6618145235)
34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using Content.Shared.Mobs;
|
|
using Content.Shared.Mobs.Systems;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Mobs.Components;
|
|
|
|
namespace Content.Server.Traits.Assorted;
|
|
|
|
public sealed class KillOnDamageSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly MobStateSystem _mob = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<KillOnDamageComponent, DamageChangedEvent>(OnDamageChanged);
|
|
}
|
|
|
|
private void OnDamageChanged(EntityUid uid, KillOnDamageComponent component, DamageChangedEvent args)
|
|
{
|
|
if (!TryComp<MobStateComponent>(uid, out var mobState))
|
|
return;
|
|
|
|
if (!_mob.IsDead(uid) && !(args.DamageDelta == null) && args.DamageDelta.DamageDict.TryGetValue(component.DamageType, out FixedPoint2 value) && value >= component.Threshold)
|
|
{
|
|
var popup = Loc.GetString(component.Popup, ("name", Identity.Name(uid, EntityManager)));
|
|
_popup.PopupEntity(popup, uid, PopupType.LargeCaution);
|
|
_mob.ChangeMobState(uid, MobState.Dead, mobState);
|
|
}
|
|
}
|
|
}
|