diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs index 24ca2e6ea5..bb16efdbdf 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs @@ -117,6 +117,13 @@ namespace Content.Server.GameObjects.Components.Disposal ? boundUi : null; + private DisposalUnitBoundUserInterfaceState? _lastUiState; + + /// + /// Store the translated state. + /// + private (PressureState State, string Localized) _locState; + public bool CanInsert(IEntity entity) { if (!Anchored) @@ -286,13 +293,31 @@ namespace Content.Server.GameObjects.Components.Disposal private DisposalUnitBoundUserInterfaceState GetInterfaceState() { - var state = Loc.GetString($"{State}"); - return new DisposalUnitBoundUserInterfaceState(Owner.Name, state, _pressure, Powered, Engaged); + string stateString; + + if (_locState.State != State) + { + stateString = Loc.GetString($"{State}"); + _locState = (State, stateString); + } + else + { + stateString = _locState.Localized; + } + + return new DisposalUnitBoundUserInterfaceState(Owner.Name, stateString, _pressure, Powered, Engaged); } private void UpdateInterface() { var state = GetInterfaceState(); + + if (_lastUiState != null && _lastUiState.Equals(state)) + { + return; + } + + _lastUiState = state; UserInterface?.SetState(state); } diff --git a/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs b/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs index 9bcd7edbf0..d223b1a605 100644 --- a/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs +++ b/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs @@ -58,7 +58,7 @@ namespace Content.Shared.GameObjects.Components.Disposal } [Serializable, NetSerializable] - public class DisposalUnitBoundUserInterfaceState : BoundUserInterfaceState + public class DisposalUnitBoundUserInterfaceState : BoundUserInterfaceState, IEquatable { public readonly string UnitName; public readonly string UnitState; @@ -75,6 +75,17 @@ namespace Content.Shared.GameObjects.Components.Disposal Powered = powered; Engaged = engaged; } + + public bool Equals(DisposalUnitBoundUserInterfaceState other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return UnitName == other.UnitName && + UnitState == other.UnitState && + Powered == other.Powered && + Engaged == other.Engaged && + Pressure.Equals(other.Pressure); + } } ///