From 0a061ecbccad1f0ecb0167f9cb5dcf20568d3171 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 21 May 2022 13:28:04 -0400 Subject: [PATCH] Added description to all modules except translation --- .../Builder/Atmosphere/CloudsBuilder.cs | 4 +- .../Builder/Body/AsteroidBeltBuilder.cs | 2 +- NewHorizons/Builder/Body/FunnelBuilder.cs | 29 +- NewHorizons/Builder/Body/ProxyBuilder.cs | 2 +- NewHorizons/Builder/Body/RingBuilder.cs | 5 +- .../Builder/Body/SingularityBuilder.cs | 20 +- NewHorizons/Builder/General/GravityBuilder.cs | 9 +- .../Builder/Orbital/FocalPointBuilder.cs | 2 +- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 356 +++++++------- .../Builder/Props/ProjectionBuilder.cs | 15 +- NewHorizons/Builder/ShipLog/MapModeBuilder.cs | 10 +- NewHorizons/Builder/ShipLog/RevealBuilder.cs | 11 +- NewHorizons/Components/Orbital/Gravity.cs | 2 +- NewHorizons/External/Configs/PlanetConfig.cs | 193 ++++++-- .../External/Configs/StarSystemConfig.cs | 59 ++- .../External/Modules/AsteroidBeltModule.cs | 58 ++- .../External/Modules/AtmosphereModule.cs | 178 +++++-- NewHorizons/External/Modules/BaseModule.cs | 111 ++++- .../External/Modules/FocalPointModule.cs | 16 +- .../External/Modules/HeightMapModule.cs | 29 +- NewHorizons/External/Modules/OrbitModule.cs | 71 +++ NewHorizons/External/Modules/ProcGenModule.cs | 8 +- NewHorizons/External/Modules/PropModule.cs | 458 +++++++++++++++++- NewHorizons/External/Modules/ShipLogModule.cs | 112 ++++- NewHorizons/External/Modules/SignalModule.cs | 58 ++- NewHorizons/External/Modules/SpawnModule.cs | 32 +- .../Modules/VariableSize/FunnelModule.cs | 41 +- .../Modules/VariableSize/LavaModule.cs | 14 +- .../Modules/VariableSize/RingModule.cs | 52 +- .../Modules/VariableSize/SandModule.cs | 7 + .../Modules/VariableSize/SingularityModule.cs | 42 +- .../Modules/VariableSize/StarModule.cs | 49 +- .../VariableSize/VariableSizeModule.cs | 7 +- .../Modules/VariableSize/WaterModule.cs | 14 +- 34 files changed, 1668 insertions(+), 408 deletions(-) diff --git a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs index dacdbd8f..aafbde20 100644 --- a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs @@ -76,11 +76,11 @@ namespace NewHorizons.Builder.Atmosphere fluidCLFV._density = 1.2f; var fluidType = FluidVolume.Type.CLOUD; - if (!string.IsNullOrEmpty(atmo.Clouds.FluidType)) + if (atmo.Clouds.FluidType != null) { try { - fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), atmo.Clouds.FluidType.ToUpper()); + fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(CloudFluidType), atmo.Clouds.FluidType).ToUpper()); } catch (Exception ex) { diff --git a/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs b/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs index c24cdf40..965d3628 100644 --- a/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs +++ b/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs @@ -35,7 +35,7 @@ namespace NewHorizons.Builder.Body SurfaceGravity = 1, SurfaceSize = size, HasReferenceFrame = false, - GravityFallOff = "inverseSquared" + GravityFallOff = GravityFallOff.InverseSquared }; config.Orbit = new OrbitModule() diff --git a/NewHorizons/Builder/Body/FunnelBuilder.cs b/NewHorizons/Builder/Body/FunnelBuilder.cs index 0186404c..00c29ded 100644 --- a/NewHorizons/Builder/Body/FunnelBuilder.cs +++ b/NewHorizons/Builder/Body/FunnelBuilder.cs @@ -1,4 +1,5 @@ -using NewHorizons.Components; +using System.Runtime.Serialization; +using NewHorizons.Components; using NewHorizons.Utility; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -8,26 +9,16 @@ namespace NewHorizons.Builder.Body { public static class FunnelBuilder { - private enum FunnelType - { - SAND, - WATER, - LAVA, - STAR - } public static void Make(GameObject planetGO, ConstantForceDetector detector, OWRigidbody rigidbody, FunnelModule module) { - var funnelType = FunnelType.SAND; - if (module.Type.ToUpper().Equals("WATER")) funnelType = FunnelType.WATER; - else if (module.Type.ToUpper().Equals("LAVA")) funnelType = FunnelType.LAVA; - else if (module.Type.ToUpper().Equals("STAR")) funnelType = FunnelType.STAR; + var funnelType = module.Type; var funnelGO = new GameObject($"{planetGO.name.Replace("_Body", "")}Funnel_Body"); funnelGO.SetActive(false); funnelGO.transform.parent = planetGO.transform; - var owrb = funnelGO.AddComponent(); + funnelGO.AddComponent(); var matchMotion = funnelGO.AddComponent(); matchMotion.SetBodyToMatch(rigidbody); @@ -61,10 +52,10 @@ namespace NewHorizons.Builder.Body var fluidVolume = sfv.gameObject; switch (funnelType) { - case FunnelType.SAND: + case FunnelType.Sand: sfv._fluidType = FluidVolume.Type.SAND; break; - case FunnelType.WATER: + case FunnelType.Water: sfv._fluidType = FluidVolume.Type.WATER; GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); @@ -111,8 +102,8 @@ namespace NewHorizons.Builder.Body */ break; - case FunnelType.LAVA: - case FunnelType.STAR: + case FunnelType.Lava: + case FunnelType.Star: sfv._fluidType = FluidVolume.Type.PLASMA; GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); @@ -129,12 +120,12 @@ namespace NewHorizons.Builder.Body proxyGO.GetComponentInChildren().material = lavaMaterial; geoGO.GetComponentInChildren().material = lavaMaterial; - if (funnelType == FunnelType.LAVA) + if (funnelType == FunnelType.Lava) { lavaMaterial.SetFloat("_HeightScale", 0); AddDestructionVolumes(fluidVolume, DeathType.Lava); } - else if (funnelType == FunnelType.STAR) + else if (funnelType == FunnelType.Star) { lavaMaterial.renderQueue = 2999; lavaMaterial.SetFloat("_HeightScale", 100000); diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 2ce8f45a..20fa7488 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -89,7 +89,7 @@ namespace NewHorizons.Builder.Body // Could improve this to actually use the proper renders and materials if (body.Config.Singularity != null) { - if (body.Config.Singularity.Type == "BlackHole") + if (body.Config.Singularity.Type == SingularityModule.SingularityType.BlackHole) { MakeBlackHole(newProxy, body.Config.Singularity.Size); } diff --git a/NewHorizons/Builder/Body/RingBuilder.cs b/NewHorizons/Builder/Body/RingBuilder.cs index e141f3ae..ad054193 100644 --- a/NewHorizons/Builder/Body/RingBuilder.cs +++ b/NewHorizons/Builder/Body/RingBuilder.cs @@ -4,6 +4,7 @@ using NewHorizons.Utility; using OWML.Common; using System; using System.Collections.Generic; +using NewHorizons.External.Modules; using UnityEngine; using Logger = NewHorizons.Utility.Logger; using NewHorizons.External.Modules.VariableSize; @@ -46,11 +47,11 @@ namespace NewHorizons.Builder.Body var sfv = ringVolume.AddComponent(); var fluidType = FluidVolume.Type.NONE; - if (!string.IsNullOrEmpty(ring.FluidType)) + if (ring.FluidType != null) { try { - fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), ring.FluidType.ToUpper()); + fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(CloudFluidType), ring.FluidType).ToUpper()); } catch (Exception ex) { diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index af26b0b5..d4e5dfde 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -2,17 +2,13 @@ using NewHorizons.External.Configs; using NewHorizons.Utility; using System; +using NewHorizons.External.Modules.VariableSize; using UnityEngine; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.Body { public static class SingularityBuilder { - enum Polarity - { - BlackHole, - WhiteHole - } private static Shader blackHoleShader = null; private static Shader whiteHoleShader = null; @@ -22,11 +18,7 @@ namespace NewHorizons.Builder.Body var size = config.Singularity.Size; var pairedSingularity = config.Singularity.PairedSingularity; - var polarity = Polarity.BlackHole; - if (config.Singularity.Type != null && config.Singularity.Type.ToUpper().Equals("WHITEHOLE")) - { - polarity = Polarity.WhiteHole; - } + var polarity = config.Singularity.Type; bool isWormHole = config.Singularity?.TargetStarSystem != null; bool hasHazardVolume = !isWormHole && (pairedSingularity == null); @@ -38,10 +30,10 @@ namespace NewHorizons.Builder.Body GameObject newSingularity = null; switch (polarity) { - case Polarity.BlackHole: + case SingularityModule.SingularityType.BlackHole: newSingularity = MakeBlackHole(go, sector, localPosition, size, hasHazardVolume, config.Singularity.TargetStarSystem); break; - case Polarity.WhiteHole: + case SingularityModule.SingularityType.WhiteHole: newSingularity = MakeWhiteHole(go, sector, OWRB, localPosition, size, makeZeroGVolume); break; } @@ -54,10 +46,10 @@ namespace NewHorizons.Builder.Body { switch (polarity) { - case Polarity.BlackHole: + case SingularityModule.SingularityType.BlackHole: PairSingularities(newSingularity, pairedSingularityAO.gameObject); break; - case Polarity.WhiteHole: + case SingularityModule.SingularityType.WhiteHole: PairSingularities(pairedSingularityAO.gameObject, newSingularity); break; } diff --git a/NewHorizons/Builder/General/GravityBuilder.cs b/NewHorizons/Builder/General/GravityBuilder.cs index 3d10e1dc..5f0fe48c 100644 --- a/NewHorizons/Builder/General/GravityBuilder.cs +++ b/NewHorizons/Builder/General/GravityBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Configs; +using NewHorizons.External.Modules; using UnityEngine; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.General @@ -7,7 +8,7 @@ namespace NewHorizons.Builder.General { public static GravityVolume Make(GameObject planetGO, AstroObject ao, PlanetConfig config) { - var exponent = config.Base.GravityFallOff.Equals("linear") ? 1f : 2f; + var exponent = config.Base.GravityFallOff == GravityFallOff.Linear ? 1f : 2f; var GM = config.Base.SurfaceGravity * Mathf.Pow(config.Base.SurfaceSize, exponent); // Gravity limit will be when the acceleration it would cause is less than 0.1 m/s^2 @@ -37,10 +38,8 @@ namespace NewHorizons.Builder.General var gravityVolume = gravityGO.AddComponent(); gravityVolume._cutoffAcceleration = 0.1f; - GravityVolume.FalloffType falloff = GravityVolume.FalloffType.linear; - if (config.Base.GravityFallOff.ToUpper().Equals("LINEAR")) falloff = GravityVolume.FalloffType.linear; - else if (config.Base.GravityFallOff.ToUpper().Equals("INVERSESQUARED")) falloff = GravityVolume.FalloffType.inverseSquared; - else Logger.LogError($"Couldn't set gravity type {config.Base.GravityFallOff}. Must be either \"linear\" or \"inverseSquared\". Defaulting to linear."); + var falloff = config.Base.GravityFallOff == GravityFallOff.Linear? GravityVolume.FalloffType.linear : GravityVolume.FalloffType.inverseSquared; + gravityVolume._falloffType = falloff; // Radius where your feet turn to the planet diff --git a/NewHorizons/Builder/Orbital/FocalPointBuilder.cs b/NewHorizons/Builder/Orbital/FocalPointBuilder.cs index 520d15d9..65e71505 100644 --- a/NewHorizons/Builder/Orbital/FocalPointBuilder.cs +++ b/NewHorizons/Builder/Orbital/FocalPointBuilder.cs @@ -71,7 +71,7 @@ namespace NewHorizons.Builder.Orbital { var surfaceAcceleration = config.Base.SurfaceGravity; var upperSurfaceRadius = config.Base.SurfaceSize; - int falloffExponent = config.Base.GravityFallOff.ToUpper().Equals("LINEAR") ? 1 : 2; + int falloffExponent = config.Base.GravityFallOff == GravityFallOff.Linear ? 1 : 2; return surfaceAcceleration * Mathf.Pow(upperSurfaceRadius, falloffExponent) / GravityVolume.GRAVITATIONAL_CONSTANT; } diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index eea5eb60..849838f9 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -73,184 +73,191 @@ namespace NewHorizons.Builder.Props var xmlPath = System.IO.File.ReadAllText(mod.ModHelper.Manifest.ModFolderPath + info.xmlFile); - if (info.type == "wall") + switch (info.type) { - var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath).gameObject; - - nomaiWallTextObj.transform.parent = sector?.transform ?? planetGO.transform; - nomaiWallTextObj.transform.position = planetGO.transform.TransformPoint(info.position); - if (info.normal != null) + case PropModule.NomaiTextInfo.NomaiTextType.Wall: { - // In global coordinates (normal was in local coordinates) - var up = (nomaiWallTextObj.transform.position - planetGO.transform.position).normalized; - var forward = planetGO.transform.TransformDirection(info.normal).normalized; + var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath).gameObject; - nomaiWallTextObj.transform.up = up; - nomaiWallTextObj.transform.forward = forward; - } - if (info.rotation != null) - { - nomaiWallTextObj.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation)); - } - - nomaiWallTextObj.SetActive(true); - } - else if (info.type == "scroll") - { - var customScroll = _scrollPrefab.InstantiateInactive(); - - var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath); - nomaiWallText.transform.parent = customScroll.transform; - nomaiWallText.transform.localPosition = Vector3.zero; - nomaiWallText.transform.localRotation = Quaternion.identity; - - nomaiWallText._showTextOnStart = false; - - // Don't want to be able to translate until its in a socket - nomaiWallText.GetComponent().enabled = false; - - nomaiWallText.gameObject.SetActive(true); - - var scrollItem = customScroll.GetComponent(); - - // Idk why this thing is always around - GameObject.Destroy(customScroll.transform.Find("Arc_BH_City_Forum_2").gameObject); - - // This variable is the bane of my existence i dont get it - scrollItem._nomaiWallText = nomaiWallText; - - // Because the scroll was already awake it does weird shit in Awake and makes some of the entries in this array be null - scrollItem._colliders = new OWCollider[] { scrollItem.GetComponent() }; - - // Else when you put them down you can't pick them back up - customScroll.GetComponent()._physicsRemoved = false; - - // Place scroll - customScroll.transform.parent = sector?.transform ?? planetGO.transform; - customScroll.transform.position = planetGO.transform.TransformPoint(info.position ?? Vector3.zero); - - var up = planetGO.transform.InverseTransformPoint(customScroll.transform.position).normalized; - customScroll.transform.rotation = Quaternion.FromToRotation(customScroll.transform.up, up) * customScroll.transform.rotation; - - customScroll.SetActive(true); - - // Enable the collider and renderer - Main.Instance.ModHelper.Events.Unity.RunWhen( - () => Main.IsSystemReady, - () => + nomaiWallTextObj.transform.parent = sector?.transform ?? planetGO.transform; + nomaiWallTextObj.transform.position = planetGO.transform.TransformPoint(info.position); + if (info.normal != null) { - Logger.Log("Fixing scroll!"); - scrollItem._nomaiWallText = nomaiWallText; - scrollItem.SetSector(sector); - customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Geo").GetComponent().enabled = true; - customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Collider").gameObject.SetActive(true); - nomaiWallText.gameObject.GetComponent().enabled = false; - customScroll.GetComponent().enabled = true; + // In global coordinates (normal was in local coordinates) + var up = (nomaiWallTextObj.transform.position - planetGO.transform.position).normalized; + var forward = planetGO.transform.TransformDirection(info.normal).normalized; + + nomaiWallTextObj.transform.up = up; + nomaiWallTextObj.transform.forward = forward; + } + if (info.rotation != null) + { + nomaiWallTextObj.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation)); } - ); - } - else if (info.type == "computer") - { - var computerObject = _computerPrefab.InstantiateInactive(); - computerObject.transform.parent = sector?.transform ?? planetGO.transform; - computerObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero); - - var up = computerObject.transform.position - planetGO.transform.position; - if (info.normal != null) up = planetGO.transform.TransformDirection(info.normal); - computerObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * computerObject.transform.rotation; - - var computer = computerObject.GetComponent(); - computer.SetSector(sector); - - computer._dictNomaiTextData = MakeNomaiTextDict(xmlPath); - computer._nomaiTextAsset = new TextAsset(xmlPath); - AddTranslation(xmlPath); - - // Make sure the computer model is loaded - OWAssetHandler.LoadObject(computerObject); - sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(computerObject)); - - computerObject.SetActive(true); - } - else if (info.type == "cairn") - { - var cairnObject = _cairnPrefab.InstantiateInactive(); - - cairnObject.transform.parent = sector?.transform ?? planetGO.transform; - cairnObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero); - - if (info.rotation != null) - { - cairnObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation)); + nomaiWallTextObj.SetActive(true); + break; } - else + case PropModule.NomaiTextInfo.NomaiTextType.Scroll: { - // By default align it to normal - var up = (cairnObject.transform.position - planetGO.transform.position).normalized; - cairnObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * cairnObject.transform.rotation; + var customScroll = _scrollPrefab.InstantiateInactive(); + + var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath); + nomaiWallText.transform.parent = customScroll.transform; + nomaiWallText.transform.localPosition = Vector3.zero; + nomaiWallText.transform.localRotation = Quaternion.identity; + + nomaiWallText._showTextOnStart = false; + + // Don't want to be able to translate until its in a socket + nomaiWallText.GetComponent().enabled = false; + + nomaiWallText.gameObject.SetActive(true); + + var scrollItem = customScroll.GetComponent(); + + // Idk why this thing is always around + GameObject.Destroy(customScroll.transform.Find("Arc_BH_City_Forum_2").gameObject); + + // This variable is the bane of my existence i dont get it + scrollItem._nomaiWallText = nomaiWallText; + + // Because the scroll was already awake it does weird shit in Awake and makes some of the entries in this array be null + scrollItem._colliders = new OWCollider[] { scrollItem.GetComponent() }; + + // Else when you put them down you can't pick them back up + customScroll.GetComponent()._physicsRemoved = false; + + // Place scroll + customScroll.transform.parent = sector?.transform ?? planetGO.transform; + customScroll.transform.position = planetGO.transform.TransformPoint(info.position ?? Vector3.zero); + + var up = planetGO.transform.InverseTransformPoint(customScroll.transform.position).normalized; + customScroll.transform.rotation = Quaternion.FromToRotation(customScroll.transform.up, up) * customScroll.transform.rotation; + + customScroll.SetActive(true); + + // Enable the collider and renderer + Main.Instance.ModHelper.Events.Unity.RunWhen( + () => Main.IsSystemReady, + () => + { + Logger.Log("Fixing scroll!"); + scrollItem._nomaiWallText = nomaiWallText; + scrollItem.SetSector(sector); + customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Geo").GetComponent().enabled = true; + customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Collider").gameObject.SetActive(true); + nomaiWallText.gameObject.GetComponent().enabled = false; + customScroll.GetComponent().enabled = true; + } + ); + break; } - - // Idk do we have to set it active before finding things? - cairnObject.SetActive(true); - - // Make it do the thing when it finishes being knocked over - foreach (var rock in cairnObject.GetComponent()._rocks) + case PropModule.NomaiTextInfo.NomaiTextType.Computer: { - rock._returning = false; - rock._owCollider.SetActivation(true); - rock.enabled = false; + var computerObject = _computerPrefab.InstantiateInactive(); + + computerObject.transform.parent = sector?.transform ?? planetGO.transform; + computerObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero); + + var up = computerObject.transform.position - planetGO.transform.position; + if (info.normal != null) up = planetGO.transform.TransformDirection(info.normal); + computerObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * computerObject.transform.rotation; + + var computer = computerObject.GetComponent(); + computer.SetSector(sector); + + computer._dictNomaiTextData = MakeNomaiTextDict(xmlPath); + computer._nomaiTextAsset = new TextAsset(xmlPath); + AddTranslation(xmlPath); + + // Make sure the computer model is loaded + OWAssetHandler.LoadObject(computerObject); + sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(computerObject)); + + computerObject.SetActive(true); + break; } - - // So we can actually knock it over - cairnObject.GetComponent().enabled = true; - - var nomaiWallText = cairnObject.transform.Find("Props_TH_ClutterSmall/Arc_Short").GetComponent(); - nomaiWallText.SetSector(sector); - - nomaiWallText._dictNomaiTextData = MakeNomaiTextDict(xmlPath); - nomaiWallText._nomaiTextAsset = new TextAsset(xmlPath); - AddTranslation(xmlPath); - - // Make sure the computer model is loaded - OWAssetHandler.LoadObject(cairnObject); - sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(cairnObject)); - } - else if (info.type == "recorder") - { - var recorderObject = _recorderPrefab.InstantiateInactive(); - - recorderObject.transform.parent = sector?.transform ?? planetGO.transform; - recorderObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero); - - if (info.rotation != null) + case PropModule.NomaiTextInfo.NomaiTextType.Cairn: { - recorderObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation)); + var cairnObject = _cairnPrefab.InstantiateInactive(); + + cairnObject.transform.parent = sector?.transform ?? planetGO.transform; + cairnObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero); + + if (info.rotation != null) + { + cairnObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation)); + } + else + { + // By default align it to normal + var up = (cairnObject.transform.position - planetGO.transform.position).normalized; + cairnObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * cairnObject.transform.rotation; + } + + // Idk do we have to set it active before finding things? + cairnObject.SetActive(true); + + // Make it do the thing when it finishes being knocked over + foreach (var rock in cairnObject.GetComponent()._rocks) + { + rock._returning = false; + rock._owCollider.SetActivation(true); + rock.enabled = false; + } + + // So we can actually knock it over + cairnObject.GetComponent().enabled = true; + + var nomaiWallText = cairnObject.transform.Find("Props_TH_ClutterSmall/Arc_Short").GetComponent(); + nomaiWallText.SetSector(sector); + + nomaiWallText._dictNomaiTextData = MakeNomaiTextDict(xmlPath); + nomaiWallText._nomaiTextAsset = new TextAsset(xmlPath); + AddTranslation(xmlPath); + + // Make sure the computer model is loaded + OWAssetHandler.LoadObject(cairnObject); + sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(cairnObject)); + break; } - else + case PropModule.NomaiTextInfo.NomaiTextType.Recorder: { - var up = recorderObject.transform.position - planetGO.transform.position; - recorderObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * recorderObject.transform.rotation; + var recorderObject = _recorderPrefab.InstantiateInactive(); + + recorderObject.transform.parent = sector?.transform ?? planetGO.transform; + recorderObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero); + + if (info.rotation != null) + { + recorderObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation)); + } + else + { + var up = recorderObject.transform.position - planetGO.transform.position; + recorderObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * recorderObject.transform.rotation; + } + + var nomaiText = recorderObject.GetComponentInChildren(); + nomaiText.SetSector(sector); + + nomaiText._dictNomaiTextData = MakeNomaiTextDict(xmlPath); + nomaiText._nomaiTextAsset = new TextAsset(xmlPath); + AddTranslation(xmlPath); + + // Make sure the recorder model is loaded + OWAssetHandler.LoadObject(recorderObject); + sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(recorderObject)); + + recorderObject.SetActive(true); + + recorderObject.transform.Find("InteractSphere").gameObject.GetComponent().enabled = true; + break; } - - var nomaiText = recorderObject.GetComponentInChildren(); - nomaiText.SetSector(sector); - - nomaiText._dictNomaiTextData = MakeNomaiTextDict(xmlPath); - nomaiText._nomaiTextAsset = new TextAsset(xmlPath); - AddTranslation(xmlPath); - - // Make sure the recorder model is loaded - OWAssetHandler.LoadObject(recorderObject); - sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(recorderObject)); - - recorderObject.SetActive(true); - - recorderObject.transform.Find("InteractSphere").gameObject.GetComponent().enabled = true; - } - else - { - Logger.LogError($"Unsupported NomaiText type {info.type}"); + default: + Logger.LogError($"Unsupported NomaiText type {info.type}"); + break; } } @@ -304,18 +311,19 @@ namespace NewHorizons.Builder.Props var parent = parentID == -1 ? null : arcsByID[parentID]; GameObject arc; - var type = info.arcInfo != null ? info.arcInfo[i].type : "adult"; - if (type == "child") + var type = info.arcInfo != null ? info.arcInfo[i].type : PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult; + switch (type) { - arc = _childArcPrefabs[Random.Range(0, _childArcPrefabs.Count())].InstantiateInactive(); - } - else if (type == "stranger" && _ghostArcPrefabs.Count() > 0) // It could be empty if they dont have the DLC - { - arc = _ghostArcPrefabs[Random.Range(0, _ghostArcPrefabs.Count())].InstantiateInactive(); - } - else - { - arc = _arcPrefabs[Random.Range(0, _arcPrefabs.Count())].InstantiateInactive(); + case PropModule.NomaiTextArcInfo.NomaiTextArcType.Child: + arc = _childArcPrefabs[Random.Range(0, _childArcPrefabs.Count())].InstantiateInactive(); + break; + case PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcPrefabs.Any(): + arc = _ghostArcPrefabs[Random.Range(0, _ghostArcPrefabs.Count())].InstantiateInactive(); + break; + case PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult: + default: + arc = _arcPrefabs[Random.Range(0, _arcPrefabs.Count())].InstantiateInactive(); + break; } arc.transform.parent = conversationZone.transform; diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index 5cbee144..1c46d054 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -14,9 +14,18 @@ namespace NewHorizons.Builder.Props private static GameObject _autoPrefab; public static void Make(GameObject go, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) { - if (info.type == "autoProjector") MakeAutoProjector(go, sector, info, mod); - else if (info.type == "slideReel") MakeSlideReel(go, sector, info, mod); - else Logger.LogError($"Invalid projection type {info.type}"); + switch (info.type) + { + case PropModule.ProjectionInfo.SlideShowType.AutoProjector: + MakeAutoProjector(go, sector, info, mod); + break; + case PropModule.ProjectionInfo.SlideShowType.SlideReel: + MakeSlideReel(go, sector, info, mod); + break; + default: + Logger.LogError($"Invalid projection type {info.type}"); + break; + } } private static void MakeSlideReel(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) diff --git a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs index 19081f08..acdefd3b 100644 --- a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs @@ -5,6 +5,7 @@ using NewHorizons.Utility; using System; using System.Collections.Generic; using System.Linq; +using NewHorizons.External.Modules.VariableSize; using UnityEngine; using UnityEngine.UI; using Logger = NewHorizons.Utility.Logger; @@ -511,8 +512,13 @@ namespace NewHorizons.Builder.ShipLog { try { - if (body.Config?.Singularity?.Type == "BlackHole") return Color.black; - if (body.Config?.Singularity?.Type == "WhiteHole") return Color.white; + switch (body.Config?.Singularity?.Type) + { + case SingularityModule.SingularityType.BlackHole: + return Color.black; + case SingularityModule.SingularityType.WhiteHole: + return Color.white; + } var starColor = body.Config?.Star?.Tint; if (starColor != null) return starColor.ToColor(); diff --git a/NewHorizons/Builder/ShipLog/RevealBuilder.cs b/NewHorizons/Builder/ShipLog/RevealBuilder.cs index 7dceadc6..97a397c1 100644 --- a/NewHorizons/Builder/ShipLog/RevealBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RevealBuilder.cs @@ -8,23 +8,22 @@ namespace NewHorizons.Builder.ShipLog { public static void Make(GameObject go, Sector sector, PropModule.RevealInfo info, IModBehaviour mod) { - GameObject newRevealGO = MakeGameObject(go, sector, info, mod); - switch (info.revealOn.ToLower()) + var newRevealGO = MakeGameObject(go, sector, info, mod); + switch (info.revealOn) { - case "enter": + case PropModule.RevealInfo.RevealVolumeType.Enter: MakeTrigger(newRevealGO, sector, info, mod); break; - case "observe": + case PropModule.RevealInfo.RevealVolumeType.Observe: MakeObservable(newRevealGO, sector, info, mod); break; - case "snapshot": + case PropModule.RevealInfo.RevealVolumeType.Snapshot: MakeSnapshot(newRevealGO, sector, info, mod); break; default: Logger.LogError("Invalid revealOn: " + info.revealOn); break; } - newRevealGO.SetActive(true); } diff --git a/NewHorizons/Components/Orbital/Gravity.cs b/NewHorizons/Components/Orbital/Gravity.cs index 4cbd050c..029d50eb 100644 --- a/NewHorizons/Components/Orbital/Gravity.cs +++ b/NewHorizons/Components/Orbital/Gravity.cs @@ -17,7 +17,7 @@ namespace NewHorizons.Components.Orbital { var surfaceAcceleration = module.SurfaceGravity; var upperSurfaceRadius = module.SurfaceSize; - int falloffExponent = module.GravityFallOff.ToUpper().Equals("LINEAR") ? 1 : 2; + int falloffExponent = module.GravityFallOff == GravityFallOff.Linear ? 1 : 2; Mass = surfaceAcceleration * Mathf.Pow(upperSurfaceRadius, falloffExponent) / GravityVolume.GRAVITATIONAL_CONSTANT; Power = falloffExponent; diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 0018f280..f6e280d5 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -1,41 +1,150 @@ using NewHorizons.External.Modules; using NewHorizons.External.Modules.VariableSize; -using NewHorizons.Utility; -using UnityEngine; +using Newtonsoft.Json; namespace NewHorizons.External.Configs { + /// + /// A planet or body to generate + /// + [JsonObject] public class PlanetConfig { - public string Name { get; set; } - public string Version { get; set; } - public string StarSystem { get; set; } = "SolarSystem"; - public bool Destroy { get; set; } - public string[] RemoveChildren { get; set; } - public int BuildPriority { get; set; } = -1; - public bool CanShowOnTitle { get; set; } = true; - public bool IsQuantumState { get; set; } - public BaseModule Base { get; set; } - public AtmosphereModule Atmosphere { get; set; } - public OrbitModule Orbit { get; set; } - public RingModule Ring { get; set; } - public HeightMapModule HeightMap { get; set; } - public ProcGenModule ProcGen { get; set; } - public AsteroidBeltModule AsteroidBelt { get; set; } - public StarModule Star { get; set; } - public FocalPointModule FocalPoint { get; set; } - public PropModule Props { get; set; } - public ShipLogModule ShipLog { get; set; } - public SpawnModule Spawn { get; set; } - public SignalModule Signal { get; set; } - public SingularityModule Singularity { get; set; } - public LavaModule Lava { get; set; } - public WaterModule Water { get; set; } - public SandModule Sand { get; set; } - public FunnelModule Funnel { get; set; } + /// + /// Unique name of your planet + /// + public string Name; + + /// + /// Version of New Horizons this config is using (Doesn't do anything) + /// + public string Version; + + /// + /// Unique star system containing your planet + /// + public string StarSystem = "SolarSystem"; + + /// + /// `true` if you want to delete this planet + /// + public bool Destroy; + + /// + /// A list of paths to child GameObjects to destroy on this planet + /// + public string[] RemoveChildren; + + /// + /// Set to a higher number if you wish for this body to be built sooner + /// + public int BuildPriority = -1; + + /// + /// Should this planet ever be shown on the title screen? + /// + public bool CanShowOnTitle = true; + + /// + /// Does this config describe a quantum state of a custom planet defined in another file? + /// + public bool IsQuantumState; + + /// + /// Base Properties of this Body + /// + public BaseModule Base; + + /// + /// Describes this Body's atmosphere + /// + public AtmosphereModule Atmosphere; + + /// + /// Describes this Body's orbit (or lack there of) + /// + public OrbitModule Orbit; + + /// + /// Creates a ring around the planet + /// + public RingModule Ring; + + /// + /// Generate the surface of this planet using a heightmap + /// + public HeightMapModule HeightMap; + + /// + /// Procedural Generation + /// + public ProcGenModule ProcGen; + + /// + /// Generate asteroids around this body + /// + public AsteroidBeltModule AsteroidBelt; + + /// + /// Make this body a star + /// + public StarModule Star; + + /// + /// Make this body into a focal point (barycenter) + /// + public FocalPointModule FocalPoint; + + /// + /// Spawn various objects on this body + /// + public PropModule Props; + + /// + /// Add ship log entries to this planet and describe how it looks in map mode + /// + public ShipLogModule ShipLog; + + /// + /// Spawn the player at this planet + /// + public SpawnModule Spawn; + + /// + /// Add signals that can be heard via the signal-scope to this planet + /// + public SignalModule Signal; + + /// + /// Add a black or white hole to this planet + /// + public SingularityModule Singularity; + + /// + /// Add lava to this planet + /// + public LavaModule Lava; + + /// + /// Add water to this planet + /// + public WaterModule Water; + + /// + /// Add sand to this planet + /// + public SandModule Sand; + + /// + /// Add funnel from this planet to another + /// + public FunnelModule Funnel; #region Obsolete - [System.Obsolete("ChildrenToDestroy is deprecated, please use RemoveChildren instead")] public string[] ChildrenToDestroy { get; set; } + + [System.Obsolete("ChildrenToDestroy is deprecated, please use RemoveChildren instead")] + public string[] ChildrenToDestroy; + #endregion Obsolete public PlanetConfig() @@ -57,22 +166,28 @@ namespace NewHorizons.External.Configs #pragma warning disable 612, 618 if (Base.WaterSize != 0) { - Water = new WaterModule(); - Water.Size = Base.WaterSize; - Water.Tint = Base.WaterTint; + Water = new WaterModule + { + Size = Base.WaterSize, + Tint = Base.WaterTint + }; } if (Base.LavaSize != 0) { - Lava = new LavaModule(); - Lava.Size = Base.LavaSize; + Lava = new LavaModule + { + Size = Base.LavaSize + }; } if (Base.BlackHoleSize != 0) { - Singularity = new SingularityModule(); - Singularity.Type = "BlackHole"; - Singularity.Size = Base.BlackHoleSize; + Singularity = new SingularityModule + { + Type = SingularityModule.SingularityType.BlackHole, + Size = Base.BlackHoleSize + }; } if (Base.IsSatellite) @@ -102,7 +217,7 @@ namespace NewHorizons.External.Configs TexturePath = Atmosphere.Cloud, CapPath = Atmosphere.CloudCap, RampPath = Atmosphere.CloudRamp, - FluidType = Atmosphere.CloudFluidType, + FluidType = Atmosphere.FluidType, UseBasicCloudShader = Atmosphere.UseBasicCloudShader, Unlit = !Atmosphere.ShadowsOnClouds, }; @@ -123,4 +238,4 @@ namespace NewHorizons.External.Configs #pragma warning restore 612, 618 } } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index b88c5483..291ed7ec 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -1,14 +1,51 @@ -namespace NewHorizons.External.Configs +using Newtonsoft.Json; + +namespace NewHorizons.External.Configs { + /// + /// Configuration for a specific star system + /// + [JsonObject] public class StarSystemConfig { + /// + /// Whether this system can be warped to via the warp drive + /// public bool canEnterViaWarpDrive = true; - public bool startHere = false; + + /// + /// Set to `true` if you want to spawn here after dying, not Timber Hearth. You can still warp back to the main star system. + /// + public bool startHere; + + /// + /// Do you want a clean slate for this star system? Or will it be a modified version of the original. + /// public bool destroyStockPlanets = true; + + /// + /// Set to the FactID that must be revealed before it can be warped to. Don't set `CanEnterViaWarpDrive` to `false` if you're using this, that would make no sense. + /// public string factRequiredForWarp; + + /// + /// Should the player be sent back in time after 22 minutes? + /// public bool enableTimeLoop = true; + + /// + /// Should the player be unable to use their map in this system? + /// public bool mapRestricted; + + /// + /// [DEPRECATED] Not implemented + /// public NomaiCoordinates coords; + + /// + /// Customize the skybox for this system + /// public SkyboxConfig skybox; public class NomaiCoordinates @@ -18,11 +55,23 @@ public int[] z; } + [JsonObject] public class SkyboxConfig { - public string assetBundle = null; - public string path = null; - public bool destroyStarField = false; + /// + /// Path to the Unity asset bundle to load the skybox material from + /// + public string assetBundle; + + /// + /// Path to the material within the asset bundle specified by `assetBundle` to use for the skybox + /// + public string path; + + /// + /// Whether to destroy the star field around the player + /// + public bool destroyStarField; } } } diff --git a/NewHorizons/External/Modules/AsteroidBeltModule.cs b/NewHorizons/External/Modules/AsteroidBeltModule.cs index a128a3b2..b46624ee 100644 --- a/NewHorizons/External/Modules/AsteroidBeltModule.cs +++ b/NewHorizons/External/Modules/AsteroidBeltModule.cs @@ -1,15 +1,53 @@ -namespace NewHorizons.External.Modules +using Newtonsoft.Json; + +namespace NewHorizons.External.Modules { + [JsonObject] public class AsteroidBeltModule { - public float InnerRadius { get; set; } - public float OuterRadius { get; set; } - public float MinSize { get; set; } = 20; - public float MaxSize { get; set; } = 50; - public int Amount { get; set; } = -1; - public float Inclination { get; set; } - public float LongitudeOfAscendingNode { get; set; } - public int RandomSeed { get; set; } - public ProcGenModule ProcGen { get; set; } + /// + /// Lowest distance from the planet asteroids can spawn + /// + public float InnerRadius; + + /// + /// Greatest distance from the planet asteroids can spawn + /// + public float OuterRadius; + + /// + /// Minimum size of the asteroids. + /// + public float MinSize = 20f; + + /// + /// Maximum size of the asteroids. + /// + public float MaxSize = 50f; + + /// + /// Amount of asteroids to create. + /// + public int Amount = -1; + + /// + /// Angle between the rings and the equatorial plane of the planet. + /// + public float Inclination; + + /// + /// Angle defining the point where the rings rise up from the planet's equatorial plane if inclination is nonzero. + /// + public float LongitudeOfAscendingNode; + + /// + /// Number used to randomize asteroid positions + /// + public int RandomSeed; + + /// + /// How the asteroids are generated + /// + public ProcGenModule ProcGen; } } diff --git a/NewHorizons/External/Modules/AtmosphereModule.cs b/NewHorizons/External/Modules/AtmosphereModule.cs index eef320fd..18134983 100644 --- a/NewHorizons/External/Modules/AtmosphereModule.cs +++ b/NewHorizons/External/Modules/AtmosphereModule.cs @@ -1,54 +1,162 @@ -using NewHorizons.Utility; -using UnityEngine; +using System.Runtime.Serialization; +using NewHorizons.Utility; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; namespace NewHorizons.External.Modules { + public enum CloudFluidType + { + [EnumMember(Value = @"NONE")] + None = 0, + + [EnumMember(Value = @"WATER")] + Water = 1, + + [EnumMember(Value = @"CLOUD")] + Cloud = 2, + + [EnumMember(Value = @"SAND")] + Sand = 3, + + [EnumMember(Value = @"PLASMA")] + Plasma = 4 + } + + [JsonObject] public class AtmosphereModule { - public float Size { get; set; } - public MColor AtmosphereTint { get; set; } - public MColor FogTint { get; set; } - public float FogDensity { get; set; } - public float FogSize { get; set; } - public bool HasRain { get; set; } - public bool HasSnow { get; set; } - public bool HasOxygen { get; set; } - public bool UseAtmosphereShader { get; set; } - public CloudInfo Clouds { get; set; } + /// + /// Scale height of the atmosphere + /// + public float Size; + + /// + /// Colour of atmospheric shader on the planet. + /// + public MColor AtmosphereTint; + + /// + /// Colour of fog on the planet, if you put fog. + /// + public MColor FogTint; + + /// + /// How dense the fog is, if you put fog. + /// + // FIXME: Min & Max Needed! + public float FogDensity; + + /// + /// Radius of fog sphere, independent of the atmosphere. This has to be set for there to be fog. + /// + public float FogSize; + + /// + /// Does this planet have rain? + /// + public bool HasRain; + + /// + /// Does this planet have snow? + /// + public bool HasSnow; + + /// + /// Lets you survive on the planet without a suit. + /// + public bool HasOxygen; + + /// + /// Whether we use an atmospheric shader on the planet. Doesn't affect clouds, fog, rain, snow, oxygen, etc. Purely visual. + /// + public bool UseAtmosphereShader; + + /// + /// Describes the clouds in the atmosphere + /// + public CloudInfo Clouds; #region Obsolete - [System.Obsolete("CloudTint is deprecated, please use CloudInfo instead")] public MColor CloudTint { get; set; } - [System.Obsolete("CloudTint is deprecated, please use CloudInfo instead")] public string Cloud { get; set; } - [System.Obsolete("CloudCap is deprecated, please use CloudInfo instead")] public string CloudCap { get; set; } - [System.Obsolete("CloudRamp is deprecated, please use CloudInfo instead")] public string CloudRamp { get; set; } - [System.Obsolete("CloudFluidType is deprecated, please use CloudInfo instead")] public string CloudFluidType { get; set; } - [System.Obsolete("UseBasicCloudShader is deprecated, please use CloudInfo instead")] public bool UseBasicCloudShader { get; set; } - [System.Obsolete("ShadowsOnClouds is deprecated, please use CloudInfo instead")] public bool ShadowsOnClouds { get; set; } = true; - [System.Obsolete("HasAtmosphere is deprecated, please use UseAtmosphereShader instead")] public bool HasAtmosphere { get; set; } + [System.Obsolete("CloudTint is deprecated, please use CloudInfo instead")] public MColor CloudTint; + [System.Obsolete("CloudTint is deprecated, please use CloudInfo instead")] public string Cloud; + [System.Obsolete("CloudCap is deprecated, please use CloudInfo instead")] public string CloudCap; + [System.Obsolete("CloudRamp is deprecated, please use CloudInfo instead")] public string CloudRamp; + [System.Obsolete("CloudFluidType is deprecated, please use CloudInfo instead")] + [JsonConverter(typeof(StringEnumConverter))] + public CloudFluidType? FluidType; + [System.Obsolete("UseBasicCloudShader is deprecated, please use CloudInfo instead")] public bool UseBasicCloudShader; + [System.Obsolete("ShadowsOnClouds is deprecated, please use CloudInfo instead")] public bool ShadowsOnClouds = true; + [System.Obsolete("HasAtmosphere is deprecated, please use UseAtmosphereShader instead")] public bool HasAtmosphere; #endregion Obsolete public class AirInfo { - public float Scale { get; set; } - public bool HasOxygen { get; set; } - public bool IsRaining { get; set; } - public bool IsSnowing { get; set; } + public float Scale; + public bool HasOxygen; + public bool IsRaining; + public bool IsSnowing; } + [JsonObject] public class CloudInfo { - public float OuterCloudRadius { get; set; } - public float InnerCloudRadius { get; set; } - public MColor Tint { get; set; } - public string TexturePath { get; set; } - public string CapPath { get; set; } - public string RampPath { get; set; } - public string FluidType { get; set; } - public bool UseBasicCloudShader { get; set; } - public bool Unlit { get; set; } - public bool HasLightning { get; set; } - public MGradient[] LightningGradient { get; set; } + /// + /// Radius from the center to the outer layer of the clouds. + /// + public float OuterCloudRadius; + + /// + /// Radius from the center to the inner layer of the clouds. + /// + public float InnerCloudRadius; + + /// + /// Colour of the inner cloud layer. + /// + public MColor Tint; + + /// + /// Relative filepath to the cloud texture, if the planet has clouds. + /// + public string TexturePath; + + /// + /// Relative filepath to the cloud cap texture, if the planet has clouds. + /// + public string CapPath; + + /// + /// Relative filepath to the cloud ramp texture, if the planet has clouds. If you don't put anything here it will be auto-generated. + /// + public string RampPath; + + /// + /// Fluid type for sounds/effects when colliding with this cloud. + /// + [JsonConverter(typeof(StringEnumConverter))] + public CloudFluidType? FluidType = CloudFluidType.Cloud; + + /// + /// Set to `false` in order to use Giant's deep shader. Set to `true` to just apply the cloud texture as is. + /// + public bool UseBasicCloudShader; + + /// + /// If the top layer shouldn't have shadows. Set to true if you're making a brown dwarf for example. + /// + public bool Unlit; + + /// + /// Add lightning to this planet like on Giant's Deep. + /// + public bool HasLightning; + + /// + /// Colour gradient of the lightning, time is in seconds. + /// + public MGradient[] LightningGradient; } } } diff --git a/NewHorizons/External/Modules/BaseModule.cs b/NewHorizons/External/Modules/BaseModule.cs index 5b0b299e..b270a6f4 100644 --- a/NewHorizons/External/Modules/BaseModule.cs +++ b/NewHorizons/External/Modules/BaseModule.cs @@ -1,30 +1,99 @@ -using NewHorizons.Utility; +using System.Runtime.Serialization; +using NewHorizons.Utility; +using Newtonsoft.Json; + namespace NewHorizons.External.Modules { + public enum GravityFallOff + { + [EnumMember(Value = @"linear")] + Linear = 0, + + [EnumMember(Value = @"inverseSquared")] + InverseSquared = 1 + } + + [JsonObject] public class BaseModule { - public bool HasMapMarker { get; set; } - public float AmbientLight { get; set; } - public float SurfaceGravity { get; set; } - public string GravityFallOff { get; set; } = "linear"; - public float SurfaceSize { get; set; } - public float SphereOfInfluence { get; set; } - public float GroundSize { get; set; } - public bool HasCometTail { get; set; } - public MVector3 CometTailRotation { get; set; } - public bool HasReferenceFrame { get; set; } = true; - public bool CenterOfSolarSystem { get; set; } = false; - public float CloakRadius { get; set; } = 0f; - public bool InvulnerableToSun { get; set; } - public bool ShowMinimap { get; set; } = true; + /// + /// If the body should have a marker on the map screen. + /// + public bool HasMapMarker; + + /// + /// The intensity of light the dark side of the body should have. Timber Hearth has `1.4` for reference + /// + public float AmbientLight; + + /// + /// The acceleration due to gravity felt as the surfaceSize. Timber Hearth has 12 for reference + /// + public float SurfaceGravity; + + /// + /// How gravity falls off with distance. Most planets use linear but the sun and some moons use inverseSquared. + /// + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public GravityFallOff GravityFallOff = GravityFallOff.Linear; + + /// + /// A scale height used for a number of things. Should be the approximate radius of the body. + /// + public float SurfaceSize; + + /// + /// An override for the radius of the planet's gravitational sphere of influence. Optional + /// + public float SphereOfInfluence; + + /// + /// Radius of a simple sphere used as the ground for the planet. If you want to use more complex terrain, leave this as 0. + /// + public float GroundSize; + + /// + /// If you want the body to have a tail like the Interloper. + /// + public bool HasCometTail; + + /// + /// If it has a comet tail, it'll be oriented according to these Euler angles. + /// + public MVector3 CometTailRotation; + + /// + /// Allows the object to be targeted on the map. + /// + public bool HasReferenceFrame = true; + + /// + /// Set this to true if you are replacing the sun with a different body. Only one object in a star system should ever have this set to true. + /// + public bool CenterOfSolarSystem = false; + + /// + /// Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you don't want a cloak, leave this as 0. + /// + public float CloakRadius = 0f; + + /// + /// Can this planet survive entering a star? + /// + public bool InvulnerableToSun; + + /// + /// Do we show the minimap when walking around this planet? + /// + public bool ShowMinimap = true; #region Obsolete - [System.Obsolete("IsSatellite is deprecated, please use ShowMinimap instead")] public bool IsSatellite { get; set; } - [System.Obsolete("BlackHoleSize is deprecated, please use SingularityModule instead")] public float BlackHoleSize { get; set; } - [System.Obsolete("LavaSize is deprecated, please use LavaModule instead")] public float LavaSize { get; set; } - [System.Obsolete("WaterTint is deprecated, please use WaterModule instead")] public float WaterSize { get; set; } - [System.Obsolete("WaterTint is deprecated, please use WaterModule instead")] public MColor WaterTint { get; set; } - [System.Obsolete("HasAmbientLight is deprecated, please use AmbientLight instead")] public bool HasAmbientLight { get; set; } + [System.Obsolete("IsSatellite is deprecated, please use ShowMinimap instead")] public bool IsSatellite; + [System.Obsolete("BlackHoleSize is deprecated, please use SingularityModule instead")] public float BlackHoleSize; + [System.Obsolete("LavaSize is deprecated, please use LavaModule instead")] public float LavaSize; + [System.Obsolete("WaterTint is deprecated, please use WaterModule instead")] public float WaterSize; + [System.Obsolete("WaterTint is deprecated, please use WaterModule instead")] public MColor WaterTint; + [System.Obsolete("HasAmbientLight is deprecated, please use AmbientLight instead")] public bool HasAmbientLight; #endregion Obsolete } } diff --git a/NewHorizons/External/Modules/FocalPointModule.cs b/NewHorizons/External/Modules/FocalPointModule.cs index 02bca3e0..0ce3105b 100644 --- a/NewHorizons/External/Modules/FocalPointModule.cs +++ b/NewHorizons/External/Modules/FocalPointModule.cs @@ -1,8 +1,18 @@ -namespace NewHorizons.External.Modules +using Newtonsoft.Json; + +namespace NewHorizons.External.Modules { + [JsonObject] public class FocalPointModule { - public string Primary { get; set; } - public string Secondary { get; set; } + /// + /// Name of the primary planet in this binary system + /// + public string Primary; + + /// + /// Name of the secondary planet in this binary system + /// + public string Secondary; } } diff --git a/NewHorizons/External/Modules/HeightMapModule.cs b/NewHorizons/External/Modules/HeightMapModule.cs index de29f105..1cb6b253 100644 --- a/NewHorizons/External/Modules/HeightMapModule.cs +++ b/NewHorizons/External/Modules/HeightMapModule.cs @@ -3,10 +3,29 @@ namespace NewHorizons.External.Modules { public class HeightMapModule { - public string HeightMap { get; set; } - public string TextureMap { get; set; } - public float MinHeight { get; set; } - public float MaxHeight { get; set; } - public MVector3 Stretch { get; set; } + /// + /// Relative filepath to the texture used for the terrain height. + /// + public string HeightMap; + + /// + /// Relative filepath to the texture used for the terrain. + /// + public string TextureMap; + + /// + /// The lowest points on your planet will be at this height. + /// + public float MinHeight; + + /// + /// The highest points on your planet will be at this height. + /// + public float MaxHeight; + + /// + /// The scale of the terrain. + /// + public MVector3 Stretch; } } diff --git a/NewHorizons/External/Modules/OrbitModule.cs b/NewHorizons/External/Modules/OrbitModule.cs index 93e0577f..ddcb571b 100644 --- a/NewHorizons/External/Modules/OrbitModule.cs +++ b/NewHorizons/External/Modules/OrbitModule.cs @@ -1,25 +1,96 @@ using NewHorizons.Components.Orbital; using NewHorizons.Utility; +using Newtonsoft.Json; +using UnityEngine; + namespace NewHorizons.External.Modules { public class OrbitModule : IOrbitalParameters { + /// + /// The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius. + /// public float SemiMajorAxis { get; set; } + + /// + /// The angle (in degrees) between the body's orbit and the plane of the star system + /// public float Inclination { get; set; } + + /// + /// The name of the body this one will orbit around + /// public string PrimaryBody { get; set; } + + /// + /// Is this the moon of a planet? Used for determining when its name is shown on the map. + /// public bool IsMoon { get; set; } + + /// + /// An angle (in degrees) defining the point where the orbit of the body rises above the orbital plane if it has nonzero inclination. + /// public float LongitudeOfAscendingNode { get; set; } + + /// + /// At 0 the orbit is a circle. The closer to 1 it is, the more oval-shaped the orbit is. + /// + // FIXME: Needs Min & Max! public float Eccentricity { get; set; } + + /// + /// An angle (in degrees) defining the location of the periapsis (the closest distance to it's primary body) if it has nonzero eccentricity. + /// public float ArgumentOfPeriapsis { get; set; } + + /// + /// Where the planet should start off in its orbit in terms of the central angle. + /// public float TrueAnomaly { get; set; } + + /// + /// The angle between the normal to the orbital plane and its axis of rotation. + /// public float AxialTilt { get; set; } + + /// + /// Rotation period in minutes. + /// public float SiderealPeriod { get; set; } + + /// + /// Should the body always have one side facing its primary? + /// public bool IsTidallyLocked { get; set; } + + /// + /// If it is tidally locked, this direction will face towards the primary. Ex: Interloper uses `0, -1, 0`. Most planets will want something like `-1, 0, 0`. + /// public MVector3 AlignmentAxis { get; set; } + + /// + /// Referring to the orbit line in the map screen. + /// public bool ShowOrbitLine { get; set; } = true; + + /// + /// Should the orbit line be dotted? + /// public bool DottedOrbitLine { get; set; } = false; + + /// + /// Is the body meant to stay in one place without moving? + /// public bool IsStatic { get; set; } + + /// + /// Colour of the orbit-line in the map view. + /// public MColor Tint { get; set; } + + /// + /// Should we just draw a line behind its orbit instead of the entire circle/ellipse? + /// public bool TrackingOrbitLine { get; set; } = false; public OrbitalParameters GetOrbitalParameters(Gravity primaryGravity, Gravity secondaryGravity) diff --git a/NewHorizons/External/Modules/ProcGenModule.cs b/NewHorizons/External/Modules/ProcGenModule.cs index be14d406..84c79902 100644 --- a/NewHorizons/External/Modules/ProcGenModule.cs +++ b/NewHorizons/External/Modules/ProcGenModule.cs @@ -1,10 +1,12 @@ using NewHorizons.Utility; +using Newtonsoft.Json; namespace NewHorizons.External.Modules { - public class ProcGenModule + [JsonObject] + public class ProcGenModule { - public float Scale { get; set; } - public MColor Color { get; set; } + public float Scale; + public MColor Color; } } diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 23a33931..df4fc361 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -1,161 +1,587 @@ -using NewHorizons.Utility; +using System.Runtime.Serialization; +using NewHorizons.Utility; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + namespace NewHorizons.External.Modules { + [JsonObject] public class PropModule { + /// + /// Scatter props around this planet's surface + /// public ScatterInfo[] Scatter; + + /// + /// Place props in predefined positions on the planet + /// public DetailInfo[] Details; + + /// + /// Add rafts to this planet + /// public RaftInfo[] Rafts; + + /// + /// Add Geysers to this planet + /// public GeyserInfo[] Geysers; + + /// + /// Add tornadoes to this planet + /// public TornadoInfo[] Tornados; + + /// + /// Add volcanoes to this planet + /// public VolcanoInfo[] Volcanoes; + + /// + /// Add dialogue triggers to this planet + /// public DialogueInfo[] Dialogue; + + /// + /// Add triggers that reveal parts of the ship log on this planet + /// public RevealInfo[] Reveal; + + /// + /// Add ship log entry locations on this planet + /// public EntryLocationInfo[] EntryLocation; + + /// + /// Add translatable text to this planet + /// public NomaiTextInfo[] NomaiText; + + /// + /// Add slideshows (from the DLC) to the planet + /// public ProjectionInfo[] SlideShows; + + /// + /// Details which will be shown from 50km away. Meant to be lower resolution. + /// public DetailInfo[] ProxyDetails; + [JsonObject] public class ScatterInfo { - public int seed = 0; + /// + /// The number used as entropy for scattering the props + /// + public int seed; + + /// + /// Number of props to scatter + /// public int count; + + /// + /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle + /// public string path; + + /// + /// Relative filepath to an asset-bundle" + /// public string assetBundle; + + /// + /// Offset this prop once it is placed + /// public MVector3 offset; + + /// + /// Rotate this prop once it is placed + /// public MVector3 rotation; - public float scale { get; set; } = 1f; + + /// + /// Scale this prop once it is placed + /// + public float scale = 1f; } + [JsonObject] public class DetailInfo { + /// + /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle + /// public string path; - public string objFilePath; //obsolete DO NOT DOCUMENT - public string mtlFilePath; //obsolete + + /// + /// [DEPRECATED] Path to the .obj file to load a 3d model from + /// + public string objFilePath; + + /// + /// [DEPRECATED] Path to the .mtl file to load a 3d model from + /// + public string mtlFilePath; + + /// + /// Relative filepath to an asset-bundle to load the prefab defined in `path` from/ + /// public string assetBundle; + + /// + /// Position of this prop relative to the body's center + /// public MVector3 position; + + /// + /// Rotate this prop + /// public MVector3 rotation; - public float scale { get; set; } = 1f; + + /// + /// Scale the prop + /// + public float scale = 1f; + + /// + /// Do we override rotation and try to automatically align this object to stand upright on the body's surface? + /// public bool alignToNormal; + + /// + /// A list of children to remove from this detail + /// public string[] removeChildren; + + /// + /// Do we reset all the components on this object? Useful for certain props that have dialogue components attached to them. + /// public bool removeComponents; } + [JsonObject] public class RaftInfo { + /// + /// Position of the raft + /// public MVector3 position; } + [JsonObject] public class GeyserInfo { + /// + /// Position of the geyser + /// public MVector3 position; } + [JsonObject] public class TornadoInfo { + /// + /// Position of the tornado + /// public MVector3 position; + + /// + /// Alternative to setting the position. Will choose a random place at this elevation. + /// public float elevation; - public float height = 30; + + /// + /// The height of this tornado. + /// + public float height = 30f; + + /// + /// The colour of the tornado. + /// public MColor tint; + + /// + /// Should it pull things downwards? Will push them upwards by default. + /// public bool downwards; + + /// + /// The rate at which the tornado will wander around the planet. Set to 0 for it to be stationary. Should be around 0.1. + /// public float wanderRate; - public float wanderDegreesX = 45; - public float wanderDegreesZ = 45; + + /// + /// Angular distance from the starting position that it will wander, in terms of the angle around the x-axis. + /// + public float wanderDegreesX = 45f; + + /// + /// Angular distance from the starting position that it will wander, in terms of the angle around the z-axis. + /// + public float wanderDegreesZ = 45f; } + [JsonObject] public class VolcanoInfo { - public MVector3 position = null; + /// + /// Position of this volcano + /// + public MVector3 position; + + /// + /// Scale of this volcano + /// public float scale = 1; - public MColor stoneTint = null; - public MColor lavaTint = null; + + /// + /// The colour of the meteor's stone. + /// + public MColor stoneTint; + + /// + /// The colour of the meteor's lava. + /// + public MColor lavaTint; + + /// + /// Minimum random speed at which meteors are launched. + /// public float minLaunchSpeed = 50f; + + /// + /// Maximum random speed at which meteors are launched. + /// public float maxLaunchSpeed = 150f; + + /// + /// Minimum time between meteor launches. + /// public float minInterval = 5f; + + /// + /// Maximum time between meteor launches. + /// public float maxInterval = 20f; } + [JsonObject] public class DialogueInfo { + /// + /// When you enter into dialogue, you will look here. + /// public MVector3 position; + + /// + /// Radius of the spherical collision volume where you get the "talk to" prompt when looking at. If you use a remoteTriggerPosition, you can set this to 0 to make the dialogue only trigger remotely. + /// public float radius = 1f; + + /// + /// The radius of the remote trigger volume. + /// public float remoteTriggerRadius; + + /// + /// Relative path to the xml file defining the dialogue. + /// public string xmlFile; + + /// + /// Allows you to trigger dialogue from a distance when you walk into an area. + /// public MVector3 remoteTriggerPosition; + + /// + /// Prevents the dialogue from being created after a specific persistent condition is set. Useful for remote dialogue triggers that you want to have happen only once. + /// public string blockAfterPersistentCondition; + + /// + /// If this dialogue is meant for a character, this is the relative path from the planet to that character's CharacterAnimController or SolanumAnimController. + /// public string pathToAnimController; + + /// + /// If a pathToAnimController is supplied, if you are within this distance the character will look at you. If it is set to 0, they will only look at you when spoken to. + /// public float lookAtRadius; } + [JsonObject] public class RevealInfo { - public string revealOn = "enter"; + public enum RevealVolumeType + { + [EnumMember(Value = @"enter")] + Enter = 0, + + [EnumMember(Value = @"observe")] + Observe = 1, + + [EnumMember(Value = @"snapshot")] + Snapshot = 2 + } + + /// + /// What needs to be done to the volume to unlock the facts + /// + [JsonConverter(typeof(StringEnumConverter))] + public RevealVolumeType revealOn = RevealVolumeType.Enter; + + /// + /// A list of facts to reveal + /// public string[] reveals; + + /// + /// The position to place this volume at + /// public MVector3 position; + + /// + /// The radius of this reveal volume + /// public float radius = 1f; + + /// + /// The max distance the user can be away from the volume to reveal the fact (`snapshot` and `observe` only) + /// public float maxDistance = -1f; // Snapshot & Observe Only + + /// + /// The max view angle (in degrees) the player can see the volume with to unlock the fact (`observe` only) + /// public float maxAngle = 180f; // Observe Only } + [JsonObject] public class EntryLocationInfo { + /// + /// ID of the entry this location relates to + /// public string id; + + /// + /// Whether this location is cloaked + /// public bool cloaked; + + /// + /// The position of this entry location + /// public MVector3 position; } + [JsonObject] public class NomaiTextInfo { + public enum NomaiTextType + { + [EnumMember(Value = @"wall")] + Wall = 0, + + [EnumMember(Value = @"scroll")] + Scroll = 1, + + [EnumMember(Value = @"Computer")] + Computer = 2, + + [EnumMember(Value = @"Cairn")] + Cairn = 3, + + [EnumMember(Value = @"Recorder")] + Recorder = 4 + } + + /// + /// Position of the root of this text + /// public MVector3 position; + + /// + /// The normal vector for this object. Used for writing on walls and positioning computers. + /// public MVector3 normal; + + /// + /// The euler angle rotation of this object. Not required if setting the normal. Computers and cairns will orient themselves to the surface of the planet automatically. + /// public MVector3 rotation; - public string type = "wall"; + + /// + /// The type of object this is. + /// + [JsonConverter(typeof(StringEnumConverter))] + public NomaiTextType type = NomaiTextType.Wall; + + /// + /// The relative path to the xml file for this object. + /// public string xmlFile; + + /// + /// The random seed used to pick what the text arcs will look like. + /// public int seed; // For randomizing arcs + + /// + /// Additional information about each arc in the text + /// public NomaiTextArcInfo[] arcInfo; } + [JsonObject] public class NomaiTextArcInfo { + public enum NomaiTextArcType + { + [EnumMember(Value = @"adult")] + Adult = 0, + + [EnumMember(Value = @"child")] + Child = 1, + + [EnumMember(Value = @"stranger")] + Stranger = 2 + } + + /// + /// The local position of this object on the wall. + /// public MVector2 position; + + /// + /// The z euler angle for this arc. + /// public float zRotation; - public string type = "adult"; + + /// + /// The type of text to display. + /// + public NomaiTextArcType type = NomaiTextArcType.Adult; } + [JsonObject] public class ProjectionInfo { + public enum SlideShowType + { + [EnumMember(Value = @"slideReel")] + SlideReel = 0, + + [EnumMember(Value = @"autoProjector")] + AutoProjector = 1 + } + + /// + /// The position of this slideshow. + /// public MVector3 position; + + /// + /// The rotation of this slideshow. + /// public MVector3 rotation; + + /// + /// The type of object this is. + /// + [JsonConverter(typeof(StringEnumConverter))] + public SlideShowType type = SlideShowType.SlideReel; + + /// + /// The ship log entries revealed after finishing this slide reel. + /// public string[] reveals; + + /// + /// The list of slides for this object. + /// public SlideInfo[] slides; - public string type = "SlideReel"; } + [JsonObject] public class SlideInfo { + /// + /// The path to the image file for this slide. + /// public string imagePath; // SlideBeatAudioModule + + /// + /// The name of the AudioClip for a one-shot sound when opening the slide. + /// public string beatAudio; + + /// + /// The time delay until the one-shot audio + /// public float beatDelay; // SlideBackdropAudioModule + + /// + /// The name of the AudioClip that will continuously play while watching these slides + /// public string backdropAudio; + + /// + /// The time to fade into the backdrop audio + /// public float backdropFadeTime; + // SlideAmbientLightModule + + /// + /// Ambient light intensity when viewing this slide. + /// public float ambientLightIntensity; + + /// + /// Ambient light range when viewing this slide. + /// public float ambientLightRange; + + /// + /// Ambient light colour when viewing this slide. + /// public MColor ambientLightColor; + + /// + /// Spotlight intensity modifier when viewing this slide. + /// public float spotIntensityMod; + // SlidePlayTimeModule + + /// + /// Play-time duration for auto-projector slides. + /// public float playTimeDuration; + // SlideBlackFrameModule + + /// + /// Before viewing this slide, there will be a black frame for this many seconds. + /// public float blackFrameDuration; + // SlideShipLogEntryModule + + /// + /// Ship log entry revealed when viewing this slide + /// public string reveal; } } diff --git a/NewHorizons/External/Modules/ShipLogModule.cs b/NewHorizons/External/Modules/ShipLogModule.cs index 0e297db4..86e7a9d0 100644 --- a/NewHorizons/External/Modules/ShipLogModule.cs +++ b/NewHorizons/External/Modules/ShipLogModule.cs @@ -1,48 +1,154 @@ using NewHorizons.Utility; +using Newtonsoft.Json; + namespace NewHorizons.External.Modules { + [JsonObject] public class ShipLogModule { + /// + /// The relative path to the xml file to load ship log entries from. + /// public string xmlFile; + + /// + /// A path to the folder where entry sprites are stored. + /// public string spriteFolder; + + /// + /// A list of fact IDs to reveal when the game starts. + /// public string[] initialReveal; + + /// + /// Describe what this planet looks and like in map mode + /// public MapModeInfo mapMode = new MapModeInfo(); + + /// + /// List colors of curiosity entries + /// public CuriosityColorInfo[] curiosities; + + /// + /// Manually layout entries in detective mode + /// public EntryPositionInfo[] entryPositions; + [JsonObject] public class MapModeInfo { + /// + /// The path to the sprite to show when the planet is revealed in map mode. + /// public string revealedSprite; + + /// + /// The path to the sprite to show when the planet is unexplored in map mode. + /// public string outlineSprite; + + /// + /// Scale to apply to the planet in map mode. + /// public float scale = 1f; + + /// + /// Hide the planet completely if unexplored instead of showing an outline. + /// public bool invisibleWhenHidden; - public float offset = 0f; + + /// + /// Extra distance to apply to this object in map mode. + /// + public float offset; + + /// + /// Manually place this planet at the specified position. + /// public MVector2 manualPosition; + + /// + /// Specify where this planet is in terms of navigation. + /// public MVector2 manualNavigationPosition; - public bool remove = false; + + /// + /// Completely remove this planet (and it's children) from map mode. + /// + public bool remove; + + /// + /// Place non-selectable objects in map mode (like sand funnels). + /// public ShipLogDetailInfo[] details; } + [JsonObject] public class ShipLogDetailInfo { + /// + /// The sprite to show when the parent AstroBody is revealed. + /// public string revealedSprite; + + /// + /// The sprite to show when the parent AstroBody is rumored/unexplored. + /// public string outlineSprite; - public float rotation = 0f; + + /// + /// The angle in degrees to rotate the detail. + /// + public float rotation; + + /// + /// Whether to completely hide this detail when the parent AstroBody is unexplored. + /// public bool invisibleWhenHidden; + + /// + /// The position (relative to the parent) to place the detail. + /// public MVector2 position; + + /// + /// The amount to scale the x and y-axis of the detail by. + /// public MVector2 scale; } + [JsonObject] public class CuriosityColorInfo { + /// + /// The ID of the curiosity to apply the color to. + /// public string id; + + /// + /// The color to apply to entries with this curiosity. + /// public MColor color; + + /// + /// The color to apply to highlighted entries with this curiosity. + /// public MColor highlightColor; } + [JsonObject] public class EntryPositionInfo { + /// + /// The name of the entry to apply the position to. + /// public string id; + + /// + /// Position of the entry + /// public MVector2 position; } } diff --git a/NewHorizons/External/Modules/SignalModule.cs b/NewHorizons/External/Modules/SignalModule.cs index 87490fae..35cede00 100644 --- a/NewHorizons/External/Modules/SignalModule.cs +++ b/NewHorizons/External/Modules/SignalModule.cs @@ -1,23 +1,73 @@ using NewHorizons.Utility; +using Newtonsoft.Json; + namespace NewHorizons.External.Modules { + [JsonObject] public class SignalModule { + /// + /// List of signals to add (Why did xen do it like this) + /// public SignalInfo[] Signals; + [JsonObject] public class SignalInfo { + /// + /// Position of the signal's source + /// public MVector3 Position; + + /// + /// The frequency ID of the signal. The built-in game values are `Default`, `Traveler`, `Quantum`, `EscapePod`, `Statue`, `WarpCore`, `HideAndSeek`, and `Radio`. You can also put a custom value. + /// public string Frequency; + + /// + /// The unique ID of the signal. + /// public string Name; - public string AudioClip = null; - public string AudioFilePath = null; + + /// + /// Name of an existing AudioClip in the game that will player over the signal. + /// + public string AudioClip; + + /// + /// Relative filepath to the .wav file to use as the audio. Mutually exclusive with audioClip. + /// + public string AudioFilePath; + + /// + /// A ship log fact to reveal when the signal is identified. + /// public string Reveals = ""; + + /// + /// Radius of the sphere giving off the signal. + /// public float SourceRadius = 1f; - public float DetectionRadius = 0f; + + /// + /// How close the player must get to the signal to detect it. This is when you get the "Unknown Signal Detected" notification. + /// + public float DetectionRadius; + + /// + /// How close the player must get to the signal to identify it. This is when you learn its name. + /// public float IdentificationRadius = 10f; + + /// + /// `false` if the player can hear the signal without equipping the signal-scope. + /// public bool OnlyAudibleToScope = true; - public bool InsideCloak = false; + + /// + /// Only set to `true` if you are putting this signal inside a cloaking field. + /// + public bool InsideCloak; } } } diff --git a/NewHorizons/External/Modules/SpawnModule.cs b/NewHorizons/External/Modules/SpawnModule.cs index 6f17885c..1161582a 100644 --- a/NewHorizons/External/Modules/SpawnModule.cs +++ b/NewHorizons/External/Modules/SpawnModule.cs @@ -1,12 +1,34 @@ using NewHorizons.Utility; +using Newtonsoft.Json; + namespace NewHorizons.External.Modules { + [JsonObject] public class SpawnModule { - public MVector3 PlayerSpawnPoint { get; set; } - public MVector3 PlayerSpawnRotation { get; set; } - public MVector3 ShipSpawnPoint { get; set; } - public MVector3 ShipSpawnRotation { get; set; } - public bool StartWithSuit { get; set; } + /// + /// If you want the player to spawn on the new body, set a value for this. Press `P` in game with Debug mode on to have the game log the position you're looking at to find a good value for this. + /// + public MVector3 PlayerSpawnPoint; + + /// + /// Euler angles by which the player will be oriented. + /// + public MVector3 PlayerSpawnRotation; + + /// + /// Required for the system to be accessible by warp drive. + /// + public MVector3 ShipSpawnPoint; + + /// + /// Euler angles by which the ship will be oriented. + /// + public MVector3 ShipSpawnRotation; + + /// + /// If you spawn on a planet with no oxygen, you probably want to set this to true ;;) + /// + public bool StartWithSuit; } } diff --git a/NewHorizons/External/Modules/VariableSize/FunnelModule.cs b/NewHorizons/External/Modules/VariableSize/FunnelModule.cs index 057b85a5..7d268d07 100644 --- a/NewHorizons/External/Modules/VariableSize/FunnelModule.cs +++ b/NewHorizons/External/Modules/VariableSize/FunnelModule.cs @@ -1,10 +1,43 @@ -using NewHorizons.Utility; +using System.Runtime.Serialization; +using NewHorizons.Utility; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + namespace NewHorizons.External.Modules.VariableSize { + public enum FunnelType + { + [EnumMember(Value = @"Sand")] + Sand = 0, + + [EnumMember(Value = @"Water")] + Water = 1, + + [EnumMember(Value = @"Lava")] + Lava = 2, + + [EnumMember(Value = @"Star")] + Star = 3 + } + + [JsonObject] public class FunnelModule : VariableSizeModule { - public string Target { get; set; } - public string Type { get; set; } = "Sand"; - public MColor Tint { get; set; } + + /// + /// The planet the funnel will flow to + /// + public string Target; + + /// + /// Type of fluid the funnel transfers + /// + [JsonConverter(typeof(StringEnumConverter))] + public FunnelType Type = FunnelType.Sand; + + /// + /// Tint of the funnel + /// + public MColor Tint; } } diff --git a/NewHorizons/External/Modules/VariableSize/LavaModule.cs b/NewHorizons/External/Modules/VariableSize/LavaModule.cs index 558336e8..2ddfda62 100644 --- a/NewHorizons/External/Modules/VariableSize/LavaModule.cs +++ b/NewHorizons/External/Modules/VariableSize/LavaModule.cs @@ -1,9 +1,19 @@ using NewHorizons.Utility; +using Newtonsoft.Json; + namespace NewHorizons.External.Modules.VariableSize { + [JsonObject] public class LavaModule : VariableSizeModule { - public float Size { get; set; } - public MColor Tint { get; set; } + /// + /// Size of the lava sphere + /// + public float Size; + + /// + /// Tint of the lava + /// + public MColor Tint; } } diff --git a/NewHorizons/External/Modules/VariableSize/RingModule.cs b/NewHorizons/External/Modules/VariableSize/RingModule.cs index 7cb32e48..88ffdb4e 100644 --- a/NewHorizons/External/Modules/VariableSize/RingModule.cs +++ b/NewHorizons/External/Modules/VariableSize/RingModule.cs @@ -1,14 +1,48 @@ -namespace NewHorizons.External.Modules.VariableSize +using Newtonsoft.Json; + +namespace NewHorizons.External.Modules.VariableSize { + [JsonObject] public class RingModule : VariableSizeModule { - public float InnerRadius { get; set; } - public float OuterRadius { get; set; } - public float Inclination { get; set; } - public float LongitudeOfAscendingNode { get; set; } - public string Texture { get; set; } - public bool Unlit { get; set; } = false; - public float RotationSpeed { get; set; } = 0f; - public string FluidType { get; set; } + /// + /// Inner radius of the disk + /// + public float InnerRadius; + + /// + /// Outer radius of the disk + /// + public float OuterRadius; + + /// + /// Angle between the rings and the equatorial plane of the planet. + /// + public float Inclination; + + /// + /// Angle defining the point where the rings rise up from the planet's equatorial plane if inclination is nonzero. + /// + public float LongitudeOfAscendingNode; + + /// + /// Relative filepath to the texture used for the rings. + /// + public string Texture; + + /// + /// Should this ring be unlit? + /// + public bool Unlit; + + /// + /// Allows the rings to rotate. + /// + public float RotationSpeed; + + /// + /// Fluid type for sounds/effects when colliding with this ring. + /// + public CloudFluidType? FluidType = CloudFluidType.None; } } diff --git a/NewHorizons/External/Modules/VariableSize/SandModule.cs b/NewHorizons/External/Modules/VariableSize/SandModule.cs index ee056aa5..b53937fa 100644 --- a/NewHorizons/External/Modules/VariableSize/SandModule.cs +++ b/NewHorizons/External/Modules/VariableSize/SandModule.cs @@ -3,7 +3,14 @@ namespace NewHorizons.External.Modules.VariableSize { public class SandModule : VariableSizeModule { + /// + /// Size of the sand + /// public float Size { get; set; } + + /// + /// Tint of the sand + /// public MColor Tint { get; set; } } } diff --git a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs index 4f4b0804..d6d9f9c3 100644 --- a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs +++ b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs @@ -1,13 +1,51 @@ -using NewHorizons.Utility; +using System.Runtime.Serialization; +using NewHorizons.Utility; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + namespace NewHorizons.External.Modules.VariableSize { + [JsonObject] public class SingularityModule : VariableSizeModule { + public enum SingularityType + { + [EnumMember(Value = @"BlackHole")] + BlackHole = 0, + + [EnumMember(Value = @"WhiteHole")] + WhiteHole = 1 + } + + /// + /// Radius of the singularity. Note that this isn't the same as the event horizon, but includes the entire volume that has warped effects in it. + /// public float Size; + + /// + /// The name of the white hole or black hole that is paired to this one. If you don't set a value, entering will kill the player + /// public string PairedSingularity; + + /// + /// If you want a black hole to load a new star system scene, put its name here. + /// public string TargetStarSystem; - public string Type; //BlackHole or WhiteHole + + /// + /// Type of singularity (white hole or black hole) + /// + [JsonConverter(typeof(StringEnumConverter))] + public SingularityType Type; + + /// + /// Position of the singularity + /// public MVector3 Position; + + /// + /// Only for White Holes. Should this white hole repel the player from it. + /// public bool MakeZeroGVolume = true; } } diff --git a/NewHorizons/External/Modules/VariableSize/StarModule.cs b/NewHorizons/External/Modules/VariableSize/StarModule.cs index f75b6374..62452bc9 100644 --- a/NewHorizons/External/Modules/VariableSize/StarModule.cs +++ b/NewHorizons/External/Modules/VariableSize/StarModule.cs @@ -1,16 +1,49 @@ using NewHorizons.Utility; +using Newtonsoft.Json; namespace NewHorizons.External.Modules.VariableSize { + [JsonObject] public class StarModule : VariableSizeModule { - public float Size { get; set; } = 2000f; - public MColor Tint { get; set; } - public MColor EndTint { get; set; } - public MColor SupernovaTint { get; set; } - public MColor LightTint { get; set; } - public float SolarLuminosity { get; set; } = 1f; - public bool HasAtmosphere { get; set; } = true; - public bool GoSupernova { get; set; } = true; + /// + /// Radius of the star. + /// + public float Size = 2000f; + + /// + /// Colour of the star. + /// + public MColor Tint; + + /// + /// Colour of the star at the end of its life. + /// + public MColor EndTint; + + /// + /// The tint of the supernova this star creates when it dies. + /// + public MColor SupernovaTint; + + /// + /// Colour of the light given off. + /// + public MColor LightTint; + + /// + /// Relative strength of the light compared to the sun. + /// + public float SolarLuminosity = 1f; + + /// + /// The default sun has its own atmosphere that is different from regular planets. If you want that, set this to `true`. + /// + public bool HasAtmosphere = true; + + /// + /// Should this star explode after 22 minutes? + /// + public bool GoSupernova = true; } } diff --git a/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs b/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs index 99054649..57f1f16e 100644 --- a/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs +++ b/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs @@ -1,8 +1,13 @@ -using UnityEngine; +using Newtonsoft.Json; +using UnityEngine; namespace NewHorizons.External.Modules.VariableSize { + [JsonObject] public class VariableSizeModule { + /// + /// Scale this module over time + /// public TimeValuePair[] Curve { get; set; } public class TimeValuePair diff --git a/NewHorizons/External/Modules/VariableSize/WaterModule.cs b/NewHorizons/External/Modules/VariableSize/WaterModule.cs index 28221d6c..721b1ef8 100644 --- a/NewHorizons/External/Modules/VariableSize/WaterModule.cs +++ b/NewHorizons/External/Modules/VariableSize/WaterModule.cs @@ -1,9 +1,19 @@ using NewHorizons.Utility; +using Newtonsoft.Json; + namespace NewHorizons.External.Modules.VariableSize { + [JsonObject] public class WaterModule : VariableSizeModule { - public float Size { get; set; } - public MColor Tint { get; set; } + /// + /// Size of the water sphere + /// + public float Size; + + /// + /// Tint of the water + /// + public MColor Tint; } }