Refresh gas canister UI on canister startup (#42616)

* Refresh UI on canister startup

* Rework DirtyUI to not fail during tests on fake canisters

* Feedback from Discord
This commit is contained in:
Ohelig
2026-01-26 08:47:04 -06:00
committed by GitHub
parent 235ad21f22
commit 256ecd3c46
2 changed files with 16 additions and 1 deletions

View File

@@ -48,7 +48,7 @@ public sealed class GasCanisterSystem : SharedGasCanisterSystem
protected override void DirtyUI(EntityUid uid, GasCanisterComponent? canister = null, NodeContainerComponent? nodeContainer = null)
{
if (!Resolve(uid, ref canister, ref nodeContainer))
if (!Resolve(uid, ref canister, ref nodeContainer, logMissing: false))
return;
var portStatus = false;

View File

@@ -23,6 +23,8 @@ public abstract class SharedGasCanisterSystem : EntitySystem
SubscribeLocalEvent<GasCanisterComponent, EntRemovedFromContainerMessage>(OnCanisterContainerModified);
SubscribeLocalEvent<GasCanisterComponent, ItemSlotInsertAttemptEvent>(OnCanisterInsertAttempt);
SubscribeLocalEvent<GasCanisterComponent, ComponentStartup>(OnCanisterStartup);
SubscribeLocalEvent<GasCanisterComponent, MapInitEvent>(OnCanisterMapInit);
SubscribeLocalEvent<GasCanisterComponent, BoundUIOpenedEvent>(OnCanisterUIOpened);
// Bound UI subscriptions
SubscribeLocalEvent<GasCanisterComponent, GasCanisterHoldingTankEjectMessage>(OnHoldingTankEjectMessage);
@@ -30,6 +32,19 @@ public abstract class SharedGasCanisterSystem : EntitySystem
SubscribeLocalEvent<GasCanisterComponent, GasCanisterChangeReleaseValveMessage>(OnCanisterChangeReleaseValve);
}
private void OnCanisterUIOpened(Entity<GasCanisterComponent> ent, ref BoundUIOpenedEvent args)
{
// Fixes all canisters not populating UI elements before MapInit. Mappers rejoice
// We still need to DirtyUI after MapInit because this has latency, bad UX for players.
DirtyUI(ent.Owner, ent);
}
private void OnCanisterMapInit(Entity<GasCanisterComponent> ent, ref MapInitEvent args)
{
// Fixes empty canisters not populating UI elements
DirtyUI(ent.Owner, ent);
}
private void OnCanisterStartup(Entity<GasCanisterComponent> ent, ref ComponentStartup args)
{
// Ensure container