static bool Prefix(BombGenerator __instance, BombFace selectedFace, BombComponent bombComponentPrefab, GeneratorSetting settings) { var bomb = __instance.GetValue <Bomb>("bomb"); var type = bombComponentPrefab.ComponentType; // Let the timer component spawn normally and record the bomb's information. if (type == ComponentTypeEnum.Timer) { allBombInfo.Add(bomb, new BombInfo(settings, selectedFace, __instance.GetValue <Random>("rand"))); void logCallback(string condition, string _, LogType __) { if (!condition.StartsWith("[BombGenerator] Bomb component list: ")) { return; } // Replace the Random object with a fake one, so that we can make the consistent RNG calls later. __instance.SetValue("rand", new FakeRandom()); Application.logMessageReceived -= logCallback; } Application.logMessageReceived += logCallback; return(true); } // If we don't have information about a bomb, just let it go through. if (!allBombInfo.TryGetValue(bomb, out BombInfo bombInfo)) { return(true); } // Once we're ready to instantiate the components, this allows us to call the original method again. if (bombInfo.EnableOriginal) { return(true); } // If the generator is trying to fill the bomb with empty components, clear the valid faces to skip over it. if (type == ComponentTypeEnum.Empty) { __instance.GetValue <List <BombFace> >("validBombFaces").Clear(); return(false); } // Start loading any fake modules. if (bombComponentPrefab.GetComponent <FakeModule>() != null) { __instance.StartCoroutine(LoadModule(bombComponentPrefab, bombInfo)); } else { bombInfo.Components.Add(bombComponentPrefab); } return(false); }
static bool Prefix(BombGenerator __instance, BombFace selectedFace, BombComponent bombComponentPrefab, GeneratorSetting settings) { var bomb = __instance.GetValue <Bomb>("bomb"); var type = bombComponentPrefab.ComponentType; // Let the timer component spawn normally and record the bomb's information. if (type == ComponentTypeEnum.Timer) { allBombInfo.Add(bomb, new BombInfo(settings, selectedFace, __instance.GetValue <Random>("rand"))); return(true); } // If we don't have information about a bomb, just let it go through. if (!allBombInfo.TryGetValue(bomb, out BombInfo bombInfo)) { return(true); } // Once we're ready to instantiate the components, this allows us to call the original method again. if (bombInfo.EnableOriginal) { return(true); } // If the generator is trying to fill the bomb with empty components, clear the valid faces to skip over it. if (type == ComponentTypeEnum.Empty) { __instance.GetValue <List <BombFace> >("validBombFaces").Clear(); return(false); } // Start loading any fake modules. if (bombComponentPrefab.GetComponent <FakeModule>() != null) { __instance.StartCoroutine(LoadModule(bombComponentPrefab, bombInfo)); } else { bombInfo.Components.Add(bombComponentPrefab); } return(false); }