Toilet fixes (#9609)
This commit is contained in:
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
25
Content.Client/Toilet/ToiletVisualsSystem.cs
Normal file
25
Content.Client/Toilet/ToiletVisualsSystem.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,6 +35,8 @@ namespace Content.Server.Buckle.Systems
|
|||||||
|
|
||||||
private void OnInteractHand(EntityUid uid, StrapComponent component, InteractHandEvent args)
|
private void OnInteractHand(EntityUid uid, StrapComponent component, InteractHandEvent args)
|
||||||
{
|
{
|
||||||
|
if (args.Handled) return;
|
||||||
|
|
||||||
if (!TryComp<BuckleComponent>(args.User, out var buckle))
|
if (!TryComp<BuckleComponent>(args.User, out var buckle))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Content.Server.Toilet;
|
|
||||||
using Content.Shared.Construction;
|
using Content.Shared.Construction;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.Toilet;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
namespace Content.Server.Construction.Conditions
|
namespace Content.Server.Construction.Conditions
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Server.Buckle.Components;
|
using Content.Server.Buckle.Components;
|
||||||
|
using Content.Server.Buckle.Systems;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Storage.Components;
|
using Content.Server.Storage.Components;
|
||||||
using Content.Server.Storage.EntitySystems;
|
using Content.Server.Storage.EntitySystems;
|
||||||
@@ -31,7 +32,7 @@ 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);
|
SubscribeLocalEvent<ToiletComponent, InteractHandEvent>(OnInteractHand, new []{typeof(StrapSystem)});
|
||||||
SubscribeLocalEvent<ToiletComponent, ExaminedEvent>(OnExamine);
|
SubscribeLocalEvent<ToiletComponent, ExaminedEvent>(OnExamine);
|
||||||
SubscribeLocalEvent<ToiletComponent, SuicideEvent>(OnSuicide);
|
SubscribeLocalEvent<ToiletComponent, SuicideEvent>(OnSuicide);
|
||||||
SubscribeLocalEvent<ToiletPryFinished>(OnToiletPried);
|
SubscribeLocalEvent<ToiletPryFinished>(OnToiletPried);
|
||||||
@@ -184,11 +185,8 @@ namespace Content.Server.Toilet
|
|||||||
UpdateSprite(uid, component);
|
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))
|
if (!EntityManager.TryGetComponent(uid,out AppearanceComponent? appearance))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using Content.Shared.Sound;
|
|||||||
using Content.Shared.Tools;
|
using Content.Shared.Tools;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
|
||||||
namespace Content.Server.Toilet
|
namespace Content.Shared.Toilet
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed class ToiletComponent : Component
|
public sealed class ToiletComponent : Component
|
||||||
@@ -22,13 +22,12 @@
|
|||||||
solutions:
|
solutions:
|
||||||
toilet:
|
toilet:
|
||||||
maxVol: 250
|
maxVol: 250
|
||||||
|
- type: Transform
|
||||||
|
anchored: true
|
||||||
- type: Construction
|
- type: Construction
|
||||||
graph: Toilet
|
graph: Toilet
|
||||||
node: toilet
|
node: toilet
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
|
||||||
- type: ToiletVisualizer
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: ToiletDirtyWater
|
id: ToiletDirtyWater
|
||||||
parent: ToiletEmpty
|
parent: ToiletEmpty
|
||||||
|
|||||||
Reference in New Issue
Block a user