diff --git a/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs b/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs index dc141963498..8fddc87f695 100644 --- a/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs +++ b/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs @@ -12,7 +12,6 @@ using Content.Shared.Shipyard; using Robust.Server.GameObjects; using Robust.Shared.Containers; -using Robust.Shared.Player; using Robust.Shared.Prototypes; using Content.Shared.Radio; using System.Linq; @@ -21,7 +20,6 @@ using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Systems; using Content.Server.Maps; -using Content.Server.UserInterface; using Content.Shared.StationRecords; using Content.Server.Chat.Systems; using Content.Server.Forensics; @@ -39,6 +37,7 @@ using Content.Shared.UserInterface; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; +using Content.Shared.Access; namespace Content.Server.Shipyard.Systems; @@ -106,7 +105,7 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component return; } - if (!GetAvailableShuttles(uid).Contains(vessel.ID)) + if (!GetAvailableShuttles(uid, targetId: targetId).Contains(vessel.ID)) { PlayDenySound(uid, component); _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(player):player} tried to purchase a vessel that was never available."); @@ -239,7 +238,7 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component PlayConfirmSound(uid, component); _adminLogger.Add(LogType.ShipYardUsage, LogImpact.Low, $"{ToPrettyString(player):actor} purchased shuttle {ToPrettyString(shuttle.Owner)} for {vessel.Price} credits via {ToPrettyString(component.Owner)}"); - RefreshState(uid, bank.Balance, true, name, sellValue, true, (ShipyardConsoleUiKey) args.UiKey); + RefreshState(uid, bank.Balance, true, name, sellValue, targetId, (ShipyardConsoleUiKey) args.UiKey); } private void TryParseShuttleName(ShuttleDeedComponent deed, string name) @@ -353,7 +352,7 @@ public void OnSellMessage(EntityUid uid, ShipyardConsoleComponent component, Shi SendSellMessage(uid, deed.ShuttleOwner!, name, secretChannel, player, secret: true); _adminLogger.Add(LogType.ShipYardUsage, LogImpact.Low, $"{ToPrettyString(player):actor} sold {shuttleName} for {bill} credits via {ToPrettyString(component.Owner)}"); - RefreshState(uid, bank.Balance, true, null, 0, true, (ShipyardConsoleUiKey) args.UiKey); + RefreshState(uid, bank.Balance, true, null, 0, targetId, (ShipyardConsoleUiKey) args.UiKey); } private void OnConsoleUIOpened(EntityUid uid, ShipyardConsoleComponent component, BoundUIOpenedEvent args) @@ -392,7 +391,7 @@ private void OnConsoleUIOpened(EntityUid uid, ShipyardConsoleComponent component sellValue -= CalculateSalesTax(component, sellValue); var fullName = deed != null ? GetFullName(deed) : null; - RefreshState(uid, bank.Balance, true, fullName, sellValue, targetId.HasValue, (ShipyardConsoleUiKey) args.UiKey); + RefreshState(uid, bank.Balance, true, fullName, sellValue, targetId, (ShipyardConsoleUiKey) args.UiKey); } private void ConsolePopup(EntityUid uid, string text) @@ -482,7 +481,14 @@ private void OnItemSlotChanged(EntityUid uid, ShipyardConsoleComponent component sellValue -= CalculateSalesTax(component, sellValue); var fullName = deed != null ? GetFullName(deed) : null; - RefreshState(uid, bank.Balance, true, fullName, sellValue, targetId.HasValue, (ShipyardConsoleUiKey) uiComp.Key); + RefreshState(uid, + bank.Balance, + true, + fullName, + sellValue, + targetId, + (ShipyardConsoleUiKey) uiComp.Key); + } } @@ -519,7 +525,8 @@ private void OnItemSlotChanged(EntityUid uid, ShipyardConsoleComponent component /// /// Returns all shuttle prototype IDs the given shipyard console can offer. /// - public List GetAvailableShuttles(EntityUid uid, ShipyardConsoleUiKey? key = null, ShipyardListingComponent? listing = null) + public List GetAvailableShuttles(EntityUid uid, ShipyardConsoleUiKey? key = null, + ShipyardListingComponent? listing = null, EntityUid? targetId = null) { var availableShuttles = new List(); @@ -536,30 +543,54 @@ public List GetAvailableShuttles(EntityUid uid, ShipyardConsoleUiKey? ke } } - // Add all prototypes matching the ui key - if (key != null && key != ShipyardConsoleUiKey.Custom && ShipyardGroupMapping.TryGetValue(key.Value, out var group)) + TryComp(targetId, out var accessComponent); + foreach (var vessel in _prototypeManager.EnumeratePrototypes()) { - var protos = _prototypeManager.EnumeratePrototypes(); - foreach (var proto in protos) + // If the vessel needs access to be bought, check the user's access. + if (!string.IsNullOrEmpty(vessel.Access)) { - if (proto.Group == group) - availableShuttles.Add(proto.ID); + bool hasAccess = false; + // Check tags + if (accessComponent?.Tags.Contains(vessel.Access) ?? false) + hasAccess = true; + + // Check each group if we haven't found access already. + if (!hasAccess) + { + var groupIds = accessComponent?.Groups ?? new HashSet>(); + foreach (var groupId in groupIds) + { + var groupProto = _prototypeManager.Index(groupId); + if (groupProto?.Tags.Contains(vessel.Access) ?? false) + { + hasAccess = true; + break; + } + } + } + + // No access to this vessel, skip to the next one. + if (!hasAccess) + continue; } - } - // Add all prototypes specified in ShipyardListing - if (listing != null || TryComp(uid, out listing)) - { - foreach (var shuttle in listing.Shuttles) + // Check that the listing contains the shuttle or that the shuttle is in the group that the console is looking for + if ((listing?.Shuttles.Contains(vessel.ID) ?? false) || + // if the listing contains the shuttle, add it to the list or + + // if the shuttle is in the group that the console is looking for + (key != null && key != ShipyardConsoleUiKey.Custom && + ShipyardGroupMapping.TryGetValue(key.Value, out var group) && vessel.Group == group)) { - availableShuttles.Add(shuttle); + availableShuttles.Add(vessel.ID); } + } return availableShuttles; } - private void RefreshState(EntityUid uid, int balance, bool access, string? shipDeed, int shipSellValue, bool isTargetIdPresent, ShipyardConsoleUiKey uiKey) + private void RefreshState(EntityUid uid, int balance, bool access, string? shipDeed, int shipSellValue, EntityUid? targetId, ShipyardConsoleUiKey uiKey) { var listing = TryComp(uid, out var comp) ? comp : null; @@ -568,9 +599,9 @@ private void RefreshState(EntityUid uid, int balance, bool access, string? shipD access, shipDeed, shipSellValue, - isTargetIdPresent, + targetId.HasValue, ((byte)uiKey), - GetAvailableShuttles(uid, uiKey, listing), + GetAvailableShuttles(uid, uiKey, listing, targetId), uiKey.ToString()); _ui.SetUiState(uid, uiKey, newState); diff --git a/Content.Shared/Access/Components/IdCardConsoleComponent.cs b/Content.Shared/Access/Components/IdCardConsoleComponent.cs index 7b06122670d..9376457f075 100644 --- a/Content.Shared/Access/Components/IdCardConsoleComponent.cs +++ b/Content.Shared/Access/Components/IdCardConsoleComponent.cs @@ -3,6 +3,8 @@ using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; +using Robust.Shared.Prototypes; namespace Content.Shared.Access.Components; @@ -46,6 +48,7 @@ public WriteToTargetIdMessage(string fullName, string jobTitle, List + /// The access required to buy the product. (e.g. Command, Mail, Bailiff, etc.) + /// + [DataField("access")] + public string Access = string.Empty; + /// Frontier - Add this field for the MapChecker script. /// /// The MapChecker override group for this vessel. @@ -51,4 +58,5 @@ public sealed class VesselPrototype : IPrototype /// [DataField("shuttlePath", required: true)] public ResPath ShuttlePath = default!; + } diff --git a/Resources/Locale/en-US/_NF/prototypes/access/accesses.ftl b/Resources/Locale/en-US/_NF/prototypes/access/accesses.ftl index e8ca0666f4d..5a35988329d 100644 --- a/Resources/Locale/en-US/_NF/prototypes/access/accesses.ftl +++ b/Resources/Locale/en-US/_NF/prototypes/access/accesses.ftl @@ -2,4 +2,6 @@ id-card-access-level-frontier = Frontier id-card-access-level-pilot = Pilot id-card-access-level-mail = Mail id-card-access-level-mercenary = Mercenary -id-card-access-level-stc = Station Traffic Controller \ No newline at end of file +id-card-access-level-stc = Station Traffic Controller +id-card-access-level-sergeant = Sergeant +id-card-access-level-bailiff = Bailiff diff --git a/Resources/Prototypes/Access/misc.yml b/Resources/Prototypes/Access/misc.yml index db359351e79..0400f602117 100644 --- a/Resources/Prototypes/Access/misc.yml +++ b/Resources/Prototypes/Access/misc.yml @@ -26,6 +26,8 @@ - Research - Service - StationTrafficController # Frontier + - Sergeant # Frontier + - Bailiff # Frontier - Maintenance - External - Janitor diff --git a/Resources/Prototypes/_NF/Access/security.yml b/Resources/Prototypes/_NF/Access/security.yml index d6fa4f60a31..41a15a2b340 100644 --- a/Resources/Prototypes/_NF/Access/security.yml +++ b/Resources/Prototypes/_NF/Access/security.yml @@ -1,7 +1,22 @@ - type: accessLevel id: Mercenary - name: id-card-access-level-mercenary + name: id-card-access-level-mercenary +- type: accessLevel + id: Sergeant + name: id-card-access-level-sergeant + +- type: accessLevel + id: Bailiff + name: id-card-access-level-bailiff + +- type: accessGroup + id: CadetNfsdAccess + tags: + - Maintenance + - External + - Security + - type: accessGroup id: GeneralNfsdAccess tags: diff --git a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml index c80618ab4eb..48c23950ec0 100644 --- a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml +++ b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml @@ -17,14 +17,11 @@ supervisors: job-supervisors-sheriff canBeAntag: false access: - - Maintenance - - External - - Command - - Brig - - Security - - Mercenary # Frontier - - Captain # Frontier - Armory + - Sergeant # Frontier + - Bailiff # Frontier + accessGroups: # Frontier + - GeneralNfsdAccess # Frontier special: - !type:AddImplantSpecial implants: [ MindShieldImplant, TrackingImplant ] # Frontier diff --git a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/cadet.yml b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/cadet.yml index 371aec388a5..4242d8419a9 100644 --- a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/cadet.yml +++ b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/cadet.yml @@ -15,7 +15,7 @@ supervisors: job-supervisors-cadet canBeAntag: false accessGroups: # Frontier - - GeneralNfsdAccess # Frontier + - CadetNfsdAccess # Frontier special: - !type:AddImplantSpecial implants: [ MindShieldImplant, TrackingImplant ] diff --git a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/detectivenf.yml b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/detectivenf.yml index 81bc81d085d..5b768e345a0 100644 --- a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/detectivenf.yml +++ b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/detectivenf.yml @@ -14,14 +14,9 @@ supervisors: job-supervisors-bailiff canBeAntag: false access: - - Maintenance - - External - - Command - - Brig - - Security - - Mercenary # Frontier - - Captain # Frontier - Detective + accessGroups: # Frontier + - GeneralNfsdAccess # Frontier special: - !type:AddImplantSpecial implants: [ MindShieldImplant, TrackingImplant ] diff --git a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/senior_officer.yml b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/senior_officer.yml index 657a142d21d..e6354dd97ae 100644 --- a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/senior_officer.yml +++ b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/senior_officer.yml @@ -16,6 +16,8 @@ icon: "JobIconSeniorOfficer" # Frontier supervisors: job-supervisors-bailiff canBeAntag: false + access: + - Sergeant # Frontier accessGroups: # Frontier - GeneralNfsdAccess # Frontier special: diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/broadhead.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/broadhead.yml index abd86bfbe68..778620f0e77 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/broadhead.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/broadhead.yml @@ -5,6 +5,7 @@ price: 50000 category: Medium group: Security + access: Detective shuttlePath: /Maps/_NF/Shuttles/Nfsd/broadhead.yml - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/cleric.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/cleric.yml index 84f228eab0b..361b2f2cb84 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/cleric.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/cleric.yml @@ -5,6 +5,7 @@ price: 11800 #Appraisal is 10500 category: Small group: None + access: Security mapchecker_group_override: Security # Treat this as a security vessel for mapchecker purposes shuttlePath: /Maps/_NF/Shuttles/Nfsd/cleric.yml diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/empress.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/empress.yml index 0f1bdf07f76..9959398dcd8 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/empress.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/empress.yml @@ -5,6 +5,7 @@ price: 170000 #Appraisal value is 150000 category: Large group: Security + access: Bailiff shuttlePath: /Maps/_NF/Shuttles/Nfsd/empress.yml - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/enforcer.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/enforcer.yml index 71a94cad095..395dcb1cc2b 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/enforcer.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/enforcer.yml @@ -5,6 +5,7 @@ # price: 21350 # category: Small # group: Security + # access: Bailiff # shuttlePath: /Maps/_NF/Shuttles/Nfsd/enforcer.yml # - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/fighter.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/fighter.yml index 4501e21cde5..6f9874d146c 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/fighter.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/fighter.yml @@ -5,6 +5,7 @@ price: 9000 #not sure how much mark up % to add but the appraisal is 7150$ now category: Small group: None + access: Security mapchecker_group_override: Security # Treat this as a security vessel for mapchecker purposes shuttlePath: /Maps/_NF/Shuttles/Nfsd/fighter.yml diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/hospitaller.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/hospitaller.yml index 4c67789e8d5..b1fa5df291a 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/hospitaller.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/hospitaller.yml @@ -5,6 +5,7 @@ price: 28220 category: Small group: Security + access: Security shuttlePath: /Maps/_NF/Shuttles/Nfsd/hospitaller.yml - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/inquisitor.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/inquisitor.yml index aabf99b7a76..e107f2dfeea 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/inquisitor.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/inquisitor.yml @@ -5,6 +5,7 @@ price: 29000 category: Small group: Security + access: Detective shuttlePath: /Maps/_NF/Shuttles/Nfsd/inquisitor.yml - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/interceptor.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/interceptor.yml index c6b0dda3dd0..35c1603abe3 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/interceptor.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/interceptor.yml @@ -5,6 +5,7 @@ price: 21350 category: Small group: Security + access: Detective shuttlePath: /Maps/_NF/Shuttles/Nfsd/interceptor.yml - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/marauder.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/marauder.yml index f5916f74f60..9515160762c 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/marauder.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/marauder.yml @@ -5,6 +5,7 @@ price: 80000 category: Large group: Security + access: Bailiff shuttlePath: /Maps/_NF/Shuttles/Nfsd/marauder.yml - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/opportunity.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/opportunity.yml index 6af64f897ee..f2a6bb3fe8c 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/opportunity.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/opportunity.yml @@ -5,6 +5,7 @@ # price: 70000 # category: Medium # group: Security + # access: Bailiff # shuttlePath: /Maps/_NF/Shuttles/Nfsd/opportunity.yml # - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/prowler.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/prowler.yml index 1c738257d01..292521fe9c8 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/prowler.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/prowler.yml @@ -5,6 +5,7 @@ price: 49220 category: Medium group: Security + access: Sergeant shuttlePath: /Maps/_NF/Shuttles/Nfsd/prowler.yml - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/rogue.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/rogue.yml index a31be56360c..9a2ee71ce88 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/rogue.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/rogue.yml @@ -5,6 +5,7 @@ price: 12200 #the appraisal is 9100$ category: Small group: None + access: Security mapchecker_group_override: Security # Treat this as a security vessel for mapchecker purposes shuttlePath: /Maps/_NF/Shuttles/Nfsd/rogue.yml diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/templar.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/templar.yml index 9598f598c7a..4a9a3afd7ae 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/templar.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/templar.yml @@ -5,6 +5,7 @@ price: 24220 category: Small group: Security + access: Security shuttlePath: /Maps/_NF/Shuttles/Nfsd/templar.yml - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/trident.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/trident.yml index b859e737074..6332fa22426 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/trident.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/trident.yml @@ -5,6 +5,7 @@ # price: 49300 # category: Medium # group: Security + # access: Bailiff # shuttlePath: /Maps/_NF/Shuttles/Nfsd/trident.yml # - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/wasp.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/wasp.yml index 3b3001b44cb..a3e0d71f6c1 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/wasp.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/wasp.yml @@ -5,6 +5,7 @@ price: 135000 category: Large group: Security + access: Bailiff shuttlePath: /Maps/_NF/Shuttles/Nfsd/wasp.yml - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/whiskey.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/whiskey.yml index 778ddddf2ea..7199b14c43a 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/whiskey.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/whiskey.yml @@ -5,6 +5,7 @@ # price: 55000 # category: Medium # group: Security +# access: Bailiff # shuttlePath: /Maps/_NF/Shuttles/Nfsd/whiskey.yml # - type: gameMap