Remove id card console component reference (#15205)
This commit is contained in:
117
Content.Shared/Access/Components/IdCardConsoleComponent.cs
Normal file
117
Content.Shared/Access/Components/IdCardConsoleComponent.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
|
||||
namespace Content.Shared.Access.Components;
|
||||
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[Access(typeof(SharedIdCardConsoleSystem))]
|
||||
public sealed class IdCardConsoleComponent : Component
|
||||
{
|
||||
public const int MaxFullNameLength = 30;
|
||||
public const int MaxJobTitleLength = 30;
|
||||
|
||||
public static string PrivilegedIdCardSlotId = "IdCardConsole-privilegedId";
|
||||
public static string TargetIdCardSlotId = "IdCardConsole-targetId";
|
||||
|
||||
[DataField("privilegedIdSlot")]
|
||||
public ItemSlot PrivilegedIdSlot = new();
|
||||
|
||||
[DataField("targetIdSlot")]
|
||||
public ItemSlot TargetIdSlot = new();
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class WriteToTargetIdMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly string FullName;
|
||||
public readonly string JobTitle;
|
||||
public readonly List<string> AccessList;
|
||||
public readonly string JobPrototype;
|
||||
|
||||
public WriteToTargetIdMessage(string fullName, string jobTitle, List<string> accessList, string jobPrototype)
|
||||
{
|
||||
FullName = fullName;
|
||||
JobTitle = jobTitle;
|
||||
AccessList = accessList;
|
||||
JobPrototype = jobPrototype;
|
||||
}
|
||||
}
|
||||
|
||||
// Put this on shared so we just send the state once in PVS range rather than every time the UI updates.
|
||||
|
||||
[DataField("accessLevels", customTypeSerializer: typeof(PrototypeIdListSerializer<AccessLevelPrototype>))]
|
||||
public List<string> AccessLevels = new()
|
||||
{
|
||||
"Armory",
|
||||
"Atmospherics",
|
||||
"Bar",
|
||||
"Brig",
|
||||
"Detective",
|
||||
"Captain",
|
||||
"Cargo",
|
||||
"Chapel",
|
||||
"Chemistry",
|
||||
"ChiefEngineer",
|
||||
"ChiefMedicalOfficer",
|
||||
"Command",
|
||||
"Engineering",
|
||||
"External",
|
||||
"HeadOfPersonnel",
|
||||
"HeadOfSecurity",
|
||||
"Hydroponics",
|
||||
"Janitor",
|
||||
"Kitchen",
|
||||
"Maintenance",
|
||||
"Medical",
|
||||
"Quartermaster",
|
||||
"Research",
|
||||
"ResearchDirector",
|
||||
"Salvage",
|
||||
"Security",
|
||||
"Service",
|
||||
"Theatre",
|
||||
};
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class IdCardConsoleBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public readonly string PrivilegedIdName;
|
||||
public readonly bool IsPrivilegedIdPresent;
|
||||
public readonly bool IsPrivilegedIdAuthorized;
|
||||
public readonly bool IsTargetIdPresent;
|
||||
public readonly string TargetIdName;
|
||||
public readonly string? TargetIdFullName;
|
||||
public readonly string? TargetIdJobTitle;
|
||||
public readonly string[]? TargetIdAccessList;
|
||||
public readonly string TargetIdJobPrototype;
|
||||
|
||||
public IdCardConsoleBoundUserInterfaceState(bool isPrivilegedIdPresent,
|
||||
bool isPrivilegedIdAuthorized,
|
||||
bool isTargetIdPresent,
|
||||
string? targetIdFullName,
|
||||
string? targetIdJobTitle,
|
||||
string[]? targetIdAccessList,
|
||||
string targetIdJobPrototype,
|
||||
string privilegedIdName,
|
||||
string targetIdName)
|
||||
{
|
||||
IsPrivilegedIdPresent = isPrivilegedIdPresent;
|
||||
IsPrivilegedIdAuthorized = isPrivilegedIdAuthorized;
|
||||
IsTargetIdPresent = isTargetIdPresent;
|
||||
TargetIdFullName = targetIdFullName;
|
||||
TargetIdJobTitle = targetIdJobTitle;
|
||||
TargetIdAccessList = targetIdAccessList;
|
||||
TargetIdJobPrototype = targetIdJobPrototype;
|
||||
PrivilegedIdName = privilegedIdName;
|
||||
TargetIdName = targetIdName;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum IdCardConsoleUiKey : byte
|
||||
{
|
||||
Key,
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
|
||||
namespace Content.Shared.Access.Components
|
||||
{
|
||||
[NetworkedComponent]
|
||||
public abstract class SharedIdCardConsoleComponent : Component
|
||||
{
|
||||
public const int MaxFullNameLength = 30;
|
||||
public const int MaxJobTitleLength = 30;
|
||||
|
||||
public static string PrivilegedIdCardSlotId = "IdCardConsole-privilegedId";
|
||||
public static string TargetIdCardSlotId = "IdCardConsole-targetId";
|
||||
|
||||
[DataField("privilegedIdSlot")]
|
||||
public ItemSlot PrivilegedIdSlot = new();
|
||||
|
||||
[DataField("targetIdSlot")]
|
||||
public ItemSlot TargetIdSlot = new();
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class WriteToTargetIdMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly string FullName;
|
||||
public readonly string JobTitle;
|
||||
public readonly List<string> AccessList;
|
||||
public readonly string JobPrototype;
|
||||
|
||||
public WriteToTargetIdMessage(string fullName, string jobTitle, List<string> accessList, string jobPrototype)
|
||||
{
|
||||
FullName = fullName;
|
||||
JobTitle = jobTitle;
|
||||
AccessList = accessList;
|
||||
JobPrototype = jobPrototype;
|
||||
}
|
||||
}
|
||||
|
||||
// Put this on shared so we just send the state once in PVS range rather than every time the UI updates.
|
||||
|
||||
[DataField("accessLevels", customTypeSerializer: typeof(PrototypeIdListSerializer<AccessLevelPrototype>))]
|
||||
public List<string> AccessLevels = new()
|
||||
{
|
||||
"Armory",
|
||||
"Atmospherics",
|
||||
"Bar",
|
||||
"Brig",
|
||||
"Detective",
|
||||
"Captain",
|
||||
"Cargo",
|
||||
"Chapel",
|
||||
"Chemistry",
|
||||
"ChiefEngineer",
|
||||
"ChiefMedicalOfficer",
|
||||
"Command",
|
||||
"Engineering",
|
||||
"External",
|
||||
"HeadOfPersonnel",
|
||||
"HeadOfSecurity",
|
||||
"Hydroponics",
|
||||
"Janitor",
|
||||
"Kitchen",
|
||||
"Maintenance",
|
||||
"Medical",
|
||||
"Quartermaster",
|
||||
"Research",
|
||||
"ResearchDirector",
|
||||
"Salvage",
|
||||
"Security",
|
||||
"Service",
|
||||
"Theatre",
|
||||
};
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class IdCardConsoleBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public readonly string PrivilegedIdName;
|
||||
public readonly bool IsPrivilegedIdPresent;
|
||||
public readonly bool IsPrivilegedIdAuthorized;
|
||||
public readonly bool IsTargetIdPresent;
|
||||
public readonly string TargetIdName;
|
||||
public readonly string? TargetIdFullName;
|
||||
public readonly string? TargetIdJobTitle;
|
||||
public readonly string[]? TargetIdAccessList;
|
||||
public readonly string TargetIdJobPrototype;
|
||||
|
||||
public IdCardConsoleBoundUserInterfaceState(bool isPrivilegedIdPresent,
|
||||
bool isPrivilegedIdAuthorized,
|
||||
bool isTargetIdPresent,
|
||||
string? targetIdFullName,
|
||||
string? targetIdJobTitle,
|
||||
string[]? targetIdAccessList,
|
||||
string targetIdJobPrototype,
|
||||
string privilegedIdName,
|
||||
string targetIdName)
|
||||
{
|
||||
IsPrivilegedIdPresent = isPrivilegedIdPresent;
|
||||
IsPrivilegedIdAuthorized = isPrivilegedIdAuthorized;
|
||||
IsTargetIdPresent = isTargetIdPresent;
|
||||
TargetIdFullName = targetIdFullName;
|
||||
TargetIdJobTitle = targetIdJobTitle;
|
||||
TargetIdAccessList = targetIdAccessList;
|
||||
TargetIdJobPrototype = targetIdJobPrototype;
|
||||
PrivilegedIdName = privilegedIdName;
|
||||
TargetIdName = targetIdName;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum IdCardConsoleUiKey : byte
|
||||
{
|
||||
Key,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,30 +17,30 @@ namespace Content.Shared.Access.Systems
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SharedIdCardConsoleComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<SharedIdCardConsoleComponent, ComponentRemove>(OnComponentRemove);
|
||||
SubscribeLocalEvent<SharedIdCardConsoleComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<SharedIdCardConsoleComponent, ComponentHandleState>(OnHandleState);
|
||||
SubscribeLocalEvent<IdCardConsoleComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<IdCardConsoleComponent, ComponentRemove>(OnComponentRemove);
|
||||
SubscribeLocalEvent<IdCardConsoleComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<IdCardConsoleComponent, ComponentHandleState>(OnHandleState);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, SharedIdCardConsoleComponent component, ref ComponentHandleState args)
|
||||
private void OnHandleState(EntityUid uid, IdCardConsoleComponent 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)
|
||||
private void OnGetState(EntityUid uid, IdCardConsoleComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new IdCardConsoleComponentState(component.AccessLevels);
|
||||
}
|
||||
|
||||
private void OnComponentInit(EntityUid uid, SharedIdCardConsoleComponent component, ComponentInit args)
|
||||
private void OnComponentInit(EntityUid uid, IdCardConsoleComponent component, ComponentInit args)
|
||||
{
|
||||
_itemSlotsSystem.AddItemSlot(uid, SharedIdCardConsoleComponent.PrivilegedIdCardSlotId, component.PrivilegedIdSlot);
|
||||
_itemSlotsSystem.AddItemSlot(uid, SharedIdCardConsoleComponent.TargetIdCardSlotId, component.TargetIdSlot);
|
||||
_itemSlotsSystem.AddItemSlot(uid, IdCardConsoleComponent.PrivilegedIdCardSlotId, component.PrivilegedIdSlot);
|
||||
_itemSlotsSystem.AddItemSlot(uid, IdCardConsoleComponent.TargetIdCardSlotId, component.TargetIdSlot);
|
||||
}
|
||||
|
||||
private void OnComponentRemove(EntityUid uid, SharedIdCardConsoleComponent component, ComponentRemove args)
|
||||
private void OnComponentRemove(EntityUid uid, IdCardConsoleComponent component, ComponentRemove args)
|
||||
{
|
||||
_itemSlotsSystem.RemoveItemSlot(uid, component.PrivilegedIdSlot);
|
||||
_itemSlotsSystem.RemoveItemSlot(uid, component.TargetIdSlot);
|
||||
|
||||
Reference in New Issue
Block a user