From be53e16746948ab8b2ab33f20ebf1e37c12984e3 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Mon, 27 Nov 2023 13:27:17 -0800 Subject: [PATCH] Move hardcoded pirates gamerule prototype ids to validated consts (#21914) * Move hardcoded pirates gamerule prototype ids to validated consts * Rename --- .../GameTicking/Rules/PiratesRuleSystem.cs | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/Content.Server/GameTicking/Rules/PiratesRuleSystem.cs b/Content.Server/GameTicking/Rules/PiratesRuleSystem.cs index 1c04835c55..885bf9cc12 100644 --- a/Content.Server/GameTicking/Rules/PiratesRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/PiratesRuleSystem.cs @@ -4,13 +4,15 @@ using Content.Server.Administration.Commands; using Content.Server.Cargo.Systems; using Content.Server.Chat.Managers; using Content.Server.GameTicking.Rules.Components; +using Content.Server.NPC.Components; +using Content.Server.NPC.Systems; using Content.Server.Preferences.Managers; using Content.Server.Spawners.Components; using Content.Server.Station.Components; using Content.Server.Station.Systems; -using Content.Server.NPC.Systems; using Content.Shared.CCVar; using Content.Shared.Humanoid; +using Content.Shared.Humanoid.Prototypes; using Content.Shared.Mind; using Content.Shared.Preferences; using Content.Shared.Roles; @@ -49,6 +51,27 @@ public sealed class PiratesRuleSystem : GameRuleSystem [Dependency] private readonly SharedAudioSystem _audioSystem = default!; [Dependency] private readonly MetaDataSystem _metaData = default!; + [ValidatePrototypeId] + private const string GameRuleId = "Pirates"; + + [ValidatePrototypeId] + private const string MobId = "MobHuman"; + + [ValidatePrototypeId] + private const string SpeciesId = "Human"; + + [ValidatePrototypeId] + private const string PirateFactionId = "Syndicate"; + + [ValidatePrototypeId] + private const string EnemyFactionId = "NanoTrasen"; + + [ValidatePrototypeId] + private const string GearId = "PirateGear"; + + [ValidatePrototypeId] + private const string SpawnPointId = "SpawnPointPirates"; + /// public override void Initialize() { @@ -189,7 +212,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem pirates.PirateShip = gridId.Value; // TODO: Loot table or something - var pirateGear = _prototypeManager.Index("PirateGear"); // YARRR + var pirateGear = _prototypeManager.Index(GearId); // YARRR var spawns = new List(); @@ -197,7 +220,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem foreach (var (_, meta, xform) in EntityQuery(true)) { - if (meta.EntityPrototype?.ID != "SpawnPointPirates" || xform.ParentUid != pirates.PirateShip) + if (meta.EntityPrototype?.ID != SpawnPointId || xform.ParentUid != pirates.PirateShip) continue; spawns.Add(xform.Coordinates); @@ -214,21 +237,21 @@ public sealed class PiratesRuleSystem : GameRuleSystem var sex = _random.Prob(0.5f) ? Sex.Male : Sex.Female; var gender = sex == Sex.Male ? Gender.Male : Gender.Female; - var name = _namingSystem.GetName("Human", gender); + var name = _namingSystem.GetName(SpeciesId, gender); var session = ops[i]; var newMind = _mindSystem.CreateMind(session.UserId, name); _mindSystem.SetUserId(newMind, session.UserId); - var mob = Spawn("MobHuman", _random.Pick(spawns)); + var mob = Spawn(MobId, _random.Pick(spawns)); _metaData.SetEntityName(mob, name); _mindSystem.TransferTo(newMind, mob); var profile = _prefs.GetPreferences(session.UserId).SelectedCharacter as HumanoidCharacterProfile; _stationSpawningSystem.EquipStartingGear(mob, pirateGear, profile); - _npcFaction.RemoveFaction(mob, "NanoTrasen", false); - _npcFaction.AddFaction(mob, "Syndicate"); + _npcFaction.RemoveFaction(mob, EnemyFactionId, false); + _npcFaction.AddFaction(mob, PirateFactionId); pirates.Pirates.Add(newMind); @@ -251,13 +274,13 @@ public sealed class PiratesRuleSystem : GameRuleSystem { if (!mind.OwnedEntity.HasValue) return; - SetOutfitCommand.SetOutfit(mind.OwnedEntity.Value, "PirateGear", EntityManager); + SetOutfitCommand.SetOutfit(mind.OwnedEntity.Value, GearId, EntityManager); var pirateRule = EntityQuery().FirstOrDefault(); if (pirateRule == null) { //todo fuck me this shit is awful - GameTicker.StartGameRule("Pirates", out var ruleEntity); + GameTicker.StartGameRule(GameRuleId, out var ruleEntity); pirateRule = Comp(ruleEntity); } -- 2.51.2