diff --git a/NewHorizons/Atmosphere/AirBuilder.cs b/NewHorizons/Atmosphere/AirBuilder.cs index aced6765..0c2b0900 100644 --- a/NewHorizons/Atmosphere/AirBuilder.cs +++ b/NewHorizons/Atmosphere/AirBuilder.cs @@ -6,7 +6,7 @@ namespace NewHorizons.Atmosphere { static class AirBuilder { - public static void Make(GameObject body, float airScale, bool isRaining) + public static void Make(GameObject body, float airScale, bool isRaining, bool hasOxygen) { GameObject airGO = new GameObject("Air"); airGO.SetActive(false); @@ -25,6 +25,11 @@ namespace NewHorizons.Atmosphere SFV.SetValue("_allowShipAutoroll", true); SFV.SetValue("_disableOnStart", false); + if(hasOxygen) + { + airGO.AddComponent(); + } + if (isRaining) { VisorRainEffectVolume VREF = airGO.AddComponent(); diff --git a/NewHorizons/Atmosphere/AtmosphereBuilder.cs b/NewHorizons/Atmosphere/AtmosphereBuilder.cs index 741a1afb..522d4572 100644 --- a/NewHorizons/Atmosphere/AtmosphereBuilder.cs +++ b/NewHorizons/Atmosphere/AtmosphereBuilder.cs @@ -6,71 +6,76 @@ namespace NewHorizons.Atmosphere { static class AtmosphereBuilder { - public static void Make(GameObject body, IPlanetConfig config) + public static void Make(GameObject body, AtmosphereModule atmosphereModule) { GameObject atmoGO = new GameObject("Atmosphere"); atmoGO.SetActive(false); atmoGO.transform.parent = body.transform; - //Logger.Log("Re-add LOD atmosphere!", Logger.LogType.Todo); + if(atmosphereModule.hasAtmosphere) + { + var mat = GameObject.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere/Atmosphere_LOD0").GetComponent().material; - /* - GameObject atmo = GameObject.Instantiate(GameObject.Find("Atmosphere_TH/AtmoSphere")); - atmo.transform.parent = atmoGO.transform; - atmo.transform.localPosition = Vector3.zero; - atmo.transform.localScale = new Vector3(config.TopCloudSize, config.TopCloudSize, config.TopCloudSize); - */ + GameObject atmo = GameObject.Instantiate(GameObject.Find("Atmosphere_TH/AtmoSphere")); + atmo.transform.parent = atmoGO.transform; + atmo.transform.localPosition = Vector3.zero; + atmo.transform.localScale = Vector3.one * atmosphereModule.Size; + atmo.SetActive(true); - /* - GameObject lod1 = new GameObject(); - lod1.transform.parent = atmo.transform; - lod1.transform.localPosition = Vector3.zero; - MeshFilter f1 = lod1.AddComponent(); - f1.mesh = GameObject.Find("Atmosphere_LOD1").GetComponent().mesh; - MeshRenderer r1 = lod1.AddComponent(); - r1.material = mat; + /* + GameObject lod0 = new GameObject(); + lod0.transform.parent = atmo.transform; + lod0.transform.localPosition = Vector3.zero; + MeshFilter f0 = lod0.AddComponent(); + f0.mesh = GameObject.Find("Atmosphere_LOD0").GetComponent().mesh; + MeshRenderer r0 = lod0.AddComponent(); + r0.material = mat; - GameObject lod2 = new GameObject(); - lod2.transform.parent = atmo.transform; - lod2.transform.localPosition = Vector3.zero; - MeshFilter f2 = lod2.AddComponent(); - f2.mesh = GameObject.Find("Atmosphere_LOD2").GetComponent().mesh; - MeshRenderer r2 = lod2.AddComponent(); - r2.material = mat; + GameObject lod1 = new GameObject(); + lod1.transform.parent = atmo.transform; + lod1.transform.localPosition = Vector3.zero; + MeshFilter f1 = lod1.AddComponent(); + f1.mesh = GameObject.Find("Atmosphere_LOD1").GetComponent().mesh; + MeshRenderer r1 = lod1.AddComponent(); + r1.material = mat; - GameObject lod3 = new GameObject(); - lod3.transform.parent = atmo.transform; - lod3.transform.localPosition = Vector3.zero; - MeshFilter f3 = lod3.AddComponent(); - f3.mesh = GameObject.Find("Atmosphere_LOD3").GetComponent().mesh; - MeshRenderer r3 = lod3.AddComponent(); - r3.material = mat; - */ + GameObject lod2 = new GameObject(); + lod2.transform.parent = atmo.transform; + lod2.transform.localPosition = Vector3.zero; + MeshFilter f2 = lod2.AddComponent(); + f2.mesh = GameObject.Find("Atmosphere_LOD2").GetComponent().mesh; + MeshRenderer r2 = lod2.AddComponent(); + r2.material = mat; - // THIS FUCKING THING. do NOT ask why i have done this. IT WORKS. - // This creates an LOD group in the worst way possible. i am so sorry. - /* - LODGroup lodg = atmo.AddComponent(); - - LOD[] lodlist = new LOD[4]; - Renderer[] t0 = { r0 }; - Renderer[] t1 = { r1 }; - Renderer[] t2 = { r2 }; - Renderer[] t3 = { r3 }; - LOD one = new LOD(1, t0); - LOD two = new LOD(0.7f, t1); - LOD three = new LOD(0.27f, t2); - LOD four = new LOD(0.08f, t3); - lodlist[0] = one; - lodlist[1] = two; - lodlist[2] = three; - lodlist[3] = four; + GameObject lod3 = new GameObject(); + lod3.transform.parent = atmo.transform; + lod3.transform.localPosition = Vector3.zero; + MeshFilter f3 = lod3.AddComponent(); + f3.mesh = GameObject.Find("Atmosphere_LOD3").GetComponent().mesh; + MeshRenderer r3 = lod3.AddComponent(); + r3.material = mat; - lodg.SetLODs(lodlist); - lodg.fadeMode = LODFadeMode.None; - */ + LODGroup lodg = atmo.AddComponent(); + + LOD[] lodlist = new LOD[4]; + Renderer[] t0 = { r0 }; + Renderer[] t1 = { r1 }; + Renderer[] t2 = { r2 }; + Renderer[] t3 = { r3 }; + LOD one = new LOD(1, t0); + LOD two = new LOD(0.7f, t1); + LOD three = new LOD(0.27f, t2); + LOD four = new LOD(0.08f, t3); + lodlist[0] = one; + lodlist[1] = two; + lodlist[2] = three; + lodlist[3] = four; + + lodg.SetLODs(lodlist); + lodg.fadeMode = LODFadeMode.None; + */ + } - //atmo.SetActive(true); atmoGO.SetActive(true); Logger.Log("Finished building atmosphere.", Logger.LogType.Log); } diff --git a/NewHorizons/Atmosphere/CloudsBuilder.cs b/NewHorizons/Atmosphere/CloudsBuilder.cs index dcf02c17..5296c087 100644 --- a/NewHorizons/Atmosphere/CloudsBuilder.cs +++ b/NewHorizons/Atmosphere/CloudsBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.External; using NewHorizons.Utility; using OWML.Utils; +using System; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -10,15 +11,19 @@ namespace NewHorizons.Atmosphere { public static void Make(GameObject body, Sector sector, AtmosphereModule atmo) { - var texturePath = atmo.Cloud ?? "assets\\default_clouds.png"; - var capPath = atmo.CloudCap ?? "assets\\default_cap.png"; - var rampPath = atmo.CloudRamp ?? "assets\\default_ramp.png"; + Texture2D image, cap, ramp; - var image = Main.Instance.ModHelper.Assets.GetTexture(texturePath); - var cap = Main.Instance.ModHelper.Assets.GetTexture(capPath); - var ramp = Main.Instance.ModHelper.Assets.GetTexture(rampPath); - - Logger.Log($"Using cloud textures: {texturePath}, {capPath}, {rampPath}"); + try + { + image = Main.Instance.CurrentAssets.GetTexture(atmo.Cloud); + cap = Main.Instance.CurrentAssets.GetTexture(atmo.CloudCap); + ramp = Main.Instance.CurrentAssets.GetTexture(atmo.CloudRamp); + } + catch(Exception e) + { + Logger.LogError($"Couldn't load Cloud textures, {e.Message}, {e.StackTrace}"); + return; + } GameObject cloudsMainGO = new GameObject(); cloudsMainGO.SetActive(false); diff --git a/NewHorizons/Body/Geometry/CubeSphere.cs b/NewHorizons/Body/Geometry/CubeSphere.cs new file mode 100644 index 00000000..6593f361 --- /dev/null +++ b/NewHorizons/Body/Geometry/CubeSphere.cs @@ -0,0 +1,212 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using Logger = NewHorizons.Utility.Logger; + +namespace NewHorizons.Body +{ + static class CubeSphere + { + public static Mesh Build(int resolution, Texture2D heightMap, float minHeight, float maxHeight) + { + // It breaks if resolution is greater than 100 I don't know why + if(resolution > 100) + { + Logger.LogWarning($"Can't make CubeSphere's with resolution higher than 100 for some reason"); + resolution = 100; + } + + Mesh mesh = new Mesh(); + mesh.name = "CubeSphere"; + + CreateVertices(mesh, resolution, heightMap, minHeight, maxHeight); + CreateTriangles(mesh, resolution); + + return mesh; + } + + // Thank you Catlikecoding + private static void CreateVertices(Mesh mesh, int resolution, Texture2D heightMap, float minHeight, float maxHeight) + { + int cornerVertices = 8; + int edgeVertices = (3 * resolution - 3) * 4; + int faceVertices = (6 * (resolution - 1) * (resolution - 1)); + + Vector3[] vertices = new Vector3[cornerVertices + edgeVertices + faceVertices]; + Vector3[] normals = new Vector3[vertices.Length]; + Vector2[] uvs = new Vector2[vertices.Length]; + + int v = 0; + for (int y = 0; y <= resolution; y++) + { + for (int x = 0; x <= resolution; x++) + { + SetVertex(vertices, normals, uvs, v++, x, y, 0, resolution, heightMap, minHeight, maxHeight); + } + for (int z = 1; z <= resolution; z++) + { + SetVertex(vertices, normals, uvs, v++, resolution, y, z, resolution, heightMap, minHeight, maxHeight); + } + for (int x = resolution - 1; x >= 0; x--) + { + SetVertex(vertices, normals, uvs, v++, x, y, resolution, resolution, heightMap, minHeight, maxHeight); + } + for (int z = resolution - 1; z > 0; z--) + { + SetVertex(vertices, normals, uvs, v++, 0, y, z, resolution, heightMap, minHeight, maxHeight); + } + } + + for (int z = 1; z < resolution; z++) + { + for (int x = 1; x < resolution; x++) + { + SetVertex(vertices, normals, uvs, v++, x, resolution, z, resolution, heightMap, minHeight, maxHeight); + } + } + for (int z = 1; z < resolution; z++) + { + for (int x = 1; x < resolution; x++) + { + SetVertex(vertices, normals, uvs, v++, x, 0, z, resolution, heightMap, minHeight, maxHeight); + } + } + + mesh.vertices = vertices; + mesh.normals = normals; + mesh.uv = uvs; + } + + private static void SetVertex(Vector3[] vertices, Vector3[] normals, Vector2[] uvs, int i, int x, int y, int z, int resolution, Texture2D heightMap, float minHeight, float maxHeight) + { + var v2 = (new Vector3(x, y, z) - (Vector3.one * (resolution / 2f))).normalized; + + float x2 = v2.x * v2.x; + float y2 = v2.y * v2.y; + float z2 = v2.z * v2.z; + Vector3 v; + v.x = v2.x * Mathf.Sqrt(1f - y2 / 2f - z2 / 2f + y2 * z2 / 3f); + v.y = v2.y * Mathf.Sqrt(1f - x2 / 2f - z2 / 2f + x2 * z2 / 3f); + v.z = v2.z * Mathf.Sqrt(1f - x2 / 2f - y2 / 2f + x2 * y2 / 3f); + + float latitude = (Mathf.Rad2Deg * Mathf.Acos(v.z / Mathf.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z))) % 180f; + float longitude = (Mathf.Rad2Deg * (v.x > 0 ? Mathf.Atan(v.y / v.x) : Mathf.Atan(v.y / v.x) + Mathf.PI) + 90f) % 360f; + + float sampleX = heightMap.width * longitude / 360f; + float sampleY = heightMap.height * latitude / 180f; + + float relativeHeight = heightMap.GetPixel((int)sampleX, (int)sampleY).r; + + normals[i] = v.normalized; + vertices[i] = normals[i] * (relativeHeight * (maxHeight - minHeight) + minHeight); + uvs[i] = new Vector2(sampleX / (float)heightMap.width, sampleY / (float)heightMap.height); + } + + private static void CreateTriangles(Mesh mesh, int resolution) + { + int quads = resolution * resolution * 6; + int[] triangles = new int[quads * 6]; + int ring = resolution * 4; + int t = 0, v = 0; + + for (int y = 0; y < resolution; y++, v++) + { + for (int q = 0; q < ring - 1; q++, v++) + { + t = SetQuad(triangles, t, v, v + 1, v + ring, v + ring + 1); + } + t = SetQuad(triangles, t, v, v - ring + 1, v + ring, v + 1); + } + + t = CreateTopFace(resolution, triangles, t, ring); + t = CreateBottomFace(resolution, triangles, t, ring, mesh.vertices.Length); + + mesh.triangles = triangles; + } + + private static int CreateTopFace(int resolution, int[] triangles, int t, int ring) + { + int v = ring * resolution; + for (int x = 0; x < resolution - 1; x++, v++) + { + t = SetQuad(triangles, t, v, v + 1, v + ring - 1, v + ring); + } + t = SetQuad(triangles, t, v, v + 1, v + ring - 1, v + 2); + + int vMin = ring * (resolution + 1) - 1; + int vMid = vMin + 1; + int vMax = v + 2; + + for (int z = 1; z < resolution - 1; z++, vMin--, vMid++, vMax++) + { + t = SetQuad(triangles, t, vMin, vMid, vMin - 1, vMid + resolution - 1); + for (int x = 1; x < resolution - 1; x++, vMid++) + { + t = SetQuad( + triangles, t, + vMid, vMid + 1, vMid + resolution - 1, vMid + resolution); + } + t = SetQuad(triangles, t, vMid, vMax, vMid + resolution - 1, vMax + 1); + } + int vTop = vMin - 2; + t = SetQuad(triangles, t, vMin, vMid, vTop + 1, vTop); + for (int x = 1; x < resolution - 1; x++, vTop--, vMid++) + { + t = SetQuad(triangles, t, vMid, vMid + 1, vTop, vTop - 1); + } + t = SetQuad(triangles, t, vMid, vTop - 2, vTop, vTop - 1); + + return t; + } + + private static int CreateBottomFace(int resolution, int[] triangles, int t, int ring, int numVertices) + { + int v = 1; + int vMid = numVertices - (resolution - 1) * (resolution - 1); + t = SetQuad(triangles, t, ring - 1, vMid, 0, 1); + for (int x = 1; x < resolution - 1; x++, v++, vMid++) + { + t = SetQuad(triangles, t, vMid, vMid + 1, v, v + 1); + } + t = SetQuad(triangles, t, vMid, v + 2, v, v + 1); + + int vMin = ring - 2; + vMid -= resolution - 2; + int vMax = v + 2; + + for (int z = 1; z < resolution - 1; z++, vMin--, vMid++, vMax++) + { + t = SetQuad(triangles, t, vMin, vMid + resolution - 1, vMin + 1, vMid); + for (int x = 1; x < resolution - 1; x++, vMid++) + { + t = SetQuad( + triangles, t, + vMid + resolution - 1, vMid + resolution, vMid, vMid + 1); + } + t = SetQuad(triangles, t, vMid + resolution - 1, vMax + 1, vMid, vMax); + } + + int vTop = vMin - 1; + t = SetQuad(triangles, t, vTop + 1, vTop, vTop + 2, vMid); + for (int x = 1; x < resolution - 1; x++, vTop--, vMid++) + { + t = SetQuad(triangles, t, vTop, vTop - 1, vMid, vMid + 1); + } + t = SetQuad(triangles, t, vTop, vTop - 1, vMid, vTop - 2); + + return t; + } + + private static int SetQuad(int[] triangles, int i, int v00, int v10, int v01, int v11) + { + triangles[i] = v00; + triangles[i + 1] = triangles[i + 4] = v01; + triangles[i + 2] = triangles[i + 3] = v10; + triangles[i + 5] = v11; + return i + 6; + } + } +} diff --git a/NewHorizons/Body/Geometry/Icosphere.cs b/NewHorizons/Body/Geometry/Icosphere.cs new file mode 100644 index 00000000..fd7334fd --- /dev/null +++ b/NewHorizons/Body/Geometry/Icosphere.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace NewHorizons.Body.Geometry +{ + static class Icosphere + { + private static readonly float t = (1f + Mathf.Sqrt(5f)) / 2f; + // By subdivisions, will add to this to memoize computation of icospheres + private static List vertices = new List() + { + new Vector3[] + { + new Vector3(-1, t, 0).normalized, + new Vector3( 1, t, 0).normalized, + new Vector3(-1, -t, 0).normalized, + new Vector3( 1, -t, 0).normalized, + new Vector3( 0, -1, t).normalized, + new Vector3( 0, 1, t).normalized, + new Vector3( 0, -1, -t).normalized, + new Vector3( 0, 1, -t).normalized, + new Vector3( t, 0, -1).normalized, + new Vector3( t, 0, 1).normalized, + new Vector3(-t, 0, -1).normalized, + new Vector3(-t, 0, 1).normalized, + } + }; + private static List triangles = new List() + { + new int[] + { + 0, 11, 5, + 0, 5, 1, + 0, 1, 7, + 0, 7, 10, + 0, 10, 11, + + 1, 5, 9, + 5, 11, 4, + 11, 10, 2, + 10, 7, 6, + 7, 1, 8, + + 3, 9, 4, + 3, 4, 2, + 3, 2, 6, + 3, 6, 8, + 3, 8, 9, + + 4, 9, 5, + 2, 4, 11, + 6, 2, 10, + 8, 6, 7, + 9, 8, 1 + } + }; + + public static Mesh Build(int subdivisions, Texture2D heightMap, float minHeight, float maxHeight) + { + Mesh mesh = new Mesh(); + + if (vertices.Count <= subdivisions) + RefineFaces(subdivisions); + + var verticesToCopy = vertices[subdivisions]; + + Vector3[] newVertices = new Vector3[verticesToCopy.Length]; + Vector3[] normals = new Vector3[verticesToCopy.Length]; + Vector2[] uvs = new Vector2[verticesToCopy.Length]; + + for(int i = 0; i < verticesToCopy.Length; i++) + { + var v = verticesToCopy[i]; + + float latitude = (Mathf.Rad2Deg * Mathf.Acos(v.z / Mathf.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z))) % 180f; + float longitude = (Mathf.Rad2Deg * (v.x > 0 ? Mathf.Atan(v.y / v.x) : Mathf.Atan(v.y / v.x) + Mathf.PI) + 90f) % 360f; + + float sampleX = heightMap.width * longitude / 360f; + float sampleY = heightMap.height * latitude / 180f; + + float height = heightMap.GetPixel((int)sampleX, (int)sampleY).r * (maxHeight - minHeight) + minHeight; + + newVertices[i] = verticesToCopy[i] * height; + normals[i] = v.normalized; + uvs[i] = new Vector2(sampleX / (float)heightMap.width, sampleY / (float)heightMap.height); + } + + mesh.vertices = newVertices; + mesh.triangles = triangles[subdivisions]; + mesh.normals = normals; + mesh.uv = uvs; + + return mesh; + } + + private static void RefineFaces(int level) + { + if (level < vertices.Count) return; + + for(int i = vertices.Count - 1; i < level; i++) + { + // Each triangle will be subdivided into 4 new ones + int[] oldTriangles = triangles[i]; + int[] newTriangles = new int[oldTriangles.Length * 4]; + + // Making too many vertices but its fine I guess. Three per old triangle. + Vector3[] oldVertices = vertices[i]; + Vector3[] newVertices = new Vector3[oldVertices.Length + oldTriangles.Length]; + Array.Copy(oldVertices, newVertices, oldVertices.Length); + + int v = oldVertices.Length; + int newTrianglesIndex = 0; + for(int j = 0; j < oldTriangles.Length; j+=3, v+=3) + { + // Old vertex indices + var v0Ind = oldTriangles[j]; + var v1Ind = oldTriangles[j + 1]; + var v2Ind = oldTriangles[j + 2]; + + // Old vertices + var v0 = oldVertices[v0Ind]; + var v1 = oldVertices[v1Ind]; + var v2 = oldVertices[v2Ind]; + + // New vertex indices + var aInd = v; + var bInd = v + 1; + var cInd = v + 2; + + // New vertices + var a = GetMidPoint(v0, v1); + var b = GetMidPoint(v1, v2); + var c = GetMidPoint(v2, v0); + + // Add the three new vertices to the vertex list + newVertices[aInd] = a; + newVertices[bInd] = b; + newVertices[cInd] = c; + + // Add the four triangles + newTriangles[newTrianglesIndex++] = v0Ind; + newTriangles[newTrianglesIndex++] = aInd; + newTriangles[newTrianglesIndex++] = cInd; + + newTriangles[newTrianglesIndex++] = v1Ind; + newTriangles[newTrianglesIndex++] = bInd; + newTriangles[newTrianglesIndex++] = aInd; + + newTriangles[newTrianglesIndex++] = v2Ind; + newTriangles[newTrianglesIndex++] = cInd; + newTriangles[newTrianglesIndex++] = bInd; + + newTriangles[newTrianglesIndex++] = aInd; + newTriangles[newTrianglesIndex++] = bInd; + newTriangles[newTrianglesIndex++] = cInd; + } + + vertices.Add(newVertices); + triangles.Add(newTriangles); + } + } + + private static Vector3 GetMidPoint(Vector3 a, Vector3 b) + { + return ((a + b) / 2f).normalized; + } + } +} diff --git a/NewHorizons/Body/HeightMapBuilder.cs b/NewHorizons/Body/HeightMapBuilder.cs index 38d86058..82964176 100644 --- a/NewHorizons/Body/HeightMapBuilder.cs +++ b/NewHorizons/Body/HeightMapBuilder.cs @@ -1,10 +1,12 @@ -using NewHorizons.External; +using NewHorizons.Body.Geometry; +using NewHorizons.External; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; +using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Body { @@ -12,206 +14,51 @@ namespace NewHorizons.Body { public static void Make(GameObject go, HeightMapModule module) { - Texture2D heightMap = Main.Instance.ModHelper.Assets.GetTexture(module.HeightMap); + Texture2D heightMap, textureMap; + try + { + heightMap = Main.Instance.CurrentAssets.GetTexture(module.HeightMap); + textureMap = Main.Instance.CurrentAssets.GetTexture(module.TextureMap); + } + catch(Exception e) + { + Logger.LogError($"Couldn't load HeightMap textures, {e.Message}, {e.StackTrace}"); + return; + } + /* GameObject cubeSphere = new GameObject("CubeSphere"); cubeSphere.transform.parent = go.transform; cubeSphere.transform.rotation = Quaternion.Euler(90, 0, 0); - cubeSphere.AddComponent(); - var mesh = cubeSphere.GetComponent().mesh; - mesh.name = "CubeSphere"; + Mesh mesh = CubeSphere.Build(100, heightMap, module.MinHeight, module.MaxHeight); - CreateVertices(mesh, 100, heightMap, module.MinHeight, module.MaxHeight); - CreateTriangles(mesh, 100); + cubeSphere.AddComponent(); + cubeSphere.GetComponent().mesh = mesh; var cubeSphereMR = cubeSphere.AddComponent(); cubeSphereMR.material = new Material(Shader.Find("Standard")); - cubeSphereMR.material.mainTexture = Main.Instance.ModHelper.Assets.GetTexture(module.TextureMap); + cubeSphereMR.material.mainTexture = textureMap; var cubeSphereMC = cubeSphere.AddComponent(); cubeSphereMC.sharedMesh = mesh; - } + */ - // Thank you Catlikecoding - private static void CreateVertices(Mesh mesh, int resolution, Texture2D heightMap, float minHeight, float maxHeight) - { - int cornerVertices = 8; - int edgeVertices = (3 * resolution - 3) * 4; - int faceVertices = (6 * (resolution - 1) * (resolution - 1)); + GameObject icosphere = new GameObject("Icosphere"); + icosphere.transform.parent = go.transform; + icosphere.transform.rotation = Quaternion.Euler(90, 0, 0); - Vector3[] vertices = new Vector3[cornerVertices + edgeVertices + faceVertices]; - Vector3[] normals = new Vector3[vertices.Length]; - Vector2[] uvs = new Vector2[vertices.Length]; + Mesh mesh = Icosphere.Build(5, heightMap, module.MinHeight, module.MaxHeight); - int v = 0; - for (int y = 0; y <= resolution; y++) - { - for (int x = 0; x <= resolution; x++) - { - SetVertex(vertices, normals, uvs, v++, x, y, 0, resolution, heightMap, minHeight, maxHeight); - } - for (int z = 1; z <= resolution; z++) - { - SetVertex(vertices, normals, uvs, v++, resolution, y, z, resolution, heightMap, minHeight, maxHeight); - } - for (int x = resolution - 1; x >= 0; x--) - { - SetVertex(vertices, normals, uvs, v++, x, y, resolution, resolution, heightMap, minHeight, maxHeight); - } - for (int z = resolution - 1; z > 0; z--) - { - SetVertex(vertices, normals, uvs, v++, 0, y, z, resolution, heightMap, minHeight, maxHeight); - } - } + icosphere.AddComponent(); + icosphere.GetComponent().mesh = mesh; - for (int z = 1; z < resolution; z++) - { - for (int x = 1; x < resolution; x++) - { - SetVertex(vertices, normals, uvs, v++, x, resolution, z, resolution, heightMap, minHeight, maxHeight); - } - } - for (int z = 1; z < resolution; z++) - { - for (int x = 1; x < resolution; x++) - { - SetVertex(vertices, normals, uvs, v++, x, 0, z, resolution, heightMap, minHeight, maxHeight); - } - } + var cubeSphereMR = icosphere.AddComponent(); + cubeSphereMR.material = new Material(Shader.Find("Standard")); + cubeSphereMR.material.mainTexture = textureMap; - mesh.vertices = vertices; - mesh.normals = normals; - mesh.uv = uvs; - } - - private static void SetVertex(Vector3[] vertices, Vector3[] normals, Vector2[] uvs, int i, int x, int y, int z, int resolution, Texture2D heightMap, float minHeight, float maxHeight) - { - var v = ((new Vector3(x, y, z) / (float)resolution) - (Vector3.one * 0.5f)).normalized; - - float x2 = v.x * v.x; - float y2 = v.y * v.y; - float z2 = v.z * v.z; - Vector3 s; - s.x = v.x * Mathf.Sqrt(1f - y2 / 2f - z2 / 2f + y2 * z2 / 3f); - s.y = v.y * Mathf.Sqrt(1f - x2 / 2f - z2 / 2f + x2 * z2 / 3f); - s.z = v.z * Mathf.Sqrt(1f - x2 / 2f - y2 / 2f + x2 * y2 / 3f); - - var latitude = (Mathf.Rad2Deg * Mathf.Acos(v.z / Mathf.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z))) % 180f; - var longitude = (Mathf.Rad2Deg * (v.x > 0 ? Mathf.Atan(v.y / v.x) : Mathf.Atan(v.y / v.x) + Mathf.PI) + 90) % 360f; - - var sampleX = heightMap.width * longitude / 360f; - var sampleY = heightMap.height * latitude / 180f; - - var relativeHeight = heightMap.GetPixel((int)sampleX, (int)sampleY).r; - - normals[i] = s.normalized; - vertices[i] = normals[i] * (relativeHeight * (maxHeight - minHeight) + minHeight); - uvs[i] = new Vector2(sampleX / (float)heightMap.width, sampleY / (float)heightMap.height); - } - - private static void CreateTriangles(Mesh mesh, int resolution) - { - int quads = resolution * resolution * 6; - int[] triangles = new int[quads * 6]; - int ring = resolution * 4; - int t = 0, v = 0; - - for (int y = 0; y < resolution; y++, v++) - { - for (int q = 0; q < ring - 1; q++, v++) - { - t = SetQuad(triangles, t, v, v + 1, v + ring, v + ring + 1); - } - t = SetQuad(triangles, t, v, v - ring + 1, v + ring, v + 1); - } - - t = CreateTopFace(resolution, triangles, t, ring); - t = CreateBottomFace(resolution, triangles, t, ring, mesh.vertices.Length); - - mesh.triangles = triangles; - } - - private static int CreateTopFace(int resolution, int[] triangles, int t, int ring) - { - int v = ring * resolution; - for (int x = 0; x < resolution - 1; x++, v++) - { - t = SetQuad(triangles, t, v, v + 1, v + ring - 1, v + ring); - } - t = SetQuad(triangles, t, v, v + 1, v + ring - 1, v + 2); - - int vMin = ring * (resolution + 1) - 1; - int vMid = vMin + 1; - int vMax = v + 2; - - for (int z = 1; z < resolution - 1; z++, vMin--, vMid++, vMax++) - { - t = SetQuad(triangles, t, vMin, vMid, vMin - 1, vMid + resolution - 1); - for (int x = 1; x < resolution - 1; x++, vMid++) - { - t = SetQuad( - triangles, t, - vMid, vMid + 1, vMid + resolution - 1, vMid + resolution); - } - t = SetQuad(triangles, t, vMid, vMax, vMid + resolution - 1, vMax + 1); - } - int vTop = vMin - 2; - t = SetQuad(triangles, t, vMin, vMid, vTop + 1, vTop); - for (int x = 1; x < resolution - 1; x++, vTop--, vMid++) - { - t = SetQuad(triangles, t, vMid, vMid + 1, vTop, vTop - 1); - } - t = SetQuad(triangles, t, vMid, vTop - 2, vTop, vTop - 1); - - return t; - } - - private static int CreateBottomFace(int resolution, int[] triangles, int t, int ring, int numVertices) - { - int v = 1; - int vMid = numVertices - (resolution - 1) * (resolution - 1); - t = SetQuad(triangles, t, ring - 1, vMid, 0, 1); - for (int x = 1; x < resolution - 1; x++, v++, vMid++) - { - t = SetQuad(triangles, t, vMid, vMid + 1, v, v + 1); - } - t = SetQuad(triangles, t, vMid, v + 2, v, v + 1); - - int vMin = ring - 2; - vMid -= resolution - 2; - int vMax = v + 2; - - for (int z = 1; z < resolution - 1; z++, vMin--, vMid++, vMax++) - { - t = SetQuad(triangles, t, vMin, vMid + resolution - 1, vMin + 1, vMid); - for (int x = 1; x < resolution - 1; x++, vMid++) - { - t = SetQuad( - triangles, t, - vMid + resolution - 1, vMid + resolution, vMid, vMid + 1); - } - t = SetQuad(triangles, t, vMid + resolution - 1, vMax + 1, vMid, vMax); - } - - int vTop = vMin - 1; - t = SetQuad(triangles, t, vTop + 1, vTop, vTop + 2, vMid); - for (int x = 1; x < resolution - 1; x++, vTop--, vMid++) - { - t = SetQuad(triangles, t, vTop, vTop - 1, vMid, vMid + 1); - } - t = SetQuad(triangles, t, vTop, vTop - 1, vMid, vTop - 2); - - return t; - } - - private static int SetQuad(int[] triangles, int i, int v00, int v10, int v01, int v11) - { - triangles[i] = v00; - triangles[i + 1] = triangles[i + 4] = v01; - triangles[i + 2] = triangles[i + 3] = v10; - triangles[i + 5] = v11; - return i + 6; + var cubeSphereMC = icosphere.AddComponent(); + cubeSphereMC.sharedMesh = mesh; } } } diff --git a/NewHorizons/Body/RingBuilder.cs b/NewHorizons/Body/RingBuilder.cs index 413b3008..e47dd4f1 100644 --- a/NewHorizons/Body/RingBuilder.cs +++ b/NewHorizons/Body/RingBuilder.cs @@ -11,12 +11,20 @@ namespace NewHorizons.General { static class RingBuilder { - public static Material RingMaterial; - public static Shader RingShader; - public static void Make(GameObject body, RingModule ring) { - var ringGO = new GameObject("Ring"); + Texture2D ringTexture; + try + { + ringTexture = Main.Instance.CurrentAssets.GetTexture(ring.Texture); + } + catch (Exception e) + { + Logger.LogError($"Couldn't load Ring texture, {e.Message}, {e.StackTrace}"); + return; + } + + var ringGO = new GameObject("Ring"); ringGO.transform.parent = body.transform; ringGO.transform.localPosition = Vector3.zero; ringGO.transform.Rotate(ringGO.transform.TransformDirection(Vector3.up), ring.LongitudeOfAscendingNode); @@ -25,20 +33,13 @@ namespace NewHorizons.General var ringMF = ringGO.AddComponent(); var ringMesh = ringMF.mesh; var ringMR = ringGO.AddComponent(); - var texture = Main.Instance.ModHelper.Assets.GetTexture(ring.Texture ?? "assets/default_rings.png"); + var texture = ringTexture; - //if (RingMaterial == null) RingMaterial = Main.bundle.LoadAsset("Assets/Ring.mat"); - //if (RingShader == null) RingShader = Main.bundle.LoadAsset("Assets/Ring.shader"); - var mat = new Material(Shader.Find("Legacy Shaders/Particles/Alpha Blended Premultiply")); mat.mainTexture = texture; mat.renderQueue = 3000; ringMR.material = mat; - //ringMR.material = new Material(RingMaterial); - //ringMR.material.shader = RingShader; - //ringMR.material.mainTexture = texture; - // Make mesh var segments = (int)Math.Max(20, ring.OuterRadius); BuildRingMesh(ringMesh, segments, ring.InnerRadius, ring.OuterRadius); diff --git a/NewHorizons/Components/RotateToCustomAstroObject.cs b/NewHorizons/Components/RotateToCustomAstroObject.cs deleted file mode 100644 index a94af9a7..00000000 --- a/NewHorizons/Components/RotateToCustomAstroObject.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; - -namespace NewHorizons.Components -{ - public class RotateToCustomAstroObject : RotateToPoint - { - private void FixedUpdate() - { - if (this._quaternionTargetMode) - { - this._hasTargetLock = base.CheckLockedOn(); - this.IncrementalRotate(Time.fixedDeltaTime); - return; - } - if (this._astroObjectLock == AstroObject.Name.None) - { - this._hasTargetLock = false; - return; - } - AstroObject astroObject = Locator.GetAstroObject(this._astroObjectLock); - if (astroObject == null) - { - this._hasTargetLock = false; - return; - } - this._target = astroObject.transform.position; - this._hasTargetLock = base.CheckLockedOn(); - this.IncrementalRotate(Time.fixedDeltaTime); - } - - public void SetNewAstroTarget(AstroObject.Name name, string customName, bool resetRampUp) - { - if (resetRampUp) - { - base.ResetRotationSpeed(resetRampUp); - } - _astroObjectLock = name; - _astroObjectCustomName = customName; - } - - private AstroObject.Name _astroObjectLock; - private string _astroObjectCustomName; - } -} diff --git a/NewHorizons/External/AtmosphereModule.cs b/NewHorizons/External/AtmosphereModule.cs index 86889c7b..b2fecfcf 100644 --- a/NewHorizons/External/AtmosphereModule.cs +++ b/NewHorizons/External/AtmosphereModule.cs @@ -19,5 +19,7 @@ namespace NewHorizons.External public float FogSize { get; set; } public bool HasRain { get; set; } public bool HasSnow { get; set; } + public bool HasOxygen { get; set; } + public bool hasAtmosphere { get; set; } } } diff --git a/NewHorizons/External/BaseModule.cs b/NewHorizons/External/BaseModule.cs index d9be81d4..ae6d9f84 100644 --- a/NewHorizons/External/BaseModule.cs +++ b/NewHorizons/External/BaseModule.cs @@ -10,7 +10,7 @@ namespace NewHorizons.External public class BaseModule : Module { public bool HasMapMarker { get; set; } - public MColor32 LightTint { get; set; } + public bool HasAmbientLight { get; set; } public float SurfaceGravity { get; set; } public float SurfaceSize { get; set; } public float WaterSize { get; set; } diff --git a/NewHorizons/External/SpawnModule.cs b/NewHorizons/External/SpawnModule.cs index 37338d45..8547366e 100644 --- a/NewHorizons/External/SpawnModule.cs +++ b/NewHorizons/External/SpawnModule.cs @@ -11,5 +11,6 @@ namespace NewHorizons.External { public MVector3 PlayerSpawnPoint { get; set; } public MVector3 ShipSpawnPoint { get; set; } + public bool StartWithSuit { get; set; } } } diff --git a/NewHorizons/General/AmbientLightBuilder.cs b/NewHorizons/General/AmbientLightBuilder.cs index cd887aa7..0965800b 100644 --- a/NewHorizons/General/AmbientLightBuilder.cs +++ b/NewHorizons/General/AmbientLightBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External; using NewHorizons.Utility; +using OWML.Utils; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -7,26 +8,18 @@ namespace NewHorizons.General { static class AmbientLightBuilder { - public static void Make(GameObject body, Sector sector, MColor32 lightTint, float scale) + public static void Make(GameObject body, float scale) { - GameObject lightGO = new GameObject("Lights"); - lightGO.SetActive(false); - lightGO.transform.parent = body.transform; + GameObject lightGO = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/AmbientLight_BH_Surface"), body.transform); + lightGO.transform.localPosition = Vector3.zero; + lightGO.name = "Light"; + + var light = lightGO.GetComponent(); + light.name = "AmbientLight"; + light.color = new Color(0.5f, 1f, 1f, 0.0225f); + light.range = scale; + light.intensity = 0.5f; - Light L = lightGO.AddComponent(); - L.type = LightType.Point; - L.range = scale + 10; - L.color = (lightTint != null) ? lightTint.ToColor32() : (Color32)Color.black; - L.intensity = 0.8f; - L.shadows = LightShadows.None; - - L.cookie = GameObject.Find("/GiantsDeep_Body/AmbientLight_GD").GetComponent().cookie; - - SectorLightsCullGroup SLCG = lightGO.AddComponent(); - SLCG.SetSector(sector); - - lightGO.SetActive(true); - Logger.Log("Finished building ambient light", Logger.LogType.Log); } } diff --git a/NewHorizons/General/SpawnpointBuilder.cs b/NewHorizons/General/SpawnpointBuilder.cs index 9bbef976..03500a1f 100644 --- a/NewHorizons/General/SpawnpointBuilder.cs +++ b/NewHorizons/General/SpawnpointBuilder.cs @@ -8,6 +8,7 @@ namespace NewHorizons.General { static class SpawnPointBuilder { + private static bool suitUpQueued = false; public static SpawnPoint Make(GameObject body, SpawnModule module, OWRigidbody rb) { SpawnPoint playerSpawn = null; @@ -36,11 +37,51 @@ namespace NewHorizons.General var ship = GameObject.Find("Ship_Body"); ship.transform.position = spawnPoint.transform.position; ship.transform.rotation = Quaternion.FromToRotation(Vector3.up, (spawnPoint.transform.position - body.transform.position).normalized); + // Move it up a bit more + ship.transform.position = ship.transform.position + ship.transform.TransformDirection(Vector3.up) * 5f; + ship.GetRequiredComponent().SetBodyToMatch(rb); } + if(module.StartWithSuit && !suitUpQueued) + { + suitUpQueued = true; + Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => SuitUp(), 4); + } Logger.Log("Made spawnpoint on [" + body.name + "]"); return playerSpawn; } + + private static void SuitUp() + { + suitUpQueued = false; + try + { + var spv = GameObject.Find("Ship_Body/Module_Supplies/Systems_Supplies/ExpeditionGear").GetComponent(); + spv.SetValue("_containsSuit", false); + + if (spv.GetValue("_allowSuitReturn")) + spv.GetValue("_interactVolume").ChangePrompt(UITextType.ReturnSuitPrompt, spv.GetValue("_pickupSuitCommandIndex")); + else + spv.GetValue("_interactVolume").EnableSingleInteraction(false, spv.GetValue("_pickupSuitCommandIndex")); + + Locator.GetPlayerTransform().GetComponent().SuitUp(false, true, true); + + spv.SetValue("_timer", 0f); + spv.SetValue("_index", 0); + + GameObject suitGeometry = spv.GetValue("_suitGeometry"); + if (suitGeometry != null) suitGeometry.SetActive(false); + + OWCollider suitOWCollider = spv.GetValue("_suitOWCollider"); + if (suitOWCollider != null) suitOWCollider.SetActivation(false); + + spv.enabled = true; + } + catch(Exception e) + { + Logger.LogWarning($"Was unable to suit up player. {e.Message}, {e.StackTrace}"); + } + } } } diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 56f9d7fc..b3872d45 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -19,10 +19,11 @@ namespace NewHorizons public class Main : ModBehaviour { public static Main Instance { get; private set; } - //public static AssetBundle bundle; public static List BodyList = new List(); + public IModAssets CurrentAssets { get; private set; } + public override object GetApi() { return new NewHorizonsApi(); @@ -35,32 +36,17 @@ namespace NewHorizons Utility.Patches.Apply(); - //bundle = ModHelper.Assets.LoadBundle("assets/new-horizons"); - Logger.Log("Begin load of config files...", Logger.LogType.Log); - foreach (var file in Directory.GetFiles(ModHelper.Manifest.ModFolderPath + @"planets\")) + try { - try - { - var config = ModHelper.Storage.Load(file.Replace(ModHelper.Manifest.ModFolderPath, "")); - Logger.Log($"Loaded {config.Name}"); - BodyList.Add(new NewHorizonsBody(config)); - } - catch(Exception e) - { - Logger.LogError($"Couldn't load {file}: {e.Message}, {e.StackTrace}"); - } + LoadConfigs(this); + } + catch(Exception) + { + Logger.LogWarning("Couldn't find planets folder"); } - if (BodyList.Count != 0) - { - Logger.Log("Loaded [" + BodyList.Count + "] config files.", Logger.LogType.Log); - } - else - { - Logger.Log("No config files found!", Logger.LogType.Warning); - } } void OnSceneLoaded(Scene scene, LoadSceneMode mode) @@ -78,8 +64,6 @@ namespace NewHorizons AstroObjectLocator.AddAstroObject(ao); } - //BodyList = BodyList.OrderBy(x => x.Config.Destroy).ToList(); - foreach (var body in BodyList) { var stringID = body.Config.Name.ToUpper().Replace(" ", "_").Replace("'", ""); @@ -109,7 +93,7 @@ namespace NewHorizons { if (body.Config.Destroy) { - Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => RemoveBody(existingPlanet)); + Instance.ModHelper.Events.Unity.FireInNUpdates(() => RemoveBody(existingPlanet), 2); } else UpdateBody(body, existingPlanet); } @@ -134,6 +118,25 @@ namespace NewHorizons } } + public void LoadConfigs(IModBehaviour mod) + { + CurrentAssets = mod.ModHelper.Assets; + var folder = mod.ModHelper.Manifest.ModFolderPath; + foreach (var file in Directory.GetFiles(folder + @"planets\")) + { + try + { + var config = mod.ModHelper.Storage.Load(file.Replace(folder, "")); + Logger.Log($"Loaded {config.Name}"); + BodyList.Add(new NewHorizonsBody(config)); + } + catch (Exception e) + { + Logger.LogError($"Couldn't load {file}: {e.Message}, {e.StackTrace}"); + } + } + } + public static GameObject UpdateBody(NewHorizonsBody body, AstroObject ao) { Logger.Log($"Updating existing AstroObject {ao}"); @@ -157,7 +160,7 @@ namespace NewHorizons } if(body.Config.Atmosphere != null) { - AirBuilder.Make(go, body.Config.Atmosphere.Size, body.Config.Atmosphere.HasRain); + AirBuilder.Make(go, body.Config.Atmosphere.Size, body.Config.Atmosphere.HasRain, body.Config.Atmosphere.HasOxygen); if (body.Config.Atmosphere.Cloud != null) { @@ -171,7 +174,7 @@ namespace NewHorizons if (body.Config.Atmosphere.FogSize != 0) FogBuilder.Make(go, sector, body.Config.Atmosphere); - AtmosphereBuilder.Make(go, body.Config); + AtmosphereBuilder.Make(go, body.Config.Atmosphere); } return go; @@ -250,6 +253,10 @@ namespace NewHorizons GameObject.Find("WhiteholeStation_Body").SetActive(false); GameObject.Find("WhiteholeStationSuperstructure_Body").SetActive(false); } + if(ao.GetAstroObjectName() == AstroObject.Name.TimberHearth) + { + GameObject.Find("MiningRig_Body").SetActive(false); + } // Deal with proxies foreach(var p in GameObject.FindObjectsOfType()) @@ -329,7 +336,7 @@ namespace NewHorizons // These can be shared between creating new planets and updating planets if (body.Config.Atmosphere != null) { - AirBuilder.Make(go, body.Config.Atmosphere.Size, body.Config.Atmosphere.HasRain); + AirBuilder.Make(go, body.Config.Atmosphere.Size, body.Config.Atmosphere.HasRain, body.Config.Atmosphere.HasOxygen); if (body.Config.Atmosphere.Cloud != null) { @@ -343,11 +350,9 @@ namespace NewHorizons if (body.Config.Atmosphere.FogSize != 0) FogBuilder.Make(go, sector, body.Config.Atmosphere); - AtmosphereBuilder.Make(go, body.Config); + AtmosphereBuilder.Make(go, body.Config.Atmosphere); } - AmbientLightBuilder.Make(go, sector, body.Config.Base.LightTint, sphereOfInfluence); - if (body.Config.Ring != null) RingBuilder.Make(go, body.Config.Ring); @@ -360,10 +365,14 @@ namespace NewHorizons if (body.Config.Base.WaterSize != 0) WaterBuilder.Make(go, sector, rb, body.Config.Base.WaterSize); + if (body.Config.Base.HasAmbientLight) + AmbientLightBuilder.Make(go, sphereOfInfluence); + Logger.Log("Generation of [" + body.Config.Name + "] completed.", Logger.LogType.Log); body.Object = go; + // Some things have to be done the second tick Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => OrbitlineBuilder.Make(body.Object, ao, body.Config.Orbit.IsMoon)); go.transform.parent = Locator.GetRootTransform(); @@ -390,8 +399,11 @@ namespace NewHorizons var body = new NewHorizonsBody(planetConfig); Main.BodyList.Add(body); + } - //Main.helper.Events.Unity.RunWhen(() => Locator.GetCenterOfTheUniverse() != null, () => Main.CreateBody(body)); + public void LoadConfigs(IModBehaviour mod) + { + Main.Instance.LoadConfigs(mod); } public GameObject GetPlanet(string name) diff --git a/NewHorizons/NewHorizons.csproj b/NewHorizons/NewHorizons.csproj index 3176fb88..80431b61 100644 --- a/NewHorizons/NewHorizons.csproj +++ b/NewHorizons/NewHorizons.csproj @@ -230,8 +230,9 @@ + + - diff --git a/NewHorizons/Utility/DebugRaycaster.cs b/NewHorizons/Utility/DebugRaycaster.cs index c1b2f673..5742691b 100644 --- a/NewHorizons/Utility/DebugRaycaster.cs +++ b/NewHorizons/Utility/DebugRaycaster.cs @@ -29,7 +29,7 @@ namespace NewHorizons.Utility var direction = Locator.GetActiveCamera().transform.TransformDirection(Vector3.forward); if (Physics.Raycast(origin, direction, out RaycastHit hitInfo, 100f, layerMask)) { - Logger.Log($"Raycast hit [{hitInfo.transform.localPosition}] on [{hitInfo.transform.gameObject.name}]"); + Logger.Log($"Raycast hit [{hitInfo.transform.InverseTransformPoint(hitInfo.point)}] on [{hitInfo.transform.gameObject.name}]"); } _rb.EnableCollisionDetection(); } diff --git a/NewHorizons/assets/default_rings.png b/NewHorizons/assets/default_rings.png deleted file mode 100644 index 50b79327..00000000 Binary files a/NewHorizons/assets/default_rings.png and /dev/null differ diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index 714bcdd1..92420264 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -1,8 +1,8 @@ { "filename": "NewHorizons.dll", "author": "xen", - "name": "NewHorizons", + "name": "New Horizons", "uniqueName": "xen.NewHorizons", "version": "0.1.0", - "owmlVersion": "2.0.0" + "owmlVersion": "2.1.0" } diff --git a/NewHorizons/planets/ash_twin.json b/NewHorizons/planets/ash_twin.json deleted file mode 100644 index bf469dea..00000000 --- a/NewHorizons/planets/ash_twin.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Ash Twin", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/assets/accretion_disk.png b/NewHorizons/planets/assets/accretion_disk.png deleted file mode 100644 index d00ee5ec..00000000 Binary files a/NewHorizons/planets/assets/accretion_disk.png and /dev/null differ diff --git a/NewHorizons/planets/assets/blank_cap.png b/NewHorizons/planets/assets/blank_cap.png deleted file mode 100644 index ea83bc43..00000000 Binary files a/NewHorizons/planets/assets/blank_cap.png and /dev/null differ diff --git a/NewHorizons/planets/assets/brimstone_clouds.png b/NewHorizons/planets/assets/brimstone_clouds.png deleted file mode 100644 index adfbb803..00000000 Binary files a/NewHorizons/planets/assets/brimstone_clouds.png and /dev/null differ diff --git a/NewHorizons/planets/assets/earth_heightmap.png b/NewHorizons/planets/assets/earth_heightmap.png deleted file mode 100644 index b0ebb0b7..00000000 Binary files a/NewHorizons/planets/assets/earth_heightmap.png and /dev/null differ diff --git a/NewHorizons/planets/assets/earth_texturemap.png b/NewHorizons/planets/assets/earth_texturemap.png deleted file mode 100644 index 79cf47b5..00000000 Binary files a/NewHorizons/planets/assets/earth_texturemap.png and /dev/null differ diff --git a/NewHorizons/planets/assets/jewel_rings.png b/NewHorizons/planets/assets/jewel_rings.png deleted file mode 100644 index a03b7701..00000000 Binary files a/NewHorizons/planets/assets/jewel_rings.png and /dev/null differ diff --git a/NewHorizons/planets/assets/jupiter.png b/NewHorizons/planets/assets/jupiter.png deleted file mode 100644 index 25f422ad..00000000 Binary files a/NewHorizons/planets/assets/jupiter.png and /dev/null differ diff --git a/NewHorizons/planets/assets/jupiter_ramp.png b/NewHorizons/planets/assets/jupiter_ramp.png deleted file mode 100644 index bb59ab50..00000000 Binary files a/NewHorizons/planets/assets/jupiter_ramp.png and /dev/null differ diff --git a/NewHorizons/planets/assets/mars_heightmap.png b/NewHorizons/planets/assets/mars_heightmap.png deleted file mode 100644 index b0aad094..00000000 Binary files a/NewHorizons/planets/assets/mars_heightmap.png and /dev/null differ diff --git a/NewHorizons/planets/assets/mars_texturemap.png b/NewHorizons/planets/assets/mars_texturemap.png deleted file mode 100644 index 0d331bad..00000000 Binary files a/NewHorizons/planets/assets/mars_texturemap.png and /dev/null differ diff --git a/NewHorizons/planets/assets/mercury_heightmap.png b/NewHorizons/planets/assets/mercury_heightmap.png deleted file mode 100644 index 09666bb6..00000000 Binary files a/NewHorizons/planets/assets/mercury_heightmap.png and /dev/null differ diff --git a/NewHorizons/planets/assets/mercury_texturemap.png b/NewHorizons/planets/assets/mercury_texturemap.png deleted file mode 100644 index cbe363fd..00000000 Binary files a/NewHorizons/planets/assets/mercury_texturemap.png and /dev/null differ diff --git a/NewHorizons/planets/assets/neptune.png b/NewHorizons/planets/assets/neptune.png deleted file mode 100644 index ea12f09f..00000000 Binary files a/NewHorizons/planets/assets/neptune.png and /dev/null differ diff --git a/NewHorizons/planets/assets/neptune_ramp.png b/NewHorizons/planets/assets/neptune_ramp.png deleted file mode 100644 index 378ce71d..00000000 Binary files a/NewHorizons/planets/assets/neptune_ramp.png and /dev/null differ diff --git a/NewHorizons/planets/assets/ringed_jewel.png b/NewHorizons/planets/assets/ringed_jewel.png deleted file mode 100644 index 7847bffe..00000000 Binary files a/NewHorizons/planets/assets/ringed_jewel.png and /dev/null differ diff --git a/NewHorizons/planets/assets/ringed_jewel_cap.png b/NewHorizons/planets/assets/ringed_jewel_cap.png deleted file mode 100644 index 08ae98e5..00000000 Binary files a/NewHorizons/planets/assets/ringed_jewel_cap.png and /dev/null differ diff --git a/NewHorizons/planets/assets/ringed_jewel_ramp.png b/NewHorizons/planets/assets/ringed_jewel_ramp.png deleted file mode 100644 index dec4b6cb..00000000 Binary files a/NewHorizons/planets/assets/ringed_jewel_ramp.png and /dev/null differ diff --git a/NewHorizons/planets/assets/saturn.png b/NewHorizons/planets/assets/saturn.png deleted file mode 100644 index d5a62a1a..00000000 Binary files a/NewHorizons/planets/assets/saturn.png and /dev/null differ diff --git a/NewHorizons/planets/assets/saturn_ramp.png b/NewHorizons/planets/assets/saturn_ramp.png deleted file mode 100644 index f805a110..00000000 Binary files a/NewHorizons/planets/assets/saturn_ramp.png and /dev/null differ diff --git a/NewHorizons/planets/assets/saturn_rings.png b/NewHorizons/planets/assets/saturn_rings.png deleted file mode 100644 index 31375524..00000000 Binary files a/NewHorizons/planets/assets/saturn_rings.png and /dev/null differ diff --git a/NewHorizons/planets/assets/uranus.png b/NewHorizons/planets/assets/uranus.png deleted file mode 100644 index dd33c015..00000000 Binary files a/NewHorizons/planets/assets/uranus.png and /dev/null differ diff --git a/NewHorizons/planets/assets/uranus_ramp.png b/NewHorizons/planets/assets/uranus_ramp.png deleted file mode 100644 index 7efe0a25..00000000 Binary files a/NewHorizons/planets/assets/uranus_ramp.png and /dev/null differ diff --git a/NewHorizons/planets/assets/venus_heightmap.png b/NewHorizons/planets/assets/venus_heightmap.png deleted file mode 100644 index 36b2c6b8..00000000 Binary files a/NewHorizons/planets/assets/venus_heightmap.png and /dev/null differ diff --git a/NewHorizons/planets/assets/venus_texturemap.png b/NewHorizons/planets/assets/venus_texturemap.png deleted file mode 100644 index d9143b09..00000000 Binary files a/NewHorizons/planets/assets/venus_texturemap.png and /dev/null differ diff --git a/NewHorizons/planets/attlerock.json b/NewHorizons/planets/attlerock.json deleted file mode 100644 index c9b71dc0..00000000 --- a/NewHorizons/planets/attlerock.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Attlerock", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/brittle_hollow.json b/NewHorizons/planets/brittle_hollow.json deleted file mode 100644 index 139ef46a..00000000 --- a/NewHorizons/planets/brittle_hollow.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Brittle Hollow", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/dark_bramble.json b/NewHorizons/planets/dark_bramble.json deleted file mode 100644 index 1b018251..00000000 --- a/NewHorizons/planets/dark_bramble.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Dark Bramble", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/earth.json b/NewHorizons/planets/earth.json deleted file mode 100644 index ab4007db..00000000 --- a/NewHorizons/planets/earth.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name" : "Earth", - "Spawn" : - { - "playerSpawnPoint" : - { - "x" : -121.3, - "y" : -246.4, - "z" : 109.6, - }, - "shipSpawnPoint" : - { - "x" : -141.5, - "y" : -245.3, - "z" : 89.0, - }, - }, - "Base" : - { - "surfaceGravity" : 12, - "surfaceSize" : 300, - "hasMapMarker" : true, - "lightTint" : - { - "r" : 200, - "g" : 240, - "b" : 255, - "a" : 255 - }, - "waterSize" : 296 - }, - "Orbit" : - { - "semiMajorAxis" : 6000, - "inclination" : 3, - "primaryBody" : "SUN", - "isMoon" : false, - "longitudeOfAscendingNode" : 0, - "eccentricity" : 0, - "argumentOfPeriapsis": 0, - "axialTilt" : 0, - }, - "Atmosphere" : - { - "size" : 375, - "fogTint" : - { - "r" : 90, - "g" : 128, - "b" : 128, - "a" : 255 - }, - "fogDensity": 0.1, - "fogSize": 375, - }, - "HeightMap" : - { - "heightMap" : "planets/assets/earth_heightmap.png", - "textureMap" : "planets/assets/earth_texturemap.png", - "minHeight" : 292, - "maxHeight" : 307, - } -} \ No newline at end of file diff --git a/NewHorizons/planets/ember_twin.json b/NewHorizons/planets/ember_twin.json deleted file mode 100644 index 43942dbc..00000000 --- a/NewHorizons/planets/ember_twin.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Ember Twin", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/giants_deep.json b/NewHorizons/planets/giants_deep.json deleted file mode 100644 index 5d3be213..00000000 --- a/NewHorizons/planets/giants_deep.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Giant's Deep", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/hollows_lantern.json b/NewHorizons/planets/hollows_lantern.json deleted file mode 100644 index c800a718..00000000 --- a/NewHorizons/planets/hollows_lantern.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Hollow's Lantern", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/interloper.json b/NewHorizons/planets/interloper.json deleted file mode 100644 index dcb01ed8..00000000 --- a/NewHorizons/planets/interloper.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Interloper", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/jupiter.json b/NewHorizons/planets/jupiter.json deleted file mode 100644 index 53143024..00000000 --- a/NewHorizons/planets/jupiter.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name" : "Jupiter", - "Base" : - { - "surfaceGravity" : 20, - "surfaceSize" : 300, - "hasMapMarker" : true, - "lightTint" : - { - "r" : 200, - "g" : 240, - "b" : 255, - "a" : 255 - }, - }, - "Orbit" : - { - "semiMajorAxis" : 10000, - "inclination" : 3, - "primaryBody" : "SUN", - "isMoon" : false, - "longitudeOfAscendingNode" : 0, - "eccentricity" : 0, - "argumentOfPeriapsis": 0, - "axialTilt" : 0, - }, - "Atmosphere" : - { - "size" : 500, - "cloudTint" : - { - "r" : 181, - "g" : 181, - "b" : 230, - "a" : 255 - }, - "cloud" : "planets/assets/jupiter.png", - "cloudCap" : "planets/assets/blank_cap.png", - "cloudRamp" : "planets/assets/jupiter_ramp.png", - "fogTint" : - { - "r" : 255, - "g" : 128, - "b" : 128, - "a" : 255 - }, - "fogDensity": 0.9, - "fogSize": 450, - }, -} \ No newline at end of file diff --git a/NewHorizons/planets/map_satellite.json b/NewHorizons/planets/map_satellite.json deleted file mode 100644 index 188caeea..00000000 --- a/NewHorizons/planets/map_satellite.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Map Satellite", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/mars.json b/NewHorizons/planets/mars.json deleted file mode 100644 index 0143d18e..00000000 --- a/NewHorizons/planets/mars.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name" : "Mars", - "Base" : - { - "surfaceGravity" : 8, - "surfaceSize" : 200, - "hasMapMarker" : true, - "lightTint" : - { - "r" : 255, - "g" : 200, - "b" : 200, - "a" : 255 - }, - }, - "Orbit" : - { - "semiMajorAxis" : 8000, - "inclination" : 3, - "primaryBody" : "SUN", - "isMoon" : false, - "longitudeOfAscendingNode" : 0, - "eccentricity" : 0, - "argumentOfPeriapsis": 0, - "axialTilt" : 0, - }, - "Atmosphere" : - { - "size" : 230, - "fogTint" : - { - "r" : 90, - "g" : 128, - "b" : 128, - "a" : 255 - }, - "fogDensity": 0.1, - "fogSize": 200, - }, - "HeightMap" : - { - "heightMap" : "planets/assets/mars_heightmap.png", - "textureMap" : "planets/assets/mars_texturemap.png", - "minHeight" : 200, - "maxHeight" : 220, - } -} \ No newline at end of file diff --git a/NewHorizons/planets/mercury.json b/NewHorizons/planets/mercury.json deleted file mode 100644 index 1fd6d34e..00000000 --- a/NewHorizons/planets/mercury.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name" : "Mercury", - "Base" : - { - "surfaceGravity" : 12, - "surfaceSize" : 200, - "hasMapMarker" : true, - "lightTint" : - { - "r" : 255, - "g" : 200, - "b" : 200, - "a" : 255 - }, - }, - "Orbit" : - { - "semiMajorAxis" : 3000, - "inclination" : 3, - "primaryBody" : "SUN", - "isMoon" : false, - "longitudeOfAscendingNode" : 0, - "eccentricity" : 0, - "argumentOfPeriapsis": 0, - "axialTilt" : 0, - }, - "HeightMap" : - { - "heightMap" : "planets/assets/mercury_heightmap.png", - "textureMap" : "planets/assets/mercury_texturemap.png", - "minHeight" : 195, - "maxHeight" : 205, - } -} \ No newline at end of file diff --git a/NewHorizons/planets/neptune.json b/NewHorizons/planets/neptune.json deleted file mode 100644 index 80a4bca6..00000000 --- a/NewHorizons/planets/neptune.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name" : "Neptune", - "Base" : - { - "surfaceGravity" : 20, - "surfaceSize" : 300, - "hasMapMarker" : true, - "lightTint" : - { - "r" : 200, - "g" : 240, - "b" : 255, - "a" : 255 - }, - }, - "Orbit" : - { - "semiMajorAxis" : 16000, - "inclination" : 3, - "primaryBody" : "SUN", - "isMoon" : false, - "longitudeOfAscendingNode" : 0, - "eccentricity" : 0, - "argumentOfPeriapsis": 0, - "axialTilt" : 0, - }, - "Atmosphere" : - { - "size" : 300, - "cloudTint" : - { - "r" : 181, - "g" : 181, - "b" : 230, - "a" : 255 - }, - "cloud" : "planets/assets/neptune.png", - "cloudCap" : "planets/assets/blank_cap.png", - "cloudRamp" : "planets/assets/neptune_ramp.png", - "fogTint" : - { - "r" : 128, - "g" : 128, - "b" : 255, - "a" : 255 - }, - "fogDensity": 0.9, - "fogSize": 300, - }, -} \ No newline at end of file diff --git a/NewHorizons/planets/orbital_probe_cannon.json b/NewHorizons/planets/orbital_probe_cannon.json deleted file mode 100644 index b6066fe0..00000000 --- a/NewHorizons/planets/orbital_probe_cannon.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Orbital Probe Cannon", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/quantum_moon.json b/NewHorizons/planets/quantum_moon.json deleted file mode 100644 index 42c9e6f2..00000000 --- a/NewHorizons/planets/quantum_moon.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Quantum Moon", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/saturn.json b/NewHorizons/planets/saturn.json deleted file mode 100644 index fd69f37c..00000000 --- a/NewHorizons/planets/saturn.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name" : "Saturn", - "Base" : - { - "surfaceGravity" : 20, - "surfaceSize" : 300, - "hasMapMarker" : true, - "lightTint" : - { - "r" : 200, - "g" : 240, - "b" : 255, - "a" : 255 - }, - }, - "Orbit" : - { - "semiMajorAxis" : 12000, - "inclination" : 3, - "primaryBody" : "SUN", - "isMoon" : false, - "longitudeOfAscendingNode" : 0, - "eccentricity" : 0, - "argumentOfPeriapsis": 0, - "axialTilt" : 0, - }, - "Atmosphere" : - { - "size" : 400, - "cloudTint" : - { - "r" : 181, - "g" : 181, - "b" : 230, - "a" : 255 - }, - "cloud" : "planets/assets/saturn.png", - "cloudCap" : "planets/assets/blank_cap.png", - "cloudRamp" : "planets/assets/saturn_ramp.png", - "fogTint" : - { - "r" : 255, - "g" : 128, - "b" : 128, - "a" : 255 - }, - "fogDensity": 0.9, - "fogSize": 400, - }, - "Ring" : - { - "innerRadius" : 500, - "outerRadius" : 950, - "texture" : "planets/assets/saturn_rings.png", - }, -} \ No newline at end of file diff --git a/NewHorizons/planets/sun_station.json b/NewHorizons/planets/sun_station.json deleted file mode 100644 index 01fcdd69..00000000 --- a/NewHorizons/planets/sun_station.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Sun Station", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/timberhearth.json b/NewHorizons/planets/timberhearth.json deleted file mode 100644 index 9732b747..00000000 --- a/NewHorizons/planets/timberhearth.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "Timber Hearth", - "destroy" : true, -} \ No newline at end of file diff --git a/NewHorizons/planets/uranus.json b/NewHorizons/planets/uranus.json deleted file mode 100644 index f8fba685..00000000 --- a/NewHorizons/planets/uranus.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name" : "Uranus", - "Base" : - { - "surfaceGravity" : 20, - "surfaceSize" : 300, - "hasMapMarker" : true, - "lightTint" : - { - "r" : 200, - "g" : 240, - "b" : 255, - "a" : 255 - }, - }, - "Orbit" : - { - "semiMajorAxis" : 14000, - "inclination" : 3, - "primaryBody" : "SUN", - "isMoon" : false, - "longitudeOfAscendingNode" : 0, - "eccentricity" : 0, - "argumentOfPeriapsis": 0, - "axialTilt" : 0, - }, - "Atmosphere" : - { - "size" : 300, - "cloudTint" : - { - "r" : 181, - "g" : 181, - "b" : 230, - "a" : 255 - }, - "cloud" : "planets/assets/uranus.png", - "cloudCap" : "planets/assets/blank_cap.png", - "cloudRamp" : "planets/assets/uranus_ramp.png", - "fogTint" : - { - "r" : 128, - "g" : 128, - "b" : 255, - "a" : 255 - }, - "fogDensity": 0.9, - "fogSize": 300, - }, -} \ No newline at end of file diff --git a/NewHorizons/planets/venus.json b/NewHorizons/planets/venus.json deleted file mode 100644 index c0df01a3..00000000 --- a/NewHorizons/planets/venus.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name" : "Venus", - "Base" : - { - "surfaceGravity" : 12, - "surfaceSize" : 300, - "hasMapMarker" : true, - "lightTint" : - { - "r" : 255, - "g" : 200, - "b" : 200, - "a" : 255 - }, - }, - "Orbit" : - { - "semiMajorAxis" : 4000, - "inclination" : 3, - "primaryBody" : "SUN", - "isMoon" : false, - "longitudeOfAscendingNode" : 0, - "eccentricity" : 0, - "argumentOfPeriapsis": 0, - "axialTilt" : 0, - }, - "Atmosphere" : - { - "size" : 350, - "fogTint" : - { - "r" : 200, - "g" : 128, - "b" : 128, - "a" : 255 - }, - "fogDensity": 0.9, - "fogSize": 350, - }, - "HeightMap" : - { - "heightMap" : "planets/assets/venus_heightmap.png", - "textureMap" : "planets/assets/venus_texturemap.png", - "minHeight" : 290, - "maxHeight" : 310, - } -} \ No newline at end of file diff --git a/NewHorizons/planets/whitehole.json b/NewHorizons/planets/whitehole.json deleted file mode 100644 index 2bf241d4..00000000 --- a/NewHorizons/planets/whitehole.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name" : "White Hole", - "destroy" : true, -} \ No newline at end of file