Geysers orient the wrong way

This commit is contained in:
Nick J. Connors 2022-01-05 00:30:31 -05:00
parent 1d6aefefd4
commit 47e1f18d40
6 changed files with 56 additions and 12 deletions

View File

@ -1,4 +1,6 @@
using System; using NewHorizons.External;
using NewHorizons.Utility;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -9,9 +11,21 @@ namespace NewHorizons.Builder.Props
{ {
public static class GeyserBuilder 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<GeyserController>()._inactiveDuration = 0.5f;
} }
} }
} }

View File

@ -46,6 +46,13 @@ namespace NewHorizons.Builder.Props
else MakeDetail(go, sector, detail.path, detail.position, detail.rotation, detail.scale, detail.alignToNormal); 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) 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); Quaternion rot = rotation == null ? Quaternion.identity : Quaternion.Euler((Vector3)rotation);
prop.transform.localRotation = rot; prop.transform.localRotation = rot;
if (alignWithNormal) if (alignWithNormal) prop.transform.AlignRadially();
{
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);
}
prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale; prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale;

View File

@ -11,7 +11,8 @@ namespace NewHorizons.External
{ {
public ScatterInfo[] Scatter; public ScatterInfo[] Scatter;
public DetailInfo[] Details; public DetailInfo[] Details;
public MVector3[] Rafts; public RaftInfo[] Rafts;
public GeyserInfo[] Geysers;
public class ScatterInfo public class ScatterInfo
{ {
@ -35,6 +36,11 @@ namespace NewHorizons.External
public bool alignToNormal; public bool alignToNormal;
} }
public class RaftInfo
{
public MVector3 position;
}
public class GeyserInfo public class GeyserInfo
{ {
public MVector3 position; public MVector3 position;

View File

@ -213,6 +213,7 @@ namespace NewHorizons
GameObject body1, body2, body3; GameObject body1, body2, body3;
body1 = LoadTitleScreenBody(eligible[indices[0]]); body1 = LoadTitleScreenBody(eligible[indices[0]]);
body1.transform.localRotation = Quaternion.Euler(15, 0, 0);
if (selectionCount > 1) if (selectionCount > 1)
{ {
body1.transform.localScale = Vector3.one * (body1.transform.localScale.x) * 0.3f; body1.transform.localScale = Vector3.one * (body1.transform.localScale.x) * 0.3f;
@ -220,12 +221,14 @@ namespace NewHorizons
body2 = LoadTitleScreenBody(eligible[indices[1]]); body2 = LoadTitleScreenBody(eligible[indices[1]]);
body2.transform.localScale = Vector3.one * (body2.transform.localScale.x) * 0.3f; body2.transform.localScale = Vector3.one * (body2.transform.localScale.x) * 0.3f;
body2.transform.localPosition = new Vector3(7, 40, 0); body2.transform.localPosition = new Vector3(7, 40, 0);
body2.transform.localRotation = Quaternion.Euler(15, 0, 0);
} }
if (selectionCount > 2) if (selectionCount > 2)
{ {
body3 = LoadTitleScreenBody(eligible[indices[2]]); body3 = LoadTitleScreenBody(eligible[indices[2]]);
body3.transform.localScale = Vector3.one * (body3.transform.localScale.x) * 0.3f; body3.transform.localScale = Vector3.one * (body3.transform.localScale.x) * 0.3f;
body3.transform.localPosition = new Vector3(-5, 10, 0); 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); GameObject.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire").SetActive(false);

View File

@ -50,6 +50,16 @@ namespace NewHorizons.Utility
return strBuilder.ToString(); 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) public static void CopyPropertiesFrom(this object destination, object source)
{ {
// If any this null throw an exception // If any this null throw an exception

View File

@ -50,6 +50,8 @@ namespace NewHorizons.Utility
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogController>("Update", typeof(Patches), nameof(Patches.OnShipLogControllerUpdate)); Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogController>("Update", typeof(Patches), nameof(Patches.OnShipLogControllerUpdate));
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<SurveyorProbe>("IsLaunched", typeof(Patches), nameof(Patches.OnSurveyorProbeIsLaunched));
// Postfixes // Postfixes
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake)); Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<OWCamera>("Awake", typeof(Patches), nameof(Patches.OnOWCameraAwake)); Main.Instance.ModHelper.HarmonyHelper.AddPostfix<OWCamera>("Awake", typeof(Patches), nameof(Patches.OnOWCameraAwake));
@ -369,5 +371,15 @@ namespace NewHorizons.Utility
} }
return false; return false;
} }
public static bool OnSurveyorProbeIsLaunched(SurveyorProbe __instance, ref bool __result)
{
if(__instance.gameObject == null)
{
__result = false;
return false;
}
return true;
}
} }
} }