From 47a5d6529eec9156d5e4cb80b7561734280d52ae Mon Sep 17 00:00:00 2001 From: neuPanda Date: Sat, 1 Jun 2024 08:10:17 -0500 Subject: [PATCH 01/12] NFSD Access Overhaul Fixed ship console refresh on id insert or removal Added Access to VesselPrototype Added Filtration to Ship List based off of Access Added Bailiff and Sergeant Access levels Added Access levels to all NFSD ship Added appropriate access groups to NFSD roles --- .../Systems/ShipyardSystem.Consoles.cs | 66 +++++++++---------- .../Components/IdCardConsoleComponent.cs | 6 +- .../Shipyard/Prototypes/VesselPrototype.cs | 8 +++ .../en-US/_NF/prototypes/access/accesses.ftl | 4 +- Resources/Prototypes/_NF/Access/security.yml | 35 +++++++++- .../_NF/Roles/Jobs/Nfsd/bailiff.yml | 3 + .../Prototypes/_NF/Roles/Jobs/Nfsd/cadet.yml | 2 +- .../_NF/Roles/Jobs/Nfsd/senior_officer.yml | 1 + .../_NF/Roles/Jobs/Nfsd/sheriff.yml | 2 + .../Prototypes/_NF/Shipyard/Nfsd/cleric.yml | 1 + .../Prototypes/_NF/Shipyard/Nfsd/empress.yml | 1 + .../Prototypes/_NF/Shipyard/Nfsd/enforcer.yml | 1 + .../Prototypes/_NF/Shipyard/Nfsd/fighter.yml | 1 + .../_NF/Shipyard/Nfsd/hospitaller.yml | 1 + .../_NF/Shipyard/Nfsd/inquisitor.yml | 1 + .../_NF/Shipyard/Nfsd/interceptor.yml | 1 + .../Prototypes/_NF/Shipyard/Nfsd/marauder.yml | 1 + .../_NF/Shipyard/Nfsd/opportunity.yml | 1 + .../Prototypes/_NF/Shipyard/Nfsd/prowler.yml | 1 + .../Prototypes/_NF/Shipyard/Nfsd/rogue.yml | 1 + .../Prototypes/_NF/Shipyard/Nfsd/templar.yml | 1 + .../Prototypes/_NF/Shipyard/Nfsd/trident.yml | 1 + .../Prototypes/_NF/Shipyard/Nfsd/wasp.yml | 1 + .../Prototypes/_NF/Shipyard/Nfsd/whiskey.yml | 1 + 24 files changed, 104 insertions(+), 38 deletions(-) diff --git a/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs b/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs index dc141963498..cf26cdb7450 100644 --- a/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs +++ b/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs @@ -106,7 +106,7 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component return; } - if (!GetAvailableShuttles(uid).Contains(vessel.ID)) + if (!GetAvailableShuttles(uid,null, null, 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 +239,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 +353,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 +392,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) @@ -453,6 +453,8 @@ private void OnItemSlotChanged(EntityUid uid, ShipyardConsoleComponent component // kind of cursed. We need to update the UI when an Id is entered, but the UI needs to know the player characters bank account. if (!TryComp(uid, out var uiComp) || uiComp.Key == null) return; + if (uiComp.CurrentSingleUser is not { Valid: true } player) + return; var uiUsers = _ui.GetActors(uid, uiComp.Key); @@ -464,7 +466,7 @@ private void OnItemSlotChanged(EntityUid uid, ShipyardConsoleComponent component if (!TryComp(player, out var bank)) continue; - var targetId = component.TargetIdSlot.ContainerSlot?.ContainedEntity; + var targetId = component.TargetIdSlot.ContainerSlot?.ContainedEntity; if (TryComp(targetId, out var deed)) { @@ -475,15 +477,16 @@ private void OnItemSlotChanged(EntityUid uid, ShipyardConsoleComponent component } } - int sellValue = 0; - if (deed?.ShuttleUid != null) - sellValue = (int) _pricing.AppraiseGrid((EntityUid) (deed?.ShuttleUid!)); + int sellValue = 0; + if (deed?.ShuttleUid != null) + sellValue = (int) _pricing.AppraiseGrid((EntityUid) (deed?.ShuttleUid!)); sellValue -= CalculateSalesTax(component, sellValue); - var fullName = deed != null ? GetFullName(deed) : null; - RefreshState(uid, bank.Balance, true, fullName, sellValue, targetId.HasValue, (ShipyardConsoleUiKey) uiComp.Key); - } + var fullName = deed != null ? GetFullName(deed) : null; + RefreshState(uid, bank.Balance, true, fullName, sellValue, targetId, + (ShipyardConsoleUiKey) uiComp.Key); + } /// @@ -519,7 +522,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 +540,26 @@ 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 accessReaderComponent); + var shuttles = _prototypeManager.EnumeratePrototypes().Where(x => { - var protos = _prototypeManager.EnumeratePrototypes(); - foreach (var proto in protos) - { - if (proto.Group == group) - availableShuttles.Add(proto.ID); - } - } + return + // if the listing contains the shuttle, add it to the list or + ((listing?.Shuttles.Contains(x.ID) ?? false) || - // Add all prototypes specified in ShipyardListing - if (listing != null || TryComp(uid, out listing)) - { - foreach (var shuttle in listing.Shuttles) - { - availableShuttles.Add(shuttle); - } - } + // 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) && x.Group == group)) && + + // and the user has the required access, add it to the list + (string.IsNullOrEmpty(x.Access) || (accessReaderComponent?.Tags.Contains(x.Access) ?? false)); + + }).Select(x=>x.ID).ToList(); - return availableShuttles; + return shuttles; } - 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 +568,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..b9d7d083e99 100644 --- a/Content.Shared/Access/Components/IdCardConsoleComponent.cs +++ b/Content.Shared/Access/Components/IdCardConsoleComponent.cs @@ -45,7 +45,8 @@ public WriteToTargetIdMessage(string fullName, string jobTitle, List> AccessLevels = new() { "Armory", - //"Atmospherics", + "Atmospherics", + "Bailiff", // Frontier //"Bar", "Brig", "Detective", @@ -57,7 +58,7 @@ public WriteToTargetIdMessage(string fullName, string jobTitle, List + /// The access of 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/_NF/Access/security.yml b/Resources/Prototypes/_NF/Access/security.yml index d6fa4f60a31..f2affe7fe88 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: @@ -19,3 +34,21 @@ - Maintenance - External - Brig + +- type: accessGroup + id: OfficerNfsdAccess + tags: + - Sergeant + +- type: accessGroup + id: ExecutiveNfsdAccess + tags: + - Sergeant + - Bailiff + +- type: accessGroup + id: CommandNfsdAccess + tags: + - Sergeant + - Bailiff + - HeadOfSecurity diff --git a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml index c80618ab4eb..2d340761300 100644 --- a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml +++ b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml @@ -25,6 +25,9 @@ - Mercenary # Frontier - Captain # Frontier - Armory + accessGroups: # Frontier + - GeneralNfsdAccess # Frontier + - ExecutiveNfsdAccess # 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/senior_officer.yml b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/senior_officer.yml index 657a142d21d..dfc2d497d63 100644 --- a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/senior_officer.yml +++ b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/senior_officer.yml @@ -18,6 +18,7 @@ canBeAntag: false accessGroups: # Frontier - GeneralNfsdAccess # Frontier + - OfficerNfsdAccess # Frontier special: - !type:AddImplantSpecial implants: [ MindShieldImplant, TrackingImplant ] diff --git a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/sheriff.yml b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/sheriff.yml index 374d6da671d..2f4e6e2619f 100644 --- a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/sheriff.yml +++ b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/sheriff.yml @@ -26,6 +26,8 @@ canBeAntag: false accessGroups: - AllAccess + - GeneralNfsdAccess # Frontier + - CommandNfsdAccess # Frontier special: - !type:AddImplantSpecial implants: [ MindShieldImplant, TrackingImplant ] 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..f49305f9acd 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: Bailiff 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..4e2944ee64c 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: Sergeant 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 From 945cc87c287276de94fb72556edbe26d4b555df7 Mon Sep 17 00:00:00 2001 From: neuPanda Date: Mon, 3 Jun 2024 16:41:44 -0400 Subject: [PATCH 02/12] removed: Atmospherics and Engineering from ID console --- Content.Shared/Access/Components/IdCardConsoleComponent.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Access/Components/IdCardConsoleComponent.cs b/Content.Shared/Access/Components/IdCardConsoleComponent.cs index b9d7d083e99..dba5cb78118 100644 --- a/Content.Shared/Access/Components/IdCardConsoleComponent.cs +++ b/Content.Shared/Access/Components/IdCardConsoleComponent.cs @@ -45,7 +45,7 @@ public WriteToTargetIdMessage(string fullName, string jobTitle, List> AccessLevels = new() { "Armory", - "Atmospherics", + //"Atmospherics", "Bailiff", // Frontier //"Bar", "Brig", @@ -58,7 +58,7 @@ public WriteToTargetIdMessage(string fullName, string jobTitle, List Date: Sat, 1 Jun 2024 08:42:08 -0500 Subject: [PATCH 03/12] Update IdCardConsoleComponent.cs Fixing issue where re-sharper removed un-used using statements per request. --- Content.Shared/Access/Components/IdCardConsoleComponent.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Content.Shared/Access/Components/IdCardConsoleComponent.cs b/Content.Shared/Access/Components/IdCardConsoleComponent.cs index dba5cb78118..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; From 79f6c75855a45f46ae85a9603275fa19f997ec51 Mon Sep 17 00:00:00 2001 From: neuPanda Date: Sat, 1 Jun 2024 08:10:17 -0500 Subject: [PATCH 04/12] NFSD Access Overhaul Fixed ship console refresh on id insert or removal Added Access to VesselPrototype Added Filtration to Ship List based off of Access Added Bailiff and Sergeant Access levels Added Access levels to all NFSD ship Added appropriate access groups to NFSD roles --- Content.Shared/Access/Components/IdCardConsoleComponent.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Content.Shared/Access/Components/IdCardConsoleComponent.cs b/Content.Shared/Access/Components/IdCardConsoleComponent.cs index 9376457f075..0c0e405da04 100644 --- a/Content.Shared/Access/Components/IdCardConsoleComponent.cs +++ b/Content.Shared/Access/Components/IdCardConsoleComponent.cs @@ -3,8 +3,6 @@ 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; @@ -60,7 +58,7 @@ public WriteToTargetIdMessage(string fullName, string jobTitle, List Date: Mon, 3 Jun 2024 16:41:44 -0400 Subject: [PATCH 05/12] removed: Atmospherics and Engineering from ID console --- Content.Shared/Access/Components/IdCardConsoleComponent.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Shared/Access/Components/IdCardConsoleComponent.cs b/Content.Shared/Access/Components/IdCardConsoleComponent.cs index 0c0e405da04..dba5cb78118 100644 --- a/Content.Shared/Access/Components/IdCardConsoleComponent.cs +++ b/Content.Shared/Access/Components/IdCardConsoleComponent.cs @@ -58,7 +58,7 @@ public WriteToTargetIdMessage(string fullName, string jobTitle, List Date: Sat, 1 Jun 2024 08:42:08 -0500 Subject: [PATCH 06/12] Update IdCardConsoleComponent.cs Fixing issue where re-sharper removed un-used using statements per request. --- Content.Shared/Access/Components/IdCardConsoleComponent.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Content.Shared/Access/Components/IdCardConsoleComponent.cs b/Content.Shared/Access/Components/IdCardConsoleComponent.cs index dba5cb78118..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; From 0d4e6165b8d8715451fcd2e7f6ad961179ebcc98 Mon Sep 17 00:00:00 2001 From: neuPanda Date: Thu, 13 Jun 2024 22:12:34 -0400 Subject: [PATCH 07/12] Updating Access per request, fixing SR access to include Srg and Bailiff --- Resources/Prototypes/Access/misc.yml | 2 ++ Resources/Prototypes/_NF/Shipyard/Nfsd/broadhead.yml | 1 + Resources/Prototypes/_NF/Shipyard/Nfsd/hospitaller.yml | 2 +- Resources/Prototypes/_NF/Shipyard/Nfsd/templar.yml | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) 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/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/hospitaller.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/hospitaller.yml index f49305f9acd..b1fa5df291a 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/hospitaller.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/hospitaller.yml @@ -5,7 +5,7 @@ price: 28220 category: Small group: Security - access: Bailiff + access: Security shuttlePath: /Maps/_NF/Shuttles/Nfsd/hospitaller.yml - type: gameMap diff --git a/Resources/Prototypes/_NF/Shipyard/Nfsd/templar.yml b/Resources/Prototypes/_NF/Shipyard/Nfsd/templar.yml index 4e2944ee64c..4a9a3afd7ae 100644 --- a/Resources/Prototypes/_NF/Shipyard/Nfsd/templar.yml +++ b/Resources/Prototypes/_NF/Shipyard/Nfsd/templar.yml @@ -5,7 +5,7 @@ price: 24220 category: Small group: Security - access: Sergeant + access: Security shuttlePath: /Maps/_NF/Shuttles/Nfsd/templar.yml - type: gameMap From 10c0a4544beae2c49ce3ab94334133c079ffd190 Mon Sep 17 00:00:00 2001 From: neuPanda Date: Tue, 2 Jul 2024 00:02:45 -0400 Subject: [PATCH 08/12] fixing mirge issue that VS so politly decided to fuck up and then hide the fact that the code would not compile by compiling old code like the little shit that it is. thank god i dont have to be proffessional with my code comments here like i do at work because i ant shit talk VS or Git when i am working so i shall unleach all my rage in this commnet for the 2 of them (git and VS) for being dicks and wasting everybody's time --- .../Systems/ShipyardSystem.Consoles.cs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs b/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs index cf26cdb7450..84018b99748 100644 --- a/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs +++ b/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs @@ -453,8 +453,6 @@ private void OnItemSlotChanged(EntityUid uid, ShipyardConsoleComponent component // kind of cursed. We need to update the UI when an Id is entered, but the UI needs to know the player characters bank account. if (!TryComp(uid, out var uiComp) || uiComp.Key == null) return; - if (uiComp.CurrentSingleUser is not { Valid: true } player) - return; var uiUsers = _ui.GetActors(uid, uiComp.Key); @@ -466,7 +464,7 @@ private void OnItemSlotChanged(EntityUid uid, ShipyardConsoleComponent component if (!TryComp(player, out var bank)) continue; - var targetId = component.TargetIdSlot.ContainerSlot?.ContainedEntity; + var targetId = component.TargetIdSlot.ContainerSlot?.ContainedEntity; if (TryComp(targetId, out var deed)) { @@ -477,16 +475,22 @@ private void OnItemSlotChanged(EntityUid uid, ShipyardConsoleComponent component } } - int sellValue = 0; - if (deed?.ShuttleUid != null) - sellValue = (int) _pricing.AppraiseGrid((EntityUid) (deed?.ShuttleUid!)); + int sellValue = 0; + if (deed?.ShuttleUid != null) + sellValue = (int) _pricing.AppraiseGrid((EntityUid) (deed?.ShuttleUid!)); sellValue -= CalculateSalesTax(component, sellValue); - var fullName = deed != null ? GetFullName(deed) : null; - RefreshState(uid, bank.Balance, true, fullName, sellValue, targetId, - (ShipyardConsoleUiKey) uiComp.Key); + var fullName = deed != null ? GetFullName(deed) : null; + RefreshState(uid, + bank.Balance, + true, + fullName, + sellValue, + targetId, + (ShipyardConsoleUiKey) uiComp.Key); + } } /// From 09c8716381f9930622b38b01523db1458a8462b7 Mon Sep 17 00:00:00 2001 From: Whatstone Date: Fri, 5 Jul 2024 22:44:31 -0400 Subject: [PATCH 09/12] ShipyardSystem cleanup, LINQ removal, vessel proto --- .../Systems/ShipyardSystem.Consoles.cs | 26 ++++++++++--------- .../Shipyard/Prototypes/VesselPrototype.cs | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs b/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs index 84018b99748..66b88f6331d 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; @@ -106,7 +104,7 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component return; } - if (!GetAvailableShuttles(uid,null, null, targetId).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."); @@ -545,22 +543,26 @@ public List GetAvailableShuttles(EntityUid uid, ShipyardConsoleUiKey? ke } TryComp(targetId, out var accessReaderComponent); - var shuttles = _prototypeManager.EnumeratePrototypes().Where(x => + foreach (var vessel in _prototypeManager.EnumeratePrototypes()) { - return + // If the user lacks access to this shuttle, skip it. + if (!string.IsNullOrEmpty(vessel.Access) && (accessReaderComponent?.Tags.Contains(vessel.Access) ?? false)) + continue; + + // 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 - ((listing?.Shuttles.Contains(x.ID) ?? false) || // 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) && x.Group == group)) && - - // and the user has the required access, add it to the list - (string.IsNullOrEmpty(x.Access) || (accessReaderComponent?.Tags.Contains(x.Access) ?? false)); + ShipyardGroupMapping.TryGetValue(key.Value, out var group) && vessel.Group == group)) + { + availableShuttles.Add(vessel.ID); + } - }).Select(x=>x.ID).ToList(); + } - return shuttles; + return availableShuttles; } private void RefreshState(EntityUid uid, int balance, bool access, string? shipDeed, int shipSellValue, EntityUid? targetId, ShipyardConsoleUiKey uiKey) diff --git a/Content.Shared/Shipyard/Prototypes/VesselPrototype.cs b/Content.Shared/Shipyard/Prototypes/VesselPrototype.cs index dfb97288d90..8d206199d2e 100644 --- a/Content.Shared/Shipyard/Prototypes/VesselPrototype.cs +++ b/Content.Shared/Shipyard/Prototypes/VesselPrototype.cs @@ -41,7 +41,7 @@ public sealed class VesselPrototype : IPrototype public string Group = string.Empty; /// - /// The access of the product. (e.g. Command, Mail, Bailiff, etc.) + /// The access required to buy the product. (e.g. Command, Mail, Bailiff, etc.) /// [DataField("access")] public string Access = string.Empty; From ea5ad2a63312884cf782b1c5e88d941688ef8cd9 Mon Sep 17 00:00:00 2001 From: Whatstone Date: Fri, 5 Jul 2024 22:52:33 -0400 Subject: [PATCH 10/12] Access: prefer NFSD accesses outright to groups --- Resources/Prototypes/_NF/Access/security.yml | 22 ++----------------- .../_NF/Roles/Jobs/Nfsd/bailiff.yml | 10 ++------- .../_NF/Roles/Jobs/Nfsd/detectivenf.yml | 9 ++------ .../_NF/Roles/Jobs/Nfsd/senior_officer.yml | 3 ++- .../_NF/Roles/Jobs/Nfsd/sheriff.yml | 2 -- 5 files changed, 8 insertions(+), 38 deletions(-) diff --git a/Resources/Prototypes/_NF/Access/security.yml b/Resources/Prototypes/_NF/Access/security.yml index f2affe7fe88..41a15a2b340 100644 --- a/Resources/Prototypes/_NF/Access/security.yml +++ b/Resources/Prototypes/_NF/Access/security.yml @@ -4,11 +4,11 @@ - type: accessLevel id: Sergeant - name: id-card-access-level-sergeant + name: id-card-access-level-sergeant - type: accessLevel id: Bailiff - name: id-card-access-level-bailiff + name: id-card-access-level-bailiff - type: accessGroup id: CadetNfsdAccess @@ -34,21 +34,3 @@ - Maintenance - External - Brig - -- type: accessGroup - id: OfficerNfsdAccess - tags: - - Sergeant - -- type: accessGroup - id: ExecutiveNfsdAccess - tags: - - Sergeant - - Bailiff - -- type: accessGroup - id: CommandNfsdAccess - tags: - - Sergeant - - Bailiff - - HeadOfSecurity diff --git a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml index 2d340761300..48c23950ec0 100644 --- a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml +++ b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/bailiff.yml @@ -17,17 +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 - - ExecutiveNfsdAccess # Frontier special: - !type:AddImplantSpecial implants: [ MindShieldImplant, TrackingImplant ] # Frontier 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 dfc2d497d63..e6354dd97ae 100644 --- a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/senior_officer.yml +++ b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/senior_officer.yml @@ -16,9 +16,10 @@ icon: "JobIconSeniorOfficer" # Frontier supervisors: job-supervisors-bailiff canBeAntag: false + access: + - Sergeant # Frontier accessGroups: # Frontier - GeneralNfsdAccess # Frontier - - OfficerNfsdAccess # Frontier special: - !type:AddImplantSpecial implants: [ MindShieldImplant, TrackingImplant ] diff --git a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/sheriff.yml b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/sheriff.yml index 2f4e6e2619f..374d6da671d 100644 --- a/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/sheriff.yml +++ b/Resources/Prototypes/_NF/Roles/Jobs/Nfsd/sheriff.yml @@ -26,8 +26,6 @@ canBeAntag: false accessGroups: - AllAccess - - GeneralNfsdAccess # Frontier - - CommandNfsdAccess # Frontier special: - !type:AddImplantSpecial implants: [ MindShieldImplant, TrackingImplant ] From c111ff4d3496aeb8d553d74c08bc0a793a692a40 Mon Sep 17 00:00:00 2001 From: Whatstone Date: Sat, 6 Jul 2024 00:01:44 -0400 Subject: [PATCH 11/12] Shipyard console: fix condition, check accessgroup --- .../Systems/ShipyardSystem.Consoles.cs | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs b/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs index 66b88f6331d..0da5fe61987 100644 --- a/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs +++ b/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs @@ -37,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; @@ -542,12 +543,34 @@ public List GetAvailableShuttles(EntityUid uid, ShipyardConsoleUiKey? ke } } - TryComp(targetId, out var accessReaderComponent); + TryComp(targetId, out var accessComponent); foreach (var vessel in _prototypeManager.EnumeratePrototypes()) { // If the user lacks access to this shuttle, skip it. - if (!string.IsNullOrEmpty(vessel.Access) && (accessReaderComponent?.Tags.Contains(vessel.Access) ?? false)) - continue; + if (!string.IsNullOrEmpty(vessel.Access)) + { + bool hasAccess = false; + // Check tags + if (accessComponent?.Tags.Contains(vessel.Access) ?? false) + hasAccess = true; + + 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; + } + } + } + + if (!hasAccess) + continue; + } // 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) || From ac73fdf868eacb434d39ec9c623d2cb84a8d1dbb Mon Sep 17 00:00:00 2001 From: Whatstone Date: Sat, 6 Jul 2024 06:44:07 -0400 Subject: [PATCH 12/12] ShipyardSystem: comment skipping for no access --- Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs b/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs index 0da5fe61987..8fddc87f695 100644 --- a/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs +++ b/Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs @@ -546,7 +546,7 @@ public List GetAvailableShuttles(EntityUid uid, ShipyardConsoleUiKey? ke TryComp(targetId, out var accessComponent); foreach (var vessel in _prototypeManager.EnumeratePrototypes()) { - // If the user lacks access to this shuttle, skip it. + // If the vessel needs access to be bought, check the user's access. if (!string.IsNullOrEmpty(vessel.Access)) { bool hasAccess = false; @@ -554,6 +554,7 @@ public List GetAvailableShuttles(EntityUid uid, ShipyardConsoleUiKey? ke 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>(); @@ -568,6 +569,7 @@ public List GetAvailableShuttles(EntityUid uid, ShipyardConsoleUiKey? ke } } + // No access to this vessel, skip to the next one. if (!hasAccess) continue; }