Toilet Fix (#18622)

Toilet Fix (#18622)
This commit is contained in:
astriloqua
2023-08-22 04:21:50 +00:00
committed by GitHub
parent 1ec014cf39
commit 7c5b9c497d
2 changed files with 28 additions and 6 deletions

View File

@@ -15,6 +15,7 @@ using Content.Shared.Popups;
using Content.Shared.Toilet; using Content.Shared.Toilet;
using Content.Shared.Tools; using Content.Shared.Tools;
using Content.Shared.Tools.Components; using Content.Shared.Tools.Components;
using Content.Shared.Verbs;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Random; using Robust.Shared.Random;
@@ -37,10 +38,11 @@ namespace Content.Server.Toilet
SubscribeLocalEvent<ToiletComponent, ComponentInit>(OnInit); SubscribeLocalEvent<ToiletComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<ToiletComponent, MapInitEvent>(OnMapInit); SubscribeLocalEvent<ToiletComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<ToiletComponent, InteractUsingEvent>(OnInteractUsing); SubscribeLocalEvent<ToiletComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<ToiletComponent, InteractHandEvent>(OnInteractHand, new []{typeof(SharedBuckleSystem)}); SubscribeLocalEvent<ToiletComponent, InteractHandEvent>(OnInteractHand);
SubscribeLocalEvent<ToiletComponent, ExaminedEvent>(OnExamine); SubscribeLocalEvent<ToiletComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<ToiletComponent, SuicideEvent>(OnSuicide); SubscribeLocalEvent<ToiletComponent, SuicideEvent>(OnSuicide);
SubscribeLocalEvent<ToiletComponent, ToiletPryDoAfterEvent>(OnToiletPried); SubscribeLocalEvent<ToiletComponent, ToiletPryDoAfterEvent>(OnToiletPried);
SubscribeLocalEvent<ToiletComponent, GetVerbsEvent<AlternativeVerb>>(OnToggleSeatVerb);
} }
private void OnSuicide(EntityUid uid, ToiletComponent component, SuicideEvent args) private void OnSuicide(EntityUid uid, ToiletComponent component, SuicideEvent args)
@@ -123,13 +125,26 @@ namespace Content.Server.Toilet
} }
} }
// just want to up/down seat? args.Handled = true;
// check that nobody seats on seat right now }
if (TryComp<StrapComponent>(uid, out var strap) && strap.BuckledEntities.Count != 0)
private void OnToggleSeatVerb(EntityUid uid, ToiletComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || !args.CanAccess || !CanToggle(uid))
return; return;
ToggleToiletSeat(uid, component); var alterToiletSeatText = component.IsSeatUp ? Loc.GetString("toilet-seat-close") : Loc.GetString("toilet-seat-open");
args.Handled = true;
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) private void OnExamine(EntityUid uid, ToiletComponent component, ExaminedEvent args)
@@ -153,6 +168,11 @@ namespace Content.Server.Toilet
UpdateSprite(uid, toilet); UpdateSprite(uid, toilet);
} }
public bool CanToggle(EntityUid uid)
{
return TryComp<StrapComponent>(uid, out var strap) && strap.BuckledEntities.Count == 0;
}
public void ToggleToiletSeat(EntityUid uid, ToiletComponent? component = null) public void ToggleToiletSeat(EntityUid uid, ToiletComponent? component = null)
{ {
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))

View File

@@ -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-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-others = {CAPITALIZE(THE($victim))} bashes themselves with {THE($owner)}!
toilet-component-suicide-message = You bash yourself with {THE($owner)}! toilet-component-suicide-message = You bash yourself with {THE($owner)}!
toilet-seat-close = Close Seat
toilet-seat-open = Open Seat