From a1c4f10061d53a30f02e5d89f95d3a5f91d12bc8 Mon Sep 17 00:00:00 2001 From: wrexbe <81056464+wrexbe@users.noreply.github.com> Date: Mon, 11 Jul 2022 23:04:33 -0700 Subject: [PATCH] Toilet fixes (#9609) --- Content.Client/Toilet/ToiletVisualizer.cs | 25 ------------------- Content.Client/Toilet/ToiletVisualsSystem.cs | 25 +++++++++++++++++++ Content.Server/Buckle/Systems/StrapSystem.cs | 2 ++ .../Conditions/ToiletLidClosed.cs | 2 +- Content.Server/Toilet/ToiletSystem.cs | 8 +++--- .../Toilet/ToiletComponent.cs | 2 +- .../Entities/Structures/Furniture/toilet.yml | 5 ++-- 7 files changed, 34 insertions(+), 35 deletions(-) delete mode 100644 Content.Client/Toilet/ToiletVisualizer.cs create mode 100644 Content.Client/Toilet/ToiletVisualsSystem.cs rename {Content.Server => Content.Shared}/Toilet/ToiletComponent.cs (95%) diff --git a/Content.Client/Toilet/ToiletVisualizer.cs b/Content.Client/Toilet/ToiletVisualizer.cs deleted file mode 100644 index 2a83e3fb94..0000000000 --- a/Content.Client/Toilet/ToiletVisualizer.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Content.Shared.Toilet; -using Robust.Client.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; - -namespace Content.Client.Toilet -{ - public sealed class ToiletVisualizer : AppearanceVisualizer - { - public override void OnChangeData(AppearanceComponent component) - { - base.OnChangeData(component); - - var entities = IoCManager.Resolve(); - if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite)) return; - - if (!component.TryGetData(ToiletVisuals.LidOpen, out bool lidOpen)) lidOpen = false; - if (!component.TryGetData(ToiletVisuals.SeatUp, out bool seatUp)) seatUp = false; - - var state = $"{(lidOpen ? "open" : "closed")}_toilet_{(seatUp ? "seat_up" : "seat_down")}"; - - sprite.LayerSetState(0, state); - } - } -} diff --git a/Content.Client/Toilet/ToiletVisualsSystem.cs b/Content.Client/Toilet/ToiletVisualsSystem.cs new file mode 100644 index 0000000000..f5b7aa5f9c --- /dev/null +++ b/Content.Client/Toilet/ToiletVisualsSystem.cs @@ -0,0 +1,25 @@ +using Content.Shared.Toilet; +using Robust.Client.GameObjects; + +namespace Content.Client.Toilet; + +public sealed class ToiletVisualsSystem : VisualizerSystem +{ + protected override void OnAppearanceChange(EntityUid uid, ToiletComponent component, ref AppearanceChangeEvent args) + { + if (args.Sprite == null) return; + + args.Component.TryGetData(ToiletVisuals.LidOpen, out bool lidOpen); + args.Component.TryGetData(ToiletVisuals.SeatUp, out bool seatUp); + + var state = (lidOpen, seatUp) switch + { + (false, false) => "closed_toilet_seat_down", + (false, true) => "closed_toilet_seat_up", + (true, false) => "open_toilet_seat_down", + (true, true) => "open_toilet_seat_up" + }; + + args.Sprite.LayerSetState(0, state); + } +} diff --git a/Content.Server/Buckle/Systems/StrapSystem.cs b/Content.Server/Buckle/Systems/StrapSystem.cs index 98b52c7a2a..b3087e0db9 100644 --- a/Content.Server/Buckle/Systems/StrapSystem.cs +++ b/Content.Server/Buckle/Systems/StrapSystem.cs @@ -35,6 +35,8 @@ namespace Content.Server.Buckle.Systems private void OnInteractHand(EntityUid uid, StrapComponent component, InteractHandEvent args) { + if (args.Handled) return; + if (!TryComp(args.User, out var buckle)) return; diff --git a/Content.Server/Construction/Conditions/ToiletLidClosed.cs b/Content.Server/Construction/Conditions/ToiletLidClosed.cs index af16af6529..93e7ee2f74 100644 --- a/Content.Server/Construction/Conditions/ToiletLidClosed.cs +++ b/Content.Server/Construction/Conditions/ToiletLidClosed.cs @@ -1,6 +1,6 @@ -using Content.Server.Toilet; using Content.Shared.Construction; using Content.Shared.Examine; +using Content.Shared.Toilet; using JetBrains.Annotations; namespace Content.Server.Construction.Conditions diff --git a/Content.Server/Toilet/ToiletSystem.cs b/Content.Server/Toilet/ToiletSystem.cs index 93576a4764..76340e1ee7 100644 --- a/Content.Server/Toilet/ToiletSystem.cs +++ b/Content.Server/Toilet/ToiletSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Buckle.Components; +using Content.Server.Buckle.Systems; using Content.Server.Popups; using Content.Server.Storage.Components; using Content.Server.Storage.EntitySystems; @@ -31,7 +32,7 @@ namespace Content.Server.Toilet SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnInteractUsing); - SubscribeLocalEvent(OnInteractHand); + SubscribeLocalEvent(OnInteractHand, new []{typeof(StrapSystem)}); SubscribeLocalEvent(OnExamine); SubscribeLocalEvent(OnSuicide); SubscribeLocalEvent(OnToiletPried); @@ -184,11 +185,8 @@ namespace Content.Server.Toilet UpdateSprite(uid, component); } - private void UpdateSprite(EntityUid uid, ToiletComponent? component = null) + private void UpdateSprite(EntityUid uid, ToiletComponent component) { - if (!Resolve(uid, ref component)) - return; - if (!EntityManager.TryGetComponent(uid,out AppearanceComponent? appearance)) return; diff --git a/Content.Server/Toilet/ToiletComponent.cs b/Content.Shared/Toilet/ToiletComponent.cs similarity index 95% rename from Content.Server/Toilet/ToiletComponent.cs rename to Content.Shared/Toilet/ToiletComponent.cs index 7d33b6fc48..0404e70eb9 100644 --- a/Content.Server/Toilet/ToiletComponent.cs +++ b/Content.Shared/Toilet/ToiletComponent.cs @@ -2,7 +2,7 @@ using Content.Shared.Sound; using Content.Shared.Tools; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; -namespace Content.Server.Toilet +namespace Content.Shared.Toilet { [RegisterComponent] public sealed class ToiletComponent : Component diff --git a/Resources/Prototypes/Entities/Structures/Furniture/toilet.yml b/Resources/Prototypes/Entities/Structures/Furniture/toilet.yml index 593a1efc62..94f8711e02 100644 --- a/Resources/Prototypes/Entities/Structures/Furniture/toilet.yml +++ b/Resources/Prototypes/Entities/Structures/Furniture/toilet.yml @@ -22,13 +22,12 @@ solutions: toilet: maxVol: 250 + - type: Transform + anchored: true - type: Construction graph: Toilet node: toilet - type: Appearance - visuals: - - type: ToiletVisualizer - - type: entity id: ToiletDirtyWater parent: ToiletEmpty