Fix Mailing Units (space-wizards/space-station-14#30174 + Other) (#2485)

# Description

_Upstream: space-wizards/space-station-14#30174_

This fixes mailing units so their UI works again alongside their
sprites. It also adds a convenience feature to reset the destination on
send since it can trip up players as it makes sense to put in an item
_then_ choose a location.

# Changelog

🆑
- fix: Mailing Unit UI is now fixed
- fix: Mailing Units' no longer use the wrong sprite when charging
- tweak: Mailing Units clear target on send or selecting the same target

---------

Co-authored-by: themias <89101928+themias@users.noreply.github.com>
This commit is contained in:
Carlen White
2025-06-28 15:00:37 -04:00
committed by Spatison
parent 373e2c8562
commit f4e9aaaaf3
3 changed files with 22 additions and 10 deletions

View File

@@ -153,7 +153,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
}
}
else if (state == VisualState.OverlayCharging)
sprite.LayerSetState(DisposalUnitVisualLayers.OverlayFlush, new RSI.StateId("disposal-charging"));
sprite.LayerSetState(DisposalUnitVisualLayers.OverlayFlush, chargingState);
else
_animationSystem.Stop(uid, AnimationKey);

View File

@@ -2,6 +2,7 @@ using Content.Shared.Disposal;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
namespace Content.Client.Disposal.UI
{
@@ -11,6 +12,8 @@ namespace Content.Client.Disposal.UI
[GenerateTypedNameReferences]
public sealed partial class MailingUnitWindow : DefaultWindow
{
public TimeSpan FullPressure;
public MailingUnitWindow()
{
RobustXamlLoader.Load(this);
@@ -26,6 +29,7 @@ namespace Content.Client.Disposal.UI
Title = Loc.GetString("ui-mailing-unit-window-title", ("tag", state.Tag ?? " "));
UnitState.Text = disposalState.UnitState;
FullPressure = disposalState.FullPressureTime;
var pressureReached = PressureBar.UpdatePressure(disposalState.FullPressureTime);
Power.Pressed = disposalState.Powered;
Engage.Pressed = disposalState.Engaged;
@@ -42,9 +46,10 @@ namespace Content.Client.Disposal.UI
return !disposalState.Powered || pressureReached;
}
public bool UpdatePressure(TimeSpan stateFullPressureTime)
protected override void FrameUpdate(FrameEventArgs args)
{
return PressureBar.UpdatePressure(stateFullPressureTime);
base.FrameUpdate(args);
PressureBar.UpdatePressure(FullPressure);
}
}
}

View File

@@ -9,6 +9,7 @@ using Content.Shared.Disposal;
using Content.Shared.Interaction;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Utility;
namespace Content.Server.Disposal.Mailing;
@@ -35,7 +36,7 @@ public sealed class MailingUnitSystem : EntitySystem
SubscribeLocalEvent<MailingUnitComponent, DeviceNetworkPacketEvent>(OnPacketReceived);
SubscribeLocalEvent<MailingUnitComponent, BeforeDisposalFlushEvent>(OnBeforeFlush);
SubscribeLocalEvent<MailingUnitComponent, ConfigurationSystem.ConfigurationUpdatedEvent>(OnConfigurationUpdated);
SubscribeLocalEvent<MailingUnitComponent, ActivateInWorldEvent>(HandleActivate);
SubscribeLocalEvent<MailingUnitComponent, ActivateInWorldEvent>(HandleActivate, before: new[] { typeof(DisposalUnitSystem) });
SubscribeLocalEvent<MailingUnitComponent, DisposalUnitUIStateUpdatedEvent>(OnDisposalUnitUIStateChange);
SubscribeLocalEvent<MailingUnitComponent, TargetSelectedMessage>(OnTargetSelected);
}
@@ -89,13 +90,17 @@ public sealed class MailingUnitSystem : EntitySystem
if (string.IsNullOrEmpty(component.Target))
{
args.Cancel();
return;
}
else
{
args.Tags.Add(MailTag);
args.Tags.Add(component.Target);
args.Tags.Add(MailTag);
args.Tags.Add(component.Target);
BroadcastSentMessage(uid, component);
BroadcastSentMessage(uid, component);
component.Target = null;
}
UpdateUserInterface(uid, component);
}
/// <summary>
@@ -179,13 +184,15 @@ public sealed class MailingUnitSystem : EntitySystem
if (component.DisposalUnitInterfaceState == null)
return;
var state = new MailingUnitBoundUserInterfaceState(component.DisposalUnitInterfaceState, component.Target, component.TargetList, component.Tag);
var state = new MailingUnitBoundUserInterfaceState(component.DisposalUnitInterfaceState, component.Target, component.TargetList.ShallowClone(), component.Tag);
_userInterfaceSystem.SetUiState(uid, MailingUnitUiKey.Key, state);
}
private void OnTargetSelected(EntityUid uid, MailingUnitComponent component, TargetSelectedMessage args)
{
component.Target = args.Target;
// Clear the Target if we select the same one
component.Target =
args.Target != component.Target ? args.Target : null;
UpdateUserInterface(uid, component);
}