Validate remaining ProtoId strings (#38747)

Validate remaining ProtoId strings
This commit is contained in:
Tayrtahn
2025-07-04 16:55:45 -04:00
committed by GitHub
parent 3a278bca8b
commit f09bade8e7
14 changed files with 44 additions and 23 deletions

View File

@@ -15,6 +15,8 @@ namespace Content.Client.Access.UI;
[GenerateTypedNameReferences]
public sealed partial class GroupedAccessLevelChecklist : BoxContainer
{
private static readonly ProtoId<AccessGroupPrototype> GeneralAccessGroup = "General";
[Dependency] private readonly IPrototypeManager _protoManager = default!;
private bool _isMonotone;
@@ -63,7 +65,7 @@ public sealed partial class GroupedAccessLevelChecklist : BoxContainer
// Ensure that the 'general' access group is added to handle
// misc. access levels that aren't associated with any group
if (_protoManager.TryIndex<AccessGroupPrototype>("General", out var generalAccessProto))
if (_protoManager.TryIndex(GeneralAccessGroup, out var generalAccessProto))
_groupedAccessLevels.TryAdd(generalAccessProto, new());
// Assign known access levels with their associated groups

View File

@@ -24,7 +24,7 @@ public sealed class DeliveryVisualizerSystem : VisualizerSystem<DeliveryComponen
if (!_prototype.TryIndex<JobIconPrototype>(job, out var icon))
{
SpriteSystem.LayerSetTexture((uid, args.Sprite), DeliveryVisualLayers.JobStamp, SpriteSystem.Frame0(_prototype.Index("JobIconUnknown")));
SpriteSystem.LayerSetTexture((uid, args.Sprite), DeliveryVisualLayers.JobStamp, SpriteSystem.Frame0(_prototype.Index(UnknownIcon).Icon));
return;
}

View File

@@ -9,13 +9,15 @@ namespace Content.Server.Botany;
public sealed class MutationSystem : EntitySystem
{
private static ProtoId<RandomPlantMutationListPrototype> RandomPlantMutations = "RandomPlantMutations";
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private RandomPlantMutationListPrototype _randomMutations = default!;
public override void Initialize()
{
_randomMutations = _prototypeManager.Index<RandomPlantMutationListPrototype>("RandomPlantMutations");
_randomMutations = _prototypeManager.Index(RandomPlantMutations);
}
/// <summary>

View File

@@ -21,6 +21,8 @@ namespace Content.Server.Cluwne;
public sealed class CluwneSystem : EntitySystem
{
private static readonly ProtoId<DamageGroupPrototype> GeneticDamageGroup = "Genetic";
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
@@ -53,7 +55,7 @@ public sealed class CluwneSystem : EntitySystem
RemComp<CluwneComponent>(uid);
RemComp<ClumsyComponent>(uid);
RemComp<AutoEmoteComponent>(uid);
var damageSpec = new DamageSpecifier(_prototypeManager.Index<DamageGroupPrototype>("Genetic"), 300);
var damageSpec = new DamageSpecifier(_prototypeManager.Index(GeneticDamageGroup), 300);
_damageableSystem.TryChangeDamage(uid, damageSpec);
}
}

View File

@@ -19,6 +19,8 @@ namespace Content.Server.Destructible.Thresholds.Behaviors;
[DataDefinition]
public sealed partial class WeightedSpawnEntityBehavior : IThresholdBehavior
{
private static readonly EntProtoId TempEntityProtoId = "TemporaryEntityForTimedDespawnSpawners";
/// <summary>
/// A table of entities with assigned weights to randomly pick from
/// </summary>
@@ -64,7 +66,7 @@ public sealed partial class WeightedSpawnEntityBehavior : IThresholdBehavior
if (SpawnAfter != 0)
{
// if it fails to get the spawner, this won't ever work so just return
if (!system.PrototypeManager.TryIndex("TemporaryEntityForTimedDespawnSpawners", out var tempSpawnerProto))
if (!system.PrototypeManager.TryIndex(TempEntityProtoId, out var tempSpawnerProto))
return;
// spawn the spawner, assign it a lifetime, and assign the entity that it will spawn when despawned

View File

@@ -48,6 +48,8 @@ namespace Content.Server.EntityEffects;
public sealed class EntityEffectSystem : EntitySystem
{
private static readonly ProtoId<WeightedRandomFillSolutionPrototype> RandomPickBotanyReagent = "RandomPickBotanyReagent";
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly BloodstreamSystem _bloodstream = default!;
[Dependency] private readonly ChatSystem _chat = default!;
@@ -854,7 +856,7 @@ public sealed class EntityEffectSystem : EntitySystem
return;
var chemicals = plantholder.Seed.Chemicals;
var randomChems = _protoManager.Index<WeightedRandomFillSolutionPrototype>("RandomPickBotanyReagent").Fills;
var randomChems = _protoManager.Index(RandomPickBotanyReagent).Fills;
// Add a random amount of a random chemical to this set of chemicals
if (randomChems != null)

View File

@@ -36,8 +36,9 @@ public sealed class GatewayGeneratorSystem : EntitySystem
[Dependency] private readonly SharedSalvageSystem _salvage = default!;
[Dependency] private readonly TileSystem _tile = default!;
[ValidatePrototypeId<LocalizedDatasetPrototype>]
private const string PlanetNames = "NamesBorer";
private static readonly ProtoId<LocalizedDatasetPrototype> PlanetNames = "NamesBorer";
private static readonly ProtoId<BiomeTemplatePrototype> BiomeTemplate = "Continental";
private static readonly ProtoId<DungeonConfigPrototype> DungeonConfig = "Experiment";
// TODO:
// Fix shader some more
@@ -101,7 +102,7 @@ public sealed class GatewayGeneratorSystem : EntitySystem
var random = new Random(seed);
var mapUid = _maps.CreateMap();
var gatewayName = _salvage.GetFTLName(_protoManager.Index<LocalizedDatasetPrototype>(PlanetNames), seed);
var gatewayName = _salvage.GetFTLName(_protoManager.Index(PlanetNames), seed);
_metadata.SetEntityName(mapUid, gatewayName);
var origin = new Vector2i(random.Next(-MaxOffset, MaxOffset), random.Next(-MaxOffset, MaxOffset));
@@ -111,7 +112,7 @@ public sealed class GatewayGeneratorSystem : EntitySystem
};
AddComp(mapUid, restricted);
_biome.EnsurePlanet(mapUid, _protoManager.Index<BiomeTemplatePrototype>("Continental"), seed);
_biome.EnsurePlanet(mapUid, _protoManager.Index(BiomeTemplate), seed);
var grid = Comp<MapGridComponent>(mapUid);
@@ -183,7 +184,7 @@ public sealed class GatewayGeneratorSystem : EntitySystem
var dungeonRotation = _dungeon.GetDungeonRotation(seed);
var dungeonPosition = (origin + dungeonRotation.RotateVec(new Vector2i(0, dungeonDistance))).Floored();
_dungeon.GenerateDungeon(_protoManager.Index<DungeonConfigPrototype>("Experiment"), args.MapUid, grid, dungeonPosition, seed);
_dungeon.GenerateDungeon(_protoManager.Index(DungeonConfig), args.MapUid, grid, dungeonPosition, seed);
// TODO: Dungeon mobs + loot.

View File

@@ -74,6 +74,7 @@ namespace Content.Server.Ghost
private EntityQuery<PhysicsComponent> _physicsQuery;
private static readonly ProtoId<TagPrototype> AllowGhostShownByEventTag = "AllowGhostShownByEvent";
private static readonly ProtoId<DamageTypePrototype> AsphyxiationDamageType = "Asphyxiation";
public override void Initialize()
{
@@ -585,7 +586,7 @@ namespace Content.Server.Ghost
dealtDamage = playerDeadThreshold - damageable.TotalDamage;
}
DamageSpecifier damage = new(_prototypeManager.Index<DamageTypePrototype>("Asphyxiation"), dealtDamage);
DamageSpecifier damage = new(_prototypeManager.Index(AsphyxiationDamageType), dealtDamage);
_damageable.TryChangeDamage(playerEntity, damage, true);
}

View File

@@ -8,8 +8,8 @@ namespace Content.Server.Salvage;
public sealed partial class SalvageSystem
{
[ValidatePrototypeId<EntityPrototype>]
public const string CoordinatesDisk = "CoordinatesDisk";
public static readonly EntProtoId CoordinatesDisk = "CoordinatesDisk";
public static readonly ProtoId<LocalizedDatasetPrototype> PlanetNames = "NamesBorer";
private void OnSalvageClaimMessage(EntityUid uid, SalvageExpeditionConsoleComponent component, ClaimSalvageMessage args)
{
@@ -28,7 +28,7 @@ public sealed partial class SalvageSystem
var mission = GetMission(_prototypeManager.Index<SalvageDifficultyPrototype>(missionparams.Difficulty), missionparams.Seed);
data.NextOffer = _timing.CurTime + mission.Duration + TimeSpan.FromSeconds(1);
_labelSystem.Label(cdUid, GetFTLName(_prototypeManager.Index<LocalizedDatasetPrototype>("NamesBorer"), missionparams.Seed));
_labelSystem.Label(cdUid, GetFTLName(_prototypeManager.Index(PlanetNames), missionparams.Seed));
_audio.PlayPvs(component.PrintSound, uid);
UpdateConsoles((station.Value, data));

View File

@@ -100,7 +100,7 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
destComp.Enabled = true;
_metaData.SetEntityName(
mapUid,
_entManager.System<SharedSalvageSystem>().GetFTLName(_prototypeManager.Index<LocalizedDatasetPrototype>("NamesBorer"), _missionParams.Seed));
_entManager.System<SharedSalvageSystem>().GetFTLName(_prototypeManager.Index(SalvageSystem.PlanetNames), _missionParams.Seed));
_entManager.AddComponent<FTLBeaconComponent>(mapUid);
// Saving the mission mapUid to a CD is made optional, in case one is somehow made in a process without a CD entity

View File

@@ -11,6 +11,9 @@ namespace Content.Server.StationEvents.Events;
public sealed class RandomSentienceRule : StationEventSystem<RandomSentienceRuleComponent>
{
private static readonly ProtoId<LocalizedDatasetPrototype> DataSourceNames = "RandomSentienceEventData";
private static readonly ProtoId<LocalizedDatasetPrototype> IntelligenceLevelNames = "RandomSentienceEventStrength";
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IRobustRandom _random = default!;
protected override void Started(EntityUid uid, RandomSentienceRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
@@ -72,8 +75,8 @@ public sealed class RandomSentienceRule : StationEventSystem<RandomSentienceRule
station.Value,
Loc.GetString("station-event-random-sentience-announcement",
("kind1", kind1), ("kind2", kind2), ("kind3", kind3), ("amount", groupList.Count),
("data", _random.Pick(_prototype.Index<LocalizedDatasetPrototype>("RandomSentienceEventData"))),
("strength", _random.Pick(_prototype.Index<LocalizedDatasetPrototype>("RandomSentienceEventStrength")))
("data", _random.Pick(_prototype.Index(DataSourceNames))),
("strength", _random.Pick(_prototype.Index(IntelligenceLevelNames)))
),
playDefaultSound: false,
colorOverride: Color.Gold

View File

@@ -8,12 +8,14 @@ using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Movement.Components;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.Body.Systems;
public partial class SharedBodySystem
{
private static readonly ProtoId<DamageTypePrototype> BloodlossDamageType = "Bloodloss";
private void InitializeParts()
{
// TODO: This doesn't handle comp removal on child ents.
@@ -178,7 +180,7 @@ public partial class SharedBodySystem
)
{
// TODO BODY SYSTEM KILL : remove this when wounding and required parts are implemented properly
var damage = new DamageSpecifier(Prototypes.Index<DamageTypePrototype>("Bloodloss"), 300);
var damage = new DamageSpecifier(Prototypes.Index(BloodlossDamageType), 300);
Damageable.TryChangeDamage(bodyEnt, damage);
}
}

View File

@@ -8,6 +8,8 @@ namespace Content.Shared.Chat;
public sealed class SharedSuicideSystem : EntitySystem
{
private static readonly ProtoId<DamageTypePrototype> FallbackDamageType = "Blunt";
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -57,8 +59,8 @@ public sealed class SharedSuicideSystem : EntitySystem
// We don't want structural damage for the same reasons listed above
if (!_prototypeManager.TryIndex(damageType, out var damagePrototype) || damagePrototype.ID == "Structural")
{
Log.Error($"{nameof(SharedSuicideSystem)} could not find the damage type prototype associated with {damageType}. Falling back to Blunt");
damagePrototype = _prototypeManager.Index<DamageTypePrototype>("Blunt");
Log.Error($"{nameof(SharedSuicideSystem)} could not find the damage type prototype associated with {damageType}. Falling back to {FallbackDamageType}");
damagePrototype = _prototypeManager.Index(FallbackDamageType);
}
var damage = new DamageSpecifier(damagePrototype, lethalAmountOfDamage);

View File

@@ -12,6 +12,8 @@ namespace Content.Shared.Humanoid
/// </summary>
public sealed class NamingSystem : EntitySystem
{
private static readonly ProtoId<SpeciesPrototype> FallbackSpecies = "Human";
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -21,8 +23,8 @@ namespace Content.Shared.Humanoid
// Some downstream is probably gonna have this eventually but then they can deal with fallbacks.
if (!_prototypeManager.TryIndex(species, out SpeciesPrototype? speciesProto))
{
speciesProto = _prototypeManager.Index<SpeciesPrototype>("Human");
Log.Warning($"Unable to find species {species} for name, falling back to Human");
speciesProto = _prototypeManager.Index(FallbackSpecies);
Log.Warning($"Unable to find species {species} for name, falling back to {FallbackSpecies}");
}
switch (speciesProto.Naming)