Toilet fixes (#9609)

This commit is contained in:
wrexbe
2022-07-11 23:04:33 -07:00
committed by GitHub
parent 21a56f4b80
commit a1c4f10061
7 changed files with 34 additions and 35 deletions

View File

@@ -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<IEntityManager>();
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);
}
}
}

View File

@@ -0,0 +1,25 @@
using Content.Shared.Toilet;
using Robust.Client.GameObjects;
namespace Content.Client.Toilet;
public sealed class ToiletVisualsSystem : VisualizerSystem<ToiletComponent>
{
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);
}
}

View File

@@ -35,6 +35,8 @@ namespace Content.Server.Buckle.Systems
private void OnInteractHand(EntityUid uid, StrapComponent component, InteractHandEvent args)
{
if (args.Handled) return;
if (!TryComp<BuckleComponent>(args.User, out var buckle))
return;

View File

@@ -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

View File

@@ -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<ToiletComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<ToiletComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<ToiletComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<ToiletComponent, InteractHandEvent>(OnInteractHand);
SubscribeLocalEvent<ToiletComponent, InteractHandEvent>(OnInteractHand, new []{typeof(StrapSystem)});
SubscribeLocalEvent<ToiletComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<ToiletComponent, SuicideEvent>(OnSuicide);
SubscribeLocalEvent<ToiletPryFinished>(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;

View File

@@ -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

View File

@@ -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