Fix usages of TryIndex() (#39124)

* Fix usages of TryIndex()

Most usages of TryIndex() were using it incorrectly. Checking whether prototype IDs specified in prototypes actually existed before using them. This is not appropriate as it's just hiding bugs that should be getting caught by the YAML linter and other tools. (#39115)

This then resulted in TryIndex() getting modified to log errors (94f98073b0), which is incorrect as it causes false-positive errors in proper uses of the API: external data validation. (#39098)

This commit goes through and checks every call site of TryIndex() to see whether they were correct. Most call sites were replaced with the new Resolve(), which is suitable for these "defensive programming" use cases.

Fixes #39115

Breaking change: while doing this I noticed IdCardComponent and related systems were erroneously using ProtoId<AccessLevelPrototype> for job prototypes. This has been corrected.

* fix tests

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
Pieter-Jan Briers
2025-09-09 18:17:56 +02:00
committed by GitHub
parent fca45851cc
commit 0c97520276
136 changed files with 229 additions and 228 deletions

View File

@@ -29,7 +29,7 @@ namespace Content.Client.Access.UI
foreach (var access in accessLevels) foreach (var access in accessLevels)
{ {
if (!protoManager.TryIndex(access, out var accessLevel)) if (!protoManager.Resolve(access, out var accessLevel))
{ {
continue; continue;
} }

View File

@@ -57,7 +57,7 @@ public sealed partial class GroupedAccessLevelChecklist : BoxContainer
foreach (var accessGroup in _accessGroups) foreach (var accessGroup in _accessGroups)
{ {
if (!_protoManager.TryIndex(accessGroup, out var accessGroupProto)) if (!_protoManager.Resolve(accessGroup, out var accessGroupProto))
continue; continue;
_groupedAccessLevels.Add(accessGroupProto, new()); _groupedAccessLevels.Add(accessGroupProto, new());
@@ -65,13 +65,13 @@ public sealed partial class GroupedAccessLevelChecklist : BoxContainer
// Ensure that the 'general' access group is added to handle // Ensure that the 'general' access group is added to handle
// misc. access levels that aren't associated with any group // 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()); _groupedAccessLevels.TryAdd(generalAccessProto, new());
// Assign known access levels with their associated groups // Assign known access levels with their associated groups
foreach (var accessLevel in _accessLevels) foreach (var accessLevel in _accessLevels)
{ {
if (!_protoManager.TryIndex(accessLevel, out var accessLevelProto)) if (!_protoManager.Resolve(accessLevel, out var accessLevelProto))
continue; continue;
var assigned = false; var assigned = false;

View File

@@ -4,6 +4,7 @@ using Content.Shared.Access.Systems;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Containers.ItemSlots; using Content.Shared.Containers.ItemSlots;
using Content.Shared.CrewManifest; using Content.Shared.CrewManifest;
using Content.Shared.Roles;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using static Content.Shared.Access.Components.IdCardConsoleComponent; using static Content.Shared.Access.Components.IdCardConsoleComponent;
@@ -74,7 +75,7 @@ namespace Content.Client.Access.UI
_window?.UpdateState(castState); _window?.UpdateState(castState);
} }
public void SubmitData(string newFullName, string newJobTitle, List<ProtoId<AccessLevelPrototype>> newAccessList, string newJobPrototype) public void SubmitData(string newFullName, string newJobTitle, List<ProtoId<AccessLevelPrototype>> newAccessList, ProtoId<JobPrototype> newJobPrototype)
{ {
if (newFullName.Length > _maxNameLength) if (newFullName.Length > _maxNameLength)
newFullName = newFullName[.._maxNameLength]; newFullName = newFullName[.._maxNameLength];

View File

@@ -123,7 +123,7 @@ namespace Content.Client.Access.UI
foreach (var group in job.AccessGroups) foreach (var group in job.AccessGroups)
{ {
if (!_prototypeManager.TryIndex(group, out AccessGroupPrototype? groupPrototype)) if (!_prototypeManager.Resolve(group, out AccessGroupPrototype? groupPrototype))
{ {
continue; continue;
} }

View File

@@ -316,8 +316,9 @@ public sealed partial class BanPanel : DefaultWindow
}; };
// This is adding the icon before the role name // 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. // TODO: This should not be using raw strings for prototypes as it means it won't be validated at all.
if (_protoMan.TryIndex<JobPrototype>(role, out var jobPrototype) && _protoMan.TryIndex(jobPrototype.Icon, out var iconProto)) // I know the ban manager is doing the same thing, but that should not leak into UI code.
if (_protoMan.TryIndex<JobPrototype>(role, out var jobPrototype) && _protoMan.Resolve(jobPrototype.Icon, out var iconProto))
{ {
var jobIconTexture = new TextureRect var jobIconTexture = new TextureRect
{ {

View File

@@ -134,7 +134,7 @@ public sealed class AlignAtmosPipeLayers : SnapgridCenter
var newProtoId = altPrototypes[(int)layer]; var newProtoId = altPrototypes[(int)layer];
if (!_protoManager.TryIndex(newProtoId, out var newProto)) if (!_protoManager.Resolve(newProtoId, out var newProto))
return; return;
if (newProto.Type != ConstructionType.Structure) if (newProto.Type != ConstructionType.Structure)

View File

@@ -58,7 +58,7 @@ public sealed class JukeboxBoundUserInterface : BoundUserInterface
_menu.SetAudioStream(jukebox.AudioStream); _menu.SetAudioStream(jukebox.AudioStream);
if (_protoManager.TryIndex(jukebox.SelectedSongId, out var songProto)) if (_protoManager.Resolve(jukebox.SelectedSongId, out var songProto))
{ {
var length = EntMan.System<AudioSystem>().GetAudioLength(songProto.Path.Path.ToString()); var length = EntMan.System<AudioSystem>().GetAudioLength(songProto.Path.Path.ToString());
_menu.SetSelectedSong(songProto.Name, (float) length.TotalSeconds); _menu.SetSelectedSong(songProto.Name, (float) length.TotalSeconds);

View File

@@ -39,7 +39,7 @@ public sealed class BarSignSystem : VisualizerSystem<BarSignComponent>
if (powered if (powered
&& sign.Current != null && sign.Current != null
&& _prototypeManager.TryIndex(sign.Current, out var proto)) && _prototypeManager.Resolve(sign.Current, out var proto))
{ {
SpriteSystem.LayerSetSprite((id, sprite), 0, proto.Icon); SpriteSystem.LayerSetSprite((id, sprite), 0, proto.Icon);
sprite.LayerSetShader(0, "unshaded"); sprite.LayerSetShader(0, "unshaded");

View File

@@ -35,7 +35,7 @@ public sealed class BarSignBoundUserInterface(EntityUid owner, Enum uiKey) : Bou
public void Update(ProtoId<BarSignPrototype>? sign) public void Update(ProtoId<BarSignPrototype>? sign)
{ {
if (_prototype.TryIndex(sign, out var signPrototype)) if (_prototype.Resolve(sign, out var signPrototype))
_menu?.UpdateState(signPrototype); _menu?.UpdateState(signPrototype);
} }

View File

@@ -29,7 +29,7 @@ public sealed partial class BountyEntry : BoxContainer
UntilNextSkip = untilNextSkip; UntilNextSkip = untilNextSkip;
if (!_prototype.TryIndex<CargoBountyPrototype>(bounty.Bounty, out var bountyPrototype)) if (!_prototype.Resolve<CargoBountyPrototype>(bounty.Bounty, out var bountyPrototype))
return; return;
var items = new List<string>(); var items = new List<string>();

View File

@@ -19,7 +19,7 @@ public sealed partial class BountyHistoryEntry : BoxContainer
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);
if (!_prototype.TryIndex(bounty.Bounty, out var bountyPrototype)) if (!_prototype.Resolve(bounty.Bounty, out var bountyPrototype))
return; return;
var items = new List<string>(); var items = new List<string>();

View File

@@ -27,7 +27,7 @@ public sealed class TypingIndicatorVisualizerSystem : VisualizerSystem<TypingInd
if (overrideIndicator != null) if (overrideIndicator != null)
currentTypingIndicator = overrideIndicator.Value; currentTypingIndicator = overrideIndicator.Value;
if (!_prototypeManager.TryIndex(currentTypingIndicator, out var proto)) if (!_prototypeManager.Resolve(currentTypingIndicator, out var proto))
{ {
Log.Error($"Unknown typing indicator id: {component.TypingIndicatorPrototype}"); Log.Error($"Unknown typing indicator id: {component.TypingIndicatorPrototype}");
return; return;

View File

@@ -45,7 +45,7 @@ public sealed class ChameleonBoundUserInterface : BoundUserInterface
var newTargets = new List<EntProtoId>(); var newTargets = new List<EntProtoId>();
foreach (var target in targets) 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; continue;
if (!proto.TryGetComponent(out TagComponent? tag, EntMan.ComponentFactory) || !_tag.HasTag(tag, st.RequiredTag)) if (!proto.TryGetComponent(out TagComponent? tag, EntMan.ComponentFactory) || !_tag.HasTag(tag, st.RequiredTag))

View File

@@ -54,7 +54,7 @@ public sealed partial class ChameleonMenu : DefaultWindow
foreach (var id in _possibleIds) foreach (var id in _possibleIds)
{ {
if (!_prototypeManager.TryIndex(id, out EntityPrototype? proto)) if (!_prototypeManager.Resolve(id, out EntityPrototype? proto))
continue; continue;
var lowId = id.Id.ToLowerInvariant(); var lowId = id.Id.ToLowerInvariant();

View File

@@ -80,7 +80,7 @@ namespace Content.Client.Construction
{ {
foreach (var constructionProto in PrototypeManager.EnumeratePrototypes<ConstructionPrototype>()) foreach (var constructionProto in PrototypeManager.EnumeratePrototypes<ConstructionPrototype>())
{ {
if (!PrototypeManager.TryIndex(constructionProto.Graph, out var graphProto)) if (!PrototypeManager.Resolve(constructionProto.Graph, out var graphProto))
continue; continue;
if (constructionProto.TargetNode is not { } targetNodeId) 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. // If we got the id of the prototype, we exit the “recursion” by clearing the stack.
stack.Clear(); stack.Clear();
if (!PrototypeManager.TryIndex(constructionProto.ID, out ConstructionPrototype? recipe)) if (!PrototypeManager.Resolve(entityId, out var proto))
continue; continue;
if (!PrototypeManager.TryIndex(entityId, out var proto)) var name = constructionProto.SetName.HasValue ? Loc.GetString(constructionProto.SetName) : proto.Name;
continue; var desc = constructionProto.SetDescription.HasValue ? Loc.GetString(constructionProto.SetDescription) : proto.Description;
var name = recipe.SetName.HasValue ? Loc.GetString(recipe.SetName) : proto.Name; constructionProto.Name = name;
var desc = recipe.SetDescription.HasValue ? Loc.GetString(recipe.SetDescription) : proto.Description; constructionProto.Description = desc;
recipe.Name = name;
recipe.Description = desc;
_recipesMetadataCache.Add(constructionProto.ID, entityId); _recipesMetadataCache.Add(constructionProto.ID, entityId);
} while (stack.Count > 0); } while (stack.Count > 0);
@@ -172,7 +169,7 @@ namespace Content.Client.Construction
"construction-ghost-examine-message", "construction-ghost-examine-message",
("name", component.Prototype.Name))); ("name", component.Prototype.Name)));
if (!PrototypeManager.TryIndex(component.Prototype.Graph, out var graph)) if (!PrototypeManager.Resolve(component.Prototype.Graph, out var graph))
return; return;
var startNode = graph.Nodes[component.Prototype.StartNode]; var startNode = graph.Nodes[component.Prototype.StartNode];

View File

@@ -510,7 +510,7 @@ namespace Content.Client.Construction.UI
foreach (var id in favorites) foreach (var id in favorites)
{ {
if (_prototypeManager.TryIndex(id, out ConstructionPrototype? recipe, logError: false)) if (_prototypeManager.TryIndex(id, out ConstructionPrototype? recipe))
_favoritedRecipes.Add(recipe); _favoritedRecipes.Add(recipe);
} }

View File

@@ -150,7 +150,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
// If the damage container on our entity's DamageableComponent // If the damage container on our entity's DamageableComponent
// is not null, we can try to check through its groups. // is not null, we can try to check through its groups.
if (damageComponent.DamageContainerID != null if (damageComponent.DamageContainerID != null
&& _prototypeManager.TryIndex<DamageContainerPrototype>(damageComponent.DamageContainerID, out var damageContainer)) && _prototypeManager.Resolve<DamageContainerPrototype>(damageComponent.DamageContainerID, out var damageContainer))
{ {
// Are we using damage overlay sprites by group? // Are we using damage overlay sprites by group?
// Check if the container matches the supported groups, // Check if the container matches the supported groups,

View File

@@ -142,7 +142,7 @@ public sealed class DoorSystem : SharedDoorSystem
private void UpdateSpriteLayers(Entity<SpriteComponent> sprite, string targetProto) private void UpdateSpriteLayers(Entity<SpriteComponent> sprite, string targetProto)
{ {
if (!_prototypeManager.TryIndex(targetProto, out var target)) if (!_prototypeManager.Resolve(targetProto, out var target))
return; return;
if (!target.TryGetComponent(out SpriteComponent? targetSprite, _componentFactory)) if (!target.TryGetComponent(out SpriteComponent? targetSprite, _componentFactory))

View File

@@ -65,7 +65,7 @@ public sealed partial class GhostRoleRadioMenu : RadialMenu
}; };
// pick the icon if it exists, otherwise fallback to the ghost role's entity // 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); entProtoView.SetPrototype(iconProto);
else else
entProtoView.SetPrototype(ghostRoleProto.EntityPrototype); entProtoView.SetPrototype(ghostRoleProto.EntityPrototype);

View File

@@ -53,7 +53,7 @@ public sealed partial class DocumentParsingManager
public bool TryAddMarkup(Control control, ProtoId<GuideEntryPrototype> entryId, bool log = true) public bool TryAddMarkup(Control control, ProtoId<GuideEntryPrototype> entryId, bool log = true)
{ {
if (!_prototype.TryIndex(entryId, out var entry)) if (!_prototype.Resolve(entryId, out var entry))
return false; return false;
using var file = _resourceManager.ContentFileReadText(entry.Text); using var file = _resourceManager.ContentFileReadText(entry.Text);

View File

@@ -28,7 +28,7 @@ public sealed class ImplanterSystem : SharedImplanterSystem
Dictionary<string, string> implants = new(); Dictionary<string, string> implants = new();
foreach (var implant in component.DeimplantWhitelist) 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); implants.Add(proto.ID, proto.Name);
} }

View File

@@ -62,7 +62,7 @@ public sealed partial class ChameleonControllerMenu : FancyWindow
// Go through every outfit and add them to the correct department. // Go through every outfit and add them to the correct department.
foreach (var outfit in _outfits) 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."; var name = outfit.LoadoutName ?? outfit.Name ?? jobProto?.Name ?? "Prototype has no name or job.";

View File

@@ -49,7 +49,7 @@ public sealed class ImplanterStatusControl : Control
if (_parent.CurrentMode == ImplanterToggleMode.Draw) if (_parent.CurrentMode == ImplanterToggleMode.Draw)
{ {
string implantName = _parent.DeimplantChosen != null 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"); : Loc.GetString("implanter-empty-text");
_label.SetMarkup(Loc.GetString("implanter-label-draw", _label.SetMarkup(Loc.GetString("implanter-label-draw",

View File

@@ -97,7 +97,7 @@ public sealed partial class LatheMenu : DefaultWindow
var recipesToShow = new List<LatheRecipePrototype>(); var recipesToShow = new List<LatheRecipePrototype>();
foreach (var recipe in Recipes) foreach (var recipe in Recipes)
{ {
if (!_prototypeManager.TryIndex(recipe, out var proto)) if (!_prototypeManager.Resolve(recipe, out var proto))
continue; continue;
// Category filtering // Category filtering
@@ -183,7 +183,7 @@ public sealed partial class LatheMenu : DefaultWindow
foreach (var (id, amount) in prototype.Materials) foreach (var (id, amount) in prototype.Materials)
{ {
if (!_prototypeManager.TryIndex(id, out var proto)) if (!_prototypeManager.Resolve(id, out var proto))
continue; continue;
var adjustedAmount = SharedLatheSystem.AdjustMaterial(amount, prototype.ApplyMaterialDiscount, multiplier); var adjustedAmount = SharedLatheSystem.AdjustMaterial(amount, prototype.ApplyMaterialDiscount, multiplier);

View File

@@ -362,7 +362,7 @@ public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState
{ {
foreach (var loadout in group) foreach (var loadout in group)
{ {
if (!_prototypeManager.TryIndex(loadout.Prototype, out var loadoutProto)) if (!_prototypeManager.Resolve(loadout.Prototype, out var loadoutProto))
continue; continue;
_spawn.EquipStartingGear(uid, loadoutProto); _spawn.EquipStartingGear(uid, loadoutProto);
@@ -385,14 +385,14 @@ public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState
{ {
foreach (var loadout in loadouts) foreach (var loadout in loadouts)
{ {
if (!_prototypeManager.TryIndex(loadout.Prototype, out var loadoutProto)) if (!_prototypeManager.Resolve(loadout.Prototype, out var loadoutProto))
continue; continue;
// TODO: Need some way to apply starting gear to an entity and replace existing stuff coz holy fucking shit dude. // TODO: Need some way to apply starting gear to an entity and replace existing stuff coz holy fucking shit dude.
foreach (var slot in slots) foreach (var slot in slots)
{ {
// Try startinggear first // Try startinggear first
if (_prototypeManager.TryIndex(loadoutProto.StartingGear, out var loadoutGear)) if (_prototypeManager.Resolve(loadoutProto.StartingGear, out var loadoutGear))
{ {
var itemType = ((IEquipmentLoadout) loadoutGear).GetGear(slot.Name); var itemType = ((IEquipmentLoadout) loadoutGear).GetGear(slot.Name);
@@ -427,7 +427,7 @@ public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState
} }
} }
if (!_prototypeManager.TryIndex(job.StartingGear, out var gear)) if (!_prototypeManager.Resolve(job.StartingGear, out var gear))
return; return;
foreach (var slot in slots) foreach (var slot in slots)

View File

@@ -810,7 +810,7 @@ namespace Content.Client.Lobby.UI
if (_prototypeManager.HasIndex<GuideEntryPrototype>(species)) if (_prototypeManager.HasIndex<GuideEntryPrototype>(species))
page = new ProtoId<GuideEntryPrototype>(species.Id); // Gross. See above todo comment. page = new ProtoId<GuideEntryPrototype>(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<ProtoId<GuideEntryPrototype>, GuideEntry>(); var dict = new Dictionary<ProtoId<GuideEntryPrototype>, GuideEntry>();
dict.Add(DefaultSpeciesGuidebook, guideRoot); dict.Add(DefaultSpeciesGuidebook, guideRoot);
@@ -1291,7 +1291,7 @@ namespace Content.Client.Lobby.UI
var sexes = new List<Sex>(); var sexes = new List<Sex>();
// add species sex options, default to just none if we are in bizzaro world and have no species // add species sex options, default to just none if we are in bizzaro world and have no species
if (_prototypeManager.TryIndex<SpeciesPrototype>(Profile.Species, out var speciesProto)) if (_prototypeManager.Resolve<SpeciesPrototype>(Profile.Species, out var speciesProto))
{ {
foreach (var sex in speciesProto.Sexes) foreach (var sex in speciesProto.Sexes)
{ {
@@ -1384,7 +1384,7 @@ namespace Content.Client.Lobby.UI
if (species is null) if (species is null)
return; return;
if (!_prototypeManager.TryIndex<SpeciesPrototype>(species, out var speciesProto)) if (!_prototypeManager.Resolve<SpeciesPrototype>(species, out var speciesProto))
return; return;
// Don't display the info button if no guide entry is found // Don't display the info button if no guide entry is found

View File

@@ -40,7 +40,7 @@ public sealed partial class LoadoutContainer : BoxContainer
SelectButton.TooltipSupplier = _ => tooltip; SelectButton.TooltipSupplier = _ => tooltip;
} }
if (_protoManager.TryIndex(proto, out var loadProto)) if (_protoManager.Resolve(proto, out var loadProto))
{ {
var ent = loadProto.DummyEntity ?? _entManager.System<LoadoutSystem>().GetFirstOrNull(loadProto); var ent = loadProto.DummyEntity ?? _entManager.System<LoadoutSystem>().GetFirstOrNull(loadProto);

View File

@@ -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() RestrictionsContainer.AddChild(new Label()
{ {
@@ -112,14 +112,14 @@ public sealed partial class LoadoutGroupContainer : BoxContainer
}) })
.ToList(); .ToList();
/* /*
* Determine which element should be displayed first: * Determine which element should be displayed first:
* - If any element is currently selected (its button is pressed), use it. * - If any element is currently selected (its button is pressed), use it.
* - Otherwise, fallback to the first element in the list. * - Otherwise, fallback to the first element in the list.
* *
* This moves the selected item outside of the sublist for better usability, * 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) * making it easier for players to quickly toggle loadout options (e.g. clothing, accessories)
* without having to search inside expanded subgroups. * without having to search inside expanded subgroups.
*/ */
var firstElement = uiElements.FirstOrDefault(e => e.Select.Pressed) ?? uiElements[0]; var firstElement = uiElements.FirstOrDefault(e => e.Select.Pressed) ?? uiElements[0];
@@ -195,8 +195,8 @@ public sealed partial class LoadoutGroupContainer : BoxContainer
/// <summary> /// <summary>
/// Creates a UI container for a single Loadout item. /// Creates a UI container for a single Loadout item.
/// ///
/// This method was extracted from RefreshLoadouts because the logic for creating /// This method was extracted from RefreshLoadouts because the logic for creating
/// individual loadout items is used multiple times inside that method, and duplicating /// individual loadout items is used multiple times inside that method, and duplicating
/// the code made it harder to maintain. /// the code made it harder to maintain.
/// ///
/// Logic: /// Logic:

View File

@@ -68,7 +68,7 @@ public sealed partial class LoadoutWindow : FancyWindow
{ {
foreach (var group in proto.Groups) foreach (var group in proto.Groups)
{ {
if (!protoManager.TryIndex(group, out var groupProto)) if (!protoManager.Resolve(group, out var groupProto))
continue; continue;
if (groupProto.Hidden) if (groupProto.Hidden)

View File

@@ -57,7 +57,7 @@ public sealed class EntityHealthBarOverlay : Overlay
const float scale = 1f; const float scale = 1f;
var scaleMatrix = Matrix3Helpers.CreateScale(new Vector2(scale, scale)); var scaleMatrix = Matrix3Helpers.CreateScale(new Vector2(scale, scale));
var rotationMatrix = Matrix3Helpers.CreateRotation(-rotation); var rotationMatrix = Matrix3Helpers.CreateRotation(-rotation);
_prototype.TryIndex(StatusIcon, out var statusIcon); _prototype.Resolve(StatusIcon, out var statusIcon);
var query = _entManager.AllEntityQueryEnumerator<MobThresholdsComponent, MobStateComponent, DamageableComponent, SpriteComponent>(); var query = _entManager.AllEntityQueryEnumerator<MobThresholdsComponent, MobStateComponent, DamageableComponent, SpriteComponent>();
while (query.MoveNext(out var uid, while (query.MoveNext(out var uid,

View File

@@ -22,7 +22,7 @@ public sealed class ShowCriminalRecordIconsSystem : EquipmentHudSystem<ShowCrimi
if (!IsActive) if (!IsActive)
return; return;
if (_prototype.TryIndex(component.StatusIcon, out var iconPrototype)) if (_prototype.Resolve(component.StatusIcon, out var iconPrototype))
ev.StatusIcons.Add(iconPrototype); ev.StatusIcons.Add(iconPrototype);
} }
} }

View File

@@ -78,9 +78,9 @@ public sealed class ShowHealthIconsSystem : EquipmentHudSystem<ShowHealthIconsCo
if (TryComp<MobStateComponent>(entity, out var state)) if (TryComp<MobStateComponent>(entity, out var state))
{ {
// Since there is no MobState for a rotting mob, we have to deal with this case first. // Since there is no MobState for a rotting mob, we have to deal with this case first.
if (HasComp<RottingComponent>(entity) && _prototypeMan.TryIndex(damageableComponent.RottingIcon, out var rottingIcon)) if (HasComp<RottingComponent>(entity) && _prototypeMan.Resolve(damageableComponent.RottingIcon, out var rottingIcon))
result.Add(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); result.Add(icon);
} }
} }

View File

@@ -51,7 +51,7 @@ public sealed class ShowJobIconsSystem : EquipmentHudSystem<ShowJobIconsComponen
} }
} }
if (_prototype.TryIndex(iconId, out var iconPrototype)) if (_prototype.Resolve(iconId, out var iconPrototype))
ev.StatusIcons.Add(iconPrototype); ev.StatusIcons.Add(iconPrototype);
else else
Log.Error($"Invalid job icon prototype: {iconPrototype}"); Log.Error($"Invalid job icon prototype: {iconPrototype}");

View File

@@ -23,7 +23,7 @@ public sealed class ShowMindShieldIconsSystem : EquipmentHudSystem<ShowMindShiel
{ {
if(!IsActive) if(!IsActive)
return; return;
if (component.IsEnabled && _prototype.TryIndex(component.MindShieldStatusIcon, out var fakeStatusIconPrototype)) if (component.IsEnabled && _prototype.Resolve(component.MindShieldStatusIcon, out var fakeStatusIconPrototype))
ev.StatusIcons.Add(fakeStatusIconPrototype); ev.StatusIcons.Add(fakeStatusIconPrototype);
} }
@@ -32,7 +32,7 @@ public sealed class ShowMindShieldIconsSystem : EquipmentHudSystem<ShowMindShiel
if (!IsActive) if (!IsActive)
return; return;
if (_prototype.TryIndex(component.MindShieldStatusIcon, out var iconPrototype)) if (_prototype.Resolve(component.MindShieldStatusIcon, out var iconPrototype))
ev.StatusIcons.Add(iconPrototype); ev.StatusIcons.Add(iconPrototype);
} }
} }

View File

@@ -65,7 +65,7 @@ public sealed partial class StencilOverlay : Overlay
{ {
foreach (var (proto, weather) in comp.Weather) foreach (var (proto, weather) in comp.Weather)
{ {
if (!_protoManager.TryIndex<WeatherPrototype>(proto, out var weatherProto)) if (!_protoManager.Resolve<WeatherPrototype>(proto, out var weatherProto))
continue; continue;
var alpha = _weather.GetPercent(weather, mapUid); var alpha = _weather.GetPercent(weather, mapUid);

View File

@@ -125,8 +125,10 @@ public sealed class RCDMenuBoundUserInterface : BoundUserInterface
var name = Loc.GetString(proto.SetName); var name = Loc.GetString(proto.SetName);
if (proto.Prototype != null && if (proto.Prototype != null &&
_prototypeManager.TryIndex(proto.Prototype, out var entProto, logError: false)) _prototypeManager.Resolve(proto.Prototype, out var entProto))
{
name = entProto.Name; name = entProto.Name;
}
msg = Loc.GetString("rcd-component-change-build-mode", ("name", 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 if (proto.Mode is RcdMode.ConstructTile or RcdMode.ConstructObject
&& proto.Prototype != null && proto.Prototype != null
&& _prototypeManager.TryIndex(proto.Prototype, out var entProto, logError: false)) && _prototypeManager.Resolve(proto.Prototype, out var entProto))
{ {
tooltip = Loc.GetString(entProto.Name); tooltip = Loc.GetString(entProto.Name);
} }

View File

@@ -42,7 +42,7 @@ public sealed partial class IntercomMenu : FancyWindow
for (var i = 0; i < entity.Comp.SupportedChannels.Count; i++) for (var i = 0; i < entity.Comp.SupportedChannels.Count; i++)
{ {
var channel = entity.Comp.SupportedChannels[i]; var channel = entity.Comp.SupportedChannels[i];
if (!_prototype.TryIndex(channel, out var prototype)) if (!_prototype.Resolve(channel, out var prototype))
continue; continue;
_channels.Add(channel); _channels.Add(channel);

View File

@@ -25,13 +25,13 @@ public sealed class RevolutionarySystem : SharedRevolutionarySystem
if (HasComp<HeadRevolutionaryComponent>(ent)) if (HasComp<HeadRevolutionaryComponent>(ent))
return; return;
if (_prototype.TryIndex(ent.Comp.StatusIcon, out var iconPrototype)) if (_prototype.Resolve(ent.Comp.StatusIcon, out var iconPrototype))
args.StatusIcons.Add(iconPrototype); args.StatusIcons.Add(iconPrototype);
} }
private void GetHeadRevIcon(Entity<HeadRevolutionaryComponent> ent, ref GetStatusIconsEvent args) private void GetHeadRevIcon(Entity<HeadRevolutionaryComponent> 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); args.StatusIcons.Add(iconPrototype);
} }
} }

View File

@@ -44,7 +44,7 @@ public sealed partial class StationAiCustomizationMenu : FancyWindow
StationAiCustomizationPrototype? selectedPrototype = null; StationAiCustomizationPrototype? selectedPrototype = null;
if (stationAiCustomization?.ProtoIds.TryGetValue(groupPrototype, out var selectedProtoId) == true) if (stationAiCustomization?.ProtoIds.TryGetValue(groupPrototype, out var selectedProtoId) == true)
_protoManager.TryIndex(selectedProtoId, out selectedPrototype); _protoManager.Resolve(selectedProtoId, out selectedPrototype);
_buttonGroups[groupPrototype] = new ButtonGroup(); _buttonGroups[groupPrototype] = new ButtonGroup();
_groupContainers[groupPrototype] = new StationAiCustomizationGroupContainer(groupPrototype, selectedPrototype, _buttonGroups[groupPrototype], this, _protoManager); _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 // Create UI entries for all customization in the group
foreach (var protoId in groupPrototype.ProtoIds) foreach (var protoId in groupPrototype.ProtoIds)
{ {
if (!protoManager.TryIndex(protoId, out var prototype)) if (!protoManager.Resolve(protoId, out var prototype))
continue; continue;
var entry = new StationAiCustomizationEntryContainer(groupPrototype, prototype, buttonGroup, menu); var entry = new StationAiCustomizationEntryContainer(groupPrototype, prototype, buttonGroup, menu);

View File

@@ -65,7 +65,7 @@ public sealed class SprayPainterSystem : SharedSprayPainterSystem
var groupList = new List<string>(); var groupList = new List<string>();
foreach (var groupId in category.Groups) foreach (var groupId in category.Groups)
{ {
if (!Proto.TryIndex(groupId, out var group)) if (!Proto.Resolve(groupId, out var group))
continue; continue;
groupList.Add(groupId); groupList.Add(groupId);

View File

@@ -42,7 +42,7 @@ public sealed class EntityStorageVisualizerSystem : VisualizerSystem<EntityStora
var forceRedrawBase = false; var forceRedrawBase = false;
if (AppearanceSystem.TryGetData<string>(uid, PaintableVisuals.Prototype, out var prototype, args.Component)) if (AppearanceSystem.TryGetData<string>(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)) if (proto.TryGetComponent(out SpriteComponent? sprite, _componentFactory))
{ {

View File

@@ -33,7 +33,7 @@ public sealed partial class StoreWithdrawWindow : DefaultWindow
_validCurrencies.Clear(); _validCurrencies.Clear();
foreach (var currency in balance) foreach (var currency in balance)
{ {
if (!_prototypeManager.TryIndex(currency.Key, out var proto)) if (!_prototypeManager.Resolve(currency.Key, out var proto))
continue; continue;
_validCurrencies.Add(proto, currency.Value); _validCurrencies.Add(proto, currency.Value);

View File

@@ -120,7 +120,7 @@ namespace Content.Client.VendingMachines.UI
{ {
var entry = inventory[i]; var entry = inventory[i];
if (!_prototypeManager.TryIndex(entry.ID, out var prototype)) if (!_prototypeManager.Resolve(entry.ID, out var prototype))
{ {
_amounts[entry.ID] = 0; _amounts[entry.ID] = 0;
continue; continue;

View File

@@ -146,8 +146,8 @@ public sealed class SuicideCommandTests
mobThresholdsComp = entManager.GetComponent<MobThresholdsComponent>(player); mobThresholdsComp = entManager.GetComponent<MobThresholdsComponent>(player);
damageableComp = entManager.GetComponent<DamageableComponent>(player); damageableComp = entManager.GetComponent<DamageableComponent>(player);
if (protoMan.TryIndex(DamageType, out var slashProto)) var slashProto = protoMan.Index(DamageType);
damageableSystem.TryChangeDamage(player, new DamageSpecifier(slashProto, FixedPoint2.New(46.5))); damageableSystem.TryChangeDamage(player, new DamageSpecifier(slashProto, FixedPoint2.New(46.5)));
}); });
// Check that running the suicide command kills the player // Check that running the suicide command kills the player

View File

@@ -27,8 +27,11 @@ public sealed class ContrabandTest
if (!proto.TryGetComponent<ContrabandComponent>(out var contraband, componentFactory)) if (!proto.TryGetComponent<ContrabandComponent>(out var contraband, componentFactory))
continue; continue;
Assert.That(protoMan.TryIndex(contraband.Severity, out var severity, false), if (!protoMan.TryIndex(contraband.Severity, out var severity))
@$"{proto.ID} has a ContrabandComponent with a unknown severity."); {
Assert.Fail($"{proto.ID} has a ContrabandComponent with a unknown severity.");
continue;
}
if (!severity.ShowDepartmentsAndJobs) if (!severity.ShowDepartmentsAndJobs)
continue; continue;

View File

@@ -88,14 +88,18 @@ public sealed class LatheTest
// Check each recipe assigned to this lathe // Check each recipe assigned to this lathe
foreach (var recipeId in recipes) 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 // Track the total material volume of the recipe
var totalQuantity = 0; var totalQuantity = 0;
// Check each material called for by the recipe // Check each material called for by the recipe
foreach (var (materialId, quantity) in recipeProto.Materials) 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 // 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}"); Assert.That(acceptedMaterials, Does.Contain(materialId), $"Lathe {latheProto.ID} has recipe {recipeId} but does not accept any materials containing {materialId}");
totalQuantity += quantity; totalQuantity += quantity;

View File

@@ -145,10 +145,7 @@ public sealed partial class MindTests
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var damageable = entMan.GetComponent<DamageableComponent>(entity); var damageable = entMan.GetComponent<DamageableComponent>(entity);
if (!protoMan.TryIndex(BluntDamageType, out var prototype)) var prototype = protoMan.Index(BluntDamageType);
{
return;
}
damageableSystem.SetDamage(entity, damageable, new DamageSpecifier(prototype, FixedPoint2.New(401))); damageableSystem.SetDamage(entity, damageable, new DamageSpecifier(prototype, FixedPoint2.New(401)));
Assert.That(mindSystem.GetMind(entity, mindContainerComp), Is.EqualTo(mindId)); Assert.That(mindSystem.GetMind(entity, mindContainerComp), Is.EqualTo(mindId));

View File

@@ -256,8 +256,7 @@ namespace Content.IntegrationTests.Tests
return; return;
var yamlEntities = node["entities"]; var yamlEntities = node["entities"];
if (!protoManager.TryIndex(DoNotMapCategory, out var dnmCategory)) var dnmCategory = protoManager.Index(DoNotMapCategory);
return;
Assert.Multiple(() => Assert.Multiple(() =>
{ {
@@ -266,7 +265,7 @@ namespace Content.IntegrationTests.Tests
var protoId = yamlEntity["proto"].AsString(); var protoId = yamlEntity["proto"].AsString();
// This doesn't properly handle prototype migrations, but thats not a significant issue. // 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; continue;
Assert.That(!proto.Categories.Contains(dnmCategory), Assert.That(!proto.Categories.Contains(dnmCategory),

View File

@@ -45,7 +45,7 @@ namespace Content.Server.Access.Systems
if (!TryComp<IdCardComponent>(ent, out var idCardComp)) if (!TryComp<IdCardComponent>(ent, out var idCardComp))
return; 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 jobIcon = args.Args.ChameleonOutfit.Icon ?? jobProto?.Icon;
var jobName = args.Args.ChameleonOutfit.Name ?? jobProto?.Name ?? ""; var jobName = args.Args.ChameleonOutfit.Name ?? jobProto?.Name ?? "";
@@ -130,7 +130,7 @@ namespace Content.Server.Access.Systems
if (!TryComp<IdCardComponent>(uid, out var idCard)) if (!TryComp<IdCardComponent>(uid, out var idCard))
return; return;
if (!_prototypeManager.TryIndex(args.JobIconId, out var jobIcon)) if (!_prototypeManager.Resolve(args.JobIconId, out var jobIcon))
return; return;
_cardSystem.TryChangeJobIcon(uid, jobIcon, idCard); _cardSystem.TryChangeJobIcon(uid, jobIcon, idCard);

View File

@@ -98,7 +98,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
var targetIdComponent = Comp<IdCardComponent>(targetId); var targetIdComponent = Comp<IdCardComponent>(targetId);
var targetAccessComponent = Comp<AccessComponent>(targetId); var targetAccessComponent = Comp<AccessComponent>(targetId);
var jobProto = targetIdComponent.JobPrototype ?? new ProtoId<AccessLevelPrototype>(string.Empty); var jobProto = targetIdComponent.JobPrototype ?? new ProtoId<JobPrototype>(string.Empty);
if (TryComp<StationRecordKeyStorageComponent>(targetId, out var keyStorage) if (TryComp<StationRecordKeyStorageComponent>(targetId, out var keyStorage)
&& keyStorage.Key is { } key && keyStorage.Key is { } key
&& _record.TryGetRecord<GeneralStationRecord>(key, out var record)) && _record.TryGetRecord<GeneralStationRecord>(key, out var record))
@@ -130,7 +130,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
string newFullName, string newFullName,
string newJobTitle, string newJobTitle,
List<ProtoId<AccessLevelPrototype>> newAccessList, List<ProtoId<AccessLevelPrototype>> newAccessList,
ProtoId<AccessLevelPrototype> newJobProto, ProtoId<JobPrototype> newJobProto,
EntityUid player, EntityUid player,
IdCardConsoleComponent? component = null) IdCardConsoleComponent? component = null)
{ {
@@ -144,7 +144,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
_idCard.TryChangeJobTitle(targetId, newJobTitle, player: player); _idCard.TryChangeJobTitle(targetId, newJobTitle, player: player);
if (_prototype.TryIndex<JobPrototype>(newJobProto, out var job) if (_prototype.TryIndex<JobPrototype>(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.TryChangeJobIcon(targetId, jobIcon, player: player);
_idCard.TryChangeJobDepartment(targetId, job); _idCard.TryChangeJobDepartment(targetId, job);

View File

@@ -82,7 +82,7 @@ public sealed class PresetIdCardSystem : EntitySystem
_cardSystem.TryChangeJobTitle(uid, job.LocalizedName); _cardSystem.TryChangeJobTitle(uid, job.LocalizedName);
_cardSystem.TryChangeJobDepartment(uid, job); _cardSystem.TryChangeJobDepartment(uid, job);
if (_prototypeManager.TryIndex(job.Icon, out var jobIcon)) if (_prototypeManager.Resolve(job.Icon, out var jobIcon))
_cardSystem.TryChangeJobIcon(uid, jobIcon); _cardSystem.TryChangeJobIcon(uid, jobIcon);
} }
} }

View File

@@ -118,7 +118,7 @@ public sealed class ExplosionCommand : LocalizedEntityCommands
return; 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 // no prototype was specified, so lets default to whichever one was defined first
type = _prototypeManager.EnumeratePrototypes<ExplosionPrototype>().FirstOrDefault(); type = _prototypeManager.EnumeratePrototypes<ExplosionPrototype>().FirstOrDefault();

View File

@@ -38,7 +38,7 @@ public sealed partial class SpeakOnUIClosedSystem : SharedSpeakOnUIClosedSystem
if (!entity.Comp.Enabled) if (!entity.Comp.Enabled)
return false; return false;
if (!_prototypeManager.TryIndex(entity.Comp.Pack, out var messagePack)) if (!_prototypeManager.Resolve(entity.Comp.Pack, out var messagePack))
return false; return false;
var message = Loc.GetString(_random.Pick(messagePack.Values), ("name", Name(entity))); var message = Loc.GetString(_random.Pick(messagePack.Values), ("name", Name(entity)));

View File

@@ -86,7 +86,7 @@ public sealed class InnerBodyAnomalySystem : SharedInnerBodyAnomalySystem
private void AddAnomalyToBody(Entity<InnerBodyAnomalyComponent> ent) private void AddAnomalyToBody(Entity<InnerBodyAnomalyComponent> ent)
{ {
if (!_proto.TryIndex(ent.Comp.InjectionProto, out var injectedAnom)) if (!_proto.Resolve(ent.Comp.InjectionProto, out var injectedAnom))
return; return;
if (ent.Comp.Injected) if (ent.Comp.Injected)
@@ -210,7 +210,7 @@ public sealed class InnerBodyAnomalySystem : SharedInnerBodyAnomalySystem
if (!ent.Comp.Injected) if (!ent.Comp.Injected)
return; return;
if (_proto.TryIndex(ent.Comp.InjectionProto, out var injectedAnom)) if (_proto.Resolve(ent.Comp.InjectionProto, out var injectedAnom))
EntityManager.RemoveComponents(ent, injectedAnom.Components); EntityManager.RemoveComponents(ent, injectedAnom.Components);
_stun.TryUpdateParalyzeDuration(ent, TimeSpan.FromSeconds(ent.Comp.StunDuration)); _stun.TryUpdateParalyzeDuration(ent, TimeSpan.FromSeconds(ent.Comp.StunDuration));

View File

@@ -51,7 +51,7 @@ public sealed class JukeboxSystem : SharedJukeboxSystem
component.AudioStream = Audio.Stop(component.AudioStream); component.AudioStream = Audio.Stop(component.AudioStream);
if (string.IsNullOrEmpty(component.SelectedSongId) || if (string.IsNullOrEmpty(component.SelectedSongId) ||
!_protoManager.TryIndex(component.SelectedSongId, out var jukeboxProto)) !_protoManager.Resolve(component.SelectedSongId, out var jukeboxProto))
{ {
return; return;
} }

View File

@@ -113,7 +113,7 @@ public sealed partial class CargoSystem
public void SetupBountyLabel(EntityUid uid, EntityUid stationId, CargoBountyData bounty, PaperComponent? paper = null, CargoBountyLabelComponent? label = null) public void SetupBountyLabel(EntityUid uid, EntityUid stationId, CargoBountyData bounty, PaperComponent? paper = null, CargoBountyLabelComponent? label = null)
{ {
if (!Resolve(uid, ref paper, ref label) || !_protoMan.TryIndex<CargoBountyPrototype>(bounty.Bounty, out var prototype)) if (!Resolve(uid, ref paper, ref label) || !_protoMan.Resolve<CargoBountyPrototype>(bounty.Bounty, out var prototype))
return; return;
label.Id = bounty.Id; label.Id = bounty.Id;
@@ -156,7 +156,7 @@ public sealed partial class CargoSystem
if (!TryGetBountyFromId(station, component.Id, out var bounty, database)) if (!TryGetBountyFromId(station, component.Id, out var bounty, database))
return; return;
if (!_protoMan.TryIndex(bounty.Value.Bounty, out var bountyPrototype) || if (!_protoMan.Resolve(bounty.Value.Bounty, out var bountyPrototype) ||
!IsBountyComplete(container.Owner, bountyPrototype)) !IsBountyComplete(container.Owner, bountyPrototype))
return; return;
@@ -275,7 +275,7 @@ public sealed partial class CargoSystem
public bool IsBountyComplete(EntityUid container, CargoBountyData data, out HashSet<EntityUid> bountyEntities) public bool IsBountyComplete(EntityUid container, CargoBountyData data, out HashSet<EntityUid> bountyEntities)
{ {
if (!_protoMan.TryIndex(data.Bounty, out var proto)) if (!_protoMan.Resolve(data.Bounty, out var proto))
{ {
bountyEntities = new(); bountyEntities = new();
return false; return false;

View File

@@ -167,7 +167,7 @@ namespace Content.Server.Cargo.Systems
// Find our order again. It might have been dispatched or approved already // 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); 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; return;
} }
@@ -322,7 +322,7 @@ namespace Content.Server.Cargo.Systems
private void OnAddOrderMessageSlipPrinter(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleAddOrderMessage args, CargoProductPrototype product) 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; return;
if (Timing.CurTime < component.NextPrintTime) if (Timing.CurTime < component.NextPrintTime)

View File

@@ -433,7 +433,7 @@ public sealed partial class ChatSystem : SharedChatSystem
RaiseLocalEvent(source, nameEv); RaiseLocalEvent(source, nameEv);
name = nameEv.VoiceName; name = nameEv.VoiceName;
// Check for a speech verb override // 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; speech = proto;
} }

View File

@@ -66,7 +66,7 @@ public sealed class TransformableContainerSystem : EntitySystem
private void OnRefreshNameModifiers(Entity<TransformableContainerComponent> entity, ref RefreshNameModifiersEvent args) private void OnRefreshNameModifiers(Entity<TransformableContainerComponent> 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)); args.AddModifier("transformable-container-component-glass", priority: -1, ("reagent", currentReagent.LocalizedName));
} }

View File

@@ -43,13 +43,13 @@ public sealed partial class CloningSystem : SharedCloningSystem
public bool TryCloning(EntityUid original, MapCoordinates? coords, ProtoId<CloningSettingsPrototype> settingsId, [NotNullWhen(true)] out EntityUid? clone) public bool TryCloning(EntityUid original, MapCoordinates? coords, ProtoId<CloningSettingsPrototype> settingsId, [NotNullWhen(true)] out EntityUid? clone)
{ {
clone = null; clone = null;
if (!_prototype.TryIndex(settingsId, out var settings)) if (!_prototype.Resolve(settingsId, out var settings))
return false; // invalid settings return false; // invalid settings
if (!TryComp<HumanoidAppearanceComponent>(original, out var humanoid)) if (!TryComp<HumanoidAppearanceComponent>(original, out var humanoid))
return false; // whatever body was to be cloned, was not a 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 return false; // invalid species
var attemptEv = new CloningAttemptEvent(settings); var attemptEv = new CloningAttemptEvent(settings);

View File

@@ -145,7 +145,7 @@ namespace Content.Server.Construction
return guide; return guide;
// If the graph doesn't actually exist, do nothing. // 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; return null;
// If either the start node or the target node are missing, do nothing. // If either the start node or the target node are missing, do nothing.

View File

@@ -61,7 +61,7 @@ public sealed class DamageForceSaySystem : EntitySystem
var ev = new BeforeForceSayEvent(component.ForceSayStringDataset); var ev = new BeforeForceSayEvent(component.ForceSayStringDataset);
RaiseLocalEvent(uid, ev); RaiseLocalEvent(uid, ev);
if (!_prototype.TryIndex(ev.Prefix, out var prefixList)) if (!_prototype.Resolve(ev.Prefix, out var prefixList))
return; return;
var suffix = Loc.GetString(_random.Pick(prefixList.Values)); var suffix = Loc.GetString(_random.Pick(prefixList.Values));

View File

@@ -20,7 +20,7 @@ public sealed class ExaminableDamageSystem : EntitySystem
private void OnExamine(Entity<ExaminableDamageComponent> ent, ref ExaminedEvent args) private void OnExamine(Entity<ExaminableDamageComponent> 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; return;
var percent = GetDamagePercent(ent); var percent = GetDamagePercent(ent);

View File

@@ -102,7 +102,7 @@ public sealed partial class DeliverySystem : SharedDeliverySystem
if (ent.Comp.WasPenalized) if (ent.Comp.WasPenalized)
return; return;
if (!_protoMan.TryIndex(ent.Comp.PenaltyBankAccount, out var accountInfo)) if (!_protoMan.Resolve(ent.Comp.PenaltyBankAccount, out var accountInfo))
return; return;
var multiplier = GetDeliveryMultiplier(ent); var multiplier = GetDeliveryMultiplier(ent);

View File

@@ -66,7 +66,7 @@ public sealed partial class WeightedSpawnEntityBehavior : IThresholdBehavior
if (SpawnAfter != 0) if (SpawnAfter != 0)
{ {
// if it fails to get the spawner, this won't ever work so just return // 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; return;
// spawn the spawner, assign it a lifetime, and assign the entity that it will spawn when despawned // spawn the spawner, assign it a lifetime, and assign the entity that it will spawn when despawned

View File

@@ -949,9 +949,7 @@ public sealed class EntityEffectSystem : EntitySystem
return; return;
var targetProto = _random.Pick(plantholder.Seed.MutationPrototypes); var targetProto = _random.Pick(plantholder.Seed.MutationPrototypes);
_protoManager.TryIndex(targetProto, out SeedPrototype? protoSeed); if (!_protoManager.TryIndex(targetProto, out SeedPrototype? protoSeed))
if (protoSeed == null)
{ {
Log.Error($"Seed prototype could not be found: {targetProto}!"); Log.Error($"Seed prototype could not be found: {targetProto}!");
return; return;

View File

@@ -32,7 +32,7 @@ public sealed class AntagLoadProfileRuleSystem : GameRuleSystem<AntagLoadProfile
: HumanoidCharacterProfile.RandomWithSpecies(); : HumanoidCharacterProfile.RandomWithSpecies();
if (profile?.Species is not { } speciesId || !_proto.TryIndex(speciesId, out var species)) if (profile?.Species is not { } speciesId || !_proto.Resolve(speciesId, out var species))
{ {
species = _proto.Index<SpeciesPrototype>(SharedHumanoidAppearanceSystem.DefaultSpecies); species = _proto.Index<SpeciesPrototype>(SharedHumanoidAppearanceSystem.DefaultSpecies);
} }

View File

@@ -17,7 +17,7 @@ public sealed class PuddleMessVariationPassSystem : VariationPassSystem<PuddleMe
{ {
var totalTiles = Stations.GetTileCount(args.Station.AsNullable()); var totalTiles = Stations.GetTileCount(args.Station.AsNullable());
if (!_proto.TryIndex(ent.Comp.RandomPuddleSolutionFill, out var proto)) if (!_proto.Resolve(ent.Comp.RandomPuddleSolutionFill, out var proto))
return; return;
var puddleMod = Random.NextGaussian(ent.Comp.TilesPerSpillAverage, ent.Comp.TilesPerSpillStdDev); var puddleMod = Random.NextGaussian(ent.Comp.TilesPerSpillAverage, ent.Comp.TilesPerSpillStdDev);

View File

@@ -808,7 +808,7 @@ public sealed class GhostRoleSystem : EntitySystem
public void OnGhostRoleRadioMessage(Entity<GhostRoleMobSpawnerComponent> entity, ref GhostRoleRadioMessage args) public void OnGhostRoleRadioMessage(Entity<GhostRoleMobSpawnerComponent> entity, ref GhostRoleRadioMessage args)
{ {
if (!_prototype.TryIndex(args.ProtoId, out var ghostRoleProto)) if (!_prototype.Resolve(args.ProtoId, out var ghostRoleProto))
return; return;
// if the prototype chosen isn't actually part of the selectable options, ignore it // if the prototype chosen isn't actually part of the selectable options, ignore it

View File

@@ -32,7 +32,7 @@ public sealed class SpookySpeakerSystem : EntitySystem
if (curTime < entity.Comp.NextSpeakTime) if (curTime < entity.Comp.NextSpeakTime)
return; return;
if (!_proto.TryIndex(entity.Comp.MessageSet, out var messages)) if (!_proto.Resolve(entity.Comp.MessageSet, out var messages))
return; return;
// Grab a random localized message from the set // Grab a random localized message from the set

View File

@@ -49,8 +49,8 @@ public sealed class ChameleonControllerSystem : SharedChameleonControllerSystem
{ {
var outfitPrototype = _proto.Index(outfit); var outfitPrototype = _proto.Index(outfit);
_proto.TryIndex(outfitPrototype.Job, out var jobPrototype); _proto.Resolve(outfitPrototype.Job, out var jobPrototype);
_proto.TryIndex(outfitPrototype.StartingGear, out var startingGearPrototype); _proto.Resolve(outfitPrototype.StartingGear, out var startingGearPrototype);
GetJobEquipmentInformation(jobPrototype, user, out var customRoleLoadout, out var defaultRoleLoadout, out var jobStartingGearPrototype); GetJobEquipmentInformation(jobPrototype, user, out var customRoleLoadout, out var defaultRoleLoadout, out var jobStartingGearPrototype);
@@ -81,7 +81,7 @@ public sealed class ChameleonControllerSystem : SharedChameleonControllerSystem
if (jobPrototype == null) if (jobPrototype == null)
return; return;
_proto.TryIndex(jobPrototype.StartingGear, out jobStartingGearPrototype); _proto.Resolve(jobPrototype.StartingGear, out jobStartingGearPrototype);
if (!TryComp<ActorComponent>(user, out var actorComponent)) if (!TryComp<ActorComponent>(user, out var actorComponent))
return; return;

View File

@@ -725,7 +725,7 @@ namespace Content.Server.Kitchen.EntitySystems
{ {
foreach (ProtoId<FoodRecipePrototype> recipeId in ent.Comp.ProvidedRecipes) foreach (ProtoId<FoodRecipePrototype> recipeId in ent.Comp.ProvidedRecipes)
{ {
if (_prototype.TryIndex(recipeId, out var recipeProto)) if (_prototype.Resolve(recipeId, out var recipeProto))
{ {
args.Recipes.Add(recipeProto); args.Recipes.Add(recipeProto);
} }

View File

@@ -137,7 +137,7 @@ namespace Content.Server.Lathe
var recipes = GetAvailableRecipes(uid, component, true); var recipes = GetAvailableRecipes(uid, component, true);
foreach (var id in recipes) foreach (var id in recipes)
{ {
if (!_proto.TryIndex(id, out var proto)) if (!_proto.Resolve(id, out var proto))
continue; continue;
foreach (var (mat, _) in proto.Materials) foreach (var (mat, _) in proto.Materials)
{ {

View File

@@ -92,7 +92,7 @@ public sealed class NameIdentifierSystem : EntitySystem
if (ent.Comp.Group is null) if (ent.Comp.Group is null)
return; return;
if (!_prototypeManager.TryIndex(ent.Comp.Group, out var group)) if (!_prototypeManager.Resolve(ent.Comp.Group, out var group))
return; return;
int id; int id;
@@ -131,7 +131,7 @@ public sealed class NameIdentifierSystem : EntitySystem
if (ent.Comp.LifeStage > ComponentLifeStage.Running) if (ent.Comp.LifeStage > ComponentLifeStage.Running)
return; return;
if (!_prototypeManager.TryIndex(ent.Comp.Group, out var group)) if (!_prototypeManager.Resolve(ent.Comp.Group, out var group))
return; return;
var format = group.FullName ? "name-identifier-format-full" : "name-identifier-format-append"; var format = group.FullName ? "name-identifier-format-full" : "name-identifier-format-append";

View File

@@ -127,7 +127,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
SetSeed(uid, component, _random.Next()); 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); SetTemplate(uid, component, biome);
var xform = Transform(uid); var xform = Transform(uid);

View File

@@ -63,7 +63,7 @@ public sealed class JobWhitelistManager : IPostInjectInit
if (!_config.GetCVar(CCVars.GameRoleWhitelist)) if (!_config.GetCVar(CCVars.GameRoleWhitelist))
return true; return true;
if (!_prototypes.TryIndex(job, out var jobPrototype) || if (!_prototypes.Resolve(job, out var jobPrototype) ||
!jobPrototype.Whitelisted) !jobPrototype.Whitelisted)
{ {
return true; return true;

View File

@@ -238,7 +238,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
for (var i = 0; i < jobs.Count; i++) 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)) && JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes, (HumanoidCharacterProfile?) _preferencesManager.GetPreferences(userId).SelectedCharacter))
{ {
continue; continue;

View File

@@ -112,7 +112,7 @@ public sealed partial class PolymorphSystem : EntitySystem
private void OnPolymorphActionEvent(Entity<PolymorphableComponent> ent, ref PolymorphActionEvent args) private void OnPolymorphActionEvent(Entity<PolymorphableComponent> 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; return;
PolymorphEntity(ent, prototype.Configuration); PolymorphEntity(ent, prototype.Configuration);
@@ -389,7 +389,7 @@ public sealed partial class PolymorphSystem : EntitySystem
if (target.Comp.PolymorphActions.ContainsKey(id)) if (target.Comp.PolymorphActions.ContainsKey(id))
return; return;
if (!_proto.TryIndex(id, out var polyProto)) if (!_proto.Resolve(id, out var polyProto))
return; return;
var entProto = _proto.Index(polyProto.Configuration.Entity); var entProto = _proto.Index(polyProto.Configuration.Entity);

View File

@@ -25,8 +25,7 @@ public sealed class PolymorphCommand : ToolshedCommand
{ {
_system ??= GetSys<PolymorphSystem>(); _system ??= GetSys<PolymorphSystem>();
if (!_proto.TryIndex(protoId, out var prototype)) var prototype = _proto.Index(protoId);
return null;
return _system.PolymorphEntity(input, prototype.Configuration); return _system.PolymorphEntity(input, prototype.Configuration);
} }

View File

@@ -16,7 +16,7 @@ public sealed partial class DungeonJob
/// </summary> /// </summary>
private async Task PostGen(BiomeDunGen dunGen, Dungeon dungeon, HashSet<Vector2i> reservedTiles, Random random) private async Task PostGen(BiomeDunGen dunGen, Dungeon dungeon, HashSet<Vector2i> reservedTiles, Random random)
{ {
if (!_prototype.TryIndex(dunGen.BiomeTemplate, out var indexedBiome)) if (!_prototype.Resolve(dunGen.BiomeTemplate, out var indexedBiome))
return; return;
var biomeSystem = _entManager.System<BiomeSystem>(); var biomeSystem = _entManager.System<BiomeSystem>();

View File

@@ -57,7 +57,7 @@ public sealed partial class DungeonJob
var roomConnections = new Dictionary<DungeonRoom, List<DungeonRoom>>(); var roomConnections = new Dictionary<DungeonRoom, List<DungeonRoom>>();
var tileDef = _tileDefManager[gen.Tile]; 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); var contents = _prototype.Index(gen.Contents);
foreach (var (room, border) in roomBorders) foreach (var (room, border) in roomBorders)

View File

@@ -72,7 +72,7 @@ public sealed partial class DungeonJob
var remapping = new Dictionary<EntProtoId, EntProtoId>(); var remapping = new Dictionary<EntProtoId, EntProtoId>();
// TODO: Move this to engine // 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)) proto.Components.TryGetComponent("EntityRemap", out var comps))
{ {
var remappingComp = (EntityRemapComponent) comps; var remappingComp = (EntityRemapComponent) comps;

View File

@@ -17,7 +17,7 @@ public sealed class RadiationProtectionSystem : EntitySystem
private void OnInit(EntityUid uid, RadiationProtectionComponent component, ComponentInit args) 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; return;
var buffComp = EnsureComp<DamageProtectionBuffComponent>(uid); var buffComp = EnsureComp<DamageProtectionBuffComponent>(uid);
// add the damage modifier if it isn't in the dict yet // add the damage modifier if it isn't in the dict yet

View File

@@ -84,7 +84,7 @@ public sealed class RadioSystem : EntitySystem
name = FormattedMessage.EscapeText(name); name = FormattedMessage.EscapeText(name);
SpeechVerbPrototype speech; 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; speech = evntProto;
else else
speech = _chat.GetSpeechVerb(messageSource, message); speech = _chat.GetSpeechVerb(messageSource, message);

View File

@@ -49,7 +49,7 @@ public sealed class RoleSystem : SharedRoleSystem
if (!Player.TryGetSessionById(mind.UserId, out var session)) if (!Player.TryGetSessionById(mind.UserId, out var session))
return; return;
if (!_proto.TryIndex(mind.RoleType, out var proto)) if (!_proto.Resolve(mind.RoleType, out var proto))
return; return;
var roleText = Loc.GetString(proto.Name); var roleText = Loc.GetString(proto.Name);

View File

@@ -89,7 +89,7 @@ public sealed partial class ShuttleSystem
var dungeonProtoId = _random.Pick(group.Protos); var dungeonProtoId = _random.Pick(group.Protos);
if (!_protoManager.TryIndex(dungeonProtoId, out var dungeonProto)) if (!_protoManager.Resolve(dungeonProtoId, out var dungeonProto))
{ {
return false; return false;
} }
@@ -192,7 +192,7 @@ public sealed partial class ShuttleSystem
throw new NotImplementedException(); 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())); _metadata.SetEntityName(spawned, _salvage.GetFTLName(dataset, _random.Next()));
} }

View File

@@ -60,7 +60,7 @@ public sealed class BorgSwitchableTypeSystem : SharedBorgSwitchableTypeSystem
} }
// Configure special components // 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) if (previousPrototype.AddComponents is { } removeComponents)
EntityManager.RemoveComponents(ent, removeComponents); EntityManager.RemoveComponents(ent, removeComponents);

View File

@@ -32,7 +32,7 @@ public sealed class ContainerSpawnPointSystem : EntitySystem
// If it's just a spawn pref check if it's for cryo (silly). // If it's just a spawn pref check if it's for cryo (silly).
if (args.HumanoidCharacterProfile?.SpawnPriority != SpawnPriorityPreference.Cryosleep && 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; return;
} }

View File

@@ -22,7 +22,7 @@ public sealed partial class EmotesMenuSystem : EntitySystem
if (!player.HasValue) if (!player.HasValue)
return; 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; return;
_chat.TryEmoteWithChat(player.Value, msg.ProtoId); _chat.TryEmoteWithChat(player.Value, msg.ProtoId);

View File

@@ -181,7 +181,7 @@ public sealed class SpreaderSystem : EntitySystem
occupiedTiles = []; occupiedTiles = [];
neighbors = []; neighbors = [];
// TODO remove occupiedTiles -- its currently unused and just slows this method down. // 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; return;
if (!TryComp<MapGridComponent>(comp.GridUid, out var grid)) if (!TryComp<MapGridComponent>(comp.GridUid, out var grid))

View File

@@ -362,7 +362,7 @@ public sealed partial class StationJobsSystem
if (!(priority == selectedPriority || selectedPriority is null)) if (!(priority == selectedPriority || selectedPriority is null))
continue; continue;
if (!_prototypeManager.TryIndex(jobId, out var job)) if (!_prototypeManager.Resolve(jobId, out var job))
continue; continue;
if (!job.CanBeAntag && (!_player.TryGetSessionById(player, out var session) || antagBlocked.Contains(session))) if (!job.CanBeAntag && (!_player.TryGetSessionById(player, out var session) || antagBlocked.Contains(session)))

View File

@@ -88,7 +88,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
EntityUid? station, EntityUid? station,
EntityUid? entity = null) EntityUid? entity = null)
{ {
_prototypeManager.TryIndex(job ?? string.Empty, out var prototype); _prototypeManager.Resolve(job, out var prototype);
RoleLoadout? loadout = null; RoleLoadout? loadout = null;
// Need to get the loadout up-front to handle names if we use an entity spawn override. // 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<JobPrototype>? job, EntityUid entity) private void DoJobSpecials(ProtoId<JobPrototype>? job, EntityUid entity)
{ {
if (!_prototypeManager.TryIndex(job ?? string.Empty, out JobPrototype? prototype)) if (!_prototypeManager.Resolve(job, out JobPrototype? prototype))
return; return;
foreach (var jobSpecial in prototype.Special) foreach (var jobSpecial in prototype.Special)
@@ -199,7 +199,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
_cardSystem.TryChangeFullName(cardId, characterName, card); _cardSystem.TryChangeFullName(cardId, characterName, card);
_cardSystem.TryChangeJobTitle(cardId, jobPrototype.LocalizedName, 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); _cardSystem.TryChangeJobIcon(cardId, jobIcon, card);
var extendedAccess = false; var extendedAccess = false;

View File

@@ -71,7 +71,7 @@ public sealed class EventManagerSystem : EntitySystem
return; return;
} }
if (!_prototype.TryIndex(randomLimitedEvent, out _)) if (!_prototype.Resolve(randomLimitedEvent, out _))
{ {
Log.Warning("A requested event is not available!"); Log.Warning("A requested event is not available!");
return; return;
@@ -104,7 +104,7 @@ public sealed class EventManagerSystem : EntitySystem
foreach (var eventid in selectedEvents) 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!"); Log.Warning("An event ID has no prototype index!");
continue; continue;

View File

@@ -54,7 +54,7 @@ public sealed class GreytideVirusRule : StationEventSystem<GreytideVirusRuleComp
var accessIds = new HashSet<ProtoId<AccessLevelPrototype>>(); var accessIds = new HashSet<ProtoId<AccessLevelPrototype>>();
foreach (var group in chosen) foreach (var group in chosen)
{ {
if (_prototype.TryIndex(group, out var proto)) if (_prototype.Resolve(group, out var proto))
accessIds.UnionWith(proto.Tags); accessIds.UnionWith(proto.Tags);
} }

View File

@@ -121,7 +121,7 @@ public sealed class SurveillanceCameraRouterSystem : EntitySystem
return; return;
} }
if (!_prototypeManager.TryIndex<DeviceFrequencyPrototype>(component.AvailableNetworks[args.Network], if (!_prototypeManager.Resolve<DeviceFrequencyPrototype>(component.AvailableNetworks[args.Network],
out var frequency)) out var frequency))
{ {
return; return;

View File

@@ -190,7 +190,7 @@ public sealed class SurveillanceCameraSystem : EntitySystem
return; return;
} }
if (!_prototypeManager.TryIndex<DeviceFrequencyPrototype>(component.AvailableNetworks[args.Network], if (!_prototypeManager.Resolve<DeviceFrequencyPrototype>(component.AvailableNetworks[args.Network],
out var frequency)) out var frequency))
{ {
return; return;

View File

@@ -340,7 +340,7 @@ public sealed class TelephoneSystem : SharedTelephoneSystem
name = FormattedMessage.EscapeText(name); name = FormattedMessage.EscapeText(name);
SpeechVerbPrototype speech; 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; speech = evntProto;
else else
speech = _chat.GetSpeechVerb(messageSource, message); speech = _chat.GetSpeechVerb(messageSource, message);

View File

@@ -88,7 +88,7 @@ public sealed class UplinkSystem : EntitySystem
/// </summary> /// </summary>
private bool ImplantUplink(EntityUid user, FixedPoint2 balance, bool giveDiscounts) private bool ImplantUplink(EntityUid user, FixedPoint2 balance, bool giveDiscounts)
{ {
if (!_proto.TryIndex<ListingPrototype>(FallbackUplinkCatalog, out var catalog)) if (!_proto.Resolve<ListingPrototype>(FallbackUplinkCatalog, out var catalog))
return false; return false;
if (!catalog.Cost.TryGetValue(TelecrystalCurrencyPrototype, out var cost)) if (!catalog.Cost.TryGetValue(TelecrystalCurrencyPrototype, out var cost))

View File

@@ -26,7 +26,7 @@ public sealed class TraitSystem : EntitySystem
{ {
// Check if player's job allows to apply traits // Check if player's job allows to apply traits
if (args.JobId == null || if (args.JobId == null ||
!_prototypeManager.TryIndex<JobPrototype>(args.JobId ?? string.Empty, out var protoJob) || !_prototypeManager.Resolve<JobPrototype>(args.JobId, out var protoJob) ||
!protoJob.ApplyTraits) !protoJob.ApplyTraits)
{ {
return; return;
@@ -36,7 +36,7 @@ public sealed class TraitSystem : EntitySystem
{ {
if (!_prototypeManager.TryIndex<TraitPrototype>(traitId, out var traitPrototype)) if (!_prototypeManager.TryIndex<TraitPrototype>(traitId, out var traitPrototype))
{ {
Log.Warning($"No trait found with ID {traitId}!"); Log.Error($"No trait found with ID {traitId}!");
return; return;
} }

View File

@@ -34,7 +34,7 @@ public sealed class SpeakOnTriggerSystem : EntitySystem
message = Loc.GetString(ent.Comp.Text); message = Loc.GetString(ent.Comp.Text);
else else
{ {
if (!_prototypeManager.TryIndex(ent.Comp.Pack, out var messagePack)) if (!_prototypeManager.Resolve(ent.Comp.Pack, out var messagePack))
return; return;
message = Loc.GetString(_random.Pick(messagePack.Values)); message = Loc.GetString(_random.Pick(messagePack.Values));
} }

Some files were not shown because too many files have changed in this diff Show More