foreach (var access in accessLevels)
{
- if (!protoManager.TryIndex(access, out var accessLevel))
+ if (!protoManager.Resolve(access, out var accessLevel))
{
continue;
}
foreach (var accessGroup in _accessGroups)
{
- if (!_protoManager.TryIndex(accessGroup, out var accessGroupProto))
+ if (!_protoManager.Resolve(accessGroup, out var accessGroupProto))
continue;
_groupedAccessLevels.Add(accessGroupProto, new());
// 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;
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;
_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];
foreach (var group in job.AccessGroups)
{
- if (!_prototypeManager.TryIndex(group, out AccessGroupPrototype? groupPrototype))
+ if (!_prototypeManager.Resolve(group, out AccessGroupPrototype? groupPrototype))
{
continue;
}
};
// 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
{
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)
_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);
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");
public void Update(ProtoId<BarSignPrototype>? sign)
{
- if (_prototype.TryIndex(sign, out var signPrototype))
+ if (_prototype.Resolve(sign, out var signPrototype))
_menu?.UpdateState(signPrototype);
}
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>();
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>();
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;
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))
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();
{
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)
// 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 = recipe.SetName.HasValue ? Loc.GetString(recipe.SetName) : proto.Name;
- var desc = recipe.SetDescription.HasValue ? Loc.GetString(recipe.SetDescription) : proto.Description;
+ var name = constructionProto.SetName.HasValue ? Loc.GetString(constructionProto.SetName) : proto.Name;
+ var desc = constructionProto.SetDescription.HasValue ? Loc.GetString(constructionProto.SetDescription) : proto.Description;
- recipe.Name = name;
- recipe.Description = desc;
+ constructionProto.Name = name;
+ constructionProto.Description = desc;
_recipesMetadataCache.Add(constructionProto.ID, entityId);
} while (stack.Count > 0);
"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];
foreach (var id in favorites)
{
- if (_prototypeManager.TryIndex(id, out ConstructionPrototype? recipe, logError: false))
+ if (_prototypeManager.TryIndex(id, out ConstructionPrototype? recipe))
_favoritedRecipes.Add(recipe);
}
// 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,
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))
};
// 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);
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);
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);
}
// 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.";
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",
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
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);
{
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);
{
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);
}
}
- if (!_prototypeManager.TryIndex(job.StartingGear, out var gear))
+ if (!_prototypeManager.Resolve(job.StartingGear, out var gear))
return;
foreach (var slot in slots)
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);
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)
{
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
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);
});
}
- 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()
{
})
.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];
/// <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:
{
foreach (var group in proto.Groups)
{
- if (!protoManager.TryIndex(group, out var groupProto))
+ if (!protoManager.Resolve(group, out var groupProto))
continue;
if (groupProto.Hidden)
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,
if (!IsActive)
return;
- if (_prototype.TryIndex(component.StatusIcon, out var iconPrototype))
+ if (_prototype.Resolve(component.StatusIcon, out var iconPrototype))
ev.StatusIcons.Add(iconPrototype);
}
}
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);
}
}
}
}
- 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}");
{
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);
}
if (!IsActive)
return;
- if (_prototype.TryIndex(component.MindShieldStatusIcon, out var iconPrototype))
+ if (_prototype.Resolve(component.MindShieldStatusIcon, out var iconPrototype))
ev.StatusIcons.Add(iconPrototype);
}
}
{
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);
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));
}
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);
}
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);
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);
}
}
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);
// 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);
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);
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))
{
_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);
{
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;
mobThresholdsComp = entManager.GetComponent<MobThresholdsComponent>(player);
damageableComp = entManager.GetComponent<DamageableComponent>(player);
- if (protoMan.TryIndex(DamageType, out var slashProto))
- damageableSystem.TryChangeDamage(player, new DamageSpecifier(slashProto, FixedPoint2.New(46.5)));
+ var slashProto = protoMan.Index(DamageType);
+ damageableSystem.TryChangeDamage(player, new DamageSpecifier(slashProto, FixedPoint2.New(46.5)));
});
// Check that running the suicide command kills the player
if (!proto.TryGetComponent<ContrabandComponent>(out var contraband, componentFactory))
continue;
- Assert.That(protoMan.TryIndex(contraband.Severity, out var severity, false),
- @$"{proto.ID} has a ContrabandComponent with a unknown severity.");
+ if (!protoMan.TryIndex(contraband.Severity, out var severity))
+ {
+ Assert.Fail($"{proto.ID} has a ContrabandComponent with a unknown severity.");
+ continue;
+ }
if (!severity.ShowDepartmentsAndJobs)
continue;
// Check each recipe assigned to this lathe
foreach (var recipeId in recipes)
{
- Assert.That(protoMan.TryIndex(recipeId, out var recipeProto));
+ if (!protoMan.TryIndex(recipeId, out var recipeProto))
+ {
+ Assert.Fail($"Lathe recipe '{recipeId}' does not exist");
+ continue;
+ }
// Track the total material volume of the recipe
var totalQuantity = 0;
// Check each material called for by the recipe
foreach (var (materialId, quantity) in recipeProto.Materials)
{
- Assert.That(protoMan.TryIndex(materialId, out var materialProto));
+ Assert.That(protoMan.HasIndex(materialId), $"Material '{materialId}' does not exist");
// Make sure the material is accepted by the lathe
Assert.That(acceptedMaterials, Does.Contain(materialId), $"Lathe {latheProto.ID} has recipe {recipeId} but does not accept any materials containing {materialId}");
totalQuantity += quantity;
await server.WaitAssertion(() =>
{
var damageable = entMan.GetComponent<DamageableComponent>(entity);
- if (!protoMan.TryIndex(BluntDamageType, out var prototype))
- {
- return;
- }
+ var prototype = protoMan.Index(BluntDamageType);
damageableSystem.SetDamage(entity, damageable, new DamageSpecifier(prototype, FixedPoint2.New(401)));
Assert.That(mindSystem.GetMind(entity, mindContainerComp), Is.EqualTo(mindId));
return;
var yamlEntities = node["entities"];
- if (!protoManager.TryIndex(DoNotMapCategory, out var dnmCategory))
- return;
+ var dnmCategory = protoManager.Index(DoNotMapCategory);
Assert.Multiple(() =>
{
var protoId = yamlEntity["proto"].AsString();
// This doesn't properly handle prototype migrations, but thats not a significant issue.
- if (!protoManager.TryIndex(protoId, out var proto, false))
+ if (!protoManager.TryIndex(protoId, out var proto))
continue;
Assert.That(!proto.Categories.Contains(dnmCategory),
if (!TryComp<IdCardComponent>(ent, out var idCardComp))
return;
- _prototypeManager.TryIndex(args.Args.ChameleonOutfit.Job, out var jobProto);
+ _prototypeManager.Resolve(args.Args.ChameleonOutfit.Job, out var jobProto);
var jobIcon = args.Args.ChameleonOutfit.Icon ?? jobProto?.Icon;
var jobName = args.Args.ChameleonOutfit.Name ?? jobProto?.Name ?? "";
if (!TryComp<IdCardComponent>(uid, out var idCard))
return;
- if (!_prototypeManager.TryIndex(args.JobIconId, out var jobIcon))
+ if (!_prototypeManager.Resolve(args.JobIconId, out var jobIcon))
return;
_cardSystem.TryChangeJobIcon(uid, jobIcon, idCard);
var targetIdComponent = Comp<IdCardComponent>(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)
&& keyStorage.Key is { } key
&& _record.TryGetRecord<GeneralStationRecord>(key, out var record))
string newFullName,
string newJobTitle,
List<ProtoId<AccessLevelPrototype>> newAccessList,
- ProtoId<AccessLevelPrototype> newJobProto,
+ ProtoId<JobPrototype> newJobProto,
EntityUid player,
IdCardConsoleComponent? component = null)
{
_idCard.TryChangeJobTitle(targetId, newJobTitle, player: player);
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.TryChangeJobDepartment(targetId, job);
_cardSystem.TryChangeJobTitle(uid, job.LocalizedName);
_cardSystem.TryChangeJobDepartment(uid, job);
- if (_prototypeManager.TryIndex(job.Icon, out var jobIcon))
+ if (_prototypeManager.Resolve(job.Icon, out var jobIcon))
_cardSystem.TryChangeJobIcon(uid, jobIcon);
}
}
return;
}
}
- else if (!_prototypeManager.TryIndex(ExplosionSystem.DefaultExplosionPrototypeId, out type))
+ else if (!_prototypeManager.Resolve(ExplosionSystem.DefaultExplosionPrototypeId, out type))
{
// no prototype was specified, so lets default to whichever one was defined first
type = _prototypeManager.EnumeratePrototypes<ExplosionPrototype>().FirstOrDefault();
if (!entity.Comp.Enabled)
return false;
- if (!_prototypeManager.TryIndex(entity.Comp.Pack, out var messagePack))
+ if (!_prototypeManager.Resolve(entity.Comp.Pack, out var messagePack))
return false;
var message = Loc.GetString(_random.Pick(messagePack.Values), ("name", Name(entity)));
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;
if (ent.Comp.Injected)
if (!ent.Comp.Injected)
return;
- if (_proto.TryIndex(ent.Comp.InjectionProto, out var injectedAnom))
+ if (_proto.Resolve(ent.Comp.InjectionProto, out var injectedAnom))
EntityManager.RemoveComponents(ent, injectedAnom.Components);
_stun.TryUpdateParalyzeDuration(ent, TimeSpan.FromSeconds(ent.Comp.StunDuration));
component.AudioStream = Audio.Stop(component.AudioStream);
if (string.IsNullOrEmpty(component.SelectedSongId) ||
- !_protoManager.TryIndex(component.SelectedSongId, out var jukeboxProto))
+ !_protoManager.Resolve(component.SelectedSongId, out var jukeboxProto))
{
return;
}
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;
label.Id = bounty.Id;
if (!TryGetBountyFromId(station, component.Id, out var bounty, database))
return;
- if (!_protoMan.TryIndex(bounty.Value.Bounty, out var bountyPrototype) ||
+ if (!_protoMan.Resolve(bounty.Value.Bounty, out var bountyPrototype) ||
!IsBountyComplete(container.Owner, bountyPrototype))
return;
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();
return false;
// Find our order again. It might have been dispatched or approved already
var order = orderDatabase.Orders[component.Account].Find(order => args.OrderId == order.OrderId && !order.Approved);
- if (order == null || !_protoMan.TryIndex(order.Account, out var account))
+ if (order == null || !_protoMan.Resolve(order.Account, out var account))
{
return;
}
private void OnAddOrderMessageSlipPrinter(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleAddOrderMessage args, CargoProductPrototype product)
{
- if (!_protoMan.TryIndex(component.Account, out var account))
+ if (!_protoMan.Resolve(component.Account, out var account))
return;
if (Timing.CurTime < component.NextPrintTime)
RaiseLocalEvent(source, nameEv);
name = nameEv.VoiceName;
// Check for a speech verb override
- if (nameEv.SpeechVerb != null && _prototypeManager.TryIndex(nameEv.SpeechVerb, out var proto))
+ if (nameEv.SpeechVerb != null && _prototypeManager.Resolve(nameEv.SpeechVerb, out var proto))
speech = proto;
}
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));
}
public bool TryCloning(EntityUid original, MapCoordinates? coords, ProtoId<CloningSettingsPrototype> settingsId, [NotNullWhen(true)] out EntityUid? clone)
{
clone = null;
- if (!_prototype.TryIndex(settingsId, out var settings))
+ if (!_prototype.Resolve(settingsId, out var settings))
return false; // invalid settings
if (!TryComp<HumanoidAppearanceComponent>(original, out var humanoid))
return false; // whatever body was to be cloned, was not a humanoid
- if (!_prototype.TryIndex(humanoid.Species, out var speciesPrototype))
+ if (!_prototype.Resolve(humanoid.Species, out var speciesPrototype))
return false; // invalid species
var attemptEv = new CloningAttemptEvent(settings);
return guide;
// If the graph doesn't actually exist, do nothing.
- if (!PrototypeManager.TryIndex(construction.Graph, out ConstructionGraphPrototype? graph))
+ if (!PrototypeManager.Resolve(construction.Graph, out ConstructionGraphPrototype? graph))
return null;
// If either the start node or the target node are missing, do nothing.
var ev = new BeforeForceSayEvent(component.ForceSayStringDataset);
RaiseLocalEvent(uid, ev);
- if (!_prototype.TryIndex(ev.Prefix, out var prefixList))
+ if (!_prototype.Resolve(ev.Prefix, out var prefixList))
return;
var suffix = Loc.GetString(_random.Pick(prefixList.Values));
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;
var percent = GetDamagePercent(ent);
if (ent.Comp.WasPenalized)
return;
- if (!_protoMan.TryIndex(ent.Comp.PenaltyBankAccount, out var accountInfo))
+ if (!_protoMan.Resolve(ent.Comp.PenaltyBankAccount, out var accountInfo))
return;
var multiplier = GetDeliveryMultiplier(ent);
if (SpawnAfter != 0)
{
// if it fails to get the spawner, this won't ever work so just return
- if (!system.PrototypeManager.TryIndex(TempEntityProtoId, out var tempSpawnerProto))
+ if (!system.PrototypeManager.Resolve(TempEntityProtoId, out var tempSpawnerProto))
return;
// spawn the spawner, assign it a lifetime, and assign the entity that it will spawn when despawned
return;
var targetProto = _random.Pick(plantholder.Seed.MutationPrototypes);
- _protoManager.TryIndex(targetProto, out SeedPrototype? protoSeed);
-
- if (protoSeed == null)
+ if (!_protoManager.TryIndex(targetProto, out SeedPrototype? protoSeed))
{
Log.Error($"Seed prototype could not be found: {targetProto}!");
return;
: 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);
}
{
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;
var puddleMod = Random.NextGaussian(ent.Comp.TilesPerSpillAverage, ent.Comp.TilesPerSpillStdDev);
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;
// if the prototype chosen isn't actually part of the selectable options, ignore it
if (curTime < entity.Comp.NextSpeakTime)
return;
- if (!_proto.TryIndex(entity.Comp.MessageSet, out var messages))
+ if (!_proto.Resolve(entity.Comp.MessageSet, out var messages))
return;
// Grab a random localized message from the set
{
var outfitPrototype = _proto.Index(outfit);
- _proto.TryIndex(outfitPrototype.Job, out var jobPrototype);
- _proto.TryIndex(outfitPrototype.StartingGear, out var startingGearPrototype);
+ _proto.Resolve(outfitPrototype.Job, out var jobPrototype);
+ _proto.Resolve(outfitPrototype.StartingGear, out var startingGearPrototype);
GetJobEquipmentInformation(jobPrototype, user, out var customRoleLoadout, out var defaultRoleLoadout, out var jobStartingGearPrototype);
if (jobPrototype == null)
return;
- _proto.TryIndex(jobPrototype.StartingGear, out jobStartingGearPrototype);
+ _proto.Resolve(jobPrototype.StartingGear, out jobStartingGearPrototype);
if (!TryComp<ActorComponent>(user, out var actorComponent))
return;
{
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);
}
var recipes = GetAvailableRecipes(uid, component, true);
foreach (var id in recipes)
{
- if (!_proto.TryIndex(id, out var proto))
+ if (!_proto.Resolve(id, out var proto))
continue;
foreach (var (mat, _) in proto.Materials)
{
if (ent.Comp.Group is null)
return;
- if (!_prototypeManager.TryIndex(ent.Comp.Group, out var group))
+ if (!_prototypeManager.Resolve(ent.Comp.Group, out var group))
return;
int id;
if (ent.Comp.LifeStage > ComponentLifeStage.Running)
return;
- if (!_prototypeManager.TryIndex(ent.Comp.Group, out var group))
+ if (!_prototypeManager.Resolve(ent.Comp.Group, out var group))
return;
var format = group.FullName ? "name-identifier-format-full" : "name-identifier-format-append";
SetSeed(uid, component, _random.Next());
}
- if (_proto.TryIndex(component.Template, out var biome))
+ if (_proto.Resolve(component.Template, out var biome))
SetTemplate(uid, component, biome);
var xform = Transform(uid);
if (!_config.GetCVar(CCVars.GameRoleWhitelist))
return true;
- if (!_prototypes.TryIndex(job, out var jobPrototype) ||
+ if (!_prototypes.Resolve(job, out var jobPrototype) ||
!jobPrototype.Whitelisted)
{
return true;
for (var i = 0; i < jobs.Count; i++)
{
- if (_prototypes.TryIndex(jobs[i], out var job)
+ if (_prototypes.Resolve(jobs[i], out var job)
&& JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes, (HumanoidCharacterProfile?) _preferencesManager.GetPreferences(userId).SelectedCharacter))
{
continue;
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;
PolymorphEntity(ent, prototype.Configuration);
if (target.Comp.PolymorphActions.ContainsKey(id))
return;
- if (!_proto.TryIndex(id, out var polyProto))
+ if (!_proto.Resolve(id, out var polyProto))
return;
var entProto = _proto.Index(polyProto.Configuration.Entity);
{
_system ??= GetSys<PolymorphSystem>();
- if (!_proto.TryIndex(protoId, out var prototype))
- return null;
+ var prototype = _proto.Index(protoId);
return _system.PolymorphEntity(input, prototype.Configuration);
}
/// </summary>
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;
var biomeSystem = _entManager.System<BiomeSystem>();
var roomConnections = new Dictionary<DungeonRoom, List<DungeonRoom>>();
var tileDef = _tileDefManager[gen.Tile];
- _prototype.TryIndex(gen.Flank, out var flankContents);
+ _prototype.Resolve(gen.Flank, out var flankContents);
var contents = _prototype.Index(gen.Contents);
foreach (var (room, border) in roomBorders)
var remapping = new Dictionary<EntProtoId, EntProtoId>();
// TODO: Move this to engine
- if (_prototype.TryIndex(gen.Entity, out var proto) &&
+ if (_prototype.Resolve(gen.Entity, out var proto) &&
proto.Components.TryGetComponent("EntityRemap", out var comps))
{
var remappingComp = (EntityRemapComponent) comps;
private void OnInit(EntityUid uid, RadiationProtectionComponent component, ComponentInit args)
{
- if (!_prototypeManager.TryIndex(component.RadiationProtectionModifierSetId, out var modifier))
+ if (!_prototypeManager.Resolve(component.RadiationProtectionModifierSetId, out var modifier))
return;
var buffComp = EnsureComp<DamageProtectionBuffComponent>(uid);
// add the damage modifier if it isn't in the dict yet
name = FormattedMessage.EscapeText(name);
SpeechVerbPrototype speech;
- if (evt.SpeechVerb != null && _prototype.TryIndex(evt.SpeechVerb, out var evntProto))
+ if (evt.SpeechVerb != null && _prototype.Resolve(evt.SpeechVerb, out var evntProto))
speech = evntProto;
else
speech = _chat.GetSpeechVerb(messageSource, message);
if (!Player.TryGetSessionById(mind.UserId, out var session))
return;
- if (!_proto.TryIndex(mind.RoleType, out var proto))
+ if (!_proto.Resolve(mind.RoleType, out var proto))
return;
var roleText = Loc.GetString(proto.Name);
var dungeonProtoId = _random.Pick(group.Protos);
- if (!_protoManager.TryIndex(dungeonProtoId, out var dungeonProto))
+ if (!_protoManager.Resolve(dungeonProtoId, out var dungeonProto))
{
return false;
}
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()));
}
}
// Configure special components
- if (Prototypes.TryIndex(ent.Comp.SelectedBorgType, out var previousPrototype))
+ if (Prototypes.Resolve(ent.Comp.SelectedBorgType, out var previousPrototype))
{
if (previousPrototype.AddComponents is { } removeComponents)
EntityManager.RemoveComponents(ent, removeComponents);
// If it's just a spawn pref check if it's for cryo (silly).
if (args.HumanoidCharacterProfile?.SpawnPriority != SpawnPriorityPreference.Cryosleep &&
- (!_proto.TryIndex(args.Job, out var jobProto) || jobProto.JobEntity == null))
+ (!_proto.Resolve(args.Job, out var jobProto) || jobProto.JobEntity == null))
{
return;
}
if (!player.HasValue)
return;
- if (!_prototypeManager.TryIndex(msg.ProtoId, out var proto) || proto.ChatTriggers.Count == 0)
+ if (!_prototypeManager.Resolve(msg.ProtoId, out var proto) || proto.ChatTriggers.Count == 0)
return;
_chat.TryEmoteWithChat(player.Value, msg.ProtoId);
occupiedTiles = [];
neighbors = [];
// TODO remove occupiedTiles -- its currently unused and just slows this method down.
- if (!_prototype.TryIndex(prototype, out var spreaderPrototype))
+ if (!_prototype.Resolve(prototype, out var spreaderPrototype))
return;
if (!TryComp<MapGridComponent>(comp.GridUid, out var grid))
if (!(priority == selectedPriority || selectedPriority is null))
continue;
- if (!_prototypeManager.TryIndex(jobId, out var job))
+ if (!_prototypeManager.Resolve(jobId, out var job))
continue;
if (!job.CanBeAntag && (!_player.TryGetSessionById(player, out var session) || antagBlocked.Contains(session)))
EntityUid? station,
EntityUid? entity = null)
{
- _prototypeManager.TryIndex(job ?? string.Empty, out var prototype);
+ _prototypeManager.Resolve(job, out var prototype);
RoleLoadout? loadout = null;
// Need to get the loadout up-front to handle names if we use an entity spawn override.
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;
foreach (var jobSpecial in prototype.Special)
_cardSystem.TryChangeFullName(cardId, characterName, card);
_cardSystem.TryChangeJobTitle(cardId, jobPrototype.LocalizedName, card);
- if (_prototypeManager.TryIndex(jobPrototype.Icon, out var jobIcon))
+ if (_prototypeManager.Resolve(jobPrototype.Icon, out var jobIcon))
_cardSystem.TryChangeJobIcon(cardId, jobIcon, card);
var extendedAccess = false;
return;
}
- if (!_prototype.TryIndex(randomLimitedEvent, out _))
+ if (!_prototype.Resolve(randomLimitedEvent, out _))
{
Log.Warning("A requested event is not available!");
return;
foreach (var eventid in selectedEvents)
{
- if (!_prototype.TryIndex(eventid, out var eventproto))
+ if (!_prototype.Resolve(eventid, out var eventproto))
{
Log.Warning("An event ID has no prototype index!");
continue;
var accessIds = new HashSet<ProtoId<AccessLevelPrototype>>();
foreach (var group in chosen)
{
- if (_prototype.TryIndex(group, out var proto))
+ if (_prototype.Resolve(group, out var proto))
accessIds.UnionWith(proto.Tags);
}
return;
}
- if (!_prototypeManager.TryIndex<DeviceFrequencyPrototype>(component.AvailableNetworks[args.Network],
+ if (!_prototypeManager.Resolve<DeviceFrequencyPrototype>(component.AvailableNetworks[args.Network],
out var frequency))
{
return;
return;
}
- if (!_prototypeManager.TryIndex<DeviceFrequencyPrototype>(component.AvailableNetworks[args.Network],
+ if (!_prototypeManager.Resolve<DeviceFrequencyPrototype>(component.AvailableNetworks[args.Network],
out var frequency))
{
return;
name = FormattedMessage.EscapeText(name);
SpeechVerbPrototype speech;
- if (ev.SpeechVerb != null && _prototype.TryIndex(ev.SpeechVerb, out var evntProto))
+ if (ev.SpeechVerb != null && _prototype.Resolve(ev.SpeechVerb, out var evntProto))
speech = evntProto;
else
speech = _chat.GetSpeechVerb(messageSource, message);
/// </summary>
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;
if (!catalog.Cost.TryGetValue(TelecrystalCurrencyPrototype, out var cost))
{
// Check if player's job allows to apply traits
if (args.JobId == null ||
- !_prototypeManager.TryIndex<JobPrototype>(args.JobId ?? string.Empty, out var protoJob) ||
+ !_prototypeManager.Resolve<JobPrototype>(args.JobId, out var protoJob) ||
!protoJob.ApplyTraits)
{
return;
{
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;
}
message = Loc.GetString(ent.Comp.Text);
else
{
- if (!_prototypeManager.TryIndex(ent.Comp.Pack, out var messagePack))
+ if (!_prototypeManager.Resolve(ent.Comp.Pack, out var messagePack))
return;
message = Loc.GetString(_random.Pick(messagePack.Values));
}
List<IWireAction> wireActions = new();
var dummyWires = 0;
- if (!_protoMan.TryIndex(wires.LayoutId, out WireLayoutPrototype? layoutPrototype))
+ if (!_protoMan.Resolve(wires.LayoutId, out WireLayoutPrototype? layoutPrototype))
{
return;
}
if (args.Handled)
return;
- _protoManager.TryIndex(component.EmoteSoundsId, out var sounds);
+ _protoManager.Resolve(component.EmoteSoundsId, out var sounds);
args.Handled = _chat.TryPlayEmoteSound(uid, sounds, args.Emote);
}
{
public void AddGroup(ProtoId<AccessGroupPrototype> group)
{
- if (!PrototypeManager.TryIndex<AccessGroupPrototype>(group, out var groupPrototype))
+ if (!PrototypeManager.Resolve<AccessGroupPrototype>(group, out var groupPrototype))
return;
Tags.UnionWith(groupPrototype.Tags);
/// </summary>
[DataField]
[AutoNetworkedField]
- public ProtoId<AccessLevelPrototype>? JobPrototype;
+ public ProtoId<JobPrototype>? JobPrototype;
/// <summary>
/// The proto IDs of the departments associated with the job
using Content.Shared.Access.Systems;
using Content.Shared.Containers.ItemSlots;
+using Content.Shared.Roles;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
public readonly string FullName;
public readonly string JobTitle;
public readonly List<ProtoId<AccessLevelPrototype>> AccessList;
- public readonly ProtoId<AccessLevelPrototype> JobPrototype;
+ public readonly ProtoId<JobPrototype> JobPrototype;
- public WriteToTargetIdMessage(string fullName, string jobTitle, List<ProtoId<AccessLevelPrototype>> accessList, ProtoId<AccessLevelPrototype> jobPrototype)
+ public WriteToTargetIdMessage(string fullName, string jobTitle, List<ProtoId<AccessLevelPrototype>> accessList, ProtoId<JobPrototype> jobPrototype)
{
FullName = fullName;
JobTitle = jobTitle;
public readonly string? TargetIdJobTitle;
public readonly List<ProtoId<AccessLevelPrototype>>? TargetIdAccessList;
public readonly List<ProtoId<AccessLevelPrototype>>? AllowedModifyAccessList;
- public readonly ProtoId<AccessLevelPrototype> TargetIdJobPrototype;
+ public readonly ProtoId<JobPrototype> TargetIdJobPrototype;
public IdCardConsoleBoundUserInterfaceState(bool isPrivilegedIdPresent,
bool isPrivilegedIdAuthorized,
string? targetIdJobTitle,
List<ProtoId<AccessLevelPrototype>>? targetIdAccessList,
List<ProtoId<AccessLevelPrototype>>? allowedModifyAccessList,
- ProtoId<AccessLevelPrototype> targetIdJobPrototype,
+ ProtoId<JobPrototype> targetIdJobPrototype,
string privilegedIdName,
string targetIdName)
{
// Add all tags in groups to the list of tags.
foreach (var group in component.Groups)
{
- if (!_prototypeManager.TryIndex<AccessGroupPrototype>(group, out var proto))
+ if (!_prototypeManager.Resolve<AccessGroupPrototype>(group, out var proto))
continue;
component.Tags.UnionWith(proto.Tags);
foreach (var group in newGroups)
{
- if (!_prototypeManager.TryIndex<AccessGroupPrototype>(group, out var proto))
+ if (!_prototypeManager.Resolve<AccessGroupPrototype>(group, out var proto))
continue;
access.Tags.UnionWith(proto.Tags);
if (ent.Comp.NumberOfPipeLayers <= 1 || ent.Comp.PipeLayersLocked)
return;
- if (!_protoManager.TryIndex(ent.Comp.Tool, out var toolProto))
+ if (!_protoManager.Resolve(ent.Comp.Tool, out var toolProto))
return;
var user = args.User;
if (!TryGetHeldTool(args.User, ent.Comp.Tool, out var tool))
{
- if (_protoManager.TryIndex(ent.Comp.Tool, out var toolProto))
+ if (_protoManager.Resolve(ent.Comp.Tool, out var toolProto))
{
var toolName = Loc.GetString(toolProto.ToolName).ToLower();
var message = Loc.GetString("atmos-pipe-layers-component-tool-missing", ("toolName", toolName));
private void OnSetBarSignMessage(Entity<BarSignComponent> ent, ref SetBarSignMessage args)
{
- if (!_prototypeManager.TryIndex(args.Sign, out var signPrototype))
+ if (!_prototypeManager.Resolve(args.Sign, out var signPrototype))
return;
SetBarSign(ent, signPrototype);
}
// TODO probably cache this or something. humans get hurt a lot
- if (!_prototypeManager.TryIndex(ent.Comp.DamageBleedModifiers, out var modifiers))
+ if (!_prototypeManager.Resolve(ent.Comp.DamageBleedModifiers, out var modifiers))
return;
// some reagents may deal and heal different damage types in the same tick, which means DamageIncreased will be true
if (_name.Trim().Length != 0)
return _name;
- if (IoCManager.Resolve<IPrototypeManager>().TryIndex(Product, out EntityPrototype? prototype))
+ if (IoCManager.Resolve<IPrototypeManager>().Resolve(Product, out EntityPrototype? prototype))
{
_name = prototype.Name;
}
if (_description.Trim().Length != 0)
return _description;
- if (IoCManager.Resolve<IPrototypeManager>().TryIndex(Product, out EntityPrototype? prototype))
+ if (IoCManager.Resolve<IPrototypeManager>().Resolve(Product, out EntityPrototype? prototype))
{
_description = prototype.Description;
}
protected void UpdateVisuals(EntityUid uid, ChameleonClothingComponent component)
{
if (string.IsNullOrEmpty(component.Default) ||
- !_proto.TryIndex(component.Default, out EntityPrototype? proto))
+ !_proto.Resolve(component.Default, out EntityPrototype? proto))
return;
// world sprite icon
{
EntProtoId? proto = null;
- if (_protoMan.TryIndex(loadout.StartingGear, out var gear))
+ if (_protoMan.Resolve(loadout.StartingGear, out var gear))
{
proto = GetFirstOrNull(gear);
}
if (count == 1)
{
- if (gear.Equipment.Count == 1 && _protoMan.TryIndex<EntityPrototype>(gear.Equipment.Values.First(), out var proto))
+ if (gear.Equipment.Count == 1 && _protoMan.Resolve(gear.Equipment.Values.First(), out var proto))
{
return proto.ID;
}
- if (gear.Inhand.Count == 1 && _protoMan.TryIndex<EntityPrototype>(gear.Inhand[0], out proto))
+ if (gear.Inhand.Count == 1 && _protoMan.Resolve(gear.Inhand[0], out proto))
{
return proto.ID;
}
public string GetName(LoadoutPrototype loadout)
{
- if (loadout.DummyEntity is not null && _protoMan.TryIndex<EntityPrototype>(loadout.DummyEntity, out var proto))
+ if (loadout.DummyEntity is not null && _protoMan.Resolve(loadout.DummyEntity, out var proto))
return proto.Name;
- if (_protoMan.TryIndex(loadout.StartingGear, out var gear))
+ if (_protoMan.Resolve(loadout.StartingGear, out var gear))
{
return GetName(gear);
}
foreach (var entity in spawns)
{
- if (_proto.TryIndex(entity, out var entProto))
+ if (_proto.Resolve(entity, out var entProto))
{
EntityManager.AddComponents(ent, entProto.Components);
}
materials[mat] += matAmount * amount * coefficient;
}
}
- else if (_prototype.TryIndex(defaultProtoId, out var defaultProto) &&
+ else if (_prototype.Resolve(defaultProtoId, out var defaultProto) &&
defaultProto.TryGetComponent<PhysicalCompositionComponent>(out var physComp, EntityManager.ComponentFactory))
{
foreach (var (mat, matAmount) in physComp.MaterialComposition)
if (args.Container.ID != ent.Comp.Container || _timing.ApplyingState)
return;
- if (_proto.TryIndex(ent.Comp.Proto, out var entProto))
+ if (_proto.Resolve(ent.Comp.Proto, out var entProto))
{
EntityManager.RemoveComponents(args.Entity, entProto.Components);
}
if (args.Container.ID != ent.Comp.Container || _timing.ApplyingState)
return;
- if (_proto.TryIndex(ent.Comp.Proto, out var entProto))
+ if (_proto.Resolve(ent.Comp.Proto, out var entProto))
{
EntityManager.AddComponents(args.Entity, entProto.Components);
}
private void DamageableInit(EntityUid uid, DamageableComponent component, ComponentInit _)
{
if (component.DamageContainerID != null &&
- _prototypeManager.TryIndex<DamageContainerPrototype>(component.DamageContainerID,
+ _prototypeManager.Resolve<DamageContainerPrototype>(component.DamageContainerID,
out var damageContainerPrototype))
{
// Initialize damage dictionary, using the types and groups from the damage
if (!ignoreResistances)
{
if (damageable.DamageModifierSetId != null &&
- _prototypeManager.TryIndex<DamageModifierSetPrototype>(damageable.DamageModifierSetId, out var modifierSet))
+ _prototypeManager.Resolve<DamageModifierSetPrototype>(damageable.DamageModifierSetId, out var modifierSet))
{
// TODO DAMAGE PERFORMANCE
// use a local private field instead of creating a new dictionary here..
IoCManager.Resolve(ref prototypeManager);
var speciesProto = prototypeManager.Index<SpeciesPrototype>(species);
if (
- !prototypeManager.TryIndex(speciesProto.SpriteSet, out var baseSprites) ||
+ !prototypeManager.Resolve(speciesProto.SpriteSet, out var baseSprites) ||
!baseSprites.Sprites.TryGetValue(layer, out var spriteName) ||
- !prototypeManager.TryIndex(spriteName, out HumanoidSpeciesSpriteLayer? sprite) ||
+ !prototypeManager.Resolve(spriteName, out HumanoidSpeciesSpriteLayer? sprite) ||
sprite == null ||
!sprite.MarkingsMatchSkin
)
}
if (string.IsNullOrEmpty(humanoid.Initial)
- || !_proto.TryIndex(humanoid.Initial, out HumanoidProfilePrototype? startingSet))
+ || !_proto.Resolve(humanoid.Initial, out HumanoidProfilePrototype? startingSet))
{
LoadProfile(uid, HumanoidCharacterProfile.DefaultWithSpecies(humanoid.Species), humanoid);
return;
if (!Resolve(uid, ref humanoid))
return;
- if (!_proto.TryIndex<SpeciesPrototype>(humanoid.Species, out var species))
+ if (!_proto.Resolve<SpeciesPrototype>(humanoid.Species, out var species))
{
return;
}
if (!_light.TryGetLight(uid, out var light))
return;
- if (_prototypeManager.TryIndex(component.EmaggedColorsPrototype, out var possibleColors))
+ if (_prototypeManager.Resolve(component.EmaggedColorsPrototype, out var possibleColors))
{
var pick = _random.Pick(possibleColors.Colors.Values);
_light.SetColor(uid, pick, light);
if (!TryComp<FoodSequenceStartPointComponent>(args.Start, out var start))
return;
- if (!_proto.TryIndex(args.Proto, out var elementProto))
+ if (!_proto.Resolve(args.Proto, out var elementProto))
return;
if (!ent.Comp.OnlyFinal || elementProto.Final || start.FoodLayers.Count == start.MaxLayers)
//looking for a suitable FoodSequence prototype
if (!element.Comp1.Entries.TryGetValue(start.Comp.Key, out var elementProto))
return false;
-
- if (!_proto.TryIndex(elementProto, out var elementIndexed))
+ if (!_proto.Resolve(elementProto, out var elementIndexed))
return false;
//if we run out of space, we can still put in one last, final finishing element.
var nameCounter = 1;
foreach (var proto in existedContentNames)
{
- if (!_proto.TryIndex(proto, out var protoIndexed))
+ if (!_proto.Resolve(proto, out var protoIndexed))
continue;
if (protoIndexed.Name is null)
switch (component.CurrentThreshold)
{
case HungerThreshold.Overfed:
- _prototype.TryIndex(HungerIconOverfedId, out prototype);
+ _prototype.Resolve(HungerIconOverfedId, out prototype);
break;
case HungerThreshold.Peckish:
- _prototype.TryIndex(HungerIconPeckishId, out prototype);
+ _prototype.Resolve(HungerIconPeckishId, out prototype);
break;
case HungerThreshold.Starving:
- _prototype.TryIndex(HungerIconStarvingId, out prototype);
+ _prototype.Resolve(HungerIconStarvingId, out prototype);
break;
default:
prototype = null;
switch (component.CurrentThirstThreshold)
{
case ThirstThreshold.OverHydrated:
- _prototype.TryIndex(ThirstIconOverhydratedId, out prototype);
+ _prototype.Resolve(ThirstIconOverhydratedId, out prototype);
break;
case ThirstThreshold.Thirsty:
- _prototype.TryIndex(ThirstIconThirstyId, out prototype);
+ _prototype.Resolve(ThirstIconThirstyId, out prototype);
break;
case ThirstThreshold.Parched:
- _prototype.TryIndex(ThirstIconParchedId, out prototype);
+ _prototype.Resolve(ThirstIconParchedId, out prototype);
break;
default:
{
var lastIngredient = ingredients[ingredients.Count - 1];
- if (!protoMan.TryIndex(lastIngredient.Proto, out var protoIndexed))
+ if (!protoMan.Resolve(lastIngredient.Proto, out var protoIndexed))
return false;
foreach (var tag in Tags)
if (ingredients.Count < ElementNumber + 1)
return false;
- if (!protoMan.TryIndex(ingredients[ElementNumber].Proto, out var protoIndexed))
+ if (!protoMan.Resolve(ingredients[ElementNumber].Proto, out var protoIndexed))
return false;
foreach (var tag in Tags)
var count = 0;
foreach (var ingredient in ingredients)
{
- if (!protoMan.TryIndex(ingredient.Proto, out var protoIndexed))
+ if (!protoMan.Resolve(ingredient.Proto, out var protoIndexed))
continue;
var allowed = false;
// Category not found so dump it.
TraitCategoryPrototype? traitCategory = null;
- if (category != null && !protoManager.TryIndex(category, out traitCategory))
+ if (category != null && !protoManager.Resolve(category, out traitCategory))
return new(this);
var list = new HashSet<ProtoId<TraitPrototype>>(_traitPreferences) { traitId };
}
// No category so dump it.
- if (!protoManager.TryIndex(traitProto.Category, out var category))
+ if (!protoManager.Resolve(traitProto.Category, out var category))
continue;
var existing = groups.GetOrNew(category.ID);
var name = Loc.GetString(prototype.SetName);
if (prototype.Prototype != null &&
- _protoManager.TryIndex(prototype.Prototype, out var proto))
+ _protoManager.Resolve(prototype.Prototype, out var proto))
name = proto.Name;
msg = Loc.GetString("rcd-component-examine-build-details", ("name", name));
var deconstructedTile = _mapSystem.GetTileRef(gridUid.Value, mapGrid, location);
var protoName = !_turf.IsSpace(deconstructedTile) ? _deconstructTileProto : _deconstructLatticeProto;
- if (_protoManager.TryIndex(protoName, out var deconProto))
+ if (_protoManager.Resolve(protoName, out var deconProto))
{
cost = deconProto.Cost;
delay = deconProto.Delay;
var formattedDeptDiff = ContentLocalizationManager.FormatPlaytime(deptDiffSpan);
var nameDepartment = "role-timer-department-unknown";
- if (protoManager.TryIndex(Department, out var departmentIndexed))
+ if (protoManager.Resolve(Department, out var departmentIndexed))
{
nameDepartment = departmentIndexed.Name;
}
prototype = null;
MindTryGetJobId(mindId, out var protoId);
- return _prototypes.TryIndex(protoId, out prototype) || prototype is not null;
+ return _prototypes.Resolve(protoId, out prototype) || prototype is not null;
}
public bool MindTryGetJobId(
return;
}
- if (!_prototypes.TryIndex(protoId, out var protoEnt))
+ if (!_prototypes.Resolve(protoId, out var protoEnt))
{
Log.Error($"Failed to add role {protoId} to {ToPrettyString(mindId)} : Role prototype does not exist");
return;
protected void UpdateEntityAppearance(Entity<BorgSwitchableTypeComponent> entity)
{
- if (!Prototypes.TryIndex(entity.Comp.SelectedBorgType, out var proto))
+ if (!Prototypes.Resolve(entity.Comp.SelectedBorgType, out var proto))
return;
UpdateEntityAppearance(entity, proto);
private void OnStationAiCustomization(Entity<StationAiCoreComponent> entity, ref StationAiCustomizationMessage args)
{
- if (!_protoManager.TryIndex(args.GroupProtoId, out var groupPrototype) || !_protoManager.TryIndex(args.CustomizationProtoId, out var customizationProto))
+ if (!_protoManager.Resolve(args.GroupProtoId, out var groupPrototype) || !_protoManager.Resolve(args.CustomizationProtoId, out var customizationProto))
return;
if (!TryGetHeld((entity, entity.Comp), out var held))
if (!entity.Comp.ProtoIds.TryGetValue(_stationAiHologramCustomGroupProtoId, out var protoId))
return;
- if (!_protoManager.TryIndex(protoId, out var prototype))
+ if (!_protoManager.Resolve(protoId, out var prototype))
return;
if (!prototype.LayerData.TryGetValue(StationAiState.Hologram.ToString(), out var layerData))
if (!TryComp<StationAiCustomizationComponent>(stationAi, out var stationAiCustomization) ||
!stationAiCustomization.ProtoIds.TryGetValue(_stationAiCoreCustomGroupProtoId, out var protoId) ||
- !_protoManager.TryIndex(protoId, out var prototype) ||
+ !_protoManager.Resolve(protoId, out var prototype) ||
!prototype.LayerData.TryGetValue(state.ToString(), out var layerData))
{
return;
if (ent.Comp.Group is not { } group
|| !painter.StylesByGroup.TryGetValue(group, out var selectedStyle)
- || !Proto.TryIndex(group, out PaintableGroupPrototype? targetGroup))
+ || !Proto.Resolve(group, out PaintableGroupPrototype? targetGroup))
return;
// Valid paint target.
name = loadout.EntityName;
}
- if (string.IsNullOrEmpty(name) && PrototypeManager.TryIndex(roleProto.NameDataset, out var nameData))
+ if (string.IsNullOrEmpty(name) && PrototypeManager.Resolve(roleProto.NameDataset, out var nameData))
{
name = Loc.GetString(_random.Pick(nameData.Values));
}
/// </summary>
public void EquipStartingGear(EntityUid entity, ProtoId<StartingGearPrototype>? startingGear, bool raiseEvent = true)
{
- PrototypeManager.TryIndex(startingGear, out var gearProto);
+ PrototypeManager.Resolve(startingGear, out var gearProto);
EquipStartingGear(entity, gearProto, raiseEvent);
}
{
foreach (var items in group.Value)
{
- if (!PrototypeManager.TryIndex(items.Prototype, out var loadoutPrototype))
+ if (!PrototypeManager.Resolve(items.Prototype, out var loadoutPrototype))
return null;
var gear = ((IEquipmentLoadout) loadoutPrototype).GetGear(slot);
public bool CanAddStatusEffect(EntityUid uid, EntProtoId effectProto)
{
- if (!_proto.TryIndex(effectProto, out var effectProtoData))
+ if (!_proto.Resolve(effectProto, out var effectProtoData))
return false;
if (!effectProtoData.TryGetComponent<StatusEffectComponent>(out var effectProtoComp, Factory))
foreach (var entity in storage.Container.ContainedEntities)
{
if (!_itemQuery.TryGetComponent(entity, out var itemComp) ||
- !_prototypeManager.TryIndex(itemComp.Size, out var itemSize))
+ !_prototypeManager.Resolve(itemComp.Size, out var itemSize))
{
continue;
}
{
if (entity == args.User
|| !_itemQuery.TryGetComponent(entity, out var itemComp) // Need comp to get item size to get weight
- || !_prototype.TryIndex(itemComp.Size, out var itemSize)
+ || !_prototype.Resolve(itemComp.Size, out var itemSize)
|| !CanInsert(uid, entity, out _, storageComp, item: itemComp)
|| !_interactionSystem.InRangeUnobstructed(args.User, entity))
{
// If we specify a max item size, use that
if (uid.Comp.MaxItemSize != null)
{
- if (_prototype.TryIndex(uid.Comp.MaxItemSize.Value, out var proto))
+ if (_prototype.Resolve(uid.Comp.MaxItemSize.Value, out var proto))
return proto;
Log.Error($"{ToPrettyString(uid.Owner)} tried to get invalid item size prototype: {uid.Comp.MaxItemSize.Value}. Stack trace:\\n{Environment.StackTrace}");
public bool TryGenerateStoryFromTemplate(ProtoId<StoryTemplatePrototype> template, [NotNullWhen(true)] out string? story, int? seed = null)
{
// Get the story template prototype from the ID
- if (!_protoMan.TryIndex(template, out var templateProto))
+ if (!_protoMan.Resolve(template, out var templateProto))
{
story = null;
return false;
foreach (var (name, list) in templateProto.Variables)
{
// Get the prototype for the world list dataset
- if (!_protoMan.TryIndex(list, out var listProto))
+ if (!_protoMan.Resolve(list, out var listProto))
continue; // Missed one, but keep going with the rest of the story
// Pick a random word from the dataset and localize it