#NullReferenceException although nothing is null
12 messages · Page 1 of 1 (latest)
[Error : Unity Log] NullReferenceException: Object reference not set to an instance of an object
Stack trace:
EnableAllEnemies.Patches.SpawnEnemiesAtStart.SpawnEnemyAtRandomLocation (System.String EnemyName, System.Int32 Amount) (at <56bdb0482cf8499298a7a23639f7593b>:0)
EnableAllEnemies.Patches.EnableEnemies.ModifyLevel (SelectableLevel& newLevel) (at <56bdb0482cf8499298a7a23639f7593b>:0)
(wrapper dynamic-method) RoundManager.DMDRoundManager::LoadNewLevel(RoundManager,int,SelectableLevel)
StartOfRound+<OpenShipDoors>d__263.MoveNext () (at <0b5b829887344817a21214132ea92eef>:0)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <e27997765c1848b09d8073e5d642717a>:0)
Can I post code here?
EnableEnemies.cs where it tries to spawn the jester:
namespace EnableAllEnemies.Patches
{
[HarmonyPatch(typeof(RoundManager))]
internal class EnableEnemies
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
static void RoundManagerStart(RoundManager __instance)
{
EAE.Instance.CurrentRound = __instance;
}
[HarmonyPatch(nameof(RoundManager.LoadNewLevel))]
[HarmonyPrefix]
static void ModifyLevel(ref SelectableLevel newLevel)
{
newLevel.Enemies = EAE.Instance.FixIndoorEnemySpawns();
newLevel.OutsideEnemies = EAE.Instance.FixOutdoorEnemySpawns();
EAE.Instance.CurrentLevel = newLevel;
bool spawned = false;
while (!spawned)
{
if(EAE.Instance.CurrentRound != null && EAE.Instance.CurrentLevel != null)
{
SpawnEnemiesAtStart.SpawnEnemyAtRandomLocation("Jester", 5);
spawned = true;
}
else
{
EAE.Instance.mls.LogError("Error tryin to spawn Jesters");
}
Thread.Sleep(100);
}
}
}
}
SpawnEnemiesAtStart.cs where it spawns the enemies: