Convert suicide to ecs (#8091)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
using Content.Server.Audio;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Recycling.Components;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Recycling;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Player;
|
||||
@@ -17,6 +23,8 @@ namespace Content.Server.Recycling
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly AmbientSoundSystem _ambience = default!;
|
||||
[Dependency] private readonly GameTicker _ticker = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly TagSystem _tags = default!;
|
||||
|
||||
private const float RecyclerSoundCooldown = 0.8f;
|
||||
@@ -25,6 +33,34 @@ namespace Content.Server.Recycling
|
||||
{
|
||||
SubscribeLocalEvent<RecyclerComponent, StartCollideEvent>(OnCollide);
|
||||
SubscribeLocalEvent<RecyclerComponent, GotEmaggedEvent>(OnEmagged);
|
||||
SubscribeLocalEvent<RecyclerComponent, SuicideEvent>(OnSuicide);
|
||||
}
|
||||
|
||||
private void OnSuicide(EntityUid uid, RecyclerComponent component, SuicideEvent args)
|
||||
{
|
||||
if (args.Handled) return;
|
||||
args.SetHandled(SuicideKind.Bloodloss);
|
||||
var victim = args.Victim;
|
||||
if (TryComp(victim, out ActorComponent? actor) &&
|
||||
actor.PlayerSession.ContentData()?.Mind is { } mind)
|
||||
{
|
||||
_ticker.OnGhostAttempt(mind, false);
|
||||
if (mind.OwnedEntity is { Valid: true } entity)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("recycler-component-suicide-message"), entity, Filter.Pvs(entity, entityManager: EntityManager));
|
||||
}
|
||||
}
|
||||
|
||||
_popup.PopupEntity(Loc.GetString("recycler-component-suicide-message-others", ("victim", victim)),
|
||||
victim,
|
||||
Filter.Pvs(victim, entityManager: EntityManager).RemoveWhereAttachedEntity(e => e == victim));
|
||||
|
||||
if (TryComp<SharedBodyComponent?>(victim, out var body))
|
||||
{
|
||||
body.Gib(true);
|
||||
}
|
||||
|
||||
Bloodstain(component);
|
||||
}
|
||||
|
||||
public void EnableRecycler(RecyclerComponent component)
|
||||
|
||||
Reference in New Issue
Block a user