new-horizons/NewHorizons/Builder/Body/GeometryBuilder.cs
2022-08-18 00:54:50 -04:00

31 lines
1.1 KiB
C#

using UnityEngine;
using NewHorizons.Utility;
namespace NewHorizons.Builder.Body
{
public static class GeometryBuilder
{
public static GameObject Make(GameObject planetGO, Sector sector, float groundScale)
{
GameObject groundGO = GameObject.CreatePrimitive(PrimitiveType.Sphere);
groundGO.transform.name = "GroundSphere";
groundGO.transform.parent = sector?.transform ?? planetGO.transform;
groundGO.transform.localScale = new Vector3(groundScale, groundScale, groundScale);
groundGO.transform.position = planetGO.transform.position;
var topLayer = SearchUtilities.Find("CloudsTopLayer_GD");
if (topLayer != null)
{
groundGO.GetComponent<MeshFilter>().mesh = topLayer.GetComponent<MeshFilter>().mesh;
groundGO.GetComponent<SphereCollider>().radius = 1f;
}
else
{
groundGO.transform.localScale *= 2;
}
groundGO.SetActive(true);
return groundGO;
}
}
}