2021-10-05 14:29:03 +11:00
|
|
|
using Content.Server.Morgue.Components;
|
2022-04-08 17:17:25 -04:00
|
|
|
using Content.Shared.Morgue;
|
|
|
|
|
using Content.Shared.Examine;
|
2021-11-28 14:56:53 +01:00
|
|
|
using Content.Shared.Database;
|
2021-10-05 14:29:03 +11:00
|
|
|
using Content.Shared.Verbs;
|
2020-10-28 22:51:43 +00:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Morgue
|
2020-10-28 22:51:43 +00:00
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class MorgueSystem : EntitySystem
|
2020-10-28 22:51:43 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private float _accumulatedFrameTime;
|
|
|
|
|
|
2021-10-05 14:29:03 +11:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
2022-02-10 15:30:59 +13:00
|
|
|
SubscribeLocalEvent<CrematoriumEntityStorageComponent, GetVerbsEvent<AlternativeVerb>>(AddCremateVerb);
|
2022-04-08 17:17:25 -04:00
|
|
|
SubscribeLocalEvent<CrematoriumEntityStorageComponent, ExaminedEvent>(OnCrematoriumExamined);
|
|
|
|
|
SubscribeLocalEvent<MorgueEntityStorageComponent, ExaminedEvent>(OnMorgueExamined);
|
2021-10-05 14:29:03 +11:00
|
|
|
}
|
|
|
|
|
|
2022-02-10 15:30:59 +13:00
|
|
|
private void AddCremateVerb(EntityUid uid, CrematoriumEntityStorageComponent component, GetVerbsEvent<AlternativeVerb> args)
|
2021-10-05 14:29:03 +11:00
|
|
|
{
|
|
|
|
|
if (!args.CanAccess || !args.CanInteract || component.Cooking || component.Open)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-02-10 15:30:59 +13:00
|
|
|
AlternativeVerb verb = new();
|
2021-10-05 14:29:03 +11:00
|
|
|
verb.Text = Loc.GetString("cremate-verb-get-data-text");
|
|
|
|
|
// TODO VERB ICON add flame/burn symbol?
|
|
|
|
|
verb.Act = () => component.TryCremate();
|
2021-11-23 23:00:16 +13:00
|
|
|
verb.Impact = LogImpact.Medium; // could be a body? or evidence? I dunno.
|
2021-10-05 14:29:03 +11:00
|
|
|
args.Verbs.Add(verb);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-08 17:17:25 -04:00
|
|
|
private void OnCrematoriumExamined(EntityUid uid, CrematoriumEntityStorageComponent component, ExaminedEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (args.IsInDetailsRange)
|
|
|
|
|
{
|
|
|
|
|
if (appearance.TryGetData(CrematoriumVisuals.Burning, out bool isBurning) && isBurning)
|
|
|
|
|
{
|
|
|
|
|
args.PushMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-is-burning", ("owner", uid)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents)
|
|
|
|
|
{
|
|
|
|
|
args.PushMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-has-contents"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
args.PushMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-empty"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnMorgueExamined(EntityUid uid, MorgueEntityStorageComponent component, ExaminedEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!TryComp<AppearanceComponent>(uid, out var appearance)) return;
|
|
|
|
|
|
|
|
|
|
if (args.IsInDetailsRange)
|
|
|
|
|
{
|
|
|
|
|
if (appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul)
|
|
|
|
|
{
|
|
|
|
|
args.PushMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-soul"));
|
|
|
|
|
}
|
|
|
|
|
else if (appearance.TryGetData(MorgueVisuals.HasMob, out bool hasMob) && hasMob)
|
|
|
|
|
{
|
|
|
|
|
args.PushMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-no-soul"));
|
|
|
|
|
}
|
|
|
|
|
else if (appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents)
|
|
|
|
|
{
|
|
|
|
|
args.PushMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-has-contents"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
args.PushMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-empty"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-28 22:51:43 +00:00
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
{
|
|
|
|
|
_accumulatedFrameTime += frameTime;
|
|
|
|
|
|
|
|
|
|
if (_accumulatedFrameTime >= 10)
|
|
|
|
|
{
|
2021-10-18 14:58:34 +02:00
|
|
|
foreach (var morgue in EntityManager.EntityQuery<MorgueEntityStorageComponent>())
|
2020-10-28 22:51:43 +00:00
|
|
|
{
|
|
|
|
|
morgue.Update();
|
|
|
|
|
}
|
|
|
|
|
_accumulatedFrameTime -= 10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|