mirror of
https://github.com/space-wizards/space-station-14.git
synced 2026-02-14 19:29:53 +01:00
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:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user