mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
Fix borg UI regenerating every tick (#27956)
* Fix UI elements being recreated when they didn't need to be * Fix up comparison (cherry picked from commit 9c3dab0be3fa2ecc66a21b471e5e78be8fcf43d0)
This commit is contained in:
committed by
Spatison
parent
baa0082d1e
commit
b968a42257
@@ -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<SiliconLaw>? _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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,13 @@ public partial class SiliconLaw : IComparable<SiliconLaw>
|
||||
return Order.CompareTo(other.Order);
|
||||
}
|
||||
|
||||
public bool Equals(SiliconLaw other)
|
||||
{
|
||||
return LawString == other.LawString
|
||||
&& Order == other.Order
|
||||
&& LawIdentifierOverride == other.LawIdentifierOverride;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a shallow clone of this law.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user