From b7f297f612187f9cb259e63afa84ee2e236a9ff6 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Tue, 9 Sep 2025 18:17:56 +0200 Subject: [PATCH] Fix usages of TryIndex() (#39124) * Fix usages of TryIndex() Most usages of TryIndex() were using it incorrectly. Checking whether prototype IDs specified in prototypes actually existed before using them. This is not appropriate as it's just hiding bugs that should be getting caught by the YAML linter and other tools. (#39115) This then resulted in TryIndex() getting modified to log errors (https://github.com/space-wizards/RobustToolbox/commit/94f98073b07bd3fa3133ae6799b34d90f46f467e), which is incorrect as it causes false-positive errors in proper uses of the API: external data validation. (#39098) This commit goes through and checks every call site of TryIndex() to see whether they were correct. Most call sites were replaced with the new Resolve(), which is suitable for these "defensive programming" use cases. Fixes #39115 Breaking change: while doing this I noticed IdCardComponent and related systems were erroneously using ProtoId for job prototypes. This has been corrected. * fix tests --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --- .../Access/UI/AccessOverriderWindow.xaml.cs | 2 +- .../UI/GroupedAccessLevelChecklist.xaml.cs | 6 ++--- .../UI/IdCardConsoleBoundUserInterface.cs | 3 ++- .../Access/UI/IdCardConsoleWindow.xaml.cs | 2 +- .../UI/BanPanel/BanPanel.xaml.cs | 5 +++-- Content.Client/Atmos/AlignAtmosPipeLayers.cs | 2 +- .../Jukebox/JukeboxBoundUserInterface.cs | 2 +- Content.Client/BarSign/BarSignSystem.cs | 2 +- .../BarSign/Ui/BarSignBoundUserInterface.cs | 2 +- Content.Client/Cargo/UI/BountyEntry.xaml.cs | 2 +- .../Cargo/UI/BountyHistoryEntry.xaml.cs | 2 +- .../TypingIndicatorVisualizerSystem.cs | 2 +- .../UI/ChameleonBoundUserInterface.cs | 2 +- .../Clothing/UI/ChameleonMenu.xaml.cs | 2 +- .../Construction/ConstructionSystem.cs | 17 ++++++-------- .../UI/ConstructionMenuPresenter.cs | 2 +- Content.Client/Damage/DamageVisualsSystem.cs | 2 +- Content.Client/Doors/DoorSystem.cs | 2 +- .../Ghost/GhostRoleRadioMenu.xaml.cs | 2 +- .../Guidebook/DocumentParsingManager.cs | 2 +- Content.Client/Implants/ImplanterSystem.cs | 2 +- .../UI/ChameleonControllerMenu.xaml.cs | 2 +- .../Implants/UI/ImplanterStatusControl.cs | 2 +- Content.Client/Lathe/UI/LatheMenu.xaml.cs | 4 ++-- Content.Client/Lobby/LobbyUIController.cs | 8 +++---- .../Lobby/UI/HumanoidProfileEditor.xaml.cs | 6 ++--- .../UI/Loadouts/LoadoutContainer.xaml.cs | 2 +- .../UI/Loadouts/LoadoutGroupContainer.xaml.cs | 22 +++++++++---------- .../Lobby/UI/Loadouts/LoadoutWindow.xaml.cs | 2 +- .../Overlays/EntityHealthBarOverlay.cs | 2 +- .../Overlays/ShowCriminalRecordIconsSystem.cs | 2 +- .../Overlays/ShowHealthIconsSystem.cs | 4 ++-- Content.Client/Overlays/ShowJobIconsSystem.cs | 2 +- .../Overlays/ShowMindShieldIconsSystem.cs | 4 ++-- Content.Client/Overlays/StencilOverlay.cs | 2 +- .../RCD/RCDMenuBoundUserInterface.cs | 6 +++-- Content.Client/Radio/Ui/IntercomMenu.xaml.cs | 2 +- .../Revolutionary/RevolutionarySystem.cs | 4 ++-- .../StationAiCustomizationMenu.xaml.cs | 4 ++-- .../SprayPainter/SprayPainterSystem.cs | 2 +- .../EntityStorageVisualizerSystem.cs | 2 +- .../Store/Ui/StoreWithdrawWindow.xaml.cs | 2 +- .../UI/VendingMachineMenu.xaml.cs | 2 +- .../Tests/Commands/SuicideCommandTests.cs | 4 ++-- .../Tests/ContrabandTest.cs | 7 ++++-- .../Tests/Lathe/LatheTest.cs | 8 +++++-- .../Tests/Minds/MindTests.cs | 5 +---- .../Tests/PostMapInitTest.cs | 5 ++--- .../Access/Systems/AgentIDCardSystem.cs | 4 ++-- .../Access/Systems/IdCardConsoleSystem.cs | 6 ++--- .../Access/Systems/PresetIdCardSystem.cs | 4 ++-- .../Commands/ExplosionCommand.cs | 2 +- .../EntitySystems/SpeakOnUIClosedSystem.cs | 2 +- .../Anomaly/Effects/InnerBodyAnomalySystem.cs | 4 ++-- Content.Server/Audio/Jukebox/JukeboxSystem.cs | 2 +- .../Cargo/Systems/CargoSystem.Bounty.cs | 6 ++--- .../Cargo/Systems/CargoSystem.Orders.cs | 4 ++-- Content.Server/Chat/Systems/ChatSystem.cs | 2 +- .../TransformableContainerSystem.cs | 2 +- Content.Server/Cloning/CloningSystem.cs | 4 ++-- .../Construction/ConstructionSystem.Guided.cs | 2 +- .../Damage/ForceSay/DamageForceSaySystem.cs | 2 +- .../Damage/Systems/ExaminableDamageSystem.cs | 2 +- .../Behaviors/WeightedSpawnEntityBehavior.cs | 2 +- .../EntityEffects/EntityEffectSystem.cs | 4 +--- .../Rules/AntagLoadProfileRuleSystem.cs | 2 +- .../PuddleMessVariationPassSystem.cs | 2 +- Content.Server/Ghost/Roles/GhostRoleSystem.cs | 2 +- Content.Server/Ghost/SpookySpeakerSystem.cs | 2 +- .../Implants/ChameleonControllerSystem.cs | 6 ++--- .../Kitchen/EntitySystems/MicrowaveSystem.cs | 2 +- Content.Server/Lathe/LatheSystem.cs | 2 +- .../NameIdentifier/NameIdentifierSystem.cs | 4 ++-- Content.Server/Parallax/BiomeSystem.cs | 2 +- .../JobWhitelist/JobWhitelistManager.cs | 2 +- .../PlayTimeTrackingSystem.cs | 7 +++--- .../Polymorph/Systems/PolymorphSystem.cs | 4 ++-- .../Polymorph/Toolshed/PolymorphCommand.cs | 3 +-- .../Procedural/DungeonJob/DungeonJob.Biome.cs | 2 +- .../DungeonJob/DungeonJob.MiddleConnection.cs | 2 +- .../Procedural/DungeonJob/DungeonJob.Ore.cs | 2 +- .../Systems/RadiationProtectionSystem.cs | 2 +- .../Radio/EntitySystems/RadioSystem.cs | 2 +- Content.Server/Roles/RoleSystem.cs | 2 +- .../Systems/ShuttleSystem.GridFill.cs | 4 ++-- .../Borgs/BorgSwitchableTypeSystem.cs | 2 +- .../ContainerSpawnPointSystem.cs | 2 +- Content.Server/Speech/EmotesMenuSystem.cs | 2 +- Content.Server/Spreader/SpreaderSystem.cs | 2 +- .../Systems/StationJobsSystem.Roundstart.cs | 2 +- .../Station/Systems/StationSpawningSystem.cs | 12 ++++------ .../StationEvents/EventManagerSystem.cs | 4 ++-- .../StationEvents/Events/GreytideVirusRule.cs | 2 +- .../Systems/SurveillanceCameraRouterSystem.cs | 2 +- .../Systems/SurveillanceCameraSystem.cs | 2 +- Content.Server/Telephone/TelephoneSystem.cs | 2 +- Content.Server/Traitor/Uplink/UplinkSystem.cs | 2 +- Content.Server/Traits/TraitSystem.cs | 4 ++-- .../Trigger/Systems/SpeakOnTriggerSystem.cs | 2 +- Content.Server/Wires/WiresSystem.cs | 2 +- Content.Server/Zombies/ZombieSystem.cs | 2 +- .../Access/Components/AccessComponent.cs | 2 +- .../Access/Components/IdCardComponent.cs | 2 +- .../Components/IdCardConsoleComponent.cs | 9 ++++---- .../Access/Systems/SharedAccessSystem.cs | 4 ++-- .../SharedAtmosPipeLayersSystem.cs | 4 ++-- Content.Shared/BarSign/BarSignSystem.cs | 2 +- .../Body/Systems/SharedBloodstreamSystem.cs | 2 +- .../Cargo/Prototypes/CargoProductPrototype.cs | 4 ++-- .../SharedChameleonClothingSystem.cs | 2 +- Content.Shared/Clothing/LoadoutSystem.cs | 10 ++++----- .../Construction/MachinePartSystem.cs | 2 +- .../Containers/ContainerCompSystem.cs | 4 ++-- .../Damage/Systems/DamageableSystem.cs | 4 ++-- .../Humanoid/Markings/MarkingManager.cs | 4 ++-- .../SharedHumanoidAppearanceSystem.cs | 4 ++-- .../UnpoweredFlashlightSystem.cs | 2 +- .../EntitySystems/FoodSequenceSystem.cs | 7 +++--- .../Nutrition/EntitySystems/HungerSystem.cs | 6 ++--- .../Nutrition/EntitySystems/ThirstSystem.cs | 6 ++--- .../FoodMetamorphRules/FoodMetamorphRule.cs | 6 ++--- .../Preferences/HumanoidCharacterProfile.cs | 4 ++-- Content.Shared/RCD/Systems/RCDSystem.cs | 4 ++-- .../DepartmentTimeRequirement.cs | 2 +- Content.Shared/Roles/Jobs/SharedJobSystem.cs | 2 +- Content.Shared/Roles/SharedRoleSystem.cs | 2 +- .../Borgs/SharedBorgSwitchableTypeSystem.cs | 2 +- .../SharedStationAiSystem.Customization.cs | 6 ++--- .../SprayPainter/SharedSprayPainterSystem.cs | 2 +- .../Station/SharedStationSpawningSystem.cs | 6 ++--- .../StatusEffectNew/StatusEffectsSystem.cs | 2 +- .../Storage/EntitySystems/DumpableSystem.cs | 2 +- .../EntitySystems/SharedStorageSystem.cs | 4 ++-- .../EntitySystems/StoryGeneratorSystem.cs | 4 ++-- 134 files changed, 232 insertions(+), 234 deletions(-) diff --git a/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs b/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs index 092a0071fb..8e527d7343 100644 --- a/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs +++ b/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs @@ -29,7 +29,7 @@ namespace Content.Client.Access.UI foreach (var access in accessLevels) { - if (!protoManager.TryIndex(access, out var accessLevel)) + if (!protoManager.Resolve(access, out var accessLevel)) { continue; } diff --git a/Content.Client/Access/UI/GroupedAccessLevelChecklist.xaml.cs b/Content.Client/Access/UI/GroupedAccessLevelChecklist.xaml.cs index 4f07c31009..41d5a84654 100644 --- a/Content.Client/Access/UI/GroupedAccessLevelChecklist.xaml.cs +++ b/Content.Client/Access/UI/GroupedAccessLevelChecklist.xaml.cs @@ -57,7 +57,7 @@ public sealed partial class GroupedAccessLevelChecklist : BoxContainer foreach (var accessGroup in _accessGroups) { - if (!_protoManager.TryIndex(accessGroup, out var accessGroupProto)) + if (!_protoManager.Resolve(accessGroup, out var accessGroupProto)) continue; _groupedAccessLevels.Add(accessGroupProto, new()); @@ -65,13 +65,13 @@ 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(GeneralAccessGroup, out var generalAccessProto)) + if (_protoManager.Resolve(GeneralAccessGroup, out var generalAccessProto)) _groupedAccessLevels.TryAdd(generalAccessProto, new()); // Assign known access levels with their associated groups foreach (var accessLevel in _accessLevels) { - if (!_protoManager.TryIndex(accessLevel, out var accessLevelProto)) + if (!_protoManager.Resolve(accessLevel, out var accessLevelProto)) continue; var assigned = false; diff --git a/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs b/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs index f93541e0e5..cc341e57e5 100644 --- a/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs +++ b/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs @@ -5,6 +5,7 @@ using Content.Shared.Access.Systems; using Content.Shared.CCVar; using Content.Shared.Containers.ItemSlots; using Content.Shared.CrewManifest; +using Content.Shared.Roles; using Robust.Shared.Configuration; using Robust.Shared.Prototypes; using static Content.Shared.Access.Components.IdCardConsoleComponent; @@ -77,7 +78,7 @@ namespace Content.Client.Access.UI _window?.UpdateState(castState); } - public void SubmitData(string newFullName, string newJobTitle, List> newAccessList, string newJobPrototype) + public void SubmitData(string newFullName, string newJobTitle, List> newAccessList, ProtoId newJobPrototype) { if (newFullName.Length > _maxNameLength) newFullName = newFullName[.._maxNameLength]; diff --git a/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs b/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs index 3509b988d4..085d819af4 100644 --- a/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs +++ b/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs @@ -111,7 +111,7 @@ namespace Content.Client.Access.UI var targetAccesses = job.Access.ToHashSet(); foreach (var group in job.AccessGroups) { - if (!_prototypeManager.TryIndex(group, out AccessGroupPrototype? groupPrototype)) + if (!_prototypeManager.Resolve(group, out AccessGroupPrototype? groupPrototype)) { continue; } diff --git a/Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs b/Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs index 46090a6f3d..c7aed30c1c 100644 --- a/Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs +++ b/Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs @@ -316,8 +316,9 @@ public sealed partial class BanPanel : DefaultWindow }; // This is adding the icon before the role name - // Yeah, this is sus, but having to split the functions up and stuff is worse imo. - if (_protoMan.TryIndex(role, out var jobPrototype) && _protoMan.TryIndex(jobPrototype.Icon, out var iconProto)) + // TODO: This should not be using raw strings for prototypes as it means it won't be validated at all. + // I know the ban manager is doing the same thing, but that should not leak into UI code. + if (_protoMan.TryIndex(role, out var jobPrototype) && _protoMan.Resolve(jobPrototype.Icon, out var iconProto)) { var jobIconTexture = new TextureRect { diff --git a/Content.Client/Atmos/AlignAtmosPipeLayers.cs b/Content.Client/Atmos/AlignAtmosPipeLayers.cs index 1bf3310a6c..51a6ce0c02 100644 --- a/Content.Client/Atmos/AlignAtmosPipeLayers.cs +++ b/Content.Client/Atmos/AlignAtmosPipeLayers.cs @@ -134,7 +134,7 @@ public sealed class AlignAtmosPipeLayers : SnapgridCenter var newProtoId = altPrototypes[(int)layer]; - if (!_protoManager.TryIndex(newProtoId, out var newProto)) + if (!_protoManager.Resolve(newProtoId, out var newProto)) return; if (newProto.Type != ConstructionType.Structure) diff --git a/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs b/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs index 865dfc478d..510b9d3def 100644 --- a/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs +++ b/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs @@ -58,7 +58,7 @@ public sealed class JukeboxBoundUserInterface : BoundUserInterface _menu.SetAudioStream(jukebox.AudioStream); - if (_protoManager.TryIndex(jukebox.SelectedSongId, out var songProto)) + if (_protoManager.Resolve(jukebox.SelectedSongId, out var songProto)) { var length = EntMan.System().GetAudioLength(songProto.Path.Path.ToString()); _menu.SetSelectedSong(songProto.Name, (float) length.TotalSeconds); diff --git a/Content.Client/BarSign/BarSignSystem.cs b/Content.Client/BarSign/BarSignSystem.cs index 02e33861b7..1ea99864a1 100644 --- a/Content.Client/BarSign/BarSignSystem.cs +++ b/Content.Client/BarSign/BarSignSystem.cs @@ -39,7 +39,7 @@ public sealed class BarSignSystem : VisualizerSystem if (powered && sign.Current != null - && _prototypeManager.TryIndex(sign.Current, out var proto)) + && _prototypeManager.Resolve(sign.Current, out var proto)) { SpriteSystem.LayerSetSprite((id, sprite), 0, proto.Icon); sprite.LayerSetShader(0, "unshaded"); diff --git a/Content.Client/BarSign/Ui/BarSignBoundUserInterface.cs b/Content.Client/BarSign/Ui/BarSignBoundUserInterface.cs index 1d1280b2f3..fe07f0f1d1 100644 --- a/Content.Client/BarSign/Ui/BarSignBoundUserInterface.cs +++ b/Content.Client/BarSign/Ui/BarSignBoundUserInterface.cs @@ -35,7 +35,7 @@ public sealed class BarSignBoundUserInterface(EntityUid owner, Enum uiKey) : Bou public void Update(ProtoId? sign) { - if (_prototype.TryIndex(sign, out var signPrototype)) + if (_prototype.Resolve(sign, out var signPrototype)) _menu?.UpdateState(signPrototype); } diff --git a/Content.Client/Cargo/UI/BountyEntry.xaml.cs b/Content.Client/Cargo/UI/BountyEntry.xaml.cs index 027d7b3e80..d813f70ff4 100644 --- a/Content.Client/Cargo/UI/BountyEntry.xaml.cs +++ b/Content.Client/Cargo/UI/BountyEntry.xaml.cs @@ -29,7 +29,7 @@ public sealed partial class BountyEntry : BoxContainer UntilNextSkip = untilNextSkip; - if (!_prototype.TryIndex(bounty.Bounty, out var bountyPrototype)) + if (!_prototype.Resolve(bounty.Bounty, out var bountyPrototype)) return; var items = new List(); diff --git a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs index 54804be641..98658e5f0a 100644 --- a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs +++ b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs @@ -19,7 +19,7 @@ public sealed partial class BountyHistoryEntry : BoxContainer RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); - if (!_prototype.TryIndex(bounty.Bounty, out var bountyPrototype)) + if (!_prototype.Resolve(bounty.Bounty, out var bountyPrototype)) return; var items = new List(); diff --git a/Content.Client/Chat/TypingIndicator/TypingIndicatorVisualizerSystem.cs b/Content.Client/Chat/TypingIndicator/TypingIndicatorVisualizerSystem.cs index 15698ad47a..d3c7148d41 100644 --- a/Content.Client/Chat/TypingIndicator/TypingIndicatorVisualizerSystem.cs +++ b/Content.Client/Chat/TypingIndicator/TypingIndicatorVisualizerSystem.cs @@ -35,7 +35,7 @@ public sealed class TypingIndicatorVisualizerSystem : VisualizerSystem(); foreach (var target in targets) { - if (string.IsNullOrEmpty(target) || !_proto.TryIndex(target, out EntityPrototype? proto)) + if (string.IsNullOrEmpty(target) || !_proto.Resolve(target, out EntityPrototype? proto)) continue; if (!proto.TryGetComponent(out TagComponent? tag, EntMan.ComponentFactory) || !_tag.HasTag(tag, st.RequiredTag)) diff --git a/Content.Client/Clothing/UI/ChameleonMenu.xaml.cs b/Content.Client/Clothing/UI/ChameleonMenu.xaml.cs index c6dce10776..fb4447bdf9 100644 --- a/Content.Client/Clothing/UI/ChameleonMenu.xaml.cs +++ b/Content.Client/Clothing/UI/ChameleonMenu.xaml.cs @@ -54,7 +54,7 @@ public sealed partial class ChameleonMenu : DefaultWindow foreach (var id in _possibleIds) { - if (!_prototypeManager.TryIndex(id, out EntityPrototype? proto)) + if (!_prototypeManager.Resolve(id, out EntityPrototype? proto)) continue; var lowId = id.Id.ToLowerInvariant(); diff --git a/Content.Client/Construction/ConstructionSystem.cs b/Content.Client/Construction/ConstructionSystem.cs index 0e7557724f..d693f4ac47 100644 --- a/Content.Client/Construction/ConstructionSystem.cs +++ b/Content.Client/Construction/ConstructionSystem.cs @@ -80,7 +80,7 @@ namespace Content.Client.Construction { foreach (var constructionProto in PrototypeManager.EnumeratePrototypes()) { - if (!PrototypeManager.TryIndex(constructionProto.Graph, out var graphProto)) + if (!PrototypeManager.Resolve(constructionProto.Graph, out var graphProto)) continue; if (constructionProto.TargetNode is not { } targetNodeId) @@ -121,17 +121,14 @@ namespace Content.Client.Construction // If we got the id of the prototype, we exit the “recursion” by clearing the stack. stack.Clear(); - if (!PrototypeManager.TryIndex(constructionProto.ID, out ConstructionPrototype? recipe)) + if (!PrototypeManager.Resolve(entityId, out var proto)) continue; - if (!PrototypeManager.TryIndex(entityId, out var proto)) - continue; + var name = constructionProto.SetName.HasValue ? Loc.GetString(constructionProto.SetName) : proto.Name; + var desc = constructionProto.SetDescription.HasValue ? Loc.GetString(constructionProto.SetDescription) : proto.Description; - var name = recipe.SetName.HasValue ? Loc.GetString(recipe.SetName) : proto.Name; - var desc = recipe.SetDescription.HasValue ? Loc.GetString(recipe.SetDescription) : proto.Description; - - recipe.Name = name; - recipe.Description = desc; + constructionProto.Name = name; + constructionProto.Description = desc; _recipesMetadataCache.Add(constructionProto.ID, entityId); } while (stack.Count > 0); @@ -172,7 +169,7 @@ namespace Content.Client.Construction "construction-ghost-examine-message", ("name", component.Prototype.Name))); - if (!PrototypeManager.TryIndex(component.Prototype.Graph, out var graph)) + if (!PrototypeManager.Resolve(component.Prototype.Graph, out var graph)) return; var startNode = graph.Nodes[component.Prototype.StartNode]; diff --git a/Content.Client/Construction/UI/ConstructionMenuPresenter.cs b/Content.Client/Construction/UI/ConstructionMenuPresenter.cs index 119e92fc6f..d5fee2bdda 100644 --- a/Content.Client/Construction/UI/ConstructionMenuPresenter.cs +++ b/Content.Client/Construction/UI/ConstructionMenuPresenter.cs @@ -510,7 +510,7 @@ namespace Content.Client.Construction.UI foreach (var id in favorites) { - if (_prototypeManager.TryIndex(id, out ConstructionPrototype? recipe, logError: false)) + if (_prototypeManager.TryIndex(id, out ConstructionPrototype? recipe)) _favoritedRecipes.Add(recipe); } diff --git a/Content.Client/Damage/DamageVisualsSystem.cs b/Content.Client/Damage/DamageVisualsSystem.cs index de866ca9a4..065bf628bc 100644 --- a/Content.Client/Damage/DamageVisualsSystem.cs +++ b/Content.Client/Damage/DamageVisualsSystem.cs @@ -150,7 +150,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem(damageComponent.DamageContainerID, out var damageContainer)) + && _prototypeManager.Resolve(damageComponent.DamageContainerID, out var damageContainer)) { // Are we using damage overlay sprites by group? // Check if the container matches the supported groups, diff --git a/Content.Client/Doors/DoorSystem.cs b/Content.Client/Doors/DoorSystem.cs index 3d9a3e2a9a..f1697b820d 100644 --- a/Content.Client/Doors/DoorSystem.cs +++ b/Content.Client/Doors/DoorSystem.cs @@ -142,7 +142,7 @@ public sealed class DoorSystem : SharedDoorSystem private void UpdateSpriteLayers(Entity sprite, string targetProto) { - if (!_prototypeManager.TryIndex(targetProto, out var target)) + if (!_prototypeManager.Resolve(targetProto, out var target)) return; if (!target.TryGetComponent(out SpriteComponent? targetSprite, _componentFactory)) diff --git a/Content.Client/Ghost/GhostRoleRadioMenu.xaml.cs b/Content.Client/Ghost/GhostRoleRadioMenu.xaml.cs index 1b65eac6ed..718b6c4995 100644 --- a/Content.Client/Ghost/GhostRoleRadioMenu.xaml.cs +++ b/Content.Client/Ghost/GhostRoleRadioMenu.xaml.cs @@ -65,7 +65,7 @@ public sealed partial class GhostRoleRadioMenu : RadialMenu }; // pick the icon if it exists, otherwise fallback to the ghost role's entity - if (_prototypeManager.TryIndex(ghostRoleProto.IconPrototype, out var iconProto)) + if (_prototypeManager.Resolve(ghostRoleProto.IconPrototype, out var iconProto)) entProtoView.SetPrototype(iconProto); else entProtoView.SetPrototype(ghostRoleProto.EntityPrototype); diff --git a/Content.Client/Guidebook/DocumentParsingManager.cs b/Content.Client/Guidebook/DocumentParsingManager.cs index ecf11d4725..8bc1a834fc 100644 --- a/Content.Client/Guidebook/DocumentParsingManager.cs +++ b/Content.Client/Guidebook/DocumentParsingManager.cs @@ -53,7 +53,7 @@ public sealed partial class DocumentParsingManager public bool TryAddMarkup(Control control, ProtoId entryId, bool log = true) { - if (!_prototype.TryIndex(entryId, out var entry)) + if (!_prototype.Resolve(entryId, out var entry)) return false; using var file = _resourceManager.ContentFileReadText(entry.Text); diff --git a/Content.Client/Implants/ImplanterSystem.cs b/Content.Client/Implants/ImplanterSystem.cs index 4ba4d015ca..a8c501daf1 100644 --- a/Content.Client/Implants/ImplanterSystem.cs +++ b/Content.Client/Implants/ImplanterSystem.cs @@ -28,7 +28,7 @@ public sealed class ImplanterSystem : SharedImplanterSystem Dictionary implants = new(); foreach (var implant in component.DeimplantWhitelist) { - if (_proto.TryIndex(implant, out var proto)) + if (_proto.Resolve(implant, out var proto)) implants.Add(proto.ID, proto.Name); } diff --git a/Content.Client/Implants/UI/ChameleonControllerMenu.xaml.cs b/Content.Client/Implants/UI/ChameleonControllerMenu.xaml.cs index a41e2e9293..c12ddb9319 100644 --- a/Content.Client/Implants/UI/ChameleonControllerMenu.xaml.cs +++ b/Content.Client/Implants/UI/ChameleonControllerMenu.xaml.cs @@ -62,7 +62,7 @@ public sealed partial class ChameleonControllerMenu : FancyWindow // Go through every outfit and add them to the correct department. foreach (var outfit in _outfits) { - _prototypeManager.TryIndex(outfit.Job, out var jobProto); + _prototypeManager.Resolve(outfit.Job, out var jobProto); var name = outfit.LoadoutName ?? outfit.Name ?? jobProto?.Name ?? "Prototype has no name or job."; diff --git a/Content.Client/Implants/UI/ImplanterStatusControl.cs b/Content.Client/Implants/UI/ImplanterStatusControl.cs index 569dd785d7..24445eeecf 100644 --- a/Content.Client/Implants/UI/ImplanterStatusControl.cs +++ b/Content.Client/Implants/UI/ImplanterStatusControl.cs @@ -49,7 +49,7 @@ public sealed class ImplanterStatusControl : Control if (_parent.CurrentMode == ImplanterToggleMode.Draw) { string implantName = _parent.DeimplantChosen != null - ? (_prototype.TryIndex(_parent.DeimplantChosen.Value, out EntityPrototype? implantProto) ? implantProto.Name : Loc.GetString("implanter-empty-text")) + ? (_prototype.Resolve(_parent.DeimplantChosen.Value, out EntityPrototype? implantProto) ? implantProto.Name : Loc.GetString("implanter-empty-text")) : Loc.GetString("implanter-empty-text"); _label.SetMarkup(Loc.GetString("implanter-label-draw", diff --git a/Content.Client/Lathe/UI/LatheMenu.xaml.cs b/Content.Client/Lathe/UI/LatheMenu.xaml.cs index 026fd046a6..491bbd85e0 100644 --- a/Content.Client/Lathe/UI/LatheMenu.xaml.cs +++ b/Content.Client/Lathe/UI/LatheMenu.xaml.cs @@ -140,7 +140,7 @@ public sealed partial class LatheMenu : DefaultWindow var recipesToShow = new List(); foreach (var recipe in Recipes) { - if (!_prototypeManager.TryIndex(recipe, out var proto)) + if (!_prototypeManager.Resolve(recipe, out var proto)) continue; // Category filtering @@ -226,7 +226,7 @@ public sealed partial class LatheMenu : DefaultWindow foreach (var (id, amount) in prototype.Materials) { - if (!_prototypeManager.TryIndex(id, out var proto)) + if (!_prototypeManager.Resolve(id, out var proto)) continue; var adjustedAmount = SharedLatheSystem.AdjustMaterial(amount, prototype.ApplyMaterialDiscount, multiplier); diff --git a/Content.Client/Lobby/LobbyUIController.cs b/Content.Client/Lobby/LobbyUIController.cs index ec052adea5..e36a2cd174 100644 --- a/Content.Client/Lobby/LobbyUIController.cs +++ b/Content.Client/Lobby/LobbyUIController.cs @@ -362,7 +362,7 @@ public sealed class LobbyUIController : UIController, IOnStateEntered(species)) page = new ProtoId(species.Id); // Gross. See above todo comment. - if (_prototypeManager.TryIndex(DefaultSpeciesGuidebook, out var guideRoot)) + if (_prototypeManager.Resolve(DefaultSpeciesGuidebook, out var guideRoot)) { var dict = new Dictionary, GuideEntry>(); dict.Add(DefaultSpeciesGuidebook, guideRoot); @@ -1400,7 +1400,7 @@ namespace Content.Client.Lobby.UI var sexes = new List(); // add species sex options, default to just none if we are in bizzaro world and have no species - if (_prototypeManager.TryIndex(Profile.Species, out var speciesProto)) + if (_prototypeManager.Resolve(Profile.Species, out var speciesProto)) { foreach (var sex in speciesProto.Sexes) { @@ -1493,7 +1493,7 @@ namespace Content.Client.Lobby.UI if (species is null) return; - if (!_prototypeManager.TryIndex(species, out var speciesProto)) + if (!_prototypeManager.Resolve(species, out var speciesProto)) return; // Don't display the info button if no guide entry is found diff --git a/Content.Client/Lobby/UI/Loadouts/LoadoutContainer.xaml.cs b/Content.Client/Lobby/UI/Loadouts/LoadoutContainer.xaml.cs index 2264cecd23..035f4a3c1a 100644 --- a/Content.Client/Lobby/UI/Loadouts/LoadoutContainer.xaml.cs +++ b/Content.Client/Lobby/UI/Loadouts/LoadoutContainer.xaml.cs @@ -40,7 +40,7 @@ public sealed partial class LoadoutContainer : BoxContainer SelectButton.TooltipSupplier = _ => tooltip; } - if (_protoManager.TryIndex(proto, out var loadProto)) + if (_protoManager.Resolve(proto, out var loadProto)) { var ent = loadProto.DummyEntity ?? _entManager.System().GetFirstOrNull(loadProto); diff --git a/Content.Client/Lobby/UI/Loadouts/LoadoutGroupContainer.xaml.cs b/Content.Client/Lobby/UI/Loadouts/LoadoutGroupContainer.xaml.cs index b06e7e41d1..644910db60 100644 --- a/Content.Client/Lobby/UI/Loadouts/LoadoutGroupContainer.xaml.cs +++ b/Content.Client/Lobby/UI/Loadouts/LoadoutGroupContainer.xaml.cs @@ -62,7 +62,7 @@ public sealed partial class LoadoutGroupContainer : BoxContainer }); } - if (protoMan.TryIndex(loadout.Role, out var roleProto) && roleProto.Points != null && loadout.Points != null) + if (protoMan.Resolve(loadout.Role, out var roleProto) && roleProto.Points != null && loadout.Points != null) { RestrictionsContainer.AddChild(new Label() { @@ -112,14 +112,14 @@ public sealed partial class LoadoutGroupContainer : BoxContainer }) .ToList(); - /* - * Determine which element should be displayed first: - * - If any element is currently selected (its button is pressed), use it. - * - Otherwise, fallback to the first element in the list. - * - * This moves the selected item outside of the sublist for better usability, - * making it easier for players to quickly toggle loadout options (e.g. clothing, accessories) - * without having to search inside expanded subgroups. + /* + * Determine which element should be displayed first: + * - If any element is currently selected (its button is pressed), use it. + * - Otherwise, fallback to the first element in the list. + * + * This moves the selected item outside of the sublist for better usability, + * making it easier for players to quickly toggle loadout options (e.g. clothing, accessories) + * without having to search inside expanded subgroups. */ var firstElement = uiElements.FirstOrDefault(e => e.Select.Pressed) ?? uiElements[0]; @@ -195,8 +195,8 @@ public sealed partial class LoadoutGroupContainer : BoxContainer /// /// Creates a UI container for a single Loadout item. /// - /// This method was extracted from RefreshLoadouts because the logic for creating - /// individual loadout items is used multiple times inside that method, and duplicating + /// This method was extracted from RefreshLoadouts because the logic for creating + /// individual loadout items is used multiple times inside that method, and duplicating /// the code made it harder to maintain. /// /// Logic: diff --git a/Content.Client/Lobby/UI/Loadouts/LoadoutWindow.xaml.cs b/Content.Client/Lobby/UI/Loadouts/LoadoutWindow.xaml.cs index 68e1ecbeae..50860b349a 100644 --- a/Content.Client/Lobby/UI/Loadouts/LoadoutWindow.xaml.cs +++ b/Content.Client/Lobby/UI/Loadouts/LoadoutWindow.xaml.cs @@ -68,7 +68,7 @@ public sealed partial class LoadoutWindow : FancyWindow { foreach (var group in proto.Groups) { - if (!protoManager.TryIndex(group, out var groupProto)) + if (!protoManager.Resolve(group, out var groupProto)) continue; if (groupProto.Hidden) diff --git a/Content.Client/Overlays/EntityHealthBarOverlay.cs b/Content.Client/Overlays/EntityHealthBarOverlay.cs index 9ff0422aba..cf9d879844 100644 --- a/Content.Client/Overlays/EntityHealthBarOverlay.cs +++ b/Content.Client/Overlays/EntityHealthBarOverlay.cs @@ -57,7 +57,7 @@ public sealed class EntityHealthBarOverlay : Overlay const float scale = 1f; var scaleMatrix = Matrix3Helpers.CreateScale(new Vector2(scale, scale)); var rotationMatrix = Matrix3Helpers.CreateRotation(-rotation); - _prototype.TryIndex(StatusIcon, out var statusIcon); + _prototype.Resolve(StatusIcon, out var statusIcon); var query = _entManager.AllEntityQueryEnumerator(); while (query.MoveNext(out var uid, diff --git a/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs b/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs index c353b17272..9a84defba0 100644 --- a/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs +++ b/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs @@ -22,7 +22,7 @@ public sealed class ShowCriminalRecordIconsSystem : EquipmentHudSystem(entity) && _prototypeMan.TryIndex(damageableComponent.RottingIcon, out var rottingIcon)) + if (HasComp(entity) && _prototypeMan.Resolve(damageableComponent.RottingIcon, out var rottingIcon)) result.Add(rottingIcon); - else if (damageableComponent.HealthIcons.TryGetValue(state.CurrentState, out var value) && _prototypeMan.TryIndex(value, out var icon)) + else if (damageableComponent.HealthIcons.TryGetValue(state.CurrentState, out var value) && _prototypeMan.Resolve(value, out var icon)) result.Add(icon); } } diff --git a/Content.Client/Overlays/ShowJobIconsSystem.cs b/Content.Client/Overlays/ShowJobIconsSystem.cs index d0d14449f6..faf4024c2f 100644 --- a/Content.Client/Overlays/ShowJobIconsSystem.cs +++ b/Content.Client/Overlays/ShowJobIconsSystem.cs @@ -51,7 +51,7 @@ public sealed class ShowJobIconsSystem : EquipmentHudSystem(proto, out var weatherProto)) + if (!_protoManager.Resolve(proto, out var weatherProto)) continue; var alpha = _weather.GetPercent(weather, mapUid); diff --git a/Content.Client/RCD/RCDMenuBoundUserInterface.cs b/Content.Client/RCD/RCDMenuBoundUserInterface.cs index 2106c83569..d074ac48ed 100644 --- a/Content.Client/RCD/RCDMenuBoundUserInterface.cs +++ b/Content.Client/RCD/RCDMenuBoundUserInterface.cs @@ -125,8 +125,10 @@ public sealed class RCDMenuBoundUserInterface : BoundUserInterface var name = Loc.GetString(proto.SetName); if (proto.Prototype != null && - _prototypeManager.TryIndex(proto.Prototype, out var entProto, logError: false)) + _prototypeManager.Resolve(proto.Prototype, out var entProto)) + { name = entProto.Name; + } msg = Loc.GetString("rcd-component-change-build-mode", ("name", name)); } @@ -142,7 +144,7 @@ public sealed class RCDMenuBoundUserInterface : BoundUserInterface if (proto.Mode is RcdMode.ConstructTile or RcdMode.ConstructObject && proto.Prototype != null - && _prototypeManager.TryIndex(proto.Prototype, out var entProto, logError: false)) + && _prototypeManager.Resolve(proto.Prototype, out var entProto)) { tooltip = Loc.GetString(entProto.Name); } diff --git a/Content.Client/Radio/Ui/IntercomMenu.xaml.cs b/Content.Client/Radio/Ui/IntercomMenu.xaml.cs index f66b3db000..887c6f6443 100644 --- a/Content.Client/Radio/Ui/IntercomMenu.xaml.cs +++ b/Content.Client/Radio/Ui/IntercomMenu.xaml.cs @@ -42,7 +42,7 @@ public sealed partial class IntercomMenu : FancyWindow for (var i = 0; i < entity.Comp.SupportedChannels.Count; i++) { var channel = entity.Comp.SupportedChannels[i]; - if (!_prototype.TryIndex(channel, out var prototype)) + if (!_prototype.Resolve(channel, out var prototype)) continue; _channels.Add(channel); diff --git a/Content.Client/Revolutionary/RevolutionarySystem.cs b/Content.Client/Revolutionary/RevolutionarySystem.cs index 8e7e687fa8..2dc16d9c11 100644 --- a/Content.Client/Revolutionary/RevolutionarySystem.cs +++ b/Content.Client/Revolutionary/RevolutionarySystem.cs @@ -25,13 +25,13 @@ public sealed class RevolutionarySystem : SharedRevolutionarySystem if (HasComp(ent)) return; - if (_prototype.TryIndex(ent.Comp.StatusIcon, out var iconPrototype)) + if (_prototype.Resolve(ent.Comp.StatusIcon, out var iconPrototype)) args.StatusIcons.Add(iconPrototype); } private void GetHeadRevIcon(Entity ent, ref GetStatusIconsEvent args) { - if (_prototype.TryIndex(ent.Comp.StatusIcon, out var iconPrototype)) + if (_prototype.Resolve(ent.Comp.StatusIcon, out var iconPrototype)) args.StatusIcons.Add(iconPrototype); } } diff --git a/Content.Client/Silicons/StationAi/StationAiCustomizationMenu.xaml.cs b/Content.Client/Silicons/StationAi/StationAiCustomizationMenu.xaml.cs index 009969196b..3c5375a8e4 100644 --- a/Content.Client/Silicons/StationAi/StationAiCustomizationMenu.xaml.cs +++ b/Content.Client/Silicons/StationAi/StationAiCustomizationMenu.xaml.cs @@ -44,7 +44,7 @@ public sealed partial class StationAiCustomizationMenu : FancyWindow StationAiCustomizationPrototype? selectedPrototype = null; if (stationAiCustomization?.ProtoIds.TryGetValue(groupPrototype, out var selectedProtoId) == true) - _protoManager.TryIndex(selectedProtoId, out selectedPrototype); + _protoManager.Resolve(selectedProtoId, out selectedPrototype); _buttonGroups[groupPrototype] = new ButtonGroup(); _groupContainers[groupPrototype] = new StationAiCustomizationGroupContainer(groupPrototype, selectedPrototype, _buttonGroups[groupPrototype], this, _protoManager); @@ -76,7 +76,7 @@ public sealed partial class StationAiCustomizationMenu : FancyWindow // Create UI entries for all customization in the group foreach (var protoId in groupPrototype.ProtoIds) { - if (!protoManager.TryIndex(protoId, out var prototype)) + if (!protoManager.Resolve(protoId, out var prototype)) continue; var entry = new StationAiCustomizationEntryContainer(groupPrototype, prototype, buttonGroup, menu); diff --git a/Content.Client/SprayPainter/SprayPainterSystem.cs b/Content.Client/SprayPainter/SprayPainterSystem.cs index 8f7d7f0362..788e97bef1 100644 --- a/Content.Client/SprayPainter/SprayPainterSystem.cs +++ b/Content.Client/SprayPainter/SprayPainterSystem.cs @@ -65,7 +65,7 @@ public sealed class SprayPainterSystem : SharedSprayPainterSystem var groupList = new List(); foreach (var groupId in category.Groups) { - if (!Proto.TryIndex(groupId, out var group)) + if (!Proto.Resolve(groupId, out var group)) continue; groupList.Add(groupId); diff --git a/Content.Client/Storage/Visualizers/EntityStorageVisualizerSystem.cs b/Content.Client/Storage/Visualizers/EntityStorageVisualizerSystem.cs index c10a24ac32..ea0b800ccc 100644 --- a/Content.Client/Storage/Visualizers/EntityStorageVisualizerSystem.cs +++ b/Content.Client/Storage/Visualizers/EntityStorageVisualizerSystem.cs @@ -42,7 +42,7 @@ public sealed class EntityStorageVisualizerSystem : VisualizerSystem(uid, PaintableVisuals.Prototype, out var prototype, args.Component)) { - if (_prototypeManager.TryIndex(prototype, out var proto)) + if (_prototypeManager.Resolve(prototype, out var proto)) { if (proto.TryGetComponent(out SpriteComponent? sprite, _componentFactory)) { diff --git a/Content.Client/Store/Ui/StoreWithdrawWindow.xaml.cs b/Content.Client/Store/Ui/StoreWithdrawWindow.xaml.cs index a8b93cd2b3..e706e74bc3 100644 --- a/Content.Client/Store/Ui/StoreWithdrawWindow.xaml.cs +++ b/Content.Client/Store/Ui/StoreWithdrawWindow.xaml.cs @@ -33,7 +33,7 @@ public sealed partial class StoreWithdrawWindow : DefaultWindow _validCurrencies.Clear(); foreach (var currency in balance) { - if (!_prototypeManager.TryIndex(currency.Key, out var proto)) + if (!_prototypeManager.Resolve(currency.Key, out var proto)) continue; _validCurrencies.Add(proto, currency.Value); diff --git a/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs b/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs index 41d29e8080..9077f95565 100644 --- a/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs +++ b/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs @@ -120,7 +120,7 @@ namespace Content.Client.VendingMachines.UI { var entry = inventory[i]; - if (!_prototypeManager.TryIndex(entry.ID, out var prototype)) + if (!_prototypeManager.Resolve(entry.ID, out var prototype)) { _amounts[entry.ID] = 0; continue; diff --git a/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs b/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs index 3d49fe490f..397f2d1af2 100644 --- a/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs +++ b/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs @@ -146,8 +146,8 @@ public sealed class SuicideCommandTests mobThresholdsComp = entManager.GetComponent(player); damageableComp = entManager.GetComponent(player); - if (protoMan.TryIndex(DamageType, out var slashProto)) - damageableSystem.TryChangeDamage(player, new DamageSpecifier(slashProto, FixedPoint2.New(46.5))); + var slashProto = protoMan.Index(DamageType); + damageableSystem.TryChangeDamage(player, new DamageSpecifier(slashProto, FixedPoint2.New(46.5))); }); // Check that running the suicide command kills the player diff --git a/Content.IntegrationTests/Tests/ContrabandTest.cs b/Content.IntegrationTests/Tests/ContrabandTest.cs index a33e7c2067..c52ef293e1 100644 --- a/Content.IntegrationTests/Tests/ContrabandTest.cs +++ b/Content.IntegrationTests/Tests/ContrabandTest.cs @@ -27,8 +27,11 @@ public sealed class ContrabandTest if (!proto.TryGetComponent(out var contraband, componentFactory)) continue; - Assert.That(protoMan.TryIndex(contraband.Severity, out var severity, false), - @$"{proto.ID} has a ContrabandComponent with a unknown severity."); + if (!protoMan.TryIndex(contraband.Severity, out var severity)) + { + Assert.Fail($"{proto.ID} has a ContrabandComponent with a unknown severity."); + continue; + } if (!severity.ShowDepartmentsAndJobs) continue; diff --git a/Content.IntegrationTests/Tests/Lathe/LatheTest.cs b/Content.IntegrationTests/Tests/Lathe/LatheTest.cs index 2fe347f636..c335f8d6c8 100644 --- a/Content.IntegrationTests/Tests/Lathe/LatheTest.cs +++ b/Content.IntegrationTests/Tests/Lathe/LatheTest.cs @@ -88,14 +88,18 @@ public sealed class LatheTest // Check each recipe assigned to this lathe foreach (var recipeId in recipes) { - Assert.That(protoMan.TryIndex(recipeId, out var recipeProto)); + if (!protoMan.TryIndex(recipeId, out var recipeProto)) + { + Assert.Fail($"Lathe recipe '{recipeId}' does not exist"); + continue; + } // Track the total material volume of the recipe var totalQuantity = 0; // Check each material called for by the recipe foreach (var (materialId, quantity) in recipeProto.Materials) { - Assert.That(protoMan.TryIndex(materialId, out var materialProto)); + Assert.That(protoMan.HasIndex(materialId), $"Material '{materialId}' does not exist"); // Make sure the material is accepted by the lathe Assert.That(acceptedMaterials, Does.Contain(materialId), $"Lathe {latheProto.ID} has recipe {recipeId} but does not accept any materials containing {materialId}"); totalQuantity += quantity; diff --git a/Content.IntegrationTests/Tests/Minds/MindTests.cs b/Content.IntegrationTests/Tests/Minds/MindTests.cs index 2f77519829..1bda6fd4db 100644 --- a/Content.IntegrationTests/Tests/Minds/MindTests.cs +++ b/Content.IntegrationTests/Tests/Minds/MindTests.cs @@ -145,10 +145,7 @@ public sealed partial class MindTests await server.WaitAssertion(() => { var damageable = entMan.GetComponent(entity); - if (!protoMan.TryIndex(BluntDamageType, out var prototype)) - { - return; - } + var prototype = protoMan.Index(BluntDamageType); damageableSystem.SetDamage(entity, damageable, new DamageSpecifier(prototype, FixedPoint2.New(401))); Assert.That(mindSystem.GetMind(entity, mindContainerComp), Is.EqualTo(mindId)); diff --git a/Content.IntegrationTests/Tests/PostMapInitTest.cs b/Content.IntegrationTests/Tests/PostMapInitTest.cs index c7066feb9a..2932991138 100644 --- a/Content.IntegrationTests/Tests/PostMapInitTest.cs +++ b/Content.IntegrationTests/Tests/PostMapInitTest.cs @@ -265,8 +265,7 @@ namespace Content.IntegrationTests.Tests return; var yamlEntities = node["entities"]; - if (!protoManager.TryIndex(DoNotMapCategory, out var dnmCategory)) - return; + var dnmCategory = protoManager.Index(DoNotMapCategory); Assert.Multiple(() => { @@ -275,7 +274,7 @@ namespace Content.IntegrationTests.Tests var protoId = yamlEntity["proto"].AsString(); // This doesn't properly handle prototype migrations, but thats not a significant issue. - if (!protoManager.TryIndex(protoId, out var proto, false)) + if (!protoManager.TryIndex(protoId, out var proto)) continue; Assert.That(!proto.Categories.Contains(dnmCategory), diff --git a/Content.Server/Access/Systems/AgentIDCardSystem.cs b/Content.Server/Access/Systems/AgentIDCardSystem.cs index 742c15a524..17cec17263 100644 --- a/Content.Server/Access/Systems/AgentIDCardSystem.cs +++ b/Content.Server/Access/Systems/AgentIDCardSystem.cs @@ -59,7 +59,7 @@ namespace Content.Server.Access.Systems if (!TryComp(ent, out var idCardComp)) return; - _prototypeManager.TryIndex(args.Args.ChameleonOutfit.Job, out var jobProto); + _prototypeManager.Resolve(args.Args.ChameleonOutfit.Job, out var jobProto); var jobIcon = args.Args.ChameleonOutfit.Icon ?? jobProto?.Icon; var jobName = args.Args.ChameleonOutfit.Name ?? jobProto?.Name ?? ""; @@ -190,7 +190,7 @@ namespace Content.Server.Access.Systems if (!TryComp(uid, out var idCard)) return; - if (!_prototypeManager.TryIndex(args.JobIconId, out var jobIcon)) + if (!_prototypeManager.Resolve(args.JobIconId, out var jobIcon)) return; _cardSystem.TryChangeJobIcon(uid, jobIcon, idCard); diff --git a/Content.Server/Access/Systems/IdCardConsoleSystem.cs b/Content.Server/Access/Systems/IdCardConsoleSystem.cs index fda98b6c12..411f0aaf7c 100644 --- a/Content.Server/Access/Systems/IdCardConsoleSystem.cs +++ b/Content.Server/Access/Systems/IdCardConsoleSystem.cs @@ -99,7 +99,7 @@ public sealed partial class IdCardConsoleSystem : SharedIdCardConsoleSystem // D var targetIdComponent = Comp(targetId); var targetAccessComponent = Comp(targetId); - var jobProto = targetIdComponent.JobPrototype ?? new ProtoId(string.Empty); + var jobProto = targetIdComponent.JobPrototype ?? new ProtoId(string.Empty); if (TryComp(targetId, out var keyStorage) && keyStorage.Key is { } key && _record.TryGetRecord(key, out var record)) @@ -131,7 +131,7 @@ public sealed partial class IdCardConsoleSystem : SharedIdCardConsoleSystem // D string newFullName, string newJobTitle, List> newAccessList, - ProtoId newJobProto, + ProtoId newJobProto, EntityUid player, IdCardConsoleComponent? component = null) { @@ -145,7 +145,7 @@ public sealed partial class IdCardConsoleSystem : SharedIdCardConsoleSystem // D _idCard.TryChangeJobTitle(targetId, newJobTitle, player: player); if (_prototype.TryIndex(newJobProto, out var job) - && _prototype.TryIndex(job.Icon, out var jobIcon)) + && _prototype.Resolve(job.Icon, out var jobIcon)) { _idCard.TryChangeJobIcon(targetId, jobIcon, player: player); _idCard.TryChangeJobDepartment(targetId, job); diff --git a/Content.Server/Access/Systems/PresetIdCardSystem.cs b/Content.Server/Access/Systems/PresetIdCardSystem.cs index a48de987ad..a6bf904a5d 100644 --- a/Content.Server/Access/Systems/PresetIdCardSystem.cs +++ b/Content.Server/Access/Systems/PresetIdCardSystem.cs @@ -86,8 +86,8 @@ public sealed class PresetIdCardSystem : EntitySystem _cardSystem.TryChangeJobTitle(uid, job.LocalizedName); _cardSystem.TryChangeJobDepartment(uid, job); - // DeltaV: only set to the job's icon if the id doesn't specify one - if (card.JobIcon == "JobIconUnknown" && _prototypeManager.TryIndex(job.Icon, out var jobIcon)) + + if (card.JobIcon == "JobIconUnknown" && _prototypeManager.Resolve(job.Icon, out var jobIcon)) // DeltaV: only set to the job's icon if the id doesn't specify one _cardSystem.TryChangeJobIcon(uid, jobIcon); } } diff --git a/Content.Server/Administration/Commands/ExplosionCommand.cs b/Content.Server/Administration/Commands/ExplosionCommand.cs index 787886f164..6f9e89243d 100644 --- a/Content.Server/Administration/Commands/ExplosionCommand.cs +++ b/Content.Server/Administration/Commands/ExplosionCommand.cs @@ -118,7 +118,7 @@ public sealed class ExplosionCommand : LocalizedEntityCommands return; } } - else if (!_prototypeManager.TryIndex(ExplosionSystem.DefaultExplosionPrototypeId, out type)) + else if (!_prototypeManager.Resolve(ExplosionSystem.DefaultExplosionPrototypeId, out type)) { // no prototype was specified, so lets default to whichever one was defined first type = _prototypeManager.EnumeratePrototypes().FirstOrDefault(); diff --git a/Content.Server/Advertise/EntitySystems/SpeakOnUIClosedSystem.cs b/Content.Server/Advertise/EntitySystems/SpeakOnUIClosedSystem.cs index 3fca640d4a..94b20c7b77 100644 --- a/Content.Server/Advertise/EntitySystems/SpeakOnUIClosedSystem.cs +++ b/Content.Server/Advertise/EntitySystems/SpeakOnUIClosedSystem.cs @@ -38,7 +38,7 @@ public sealed partial class SpeakOnUIClosedSystem : SharedSpeakOnUIClosedSystem if (!entity.Comp.Enabled) return false; - if (!_prototypeManager.TryIndex(entity.Comp.Pack, out var messagePack)) + if (!_prototypeManager.Resolve(entity.Comp.Pack, out var messagePack)) return false; var message = Loc.GetString(_random.Pick(messagePack.Values), ("name", Name(entity))); diff --git a/Content.Server/Anomaly/Effects/InnerBodyAnomalySystem.cs b/Content.Server/Anomaly/Effects/InnerBodyAnomalySystem.cs index bcf0a00bb3..f040514424 100644 --- a/Content.Server/Anomaly/Effects/InnerBodyAnomalySystem.cs +++ b/Content.Server/Anomaly/Effects/InnerBodyAnomalySystem.cs @@ -86,7 +86,7 @@ public sealed class InnerBodyAnomalySystem : SharedInnerBodyAnomalySystem private void AddAnomalyToBody(Entity ent) { - if (!_proto.TryIndex(ent.Comp.InjectionProto, out var injectedAnom)) + if (!_proto.Resolve(ent.Comp.InjectionProto, out var injectedAnom)) return; if (ent.Comp.Injected) @@ -216,7 +216,7 @@ public sealed class InnerBodyAnomalySystem : SharedInnerBodyAnomalySystem if (!ent.Comp.Injected) return; - if (_proto.TryIndex(ent.Comp.InjectionProto, out var injectedAnom)) + if (_proto.Resolve(ent.Comp.InjectionProto, out var injectedAnom)) EntityManager.RemoveComponents(ent, injectedAnom.Components); if (!ent.Comp.SkipStun) // imp. added this check for anomalites diff --git a/Content.Server/Audio/Jukebox/JukeboxSystem.cs b/Content.Server/Audio/Jukebox/JukeboxSystem.cs index 3535f6b238..81d71894b8 100644 --- a/Content.Server/Audio/Jukebox/JukeboxSystem.cs +++ b/Content.Server/Audio/Jukebox/JukeboxSystem.cs @@ -51,7 +51,7 @@ public sealed class JukeboxSystem : SharedJukeboxSystem component.AudioStream = Audio.Stop(component.AudioStream); if (string.IsNullOrEmpty(component.SelectedSongId) || - !_protoManager.TryIndex(component.SelectedSongId, out var jukeboxProto)) + !_protoManager.Resolve(component.SelectedSongId, out var jukeboxProto)) { return; } diff --git a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs index 934517eadc..c2c2a8365c 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs @@ -113,7 +113,7 @@ public sealed partial class CargoSystem public void SetupBountyLabel(EntityUid uid, EntityUid stationId, CargoBountyData bounty, PaperComponent? paper = null, CargoBountyLabelComponent? label = null) { - if (!Resolve(uid, ref paper, ref label) || !_protoMan.TryIndex(bounty.Bounty, out var prototype)) + if (!Resolve(uid, ref paper, ref label) || !_protoMan.Resolve(bounty.Bounty, out var prototype)) return; label.Id = bounty.Id; @@ -156,7 +156,7 @@ public sealed partial class CargoSystem if (!TryGetBountyFromId(station, component.Id, out var bounty, database)) return; - if (!_protoMan.TryIndex(bounty.Value.Bounty, out var bountyPrototype) || + if (!_protoMan.Resolve(bounty.Value.Bounty, out var bountyPrototype) || !IsBountyComplete(container.Owner, bountyPrototype)) return; @@ -275,7 +275,7 @@ public sealed partial class CargoSystem public bool IsBountyComplete(EntityUid container, CargoBountyData data, out HashSet bountyEntities) { - if (!_protoMan.TryIndex(data.Bounty, out var proto)) + if (!_protoMan.Resolve(data.Bounty, out var proto)) { bountyEntities = new(); return false; diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index 95a75657b4..5df1465122 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -167,7 +167,7 @@ namespace Content.Server.Cargo.Systems // Find our order again. It might have been dispatched or approved already var order = orderDatabase.Orders[component.Account].Find(order => args.OrderId == order.OrderId && !order.Approved); - if (order == null || !_protoMan.TryIndex(order.Account, out var account)) + if (order == null || !_protoMan.Resolve(order.Account, out var account)) { return; } @@ -322,7 +322,7 @@ namespace Content.Server.Cargo.Systems private void OnAddOrderMessageSlipPrinter(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleAddOrderMessage args, CargoProductPrototype product) { - if (!_protoMan.TryIndex(component.Account, out var account)) + if (!_protoMan.Resolve(component.Account, out var account)) return; if (Timing.CurTime < component.NextPrintTime) diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 94bef7c7b8..09b8aba14d 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -466,7 +466,7 @@ public sealed partial class ChatSystem : SharedChatSystem RaiseLocalEvent(source, nameEv); name = nameEv.VoiceName; // Check for a speech verb override - if (nameEv.SpeechVerb != null && _prototypeManager.TryIndex(nameEv.SpeechVerb, out var proto)) + if (nameEv.SpeechVerb != null && _prototypeManager.Resolve(nameEv.SpeechVerb, out var proto)) speech = proto; } diff --git a/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs b/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs index 48d547d1e0..d5b220c3e8 100644 --- a/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs @@ -66,7 +66,7 @@ public sealed class TransformableContainerSystem : EntitySystem private void OnRefreshNameModifiers(Entity entity, ref RefreshNameModifiersEvent args) { - if (_prototypeManager.TryIndex(entity.Comp.CurrentReagent, out var currentReagent)) + if (_prototypeManager.Resolve(entity.Comp.CurrentReagent, out var currentReagent)) { args.AddModifier("transformable-container-component-glass", priority: -1, ("reagent", currentReagent.LocalizedName)); } diff --git a/Content.Server/Cloning/CloningSystem.cs b/Content.Server/Cloning/CloningSystem.cs index b0d62be523..6e0f38ad51 100644 --- a/Content.Server/Cloning/CloningSystem.cs +++ b/Content.Server/Cloning/CloningSystem.cs @@ -43,13 +43,13 @@ public sealed partial class CloningSystem : SharedCloningSystem public bool TryCloning(EntityUid original, MapCoordinates? coords, ProtoId settingsId, [NotNullWhen(true)] out EntityUid? clone) { clone = null; - if (!_prototype.TryIndex(settingsId, out var settings)) + if (!_prototype.Resolve(settingsId, out var settings)) return false; // invalid settings if (!TryComp(original, out var humanoid)) return false; // whatever body was to be cloned, was not a humanoid - if (!_prototype.TryIndex(humanoid.Species, out var speciesPrototype)) + if (!_prototype.Resolve(humanoid.Species, out var speciesPrototype)) return false; // invalid species var attemptEv = new CloningAttemptEvent(settings); diff --git a/Content.Server/Construction/ConstructionSystem.Guided.cs b/Content.Server/Construction/ConstructionSystem.Guided.cs index 157e421158..42c64db991 100644 --- a/Content.Server/Construction/ConstructionSystem.Guided.cs +++ b/Content.Server/Construction/ConstructionSystem.Guided.cs @@ -145,7 +145,7 @@ namespace Content.Server.Construction return guide; // If the graph doesn't actually exist, do nothing. - if (!PrototypeManager.TryIndex(construction.Graph, out ConstructionGraphPrototype? graph)) + if (!PrototypeManager.Resolve(construction.Graph, out ConstructionGraphPrototype? graph)) return null; // If either the start node or the target node are missing, do nothing. diff --git a/Content.Server/Damage/ForceSay/DamageForceSaySystem.cs b/Content.Server/Damage/ForceSay/DamageForceSaySystem.cs index 8dfe665541..a46d42f3e3 100644 --- a/Content.Server/Damage/ForceSay/DamageForceSaySystem.cs +++ b/Content.Server/Damage/ForceSay/DamageForceSaySystem.cs @@ -61,7 +61,7 @@ public sealed class DamageForceSaySystem : EntitySystem var ev = new BeforeForceSayEvent(component.ForceSayStringDataset); RaiseLocalEvent(uid, ev); - if (!_prototype.TryIndex(ev.Prefix, out var prefixList)) + if (!_prototype.Resolve(ev.Prefix, out var prefixList)) return; var suffix = Loc.GetString(_random.Pick(prefixList.Values)); diff --git a/Content.Server/Damage/Systems/ExaminableDamageSystem.cs b/Content.Server/Damage/Systems/ExaminableDamageSystem.cs index 155cf08962..b0dfae71b7 100644 --- a/Content.Server/Damage/Systems/ExaminableDamageSystem.cs +++ b/Content.Server/Damage/Systems/ExaminableDamageSystem.cs @@ -20,7 +20,7 @@ public sealed class ExaminableDamageSystem : EntitySystem private void OnExamine(Entity ent, ref ExaminedEvent args) { - if (!_prototype.TryIndex(ent.Comp.Messages, out var proto) || proto.Values.Count == 0) + if (!_prototype.Resolve(ent.Comp.Messages, out var proto) || proto.Values.Count == 0) return; var percent = GetDamagePercent(ent); diff --git a/Content.Server/Destructible/Thresholds/Behaviors/WeightedSpawnEntityBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/WeightedSpawnEntityBehavior.cs index 96fa4dd438..4a275ac895 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/WeightedSpawnEntityBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/WeightedSpawnEntityBehavior.cs @@ -66,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(TempEntityProtoId, out var tempSpawnerProto)) + if (!system.PrototypeManager.Resolve(TempEntityProtoId, out var tempSpawnerProto)) return; // spawn the spawner, assign it a lifetime, and assign the entity that it will spawn when despawned diff --git a/Content.Server/EntityEffects/EntityEffectSystem.cs b/Content.Server/EntityEffects/EntityEffectSystem.cs index cf19b9d996..424d11f5fe 100644 --- a/Content.Server/EntityEffects/EntityEffectSystem.cs +++ b/Content.Server/EntityEffects/EntityEffectSystem.cs @@ -975,9 +975,7 @@ public sealed class EntityEffectSystem : EntitySystem return; var targetProto = _random.Pick(plantholder.Seed.MutationPrototypes); - _protoManager.TryIndex(targetProto, out SeedPrototype? protoSeed); - - if (protoSeed == null) + if (!_protoManager.TryIndex(targetProto, out SeedPrototype? protoSeed)) { Log.Error($"Seed prototype could not be found: {targetProto}!"); return; diff --git a/Content.Server/GameTicking/Rules/AntagLoadProfileRuleSystem.cs b/Content.Server/GameTicking/Rules/AntagLoadProfileRuleSystem.cs index 3527e2a11c..84f87a487b 100644 --- a/Content.Server/GameTicking/Rules/AntagLoadProfileRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/AntagLoadProfileRuleSystem.cs @@ -32,7 +32,7 @@ public sealed class AntagLoadProfileRuleSystem : GameRuleSystem(SharedHumanoidAppearanceSystem.DefaultSpecies); } diff --git a/Content.Server/GameTicking/Rules/VariationPass/PuddleMessVariationPassSystem.cs b/Content.Server/GameTicking/Rules/VariationPass/PuddleMessVariationPassSystem.cs index 2895416a7f..c81001daac 100644 --- a/Content.Server/GameTicking/Rules/VariationPass/PuddleMessVariationPassSystem.cs +++ b/Content.Server/GameTicking/Rules/VariationPass/PuddleMessVariationPassSystem.cs @@ -17,7 +17,7 @@ public sealed class PuddleMessVariationPassSystem : VariationPassSystem entity, ref GhostRoleRadioMessage args) { - if (!_prototype.TryIndex(args.ProtoId, out var ghostRoleProto)) + if (!_prototype.Resolve(args.ProtoId, out var ghostRoleProto)) return; // if the prototype chosen isn't actually part of the selectable options, ignore it diff --git a/Content.Server/Ghost/SpookySpeakerSystem.cs b/Content.Server/Ghost/SpookySpeakerSystem.cs index 5a83ca39b1..ce3a2705a0 100644 --- a/Content.Server/Ghost/SpookySpeakerSystem.cs +++ b/Content.Server/Ghost/SpookySpeakerSystem.cs @@ -32,7 +32,7 @@ public sealed class SpookySpeakerSystem : EntitySystem if (curTime < entity.Comp.NextSpeakTime) return; - if (!_proto.TryIndex(entity.Comp.MessageSet, out var messages)) + if (!_proto.Resolve(entity.Comp.MessageSet, out var messages)) return; // Grab a random localized message from the set diff --git a/Content.Server/Implants/ChameleonControllerSystem.cs b/Content.Server/Implants/ChameleonControllerSystem.cs index 930f2e3156..e884e181ee 100644 --- a/Content.Server/Implants/ChameleonControllerSystem.cs +++ b/Content.Server/Implants/ChameleonControllerSystem.cs @@ -49,8 +49,8 @@ public sealed class ChameleonControllerSystem : SharedChameleonControllerSystem { var outfitPrototype = _proto.Index(outfit); - _proto.TryIndex(outfitPrototype.Job, out var jobPrototype); - _proto.TryIndex(outfitPrototype.StartingGear, out var startingGearPrototype); + _proto.Resolve(outfitPrototype.Job, out var jobPrototype); + _proto.Resolve(outfitPrototype.StartingGear, out var startingGearPrototype); GetJobEquipmentInformation(jobPrototype, user, out var customRoleLoadout, out var defaultRoleLoadout, out var jobStartingGearPrototype); @@ -81,7 +81,7 @@ public sealed class ChameleonControllerSystem : SharedChameleonControllerSystem if (jobPrototype == null) return; - _proto.TryIndex(jobPrototype.StartingGear, out jobStartingGearPrototype); + _proto.Resolve(jobPrototype.StartingGear, out jobStartingGearPrototype); if (!TryComp(user, out var actorComponent)) return; diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index f6dc23a2f4..9094a748dd 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -750,7 +750,7 @@ namespace Content.Server.Kitchen.EntitySystems { foreach (ProtoId recipeId in ent.Comp.ProvidedRecipes) { - if (_prototype.TryIndex(recipeId, out var recipeProto)) + if (_prototype.Resolve(recipeId, out var recipeProto)) { args.Recipes.Add(recipeProto); } diff --git a/Content.Server/Lathe/LatheSystem.cs b/Content.Server/Lathe/LatheSystem.cs index 226ee993c7..00c61705b2 100644 --- a/Content.Server/Lathe/LatheSystem.cs +++ b/Content.Server/Lathe/LatheSystem.cs @@ -138,7 +138,7 @@ namespace Content.Server.Lathe var recipes = GetAvailableRecipes(uid, component, true); foreach (var id in recipes) { - if (!_proto.TryIndex(id, out var proto)) + if (!_proto.Resolve(id, out var proto)) continue; foreach (var (mat, _) in proto.Materials) { diff --git a/Content.Server/NameIdentifier/NameIdentifierSystem.cs b/Content.Server/NameIdentifier/NameIdentifierSystem.cs index 1e5ed67a63..5aa60924ec 100644 --- a/Content.Server/NameIdentifier/NameIdentifierSystem.cs +++ b/Content.Server/NameIdentifier/NameIdentifierSystem.cs @@ -92,7 +92,7 @@ public sealed class NameIdentifierSystem : EntitySystem if (ent.Comp.Group is null) return; - if (!_prototypeManager.TryIndex(ent.Comp.Group, out var group)) + if (!_prototypeManager.Resolve(ent.Comp.Group, out var group)) return; int id; @@ -131,7 +131,7 @@ public sealed class NameIdentifierSystem : EntitySystem if (ent.Comp.LifeStage > ComponentLifeStage.Running) return; - if (!_prototypeManager.TryIndex(ent.Comp.Group, out var group)) + if (!_prototypeManager.Resolve(ent.Comp.Group, out var group)) return; var format = group.FullName ? "name-identifier-format-full" : "name-identifier-format-append"; diff --git a/Content.Server/Parallax/BiomeSystem.cs b/Content.Server/Parallax/BiomeSystem.cs index 496cb387e8..6974bc1fda 100644 --- a/Content.Server/Parallax/BiomeSystem.cs +++ b/Content.Server/Parallax/BiomeSystem.cs @@ -127,7 +127,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem SetSeed(uid, component, _random.Next()); } - if (_proto.TryIndex(component.Template, out var biome)) + if (_proto.Resolve(component.Template, out var biome)) SetTemplate(uid, component, biome); var xform = Transform(uid); diff --git a/Content.Server/Players/JobWhitelist/JobWhitelistManager.cs b/Content.Server/Players/JobWhitelist/JobWhitelistManager.cs index 89a7597015..6df1f1632e 100644 --- a/Content.Server/Players/JobWhitelist/JobWhitelistManager.cs +++ b/Content.Server/Players/JobWhitelist/JobWhitelistManager.cs @@ -64,7 +64,7 @@ public sealed class JobWhitelistManager : IPostInjectInit if (!_config.GetCVar(CCVars.GameRoleWhitelist)) return true; - if (!_prototypes.TryIndex(job, out var jobPrototype) || + if (!_prototypes.Resolve(job, out var jobPrototype) || !jobPrototype.Whitelisted) { return true; diff --git a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs index 831c5774da..5beddae1e8 100644 --- a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs +++ b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs @@ -241,12 +241,13 @@ public sealed class PlayTimeTrackingSystem : EntitySystem playTimes ??= new Dictionary(); } - var isWhitelisted = player.ContentData()?.Whitelisted ?? false; // DeltaV - Whitelist requirement + var isWhitelisted = player.ContentData()?.Whitelisted ?? false; // DeltaV - Whitelist Requirement for (var i = 0; i < jobs.Count; i++) { - if (_prototypes.TryIndex(jobs[i], out var job) - && JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes, (HumanoidCharacterProfile?) _preferencesManager.GetPreferences(userId).SelectedCharacter, isWhitelisted)) + if (_prototypes.Resolve(jobs[i], out var job) + && JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes, (HumanoidCharacterProfile?) _preferencesManager.GetPreferences(userId).SelectedCharacter, + isWhitelisted)) // DeltaV - Whitelist Requirement { continue; } diff --git a/Content.Server/Polymorph/Systems/PolymorphSystem.cs b/Content.Server/Polymorph/Systems/PolymorphSystem.cs index 219f609628..4a4dc1bebf 100644 --- a/Content.Server/Polymorph/Systems/PolymorphSystem.cs +++ b/Content.Server/Polymorph/Systems/PolymorphSystem.cs @@ -117,7 +117,7 @@ public sealed partial class PolymorphSystem : EntitySystem private void OnPolymorphActionEvent(Entity ent, ref PolymorphActionEvent args) { - if (!_proto.TryIndex(args.ProtoId, out var prototype) || args.Handled) + if (!_proto.Resolve(args.ProtoId, out var prototype) || args.Handled) return; PolymorphEntity(ent, prototype.Configuration); @@ -406,7 +406,7 @@ public sealed partial class PolymorphSystem : EntitySystem if (target.Comp.PolymorphActions.ContainsKey(id)) return; - if (!_proto.TryIndex(id, out var polyProto)) + if (!_proto.Resolve(id, out var polyProto)) return; var entProto = _proto.Index(polyProto.Configuration.Entity); diff --git a/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs b/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs index db1e1faad6..23caff1e5d 100644 --- a/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs +++ b/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs @@ -25,8 +25,7 @@ public sealed class PolymorphCommand : ToolshedCommand { _system ??= GetSys(); - if (!_proto.TryIndex(protoId, out var prototype)) - return null; + var prototype = _proto.Index(protoId); return _system.PolymorphEntity(input, prototype.Configuration); } diff --git a/Content.Server/Procedural/DungeonJob/DungeonJob.Biome.cs b/Content.Server/Procedural/DungeonJob/DungeonJob.Biome.cs index 48adb8af18..10f11bb854 100644 --- a/Content.Server/Procedural/DungeonJob/DungeonJob.Biome.cs +++ b/Content.Server/Procedural/DungeonJob/DungeonJob.Biome.cs @@ -16,7 +16,7 @@ public sealed partial class DungeonJob /// private async Task PostGen(BiomeDunGen dunGen, Dungeon dungeon, HashSet reservedTiles, Random random) { - if (!_prototype.TryIndex(dunGen.BiomeTemplate, out var indexedBiome)) + if (!_prototype.Resolve(dunGen.BiomeTemplate, out var indexedBiome)) return; var biomeSystem = _entManager.System(); diff --git a/Content.Server/Procedural/DungeonJob/DungeonJob.MiddleConnection.cs b/Content.Server/Procedural/DungeonJob/DungeonJob.MiddleConnection.cs index d6e3c09d62..451bb8baee 100644 --- a/Content.Server/Procedural/DungeonJob/DungeonJob.MiddleConnection.cs +++ b/Content.Server/Procedural/DungeonJob/DungeonJob.MiddleConnection.cs @@ -57,7 +57,7 @@ public sealed partial class DungeonJob var roomConnections = new Dictionary>(); var tileDef = _tileDefManager[gen.Tile]; - _prototype.TryIndex(gen.Flank, out var flankContents); + _prototype.Resolve(gen.Flank, out var flankContents); var contents = _prototype.Index(gen.Contents); foreach (var (room, border) in roomBorders) diff --git a/Content.Server/Procedural/DungeonJob/DungeonJob.Ore.cs b/Content.Server/Procedural/DungeonJob/DungeonJob.Ore.cs index a524afae2e..a66dcf32c0 100644 --- a/Content.Server/Procedural/DungeonJob/DungeonJob.Ore.cs +++ b/Content.Server/Procedural/DungeonJob/DungeonJob.Ore.cs @@ -75,7 +75,7 @@ public sealed partial class DungeonJob var remapping = new Dictionary(); // TODO: Move this to engine - if (_prototype.TryIndex(gen.Entity, out var proto) && + if (_prototype.Resolve(gen.Entity, out var proto) && proto.Components.TryGetComponent("EntityRemap", out var comps)) { var remappingComp = (EntityRemapComponent) comps; diff --git a/Content.Server/Radiation/Systems/RadiationProtectionSystem.cs b/Content.Server/Radiation/Systems/RadiationProtectionSystem.cs index 5222c31bfe..a32fa810c9 100644 --- a/Content.Server/Radiation/Systems/RadiationProtectionSystem.cs +++ b/Content.Server/Radiation/Systems/RadiationProtectionSystem.cs @@ -17,7 +17,7 @@ public sealed class RadiationProtectionSystem : EntitySystem private void OnInit(EntityUid uid, RadiationProtectionComponent component, ComponentInit args) { - if (!_prototypeManager.TryIndex(component.RadiationProtectionModifierSetId, out var modifier)) + if (!_prototypeManager.Resolve(component.RadiationProtectionModifierSetId, out var modifier)) return; var buffComp = EnsureComp(uid); // add the damage modifier if it isn't in the dict yet diff --git a/Content.Server/Radio/EntitySystems/RadioSystem.cs b/Content.Server/Radio/EntitySystems/RadioSystem.cs index bdc368fa93..6af52b980f 100644 --- a/Content.Server/Radio/EntitySystems/RadioSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioSystem.cs @@ -84,7 +84,7 @@ public sealed class RadioSystem : EntitySystem name = FormattedMessage.EscapeText(name); SpeechVerbPrototype speech; - if (evt.SpeechVerb != null && _prototype.TryIndex(evt.SpeechVerb, out var evntProto)) + if (evt.SpeechVerb != null && _prototype.Resolve(evt.SpeechVerb, out var evntProto)) speech = evntProto; else speech = _chat.GetSpeechVerb(messageSource, message); diff --git a/Content.Server/Roles/RoleSystem.cs b/Content.Server/Roles/RoleSystem.cs index 346e13bd07..71fb8a9cb5 100644 --- a/Content.Server/Roles/RoleSystem.cs +++ b/Content.Server/Roles/RoleSystem.cs @@ -49,7 +49,7 @@ public sealed class RoleSystem : SharedRoleSystem if (!Player.TryGetSessionById(mind.UserId, out var session)) return; - if (!_proto.TryIndex(mind.RoleType, out var proto)) + if (!_proto.Resolve(mind.RoleType, out var proto)) return; var roleText = Loc.GetString(proto.Name); diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs index 2e6ebe396c..ca704d8e50 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs @@ -89,7 +89,7 @@ public sealed partial class ShuttleSystem var dungeonProtoId = _random.Pick(group.Protos); - if (!_protoManager.TryIndex(dungeonProtoId, out var dungeonProto)) + if (!_protoManager.Resolve(dungeonProtoId, out var dungeonProto)) { return false; } @@ -192,7 +192,7 @@ public sealed partial class ShuttleSystem throw new NotImplementedException(); } - if (_protoManager.TryIndex(group.NameDataset, out var dataset)) + if (_protoManager.Resolve(group.NameDataset, out var dataset)) { _metadata.SetEntityName(spawned, _salvage.GetFTLName(dataset, _random.Next())); } diff --git a/Content.Server/Silicons/Borgs/BorgSwitchableTypeSystem.cs b/Content.Server/Silicons/Borgs/BorgSwitchableTypeSystem.cs index 518652c229..3208c9c1c7 100644 --- a/Content.Server/Silicons/Borgs/BorgSwitchableTypeSystem.cs +++ b/Content.Server/Silicons/Borgs/BorgSwitchableTypeSystem.cs @@ -65,7 +65,7 @@ public sealed partial class BorgSwitchableTypeSystem : SharedBorgSwitchableTypeS // End DeltaV Code // Configure special components - if (Prototypes.TryIndex(ent.Comp.SelectedBorgType, out var previousPrototype)) + if (Prototypes.Resolve(ent.Comp.SelectedBorgType, out var previousPrototype)) { if (previousPrototype.AddComponents is { } removeComponents) EntityManager.RemoveComponents(ent, removeComponents); diff --git a/Content.Server/Spawners/EntitySystems/ContainerSpawnPointSystem.cs b/Content.Server/Spawners/EntitySystems/ContainerSpawnPointSystem.cs index bf694d229a..61249a0f5a 100644 --- a/Content.Server/Spawners/EntitySystems/ContainerSpawnPointSystem.cs +++ b/Content.Server/Spawners/EntitySystems/ContainerSpawnPointSystem.cs @@ -36,7 +36,7 @@ public sealed class ContainerSpawnPointSystem : EntitySystem // If it's just a spawn pref check if it's for cryo (silly). if (args.HumanoidCharacterProfile?.SpawnPriority != SpawnPriorityPreference.Cryosleep && - (!_proto.TryIndex(args.Job, out var jobProto) || jobProto.JobEntity == null)) + (!_proto.Resolve(args.Job, out var jobProto) || jobProto.JobEntity == null)) { return; } diff --git a/Content.Server/Speech/EmotesMenuSystem.cs b/Content.Server/Speech/EmotesMenuSystem.cs index 6371912bc1..a7132ab34d 100644 --- a/Content.Server/Speech/EmotesMenuSystem.cs +++ b/Content.Server/Speech/EmotesMenuSystem.cs @@ -24,7 +24,7 @@ public sealed partial class EmotesMenuSystem : EntitySystem if (!player.HasValue) return; - if (!_prototypeManager.TryIndex(msg.ProtoId, out var proto) || proto.ChatTriggers.Count == 0) + if (!_prototypeManager.Resolve(msg.ProtoId, out var proto) || proto.ChatTriggers.Count == 0) return; //RMC emote system diff --git a/Content.Server/Spreader/SpreaderSystem.cs b/Content.Server/Spreader/SpreaderSystem.cs index 328f4f0504..2bc067542d 100644 --- a/Content.Server/Spreader/SpreaderSystem.cs +++ b/Content.Server/Spreader/SpreaderSystem.cs @@ -181,7 +181,7 @@ public sealed class SpreaderSystem : EntitySystem occupiedTiles = []; neighbors = []; // TODO remove occupiedTiles -- its currently unused and just slows this method down. - if (!_prototype.TryIndex(prototype, out var spreaderPrototype)) + if (!_prototype.Resolve(prototype, out var spreaderPrototype)) return; if (!TryComp(comp.GridUid, out var grid)) diff --git a/Content.Server/Station/Systems/StationJobsSystem.Roundstart.cs b/Content.Server/Station/Systems/StationJobsSystem.Roundstart.cs index c6c682bcf3..3510aca85e 100644 --- a/Content.Server/Station/Systems/StationJobsSystem.Roundstart.cs +++ b/Content.Server/Station/Systems/StationJobsSystem.Roundstart.cs @@ -362,7 +362,7 @@ public sealed partial class StationJobsSystem if (!(priority == selectedPriority || selectedPriority is null)) continue; - if (!_prototypeManager.TryIndex(jobId, out var job)) + if (!_prototypeManager.Resolve(jobId, out var job)) continue; if (!job.CanBeAntag && (!_player.TryGetSessionById(player, out var session) || antagBlocked.Contains(session))) diff --git a/Content.Server/Station/Systems/StationSpawningSystem.cs b/Content.Server/Station/Systems/StationSpawningSystem.cs index 49556f2ed1..8d86ed51f9 100644 --- a/Content.Server/Station/Systems/StationSpawningSystem.cs +++ b/Content.Server/Station/Systems/StationSpawningSystem.cs @@ -91,11 +91,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem EntityUid? station, EntityUid? entity = null) { - // Delta-V, prevent errors if this is an empty job. - JobPrototype? prototype = null; - if (!string.IsNullOrWhiteSpace(job)) - _prototypeManager.TryIndex(job ?? string.Empty, out prototype); - // Delta-V end + _prototypeManager.Resolve(job, out var prototype); RoleLoadout? loadout = null; // Need to get the loadout up-front to handle names if we use an entity spawn override. @@ -176,7 +172,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem private void DoJobSpecials(ProtoId? job, EntityUid entity) { - if (!_prototypeManager.TryIndex(job ?? string.Empty, out JobPrototype? prototype)) + if (!_prototypeManager.Resolve(job, out JobPrototype? prototype)) return; foreach (var jobSpecial in prototype.Special) @@ -208,8 +204,8 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem if (card.JobTitle == null) // DeltaV _cardSystem.TryChangeJobTitle(cardId, jobPrototype.LocalizedName, card); - // DeltaV - if (card.JobIcon == "JobIconUnknown" && _prototypeManager.TryIndex(jobPrototype.Icon, out var jobIcon)) + + if (card.JobIcon == "JobIconUnknown" && _prototypeManager.Resolve(jobPrototype.Icon, out var jobIcon)) // DeltaV _cardSystem.TryChangeJobIcon(cardId, jobIcon, card); var extendedAccess = false; diff --git a/Content.Server/StationEvents/EventManagerSystem.cs b/Content.Server/StationEvents/EventManagerSystem.cs index e90e111600..26c83a54bc 100644 --- a/Content.Server/StationEvents/EventManagerSystem.cs +++ b/Content.Server/StationEvents/EventManagerSystem.cs @@ -90,7 +90,7 @@ public sealed class EventManagerSystem : EntitySystem return null; } - if (!_prototype.HasIndex(randomLimitedEvent)) + if (!_prototype.Resolve(randomLimitedEvent, out _)) { Log.Warning("A requested event is not available!"); return null; @@ -123,7 +123,7 @@ public sealed class EventManagerSystem : EntitySystem foreach (var eventid in selectedEvents) { - if (!_prototype.TryIndex(eventid, out var eventproto)) + if (!_prototype.Resolve(eventid, out var eventproto)) { Log.Warning("An event ID has no prototype index!"); continue; diff --git a/Content.Server/StationEvents/Events/GreytideVirusRule.cs b/Content.Server/StationEvents/Events/GreytideVirusRule.cs index ef63248c84..501617f381 100644 --- a/Content.Server/StationEvents/Events/GreytideVirusRule.cs +++ b/Content.Server/StationEvents/Events/GreytideVirusRule.cs @@ -54,7 +54,7 @@ public sealed class GreytideVirusRule : StationEventSystem>(); foreach (var group in chosen) { - if (_prototype.TryIndex(group, out var proto)) + if (_prototype.Resolve(group, out var proto)) accessIds.UnionWith(proto.Tags); } diff --git a/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraRouterSystem.cs b/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraRouterSystem.cs index 32e42a52dd..d4af86cd71 100644 --- a/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraRouterSystem.cs +++ b/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraRouterSystem.cs @@ -121,7 +121,7 @@ public sealed class SurveillanceCameraRouterSystem : EntitySystem return; } - if (!_prototypeManager.TryIndex(component.AvailableNetworks[args.Network], + if (!_prototypeManager.Resolve(component.AvailableNetworks[args.Network], out var frequency)) { return; diff --git a/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraSystem.cs b/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraSystem.cs index 2a288d9017..7f7dbc6c97 100644 --- a/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraSystem.cs +++ b/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraSystem.cs @@ -190,7 +190,7 @@ public sealed class SurveillanceCameraSystem : EntitySystem return; } - if (!_prototypeManager.TryIndex(component.AvailableNetworks[args.Network], + if (!_prototypeManager.Resolve(component.AvailableNetworks[args.Network], out var frequency)) { return; diff --git a/Content.Server/Telephone/TelephoneSystem.cs b/Content.Server/Telephone/TelephoneSystem.cs index 46f45d1286..0e3090c77e 100644 --- a/Content.Server/Telephone/TelephoneSystem.cs +++ b/Content.Server/Telephone/TelephoneSystem.cs @@ -340,7 +340,7 @@ public sealed class TelephoneSystem : SharedTelephoneSystem name = FormattedMessage.EscapeText(name); SpeechVerbPrototype speech; - if (ev.SpeechVerb != null && _prototype.TryIndex(ev.SpeechVerb, out var evntProto)) + if (ev.SpeechVerb != null && _prototype.Resolve(ev.SpeechVerb, out var evntProto)) speech = evntProto; else speech = _chat.GetSpeechVerb(messageSource, message); diff --git a/Content.Server/Traitor/Uplink/UplinkSystem.cs b/Content.Server/Traitor/Uplink/UplinkSystem.cs index f4a9ca75fd..e4aa7b5ec1 100644 --- a/Content.Server/Traitor/Uplink/UplinkSystem.cs +++ b/Content.Server/Traitor/Uplink/UplinkSystem.cs @@ -88,7 +88,7 @@ public sealed class UplinkSystem : EntitySystem /// private bool ImplantUplink(EntityUid user, FixedPoint2 balance, bool giveDiscounts) { - if (!_proto.TryIndex(FallbackUplinkCatalog, out var catalog)) + if (!_proto.Resolve(FallbackUplinkCatalog, out var catalog)) return false; if (!catalog.Cost.TryGetValue(TelecrystalCurrencyPrototype, out var cost)) diff --git a/Content.Server/Traits/TraitSystem.cs b/Content.Server/Traits/TraitSystem.cs index f38f647259..79c29f62b1 100644 --- a/Content.Server/Traits/TraitSystem.cs +++ b/Content.Server/Traits/TraitSystem.cs @@ -26,7 +26,7 @@ public sealed class TraitSystem : EntitySystem { // Check if player's job allows to apply traits if (args.JobId == null || - !_prototypeManager.TryIndex(args.JobId ?? string.Empty, out var protoJob) || + !_prototypeManager.Resolve(args.JobId, out var protoJob) || !protoJob.ApplyTraits) { return; @@ -36,7 +36,7 @@ public sealed class TraitSystem : EntitySystem { if (!_prototypeManager.TryIndex(traitId, out var traitPrototype)) { - Log.Warning($"No trait found with ID {traitId}!"); + Log.Error($"No trait found with ID {traitId}!"); return; } diff --git a/Content.Server/Trigger/Systems/SpeakOnTriggerSystem.cs b/Content.Server/Trigger/Systems/SpeakOnTriggerSystem.cs index 6da6f707c1..1e08587ce7 100644 --- a/Content.Server/Trigger/Systems/SpeakOnTriggerSystem.cs +++ b/Content.Server/Trigger/Systems/SpeakOnTriggerSystem.cs @@ -34,7 +34,7 @@ public sealed class SpeakOnTriggerSystem : EntitySystem message = Loc.GetString(ent.Comp.Text); else { - if (!_prototypeManager.TryIndex(ent.Comp.Pack, out var messagePack)) + if (!_prototypeManager.Resolve(ent.Comp.Pack, out var messagePack)) return; message = Loc.GetString(_random.Pick(messagePack.Values)); } diff --git a/Content.Server/Wires/WiresSystem.cs b/Content.Server/Wires/WiresSystem.cs index 4f588faea7..1e4573908d 100644 --- a/Content.Server/Wires/WiresSystem.cs +++ b/Content.Server/Wires/WiresSystem.cs @@ -73,7 +73,7 @@ public sealed partial class WiresSystem : SharedWiresSystem // DeltaV - made par List wireActions = new(); var dummyWires = 0; - if (!_protoMan.TryIndex(wires.LayoutId, out WireLayoutPrototype? layoutPrototype)) + if (!_protoMan.Resolve(wires.LayoutId, out WireLayoutPrototype? layoutPrototype)) { return; } diff --git a/Content.Server/Zombies/ZombieSystem.cs b/Content.Server/Zombies/ZombieSystem.cs index d00c5de3a1..c293f12aa7 100644 --- a/Content.Server/Zombies/ZombieSystem.cs +++ b/Content.Server/Zombies/ZombieSystem.cs @@ -183,7 +183,7 @@ namespace Content.Server.Zombies if (args.Handled) return; - _protoManager.TryIndex(component.EmoteSoundsId, out var sounds); + _protoManager.Resolve(component.EmoteSoundsId, out var sounds); args.Handled = _chat.TryPlayEmoteSound(uid, sounds, args.Emote); } diff --git a/Content.Shared/Access/Components/AccessComponent.cs b/Content.Shared/Access/Components/AccessComponent.cs index 00ee87b3b6..dce9d4b76b 100644 --- a/Content.Shared/Access/Components/AccessComponent.cs +++ b/Content.Shared/Access/Components/AccessComponent.cs @@ -51,7 +51,7 @@ public record struct GetAccessTagsEvent(HashSet> T { public void AddGroup(ProtoId group) { - if (!PrototypeManager.TryIndex(group, out var groupPrototype)) + if (!PrototypeManager.Resolve(group, out var groupPrototype)) return; Tags.UnionWith(groupPrototype.Tags); diff --git a/Content.Shared/Access/Components/IdCardComponent.cs b/Content.Shared/Access/Components/IdCardComponent.cs index 9ca82b67b4..93c61ea9f0 100644 --- a/Content.Shared/Access/Components/IdCardComponent.cs +++ b/Content.Shared/Access/Components/IdCardComponent.cs @@ -41,7 +41,7 @@ public sealed partial class IdCardComponent : Component /// [DataField] [AutoNetworkedField] - public ProtoId? JobPrototype; + public ProtoId? JobPrototype; /// /// The proto IDs of the departments associated with the job diff --git a/Content.Shared/Access/Components/IdCardConsoleComponent.cs b/Content.Shared/Access/Components/IdCardConsoleComponent.cs index 6d72e82fd9..d501d8343d 100644 --- a/Content.Shared/Access/Components/IdCardConsoleComponent.cs +++ b/Content.Shared/Access/Components/IdCardConsoleComponent.cs @@ -1,5 +1,6 @@ using Content.Shared.Access.Systems; using Content.Shared.Containers.ItemSlots; +using Content.Shared.Roles; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; @@ -25,9 +26,9 @@ public sealed partial class IdCardConsoleComponent : Component public readonly string FullName; public readonly string JobTitle; public readonly List> AccessList; - public readonly ProtoId JobPrototype; + public readonly ProtoId JobPrototype; - public WriteToTargetIdMessage(string fullName, string jobTitle, List> accessList, ProtoId jobPrototype) + public WriteToTargetIdMessage(string fullName, string jobTitle, List> accessList, ProtoId jobPrototype) { FullName = fullName; JobTitle = jobTitle; @@ -105,7 +106,7 @@ public sealed partial class IdCardConsoleComponent : Component public readonly string? TargetIdJobTitle; public readonly List>? TargetIdAccessList; public readonly List>? AllowedModifyAccessList; - public readonly ProtoId TargetIdJobPrototype; + public readonly ProtoId TargetIdJobPrototype; public IdCardConsoleBoundUserInterfaceState(bool isPrivilegedIdPresent, bool isPrivilegedIdAuthorized, @@ -114,7 +115,7 @@ public sealed partial class IdCardConsoleComponent : Component string? targetIdJobTitle, List>? targetIdAccessList, List>? allowedModifyAccessList, - ProtoId targetIdJobPrototype, + ProtoId targetIdJobPrototype, string privilegedIdName, string targetIdName) { diff --git a/Content.Shared/Access/Systems/SharedAccessSystem.cs b/Content.Shared/Access/Systems/SharedAccessSystem.cs index a4b04c3559..e161d90e91 100644 --- a/Content.Shared/Access/Systems/SharedAccessSystem.cs +++ b/Content.Shared/Access/Systems/SharedAccessSystem.cs @@ -23,7 +23,7 @@ namespace Content.Shared.Access.Systems // Add all tags in groups to the list of tags. foreach (var group in component.Groups) { - if (!_prototypeManager.TryIndex(group, out var proto)) + if (!_prototypeManager.Resolve(group, out var proto)) continue; component.Tags.UnionWith(proto.Tags); @@ -79,7 +79,7 @@ namespace Content.Shared.Access.Systems foreach (var group in newGroups) { - if (!_prototypeManager.TryIndex(group, out var proto)) + if (!_prototypeManager.Resolve(group, out var proto)) continue; access.Tags.UnionWith(proto.Tags); diff --git a/Content.Shared/Atmos/EntitySystems/SharedAtmosPipeLayersSystem.cs b/Content.Shared/Atmos/EntitySystems/SharedAtmosPipeLayersSystem.cs index f6ec1c5799..708f8ecb3f 100644 --- a/Content.Shared/Atmos/EntitySystems/SharedAtmosPipeLayersSystem.cs +++ b/Content.Shared/Atmos/EntitySystems/SharedAtmosPipeLayersSystem.cs @@ -52,7 +52,7 @@ public abstract partial class SharedAtmosPipeLayersSystem : EntitySystem if (ent.Comp.NumberOfPipeLayers <= 1 || ent.Comp.PipeLayersLocked) return; - if (!_protoManager.TryIndex(ent.Comp.Tool, out var toolProto)) + if (!_protoManager.Resolve(ent.Comp.Tool, out var toolProto)) return; var user = args.User; @@ -138,7 +138,7 @@ public abstract partial class SharedAtmosPipeLayersSystem : EntitySystem if (!TryGetHeldTool(args.User, ent.Comp.Tool, out var tool)) { - if (_protoManager.TryIndex(ent.Comp.Tool, out var toolProto)) + if (_protoManager.Resolve(ent.Comp.Tool, out var toolProto)) { var toolName = Loc.GetString(toolProto.ToolName).ToLower(); var message = Loc.GetString("atmos-pipe-layers-component-tool-missing", ("toolName", toolName)); diff --git a/Content.Shared/BarSign/BarSignSystem.cs b/Content.Shared/BarSign/BarSignSystem.cs index bf28cfe6b7..0c9770bfe9 100644 --- a/Content.Shared/BarSign/BarSignSystem.cs +++ b/Content.Shared/BarSign/BarSignSystem.cs @@ -31,7 +31,7 @@ public sealed class BarSignSystem : EntitySystem private void OnSetBarSignMessage(Entity ent, ref SetBarSignMessage args) { - if (!_prototypeManager.TryIndex(args.Sign, out var signPrototype)) + if (!_prototypeManager.Resolve(args.Sign, out var signPrototype)) return; SetBarSign(ent, signPrototype); diff --git a/Content.Shared/Body/Systems/SharedBloodstreamSystem.cs b/Content.Shared/Body/Systems/SharedBloodstreamSystem.cs index 4b3270f1ed..3b46d3913c 100644 --- a/Content.Shared/Body/Systems/SharedBloodstreamSystem.cs +++ b/Content.Shared/Body/Systems/SharedBloodstreamSystem.cs @@ -191,7 +191,7 @@ public abstract class SharedBloodstreamSystem : EntitySystem } // TODO probably cache this or something. humans get hurt a lot - if (!_prototypeManager.TryIndex(ent.Comp.DamageBleedModifiers, out var modifiers)) + if (!_prototypeManager.Resolve(ent.Comp.DamageBleedModifiers, out var modifiers)) return; // some reagents may deal and heal different damage types in the same tick, which means DamageIncreased will be true diff --git a/Content.Shared/Cargo/Prototypes/CargoProductPrototype.cs b/Content.Shared/Cargo/Prototypes/CargoProductPrototype.cs index d98c9bd8f7..46a3a0de13 100644 --- a/Content.Shared/Cargo/Prototypes/CargoProductPrototype.cs +++ b/Content.Shared/Cargo/Prototypes/CargoProductPrototype.cs @@ -36,7 +36,7 @@ namespace Content.Shared.Cargo.Prototypes if (_name.Trim().Length != 0) return _name; - if (IoCManager.Resolve().TryIndex(Product, out EntityPrototype? prototype)) + if (IoCManager.Resolve().Resolve(Product, out EntityPrototype? prototype)) { _name = prototype.Name; } @@ -56,7 +56,7 @@ namespace Content.Shared.Cargo.Prototypes if (_description.Trim().Length != 0) return _description; - if (IoCManager.Resolve().TryIndex(Product, out EntityPrototype? prototype)) + if (IoCManager.Resolve().Resolve(Product, out EntityPrototype? prototype)) { _description = prototype.Description; } diff --git a/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs index f2d99dfd62..4ee4fd4919 100644 --- a/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs @@ -74,7 +74,7 @@ public abstract class SharedChameleonClothingSystem : EntitySystem protected void UpdateVisuals(EntityUid uid, ChameleonClothingComponent component) { if (string.IsNullOrEmpty(component.Default) || - !_proto.TryIndex(component.Default, out EntityPrototype? proto)) + !_proto.Resolve(component.Default, out EntityPrototype? proto)) return; // world sprite icon diff --git a/Content.Shared/Clothing/LoadoutSystem.cs b/Content.Shared/Clothing/LoadoutSystem.cs index 08b4f5f763..dfe6d1377b 100644 --- a/Content.Shared/Clothing/LoadoutSystem.cs +++ b/Content.Shared/Clothing/LoadoutSystem.cs @@ -44,7 +44,7 @@ public sealed class LoadoutSystem : EntitySystem { EntProtoId? proto = null; - if (_protoMan.TryIndex(loadout.StartingGear, out var gear)) + if (_protoMan.Resolve(loadout.StartingGear, out var gear)) { proto = GetFirstOrNull(gear); } @@ -65,12 +65,12 @@ public sealed class LoadoutSystem : EntitySystem if (count == 1) { - if (gear.Equipment.Count == 1 && _protoMan.TryIndex(gear.Equipment.Values.First(), out var proto)) + if (gear.Equipment.Count == 1 && _protoMan.Resolve(gear.Equipment.Values.First(), out var proto)) { return proto.ID; } - if (gear.Inhand.Count == 1 && _protoMan.TryIndex(gear.Inhand[0], out proto)) + if (gear.Inhand.Count == 1 && _protoMan.Resolve(gear.Inhand[0], out proto)) { return proto.ID; } @@ -90,10 +90,10 @@ public sealed class LoadoutSystem : EntitySystem public string GetName(LoadoutPrototype loadout) { - if (loadout.DummyEntity is not null && _protoMan.TryIndex(loadout.DummyEntity, out var proto)) + if (loadout.DummyEntity is not null && _protoMan.Resolve(loadout.DummyEntity, out var proto)) return proto.Name; - if (_protoMan.TryIndex(loadout.StartingGear, out var gear)) + if (_protoMan.Resolve(loadout.StartingGear, out var gear)) { return GetName(gear); } diff --git a/Content.Shared/Construction/MachinePartSystem.cs b/Content.Shared/Construction/MachinePartSystem.cs index f3314dfc11..7ac9fde94c 100644 --- a/Content.Shared/Construction/MachinePartSystem.cs +++ b/Content.Shared/Construction/MachinePartSystem.cs @@ -109,7 +109,7 @@ namespace Content.Shared.Construction materials[mat] += matAmount * amount * coefficient; } } - else if (_prototype.TryIndex(defaultProtoId, out var defaultProto) && + else if (_prototype.Resolve(defaultProtoId, out var defaultProto) && defaultProto.TryGetComponent(out var physComp, EntityManager.ComponentFactory)) { foreach (var (mat, matAmount) in physComp.MaterialComposition) diff --git a/Content.Shared/Containers/ContainerCompSystem.cs b/Content.Shared/Containers/ContainerCompSystem.cs index 75908efea3..d9eac28dab 100644 --- a/Content.Shared/Containers/ContainerCompSystem.cs +++ b/Content.Shared/Containers/ContainerCompSystem.cs @@ -24,7 +24,7 @@ public sealed class ContainerCompSystem : EntitySystem if (args.Container.ID != ent.Comp.Container || _timing.ApplyingState) return; - if (_proto.TryIndex(ent.Comp.Proto, out var entProto)) + if (_proto.Resolve(ent.Comp.Proto, out var entProto)) { EntityManager.RemoveComponents(args.Entity, entProto.Components); } @@ -35,7 +35,7 @@ public sealed class ContainerCompSystem : EntitySystem if (args.Container.ID != ent.Comp.Container || _timing.ApplyingState) return; - if (_proto.TryIndex(ent.Comp.Proto, out var entProto)) + if (_proto.Resolve(ent.Comp.Proto, out var entProto)) { EntityManager.AddComponents(args.Entity, entProto.Components); } diff --git a/Content.Shared/Damage/Systems/DamageableSystem.cs b/Content.Shared/Damage/Systems/DamageableSystem.cs index d0a9bcaf69..3f962d198f 100644 --- a/Content.Shared/Damage/Systems/DamageableSystem.cs +++ b/Content.Shared/Damage/Systems/DamageableSystem.cs @@ -99,7 +99,7 @@ namespace Content.Shared.Damage private void DamageableInit(EntityUid uid, DamageableComponent component, ComponentInit _) { if (component.DamageContainerID != null && - _prototypeManager.TryIndex(component.DamageContainerID, + _prototypeManager.Resolve(component.DamageContainerID, out var damageContainerPrototype)) { // Initialize damage dictionary, using the types and groups from the damage @@ -217,7 +217,7 @@ namespace Content.Shared.Damage if (!ignoreResistances) { if (damageable.DamageModifierSetId != null && - _prototypeManager.TryIndex(damageable.DamageModifierSetId, out var modifierSet)) + _prototypeManager.Resolve(damageable.DamageModifierSetId, out var modifierSet)) { // TODO DAMAGE PERFORMANCE // use a local private field instead of creating a new dictionary here.. diff --git a/Content.Shared/Humanoid/Markings/MarkingManager.cs b/Content.Shared/Humanoid/Markings/MarkingManager.cs index e844dc2280..28637f9303 100644 --- a/Content.Shared/Humanoid/Markings/MarkingManager.cs +++ b/Content.Shared/Humanoid/Markings/MarkingManager.cs @@ -254,9 +254,9 @@ namespace Content.Shared.Humanoid.Markings IoCManager.Resolve(ref prototypeManager); var speciesProto = prototypeManager.Index(species); if ( - !prototypeManager.TryIndex(speciesProto.SpriteSet, out var baseSprites) || + !prototypeManager.Resolve(speciesProto.SpriteSet, out var baseSprites) || !baseSprites.Sprites.TryGetValue(layer, out var spriteName) || - !prototypeManager.TryIndex(spriteName, out HumanoidSpeciesSpriteLayer? sprite) || + !prototypeManager.Resolve(spriteName, out HumanoidSpeciesSpriteLayer? sprite) || sprite == null || !sprite.MarkingsMatchSkin ) diff --git a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs index e05ac17fa2..6047134695 100644 --- a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs +++ b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs @@ -93,7 +93,7 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem } if (string.IsNullOrEmpty(humanoid.Initial) - || !_proto.TryIndex(humanoid.Initial, out HumanoidProfilePrototype? startingSet)) + || !_proto.Resolve(humanoid.Initial, out HumanoidProfilePrototype? startingSet)) { LoadProfile(uid, HumanoidCharacterProfile.DefaultWithSpecies(humanoid.Species), humanoid); return; @@ -297,7 +297,7 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem if (!Resolve(uid, ref humanoid)) return; - if (!_proto.TryIndex(humanoid.Species, out var species)) + if (!_proto.Resolve(humanoid.Species, out var species)) { return; } diff --git a/Content.Shared/Light/EntitySystems/UnpoweredFlashlightSystem.cs b/Content.Shared/Light/EntitySystems/UnpoweredFlashlightSystem.cs index 6dc6cbfe0b..ce3c016080 100644 --- a/Content.Shared/Light/EntitySystems/UnpoweredFlashlightSystem.cs +++ b/Content.Shared/Light/EntitySystems/UnpoweredFlashlightSystem.cs @@ -86,7 +86,7 @@ public sealed class UnpoweredFlashlightSystem : EntitySystem if (!_light.TryGetLight(uid, out var light)) return; - if (_prototypeManager.TryIndex(component.EmaggedColorsPrototype, out var possibleColors)) + if (_prototypeManager.Resolve(component.EmaggedColorsPrototype, out var possibleColors)) { var pick = _random.Pick(possibleColors.Colors.Values); _light.SetColor(uid, pick, light); diff --git a/Content.Shared/Nutrition/EntitySystems/FoodSequenceSystem.cs b/Content.Shared/Nutrition/EntitySystems/FoodSequenceSystem.cs index 0fa85666a0..697845b231 100644 --- a/Content.Shared/Nutrition/EntitySystems/FoodSequenceSystem.cs +++ b/Content.Shared/Nutrition/EntitySystems/FoodSequenceSystem.cs @@ -45,7 +45,7 @@ public sealed class FoodSequenceSystem : SharedFoodSequenceSystem if (!TryComp(args.Start, out var start)) return; - if (!_proto.TryIndex(args.Proto, out var elementProto)) + if (!_proto.Resolve(args.Proto, out var elementProto)) return; if (!ent.Comp.OnlyFinal || elementProto.Final || start.FoodLayers.Count == start.MaxLayers) @@ -117,8 +117,7 @@ public sealed class FoodSequenceSystem : SharedFoodSequenceSystem //looking for a suitable FoodSequence prototype if (!element.Comp1.Entries.TryGetValue(start.Comp.Key, out var elementProto)) return false; - - if (!_proto.TryIndex(elementProto, out var elementIndexed)) + if (!_proto.Resolve(elementProto, out var elementIndexed)) return false; //if we run out of space, we can still put in one last, final finishing element. @@ -185,7 +184,7 @@ public sealed class FoodSequenceSystem : SharedFoodSequenceSystem var nameCounter = 1; foreach (var proto in existedContentNames) { - if (!_proto.TryIndex(proto, out var protoIndexed)) + if (!_proto.Resolve(proto, out var protoIndexed)) continue; if (protoIndexed.Name is null) diff --git a/Content.Shared/Nutrition/EntitySystems/HungerSystem.cs b/Content.Shared/Nutrition/EntitySystems/HungerSystem.cs index bd869c6415..559a6a1019 100644 --- a/Content.Shared/Nutrition/EntitySystems/HungerSystem.cs +++ b/Content.Shared/Nutrition/EntitySystems/HungerSystem.cs @@ -237,13 +237,13 @@ public sealed class HungerSystem : EntitySystem switch (component.CurrentThreshold) { case HungerThreshold.Overfed: - _prototype.TryIndex(HungerIconOverfedId, out prototype); + _prototype.Resolve(HungerIconOverfedId, out prototype); break; case HungerThreshold.Peckish: - _prototype.TryIndex(HungerIconPeckishId, out prototype); + _prototype.Resolve(HungerIconPeckishId, out prototype); break; case HungerThreshold.Starving: - _prototype.TryIndex(HungerIconStarvingId, out prototype); + _prototype.Resolve(HungerIconStarvingId, out prototype); break; default: prototype = null; diff --git a/Content.Shared/Nutrition/EntitySystems/ThirstSystem.cs b/Content.Shared/Nutrition/EntitySystems/ThirstSystem.cs index 808337639a..ff0ce54953 100644 --- a/Content.Shared/Nutrition/EntitySystems/ThirstSystem.cs +++ b/Content.Shared/Nutrition/EntitySystems/ThirstSystem.cs @@ -126,15 +126,15 @@ public sealed class ThirstSystem : EntitySystem switch (component.CurrentThirstThreshold) { case ThirstThreshold.OverHydrated: - _prototype.TryIndex(ThirstIconOverhydratedId, out prototype); + _prototype.Resolve(ThirstIconOverhydratedId, out prototype); break; case ThirstThreshold.Thirsty: - _prototype.TryIndex(ThirstIconThirstyId, out prototype); + _prototype.Resolve(ThirstIconThirstyId, out prototype); break; case ThirstThreshold.Parched: - _prototype.TryIndex(ThirstIconParchedId, out prototype); + _prototype.Resolve(ThirstIconParchedId, out prototype); break; default: diff --git a/Content.Shared/Nutrition/FoodMetamorphRules/FoodMetamorphRule.cs b/Content.Shared/Nutrition/FoodMetamorphRules/FoodMetamorphRule.cs index 9e59573ff8..b5c8ad08c5 100644 --- a/Content.Shared/Nutrition/FoodMetamorphRules/FoodMetamorphRule.cs +++ b/Content.Shared/Nutrition/FoodMetamorphRules/FoodMetamorphRule.cs @@ -53,7 +53,7 @@ public sealed partial class LastElementHasTags : FoodMetamorphRule { var lastIngredient = ingredients[ingredients.Count - 1]; - if (!protoMan.TryIndex(lastIngredient.Proto, out var protoIndexed)) + if (!protoMan.Resolve(lastIngredient.Proto, out var protoIndexed)) return false; foreach (var tag in Tags) @@ -96,7 +96,7 @@ public sealed partial class ElementHasTags : FoodMetamorphRule if (ingredients.Count < ElementNumber + 1) return false; - if (!protoMan.TryIndex(ingredients[ElementNumber].Proto, out var protoIndexed)) + if (!protoMan.Resolve(ingredients[ElementNumber].Proto, out var protoIndexed)) return false; foreach (var tag in Tags) @@ -180,7 +180,7 @@ public sealed partial class IngredientsWithTags : FoodMetamorphRule var count = 0; foreach (var ingredient in ingredients) { - if (!protoMan.TryIndex(ingredient.Proto, out var protoIndexed)) + if (!protoMan.Resolve(ingredient.Proto, out var protoIndexed)) continue; var allowed = false; diff --git a/Content.Shared/Preferences/HumanoidCharacterProfile.cs b/Content.Shared/Preferences/HumanoidCharacterProfile.cs index acf943c149..4dbe7b822e 100644 --- a/Content.Shared/Preferences/HumanoidCharacterProfile.cs +++ b/Content.Shared/Preferences/HumanoidCharacterProfile.cs @@ -443,7 +443,7 @@ namespace Content.Shared.Preferences // Category not found so dump it. TraitCategoryPrototype? traitCategory = null; - if (category != null && !protoManager.TryIndex(category, out traitCategory)) + if (category != null && !protoManager.Resolve(category, out traitCategory)) return new(this); var list = new HashSet>(_traitPreferences) { traitId }; @@ -727,7 +727,7 @@ namespace Content.Shared.Preferences } // No category so dump it. - if (!protoManager.TryIndex(traitProto.Category, out var category)) + if (!protoManager.Resolve(traitProto.Category, out var category)) continue; var existing = groups.GetOrNew(category.ID); diff --git a/Content.Shared/RCD/Systems/RCDSystem.cs b/Content.Shared/RCD/Systems/RCDSystem.cs index cb8450a500..2e638d7c13 100644 --- a/Content.Shared/RCD/Systems/RCDSystem.cs +++ b/Content.Shared/RCD/Systems/RCDSystem.cs @@ -111,7 +111,7 @@ public sealed class RCDSystem : EntitySystem var name = Loc.GetString(prototype.SetName); if (prototype.Prototype != null && - _protoManager.TryIndex(prototype.Prototype, out var proto)) + _protoManager.Resolve(prototype.Prototype, out var proto)) name = proto.Name; msg = Loc.GetString("rcd-component-examine-build-details", ("name", name)); @@ -178,7 +178,7 @@ public sealed class RCDSystem : EntitySystem var deconstructedTile = _mapSystem.GetTileRef(gridUid.Value, mapGrid, location); var protoName = !_turf.IsSpace(deconstructedTile) ? _deconstructTileProto : _deconstructLatticeProto; - if (_protoManager.TryIndex(protoName, out var deconProto)) + if (_protoManager.Resolve(protoName, out var deconProto)) { cost = deconProto.Cost; delay = deconProto.Delay; diff --git a/Content.Shared/Roles/JobRequirement/DepartmentTimeRequirement.cs b/Content.Shared/Roles/JobRequirement/DepartmentTimeRequirement.cs index 86a64d1098..37f5aacdf9 100644 --- a/Content.Shared/Roles/JobRequirement/DepartmentTimeRequirement.cs +++ b/Content.Shared/Roles/JobRequirement/DepartmentTimeRequirement.cs @@ -54,7 +54,7 @@ public sealed partial class DepartmentTimeRequirement : JobRequirement var formattedDeptDiff = ContentLocalizationManager.FormatPlaytime(deptDiffSpan); var nameDepartment = "role-timer-department-unknown"; - if (protoManager.TryIndex(Department, out var departmentIndexed)) + if (protoManager.Resolve(Department, out var departmentIndexed)) { nameDepartment = departmentIndexed.Name; } diff --git a/Content.Shared/Roles/Jobs/SharedJobSystem.cs b/Content.Shared/Roles/Jobs/SharedJobSystem.cs index 6526a3237a..867842308e 100644 --- a/Content.Shared/Roles/Jobs/SharedJobSystem.cs +++ b/Content.Shared/Roles/Jobs/SharedJobSystem.cs @@ -161,7 +161,7 @@ public abstract class SharedJobSystem : EntitySystem prototype = null; MindTryGetJobId(mindId, out var protoId); - return _prototypes.TryIndex(protoId, out prototype) || prototype is not null; + return _prototypes.Resolve(protoId, out prototype) || prototype is not null; } public bool MindTryGetJobId( diff --git a/Content.Shared/Roles/SharedRoleSystem.cs b/Content.Shared/Roles/SharedRoleSystem.cs index d1afae9fd1..ea25555257 100644 --- a/Content.Shared/Roles/SharedRoleSystem.cs +++ b/Content.Shared/Roles/SharedRoleSystem.cs @@ -140,7 +140,7 @@ public abstract class SharedRoleSystem : EntitySystem return; } - if (!_prototypes.TryIndex(protoId, out var protoEnt)) + if (!_prototypes.Resolve(protoId, out var protoEnt)) { Log.Error($"Failed to add role {protoId} to {ToPrettyString(mindId)} : Role prototype does not exist"); return; diff --git a/Content.Shared/Silicons/Borgs/SharedBorgSwitchableTypeSystem.cs b/Content.Shared/Silicons/Borgs/SharedBorgSwitchableTypeSystem.cs index f090af64e7..9c83633f45 100644 --- a/Content.Shared/Silicons/Borgs/SharedBorgSwitchableTypeSystem.cs +++ b/Content.Shared/Silicons/Borgs/SharedBorgSwitchableTypeSystem.cs @@ -100,7 +100,7 @@ public abstract partial class SharedBorgSwitchableTypeSystem : EntitySystem // D protected void UpdateEntityAppearance(Entity entity) { - if (!Prototypes.TryIndex(entity.Comp.SelectedBorgType, out var proto)) + if (!Prototypes.Resolve(entity.Comp.SelectedBorgType, out var proto)) return; UpdateEntityAppearance(entity, proto); diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Customization.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Customization.cs index d3f3fe4297..7a5131c9a1 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Customization.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Customization.cs @@ -15,7 +15,7 @@ public abstract partial class SharedStationAiSystem private void OnStationAiCustomization(Entity entity, ref StationAiCustomizationMessage args) { - if (!_protoManager.TryIndex(args.GroupProtoId, out var groupPrototype) || !_protoManager.TryIndex(args.CustomizationProtoId, out var customizationProto)) + if (!_protoManager.Resolve(args.GroupProtoId, out var groupPrototype) || !_protoManager.Resolve(args.CustomizationProtoId, out var customizationProto)) return; if (!TryGetHeld((entity, entity.Comp), out var held)) @@ -48,7 +48,7 @@ public abstract partial class SharedStationAiSystem if (!entity.Comp.ProtoIds.TryGetValue(_stationAiHologramCustomGroupProtoId, out var protoId)) return; - if (!_protoManager.TryIndex(protoId, out var prototype)) + if (!_protoManager.Resolve(protoId, out var prototype)) return; if (!prototype.LayerData.TryGetValue(StationAiState.Hologram.ToString(), out var layerData)) @@ -70,7 +70,7 @@ public abstract partial class SharedStationAiSystem if (!TryComp(stationAi, out var stationAiCustomization) || !stationAiCustomization.ProtoIds.TryGetValue(_stationAiCoreCustomGroupProtoId, out var protoId) || - !_protoManager.TryIndex(protoId, out var prototype) || + !_protoManager.Resolve(protoId, out var prototype) || !prototype.LayerData.TryGetValue(state.ToString(), out var layerData)) { return; diff --git a/Content.Shared/SprayPainter/SharedSprayPainterSystem.cs b/Content.Shared/SprayPainter/SharedSprayPainterSystem.cs index 0a766df348..a1316e3565 100644 --- a/Content.Shared/SprayPainter/SharedSprayPainterSystem.cs +++ b/Content.Shared/SprayPainter/SharedSprayPainterSystem.cs @@ -181,7 +181,7 @@ public abstract class SharedSprayPainterSystem : EntitySystem if (ent.Comp.Group is not { } group || !painter.StylesByGroup.TryGetValue(group, out var selectedStyle) - || !Proto.TryIndex(group, out PaintableGroupPrototype? targetGroup)) + || !Proto.Resolve(group, out PaintableGroupPrototype? targetGroup)) return; // Valid paint target. diff --git a/Content.Shared/Station/SharedStationSpawningSystem.cs b/Content.Shared/Station/SharedStationSpawningSystem.cs index c6da125d9f..719f9fbf2a 100644 --- a/Content.Shared/Station/SharedStationSpawningSystem.cs +++ b/Content.Shared/Station/SharedStationSpawningSystem.cs @@ -75,7 +75,7 @@ public abstract class SharedStationSpawningSystem : EntitySystem name = loadout.EntityName; } - if (string.IsNullOrEmpty(name) && PrototypeManager.TryIndex(roleProto.NameDataset, out var nameData)) + if (string.IsNullOrEmpty(name) && PrototypeManager.Resolve(roleProto.NameDataset, out var nameData)) { name = Loc.GetString(_random.Pick(nameData.Values)); } @@ -97,7 +97,7 @@ public abstract class SharedStationSpawningSystem : EntitySystem /// public void EquipStartingGear(EntityUid entity, ProtoId? startingGear, bool raiseEvent = true) { - PrototypeManager.TryIndex(startingGear, out var gearProto); + PrototypeManager.Resolve(startingGear, out var gearProto); EquipStartingGear(entity, gearProto, raiseEvent); } @@ -206,7 +206,7 @@ public abstract class SharedStationSpawningSystem : EntitySystem { foreach (var items in group.Value) { - if (!PrototypeManager.TryIndex(items.Prototype, out var loadoutPrototype)) + if (!PrototypeManager.Resolve(items.Prototype, out var loadoutPrototype)) return null; var gear = ((IEquipmentLoadout) loadoutPrototype).GetGear(slot); diff --git a/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs b/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs index 081a14c837..b6374052fa 100644 --- a/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs +++ b/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs @@ -122,7 +122,7 @@ public sealed partial class StatusEffectsSystem : EntitySystem public bool CanAddStatusEffect(EntityUid uid, EntProtoId effectProto) { - if (!_proto.TryIndex(effectProto, out var effectProtoData)) + if (!_proto.Resolve(effectProto, out var effectProtoData)) return false; if (!effectProtoData.TryGetComponent(out var effectProtoComp, Factory)) diff --git a/Content.Shared/Storage/EntitySystems/DumpableSystem.cs b/Content.Shared/Storage/EntitySystems/DumpableSystem.cs index a408c1ecce..83987c1498 100644 --- a/Content.Shared/Storage/EntitySystems/DumpableSystem.cs +++ b/Content.Shared/Storage/EntitySystems/DumpableSystem.cs @@ -125,7 +125,7 @@ public sealed class DumpableSystem : EntitySystem foreach (var entity in storage.Container.ContainedEntities) { if (!_itemQuery.TryGetComponent(entity, out var itemComp) || - !_prototypeManager.TryIndex(itemComp.Size, out var itemSize)) + !_prototypeManager.Resolve(itemComp.Size, out var itemSize)) { continue; } diff --git a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs index 6f6b22ccec..5b47b157f4 100644 --- a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs @@ -580,7 +580,7 @@ public abstract class SharedStorageSystem : EntitySystem { if (entity == args.User || !_itemQuery.TryGetComponent(entity, out var itemComp) // Need comp to get item size to get weight - || !_prototype.TryIndex(itemComp.Size, out var itemSize) + || !_prototype.Resolve(itemComp.Size, out var itemSize) || !CanInsert(uid, entity, out _, storageComp, item: itemComp) || !_interactionSystem.InRangeUnobstructed(args.User, entity)) { @@ -1826,7 +1826,7 @@ public abstract class SharedStorageSystem : EntitySystem // If we specify a max item size, use that if (uid.Comp.MaxItemSize != null) { - if (_prototype.TryIndex(uid.Comp.MaxItemSize.Value, out var proto)) + if (_prototype.Resolve(uid.Comp.MaxItemSize.Value, out var proto)) return proto; Log.Error($"{ToPrettyString(uid.Owner)} tried to get invalid item size prototype: {uid.Comp.MaxItemSize.Value}. Stack trace:\\n{Environment.StackTrace}"); diff --git a/Content.Shared/StoryGen/EntitySystems/StoryGeneratorSystem.cs b/Content.Shared/StoryGen/EntitySystems/StoryGeneratorSystem.cs index 51ad85730c..07699fa372 100644 --- a/Content.Shared/StoryGen/EntitySystems/StoryGeneratorSystem.cs +++ b/Content.Shared/StoryGen/EntitySystems/StoryGeneratorSystem.cs @@ -24,7 +24,7 @@ public sealed partial class StoryGeneratorSystem : EntitySystem public bool TryGenerateStoryFromTemplate(ProtoId template, [NotNullWhen(true)] out string? story, int? seed = null) { // Get the story template prototype from the ID - if (!_protoMan.TryIndex(template, out var templateProto)) + if (!_protoMan.Resolve(template, out var templateProto)) { story = null; return false; @@ -39,7 +39,7 @@ public sealed partial class StoryGeneratorSystem : EntitySystem foreach (var (name, list) in templateProto.Variables) { // Get the prototype for the world list dataset - if (!_protoMan.TryIndex(list, out var listProto)) + if (!_protoMan.Resolve(list, out var listProto)) continue; // Missed one, but keep going with the rest of the story // Pick a random word from the dataset and localize it