static IEnumerator initPrefab() { if (stasisSpherePrefab) { yield break; } if (alreadyInit || !(alreadyInit = true)) // to avoid simultaneous initialization { yield return(new WaitUntil(() => stasisSpherePrefab)); yield break; } #if GAME_BZ #pragma warning disable CS0612 // TechType.StasisRifle is obsolete in BZ #endif var task = PrefabUtils.getPrefabAsync(TechType.StasisRifle); #if GAME_BZ #pragma warning restore CS0612 #endif yield return(task); var stasisRiflePrefab = task.GetResult(); if (!stasisRiflePrefab) { "StasisExplosion.initPrefab: invalid prefab for StasisRifle!".logError(); yield break; } stasisSpherePrefab = PrefabUtils.storePrefabCopy(stasisRiflePrefab.GetComponent <StasisRifle>()?.effectSpherePrefab); }
public static void initPrefab(GameObject gasTorpedoPrefab) { if (torpedoType != null) { return; } if (!gasTorpedoPrefab) { "StasisTorpedo.initPrefab: invalid prefab for GasTorpedo!".logError(); return; } var explosionPrefab = new GameObject("StasisExplosion", typeof(StasisExplosion)); SMLHelper.V2.Assets.ModPrefabCache.AddPrefab(explosionPrefab, false); var torpedoPrefab = PrefabUtils.storePrefabCopy(gasTorpedoPrefab); torpedoPrefab.GetComponent <SeamothTorpedo>().explosionPrefab = explosionPrefab; torpedoType = new() { techType = TechType, prefab = torpedoPrefab }; } }