Files

52 lines
1.7 KiB
C#
Raw Permalink Normal View History

using Content.Shared.Morgue;
2023-05-29 10:44:11 +10:00
using Content.Shared.Morgue.Components;
using Content.Shared.Storage.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Timing;
2022-07-13 19:11:59 -04:00
namespace Content.Server.Morgue;
public sealed class MorgueSystem : SharedMorgueSystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
2022-07-13 19:11:59 -04:00
public override void Initialize()
{
2022-07-13 19:11:59 -04:00
base.Initialize();
SubscribeLocalEvent<MorgueComponent, MapInitEvent>(OnMapInit);
2022-07-13 19:11:59 -04:00
}
private void OnMapInit(Entity<MorgueComponent> ent, ref MapInitEvent args)
2022-07-13 19:11:59 -04:00
{
ent.Comp.NextBeep = _timing.CurTime + ent.Comp.NextBeep;
2022-07-13 19:11:59 -04:00
}
2022-07-13 19:11:59 -04:00
/// <summary>
/// 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
var curTime = _timing.CurTime;
var query = EntityQueryEnumerator<MorgueComponent, EntityStorageComponent, AppearanceComponent>();
while (query.MoveNext(out var uid, out var comp, out var storage, out var appearance))
{
if (curTime < comp.NextBeep)
2022-07-13 19:11:59 -04:00
continue;
2022-07-14 17:25:44 +12:00
comp.NextBeep += comp.BeepTime;
CheckContents(uid, comp, storage);
if (comp.DoSoulBeep && _appearance.TryGetData<MorgueContents>(uid, MorgueVisuals.Contents, out var contents, appearance) && contents == MorgueContents.HasSoul)
{
_audio.PlayPvs(comp.OccupantHasSoulAlarmSound, uid);
}
}
}
}