Decouple GasPrototype IDs from Gas Enum (#41266)
* Remove final enum coupling from gas YAML * Fix comment * Fix test * Apply suggestions from code review --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using Content.Shared.Atmos.Components;
|
||||
using Content.Shared.Atmos.Prototypes;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Systems;
|
||||
@@ -25,10 +24,17 @@ namespace Content.Shared.Atmos.EntitySystems
|
||||
|
||||
InitializeBreathTool();
|
||||
|
||||
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
|
||||
foreach (var gas in Enum.GetValues<Gas>())
|
||||
{
|
||||
GasPrototypes[i] = _prototypeManager.Index<GasPrototype>(i.ToString());
|
||||
GasReagents[i] = GasPrototypes[i].Reagent;
|
||||
var idx = (int)gas;
|
||||
// Log an error if the corresponding prototype isn't found
|
||||
if (!_prototypeManager.TryIndex<GasPrototype>(gas.ToString(), out var gasPrototype))
|
||||
{
|
||||
Log.Error($"Failed to find corresponding {nameof(GasPrototype)} for gas ID {(int)gas} ({gas}) with expected ID \"{gas.ToString()}\". Is your prototype named correctly?");
|
||||
continue;
|
||||
}
|
||||
GasPrototypes[idx] = gasPrototype;
|
||||
GasReagents[idx] = gasPrototype.Reagent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user