diff --git a/NewHorizons/Builder/Props/GeyserBuilder.cs b/NewHorizons/Builder/Props/GeyserBuilder.cs index ab8e358a..93c3feea 100644 --- a/NewHorizons/Builder/Props/GeyserBuilder.cs +++ b/NewHorizons/Builder/Props/GeyserBuilder.cs @@ -1,4 +1,6 @@ -using System; +using NewHorizons.External; +using NewHorizons.Utility; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,9 +11,21 @@ namespace NewHorizons.Builder.Props { public static class GeyserBuilder { - public static void Make(GameObject body) + public static void Make(GameObject go, Sector sector, PropModule.GeyserInfo info) { + var original = GameObject.Find("TimberHearth_Body/Sector_TH/Interactables_TH/Geysers/Geyser_Village/"); + GameObject geyserGO = GameObject.Instantiate(original, go.transform); + geyserGO.name = "Geyser"; + var pos = ((Vector3)info.position); + var length = pos.magnitude; + geyserGO.transform.localPosition = pos.normalized * (length - 100f); + + var originalRadial = -(original.transform.position - GameObject.Find("TimberHearth_Body").transform.position).normalized; + geyserGO.transform.rotation *= Quaternion.FromToRotation(originalRadial, pos.normalized); + + geyserGO.GetComponent()._inactiveDuration = 0.5f; + } } } diff --git a/NewHorizons/Builder/Props/PropBuilder.cs b/NewHorizons/Builder/Props/PropBuilder.cs index e626aa6d..7899abf4 100644 --- a/NewHorizons/Builder/Props/PropBuilder.cs +++ b/NewHorizons/Builder/Props/PropBuilder.cs @@ -46,6 +46,13 @@ namespace NewHorizons.Builder.Props else MakeDetail(go, sector, detail.path, detail.position, detail.rotation, detail.scale, detail.alignToNormal); } } + if(config.Props.Geysers != null) + { + foreach(var geyserInfo in config.Props.Geysers) + { + GeyserBuilder.Make(go, sector, geyserInfo); + } + } } public static GameObject MakeDetail(GameObject go, Sector sector, string propToClone, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal) @@ -96,15 +103,7 @@ namespace NewHorizons.Builder.Props Quaternion rot = rotation == null ? Quaternion.identity : Quaternion.Euler((Vector3)rotation); prop.transform.localRotation = rot; - if (alignWithNormal) - { - var up = prop.transform.localPosition.normalized; - var front = Vector3.Cross(up, Vector3.left); - if (front.sqrMagnitude == 0f) front = Vector3.Cross(up, Vector3.forward); - if (front.sqrMagnitude == 0f) front = Vector3.Cross(up, Vector3.up); - - prop.transform.LookAt(prop.transform.position + front, up); - } + if (alignWithNormal) prop.transform.AlignRadially(); prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale; diff --git a/NewHorizons/External/PropModule.cs b/NewHorizons/External/PropModule.cs index fae6e3f6..c864ea7d 100644 --- a/NewHorizons/External/PropModule.cs +++ b/NewHorizons/External/PropModule.cs @@ -11,7 +11,8 @@ namespace NewHorizons.External { public ScatterInfo[] Scatter; public DetailInfo[] Details; - public MVector3[] Rafts; + public RaftInfo[] Rafts; + public GeyserInfo[] Geysers; public class ScatterInfo { @@ -35,6 +36,11 @@ namespace NewHorizons.External public bool alignToNormal; } + public class RaftInfo + { + public MVector3 position; + } + public class GeyserInfo { public MVector3 position; diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 932a9cb6..1d2ea11c 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -213,6 +213,7 @@ namespace NewHorizons GameObject body1, body2, body3; body1 = LoadTitleScreenBody(eligible[indices[0]]); + body1.transform.localRotation = Quaternion.Euler(15, 0, 0); if (selectionCount > 1) { body1.transform.localScale = Vector3.one * (body1.transform.localScale.x) * 0.3f; @@ -220,12 +221,14 @@ namespace NewHorizons body2 = LoadTitleScreenBody(eligible[indices[1]]); body2.transform.localScale = Vector3.one * (body2.transform.localScale.x) * 0.3f; body2.transform.localPosition = new Vector3(7, 40, 0); + body2.transform.localRotation = Quaternion.Euler(15, 0, 0); } if (selectionCount > 2) { body3 = LoadTitleScreenBody(eligible[indices[2]]); body3.transform.localScale = Vector3.one * (body3.transform.localScale.x) * 0.3f; body3.transform.localPosition = new Vector3(-5, 10, 0); + body3.transform.localRotation = Quaternion.Euler(15, 0, 0); } GameObject.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire").SetActive(false); diff --git a/NewHorizons/Utility/NewHorizonExtensions.cs b/NewHorizons/Utility/NewHorizonExtensions.cs index cfc03a43..633c96dc 100644 --- a/NewHorizons/Utility/NewHorizonExtensions.cs +++ b/NewHorizons/Utility/NewHorizonExtensions.cs @@ -50,6 +50,16 @@ namespace NewHorizons.Utility return strBuilder.ToString(); } + public static void AlignRadially(this Transform transform) + { + var up = transform.localPosition.normalized; + var front = Vector3.Cross(up, Vector3.left); + if (front.sqrMagnitude == 0f) front = Vector3.Cross(up, Vector3.forward); + if (front.sqrMagnitude == 0f) front = Vector3.Cross(up, Vector3.up); + + transform.LookAt(transform.position + front, up); + } + public static void CopyPropertiesFrom(this object destination, object source) { // If any this null throw an exception diff --git a/NewHorizons/Utility/Patches.cs b/NewHorizons/Utility/Patches.cs index 3f3a6532..3f8a7a3e 100644 --- a/NewHorizons/Utility/Patches.cs +++ b/NewHorizons/Utility/Patches.cs @@ -50,6 +50,8 @@ namespace NewHorizons.Utility Main.Instance.ModHelper.HarmonyHelper.AddPrefix("Update", typeof(Patches), nameof(Patches.OnShipLogControllerUpdate)); + Main.Instance.ModHelper.HarmonyHelper.AddPrefix("IsLaunched", typeof(Patches), nameof(Patches.OnSurveyorProbeIsLaunched)); + // Postfixes Main.Instance.ModHelper.HarmonyHelper.AddPostfix("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake)); Main.Instance.ModHelper.HarmonyHelper.AddPostfix("Awake", typeof(Patches), nameof(Patches.OnOWCameraAwake)); @@ -369,5 +371,15 @@ namespace NewHorizons.Utility } return false; } + + public static bool OnSurveyorProbeIsLaunched(SurveyorProbe __instance, ref bool __result) + { + if(__instance.gameObject == null) + { + __result = false; + return false; + } + return true; + } } }