diff --git a/Content.Server/Access/Systems/PresetIdCardSystem.cs b/Content.Server/Access/Systems/PresetIdCardSystem.cs
index 78e4185ff8..a9e22ebf62 100644
--- a/Content.Server/Access/Systems/PresetIdCardSystem.cs
+++ b/Content.Server/Access/Systems/PresetIdCardSystem.cs
@@ -33,6 +33,7 @@ namespace Content.Server.Access.Systems
// set access for access component
_accessSystem.TrySetTags(uid, job.Access);
+ _accessSystem.TryAddGroups(uid, job.AccessGroups);
// and also change job title on a card id
_cardSystem.TryChangeJobTitle(uid, job.Name);
diff --git a/Content.Shared/Access/AccessGroupPrototype.cs b/Content.Shared/Access/AccessGroupPrototype.cs
new file mode 100644
index 0000000000..529a4146a1
--- /dev/null
+++ b/Content.Shared/Access/AccessGroupPrototype.cs
@@ -0,0 +1,19 @@
+using Content.Shared.Access.Components;
+using Robust.Shared.Prototypes;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
+
+namespace Content.Shared.Access;
+
+///
+/// Contains a list of access tags that are part of this group.
+/// Used by to avoid boilerplate.
+///
+[Prototype("accessGroup")]
+public sealed class AccessGroupPrototype : IPrototype
+{
+ [DataField("id", required: true)]
+ public string ID { get; } = default!;
+
+ [DataField("tags", required: true, customTypeSerializer:typeof(PrototypeIdHashSetSerializer))]
+ public HashSet Tags = default!;
+}
diff --git a/Content.Shared/Access/Components/AccessComponent.cs b/Content.Shared/Access/Components/AccessComponent.cs
index e53ad7c54a..1fe2afab89 100644
--- a/Content.Shared/Access/Components/AccessComponent.cs
+++ b/Content.Shared/Access/Components/AccessComponent.cs
@@ -13,10 +13,12 @@ namespace Content.Shared.Access.Components
///
[RegisterComponent]
[Friend(typeof(AccessSystem))]
- public class AccessComponent : Component
+ public sealed class AccessComponent : Component
{
[DataField("tags", customTypeSerializer: typeof(PrototypeIdHashSetSerializer))]
- [ViewVariables]
public HashSet Tags = new();
+
+ [DataField("groups", customTypeSerializer: typeof(PrototypeIdHashSetSerializer))]
+ public HashSet Groups = new();
}
}
diff --git a/Content.Shared/Access/Systems/AccessSystem.cs b/Content.Shared/Access/Systems/AccessSystem.cs
index deb58c2b35..3d00072df4 100644
--- a/Content.Shared/Access/Systems/AccessSystem.cs
+++ b/Content.Shared/Access/Systems/AccessSystem.cs
@@ -1,11 +1,33 @@
using Content.Shared.Access.Components;
using Robust.Shared.GameObjects;
using System.Collections.Generic;
+using Robust.Shared.Prototypes;
namespace Content.Shared.Access.Systems
{
- public class AccessSystem : EntitySystem
+ public sealed class AccessSystem : EntitySystem
{
+ [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnAccessInit);
+ }
+
+ private void OnAccessInit(EntityUid uid, AccessComponent component, ComponentInit args)
+ {
+ // Add all tags in groups to the list of tags.
+ foreach (var group in component.Groups)
+ {
+ if (!_prototypeManager.TryIndex(group, out var proto))
+ continue;
+
+ component.Tags.UnionWith(proto.Tags);
+ }
+ }
+
///
/// Replaces the set of access tags we have with the provided set.
///
@@ -20,5 +42,21 @@ namespace Content.Shared.Access.Systems
return true;
}
+
+ public bool TryAddGroups(EntityUid uid, IEnumerable newGroups, AccessComponent? access = null)
+ {
+ if (!Resolve(uid, ref access))
+ return false;
+
+ foreach (var group in newGroups)
+ {
+ if (!_prototypeManager.TryIndex(group, out var proto))
+ continue;
+
+ access.Tags.UnionWith(proto.Tags);
+ }
+
+ return true;
+ }
}
}
diff --git a/Content.Shared/Roles/JobPrototype.cs b/Content.Shared/Roles/JobPrototype.cs
index c8c67c2278..b60d7a7337 100644
--- a/Content.Shared/Roles/JobPrototype.cs
+++ b/Content.Shared/Roles/JobPrototype.cs
@@ -62,5 +62,8 @@ namespace Content.Shared.Roles
[DataField("access", customTypeSerializer: typeof(PrototypeIdListSerializer))]
public IReadOnlyCollection Access { get; } = Array.Empty();
+
+ [DataField("accessGroups", customTypeSerializer: typeof(PrototypeIdListSerializer))]
+ public IReadOnlyCollection AccessGroups { get; } = Array.Empty();
}
}
diff --git a/Resources/Prototypes/AccessLevels/cargo.yml b/Resources/Prototypes/Access/cargo.yml
similarity index 57%
rename from Resources/Prototypes/AccessLevels/cargo.yml
rename to Resources/Prototypes/Access/cargo.yml
index 57244f1312..7820f705f5 100644
--- a/Resources/Prototypes/AccessLevels/cargo.yml
+++ b/Resources/Prototypes/Access/cargo.yml
@@ -6,3 +6,10 @@
- type: accessLevel
id: Salvage
+
+- type: accessGroup
+ id: Cargo
+ tags:
+ - Quartermaster
+ - Salvage
+ - Cargo
diff --git a/Resources/Prototypes/AccessLevels/command.yml b/Resources/Prototypes/Access/command.yml
similarity index 61%
rename from Resources/Prototypes/AccessLevels/command.yml
rename to Resources/Prototypes/Access/command.yml
index 3ade22c893..fb21d3d912 100644
--- a/Resources/Prototypes/AccessLevels/command.yml
+++ b/Resources/Prototypes/Access/command.yml
@@ -7,3 +7,10 @@
- type: accessLevel
id: HeadOfPersonnel
name: Head of Personnel
+
+- type: accessGroup
+ id: Command
+ tags:
+ - Command
+ - Captain
+ - HeadOfPersonnel
diff --git a/Resources/Prototypes/AccessLevels/engineering.yml b/Resources/Prototypes/Access/engineering.yml
similarity index 55%
rename from Resources/Prototypes/AccessLevels/engineering.yml
rename to Resources/Prototypes/Access/engineering.yml
index d4ed2400f6..31788c6b1a 100644
--- a/Resources/Prototypes/AccessLevels/engineering.yml
+++ b/Resources/Prototypes/Access/engineering.yml
@@ -4,3 +4,9 @@
- type: accessLevel
id: Engineering
+
+- type: accessGroup
+ id: Engineering
+ tags:
+ - ChiefEngineer
+ - Engineering
diff --git a/Resources/Prototypes/AccessLevels/external.yml b/Resources/Prototypes/Access/external.yml
similarity index 100%
rename from Resources/Prototypes/AccessLevels/external.yml
rename to Resources/Prototypes/Access/external.yml
diff --git a/Resources/Prototypes/AccessLevels/maintenance.yml b/Resources/Prototypes/Access/maintenance.yml
similarity index 100%
rename from Resources/Prototypes/AccessLevels/maintenance.yml
rename to Resources/Prototypes/Access/maintenance.yml
diff --git a/Resources/Prototypes/AccessLevels/medical.yml b/Resources/Prototypes/Access/medical.yml
similarity index 60%
rename from Resources/Prototypes/AccessLevels/medical.yml
rename to Resources/Prototypes/Access/medical.yml
index 64b584ff21..f4ee93e98c 100644
--- a/Resources/Prototypes/AccessLevels/medical.yml
+++ b/Resources/Prototypes/Access/medical.yml
@@ -4,6 +4,13 @@
- type: accessLevel
id: Medical
-
+
- type: accessLevel
id: Chemistry
+
+- type: accessGroup
+ id: Medical
+ tags:
+ - ChiefMedicalOfficer
+ - Medical
+ - Chemistry
diff --git a/Resources/Prototypes/Access/misc.yml b/Resources/Prototypes/Access/misc.yml
new file mode 100644
index 0000000000..e907158430
--- /dev/null
+++ b/Resources/Prototypes/Access/misc.yml
@@ -0,0 +1,29 @@
+- type: accessGroup
+ id: AllAccess
+ tags:
+ - Captain
+ - HeadOfPersonnel
+ - ChiefEngineer
+ - ChiefMedicalOfficer
+ - HeadOfSecurity
+ - ResearchDirector
+ - Command
+ - Security
+ - Armory
+ - Brig
+ - Engineering
+ - Medical
+ - Quartermaster
+ - Salvage
+ - Cargo
+ - Research
+ - Service
+ - Maintenance
+ - External
+ - Janitor
+ - Theatre
+ - Bar
+ - Chemistry
+ - Kitchen
+ - Chapel
+ - Hydroponics
diff --git a/Resources/Prototypes/AccessLevels/research.yml b/Resources/Prototypes/Access/research.yml
similarity index 57%
rename from Resources/Prototypes/AccessLevels/research.yml
rename to Resources/Prototypes/Access/research.yml
index 774c325aa0..d265d568b3 100644
--- a/Resources/Prototypes/AccessLevels/research.yml
+++ b/Resources/Prototypes/Access/research.yml
@@ -4,3 +4,9 @@
- type: accessLevel
id: Research
+
+- type: accessGroup
+ id: Research
+ tags:
+ - ResearchDirector
+ - Research
diff --git a/Resources/Prototypes/AccessLevels/security.yml b/Resources/Prototypes/Access/security.yml
similarity index 64%
rename from Resources/Prototypes/AccessLevels/security.yml
rename to Resources/Prototypes/Access/security.yml
index a8667c0665..0e89b62193 100644
--- a/Resources/Prototypes/AccessLevels/security.yml
+++ b/Resources/Prototypes/Access/security.yml
@@ -4,7 +4,7 @@
- type: accessLevel
id: Security
-
+
- type: accessLevel
id: Armory
@@ -13,3 +13,12 @@
#- type: accessLevel
# id: Detective
+
+- type: accessGroup
+ id: Security
+ tags:
+ - HeadOfSecurity
+ - Security
+ - Armory
+ - Brig
+ # - Detective
diff --git a/Resources/Prototypes/AccessLevels/service.yml b/Resources/Prototypes/Access/service.yml
similarity index 62%
rename from Resources/Prototypes/AccessLevels/service.yml
rename to Resources/Prototypes/Access/service.yml
index 335e245dd5..52271cf0dd 100644
--- a/Resources/Prototypes/AccessLevels/service.yml
+++ b/Resources/Prototypes/Access/service.yml
@@ -17,4 +17,15 @@
id: Theatre
- type: accessLevel
- id: Chapel
\ No newline at end of file
+ id: Chapel
+
+- type: accessGroup
+ id: Service
+ tags:
+ - Bar
+ - Kitchen
+ - Hydroponics
+ - Service
+ - Janitor
+ - Theatre
+ - Chapel
diff --git a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml
index 57698749df..9c2e842e18 100644
--- a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml
+++ b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml
@@ -32,3 +32,6 @@
- type: Body
template: AGhostTemplate
preset: HumanPreset
+ - type: Access
+ groups:
+ - AllAccess
diff --git a/Resources/Prototypes/Entities/Mobs/Player/silicon.yml b/Resources/Prototypes/Entities/Mobs/Player/silicon.yml
index 9774493890..f94fa247da 100644
--- a/Resources/Prototypes/Entities/Mobs/Player/silicon.yml
+++ b/Resources/Prototypes/Entities/Mobs/Player/silicon.yml
@@ -98,28 +98,8 @@
- Opaque
- type: Tag
- type: Access
- tags:
- - Maintenance
- - Cargo
- # - Quartermaster
- - Engineering
- - ChiefEngineer
- - Medical
- - ChiefMedicalOfficer
- - Research
- - ResearchDirector
- - Security
- - Service
- - Captain
- - Command
- - External
- - HeadOfSecurity
- - HeadOfPersonnel
- - Bar
- - Hydroponics
- - Kitchen
- - Janitor
- - Theatre
+ groups:
+ - AllAccess
- type: Appearance
visuals:
- type: GenericEnumVisualizer
diff --git a/Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml b/Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml
index e95b745719..e3c5996ee6 100644
--- a/Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml
+++ b/Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml
@@ -347,28 +347,8 @@
jobTitle: Central Commander
- type: Access
#GOD DEAR FUCKING GOD WE NEED AN ALL-ACCESS FLAG
- tags:
- - Maintenance
- - Cargo
- # - Quartermaster
- - Engineering
- # - ChiefEngineer
- - Medical
- # - ChiefMedicalOfficer
- - Research
- # - ResearchDirector
- - Security
- - Service
- - Captain
- - Command
- - External
- #- HeadOfSecurity
- - HeadOfPersonnel
- - Bar
- #- Hydroponics
- #- Kitchen
- - Janitor
- - Theatre
+ groups:
+ - AllAccess
- type: entity
parent: IDCardStandard
diff --git a/Resources/Prototypes/Roles/Jobs/Command/captain.yml b/Resources/Prototypes/Roles/Jobs/Command/captain.yml
index 9621655fa2..9a59382af4 100644
--- a/Resources/Prototypes/Roles/Jobs/Command/captain.yml
+++ b/Resources/Prototypes/Roles/Jobs/Command/captain.yml
@@ -10,38 +10,8 @@
joinNotifyCrew: true
supervisors: "Nanotrasen officials"
canBeAntag: false
- access:
- # All of em.
- # Could probably do with some kind of wildcard or whatever to automate this.
- # HELL FUCKING YEAH WE COULD
- # Guys please don't fight
- # Seriously though...
- - Captain
- - HeadOfPersonnel
- - ChiefEngineer
- - ChiefMedicalOfficer
- - HeadOfSecurity
- - ResearchDirector
- - Command
- - Security
- - Armory
- - Brig
- - Engineering
- - Medical
- - Quartermaster
- - Salvage
- - Cargo
- - Research
- - Service
- - Maintenance
- - External
- - Janitor
- - Theatre
- - Bar
- - Chemistry
- - Kitchen
- - Chapel
- - Hydroponics
+ accessGroups:
+ - AllAccess
- type: startingGear
id: CaptainGear