Access groups + aghost all access (#6671)
This commit is contained in:
@@ -33,6 +33,7 @@ namespace Content.Server.Access.Systems
|
|||||||
|
|
||||||
// set access for access component
|
// set access for access component
|
||||||
_accessSystem.TrySetTags(uid, job.Access);
|
_accessSystem.TrySetTags(uid, job.Access);
|
||||||
|
_accessSystem.TryAddGroups(uid, job.AccessGroups);
|
||||||
|
|
||||||
// and also change job title on a card id
|
// and also change job title on a card id
|
||||||
_cardSystem.TryChangeJobTitle(uid, job.Name);
|
_cardSystem.TryChangeJobTitle(uid, job.Name);
|
||||||
|
|||||||
19
Content.Shared/Access/AccessGroupPrototype.cs
Normal file
19
Content.Shared/Access/AccessGroupPrototype.cs
Normal file
@@ -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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains a list of access tags that are part of this group.
|
||||||
|
/// Used by <see cref="AccessComponent"/> to avoid boilerplate.
|
||||||
|
/// </summary>
|
||||||
|
[Prototype("accessGroup")]
|
||||||
|
public sealed class AccessGroupPrototype : IPrototype
|
||||||
|
{
|
||||||
|
[DataField("id", required: true)]
|
||||||
|
public string ID { get; } = default!;
|
||||||
|
|
||||||
|
[DataField("tags", required: true, customTypeSerializer:typeof(PrototypeIdHashSetSerializer<AccessLevelPrototype>))]
|
||||||
|
public HashSet<string> Tags = default!;
|
||||||
|
}
|
||||||
@@ -13,10 +13,12 @@ namespace Content.Shared.Access.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
[Friend(typeof(AccessSystem))]
|
[Friend(typeof(AccessSystem))]
|
||||||
public class AccessComponent : Component
|
public sealed class AccessComponent : Component
|
||||||
{
|
{
|
||||||
[DataField("tags", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<AccessLevelPrototype>))]
|
[DataField("tags", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<AccessLevelPrototype>))]
|
||||||
[ViewVariables]
|
|
||||||
public HashSet<string> Tags = new();
|
public HashSet<string> Tags = new();
|
||||||
|
|
||||||
|
[DataField("groups", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<AccessGroupPrototype>))]
|
||||||
|
public HashSet<string> Groups = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,33 @@
|
|||||||
using Content.Shared.Access.Components;
|
using Content.Shared.Access.Components;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Shared.Access.Systems
|
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<AccessComponent, ComponentInit>(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<AccessGroupPrototype>(group, out var proto))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
component.Tags.UnionWith(proto.Tags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces the set of access tags we have with the provided set.
|
/// Replaces the set of access tags we have with the provided set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -20,5 +42,21 @@ namespace Content.Shared.Access.Systems
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TryAddGroups(EntityUid uid, IEnumerable<string> newGroups, AccessComponent? access = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref access))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (var group in newGroups)
|
||||||
|
{
|
||||||
|
if (!_prototypeManager.TryIndex<AccessGroupPrototype>(group, out var proto))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
access.Tags.UnionWith(proto.Tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,5 +62,8 @@ namespace Content.Shared.Roles
|
|||||||
|
|
||||||
[DataField("access", customTypeSerializer: typeof(PrototypeIdListSerializer<AccessLevelPrototype>))]
|
[DataField("access", customTypeSerializer: typeof(PrototypeIdListSerializer<AccessLevelPrototype>))]
|
||||||
public IReadOnlyCollection<string> Access { get; } = Array.Empty<string>();
|
public IReadOnlyCollection<string> Access { get; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
[DataField("accessGroups", customTypeSerializer: typeof(PrototypeIdListSerializer<AccessGroupPrototype>))]
|
||||||
|
public IReadOnlyCollection<string> AccessGroups { get; } = Array.Empty<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,3 +6,10 @@
|
|||||||
|
|
||||||
- type: accessLevel
|
- type: accessLevel
|
||||||
id: Salvage
|
id: Salvage
|
||||||
|
|
||||||
|
- type: accessGroup
|
||||||
|
id: Cargo
|
||||||
|
tags:
|
||||||
|
- Quartermaster
|
||||||
|
- Salvage
|
||||||
|
- Cargo
|
||||||
@@ -7,3 +7,10 @@
|
|||||||
- type: accessLevel
|
- type: accessLevel
|
||||||
id: HeadOfPersonnel
|
id: HeadOfPersonnel
|
||||||
name: Head of Personnel
|
name: Head of Personnel
|
||||||
|
|
||||||
|
- type: accessGroup
|
||||||
|
id: Command
|
||||||
|
tags:
|
||||||
|
- Command
|
||||||
|
- Captain
|
||||||
|
- HeadOfPersonnel
|
||||||
@@ -4,3 +4,9 @@
|
|||||||
|
|
||||||
- type: accessLevel
|
- type: accessLevel
|
||||||
id: Engineering
|
id: Engineering
|
||||||
|
|
||||||
|
- type: accessGroup
|
||||||
|
id: Engineering
|
||||||
|
tags:
|
||||||
|
- ChiefEngineer
|
||||||
|
- Engineering
|
||||||
@@ -4,6 +4,13 @@
|
|||||||
|
|
||||||
- type: accessLevel
|
- type: accessLevel
|
||||||
id: Medical
|
id: Medical
|
||||||
|
|
||||||
- type: accessLevel
|
- type: accessLevel
|
||||||
id: Chemistry
|
id: Chemistry
|
||||||
|
|
||||||
|
- type: accessGroup
|
||||||
|
id: Medical
|
||||||
|
tags:
|
||||||
|
- ChiefMedicalOfficer
|
||||||
|
- Medical
|
||||||
|
- Chemistry
|
||||||
29
Resources/Prototypes/Access/misc.yml
Normal file
29
Resources/Prototypes/Access/misc.yml
Normal file
@@ -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
|
||||||
@@ -4,3 +4,9 @@
|
|||||||
|
|
||||||
- type: accessLevel
|
- type: accessLevel
|
||||||
id: Research
|
id: Research
|
||||||
|
|
||||||
|
- type: accessGroup
|
||||||
|
id: Research
|
||||||
|
tags:
|
||||||
|
- ResearchDirector
|
||||||
|
- Research
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
- type: accessLevel
|
- type: accessLevel
|
||||||
id: Security
|
id: Security
|
||||||
|
|
||||||
- type: accessLevel
|
- type: accessLevel
|
||||||
id: Armory
|
id: Armory
|
||||||
|
|
||||||
@@ -13,3 +13,12 @@
|
|||||||
|
|
||||||
#- type: accessLevel
|
#- type: accessLevel
|
||||||
# id: Detective
|
# id: Detective
|
||||||
|
|
||||||
|
- type: accessGroup
|
||||||
|
id: Security
|
||||||
|
tags:
|
||||||
|
- HeadOfSecurity
|
||||||
|
- Security
|
||||||
|
- Armory
|
||||||
|
- Brig
|
||||||
|
# - Detective
|
||||||
@@ -17,4 +17,15 @@
|
|||||||
id: Theatre
|
id: Theatre
|
||||||
|
|
||||||
- type: accessLevel
|
- type: accessLevel
|
||||||
id: Chapel
|
id: Chapel
|
||||||
|
|
||||||
|
- type: accessGroup
|
||||||
|
id: Service
|
||||||
|
tags:
|
||||||
|
- Bar
|
||||||
|
- Kitchen
|
||||||
|
- Hydroponics
|
||||||
|
- Service
|
||||||
|
- Janitor
|
||||||
|
- Theatre
|
||||||
|
- Chapel
|
||||||
@@ -32,3 +32,6 @@
|
|||||||
- type: Body
|
- type: Body
|
||||||
template: AGhostTemplate
|
template: AGhostTemplate
|
||||||
preset: HumanPreset
|
preset: HumanPreset
|
||||||
|
- type: Access
|
||||||
|
groups:
|
||||||
|
- AllAccess
|
||||||
|
|||||||
@@ -98,28 +98,8 @@
|
|||||||
- Opaque
|
- Opaque
|
||||||
- type: Tag
|
- type: Tag
|
||||||
- type: Access
|
- type: Access
|
||||||
tags:
|
groups:
|
||||||
- Maintenance
|
- AllAccess
|
||||||
- Cargo
|
|
||||||
# - Quartermaster
|
|
||||||
- Engineering
|
|
||||||
- ChiefEngineer
|
|
||||||
- Medical
|
|
||||||
- ChiefMedicalOfficer
|
|
||||||
- Research
|
|
||||||
- ResearchDirector
|
|
||||||
- Security
|
|
||||||
- Service
|
|
||||||
- Captain
|
|
||||||
- Command
|
|
||||||
- External
|
|
||||||
- HeadOfSecurity
|
|
||||||
- HeadOfPersonnel
|
|
||||||
- Bar
|
|
||||||
- Hydroponics
|
|
||||||
- Kitchen
|
|
||||||
- Janitor
|
|
||||||
- Theatre
|
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
- type: GenericEnumVisualizer
|
- type: GenericEnumVisualizer
|
||||||
|
|||||||
@@ -347,28 +347,8 @@
|
|||||||
jobTitle: Central Commander
|
jobTitle: Central Commander
|
||||||
- type: Access
|
- type: Access
|
||||||
#GOD DEAR FUCKING GOD WE NEED AN ALL-ACCESS FLAG
|
#GOD DEAR FUCKING GOD WE NEED AN ALL-ACCESS FLAG
|
||||||
tags:
|
groups:
|
||||||
- Maintenance
|
- AllAccess
|
||||||
- Cargo
|
|
||||||
# - Quartermaster
|
|
||||||
- Engineering
|
|
||||||
# - ChiefEngineer
|
|
||||||
- Medical
|
|
||||||
# - ChiefMedicalOfficer
|
|
||||||
- Research
|
|
||||||
# - ResearchDirector
|
|
||||||
- Security
|
|
||||||
- Service
|
|
||||||
- Captain
|
|
||||||
- Command
|
|
||||||
- External
|
|
||||||
#- HeadOfSecurity
|
|
||||||
- HeadOfPersonnel
|
|
||||||
- Bar
|
|
||||||
#- Hydroponics
|
|
||||||
#- Kitchen
|
|
||||||
- Janitor
|
|
||||||
- Theatre
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: IDCardStandard
|
parent: IDCardStandard
|
||||||
|
|||||||
@@ -10,38 +10,8 @@
|
|||||||
joinNotifyCrew: true
|
joinNotifyCrew: true
|
||||||
supervisors: "Nanotrasen officials"
|
supervisors: "Nanotrasen officials"
|
||||||
canBeAntag: false
|
canBeAntag: false
|
||||||
access:
|
accessGroups:
|
||||||
# All of em.
|
- AllAccess
|
||||||
# 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
|
|
||||||
|
|
||||||
- type: startingGear
|
- type: startingGear
|
||||||
id: CaptainGear
|
id: CaptainGear
|
||||||
|
|||||||
Reference in New Issue
Block a user