public readonly EntityUid Entity;
public float AccumulatedTime;
private string _lastValidName;
+ private List<EntityUid> _modules = new();
public BorgMenu(EntityUid entity)
{
("actual", _chassis.ModuleCount),
("max", _chassis.MaxModules));
+ if (_chassis.ModuleContainer.Count == _modules.Count)
+ {
+ var isSame = true;
+ foreach (var module in _chassis.ModuleContainer.ContainedEntities)
+ {
+ if (_modules.Contains(module))
+ continue;
+ isSame = false;
+ break;
+ }
+
+ if (isSame)
+ return;
+ }
+
ModuleContainer.Children.Clear();
+ _modules.Clear();
foreach (var module in _chassis.ModuleContainer.ContainedEntities)
{
var control = new BorgModuleControl(module, _entity);
RemoveModuleButtonPressed?.Invoke(module);
};
ModuleContainer.AddChild(control);
+ _modules.Add(module);
}
}
NameChanged?.Invoke(_lastValidName);
}
}
-
+using System.Linq;
+using Content.Shared.Silicons.Laws;
using Content.Shared.Silicons.Laws.Components;
using JetBrains.Annotations;
-using Robust.Client.GameObjects;
namespace Content.Client.Silicons.Laws.Ui;
[ViewVariables]
private SiliconLawMenu? _menu;
private EntityUid _owner;
+ private List<SiliconLaw>? _laws;
public SiliconLawBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
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);
}
}
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>