using Content.Client.Resources;
using Content.Client.UserInterface.Controls;
using Content.Shared.Singularity.Components;
+using Content.Shared.Access.Systems;
using Robust.Client.Animations;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Shared.Noise;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
+using Robust.Client.Player;
namespace Content.Client.ParticleAccelerator.UI;
{
[Dependency] private readonly IResourceCache _cache = default!;
+ [Dependency] private readonly IEntityManager _entityManager = default!;
+ [Dependency] private readonly IPlayerManager _player = default!;
+
+ private readonly AccessReaderSystem _accessReader;
+
private readonly FastNoiseLite _drawNoiseGenerator;
private readonly Animation _alarmControlAnimation;
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
+ _accessReader = _entityManager.System<AccessReaderSystem>();
_drawNoiseGenerator = new();
_drawNoiseGenerator.SetFractalType(FastNoiseLite.FractalType.FBm);
_drawNoiseGenerator.SetFrequency(0.5f);
private bool StrengthSpinBoxValid(int n)
{
- return n >= 0 && n <= _maxStrength ;
+ return n >= 0 && n <= _maxStrength;
}
protected override DragMode GetDragModeFor(Vector2 relativeMousePos)
private void UpdateUI(bool assembled, bool blocked, bool enabled, bool powerBlock)
{
+ bool hasAccess = _player.LocalSession?.AttachedEntity is {} player
+ && _accessReader.IsAllowed(player, _entity);
+
OnButton.Pressed = enabled;
OffButton.Pressed = !enabled;
- var cantUse = !assembled || blocked || powerBlock;
+ var cantUse = !assembled || blocked || powerBlock || !hasAccess;
OnButton.Disabled = cantUse;
OffButton.Disabled = cantUse;
- ScanButton.Disabled = blocked;
+ ScanButton.Disabled = blocked || !hasAccess;
var cantChangeLevel = !assembled || blocked || !enabled || cantUse;
StateSpinBox.SetButtonDisabled(cantChangeLevel);