diff --git a/Content.Client/Morgue/Visualizers/MorgueVisualLayers.cs b/Content.Client/Morgue/Visualizers/MorgueVisualLayers.cs new file mode 100644 index 0000000000..5da5092add --- /dev/null +++ b/Content.Client/Morgue/Visualizers/MorgueVisualLayers.cs @@ -0,0 +1,7 @@ +namespace Content.Client.Morgue.Visualizers; + +public enum MorgueVisualLayers : byte +{ + Base, + Light, +} diff --git a/Content.Client/Morgue/Visualizers/MorgueVisualizerSystem.cs b/Content.Client/Morgue/Visualizers/MorgueVisualizerSystem.cs deleted file mode 100644 index 914fc00903..0000000000 --- a/Content.Client/Morgue/Visualizers/MorgueVisualizerSystem.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Content.Shared.Morgue; -using Content.Shared.Storage; -using Robust.Client.GameObjects; - -namespace Content.Client.Morgue.Visualizers; - -public sealed class MorgueVisualizerSystem : VisualizerSystem -{ - public override void Initialize() - { - base.Initialize(); - } - - protected override void OnAppearanceChange(EntityUid uid, MorgueVisualsComponent component, ref AppearanceChangeEvent args) - { - if (args.Sprite == null) - return; - - string? lightState = null; - if (args.Component.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul) - lightState = component.LightSoul; - else if (args.Component.TryGetData(MorgueVisuals.HasMob, out bool hasMob) && hasMob) - lightState = component.LightMob; - else if (args.Component.TryGetData(StorageVisuals.HasContents, out bool hasContents) && hasContents) - lightState = component.LightContents; - - if (lightState != null) - { - args.Sprite.LayerSetState(MorgueVisualLayers.Light, lightState); - args.Sprite.LayerSetVisible(MorgueVisualLayers.Light, true); - } - else - { - args.Sprite.LayerSetVisible(MorgueVisualLayers.Light, false); - } - } -} diff --git a/Content.Client/Morgue/Visualizers/MorgueVisualsComponent.cs b/Content.Client/Morgue/Visualizers/MorgueVisualsComponent.cs deleted file mode 100644 index 7e58c33821..0000000000 --- a/Content.Client/Morgue/Visualizers/MorgueVisualsComponent.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Content.Client.Morgue.Visualizers; - -[RegisterComponent] -public sealed class MorgueVisualsComponent : Component -{ - [DataField("lightContents", required: true)] - public string LightContents = default!; - [DataField("lightMob", required: true)] - public string LightMob = default!; - [DataField("lightSoul", required: true)] - public string LightSoul = default!; -} - -public enum MorgueVisualLayers : byte -{ - Base, - Light, -} diff --git a/Content.Server/Entry/IgnoredComponents.cs b/Content.Server/Entry/IgnoredComponents.cs index 01e1359458..daa15a1a0b 100644 --- a/Content.Server/Entry/IgnoredComponents.cs +++ b/Content.Server/Entry/IgnoredComponents.cs @@ -36,7 +36,6 @@ namespace Content.Server.Entry "AMEShieldingVisuals", "PipeColorVisuals", "FireVisuals", - "MorgueVisuals", "CrematoriumVisuals", }; } diff --git a/Content.Server/Morgue/MorgueSystem.cs b/Content.Server/Morgue/MorgueSystem.cs index 79eb0762eb..46fefabfc5 100644 --- a/Content.Server/Morgue/MorgueSystem.cs +++ b/Content.Server/Morgue/MorgueSystem.cs @@ -31,40 +31,48 @@ public sealed partial class MorgueSystem : EntitySystem if (!args.IsInDetailsRange) return; - 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(StorageVisuals.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")); + appearance.TryGetData(MorgueVisuals.Contents, out MorgueContents contents); + + var text = contents switch + { + MorgueContents.HasSoul => "morgue-entity-storage-component-on-examine-details-body-has-soul", + MorgueContents.HasContents => "morgue-entity-storage-component-on-examine-details-has-contents", + MorgueContents.HasMob => "morgue-entity-storage-component-on-examine-details-body-has-no-soul", + _ => "morgue-entity-storage-component-on-examine-details-empty" + }; + + args.PushMarkup(Loc.GetString(text)); } /// /// Updates data periodically in case something died/got deleted in the morgue. /// - private void CheckContents(EntityUid uid, MorgueComponent? morgue = null, EntityStorageComponent? storage = null) + private void CheckContents(EntityUid uid, MorgueComponent? morgue = null, EntityStorageComponent? storage = null, AppearanceComponent? app = null) { - if (!Resolve(uid, ref morgue, ref storage)) + if (!Resolve(uid, ref morgue, ref storage, ref app)) return; - var hasMob = false; - var hasSoul = false; + if (storage.Contents.ContainedEntities.Count == 0) + { + app.SetData(MorgueVisuals.Contents, MorgueContents.Empty); + return; + } + var hasMob = false; + foreach (var ent in storage.Contents.ContainedEntities) { if (!hasMob && HasComp(ent)) hasMob = true; - if (!hasSoul && TryComp(ent, out var actor) && actor.PlayerSession != null) - hasSoul = true; + + if (TryComp(ent, out var actor) && actor.PlayerSession != null) + { + app.SetData(MorgueVisuals.Contents, MorgueContents.HasSoul); + return; + } } - if (TryComp(uid, out var app)) - { - app.SetData(MorgueVisuals.HasMob, hasMob); - app.SetData(MorgueVisuals.HasSoul, hasSoul); - } + app.SetData(MorgueVisuals.Contents, hasMob ? MorgueContents.HasMob : MorgueContents.HasContents); } /// @@ -74,18 +82,18 @@ public sealed partial class MorgueSystem : EntitySystem { base.Update(frameTime); - foreach (var comp in EntityQuery()) + foreach (var (comp, storage, appearance) in EntityQuery()) { comp.AccumulatedFrameTime += frameTime; - CheckContents(comp.Owner, comp); + CheckContents(comp.Owner, comp, storage, appearance); if (comp.AccumulatedFrameTime < comp.BeepTime) continue; + comp.AccumulatedFrameTime -= comp.BeepTime; - if (comp.DoSoulBeep && TryComp(comp.Owner, out var appearance) && - appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul) + if (comp.DoSoulBeep && appearance.TryGetData(MorgueVisuals.Contents, out MorgueContents contents) && contents == MorgueContents.HasSoul) { SoundSystem.Play(comp.OccupantHasSoulAlarmSound.GetSound(), Filter.Pvs(comp.Owner), comp.Owner); } diff --git a/Content.Shared/Morgue/SharedMorgue.cs b/Content.Shared/Morgue/SharedMorgue.cs index 4563be36d7..28c202023c 100644 --- a/Content.Shared/Morgue/SharedMorgue.cs +++ b/Content.Shared/Morgue/SharedMorgue.cs @@ -3,14 +3,22 @@ using Robust.Shared.Serialization; namespace Content.Shared.Morgue; [Serializable, NetSerializable] -public enum MorgueVisuals +public enum MorgueVisuals : byte { - HasMob, - HasSoul, + Contents } [Serializable, NetSerializable] -public enum CrematoriumVisuals +public enum MorgueContents : byte +{ + Empty, + HasMob, + HasSoul, + HasContents, +} + +[Serializable, NetSerializable] +public enum CrematoriumVisuals : byte { Burning, } diff --git a/Resources/Prototypes/Entities/Structures/Storage/morgue.yml b/Resources/Prototypes/Entities/Structures/Storage/morgue.yml index 1eb005cfea..3328ac23a1 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/morgue.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/morgue.yml @@ -11,6 +11,7 @@ map: ["enum.MorgueVisualLayers.Base"] - state: morgue_tray offset: 0, -1 + visible: false map: ["enum.StorageVisualLayers.Door"] - state: morgue_nomob_light visible: false @@ -46,15 +47,24 @@ entity_storage: !type:Container morgue_tray: !type:ContainerSlot - type: Appearance + - type: GenericVisualizer visuals: - - type: StorageVisualizer - state: morgue_closed - state_alt: morgue_open - state_open: morgue_tray - - type: MorgueVisuals - lightContents: morgue_nomob_light - lightMob: morgue_nosoul_light - lightSoul: morgue_soul_light + enum.StorageVisuals.Open: + # basic open.close layer: + enum.MorgueVisualLayers.Base: + True: { state: morgue_open} + False: { state: morgue_closed} + # show/hide morgue tray: + enum.StorageVisualLayers.Door: + True: { visible: true} + False: { visible: false} + enum.MorgueVisuals.Contents: + # toggle contents light indicator: + enum.MorgueVisualLayers.Light: + Empty: {visible: false} + HasContents: {visible: true, state: morgue_nomob_light} + HasMob: {visible: true, state: morgue_nosoul_light} + HasSoul: {visible: true, state: morgue_soul_light} - type: Transform anchored: true - type: AntiRottingContainer