refactor toilet (#15406)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -25,11 +25,11 @@ namespace Content.Server.Toilet
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly BodySystem _bodySystem = default!;
|
||||
[Dependency] private readonly BodySystem _body = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SecretStashSystem _secretStash = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedToolSystem _tool = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -49,16 +49,17 @@ namespace Content.Server.Toilet
|
||||
return;
|
||||
|
||||
// Check that victim has a head
|
||||
if (EntityManager.TryGetComponent<BodyComponent>(args.Victim, out var body) &&
|
||||
_bodySystem.BodyHasChildOfType(args.Victim, BodyPartType.Head, body))
|
||||
// FIXME: since suiciding turns you into a ghost immediately, both messages are seen, not sure how this can be fixed
|
||||
if (TryComp<BodyComponent>(args.Victim, out var body) &&
|
||||
_body.BodyHasChildOfType(args.Victim, BodyPartType.Head, body))
|
||||
{
|
||||
var othersMessage = Loc.GetString("toilet-component-suicide-head-message-others",
|
||||
("victim", Identity.Entity(args.Victim, EntityManager)), ("owner", uid));
|
||||
_popupSystem.PopupEntity(othersMessage, uid, Filter.PvsExcept(args.Victim), true, PopupType.MediumCaution);
|
||||
_popup.PopupEntity(othersMessage, uid, Filter.PvsExcept(args.Victim), true, PopupType.MediumCaution);
|
||||
|
||||
var selfMessage = Loc.GetString("toilet-component-suicide-head-message",
|
||||
("owner", uid));
|
||||
_popupSystem.PopupEntity(selfMessage, uid, args.Victim, PopupType.LargeCaution);
|
||||
_popup.PopupEntity(selfMessage, uid, args.Victim, PopupType.LargeCaution);
|
||||
|
||||
args.SetHandled(SuicideKind.Asphyxiation);
|
||||
}
|
||||
@@ -66,11 +67,11 @@ namespace Content.Server.Toilet
|
||||
{
|
||||
var othersMessage = Loc.GetString("toilet-component-suicide-message-others",
|
||||
("victim", Identity.Entity(args.Victim, EntityManager)), ("owner", uid));
|
||||
_popupSystem.PopupEntity(othersMessage, uid, Filter.PvsExcept(uid), true, PopupType.MediumCaution);
|
||||
_popup.PopupEntity(othersMessage, uid, Filter.PvsExcept(uid), true, PopupType.MediumCaution);
|
||||
|
||||
var selfMessage = Loc.GetString("toilet-component-suicide-message",
|
||||
("owner", uid));
|
||||
_popupSystem.PopupEntity(selfMessage, uid, args.Victim, PopupType.LargeCaution);
|
||||
_popup.PopupEntity(selfMessage, uid, args.Victim, PopupType.LargeCaution);
|
||||
|
||||
args.SetHandled(SuicideKind.Blunt);
|
||||
}
|
||||
@@ -78,7 +79,7 @@ namespace Content.Server.Toilet
|
||||
|
||||
private void OnInit(EntityUid uid, ToiletComponent component, ComponentInit args)
|
||||
{
|
||||
EntityManager.EnsureComponent<SecretStashComponent>(uid);
|
||||
EnsureComp<SecretStashComponent>(uid);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, ToiletComponent component, MapInitEvent args)
|
||||
@@ -94,7 +95,7 @@ namespace Content.Server.Toilet
|
||||
return;
|
||||
|
||||
// are player trying place or lift of cistern lid?
|
||||
if (_toolSystem.UseTool(args.Used, args.User, uid, component.PryLidTime, component.PryingQuality, new ToiletPryDoAfterEvent()))
|
||||
if (_tool.UseTool(args.Used, args.User, uid, component.PryLidTime, component.PryingQuality, new ToiletPryDoAfterEvent()))
|
||||
{
|
||||
args.Handled = true;
|
||||
}
|
||||
@@ -124,11 +125,8 @@ namespace Content.Server.Toilet
|
||||
|
||||
// just want to up/down seat?
|
||||
// check that nobody seats on seat right now
|
||||
if (EntityManager.TryGetComponent(uid, out StrapComponent? strap))
|
||||
{
|
||||
if (strap.BuckledEntities.Count != 0)
|
||||
return;
|
||||
}
|
||||
if (TryComp<StrapComponent>(uid, out var strap) && strap.BuckledEntities.Count != 0)
|
||||
return;
|
||||
|
||||
ToggleToiletSeat(uid, component);
|
||||
args.Handled = true;
|
||||
@@ -167,7 +165,7 @@ namespace Content.Server.Toilet
|
||||
|
||||
private void UpdateSprite(EntityUid uid, ToiletComponent component)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
|
||||
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
return;
|
||||
|
||||
_appearance.SetData(uid, ToiletVisuals.LidOpen, component.LidOpen, appearance);
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Toilet
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum ToiletVisuals
|
||||
{
|
||||
LidOpen,
|
||||
SeatUp
|
||||
}
|
||||
}
|
||||
10
Content.Shared/Toilet/ToiletVisuals.cs
Normal file
10
Content.Shared/Toilet/ToiletVisuals.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Toilet;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum ToiletVisuals
|
||||
{
|
||||
LidOpen,
|
||||
SeatUp
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
## ToiletComponent
|
||||
|
||||
toilet-component-on-examine-found-hidden-item = There is [color=darkgreen]something[/color] inside cistern!
|
||||
toilet-component-on-examine-found-hidden-item = There is something inside of the cistern!
|
||||
toilet-component-suicide-head-message-others = {CAPITALIZE(THE($victim))} sticks their head into {THE($owner)} and flushes 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)}!
|
||||
|
||||
Reference in New Issue
Block a user