Skip to content

Commit

Permalink
Loadouts (#45)
Browse files Browse the repository at this point in the history
Description copied from my Wizard's Den PR
Resolves Simple-Station/Einstein-Engines#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

<details><summary><h1>Media (Click Me!)</h1></summary>
<p>

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

</p>
</details> 

# 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 <[email protected]>
  • Loading branch information
DEATHB4DEFEAT and VMSolidus committed May 13, 2024
1 parent 255e307 commit 5285573
Show file tree
Hide file tree
Showing 76 changed files with 7,105 additions and 150 deletions.
13 changes: 10 additions & 3 deletions Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -126,6 +124,7 @@ public void UpdateUI()
_summaryLabel.Text = selectedCharacter.Summary;
_entityManager.System<HumanoidAppearanceSystem>().LoadProfile(_previewDummy.Value, selectedCharacter);
GiveDummyJobClothes(_previewDummy.Value, selectedCharacter);
GiveDummyLoadoutItems(_previewDummy.Value, selectedCharacter);
}
}
}
Expand Down Expand Up @@ -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<IPrototypeManager>().Index<JobPrototype>(highPriorityJobId ?? SharedGameTicker.FallbackOverflowJob);

EntitySystem.Get<LoadoutSystem>().ApplyCharacterLoadout(dummy, highPriorityJob, profile);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public sealed partial class JobRequirementsManager
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypes = default!;

private readonly Dictionary<string, TimeSpan> _roles = new();
public readonly Dictionary<string, TimeSpan> PlayTimes = new();
private readonly List<string> _roleBans = new();

private ISawmill _sawmill = default!;
Expand All @@ -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();
}
}

Expand All @@ -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");
Expand Down Expand Up @@ -96,7 +96,7 @@ public bool IsAllowed(JobPrototype job, [NotNullWhen(false)] out FormattedMessag
return CheckRoleTime(job.Requirements, out reason);
}

public bool CheckRoleTime(HashSet<JobRequirement>? requirements, [NotNullWhen(false)] out FormattedMessage? reason)
public bool CheckRoleTime(HashSet<JobRequirement>? requirements, [NotNullWhen(false)] out FormattedMessage? reason, string? localePrefix = null)
{
reason = null;

Expand All @@ -106,7 +106,7 @@ public bool CheckRoleTime(HashSet<JobRequirement>? requirements, [NotNullWhen(fa
var reasons = new List<string>();
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());
Expand All @@ -118,7 +118,7 @@ public bool CheckRoleTime(HashSet<JobRequirement>? 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<KeyValuePair<string, TimeSpan>> FetchPlaytimeByRoles()
Expand All @@ -127,7 +127,7 @@ public IEnumerable<KeyValuePair<string, TimeSpan>> 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<string, TimeSpan>(job.Name, locJobName);
}
Expand Down
3 changes: 1 addition & 2 deletions Content.Client/Preferences/UI/CharacterSetupGui.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public CharacterPickerButton(
if (humanoid != null)
{
LobbyCharacterPreviewPanel.GiveDummyJobClothes(_previewDummy, humanoid);
LobbyCharacterPreviewPanel.GiveDummyLoadoutItems(_previewDummy, humanoid);
}

var isSelectedCharacter = profile == preferencesManager.Preferences?.SelectedCharacter;
Expand Down Expand Up @@ -229,10 +230,8 @@ public CharacterPickerButton(
};
deleteButton.OnPressed += _ =>
{
deleteButton.Visible = false;
confirmDeleteButton.Visible = true;
};

var internalHBox = new BoxContainer
Expand Down
15 changes: 15 additions & 0 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@
<Control HorizontalExpand="True"/>
<Button Name="ShowClothes" Pressed="True" ToggleMode="True" Text="{Loc 'humanoid-profile-editor-clothing-show'}" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Show loadouts -->
<BoxContainer HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-loadouts'}" />
<Control HorizontalExpand="True"/>
<Button Name="ShowLoadouts" Pressed="True" ToggleMode="True" Text="{Loc 'Show'}" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Clothing -->
<BoxContainer HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-clothing-label'}" />
Expand Down Expand Up @@ -142,6 +148,15 @@
<BoxContainer Name="CTraitsList" Orientation="Vertical" />
</ScrollContainer>
</BoxContainer>
<BoxContainer Name="CLoadoutsTab" Orientation="Vertical" Margin="10">
<!-- Loadouts -->
<Label Name="LoadoutPointsLabel" HorizontalAlignment="Stretch" Align="Center" />
<ProgressBar Name="LoadoutPointsBar" MaxValue="1" Value="1" MaxHeight="8" Margin="0 5" />

<Button Name="CHideShowUnusableButton" Text="{Loc 'humanoid-profile-editor-loadouts-show-unusable-button'}" ToolTip="{Loc 'humanoid-profile-editor-loadouts-show-unusable-button-tooltip'}" ToggleMode="True" Margin="0 0 0 5" />

<TabContainer Name="CLoadoutsTabs" VerticalExpand="True" />
</BoxContainer>
<BoxContainer Name="CMarkingsTab" Orientation="Vertical" Margin="10">
<!-- Markings -->
<ScrollContainer VerticalExpand="True">
Expand Down
Loading

0 comments on commit 5285573

Please sign in to comment.