Files
wwdpublic/Content.Shared/Access/Components/IdCardConsoleComponent.cs
Velcroboy ce00812d95 Adds robust granular access (#470)
* Adds robust granular access

* Updates drobes with appropriate access

* Typo/file not saved

* Remove dupe/copy-paste oops

* Remove dupe/copy-paste oops

* Remove dupe/copy-paste oops

* Revert "Typo/file not saved"

This reverts commit 190363ead8db415e1d0e06e27b884cbcf835a398.

* Revert "Revert "Typo/file not saved""

This reverts commit dd116f2b04f48d3dad97dc4e57a56a3ed1234e7d.

* Revert "Remove dupe/copy-paste oops"

This reverts commit 5660903ac46f920efc73bea2f217c5ad50268c96.

* Remove dupe, fix copy/paste

* Fix some more copy/paste

* ugg

---------

Co-authored-by: Jeff <>
2023-11-25 18:49:26 -06:00

134 lines
4.6 KiB
C#

using Content.Shared.Access.Systems;
using Content.Shared.Containers.ItemSlots;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Access.Components;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(SharedIdCardConsoleSystem))]
public sealed partial 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]
public ItemSlot PrivilegedIdSlot = new();
[DataField]
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, AutoNetworkedField]
public List<ProtoId<AccessLevelPrototype>> AccessLevels = new()
{
"Armory",
"Atmospherics",
"Bar",
//"Brig", Delta V: Removed Brig Access
"Boxer", // DeltaV - Add Boxer access
"Detective",
"Captain",
"Cargo",
"Chapel",
"Chemistry",
"ChiefEngineer",
"ChiefMedicalOfficer",
"Clown", // DeltaV - Add Clown access
"Command",
"Engineering",
"External",
"HeadOfPersonnel",
"HeadOfSecurity",
"Hydroponics",
"Janitor",
"Kitchen",
"Lawyer",
"Library", // DeltaV - Add Library access
"Maintenance",
"Medical",
"Mime", // DeltaV - Add Mime access
"Musician", // DeltaV - Add Musician access
"Paramedic", // DeltaV - Add Paramedic access
"Psychologist", // DeltaV - Add Psychologist access
"Quartermaster",
"Reporter", // DeltaV - Add Reporter access
"Research",
"ResearchDirector",
"Salvage",
"Security",
"Service",
"Theatre",
"Orders", // DeltaV - Orders, see Resources/Prototypes/DeltaV/Access/cargo.yml
"Mail", // Nyanotrasen - Mail, see Resources/Prototypes/Nyanotrasen/Access/cargo.yml
"Mantis", // DeltaV - Psionic Mantis, see Resources/Prototypes/DeltaV/Access/epistemics.yml
"Zookeeper", // DeltaV - Add Zookeeper access
};
[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,
}
}