diff --git a/Content.Client/Silicons/Laws/Ui/SiliconLawBoundUserInterface.cs b/Content.Client/Silicons/Laws/Ui/SiliconLawBoundUserInterface.cs index 93349794b8..56216b9184 100644 --- a/Content.Client/Silicons/Laws/Ui/SiliconLawBoundUserInterface.cs +++ b/Content.Client/Silicons/Laws/Ui/SiliconLawBoundUserInterface.cs @@ -1,3 +1,5 @@ +using System.Linq; +using Content.Shared.Silicons.Laws; using Content.Shared.Silicons.Laws.Components; using JetBrains.Annotations; using Robust.Client.UserInterface; @@ -10,6 +12,7 @@ public sealed class SiliconLawBoundUserInterface : BoundUserInterface [ViewVariables] private SiliconLawMenu? _menu; private EntityUid _owner; + private List? _laws; public SiliconLawBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { @@ -30,6 +33,23 @@ public sealed class SiliconLawBoundUserInterface : BoundUserInterface if (state is not SiliconLawBuiState msg) return; + if (_laws != null && _laws.Count == msg.Laws.Count) + { + var isSame = true; + foreach (var law in msg.Laws) + { + if (_laws.Contains(law)) + continue; + isSame = false; + break; + } + + if (isSame) + return; + } + + _laws = msg.Laws.ToList(); + _menu?.Update(_owner, msg); } } diff --git a/Content.Shared/Silicons/Laws/SiliconLawPrototype.cs b/Content.Shared/Silicons/Laws/SiliconLawPrototype.cs index 5e5df448b3..d10b86c241 100644 --- a/Content.Shared/Silicons/Laws/SiliconLawPrototype.cs +++ b/Content.Shared/Silicons/Laws/SiliconLawPrototype.cs @@ -39,6 +39,13 @@ public partial class SiliconLaw : IComparable return Order.CompareTo(other.Order); } + public bool Equals(SiliconLaw other) + { + return LawString == other.LawString + && Order == other.Order + && LawIdentifierOverride == other.LawIdentifierOverride; + } + /// /// Return a shallow clone of this law. ///