From 528557383a1cbb09efdf9e6cbac23ae448f04c33 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Date: Sun, 12 May 2024 21:46:57 -0700 Subject: [PATCH 1/7] Loadouts (#45) Description copied from my Wizard's Den PR Resolves https://github.com/Simple-Station/Einstein-Engines/issues/32 # TODO - [x] CVars - [x] Server side loadout point validation - Make tabContainer less bad - [x] Move head clothes to loadouts from lockers - [x] Move job starting equipment to loadouts - [x] Loadout item preview - [x] Fix loadouts duplicating on server restart - [x] Make sure everything is localized -- Components and Tags are an odd thing to display to the player in the whitelist and are very unrealistic to make localizations for, so.. not doing that, what do I do? - [x] Fix all items going into the bag no matter their size - [x] Add min/cur/max points to the bar - [x] Use buttons instead of checkboxes - [x] "Show Unusable" button to hide things your character currently doesn't match the whitelists for - [x] Time whitelist option - [x] Species whitelist option - [x] Trait whitelist option instead of EntityWhitelist for the sake of localization - [ ] More loadouts (filler things while waiting for review) - [ ] - Golden or themed items for Command roles with an undecided amount of playtime on their respective jobs - [x] - Goliath cloak for playing a lot of Salvage - [x] - Senior items for playing a lot of its respective role - [ ] - Varying materials of pocket watches for people with varying overall playtime - [x] Fix loadout selectors not updating to match current preferences

Media (Click Me!)

I need to rerecord these https://github.com/space-wizards/space-station-14/assets/77995199/59713874-b043-4813-848e-56b2951b6935 https://github.com/space-wizards/space-station-14/assets/77995199/40180aee-bfe3-4f30-9df8-0f628e7e4514

# Changelog :cl: - add: Added a new character customization tab for selecting items to start your shift with, loadouts! - remove: Removed some default job equipment in favor of loadouts - remove: Removed several clothing items from Command lockers in favor of loadouts --------- Co-authored-by: VMSolidus --- .../Lobby/UI/LobbyCharacterPreviewPanel.cs | 13 +- .../JobRequirementsManager.cs | 16 +- .../Preferences/UI/CharacterSetupGui.xaml.cs | 3 +- .../Preferences/UI/HumanoidProfileEditor.xaml | 15 + .../UI/HumanoidProfileEditor.xaml.cs | 397 +++- .../Tests/Preferences/ServerDbSqliteTests.cs | 5 +- .../20240505230501_Loadouts.Designer.cs | 1802 +++++++++++++++++ .../Postgres/20240505230501_Loadouts.cs | 48 + .../PostgresServerDbContextModelSnapshot.cs | 41 + .../20240505230431_Loadouts.Designer.cs | 1731 ++++++++++++++++ .../Sqlite/20240505230431_Loadouts.cs | 47 + .../SqliteServerDbContextModelSnapshot.cs | 39 + Content.Server.Database/Model.cs | 18 +- .../Clothing/Systems/LoadoutSystem.cs | 49 + Content.Server/Database/ServerDbBase.cs | 12 +- Content.Shared/CCVar/CCVars.cs | 12 + Content.Shared/Clothing/LoadoutSystem.cs | 35 - .../Prototypes/LoadoutCategoryPrototype.cs | 13 + .../Loadouts/Prototypes/LoadoutPrototype.cs | 45 + .../Loadouts/Systems/LoadoutRequirements.cs | 375 ++++ .../Loadouts/Systems/LoadoutSystem.cs | 149 ++ .../Preferences/HumanoidCharacterProfile.cs | 129 +- Content.Shared/Roles/JobRequirements.cs | 15 +- .../Locale/en-US/loadouts/categories.ftl | 7 + Resources/Locale/en-US/loadouts/eyes.ftl | 2 + Resources/Locale/en-US/loadouts/head.ftl | 2 + Resources/Locale/en-US/loadouts/items.ftl | 13 + .../Locale/en-US/loadouts/jobs/cargo.ftl | 1 + .../en-US/loadouts/jobs/engineering.ftl | 5 + .../en-US/loadouts/jobs/heads/captain.ftl | 12 + .../loadouts/jobs/heads/chiefEngineer.ftl | 3 + .../jobs/heads/chiefMedicalOfficer.ftl | 5 + .../loadouts/jobs/heads/headOfPersonnel.ftl | 4 + .../loadouts/jobs/heads/headOfSecurity.ftl | 10 + .../loadouts/jobs/heads/quarterMaster.ftl | 3 + .../loadouts/jobs/heads/researchDirector.ftl | 3 + .../Locale/en-US/loadouts/jobs/medical.ftl | 3 + .../Locale/en-US/loadouts/jobs/science.ftl | 3 + .../Locale/en-US/loadouts/jobs/security.ftl | 3 + .../Locale/en-US/loadouts/jobs/service.ftl | 7 + .../en-US/loadouts/loadout-requirements.ftl | 13 + Resources/Locale/en-US/loadouts/neck.ftl | 0 .../Locale/en-US/loadouts/outerClothing.ftl | 5 + Resources/Locale/en-US/loadouts/shoes.ftl | 10 + Resources/Locale/en-US/loadouts/uniform.ftl | 1 + .../ui/humanoid-profile-editor.ftl | 10 + .../Catalog/Fills/Lockers/heads.yml | 32 - .../Loadouts/Jobs/Heads/captain.yml | 148 ++ .../Loadouts/Jobs/Heads/chiefEngineer.yml | 46 + .../Jobs/Heads/chiefMedicalOfficer.yml | 68 + .../Loadouts/Jobs/Heads/headOfPersonnel.yml | 104 + .../Loadouts/Jobs/Heads/headOfSecurity.yml | 175 ++ .../Loadouts/Jobs/Heads/quarterMaster.yml | 71 + .../Loadouts/Jobs/Heads/researchDirector.yml | 57 + Resources/Prototypes/Loadouts/Jobs/cargo.yml | 14 + .../Prototypes/Loadouts/Jobs/engineering.yml | 170 ++ .../Prototypes/Loadouts/Jobs/medical.yml | 197 ++ .../Prototypes/Loadouts/Jobs/science.yml | 86 + .../Prototypes/Loadouts/Jobs/security.yml | 89 + .../Prototypes/Loadouts/Jobs/service.yml | 183 ++ Resources/Prototypes/Loadouts/categories.yml | 18 + Resources/Prototypes/Loadouts/eyes.yml | 13 + Resources/Prototypes/Loadouts/head.yml | 125 ++ Resources/Prototypes/Loadouts/items.yml | 90 + Resources/Prototypes/Loadouts/neck.yml | 27 + .../Prototypes/Loadouts/outerClothing.yml | 34 + Resources/Prototypes/Loadouts/shoes.yml | 98 + Resources/Prototypes/Loadouts/uniform.yml | 261 +++ .../Entities/Clothing/OuterClothing/coats.yml | 4 +- .../Roles/Jobs/Engineering/chief_engineer.yml | 1 - .../Jobs/Engineering/station_engineer.yml | 2 - .../Prototypes/Roles/Jobs/Medical/chemist.yml | 2 - .../Jobs/Medical/chief_medical_officer.yml | 1 - .../Roles/Jobs/Medical/medical_doctor.yml | 1 - .../Roles/Jobs/Science/research_director.yml | 2 - .../Roles/Jobs/Security/head_of_security.yml | 2 - 76 files changed, 7105 insertions(+), 150 deletions(-) create mode 100644 Content.Server.Database/Migrations/Postgres/20240505230501_Loadouts.Designer.cs create mode 100644 Content.Server.Database/Migrations/Postgres/20240505230501_Loadouts.cs create mode 100644 Content.Server.Database/Migrations/Sqlite/20240505230431_Loadouts.Designer.cs create mode 100644 Content.Server.Database/Migrations/Sqlite/20240505230431_Loadouts.cs create mode 100644 Content.Server/Clothing/Systems/LoadoutSystem.cs delete mode 100644 Content.Shared/Clothing/LoadoutSystem.cs create mode 100644 Content.Shared/Clothing/Loadouts/Prototypes/LoadoutCategoryPrototype.cs create mode 100644 Content.Shared/Clothing/Loadouts/Prototypes/LoadoutPrototype.cs create mode 100644 Content.Shared/Clothing/Loadouts/Systems/LoadoutRequirements.cs create mode 100644 Content.Shared/Clothing/Loadouts/Systems/LoadoutSystem.cs create mode 100644 Resources/Locale/en-US/loadouts/categories.ftl create mode 100644 Resources/Locale/en-US/loadouts/eyes.ftl create mode 100644 Resources/Locale/en-US/loadouts/head.ftl create mode 100644 Resources/Locale/en-US/loadouts/items.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/cargo.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/engineering.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/heads/captain.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/heads/chiefEngineer.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/heads/chiefMedicalOfficer.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/heads/headOfPersonnel.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/heads/headOfSecurity.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/heads/quarterMaster.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/heads/researchDirector.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/medical.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/science.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/security.ftl create mode 100644 Resources/Locale/en-US/loadouts/jobs/service.ftl create mode 100644 Resources/Locale/en-US/loadouts/loadout-requirements.ftl create mode 100644 Resources/Locale/en-US/loadouts/neck.ftl create mode 100644 Resources/Locale/en-US/loadouts/outerClothing.ftl create mode 100644 Resources/Locale/en-US/loadouts/shoes.ftl create mode 100644 Resources/Locale/en-US/loadouts/uniform.ftl create mode 100644 Resources/Prototypes/Loadouts/Jobs/Heads/captain.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/Heads/chiefEngineer.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/Heads/chiefMedicalOfficer.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/Heads/headOfPersonnel.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/Heads/headOfSecurity.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/Heads/quarterMaster.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/Heads/researchDirector.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/cargo.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/engineering.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/medical.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/science.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/security.yml create mode 100644 Resources/Prototypes/Loadouts/Jobs/service.yml create mode 100644 Resources/Prototypes/Loadouts/categories.yml create mode 100644 Resources/Prototypes/Loadouts/eyes.yml create mode 100644 Resources/Prototypes/Loadouts/head.yml create mode 100644 Resources/Prototypes/Loadouts/items.yml create mode 100644 Resources/Prototypes/Loadouts/neck.yml create mode 100644 Resources/Prototypes/Loadouts/outerClothing.yml create mode 100644 Resources/Prototypes/Loadouts/shoes.yml create mode 100644 Resources/Prototypes/Loadouts/uniform.yml diff --git a/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs b/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs index f9481caa3bb..59a518f2696 100644 --- a/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs +++ b/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs @@ -1,16 +1,14 @@ using System.Linq; using System.Numerics; -using Content.Client.Alerts; using Content.Client.Humanoid; using Content.Client.Inventory; using Content.Client.Preferences; using Content.Client.UserInterface.Controls; +using Content.Shared.Clothing.Loadouts.Systems; using Content.Shared.GameTicking; using Content.Shared.Humanoid.Prototypes; -using Content.Shared.Inventory; using Content.Shared.Preferences; using Content.Shared.Roles; -using Robust.Client.GameObjects; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Shared.Map; @@ -126,6 +124,7 @@ public void UpdateUI() _summaryLabel.Text = selectedCharacter.Summary; _entityManager.System().LoadProfile(_previewDummy.Value, selectedCharacter); GiveDummyJobClothes(_previewDummy.Value, selectedCharacter); + GiveDummyLoadoutItems(_previewDummy.Value, selectedCharacter); } } } @@ -162,5 +161,13 @@ public static void GiveDummyJobClothes(EntityUid dummy, HumanoidCharacterProfile } } } + + public static void GiveDummyLoadoutItems(EntityUid dummy, HumanoidCharacterProfile profile) + { + var highPriorityJobId = profile.JobPriorities.FirstOrDefault(j => j.Value == JobPriority.High).Key; + var highPriorityJob = IoCManager.Resolve().Index(highPriorityJobId ?? SharedGameTicker.FallbackOverflowJob); + + EntitySystem.Get().ApplyCharacterLoadout(dummy, highPriorityJob, profile); + } } } diff --git a/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs b/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs index b8267ea2955..7688a3b3aaa 100644 --- a/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs +++ b/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs @@ -21,7 +21,7 @@ public sealed partial class JobRequirementsManager [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPrototypeManager _prototypes = default!; - private readonly Dictionary _roles = new(); + public readonly Dictionary PlayTimes = new(); private readonly List _roleBans = new(); private ISawmill _sawmill = default!; @@ -45,7 +45,7 @@ private void ClientOnRunLevelChanged(object? sender, RunLevelChangedEventArgs e) if (e.NewLevel == ClientRunLevel.Initialize) { // Reset on disconnect, just in case. - _roles.Clear(); + PlayTimes.Clear(); } } @@ -63,12 +63,12 @@ private void RxRoleBans(MsgRoleBans message) private void RxPlayTime(MsgPlayTime message) { - _roles.Clear(); + PlayTimes.Clear(); // NOTE: do not assign _roles = message.Trackers due to implicit data sharing in integration tests. foreach (var (tracker, time) in message.Trackers) { - _roles[tracker] = time; + PlayTimes[tracker] = time; } /*var sawmill = Logger.GetSawmill("play_time"); @@ -96,7 +96,7 @@ public bool IsAllowed(JobPrototype job, [NotNullWhen(false)] out FormattedMessag return CheckRoleTime(job.Requirements, out reason); } - public bool CheckRoleTime(HashSet? requirements, [NotNullWhen(false)] out FormattedMessage? reason) + public bool CheckRoleTime(HashSet? requirements, [NotNullWhen(false)] out FormattedMessage? reason, string? localePrefix = null) { reason = null; @@ -106,7 +106,7 @@ public bool CheckRoleTime(HashSet? requirements, [NotNullWhen(fa var reasons = new List(); foreach (var requirement in requirements) { - if (JobRequirements.TryRequirementMet(requirement, _roles, out var jobReason, _entManager, _prototypes, _whitelisted)) + if (JobRequirements.TryRequirementMet(requirement, PlayTimes, out var jobReason, _entManager, _prototypes, _whitelisted, localePrefix)) continue; reasons.Add(jobReason.ToMarkup()); @@ -118,7 +118,7 @@ public bool CheckRoleTime(HashSet? requirements, [NotNullWhen(fa public TimeSpan FetchOverallPlaytime() { - return _roles.TryGetValue("Overall", out var overallPlaytime) ? overallPlaytime : TimeSpan.Zero; + return PlayTimes.TryGetValue("Overall", out var overallPlaytime) ? overallPlaytime : TimeSpan.Zero; } public IEnumerable> FetchPlaytimeByRoles() @@ -127,7 +127,7 @@ public IEnumerable> FetchPlaytimeByRoles() foreach (var job in jobsToMap) { - if (_roles.TryGetValue(job.PlayTimeTracker, out var locJobName)) + if (PlayTimes.TryGetValue(job.PlayTimeTracker, out var locJobName)) { yield return new KeyValuePair(job.Name, locJobName); } diff --git a/Content.Client/Preferences/UI/CharacterSetupGui.xaml.cs b/Content.Client/Preferences/UI/CharacterSetupGui.xaml.cs index f1052086de6..dba96d74b6c 100644 --- a/Content.Client/Preferences/UI/CharacterSetupGui.xaml.cs +++ b/Content.Client/Preferences/UI/CharacterSetupGui.xaml.cs @@ -181,6 +181,7 @@ public CharacterPickerButton( if (humanoid != null) { LobbyCharacterPreviewPanel.GiveDummyJobClothes(_previewDummy, humanoid); + LobbyCharacterPreviewPanel.GiveDummyLoadoutItems(_previewDummy, humanoid); } var isSelectedCharacter = profile == preferencesManager.Preferences?.SelectedCharacter; @@ -229,10 +230,8 @@ public CharacterPickerButton( }; deleteButton.OnPressed += _ => { - deleteButton.Visible = false; confirmDeleteButton.Visible = true; - }; var internalHBox = new BoxContainer diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml index d0dd02a58ad..9a70d678310 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml @@ -85,6 +85,12 @@