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

View File

@@ -1,13 +1,16 @@
using System.Linq; using System.Linq;
using Content.Server.Administration.Commands;
using Content.Server.Cargo.Systems; using Content.Server.Cargo.Systems;
using Content.Server.Chat.Managers; using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Configurations; using Content.Server.GameTicking.Rules.Configurations;
using Content.Server.Preferences.Managers;
using Content.Server.RoundEnd; using Content.Server.RoundEnd;
using Content.Server.Spawners.Components; using Content.Server.Spawners.Components;
using Content.Server.Station.Components; using Content.Server.Station.Components;
using Content.Server.Station.Systems; using Content.Server.Station.Systems;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.CharacterAppearance; using Content.Shared.CharacterAppearance;
using Content.Shared.Preferences;
using Content.Shared.Roles; using Content.Shared.Roles;
using Robust.Server.Maps; using Robust.Server.Maps;
using Robust.Server.Player; using Robust.Server.Player;
@@ -30,6 +33,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem
[Dependency] private readonly IChatManager _chatManager = default!; [Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IMapLoader _mapLoader = default!; [Dependency] private readonly IMapLoader _mapLoader = default!;
[Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IServerPreferencesManager _prefs = default!;
[Dependency] private readonly StationSpawningSystem _stationSpawningSystem = default!; [Dependency] private readonly StationSpawningSystem _stationSpawningSystem = default!;
[Dependency] private readonly StationSystem _stationSystem = default!; [Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly PricingSystem _pricingSystem = default!; [Dependency] private readonly PricingSystem _pricingSystem = default!;
@@ -208,7 +212,8 @@ public sealed class PiratesRuleSystem : GameRuleSystem
MetaData(mob).EntityName = name; MetaData(mob).EntityName = name;
newMind.TransferTo(mob); newMind.TransferTo(mob);
_stationSpawningSystem.EquipStartingGear(mob, pirateGear, null); var profile = _prefs.GetPreferences(session.UserId).SelectedCharacter as HumanoidCharacterProfile;
_stationSpawningSystem.EquipStartingGear(mob, pirateGear, profile);
_pirates.Add(newMind); _pirates.Add(newMind);
@@ -227,7 +232,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem
{ {
if (!mind.OwnedEntity.HasValue) if (!mind.OwnedEntity.HasValue)
return; return;
_stationSpawningSystem.EquipStartingGear(mind.OwnedEntity.Value, _prototypeManager.Index<StartingGearPrototype>("PirateGear"), null); SetOutfitCommand.SetOutfit(mind.OwnedEntity.Value, "PirateGear", EntityManager);
} }
private void OnStartAttempt(RoundStartAttemptEvent ev) private void OnStartAttempt(RoundStartAttemptEvent ev)