Files

59 lines
1.8 KiB
C#
Raw Permalink Normal View History

using Content.Server.Ghost;
using Content.Shared.IdentityManagement;
2022-07-13 19:11:59 -04:00
using Content.Shared.Interaction.Events;
using Content.Shared.Morgue;
using Content.Shared.Morgue.Components;
2022-07-13 19:11:59 -04:00
using Content.Shared.Popups;
using Robust.Shared.Player;
2022-07-13 19:11:59 -04:00
namespace Content.Server.Morgue;
public sealed class CrematoriumSystem : SharedCrematoriumSystem
2022-07-13 19:11:59 -04:00
{
[Dependency] private readonly GhostSystem _ghostSystem = default!;
2022-07-13 19:11:59 -04:00
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CrematoriumComponent, SuicideByEnvironmentEvent>(OnSuicideByEnvironment);
}
2022-07-13 19:11:59 -04:00
private void OnSuicideByEnvironment(Entity<CrematoriumComponent> ent, ref SuicideByEnvironmentEvent args)
2022-07-13 19:11:59 -04:00
{
if (args.Handled)
return;
var victim = args.Victim;
if (HasComp<ActorComponent>(victim) && Mind.TryGetMind(victim, out var mindId, out var mind))
2022-07-13 19:11:59 -04:00
{
_ghostSystem.OnGhostAttempt(mindId, false, mind: mind);
2022-07-13 19:11:59 -04:00
if (mind.OwnedEntity is { Valid: true } entity)
{
Popup.PopupEntity(Loc.GetString("crematorium-entity-storage-component-suicide-message"), entity);
2022-07-13 19:11:59 -04:00
}
}
Popup.PopupEntity(Loc.GetString("crematorium-entity-storage-component-suicide-message-others",
2022-07-15 20:10:52 +12:00
("victim", Identity.Entity(victim, EntityManager))),
victim,
Filter.PvsExcept(victim),
true,
PopupType.LargeCaution);
2022-07-13 19:11:59 -04:00
if (EntityStorage.CanInsert(victim, ent.Owner))
2022-07-13 19:11:59 -04:00
{
EntityStorage.CloseStorage(ent.Owner);
Standing.Down(victim, false);
EntityStorage.Insert(victim, ent.Owner);
2022-07-13 19:11:59 -04:00
}
else
{
EntityStorage.CloseStorage(ent.Owner);
Del(victim);
2022-07-13 19:11:59 -04:00
}
Cremate(ent.AsNullable());
args.Handled = true;
2022-07-13 19:11:59 -04:00
}
}