Store what access levels are available on the IDCard console (#8259)
Might be better as an accessgroup instead? LMK
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Access.Systems
|
||||
{
|
||||
@@ -9,12 +11,27 @@ namespace Content.Shared.Access.Systems
|
||||
{
|
||||
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
|
||||
|
||||
public const string Sawmill = "idconsole";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SharedIdCardConsoleComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<SharedIdCardConsoleComponent, ComponentRemove>(OnComponentRemove);
|
||||
SubscribeLocalEvent<SharedIdCardConsoleComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<SharedIdCardConsoleComponent, ComponentHandleState>(OnHandleState);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, SharedIdCardConsoleComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not IdCardConsoleComponentState state) return;
|
||||
component.AccessLevels = state.AccessLevels;
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, SharedIdCardConsoleComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new IdCardConsoleComponentState(component.AccessLevels);
|
||||
}
|
||||
|
||||
private void OnComponentInit(EntityUid uid, SharedIdCardConsoleComponent component, ComponentInit args)
|
||||
@@ -28,5 +45,16 @@ namespace Content.Shared.Access.Systems
|
||||
_itemSlotsSystem.RemoveItemSlot(uid, component.PrivilegedIdSlot);
|
||||
_itemSlotsSystem.RemoveItemSlot(uid, component.TargetIdSlot);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class IdCardConsoleComponentState : ComponentState
|
||||
{
|
||||
public List<string> AccessLevels;
|
||||
|
||||
public IdCardConsoleComponentState(List<string> accessLevels)
|
||||
{
|
||||
AccessLevels = accessLevels;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user