2022-10-23 00:46:28 +02:00
|
|
|
using Content.Shared.Morgue;
|
2023-05-29 10:44:11 +10:00
|
|
|
using Content.Shared.Morgue.Components;
|
2025-08-22 01:49:50 +02:00
|
|
|
using Content.Shared.Storage.Components;
|
2023-11-27 22:12:34 +11:00
|
|
|
using Robust.Shared.Audio.Systems;
|
2025-08-22 01:49:50 +02:00
|
|
|
using Robust.Shared.Timing;
|
2020-10-28 22:51:43 +00:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
namespace Content.Server.Morgue;
|
|
|
|
|
|
2025-08-22 01:49:50 +02:00
|
|
|
public sealed class MorgueSystem : SharedMorgueSystem
|
2020-10-28 22:51:43 +00:00
|
|
|
{
|
2025-08-22 01:49:50 +02:00
|
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
2022-09-19 19:59:04 -04:00
|
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
2025-08-22 01:49:50 +02:00
|
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
2022-09-19 19:59:04 -04:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
public override void Initialize()
|
2020-10-28 22:51:43 +00:00
|
|
|
{
|
2022-07-13 19:11:59 -04:00
|
|
|
base.Initialize();
|
2022-05-12 05:05:16 -07:00
|
|
|
|
2025-08-22 01:49:50 +02:00
|
|
|
SubscribeLocalEvent<MorgueComponent, MapInitEvent>(OnMapInit);
|
2022-07-13 19:11:59 -04:00
|
|
|
}
|
2022-05-12 05:05:16 -07:00
|
|
|
|
2025-08-22 01:49:50 +02:00
|
|
|
private void OnMapInit(Entity<MorgueComponent> ent, ref MapInitEvent args)
|
2022-07-13 19:11:59 -04:00
|
|
|
{
|
2025-08-22 01:49:50 +02:00
|
|
|
ent.Comp.NextBeep = _timing.CurTime + ent.Comp.NextBeep;
|
2022-07-13 19:11:59 -04:00
|
|
|
}
|
2022-05-12 05:05:16 -07:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
/// <summary>
|
2025-08-22 01:49:50 +02:00
|
|
|
/// Handles the periodic beeping that morgues do when a live body is inside.
|
2022-07-13 19:11:59 -04:00
|
|
|
/// </summary>
|
|
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
{
|
|
|
|
|
base.Update(frameTime);
|
2022-04-08 17:17:25 -04:00
|
|
|
|
2025-08-22 01:49:50 +02:00
|
|
|
var curTime = _timing.CurTime;
|
2023-10-19 12:34:31 -07:00
|
|
|
var query = EntityQueryEnumerator<MorgueComponent, EntityStorageComponent, AppearanceComponent>();
|
|
|
|
|
while (query.MoveNext(out var uid, out var comp, out var storage, out var appearance))
|
2020-10-28 22:51:43 +00:00
|
|
|
{
|
2025-08-22 01:49:50 +02:00
|
|
|
if (curTime < comp.NextBeep)
|
2022-07-13 19:11:59 -04:00
|
|
|
continue;
|
2022-07-14 17:25:44 +12:00
|
|
|
|
2025-08-22 01:49:50 +02:00
|
|
|
comp.NextBeep += comp.BeepTime;
|
|
|
|
|
|
|
|
|
|
CheckContents(uid, comp, storage);
|
2020-10-28 22:51:43 +00:00
|
|
|
|
2023-10-19 12:34:31 -07:00
|
|
|
if (comp.DoSoulBeep && _appearance.TryGetData<MorgueContents>(uid, MorgueVisuals.Contents, out var contents, appearance) && contents == MorgueContents.HasSoul)
|
2020-10-28 22:51:43 +00:00
|
|
|
{
|
2023-10-19 12:34:31 -07:00
|
|
|
_audio.PlayPvs(comp.OccupantHasSoulAlarmSound, uid);
|
2020-10-28 22:51:43 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|