Merge branch 'more-details' into planetary-features

This commit is contained in:
Nick J. Connors 2022-01-10 19:23:56 -05:00
commit 0f878a4df1
5 changed files with 42 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.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<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);
}
}
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;

View File

@ -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;

View File

@ -221,6 +221,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;

View File

@ -51,6 +51,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