Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
121 lines
3.9 KiB
C#
121 lines
3.9 KiB
C#
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[]? AllowedModifyAccessList;
|
|
public readonly string TargetIdJobPrototype;
|
|
|
|
public IdCardConsoleBoundUserInterfaceState(bool isPrivilegedIdPresent,
|
|
bool isPrivilegedIdAuthorized,
|
|
bool isTargetIdPresent,
|
|
string? targetIdFullName,
|
|
string? targetIdJobTitle,
|
|
string[]? targetIdAccessList,
|
|
string[]? allowedModifyAccessList,
|
|
string targetIdJobPrototype,
|
|
string privilegedIdName,
|
|
string targetIdName)
|
|
{
|
|
IsPrivilegedIdPresent = isPrivilegedIdPresent;
|
|
IsPrivilegedIdAuthorized = isPrivilegedIdAuthorized;
|
|
IsTargetIdPresent = isTargetIdPresent;
|
|
TargetIdFullName = targetIdFullName;
|
|
TargetIdJobTitle = targetIdJobTitle;
|
|
TargetIdAccessList = targetIdAccessList;
|
|
AllowedModifyAccessList = allowedModifyAccessList;
|
|
TargetIdJobPrototype = targetIdJobPrototype;
|
|
PrivilegedIdName = privilegedIdName;
|
|
TargetIdName = targetIdName;
|
|
}
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
public enum IdCardConsoleUiKey : byte
|
|
{
|
|
Key,
|
|
}
|
|
}
|