Registering an enemy with rarity table method does not add the enemy to the spawn list
Closed this issue · 0 comments
Heya! I seem to have spotted an issue where the non-default overloads for registering an enemy, specifically with rarity tables does not add an enemy after all if it hasn't already been registered. I don't think this is intended functionality?
LethalLib/LethalLib/Modules/Enemies.cs
Lines 372 to 405 in 553a3b4
At the end of this method call compared to the the base rarity overload method, the enemy is not added/registered to the list of enemies via spawnableEnemies.Add(spawnableEnemy)
.
This means that to register an enemy, it must always be done through the non rarity table enabled method first. A possible workaround for this can be seen below.
// Register our enemy with no levels so it shows up in the debug menu.
// This is a bug/issue in LethalLib that doesn't register the enemy correctly outside of the base overload
// https://github.com/EvaisaDev/LethalLib/blob/main/LethalLib/Modules/Enemies.cs#L372-L405
// Reference the fact that spawnableEnemies.Add(spawnableEnemy) is not called at the end of this method.
Enemies.RegisterEnemy(
lockerEnemy,
Locker.Config.LockerSpawnWeight.Value,
Levels.LevelTypes.None,
Enemies.SpawnType.Default,
lockerTerminalNode,
lockerTerminalKeyword
);
// Need to do this to not keep the none level type registered.
Enemies.RemoveEnemyFromLevels(lockerEnemy, Levels.LevelTypes.None);
// Register our enemy and set spawn options from the config.
Enemies.RegisterEnemy(
lockerEnemy,
Enemies.SpawnType.Default,
new Dictionary<Levels.LevelTypes, int>
{
[Levels.LevelTypes.ExperimentationLevel] = Locker.Config.LockerSpawnWeight.Value
},
levelWeightOverrides,
lockerTerminalNode,
lockerTerminalKeyword
);
As a proposed solution, we should check if the enemy with that name/identifier has already been registered. If not, it should be registered at the end of the method.