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:
committed by
GitHub
parent
fca45851cc
commit
0c97520276
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<ProtoId<AccessLevelPrototype>> newAccessList, string newJobPrototype)
|
||||
public void SubmitData(string newFullName, string newJobTitle, List<ProtoId<AccessLevelPrototype>> newAccessList, ProtoId<JobPrototype> newJobPrototype)
|
||||
{
|
||||
if (newFullName.Length > _maxNameLength)
|
||||
newFullName = newFullName[.._maxNameLength];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<JobPrototype>(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<JobPrototype>(role, out var jobPrototype) && _protoMan.Resolve(jobPrototype.Icon, out var iconProto))
|
||||
{
|
||||
var jobIconTexture = new TextureRect
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<AudioSystem>().GetAudioLength(songProto.Path.Path.ToString());
|
||||
_menu.SetSelectedSong(songProto.Name, (float) length.TotalSeconds);
|
||||
|
||||
@@ -39,7 +39,7 @@ public sealed class BarSignSystem : VisualizerSystem<BarSignComponent>
|
||||
|
||||
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");
|
||||
|
||||
@@ -35,7 +35,7 @@ public sealed class BarSignBoundUserInterface(EntityUid owner, Enum uiKey) : Bou
|
||||
|
||||
public void Update(ProtoId<BarSignPrototype>? sign)
|
||||
{
|
||||
if (_prototype.TryIndex(sign, out var signPrototype))
|
||||
if (_prototype.Resolve(sign, out var signPrototype))
|
||||
_menu?.UpdateState(signPrototype);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public sealed partial class BountyEntry : BoxContainer
|
||||
|
||||
UntilNextSkip = untilNextSkip;
|
||||
|
||||
if (!_prototype.TryIndex<CargoBountyPrototype>(bounty.Bounty, out var bountyPrototype))
|
||||
if (!_prototype.Resolve<CargoBountyPrototype>(bounty.Bounty, out var bountyPrototype))
|
||||
return;
|
||||
|
||||
var items = new List<string>();
|
||||
|
||||
@@ -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<string>();
|
||||
|
||||
@@ -27,7 +27,7 @@ public sealed class TypingIndicatorVisualizerSystem : VisualizerSystem<TypingInd
|
||||
if (overrideIndicator != null)
|
||||
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}");
|
||||
return;
|
||||
|
||||
@@ -45,7 +45,7 @@ public sealed class ChameleonBoundUserInterface : BoundUserInterface
|
||||
var newTargets = new List<EntProtoId>();
|
||||
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))
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Content.Client.Construction
|
||||
{
|
||||
foreach (var constructionProto in PrototypeManager.EnumeratePrototypes<ConstructionPrototype>())
|
||||
{
|
||||
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];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
|
||||
// If the damage container on our entity's DamageableComponent
|
||||
// is not null, we can try to check through its groups.
|
||||
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?
|
||||
// Check if the container matches the supported groups,
|
||||
|
||||
@@ -142,7 +142,7 @@ public sealed class DoorSystem : SharedDoorSystem
|
||||
|
||||
private void UpdateSpriteLayers(Entity<SpriteComponent> 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))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -53,7 +53,7 @@ public sealed partial class DocumentParsingManager
|
||||
|
||||
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;
|
||||
|
||||
using var file = _resourceManager.ContentFileReadText(entry.Text);
|
||||
|
||||
@@ -28,7 +28,7 @@ public sealed class ImplanterSystem : SharedImplanterSystem
|
||||
Dictionary<string, string> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.";
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -97,7 +97,7 @@ public sealed partial class LatheMenu : DefaultWindow
|
||||
var recipesToShow = new List<LatheRecipePrototype>();
|
||||
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);
|
||||
|
||||
@@ -362,7 +362,7 @@ public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState
|
||||
{
|
||||
foreach (var loadout in group)
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(loadout.Prototype, out var loadoutProto))
|
||||
if (!_prototypeManager.Resolve(loadout.Prototype, out var loadoutProto))
|
||||
continue;
|
||||
|
||||
_spawn.EquipStartingGear(uid, loadoutProto);
|
||||
@@ -385,14 +385,14 @@ public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState
|
||||
{
|
||||
foreach (var loadout in loadouts)
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(loadout.Prototype, out var loadoutProto))
|
||||
if (!_prototypeManager.Resolve(loadout.Prototype, out var loadoutProto))
|
||||
continue;
|
||||
|
||||
// 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)
|
||||
{
|
||||
// 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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
foreach (var slot in slots)
|
||||
|
||||
@@ -810,7 +810,7 @@ namespace Content.Client.Lobby.UI
|
||||
if (_prototypeManager.HasIndex<GuideEntryPrototype>(species))
|
||||
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>();
|
||||
dict.Add(DefaultSpeciesGuidebook, guideRoot);
|
||||
@@ -1291,7 +1291,7 @@ namespace Content.Client.Lobby.UI
|
||||
var sexes = new List<Sex>();
|
||||
|
||||
// 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)
|
||||
{
|
||||
@@ -1384,7 +1384,7 @@ namespace Content.Client.Lobby.UI
|
||||
if (species is null)
|
||||
return;
|
||||
|
||||
if (!_prototypeManager.TryIndex<SpeciesPrototype>(species, out var speciesProto))
|
||||
if (!_prototypeManager.Resolve<SpeciesPrototype>(species, out var speciesProto))
|
||||
return;
|
||||
|
||||
// Don't display the info button if no guide entry is found
|
||||
|
||||
@@ -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<LoadoutSystem>().GetFirstOrNull(loadProto);
|
||||
|
||||
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// 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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<MobThresholdsComponent, MobStateComponent, DamageableComponent, SpriteComponent>();
|
||||
while (query.MoveNext(out var uid,
|
||||
|
||||
@@ -22,7 +22,7 @@ public sealed class ShowCriminalRecordIconsSystem : EquipmentHudSystem<ShowCrimi
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
if (_prototype.TryIndex(component.StatusIcon, out var iconPrototype))
|
||||
if (_prototype.Resolve(component.StatusIcon, out var iconPrototype))
|
||||
ev.StatusIcons.Add(iconPrototype);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ public sealed class ShowHealthIconsSystem : EquipmentHudSystem<ShowHealthIconsCo
|
||||
if (TryComp<MobStateComponent>(entity, out var state))
|
||||
{
|
||||
// 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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
else
|
||||
Log.Error($"Invalid job icon prototype: {iconPrototype}");
|
||||
|
||||
@@ -23,7 +23,7 @@ public sealed class ShowMindShieldIconsSystem : EquipmentHudSystem<ShowMindShiel
|
||||
{
|
||||
if(!IsActive)
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public sealed class ShowMindShieldIconsSystem : EquipmentHudSystem<ShowMindShiel
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
if (_prototype.TryIndex(component.MindShieldStatusIcon, out var iconPrototype))
|
||||
if (_prototype.Resolve(component.MindShieldStatusIcon, out var iconPrototype))
|
||||
ev.StatusIcons.Add(iconPrototype);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public sealed partial class StencilOverlay : Overlay
|
||||
{
|
||||
foreach (var (proto, weather) in comp.Weather)
|
||||
{
|
||||
if (!_protoManager.TryIndex<WeatherPrototype>(proto, out var weatherProto))
|
||||
if (!_protoManager.Resolve<WeatherPrototype>(proto, out var weatherProto))
|
||||
continue;
|
||||
|
||||
var alpha = _weather.GetPercent(weather, mapUid);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -25,13 +25,13 @@ public sealed class RevolutionarySystem : SharedRevolutionarySystem
|
||||
if (HasComp<HeadRevolutionaryComponent>(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<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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -65,7 +65,7 @@ public sealed class SprayPainterSystem : SharedSprayPainterSystem
|
||||
var groupList = new List<string>();
|
||||
foreach (var groupId in category.Groups)
|
||||
{
|
||||
if (!Proto.TryIndex(groupId, out var group))
|
||||
if (!Proto.Resolve(groupId, out var group))
|
||||
continue;
|
||||
|
||||
groupList.Add(groupId);
|
||||
|
||||
@@ -42,7 +42,7 @@ public sealed class EntityStorageVisualizerSystem : VisualizerSystem<EntityStora
|
||||
var forceRedrawBase = false;
|
||||
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))
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user