From 7c5b9c497d7ac48eeb3e9a600a03d8d95f0eaba1 Mon Sep 17 00:00:00 2001 From: astriloqua <129308840+astriloqua@users.noreply.github.com> Date: Tue, 22 Aug 2023 04:21:50 +0000 Subject: [PATCH] Toilet Fix (#18622) Toilet Fix (#18622) --- Content.Server/Toilet/ToiletSystem.cs | 32 +++++++++++++++---- .../Locale/en-US/toilet/toilet-component.ftl | 2 ++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Content.Server/Toilet/ToiletSystem.cs b/Content.Server/Toilet/ToiletSystem.cs index 91685640a7..e749260e94 100644 --- a/Content.Server/Toilet/ToiletSystem.cs +++ b/Content.Server/Toilet/ToiletSystem.cs @@ -15,6 +15,7 @@ using Content.Shared.Popups; using Content.Shared.Toilet; using Content.Shared.Tools; using Content.Shared.Tools.Components; +using Content.Shared.Verbs; using Robust.Shared.Audio; using Robust.Shared.Player; using Robust.Shared.Random; @@ -37,10 +38,11 @@ namespace Content.Server.Toilet SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnInteractUsing); - SubscribeLocalEvent(OnInteractHand, new []{typeof(SharedBuckleSystem)}); + SubscribeLocalEvent(OnInteractHand); SubscribeLocalEvent(OnExamine); SubscribeLocalEvent(OnSuicide); SubscribeLocalEvent(OnToiletPried); + SubscribeLocalEvent>(OnToggleSeatVerb); } private void OnSuicide(EntityUid uid, ToiletComponent component, SuicideEvent args) @@ -123,13 +125,26 @@ namespace Content.Server.Toilet } } - // just want to up/down seat? - // check that nobody seats on seat right now - if (TryComp(uid, out var strap) && strap.BuckledEntities.Count != 0) + args.Handled = true; + } + + private void OnToggleSeatVerb(EntityUid uid, ToiletComponent component, GetVerbsEvent args) + { + if (!args.CanInteract || !args.CanAccess || !CanToggle(uid)) return; - ToggleToiletSeat(uid, component); - args.Handled = true; + var alterToiletSeatText = component.IsSeatUp ? Loc.GetString("toilet-seat-close") : Loc.GetString("toilet-seat-open"); + + var verb = new AlternativeVerb() + { + Act = () => { + if (CanToggle(uid)) + ToggleToiletSeat(uid, component); + }, + Text = alterToiletSeatText + }; + + args.Verbs.Add(verb); } private void OnExamine(EntityUid uid, ToiletComponent component, ExaminedEvent args) @@ -153,6 +168,11 @@ namespace Content.Server.Toilet UpdateSprite(uid, toilet); } + public bool CanToggle(EntityUid uid) + { + return TryComp(uid, out var strap) && strap.BuckledEntities.Count == 0; + } + public void ToggleToiletSeat(EntityUid uid, ToiletComponent? component = null) { if (!Resolve(uid, ref component)) diff --git a/Resources/Locale/en-US/toilet/toilet-component.ftl b/Resources/Locale/en-US/toilet/toilet-component.ftl index 2cbfdfbff1..7807759e42 100644 --- a/Resources/Locale/en-US/toilet/toilet-component.ftl +++ b/Resources/Locale/en-US/toilet/toilet-component.ftl @@ -5,3 +5,5 @@ toilet-component-suicide-head-message-others = {CAPITALIZE(THE($victim))} sticks toilet-component-suicide-head-message = You stick your head into {THE($owner)} and flush it! toilet-component-suicide-message-others = {CAPITALIZE(THE($victim))} bashes themselves with {THE($owner)}! toilet-component-suicide-message = You bash yourself with {THE($owner)}! +toilet-seat-close = Close Seat +toilet-seat-open = Open Seat