feat: Medbay cryo pods (#11349)
Fixes https://github.com/space-wizards/space-station-14/issues/11245
This commit is contained in:
83
Content.Client/Medical/Cryogenics/CryoPodSystem.cs
Normal file
83
Content.Client/Medical/Cryogenics/CryoPodSystem.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.Medical.Cryogenics;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Client.GameObjects;
|
||||
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
|
||||
|
||||
namespace Content.Client.Medical.Cryogenics;
|
||||
|
||||
public sealed class CryoPodSystem: SharedCryoPodSystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CryoPodComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<CryoPodComponent, GetVerbsEvent<AlternativeVerb>>(AddAlternativeVerbs);
|
||||
SubscribeLocalEvent<CryoPodComponent, GotEmaggedEvent>(OnEmagged);
|
||||
SubscribeLocalEvent<CryoPodComponent, DoInsertCryoPodEvent>(DoInsertCryoPod);
|
||||
SubscribeLocalEvent<CryoPodComponent, DoInsertCancelledCryoPodEvent>(DoInsertCancelCryoPod);
|
||||
SubscribeLocalEvent<CryoPodComponent, CryoPodPryFinished>(OnCryoPodPryFinished);
|
||||
SubscribeLocalEvent<CryoPodComponent, CryoPodPryInterrupted>(OnCryoPodPryInterrupted);
|
||||
|
||||
SubscribeLocalEvent<CryoPodComponent, AppearanceChangeEvent>(OnAppearanceChange);
|
||||
SubscribeLocalEvent<InsideCryoPodComponent, ComponentStartup>(OnCryoPodInsertion);
|
||||
SubscribeLocalEvent<InsideCryoPodComponent, ComponentRemove>(OnCryoPodRemoval);
|
||||
}
|
||||
|
||||
private void OnCryoPodInsertion(EntityUid uid, InsideCryoPodComponent component, ComponentStartup args)
|
||||
{
|
||||
if (!TryComp<SpriteComponent>(uid, out var spriteComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
component.PreviousOffset = spriteComponent.Offset;
|
||||
spriteComponent.Offset = new Vector2(0, 1);
|
||||
}
|
||||
|
||||
private void OnCryoPodRemoval(EntityUid uid, InsideCryoPodComponent component, ComponentRemove args)
|
||||
{
|
||||
if (!TryComp<SpriteComponent>(uid, out var spriteComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spriteComponent.Offset = component.PreviousOffset;
|
||||
}
|
||||
|
||||
private void OnAppearanceChange(EntityUid uid, SharedCryoPodComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.Component.TryGetData(SharedCryoPodComponent.CryoPodVisuals.ContainsEntity, out bool isOpen)
|
||||
|| !args.Component.TryGetData(SharedCryoPodComponent.CryoPodVisuals.IsOn, out bool isOn))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isOpen)
|
||||
{
|
||||
args.Sprite.LayerSetState(CryoPodVisualLayers.Base, "pod-open");
|
||||
args.Sprite.LayerSetVisible(CryoPodVisualLayers.Cover, false);
|
||||
args.Sprite.DrawDepth = (int) DrawDepth.Objects;
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Sprite.DrawDepth = (int) DrawDepth.Mobs;
|
||||
args.Sprite.LayerSetState(CryoPodVisualLayers.Base, isOn ? "pod-on" : "pod-off");
|
||||
args.Sprite.LayerSetState(CryoPodVisualLayers.Cover, isOn ? "cover-on" : "cover-off");
|
||||
args.Sprite.LayerSetVisible(CryoPodVisualLayers.Cover, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum CryoPodVisualLayers : byte
|
||||
{
|
||||
Base,
|
||||
Cover,
|
||||
}
|
||||
Reference in New Issue
Block a user