Skip to content

Commit

Permalink
Fix starting gear (space-wizards#27008)
Browse files Browse the repository at this point in the history
Slight blunder on the loadout prototype being used and all the names aligning means playtesting didn't catch it earlier.

Ideally player spawning code wouldn't have sucked so I could add tests like I wanted but it is what it is.
  • Loading branch information
metalgearsloth authored Apr 16, 2024
1 parent 12766fe commit 9bc3e07
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Content.Server/Station/Systems/StationSpawningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public EntityUid SpawnPlayerMob(
// Run loadouts after so stuff like storage loadouts can get
var jobLoadout = LoadoutSystem.GetJobPrototype(prototype?.ID);

if (_prototypeManager.TryIndex(jobLoadout, out RoleLoadoutPrototype? loadoutProto))
if (_prototypeManager.TryIndex(jobLoadout, out RoleLoadoutPrototype? roleProto))
{
RoleLoadout? loadout = null;
profile?.Loadouts.TryGetValue(jobLoadout, out loadout);
Expand All @@ -202,12 +202,23 @@ public EntityUid SpawnPlayerMob(
}

// Order loadout selections by the order they appear on the prototype.
foreach (var group in loadout.SelectedLoadouts.OrderBy(x => loadoutProto.Groups.FindIndex(e => e == x.Key)))
foreach (var group in loadout.SelectedLoadouts.OrderBy(x => roleProto.Groups.FindIndex(e => e == x.Key)))
{
foreach (var items in group.Value)
{
if (!_prototypeManager.TryIndex(items.Prototype, out var loadoutProto))
{
Log.Error($"Unable to find loadout prototype for {items.Prototype}");
continue;
}

if (!_prototypeManager.TryIndex(loadoutProto.Equipment, out var startingGear))
{
Log.Error($"Unable to find starting gear {loadoutProto.Equipment} for loadout {loadoutProto}");
continue;
}

// Handle any extra data here.
var startingGear = _prototypeManager.Index<StartingGearPrototype>(items.Prototype);
EquipStartingGear(entity.Value, startingGear);
}
}
Expand Down

0 comments on commit 9bc3e07

Please sign in to comment.