Adding an AccessReader to a particle accelerator with engineering access (#30394)
Adding an AccessReader to a particle accelerator
This commit is contained in:
@@ -3,6 +3,7 @@ using Content.Client.Message;
|
|||||||
using Content.Client.Resources;
|
using Content.Client.Resources;
|
||||||
using Content.Client.UserInterface.Controls;
|
using Content.Client.UserInterface.Controls;
|
||||||
using Content.Shared.Singularity.Components;
|
using Content.Shared.Singularity.Components;
|
||||||
|
using Content.Shared.Access.Systems;
|
||||||
using Robust.Client.Animations;
|
using Robust.Client.Animations;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
@@ -13,6 +14,7 @@ using Robust.Client.UserInterface.XAML;
|
|||||||
using Robust.Shared.Noise;
|
using Robust.Shared.Noise;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
using Robust.Client.Player;
|
||||||
|
|
||||||
namespace Content.Client.ParticleAccelerator.UI;
|
namespace Content.Client.ParticleAccelerator.UI;
|
||||||
|
|
||||||
@@ -21,6 +23,11 @@ public sealed partial class ParticleAcceleratorControlMenu : FancyWindow
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IResourceCache _cache = default!;
|
[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 FastNoiseLite _drawNoiseGenerator;
|
||||||
|
|
||||||
private readonly Animation _alarmControlAnimation;
|
private readonly Animation _alarmControlAnimation;
|
||||||
@@ -44,6 +51,7 @@ public sealed partial class ParticleAcceleratorControlMenu : FancyWindow
|
|||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
|
_accessReader = _entityManager.System<AccessReaderSystem>();
|
||||||
_drawNoiseGenerator = new();
|
_drawNoiseGenerator = new();
|
||||||
_drawNoiseGenerator.SetFractalType(FastNoiseLite.FractalType.FBm);
|
_drawNoiseGenerator.SetFractalType(FastNoiseLite.FractalType.FBm);
|
||||||
_drawNoiseGenerator.SetFrequency(0.5f);
|
_drawNoiseGenerator.SetFrequency(0.5f);
|
||||||
@@ -201,13 +209,16 @@ public sealed partial class ParticleAcceleratorControlMenu : FancyWindow
|
|||||||
|
|
||||||
private void UpdateUI(bool assembled, bool blocked, bool enabled, bool powerBlock)
|
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;
|
OnButton.Pressed = enabled;
|
||||||
OffButton.Pressed = !enabled;
|
OffButton.Pressed = !enabled;
|
||||||
|
|
||||||
var cantUse = !assembled || blocked || powerBlock;
|
var cantUse = !assembled || blocked || powerBlock || !hasAccess;
|
||||||
OnButton.Disabled = cantUse;
|
OnButton.Disabled = cantUse;
|
||||||
OffButton.Disabled = cantUse;
|
OffButton.Disabled = cantUse;
|
||||||
ScanButton.Disabled = blocked;
|
ScanButton.Disabled = blocked || !hasAccess;
|
||||||
|
|
||||||
var cantChangeLevel = !assembled || blocked || !enabled || cantUse;
|
var cantChangeLevel = !assembled || blocked || !enabled || cantUse;
|
||||||
StateSpinBox.SetButtonDisabled(cantChangeLevel);
|
StateSpinBox.SetButtonDisabled(cantChangeLevel);
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
- type: Wires
|
- type: Wires
|
||||||
boardName: wires-board-name-pa
|
boardName: wires-board-name-pa
|
||||||
layoutId: ParticleAccelerator
|
layoutId: ParticleAccelerator
|
||||||
|
- type: AccessReader
|
||||||
|
access: [["Engineering"]]
|
||||||
|
|
||||||
# Unfinished
|
# Unfinished
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user