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 f3a37f054e..801140f517 100644 --- a/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs +++ b/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs @@ -4,6 +4,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; @@ -74,7 +75,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 48ae1b0ced..202653f700 100644 --- a/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs +++ b/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs @@ -123,7 +123,7 @@ namespace Content.Client.Access.UI 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 c4b0c8f282..e1197d4ac4 100644 --- a/Content.Client/Chat/TypingIndicator/TypingIndicatorVisualizerSystem.cs +++ b/Content.Client/Chat/TypingIndicator/TypingIndicatorVisualizerSystem.cs @@ -27,7 +27,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 a0dc241c29..f6688a63af 100644 --- a/Content.Client/Lathe/UI/LatheMenu.xaml.cs +++ b/Content.Client/Lathe/UI/LatheMenu.xaml.cs @@ -97,7 +97,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 @@ -183,7 +183,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); @@ -1291,7 +1291,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) { @@ -1384,7 +1384,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, out var state)) { // Since there is no MobState for a rotting mob, we have to deal with this case first. - if (HasComp(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 c001b7ec70..3c9d5d1e55 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 61b8d54448..c232ccf415 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 a7a50a5270..22db3ca31f 100644 --- a/Content.IntegrationTests/Tests/PostMapInitTest.cs +++ b/Content.IntegrationTests/Tests/PostMapInitTest.cs @@ -256,8 +256,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(() => { @@ -266,7 +265,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 0df760baef..1706908e72 100644 --- a/Content.Server/Access/Systems/AgentIDCardSystem.cs +++ b/Content.Server/Access/Systems/AgentIDCardSystem.cs @@ -45,7 +45,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 ?? ""; @@ -130,7 +130,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 62dfddbb58..13f2430b3d 100644 --- a/Content.Server/Access/Systems/IdCardConsoleSystem.cs +++ b/Content.Server/Access/Systems/IdCardConsoleSystem.cs @@ -98,7 +98,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem 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)) @@ -130,7 +130,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem string newFullName, string newJobTitle, List> newAccessList, - ProtoId newJobProto, + ProtoId newJobProto, EntityUid player, IdCardConsoleComponent? component = null) { @@ -144,7 +144,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem _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 426e523243..6d9f61d941 100644 --- a/Content.Server/Access/Systems/PresetIdCardSystem.cs +++ b/Content.Server/Access/Systems/PresetIdCardSystem.cs @@ -82,7 +82,7 @@ public sealed class PresetIdCardSystem : EntitySystem _cardSystem.TryChangeJobTitle(uid, job.LocalizedName); _cardSystem.TryChangeJobDepartment(uid, job); - if (_prototypeManager.TryIndex(job.Icon, out var jobIcon)) + if (_prototypeManager.Resolve(job.Icon, out var jobIcon)) _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 bed2499298..d6039fac01 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) @@ -210,7 +210,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); _stun.TryUpdateParalyzeDuration(ent, TimeSpan.FromSeconds(ent.Comp.StunDuration)); 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 febe093d98..0b5f015593 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 2dc001a9c9..b073cc0e69 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -433,7 +433,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/Delivery/DeliverySystem.cs b/Content.Server/Delivery/DeliverySystem.cs index 5fc9b53316..72d9427dff 100644 --- a/Content.Server/Delivery/DeliverySystem.cs +++ b/Content.Server/Delivery/DeliverySystem.cs @@ -102,7 +102,7 @@ public sealed partial class DeliverySystem : SharedDeliverySystem if (ent.Comp.WasPenalized) return; - if (!_protoMan.TryIndex(ent.Comp.PenaltyBankAccount, out var accountInfo)) + if (!_protoMan.Resolve(ent.Comp.PenaltyBankAccount, out var accountInfo)) return; var multiplier = GetDeliveryMultiplier(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 f423a43261..4e447c7fab 100644 --- a/Content.Server/EntityEffects/EntityEffectSystem.cs +++ b/Content.Server/EntityEffects/EntityEffectSystem.cs @@ -949,9 +949,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 f5c8c4d0d8..c2d2614a0a 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -725,7 +725,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 02abb07791..97602ad2ba 100644 --- a/Content.Server/Lathe/LatheSystem.cs +++ b/Content.Server/Lathe/LatheSystem.cs @@ -137,7 +137,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 c0b9beaa9a..27e25a4b4f 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 04289a4098..72f18e00cb 100644 --- a/Content.Server/Players/JobWhitelist/JobWhitelistManager.cs +++ b/Content.Server/Players/JobWhitelist/JobWhitelistManager.cs @@ -63,7 +63,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 e75801d6de..d55920f83c 100644 --- a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs +++ b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs @@ -238,7 +238,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem for (var i = 0; i < jobs.Count; i++) { - if (_prototypes.TryIndex(jobs[i], out var job) + if (_prototypes.Resolve(jobs[i], out var job) && JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes, (HumanoidCharacterProfile?) _preferencesManager.GetPreferences(userId).SelectedCharacter)) { continue; diff --git a/Content.Server/Polymorph/Systems/PolymorphSystem.cs b/Content.Server/Polymorph/Systems/PolymorphSystem.cs index b9453d2924..9547bc1ea5 100644 --- a/Content.Server/Polymorph/Systems/PolymorphSystem.cs +++ b/Content.Server/Polymorph/Systems/PolymorphSystem.cs @@ -112,7 +112,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); @@ -389,7 +389,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 78ab2b7a0d..9253191272 100644 --- a/Content.Server/Procedural/DungeonJob/DungeonJob.Ore.cs +++ b/Content.Server/Procedural/DungeonJob/DungeonJob.Ore.cs @@ -72,7 +72,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 d1a32a6a5b..e90acf1b80 100644 --- a/Content.Server/Silicons/Borgs/BorgSwitchableTypeSystem.cs +++ b/Content.Server/Silicons/Borgs/BorgSwitchableTypeSystem.cs @@ -60,7 +60,7 @@ public sealed class BorgSwitchableTypeSystem : SharedBorgSwitchableTypeSystem } // 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 db82dc70a2..1a592b9929 100644 --- a/Content.Server/Spawners/EntitySystems/ContainerSpawnPointSystem.cs +++ b/Content.Server/Spawners/EntitySystems/ContainerSpawnPointSystem.cs @@ -32,7 +32,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 a69b5a65e4..5f91742eb1 100644 --- a/Content.Server/Speech/EmotesMenuSystem.cs +++ b/Content.Server/Speech/EmotesMenuSystem.cs @@ -22,7 +22,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; _chat.TryEmoteWithChat(player.Value, msg.ProtoId); 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 46d2e308d0..3967e320a8 100644 --- a/Content.Server/Station/Systems/StationSpawningSystem.cs +++ b/Content.Server/Station/Systems/StationSpawningSystem.cs @@ -88,7 +88,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem EntityUid? station, EntityUid? entity = null) { - _prototypeManager.TryIndex(job ?? string.Empty, out var prototype); + _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. @@ -168,7 +168,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) @@ -199,7 +199,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem _cardSystem.TryChangeFullName(cardId, characterName, card); _cardSystem.TryChangeJobTitle(cardId, jobPrototype.LocalizedName, card); - if (_prototypeManager.TryIndex(jobPrototype.Icon, out var jobIcon)) + if (_prototypeManager.Resolve(jobPrototype.Icon, out var jobIcon)) _cardSystem.TryChangeJobIcon(cardId, jobIcon, card); var extendedAccess = false; diff --git a/Content.Server/StationEvents/EventManagerSystem.cs b/Content.Server/StationEvents/EventManagerSystem.cs index 6585fe3248..b86d30e2e7 100644 --- a/Content.Server/StationEvents/EventManagerSystem.cs +++ b/Content.Server/StationEvents/EventManagerSystem.cs @@ -71,7 +71,7 @@ public sealed class EventManagerSystem : EntitySystem return; } - if (!_prototype.TryIndex(randomLimitedEvent, out _)) + if (!_prototype.Resolve(randomLimitedEvent, out _)) { Log.Warning("A requested event is not available!"); return; @@ -104,7 +104,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 8d33b858de..dba21911dc 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 59cb9537f2..d6035f887b 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 fef52a5b5d..c9fd429c47 100644 --- a/Content.Server/Wires/WiresSystem.cs +++ b/Content.Server/Wires/WiresSystem.cs @@ -73,7 +73,7 @@ public sealed class WiresSystem : SharedWiresSystem 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 f4ff5dd60c..5107a87c2a 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 8d54024f72..8c965971a8 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; @@ -85,7 +86,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, @@ -94,7 +95,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 4b38d926f6..18b79bf52b 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/ComponentTable/SharedComponentTableSystem.cs b/Content.Shared/ComponentTable/SharedComponentTableSystem.cs index cdb1b2dc74..e4ff855352 100644 --- a/Content.Shared/ComponentTable/SharedComponentTableSystem.cs +++ b/Content.Shared/ComponentTable/SharedComponentTableSystem.cs @@ -24,7 +24,7 @@ public sealed class SharedComponentTableSystem : EntitySystem foreach (var entity in spawns) { - if (_proto.TryIndex(entity, out var entProto)) + if (_proto.Resolve(entity, out var entProto)) { EntityManager.AddComponents(ent, entProto.Components); } 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 70fbc46806..f3a4f37830 100644 --- a/Content.Shared/Damage/Systems/DamageableSystem.cs +++ b/Content.Shared/Damage/Systems/DamageableSystem.cs @@ -92,7 +92,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 @@ -195,7 +195,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 1df46e53d6..7a22c0c29e 100644 --- a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs +++ b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs @@ -91,7 +91,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; @@ -292,7 +292,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 f22669ddc7..e3447fdf3a 100644 --- a/Content.Shared/Preferences/HumanoidCharacterProfile.cs +++ b/Content.Shared/Preferences/HumanoidCharacterProfile.cs @@ -399,7 +399,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 }; @@ -662,7 +662,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 8c86299210..4034b8b419 100644 --- a/Content.Shared/Roles/JobRequirement/DepartmentTimeRequirement.cs +++ b/Content.Shared/Roles/JobRequirement/DepartmentTimeRequirement.cs @@ -53,7 +53,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 914470e3c9..12a7928c0b 100644 --- a/Content.Shared/Silicons/Borgs/SharedBorgSwitchableTypeSystem.cs +++ b/Content.Shared/Silicons/Borgs/SharedBorgSwitchableTypeSystem.cs @@ -100,7 +100,7 @@ public abstract class SharedBorgSwitchableTypeSystem : EntitySystem 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 ac65bd5584..4ed0da5b9e 100644 --- a/Content.Shared/Station/SharedStationSpawningSystem.cs +++ b/Content.Shared/Station/SharedStationSpawningSystem.cs @@ -73,7 +73,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)); } @@ -95,7 +95,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); } @@ -198,7 +198,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 750868481e..446b3fd3b1 100644 --- a/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs +++ b/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs @@ -123,7 +123,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 6c0cc2d656..0d744a4fe9 100644 --- a/Content.Shared/Storage/EntitySystems/DumpableSystem.cs +++ b/Content.Shared/Storage/EntitySystems/DumpableSystem.cs @@ -108,7 +108,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 74c47bbb25..e4f0aa8b23 100644 --- a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs @@ -579,7 +579,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)) { @@ -1822,7 +1822,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