Nukie and priate outfit spawning fixes (#11274)

This commit is contained in:
Leon Friedrich
2022-09-15 12:06:40 +12:00
committed by GitHub
parent ad90ed28f9
commit f54c1cb2b3
2 changed files with 21 additions and 7 deletions

View File

@@ -34,6 +34,9 @@ using Content.Server.Traitor.Uplink;
using Robust.Shared.Audio;
using Robust.Shared.Configuration;
using Robust.Shared.Player;
using Content.Server.Administration.Commands;
using Content.Shared.Preferences;
using Content.Server.Preferences.Managers;
namespace Content.Server.GameTicking.Rules;
@@ -42,6 +45,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IServerPreferencesManager _prefs = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IMapLoader _mapLoader = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
@@ -541,7 +545,11 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
if (!TryComp<NukeOperativeSpawnerComponent>(spawner, out var nukeOpSpawner))
return;
SetupOperativeEntity(uid, nukeOpSpawner.OperativeName, nukeOpSpawner.OperativeStartingGear);
HumanoidCharacterProfile? profile = null;
if (TryComp(args.Spawned, out ActorComponent? actor))
profile = _prefs.GetPreferences(actor.PlayerSession.UserId).SelectedCharacter as HumanoidCharacterProfile;
SetupOperativeEntity(uid, nukeOpSpawner.OperativeName, nukeOpSpawner.OperativeStartingGear, profile);
_operativeMindPendingData.Add(uid, nukeOpSpawner.OperativeRolePrototype);
}
@@ -659,14 +667,14 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
/// <summary>
/// Adds missing nuke operative components, equips starting gear and renames the entity.
/// </summary>
private void SetupOperativeEntity(EntityUid mob, string name, string gear)
private void SetupOperativeEntity(EntityUid mob, string name, string gear, HumanoidCharacterProfile? profile)
{
MetaData(mob).EntityName = name;
EntityManager.EnsureComponent<RandomHumanoidAppearanceComponent>(mob);
EntityManager.EnsureComponent<NukeOperativeComponent>(mob);
if(_startingGearPrototypes.TryGetValue(gear, out var gearPrototype))
_stationSpawningSystem.EquipStartingGear(mob, gearPrototype, null);
_stationSpawningSystem.EquipStartingGear(mob, gearPrototype, profile);
_faction.RemoveFaction(mob, "NanoTrasen", false);
_faction.AddFaction(mob, "Syndicate", true);
@@ -708,7 +716,8 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
if (sessions.TryGetValue(i, out var session))
{
var mob = EntityManager.SpawnEntity(_nukeopsRuleConfig.SpawnEntityPrototype, _random.Pick(spawns));
SetupOperativeEntity(mob, spawnDetails.Name, spawnDetails.Gear);
var profile = _prefs.GetPreferences(session.UserId).SelectedCharacter as HumanoidCharacterProfile;
SetupOperativeEntity(mob, spawnDetails.Name, spawnDetails.Gear, profile);
var newMind = new Mind.Mind(session.UserId)
{
@@ -754,7 +763,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
return;
mind.AddRole(new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(_nukeopsRuleConfig.OperativeRoleProto)));
_stationSpawningSystem.EquipStartingGear(mind.OwnedEntity.Value, _prototypeManager.Index<StartingGearPrototype>("SyndicateOperativeGearFull"), null);
SetOutfitCommand.SetOutfit(mind.OwnedEntity.Value, "SyndicateOperativeGearFull", EntityManager);
}
private void OnStartAttempt(RoundStartAttemptEvent ev)