-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
deltanedas
committed
Jan 15, 2025
1 parent
7ca7d9c
commit 5eb606d
Showing
1 changed file
with
25 additions
and
11 deletions.
There are no files selected for viewing
36 changes: 25 additions & 11 deletions
36
Content.Server/_Shitmed/DelayedDeath/DelayedDeathSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,42 @@ | ||
using Content.Shared.Damage; | ||
using Content.Shared.Damage.Prototypes; | ||
using Content.Shared.Medical; | ||
using Content.Shared.Mobs; | ||
using Content.Shared.Mobs.Components; | ||
using Content.Shared.Mobs.Systems; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server._Shitmed.DelayedDeath; | ||
|
||
public partial class DelayedDeathSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly DamageableSystem _damageable = default!; | ||
[Dependency] private readonly MobStateSystem _mobState = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypes = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<DelayedDeathComponent, TargetBeforeDefibrillatorZapsEvent>(OnDefibZap); | ||
} | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
|
||
using var query = EntityQueryEnumerator<DelayedDeathComponent>(); | ||
while (query.MoveNext(out var ent, out var component)) | ||
using var query = EntityQueryEnumerator<DelayedDeathComponent, MobStateComponent>(); | ||
while (query.MoveNext(out var ent, out var comp, out var mob)) | ||
{ | ||
component.DeathTimer += frameTime; | ||
comp.DeathTimer += frameTime; | ||
|
||
if (component.DeathTimer >= component.DeathTime && !_mobState.IsDead(ent)) | ||
if (comp.DeathTimer >= comp.DeathTime && !_mobState.IsDead(ent, mob)) | ||
{ | ||
var damage = new DamageSpecifier(_prototypes.Index<DamageTypePrototype>("Bloodloss"), 150); | ||
_damageable.TryChangeDamage(ent, damage, partMultiplier: 0f); | ||
// go crit then dead so deathgasp can happen | ||
_mobState.ChangeMobState(ent, MobState.Critical, mob); | ||
_mobState.ChangeMobState(ent, MobState.Dead, mob); | ||
} | ||
} | ||
} | ||
|
||
private void OnDefibZap(Entity<DelayedDeathComponent> ent, ref TargetBeforeDefibrillatorZapsEvent args) | ||
{ | ||
// can't defib someone without a heart or brain pal | ||
args.Cancel(); | ||
} | ||
} |