Fix Set Outfit command/verb (#29672)
* Filter Set Outfit menu to exclude loadout sets * Apply loadouts to job outfits * Use appropriate species for Urists * squishy --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Content.Client.UserInterface.Controls;
|
using Content.Client.UserInterface.Controls;
|
||||||
|
using Content.Shared.Preferences.Loadouts;
|
||||||
using Content.Shared.Roles;
|
using Content.Shared.Roles;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.Console;
|
using Robust.Client.Console;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Client.Administration.UI.SetOutfit
|
namespace Content.Client.Administration.UI.SetOutfit
|
||||||
@@ -65,9 +64,18 @@ namespace Content.Client.Administration.UI.SetOutfit
|
|||||||
PopulateByFilter(SearchBar.Text);
|
PopulateByFilter(SearchBar.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<StartingGearPrototype> GetPrototypes()
|
||||||
|
{
|
||||||
|
// Filter out any StartingGearPrototypes that belong to loadouts
|
||||||
|
var loadouts = _prototypeManager.EnumeratePrototypes<LoadoutPrototype>();
|
||||||
|
var loadoutGears = loadouts.Select(l => l.StartingGear);
|
||||||
|
return _prototypeManager.EnumeratePrototypes<StartingGearPrototype>()
|
||||||
|
.Where(p => !loadoutGears.Contains(p.ID));
|
||||||
|
}
|
||||||
|
|
||||||
private void PopulateList()
|
private void PopulateList()
|
||||||
{
|
{
|
||||||
foreach (var gear in _prototypeManager.EnumeratePrototypes<StartingGearPrototype>())
|
foreach (var gear in GetPrototypes())
|
||||||
{
|
{
|
||||||
OutfitList.Add(GetItem(gear, OutfitList));
|
OutfitList.Add(GetItem(gear, OutfitList));
|
||||||
}
|
}
|
||||||
@@ -76,7 +84,7 @@ namespace Content.Client.Administration.UI.SetOutfit
|
|||||||
private void PopulateByFilter(string filter)
|
private void PopulateByFilter(string filter)
|
||||||
{
|
{
|
||||||
OutfitList.Clear();
|
OutfitList.Clear();
|
||||||
foreach (var gear in _prototypeManager.EnumeratePrototypes<StartingGearPrototype>())
|
foreach (var gear in GetPrototypes())
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(filter) &&
|
if (!string.IsNullOrEmpty(filter) &&
|
||||||
gear.ID.ToLowerInvariant().Contains(filter.Trim().ToLowerInvariant()))
|
gear.ID.ToLowerInvariant().Contains(filter.Trim().ToLowerInvariant()))
|
||||||
|
|||||||
@@ -4,11 +4,15 @@ using Content.Server.Hands.Systems;
|
|||||||
using Content.Server.Preferences.Managers;
|
using Content.Server.Preferences.Managers;
|
||||||
using Content.Shared.Access.Components;
|
using Content.Shared.Access.Components;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
|
using Content.Shared.Clothing;
|
||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
|
using Content.Shared.Humanoid;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.PDA;
|
using Content.Shared.PDA;
|
||||||
using Content.Shared.Preferences;
|
using Content.Shared.Preferences;
|
||||||
|
using Content.Shared.Preferences.Loadouts;
|
||||||
using Content.Shared.Roles;
|
using Content.Shared.Roles;
|
||||||
|
using Content.Shared.Station;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -82,9 +86,11 @@ namespace Content.Server.Administration.Commands
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
HumanoidCharacterProfile? profile = null;
|
HumanoidCharacterProfile? profile = null;
|
||||||
|
ICommonSession? session = null;
|
||||||
// Check if we are setting the outfit of a player to respect the preferences
|
// Check if we are setting the outfit of a player to respect the preferences
|
||||||
if (entityManager.TryGetComponent(target, out ActorComponent? actorComponent))
|
if (entityManager.TryGetComponent(target, out ActorComponent? actorComponent))
|
||||||
{
|
{
|
||||||
|
session = actorComponent.PlayerSession;
|
||||||
var userId = actorComponent.PlayerSession.UserId;
|
var userId = actorComponent.PlayerSession.UserId;
|
||||||
var preferencesManager = IoCManager.Resolve<IServerPreferencesManager>();
|
var preferencesManager = IoCManager.Resolve<IServerPreferencesManager>();
|
||||||
var prefs = preferencesManager.GetPreferences(userId);
|
var prefs = preferencesManager.GetPreferences(userId);
|
||||||
@@ -128,6 +134,36 @@ namespace Content.Server.Administration.Commands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See if this starting gear is associated with a job
|
||||||
|
var jobs = prototypeManager.EnumeratePrototypes<JobPrototype>();
|
||||||
|
foreach (var job in jobs)
|
||||||
|
{
|
||||||
|
if (job.StartingGear != gear)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var jobProtoId = LoadoutSystem.GetJobPrototype(job.ID);
|
||||||
|
if (!prototypeManager.TryIndex<RoleLoadoutPrototype>(jobProtoId, out var jobProto))
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Don't require a player, so this works on Urists
|
||||||
|
profile ??= entityManager.TryGetComponent<HumanoidAppearanceComponent>(target, out var comp)
|
||||||
|
? HumanoidCharacterProfile.DefaultWithSpecies(comp.Species)
|
||||||
|
: new HumanoidCharacterProfile();
|
||||||
|
// Try to get the user's existing loadout for the role
|
||||||
|
profile.Loadouts.TryGetValue(jobProtoId, out var roleLoadout);
|
||||||
|
|
||||||
|
if (roleLoadout == null)
|
||||||
|
{
|
||||||
|
// If they don't have a loadout for the role, make a default one
|
||||||
|
roleLoadout = new RoleLoadout(jobProtoId);
|
||||||
|
roleLoadout.SetDefault(profile, session, prototypeManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equip the target with the job loadout
|
||||||
|
var stationSpawning = entityManager.System<SharedStationSpawningSystem>();
|
||||||
|
stationSpawning.EquipRoleLoadout(target, roleLoadout, jobProto);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user