make rnd console require science access (#17671)

This commit is contained in:
Nemanja
2023-06-29 14:19:19 -04:00
committed by GitHub
parent 872a008a12
commit 8f5282fb89
6 changed files with 34 additions and 3 deletions

View File

@@ -1,8 +1,11 @@
using Content.Client.UserInterface.Controls;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Research.Components;
using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
@@ -19,9 +22,11 @@ public sealed partial class ResearchConsoleMenu : FancyWindow
[Dependency] private readonly IEntityManager _entity = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IPlayerManager _player = default!;
private readonly TechnologyDatabaseComponent? _technologyDatabase;
private readonly ResearchSystem _research;
private readonly SpriteSystem _sprite;
private readonly AccessReaderSystem _accessReader = default!;
public readonly EntityUid Entity;
@@ -32,6 +37,7 @@ public sealed partial class ResearchConsoleMenu : FancyWindow
_research = _entity.System<ResearchSystem>();
_sprite = _entity.System<SpriteSystem>();
_accessReader = _entity.System<AccessReaderSystem>();
Entity = entity;
ServerButton.OnPressed += _ => OnServerButtonPressed?.Invoke();
@@ -60,10 +66,14 @@ public sealed partial class ResearchConsoleMenu : FancyWindow
{
MinHeight = 10
});
var hasAccess = _player.LocalPlayer?.ControlledEntity is not { } local ||
!_entity.TryGetComponent<AccessReaderComponent>(Entity, out var access) ||
_accessReader.IsAllowed(local, access);
foreach (var techId in _technologyDatabase.CurrentTechnologyCards)
{
var tech = _prototype.Index<TechnologyPrototype>(techId);
var cardControl = new TechnologyCardControl(tech, _prototype, _sprite, GetTechnologyDescription(tech), state.Points);
var cardControl = new TechnologyCardControl(tech, _prototype, _sprite, GetTechnologyDescription(tech), state.Points, hasAccess);
cardControl.OnPressed += () => OnTechnologyCardPressed?.Invoke(techId);
TechnologyCardsContainer.AddChild(cardControl);
}