diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index 91428a7e..7730a7c9 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -24,6 +24,18 @@ namespace NewHorizons.Builder.Props meteorLauncher._detectableField = null; meteorLauncher._launchDirection = Vector3.up; meteorLauncher._dynamicProbability = 0f; + var meteorPrefab = meteorLauncher._meteorPrefab.InstantiateInactive().Rename("Prefab_VM_MoltenMeteor").DontDestroyOnLoad(); + var meteor = meteorPrefab.GetComponent(); + GameObject.DestroyImmediate(meteorPrefab.FindChild("ConstantDetectors")); + var detectors = meteorPrefab.FindChild("DynamicDetector"); + var rigidbody = meteor.GetComponent(); + meteor._owRigidbody = rigidbody; + meteor._constantFluidDetector = null; + meteor._constantForceDetector = null; + rigidbody.RegisterAttachedFluidDetector(detectors.GetComponent()); + rigidbody.RegisterAttachedForceDetector(detectors.AddComponent()); + meteor._owColliders = meteorPrefab.GetComponentsInChildren(); + meteorLauncher._meteorPrefab = meteorPrefab; } } @@ -44,6 +56,10 @@ namespace NewHorizons.Builder.Props meteorLauncher._minInterval = info.minInterval; meteorLauncher._maxInterval = info.maxInterval; + var lavaMaterial = launcherGO.FindChild("EruptionParticles_Lava").GetComponent().sharedMaterial; + lavaMaterial.SetColor(Color1, info.stoneTint?.ToColor() ?? defaultStoneTint); + lavaMaterial.SetColor(EmissionColor, info.lavaTint?.ToColor() ?? defaultLavaTint); + launcherGO.SetActive(true); // Have to null check else it breaks on reload configs @@ -64,16 +80,6 @@ namespace NewHorizons.Builder.Props mat.SetColor(Color1, info.stoneTint?.ToColor() ?? defaultStoneTint); mat.SetColor(EmissionColor, info.lavaTint?.ToColor() ?? defaultLavaTint); - GameObject.Destroy(meteor.transform.Find("ConstantDetectors").gameObject); - - var detectors = meteor.transform.Find("DynamicDetector").gameObject; - - meteor._constantFluidDetector = null; - meteor._constantForceDetector = null; - - var forceDetector = detectors.gameObject.AddComponent(); - - meteor._owColliders = meteor.gameObject.GetComponentsInChildren(); } } } diff --git a/NewHorizons/Patches/MeteorPatches.cs b/NewHorizons/Patches/MeteorPatches.cs new file mode 100644 index 00000000..131f57be --- /dev/null +++ b/NewHorizons/Patches/MeteorPatches.cs @@ -0,0 +1,15 @@ +using HarmonyLib; + +namespace NewHorizons.Patches +{ + [HarmonyPatch] + public static class MeteorPatches + { + [HarmonyPrefix] + [HarmonyPatch(typeof(MeteorController), nameof(MeteorController.Suspend), new System.Type[0])] + public static void MeteorController_Suspend(MeteorController __instance) + { + __instance.gameObject.SetActive(true); + } + } +}