diff --git a/NJsonSchema/NJsonSchema.dll b/NJsonSchema/NJsonSchema.dll deleted file mode 100644 index 4da32964..00000000 Binary files a/NJsonSchema/NJsonSchema.dll and /dev/null differ diff --git a/NJsonSchema/Namotion.Reflection.dll b/NJsonSchema/Namotion.Reflection.dll deleted file mode 100644 index daa85b06..00000000 Binary files a/NJsonSchema/Namotion.Reflection.dll and /dev/null differ diff --git a/NewHorizons.sln b/NewHorizons.sln index d8ea38c5..7a24fbab 100644 --- a/NewHorizons.sln +++ b/NewHorizons.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.30204.135 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewHorizons", "NewHorizons\NewHorizons.csproj", "{8A39F9E7-1A89-430C-9C3E-BDFB3B7E17DF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchemaExporter", "SchemaExporter\SchemaExporter.csproj", "{28E23A7D-997B-4559-BBFA-788F45125F1B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {8A39F9E7-1A89-430C-9C3E-BDFB3B7E17DF}.Debug|Any CPU.Build.0 = Debug|Any CPU {8A39F9E7-1A89-430C-9C3E-BDFB3B7E17DF}.Release|Any CPU.ActiveCfg = Release|Any CPU {8A39F9E7-1A89-430C-9C3E-BDFB3B7E17DF}.Release|Any CPU.Build.0 = Release|Any CPU + {28E23A7D-997B-4559-BBFA-788F45125F1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28E23A7D-997B-4559-BBFA-788F45125F1B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28E23A7D-997B-4559-BBFA-788F45125F1B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28E23A7D-997B-4559-BBFA-788F45125F1B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/NewHorizons/Builder/Atmosphere/AirBuilder.cs b/NewHorizons/Builder/Atmosphere/AirBuilder.cs index e39d216c..aee26625 100644 --- a/NewHorizons/Builder/Atmosphere/AirBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/AirBuilder.cs @@ -13,7 +13,7 @@ namespace NewHorizons.Builder.Atmosphere SphereCollider sc = airGO.AddComponent(); sc.isTrigger = true; - sc.radius = info.Scale; + sc.radius = info.scale; SimpleFluidVolume sfv = airGO.AddComponent(); sfv._layer = 5; @@ -23,12 +23,12 @@ namespace NewHorizons.Builder.Atmosphere sfv._allowShipAutoroll = true; sfv._disableOnStart = false; - if (info.HasOxygen) + if (info.hasOxygen) { airGO.AddComponent(); } - if (info.IsRaining) + if (info.isRaining) { var vref = airGO.AddComponent(); vref._rainDirection = VisorRainEffectVolume.RainDirection.Radial; diff --git a/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs b/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs index 61da791c..c60ae6a3 100644 --- a/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs @@ -14,17 +14,17 @@ namespace NewHorizons.Builder.Atmosphere atmoGO.SetActive(false); atmoGO.transform.parent = sector?.transform ?? planetGO.transform; - if (atmosphereModule.UseAtmosphereShader) + if (atmosphereModule.useAtmosphereShader) { GameObject atmo = GameObject.Instantiate(GameObject.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere"), atmoGO.transform, true); atmo.transform.position = planetGO.transform.TransformPoint(Vector3.zero); - atmo.transform.localScale = Vector3.one * atmosphereModule.Size * 1.2f; + atmo.transform.localScale = Vector3.one * atmosphereModule.size * 1.2f; foreach (var meshRenderer in atmo.GetComponentsInChildren()) { - meshRenderer.material.SetFloat(InnerRadius, atmosphereModule.Clouds != null ? atmosphereModule.Size : surfaceSize); - meshRenderer.material.SetFloat(OuterRadius, atmosphereModule.Size * 1.2f); - if (atmosphereModule.AtmosphereTint != null) - meshRenderer.material.SetColor(SkyColor, atmosphereModule.AtmosphereTint.ToColor()); + meshRenderer.material.SetFloat(InnerRadius, atmosphereModule.clouds != null ? atmosphereModule.size : surfaceSize); + meshRenderer.material.SetFloat(OuterRadius, atmosphereModule.size * 1.2f); + if (atmosphereModule.atmosphereTint != null) + meshRenderer.material.SetColor(SkyColor, atmosphereModule.atmosphereTint.ToColor()); } atmo.SetActive(true); diff --git a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs index a50a0059..ea20d434 100644 --- a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs @@ -30,16 +30,16 @@ namespace NewHorizons.Builder.Atmosphere GameObject cloudsBottomGO = new GameObject("BottomClouds"); cloudsBottomGO.SetActive(false); cloudsBottomGO.transform.parent = cloudsMainGO.transform; - cloudsBottomGO.transform.localScale = Vector3.one * atmo.Clouds.InnerCloudRadius; + cloudsBottomGO.transform.localScale = Vector3.one * atmo.clouds.innerCloudRadius; TessellatedSphereRenderer bottomTSR = cloudsBottomGO.AddComponent(); bottomTSR.tessellationMeshGroup = GameObject.Find("CloudsBottomLayer_QM").GetComponent().tessellationMeshGroup; var bottomTSRMaterials = GameObject.Find("CloudsBottomLayer_QM").GetComponent().sharedMaterials; // If they set a colour apply it to all the materials else keep the default QM one - if (atmo.Clouds.Tint != null) + if (atmo.clouds.tint != null) { - var bottomColor = atmo.Clouds.Tint.ToColor(); + var bottomColor = atmo.clouds.tint.ToColor(); var bottomTSRTempArray = new Material[2]; @@ -70,10 +70,10 @@ namespace NewHorizons.Builder.Atmosphere SphereCollider fluidSC = cloudsFluidGO.AddComponent(); fluidSC.isTrigger = true; - fluidSC.radius = atmo.Size; + fluidSC.radius = atmo.size; OWShellCollider fluidOWSC = cloudsFluidGO.AddComponent(); - fluidOWSC._innerRadius = atmo.Size * 0.9f; + fluidOWSC._innerRadius = atmo.size * 0.9f; CloudLayerFluidVolume fluidCLFV = cloudsFluidGO.AddComponent(); fluidCLFV._layer = 5; @@ -81,15 +81,15 @@ namespace NewHorizons.Builder.Atmosphere fluidCLFV._density = 1.2f; var fluidType = FluidVolume.Type.CLOUD; - if (atmo.Clouds.FluidType != null) + if (atmo.clouds.fluidType != null) { try { - fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(CloudFluidType), atmo.Clouds.FluidType).ToUpper()); + fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(CloudFluidType), atmo.clouds.fluidType).ToUpper()); } catch (Exception ex) { - Logger.LogError($"Couldn't parse fluid volume type [{atmo.Clouds.FluidType}]: {ex.Message}, {ex.StackTrace}"); + Logger.LogError($"Couldn't parse fluid volume type [{atmo.clouds.fluidType}]: {ex.Message}, {ex.StackTrace}"); } } @@ -100,25 +100,25 @@ namespace NewHorizons.Builder.Atmosphere // Fix the rotations once the rest is done cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(0, 0, 0)); // For the base shader it has to be rotated idk - if (atmo.Clouds.UseBasicCloudShader) cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0)); + if (atmo.clouds.useBasicCloudShader) cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0)); // Lightning - if (atmo.Clouds.HasLightning) + if (atmo.clouds.hasLightning) { var lightning = _lightningPrefab.InstantiateInactive(); lightning.transform.parent = cloudsMainGO.transform; lightning.transform.localPosition = Vector3.zero; var lightningGenerator = lightning.GetComponent(); - lightningGenerator._altitude = (atmo.Clouds.OuterCloudRadius + atmo.Clouds.InnerCloudRadius) / 2f; + lightningGenerator._altitude = (atmo.clouds.outerCloudRadius + atmo.clouds.innerCloudRadius) / 2f; lightningGenerator._audioSector = sector; - if (atmo.Clouds.LightningGradient != null) + if (atmo.clouds.lightningGradient != null) { - var gradient = new GradientColorKey[atmo.Clouds.LightningGradient.Length]; + var gradient = new GradientColorKey[atmo.clouds.lightningGradient.Length]; - for(int i = 0; i < atmo.Clouds.LightningGradient.Length; i++) + for(int i = 0; i < atmo.clouds.lightningGradient.Length; i++) { - var pair = atmo.Clouds.LightningGradient[i]; + var pair = atmo.clouds.lightningGradient[i]; gradient[i] = new GradientColorKey(pair.Tint.ToColor(), pair.Time); } @@ -138,18 +138,18 @@ namespace NewHorizons.Builder.Atmosphere public static GameObject MakeTopClouds(GameObject rootObject, AtmosphereModule atmo, IModBehaviour mod) { - Color cloudTint = atmo.Clouds.Tint?.ToColor() ?? Color.white; + Color cloudTint = atmo.clouds.tint?.ToColor() ?? Color.white; Texture2D image, cap, ramp; try { - image = ImageUtilities.GetTexture(mod, atmo.Clouds.TexturePath); + image = ImageUtilities.GetTexture(mod, atmo.clouds.texturePath); - if (atmo.Clouds.CapPath == null) cap = ImageUtilities.ClearTexture(128, 128); - else cap = ImageUtilities.GetTexture(mod, atmo.Clouds.CapPath); - if (atmo.Clouds.RampPath == null) ramp = ImageUtilities.CanvasScaled(image, 1, image.height); - else ramp = ImageUtilities.GetTexture(mod, atmo.Clouds.RampPath); + if (atmo.clouds.capPath == null) cap = ImageUtilities.ClearTexture(128, 128); + else cap = ImageUtilities.GetTexture(mod, atmo.clouds.capPath); + if (atmo.clouds.rampPath == null) ramp = ImageUtilities.CanvasScaled(image, 1, image.height); + else ramp = ImageUtilities.GetTexture(mod, atmo.clouds.rampPath); } catch (Exception e) { @@ -160,7 +160,7 @@ namespace NewHorizons.Builder.Atmosphere GameObject cloudsTopGO = new GameObject("TopClouds"); cloudsTopGO.SetActive(false); cloudsTopGO.transform.parent = rootObject.transform; - cloudsTopGO.transform.localScale = Vector3.one * atmo.Clouds.OuterCloudRadius; + cloudsTopGO.transform.localScale = Vector3.one * atmo.clouds.outerCloudRadius; MeshFilter topMF = cloudsTopGO.AddComponent(); topMF.mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent().mesh; @@ -171,19 +171,19 @@ namespace NewHorizons.Builder.Atmosphere if (_gdCloudMaterials == null) _gdCloudMaterials = GameObject.Find("CloudsTopLayer_GD").GetComponent().sharedMaterials; var tempArray = new Material[2]; - if (atmo.Clouds.UseBasicCloudShader) + if (atmo.clouds.useBasicCloudShader) { var material = new Material(_sphereShader); - if (atmo.Clouds.Unlit) material.renderQueue = 2550; - material.name = atmo.Clouds.Unlit ? "BasicCloud" : "BasicShadowCloud"; + if (atmo.clouds.unlit) material.renderQueue = 2550; + material.name = atmo.clouds.unlit ? "BasicCloud" : "BasicShadowCloud"; tempArray[0] = material; } else { var material = new Material(_gdCloudMaterials[0]); - if (atmo.Clouds.Unlit) material.renderQueue = 2550; - material.name = atmo.Clouds.Unlit ? "AdvancedCloud" : "AdvancedShadowCloud"; + if (atmo.clouds.unlit) material.renderQueue = 2550; + material.name = atmo.clouds.unlit ? "AdvancedCloud" : "AdvancedShadowCloud"; tempArray[0] = material; } @@ -201,14 +201,14 @@ namespace NewHorizons.Builder.Atmosphere material.SetTexture(CapTex, cap); } - if (atmo.Clouds.Unlit) + if (atmo.clouds.unlit) { cloudsTopGO.layer = LayerMask.NameToLayer("IgnoreSun"); } RotateTransform topRT = cloudsTopGO.AddComponent(); // Idk why but the axis is weird - topRT._localAxis = atmo.Clouds.UseBasicCloudShader ? Vector3.forward : Vector3.up; + topRT._localAxis = atmo.clouds.useBasicCloudShader ? Vector3.forward : Vector3.up; topRT._degreesPerSecond = 10; topRT._randomizeRotationRate = false; diff --git a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs index f3254ba2..6094f256 100644 --- a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs @@ -19,7 +19,7 @@ namespace NewHorizons.Builder.Atmosphere SCG._dynamicCullingBounds = false; SCG._waitForStreaming = false; - if (info.IsRaining) + if (info.isRaining) { var rainGO = GameObject.Instantiate(SearchUtilities.CachedFind("/GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain"), effectsGO.transform); rainGO.transform.position = planetGO.transform.position; @@ -29,7 +29,7 @@ namespace NewHorizons.Builder.Atmosphere { new Keyframe(surfaceSize - 0.5f, 0), new Keyframe(surfaceSize, 10f), - new Keyframe(info.Scale, 0f) + new Keyframe(info.scale, 0f) }); rainGO.GetComponent()._activeInSector = sector; @@ -37,7 +37,7 @@ namespace NewHorizons.Builder.Atmosphere rainGO.SetActive(true); } - if (info.IsSnowing) + if (info.isSnowing) { var snowGO = new GameObject("SnowEffects"); snowGO.transform.parent = effectsGO.transform; @@ -53,7 +53,7 @@ namespace NewHorizons.Builder.Atmosphere { new Keyframe(surfaceSize - 0.5f, 0), new Keyframe(surfaceSize, 10f), - new Keyframe(info.Scale, 0f) + new Keyframe(info.scale, 0f) }); snowEmitter.GetComponent()._activeInSector = sector; diff --git a/NewHorizons/Builder/Atmosphere/FogBuilder.cs b/NewHorizons/Builder/Atmosphere/FogBuilder.cs index b7d3ef0f..2ee92b02 100644 --- a/NewHorizons/Builder/Atmosphere/FogBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/FogBuilder.cs @@ -25,24 +25,24 @@ namespace NewHorizons.Builder.Atmosphere PlanetaryFogController PFC = fogGO.AddComponent(); PFC.fogLookupTexture = dbPlanetaryFogController.fogLookupTexture; - PFC.fogRadius = atmo.FogSize; - PFC.fogDensity = atmo.FogDensity; + PFC.fogRadius = atmo.fogSize; + PFC.fogDensity = atmo.fogDensity; PFC.fogExponent = 1f; PFC.fogColorRampTexture = dbPlanetaryFogController.fogColorRampTexture; PFC.fogColorRampIntensity = 1f; - PFC.fogTint = atmo.FogTint.ToColor(); + PFC.fogTint = atmo.fogTint.ToColor(); GameObject lodFogGO = new GameObject("LODFogSphere"); lodFogGO.SetActive(false); lodFogGO.transform.parent = fogGO.transform; - lodFogGO.transform.localScale = Vector3.one * atmo.Size / 320f; + lodFogGO.transform.localScale = Vector3.one * atmo.size / 320f; MeshFilter lodMF = lodFogGO.AddComponent(); lodMF.mesh = brambleLODFog.GetComponent().mesh; MeshRenderer lodMR = lodFogGO.AddComponent(); lodMR.material = new Material(brambleLODFog.GetComponent().material); - lodMR.material.color = atmo.FogTint.ToColor(); + lodMR.material.color = atmo.fogTint.ToColor(); lodMR.material.renderQueue = 1000; /* diff --git a/NewHorizons/Builder/Atmosphere/SunOverrideBuilder.cs b/NewHorizons/Builder/Atmosphere/SunOverrideBuilder.cs index e1d07a84..33ebcca3 100644 --- a/NewHorizons/Builder/Atmosphere/SunOverrideBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/SunOverrideBuilder.cs @@ -12,8 +12,8 @@ namespace NewHorizons.Builder.Atmosphere GiantsDeepSunOverrideVolume GDSOV = overrideGO.AddComponent(); GDSOV._sector = sector; - GDSOV._cloudsOuterRadius = atmo.Size; - GDSOV._cloudsInnerRadius = atmo.Size * 0.9f; + GDSOV._cloudsOuterRadius = atmo.size; + GDSOV._cloudsInnerRadius = atmo.size * 0.9f; GDSOV._waterOuterRadius = surfaceSize; GDSOV._waterInnerRadius = 0f; diff --git a/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs b/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs index f39da7c9..6a960870 100644 --- a/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs @@ -8,7 +8,7 @@ namespace NewHorizons.Builder.Atmosphere public static void Make(GameObject planetGO, PlanetConfig config, float sphereOfInfluence) { - var innerRadius = config.Base.SurfaceSize; + var innerRadius = config.Base.surfaceSize; GameObject volumesGO = new GameObject("Volumes"); volumesGO.SetActive(false); @@ -30,8 +30,8 @@ namespace NewHorizons.Builder.Atmosphere PlanetoidRuleset PR = rulesetGO.AddComponent(); PR._altitudeFloor = innerRadius; PR._altitudeCeiling = sphereOfInfluence; - PR._useMinimap = config.Base.ShowMinimap; - PR._useAltimeter = config.Base.ShowMinimap; + PR._useMinimap = config.Base.showMinimap; + PR._useAltimeter = config.Base.showMinimap; rulesetGO.AddComponent(); @@ -42,9 +42,9 @@ namespace NewHorizons.Builder.Atmosphere ER._material = gdRuleset._material; var cloudMaterial = new Material(gdRuleset._cloudMaterial); - if (config.Atmosphere?.Clouds?.Tint != null) + if (config.Atmosphere?.clouds?.tint != null) { - cloudMaterial.SetColor(FogColor, config.Atmosphere.Clouds.Tint.ToColor32()); + cloudMaterial.SetColor(FogColor, config.Atmosphere.clouds.tint.ToColor32()); } ER._cloudMaterial = cloudMaterial; diff --git a/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs b/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs index 965d3628..41f0b47f 100644 --- a/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs +++ b/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs @@ -13,55 +13,55 @@ namespace NewHorizons.Builder.Body { var belt = parentConfig.AsteroidBelt; - float minSize = belt.MinSize; - float maxSize = belt.MaxSize; - int count = (int)(2f * Mathf.PI * belt.InnerRadius / (10f * maxSize)); - if (belt.Amount >= 0) count = belt.Amount; + float minSize = belt.minSize; + float maxSize = belt.maxSize; + int count = (int)(2f * Mathf.PI * belt.innerRadius / (10f * maxSize)); + if (belt.amount >= 0) count = belt.amount; if (count > 200) count = 200; - Random.InitState(belt.RandomSeed); + Random.InitState(belt.randomSeed); for (int i = 0; i < count; i++) { var size = Random.Range(minSize, maxSize); var config = new PlanetConfig(); - config.Name = $"{bodyName} Asteroid {i}"; - config.StarSystem = parentConfig.StarSystem; + config.name = $"{bodyName} Asteroid {i}"; + config.starSystem = parentConfig.starSystem; config.Base = new BaseModule() { - HasMapMarker = false, - SurfaceGravity = 1, - SurfaceSize = size, - HasReferenceFrame = false, - GravityFallOff = GravityFallOff.InverseSquared + hasMapMarker = false, + surfaceGravity = 1, + surfaceSize = size, + hasReferenceFrame = false, + gravityFallOff = GravityFallOff.InverseSquared }; config.Orbit = new OrbitModule() { IsMoon = true, - Inclination = belt.Inclination + Random.Range(-2f, 2f), - LongitudeOfAscendingNode = belt.LongitudeOfAscendingNode, + Inclination = belt.inclination + Random.Range(-2f, 2f), + LongitudeOfAscendingNode = belt.longitudeOfAscendingNode, TrueAnomaly = 360f * (i + Random.Range(-0.2f, 0.2f)) / (float)count, PrimaryBody = bodyName, - SemiMajorAxis = Random.Range(belt.InnerRadius, belt.OuterRadius), + SemiMajorAxis = Random.Range(belt.innerRadius, belt.outerRadius), ShowOrbitLine = false }; - config.ProcGen = belt.ProcGen; + config.ProcGen = belt.procGen; if (config.ProcGen == null) { config.ProcGen = new ProcGenModule() { - Scale = size, - Color = new MColor(126, 94, 73, 255) + scale = size, + color = new MColor(126, 94, 73, 255) }; } else { // Still update the size - config.ProcGen.Scale = size; + config.ProcGen.scale = size; } var asteroid = new NewHorizonsBody(config, mod); diff --git a/NewHorizons/Builder/Body/CometTailBuilder.cs b/NewHorizons/Builder/Body/CometTailBuilder.cs index 19e3f762..be13a836 100644 --- a/NewHorizons/Builder/Body/CometTailBuilder.cs +++ b/NewHorizons/Builder/Body/CometTailBuilder.cs @@ -9,10 +9,10 @@ namespace NewHorizons.Builder.Body var cometTail = GameObject.Instantiate(GameObject.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes"), sector?.transform ?? planetGO.transform); cometTail.transform.position = planetGO.transform.position; cometTail.name = "CometTail"; - cometTail.transform.localScale = Vector3.one * config.Base.SurfaceSize / 110; + cometTail.transform.localScale = Vector3.one * config.Base.surfaceSize / 110; Vector3 alignment = new Vector3(0, 270, 90); - if (config.Base.CometTailRotation != null) alignment = config.Base.CometTailRotation; + if (config.Base.cometTailRotation != null) alignment = config.Base.cometTailRotation; cometTail.transform.rotation = Quaternion.Euler(alignment); } diff --git a/NewHorizons/Builder/Body/FunnelBuilder.cs b/NewHorizons/Builder/Body/FunnelBuilder.cs index 5331d4c4..5f9ccd93 100644 --- a/NewHorizons/Builder/Body/FunnelBuilder.cs +++ b/NewHorizons/Builder/Body/FunnelBuilder.cs @@ -15,7 +15,7 @@ namespace NewHorizons.Builder.Body public static void Make(GameObject planetGO, ConstantForceDetector detector, OWRigidbody rigidbody, FunnelModule module) { - var funnelType = module.Type; + var funnelType = module.type; var funnelGO = new GameObject($"{planetGO.name.Replace("_Body", "")}Funnel_Body"); funnelGO.SetActive(false); @@ -68,9 +68,9 @@ namespace NewHorizons.Builder.Body for (int i = 0; i < waterMaterials.Length; i++) { materials[i] = new Material(waterMaterials[i]); - if (module.Tint != null) + if (module.tint != null) { - materials[i].SetColor(FogColor, module.Tint.ToColor()); + materials[i].SetColor(FogColor, module.tint.ToColor()); } } @@ -115,9 +115,9 @@ namespace NewHorizons.Builder.Body lavaMaterial.mainTextureOffset = new Vector2(0.1f, 0.2f); lavaMaterial.mainTextureScale = new Vector2(1f, 3f); - if (module.Tint != null) + if (module.tint != null) { - lavaMaterial.SetColor(EmissionColor, module.Tint.ToColor()); + lavaMaterial.SetColor(EmissionColor, module.tint.ToColor()); } proxyGO.GetComponentInChildren().material = lavaMaterial; @@ -164,12 +164,12 @@ namespace NewHorizons.Builder.Body private static void PostMake(GameObject funnelGO, FunnelController funnelSizeController, FunnelModule module) { - var targetAO = AstroObjectLocator.GetAstroObject(module.Target); + var targetAO = AstroObjectLocator.GetAstroObject(module.target); var target = targetAO?.GetAttachedOWRigidbody(); if (target == null) { if (targetAO != null) Logger.LogError($"Found funnel target ({targetAO.name}) but couldn't find rigidbody for the funnel {funnelGO.name}"); - else Logger.LogError($"Couldn't find the target ({module.Target}) for the funnel {funnelGO.name}"); + else Logger.LogError($"Couldn't find the target ({module.target}) for the funnel {funnelGO.name}"); return; } diff --git a/NewHorizons/Builder/Body/HeightMapBuilder.cs b/NewHorizons/Builder/Body/HeightMapBuilder.cs index dda66b51..2561cde6 100644 --- a/NewHorizons/Builder/Body/HeightMapBuilder.cs +++ b/NewHorizons/Builder/Body/HeightMapBuilder.cs @@ -16,10 +16,10 @@ namespace NewHorizons.Builder.Body Texture2D heightMap, textureMap; try { - if (module.HeightMap == null) heightMap = Texture2D.whiteTexture; - else heightMap = ImageUtilities.GetTexture(mod, module.HeightMap); - if (module.TextureMap == null) textureMap = Texture2D.whiteTexture; - else textureMap = ImageUtilities.GetTexture(mod, module.TextureMap); + if (module.heightMap == null) heightMap = Texture2D.whiteTexture; + else heightMap = ImageUtilities.GetTexture(mod, module.heightMap); + if (module.textureMap == null) textureMap = Texture2D.whiteTexture; + else textureMap = ImageUtilities.GetTexture(mod, module.textureMap); } catch (Exception e) { @@ -32,8 +32,8 @@ namespace NewHorizons.Builder.Body cubeSphere.transform.parent = sector?.transform ?? planetGO.transform; cubeSphere.transform.rotation = Quaternion.Euler(90, 0, 0); - Vector3 stretch = module.Stretch != null ? (Vector3)module.Stretch : Vector3.one; - Mesh mesh = CubeSphere.Build(resolution, heightMap, module.MinHeight, module.MaxHeight, stretch); + Vector3 stretch = module.stretch != null ? (Vector3)module.stretch : Vector3.one; + Mesh mesh = CubeSphere.Build(resolution, heightMap, module.minHeight, module.maxHeight, stretch); cubeSphere.AddComponent(); cubeSphere.GetComponent().mesh = mesh; diff --git a/NewHorizons/Builder/Body/LavaBuilder.cs b/NewHorizons/Builder/Body/LavaBuilder.cs index b164c036..9d2f40df 100644 --- a/NewHorizons/Builder/Body/LavaBuilder.cs +++ b/NewHorizons/Builder/Body/LavaBuilder.cs @@ -11,7 +11,7 @@ namespace NewHorizons.Builder.Body public static void Make(GameObject planetGO, Sector sector, OWRigidbody rb, LavaModule module) { - var heightScale = module.Size; + var heightScale = module.size; if (module.Curve != null) { var modifier = 1f; @@ -26,13 +26,13 @@ namespace NewHorizons.Builder.Body moltenCore.SetActive(false); moltenCore.transform.parent = sector?.transform ?? planetGO.transform; moltenCore.transform.position = planetGO.transform.position; - moltenCore.transform.localScale = Vector3.one * module.Size; + moltenCore.transform.localScale = Vector3.one * module.size; var lavaSphere = GameObject.Instantiate(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere"), moltenCore.transform); lavaSphere.transform.localScale = Vector3.one; lavaSphere.transform.name = "LavaSphere"; lavaSphere.GetComponent().material.SetFloat(HeightScale, heightScale); - if (module.Tint != null) lavaSphere.GetComponent().material.SetColor(EmissionColor, module.Tint.ToColor()); + if (module.tint != null) lavaSphere.GetComponent().material.SetColor(EmissionColor, module.tint.ToColor()); var sectorCullGroup = lavaSphere.GetComponent(); sectorCullGroup.SetSector(sector); @@ -44,7 +44,7 @@ namespace NewHorizons.Builder.Body proxyLavaSphere.transform.localScale = Vector3.one; proxyLavaSphere.name = "LavaSphere_Proxy"; proxyLavaSphere.GetComponent().material.SetFloat(HeightScale, heightScale); - if (module.Tint != null) proxyLavaSphere.GetComponent().material.SetColor(EmissionColor, module.Tint.ToColor()); + if (module.tint != null) proxyLavaSphere.GetComponent().material.SetColor(EmissionColor, module.tint.ToColor()); var sectorProxy = moltenCoreProxy.GetComponent(); sectorProxy._renderers = new List { proxyLavaSphere.GetComponent() }; @@ -60,7 +60,7 @@ namespace NewHorizons.Builder.Body var curve = new AnimationCurve(); foreach (var pair in module.Curve) { - curve.AddKey(new Keyframe(pair.Time, module.Size * pair.Value)); + curve.AddKey(new Keyframe(pair.Time, module.size * pair.Value)); } levelController._scaleCurve = curve; } diff --git a/NewHorizons/Builder/Body/ProcGenBuilder.cs b/NewHorizons/Builder/Body/ProcGenBuilder.cs index 98e826c5..af13da22 100644 --- a/NewHorizons/Builder/Body/ProcGenBuilder.cs +++ b/NewHorizons/Builder/Body/ProcGenBuilder.cs @@ -20,14 +20,14 @@ namespace NewHorizons.Builder.Body icosphere.transform.rotation = Quaternion.Euler(90, 0, 0); icosphere.transform.position = planetGO.transform.position; - Mesh mesh = Icosphere.Build(4, module.Scale, module.Scale * 1.2f); + Mesh mesh = Icosphere.Build(4, module.scale, module.scale * 1.2f); icosphere.AddComponent(); icosphere.GetComponent().mesh = mesh; var cubeSphereMR = icosphere.AddComponent(); cubeSphereMR.material = new Material(Shader.Find("Standard")); - cubeSphereMR.material.color = module.Color != null ? module.Color.ToColor() : Color.white; + cubeSphereMR.material.color = module.color != null ? module.color.ToColor() : Color.white; var cubeSphereMC = icosphere.AddComponent(); cubeSphereMC.sharedMesh = mesh; diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 32b37be0..33510c62 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -31,60 +31,60 @@ namespace NewHorizons.Builder.Body { if (lavaMaterial == null) lavaMaterial = SearchUtilities.FindObjectOfTypeAndName("VolcanicMoon_Body").transform.Find("LavaSphere").GetComponent().material; - var proxyName = $"{body.Config.Name}_Proxy"; + var proxyName = $"{body.Config.name}_Proxy"; var newProxy = new GameObject(proxyName); try { // We want to take the largest size I think - var realSize = body.Config.Base.SurfaceSize; + var realSize = body.Config.Base.surfaceSize; if (body.Config.HeightMap != null) { HeightMapBuilder.Make(newProxy, null, body.Config.HeightMap, body.Mod, 20); - if (realSize < body.Config.HeightMap.MaxHeight) realSize = body.Config.HeightMap.MaxHeight; + if (realSize < body.Config.HeightMap.maxHeight) realSize = body.Config.HeightMap.maxHeight; } - if (body.Config.Base.GroundSize != 0) + if (body.Config.Base.groundSize != 0) { - GeometryBuilder.Make(newProxy, null, body.Config.Base.GroundSize); - if (realSize < body.Config.Base.GroundSize) realSize = body.Config.Base.GroundSize; + GeometryBuilder.Make(newProxy, null, body.Config.Base.groundSize); + if (realSize < body.Config.Base.groundSize) realSize = body.Config.Base.groundSize; } - if (body.Config.Atmosphere?.Clouds != null) + if (body.Config.Atmosphere?.clouds != null) { CloudsBuilder.MakeTopClouds(newProxy, body.Config.Atmosphere, body.Mod); - if (realSize < body.Config.Atmosphere.Size) realSize = body.Config.Atmosphere.Size; + if (realSize < body.Config.Atmosphere.size) realSize = body.Config.Atmosphere.size; } if (body.Config.Ring != null) { RingBuilder.MakeRingGraphics(newProxy, null, body.Config.Ring, body.Mod); - if (realSize < body.Config.Ring.OuterRadius) realSize = body.Config.Ring.OuterRadius; + if (realSize < body.Config.Ring.outerRadius) realSize = body.Config.Ring.outerRadius; } if (body.Config.Star != null) { var starGO = StarBuilder.MakeStarProxy(planetGO, newProxy, body.Config.Star); - if (realSize < body.Config.Star.Size) realSize = body.Config.Star.Size; + if (realSize < body.Config.Star.size) realSize = body.Config.Star.size; } if (body.Config.ProcGen != null) { ProcGenBuilder.Make(newProxy, null, body.Config.ProcGen); - if (realSize < body.Config.ProcGen.Scale) realSize = body.Config.ProcGen.Scale; + if (realSize < body.Config.ProcGen.scale) realSize = body.Config.ProcGen.scale; } if (body.Config.Lava != null) { - var sphere = AddColouredSphere(newProxy, body.Config.Lava.Size, body.Config.Lava.Curve, Color.black); - if (realSize < body.Config.Lava.Size) realSize = body.Config.Lava.Size; + var sphere = AddColouredSphere(newProxy, body.Config.Lava.size, body.Config.Lava.Curve, Color.black); + if (realSize < body.Config.Lava.size) realSize = body.Config.Lava.size; var material = new Material(lavaMaterial); - if (body.Config.Lava.Tint != null) material.SetColor(EmissionColor, body.Config.Lava.Tint.ToColor()); + if (body.Config.Lava.tint != null) material.SetColor(EmissionColor, body.Config.Lava.tint.ToColor()); sphere.GetComponent().material = material; } if (body.Config.Water != null) { - var colour = body.Config.Water.Tint?.ToColor() ?? Color.blue; - AddColouredSphere(newProxy, body.Config.Water.Size, body.Config.Water.Curve, colour); - if (realSize < body.Config.Water.Size) realSize = body.Config.Water.Size; + var colour = body.Config.Water.tint?.ToColor() ?? Color.blue; + AddColouredSphere(newProxy, body.Config.Water.size, body.Config.Water.Curve, colour); + if (realSize < body.Config.Water.size) realSize = body.Config.Water.size; } if (body.Config.Sand != null) { @@ -95,24 +95,24 @@ 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 == SingularityModule.SingularityType.BlackHole) + if (body.Config.Singularity.type == SingularityModule.SingularityType.BlackHole) { - MakeBlackHole(newProxy, body.Config.Singularity.Size); + MakeBlackHole(newProxy, body.Config.Singularity.size); } else { - MakeWhiteHole(newProxy, body.Config.Singularity.Size); + MakeWhiteHole(newProxy, body.Config.Singularity.size); } - if (realSize < body.Config.Singularity.Size) realSize = body.Config.Singularity.Size; + if (realSize < body.Config.Singularity.size) realSize = body.Config.Singularity.size; } - if (body.Config.Base.HasCometTail) + if (body.Config.Base.hasCometTail) { CometTailBuilder.Make(newProxy, null, body.Config); } - if (body.Config.Props?.ProxyDetails != null) + if (body.Config.Props?.proxyDetails != null) { - foreach (var detailInfo in body.Config.Props.ProxyDetails) + foreach (var detailInfo in body.Config.Props.proxyDetails) { DetailBuilder.Make(newProxy, null, body.Config, body.Mod, body.Mod.ModHelper.Manifest.UniqueName, detailInfo); } @@ -136,12 +136,12 @@ namespace NewHorizons.Builder.Body } var proxyController = newProxy.AddComponent(); - proxyController.astroName = body.Config.Name; + proxyController.astroName = body.Config.name; proxyController._realObjectDiameter = realSize; } catch (Exception ex) { - Logger.LogError($"Exception thrown when generating proxy for [{body.Config.Name}] : {ex.Message}, {ex.StackTrace}"); + Logger.LogError($"Exception thrown when generating proxy for [{body.Config.name}] : {ex.Message}, {ex.StackTrace}"); GameObject.Destroy(newProxy); } } diff --git a/NewHorizons/Builder/Body/RingBuilder.cs b/NewHorizons/Builder/Body/RingBuilder.cs index b4fc065b..87084e4b 100644 --- a/NewHorizons/Builder/Body/RingBuilder.cs +++ b/NewHorizons/Builder/Body/RingBuilder.cs @@ -33,8 +33,8 @@ namespace NewHorizons.Builder.Body ringVolume.layer = LayerMask.NameToLayer("BasicEffectVolume"); var ringShape = ringVolume.AddComponent(); - ringShape.innerRadius = ring.InnerRadius; - ringShape.outerRadius = ring.OuterRadius; + ringShape.innerRadius = ring.innerRadius; + ringShape.outerRadius = ring.outerRadius; ringShape.height = 20f; ringShape.center = Vector3.zero; ringShape.SetCollisionMode(Shape.CollisionMode.Volume); @@ -48,15 +48,15 @@ namespace NewHorizons.Builder.Body var sfv = ringVolume.AddComponent(); var fluidType = FluidVolume.Type.NONE; - if (ring.FluidType != null) + if (ring.fluidType != null) { try { - fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(CloudFluidType), ring.FluidType).ToUpper()); + fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(CloudFluidType), ring.fluidType).ToUpper()); } catch (Exception ex) { - Logger.LogError($"Couldn't parse fluid volume type [{ring.FluidType}]: {ex.Message}, {ex.StackTrace}"); + Logger.LogError($"Couldn't parse fluid volume type [{ring.fluidType}]: {ex.Message}, {ex.StackTrace}"); } } @@ -73,12 +73,12 @@ namespace NewHorizons.Builder.Body public static GameObject MakeRingGraphics(GameObject rootObject, Sector sector, RingModule ring, IModBehaviour mod) { // Properly lit shader doesnt work yet - ring.Unlit = true; + ring.unlit = true; Texture2D ringTexture; try { - ringTexture = ImageUtilities.GetTexture(mod, ring.Texture); + ringTexture = ImageUtilities.GetTexture(mod, ring.texture); } catch (Exception e) { @@ -90,8 +90,8 @@ namespace NewHorizons.Builder.Body ringGO.transform.parent = sector?.transform ?? rootObject.transform; ringGO.transform.position = rootObject.transform.position; ringGO.transform.rotation = rootObject.transform.rotation; - ringGO.transform.Rotate(ringGO.transform.TransformDirection(Vector3.up), ring.LongitudeOfAscendingNode); - ringGO.transform.Rotate(ringGO.transform.TransformDirection(Vector3.left), ring.Inclination); + ringGO.transform.Rotate(ringGO.transform.TransformDirection(Vector3.up), ring.longitudeOfAscendingNode); + ringGO.transform.Rotate(ringGO.transform.TransformDirection(Vector3.left), ring.inclination); var ringMF = ringGO.AddComponent(); var ringMesh = ringMF.mesh; @@ -103,26 +103,26 @@ namespace NewHorizons.Builder.Body if (RingShader1Pixel == null) RingShader1Pixel = Main.NHAssetBundle.LoadAsset("Assets/Shaders/Ring1Pixel.shader"); if (UnlitRingShader1Pixel == null) UnlitRingShader1Pixel = Main.NHAssetBundle.LoadAsset("Assets/Shaders/UnlitRing1Pixel.shader"); - var mat = new Material(ring.Unlit ? UnlitRingShader : RingShader); + var mat = new Material(ring.unlit ? UnlitRingShader : RingShader); if (texture.width == 1) { - mat = new Material(ring.Unlit ? UnlitRingShader1Pixel : RingShader1Pixel); + mat = new Material(ring.unlit ? UnlitRingShader1Pixel : RingShader1Pixel); mat.SetFloat(InnerRadius, 0); } - ringMR.receiveShadows = !ring.Unlit; + ringMR.receiveShadows = !ring.unlit; mat.mainTexture = texture; mat.renderQueue = 3000; ringMR.material = mat; // Make mesh - var segments = (int)Mathf.Clamp(ring.OuterRadius, 20, 2000); - BuildRingMesh(ringMesh, segments, ring.InnerRadius, ring.OuterRadius); + var segments = (int)Mathf.Clamp(ring.outerRadius, 20, 2000); + BuildRingMesh(ringMesh, segments, ring.innerRadius, ring.outerRadius); - if (ring.RotationSpeed != 0) + if (ring.rotationSpeed != 0) { var rot = ringGO.AddComponent(); - rot._degreesPerSecond = ring.RotationSpeed; + rot._degreesPerSecond = ring.rotationSpeed; rot._localAxis = Vector3.down; } diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 46f8c190..949041f0 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -20,23 +20,23 @@ namespace NewHorizons.Builder.Body public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetConfig config) { - var size = config.Singularity.Size; - var pairedSingularity = config.Singularity.PairedSingularity; + var size = config.Singularity.size; + var pairedSingularity = config.Singularity.pairedSingularity; - var polarity = config.Singularity.Type; + var polarity = config.Singularity.type; - bool isWormHole = config.Singularity?.TargetStarSystem != null; + bool isWormHole = config.Singularity?.targetStarSystem != null; bool hasHazardVolume = !isWormHole && (pairedSingularity == null); - bool makeZeroGVolume = config.Singularity == null ? true : config.Singularity.MakeZeroGVolume; + bool makeZeroGVolume = config.Singularity == null ? true : config.Singularity.makeZeroGVolume; - Vector3 localPosition = config.Singularity?.Position == null ? Vector3.zero : (Vector3)config.Singularity.Position; + Vector3 localPosition = config.Singularity?.position == null ? Vector3.zero : (Vector3)config.Singularity.position; GameObject newSingularity = null; switch (polarity) { case SingularityModule.SingularityType.BlackHole: - newSingularity = MakeBlackHole(go, sector, localPosition, size, hasHazardVolume, config.Singularity.TargetStarSystem); + newSingularity = MakeBlackHole(go, sector, localPosition, size, hasHazardVolume, config.Singularity.targetStarSystem); break; case SingularityModule.SingularityType.WhiteHole: newSingularity = MakeWhiteHole(go, sector, OWRB, localPosition, size, makeZeroGVolume); diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index cfbccae0..0d93e1ae 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -25,7 +25,7 @@ namespace NewHorizons.Builder.Body var sunAudio = GameObject.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Audio_SUN"), starGO.transform); sunAudio.transform.localPosition = Vector3.zero; sunAudio.transform.localScale = Vector3.one; - sunAudio.transform.Find("SurfaceAudio_Sun").GetComponent().maxDistance = starModule.Size * 2f; + sunAudio.transform.Find("SurfaceAudio_Sun").GetComponent().maxDistance = starModule.size * 2f; var surfaceAudio = sunAudio.GetComponentInChildren(); surfaceAudio.SetSector(sector); surfaceAudio._sunController = null; @@ -33,28 +33,28 @@ namespace NewHorizons.Builder.Body sunAudio.name = "Audio_Star"; GameObject sunAtmosphere = null; - if (starModule.HasAtmosphere) + if (starModule.hasAtmosphere) { sunAtmosphere = GameObject.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), starGO.transform); sunAtmosphere.transform.position = planetGO.transform.position; sunAtmosphere.transform.localScale = Vector3.one * OuterRadiusRatio; sunAtmosphere.name = "Atmosphere_Star"; PlanetaryFogController fog = sunAtmosphere.transform.Find("FogSphere").GetComponent(); - if (starModule.Tint != null) + if (starModule.tint != null) { - fog.fogTint = starModule.Tint.ToColor(); + fog.fogTint = starModule.tint.ToColor(); sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one; foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren()) { - lod.material.SetColor(SkyColor, starModule.Tint.ToColor()); - lod.material.SetColor(AtmosFar, starModule.Tint.ToColor()); - lod.material.SetColor(AtmosNear, starModule.Tint.ToColor()); - lod.material.SetFloat(InnerRadius, starModule.Size); - lod.material.SetFloat(OuterRadius, starModule.Size * OuterRadiusRatio); + lod.material.SetColor(SkyColor, starModule.tint.ToColor()); + lod.material.SetColor(AtmosFar, starModule.tint.ToColor()); + lod.material.SetColor(AtmosNear, starModule.tint.ToColor()); + lod.material.SetFloat(InnerRadius, starModule.size); + lod.material.SetFloat(OuterRadius, starModule.size * OuterRadiusRatio); } } fog.transform.localScale = Vector3.one; - fog.fogRadius = starModule.Size * OuterRadiusRatio; + fog.fogRadius = starModule.size * OuterRadiusRatio; fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f); } @@ -86,11 +86,11 @@ namespace NewHorizons.Builder.Body var light = sunLight.AddComponent(); light.CopyPropertiesFrom(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent()); - light.intensity *= starModule.SolarLuminosity; - light.range *= Mathf.Sqrt(starModule.SolarLuminosity); + light.intensity *= starModule.solarLuminosity; + light.range *= Mathf.Sqrt(starModule.solarLuminosity); Color lightColour = light.color; - if (starModule.LightTint != null) lightColour = starModule.LightTint.ToColor(); + if (starModule.lightTint != null) lightColour = starModule.lightTint.ToColor(); light.color = lightColour; ambientLight.color = lightColour; @@ -105,7 +105,7 @@ namespace NewHorizons.Builder.Body proxyShadowLight._light = light; StarController starController = null; - if (starModule.SolarLuminosity != 0) + if (starModule.solarLuminosity != 0) { starController = planetGO.AddComponent(); starController.Light = light; @@ -113,7 +113,7 @@ namespace NewHorizons.Builder.Body starController.FaceActiveCamera = faceActiveCamera; starController.CSMTextureCacher = csmTextureCacher; starController.ProxyShadowLight = proxyShadowLight; - starController.Intensity = starModule.SolarLuminosity; + starController.Intensity = starModule.solarLuminosity; starController.SunColor = lightColour; } @@ -121,12 +121,12 @@ namespace NewHorizons.Builder.Body var controller = starGO.AddComponent(); if (starModule.Curve != null) controller.scaleCurve = starModule.GetAnimationCurve(); - controller.size = starModule.Size; + controller.size = starModule.size; controller.atmosphere = sunAtmosphere; controller.supernova = supernova; - controller.startColour = starModule.Tint; - controller.endColour = starModule.EndTint; - controller.willExplode = starModule.GoSupernova; + controller.startColour = starModule.tint; + controller.endColour = starModule.endTint; + controller.willExplode = starModule.goSupernova; // It fucking insists on this existing and its really annoying var supernovaVolume = new GameObject("SupernovaVolumePlaceholder"); @@ -147,10 +147,10 @@ namespace NewHorizons.Builder.Body var controller = starGO.AddComponent(); if (starModule.Curve != null) controller.scaleCurve = starModule.GetAnimationCurve(); - controller.size = starModule.Size; + controller.size = starModule.size; controller.supernova = supernova; - controller.startColour = starModule.Tint; - controller.endColour = starModule.EndTint; + controller.startColour = starModule.tint; + controller.endColour = starModule.endTint; controller.enabled = true; planet.GetComponentInChildren().SetProxy(controller); @@ -175,9 +175,9 @@ namespace NewHorizons.Builder.Body solarFlareEmitter.transform.localScale = Vector3.one; solarFlareEmitter.name = "SolarFlareEmitter"; - if (starModule.Tint != null) + if (starModule.tint != null) { - var flareTint = starModule.Tint.ToColor(); + var flareTint = starModule.tint.ToColor(); var emitter = solarFlareEmitter.GetComponent(); emitter.tint = flareTint; foreach (var controller in solarFlareEmitter.GetComponentsInChildren()) @@ -189,29 +189,29 @@ namespace NewHorizons.Builder.Body } starGO.transform.position = rootObject.transform.position; - starGO.transform.localScale = starModule.Size * Vector3.one; + starGO.transform.localScale = starModule.size * Vector3.one; - if (starModule.Tint != null) + if (starModule.tint != null) { TessellatedSphereRenderer surface = sunSurface.GetComponent(); - var colour = starModule.Tint.ToColor(); + var colour = starModule.tint.ToColor(); var sun = GameObject.Find("Sun_Body"); var mainSequenceMaterial = sun.GetComponent().GetValue("_startSurfaceMaterial"); var giantMaterial = sun.GetComponent().GetValue("_endSurfaceMaterial"); - surface.sharedMaterial = new Material(starModule.Size >= 3000 ? giantMaterial : mainSequenceMaterial); - var mod = Mathf.Max(1f, 2f * Mathf.Sqrt(starModule.SolarLuminosity)); + surface.sharedMaterial = new Material(starModule.size >= 3000 ? giantMaterial : mainSequenceMaterial); + var mod = Mathf.Max(1f, 2f * Mathf.Sqrt(starModule.solarLuminosity)); var adjustedColour = new Color(colour.r * mod, colour.g * mod, colour.b * mod); surface.sharedMaterial.color = adjustedColour; Color.RGBToHSV(adjustedColour, out float H, out float S, out float V); var darkenedColor = Color.HSVToRGB(H, S * 1.2f, V * 0.05f); - if (starModule.EndTint != null) + if (starModule.endTint != null) { - var endColour = starModule.EndTint.ToColor(); + var endColour = starModule.endTint.ToColor(); darkenedColor = new Color(endColour.r * mod, endColour.g * mod, endColour.b * mod); } @@ -231,9 +231,9 @@ namespace NewHorizons.Builder.Body supernova._surface = starGO.GetComponentInChildren(); supernova._supernovaVolume = null; - if (starModule.SupernovaTint != null) + if (starModule.supernovaTint != null) { - var colour = starModule.SupernovaTint.ToColor(); + var colour = starModule.supernovaTint.ToColor(); var supernovaMaterial = new Material(supernova._supernovaMaterial); var ramp = ImageUtilities.LerpGreyscaleImage(ImageUtilities.GetTexture(Main.Instance, "AssetBundle/Effects_SUN_Supernova_d.png"), Color.white, colour); diff --git a/NewHorizons/Builder/Body/WaterBuilder.cs b/NewHorizons/Builder/Body/WaterBuilder.cs index 15c1fb3e..acca5a7d 100644 --- a/NewHorizons/Builder/Body/WaterBuilder.cs +++ b/NewHorizons/Builder/Body/WaterBuilder.cs @@ -14,7 +14,7 @@ namespace NewHorizons.Builder.Body public static void Make(GameObject planetGO, Sector sector, OWRigidbody rb, WaterModule module) { - var waterSize = module.Size; + var waterSize = module.size; GameObject waterGO = new GameObject("Water"); waterGO.SetActive(false); @@ -38,10 +38,10 @@ namespace NewHorizons.Builder.Body for (int i = 0; i < GDSharedMaterials.Length; i++) { tempArray[i] = new Material(GDSharedMaterials[i]); - if (module.Tint != null) + if (module.tint != null) { - tempArray[i].color = module.Tint.ToColor(); - tempArray[i].SetColor("_FogColor", module.Tint.ToColor()); + tempArray[i].color = module.tint.ToColor(); + tempArray[i].SetColor("_FogColor", module.tint.ToColor()); } } @@ -83,9 +83,9 @@ namespace NewHorizons.Builder.Body fogGO.transform.localPosition = Vector3.zero; fogGO.transform.localScale = Vector3.one; - if (module.Tint != null) + if (module.tint != null) { - var adjustedColour = module.Tint.ToColor() / 4f; + var adjustedColour = module.tint.ToColor() / 4f; adjustedColour.a = adjustedColour.a * 4f; fogGO.GetComponent().material.color = adjustedColour; } @@ -100,12 +100,12 @@ namespace NewHorizons.Builder.Body } sizeController.scaleCurve = curve; sizeController.oceanFogMaterial = fogGO.GetComponent().material; - sizeController.size = module.Size; + sizeController.size = module.size; } else { - fogGO.GetComponent().material.SetFloat(Radius, module.Size); - fogGO.GetComponent().material.SetFloat(Radius2, module.Size / 2f); + fogGO.GetComponent().material.SetFloat(Radius, module.size); + fogGO.GetComponent().material.SetFloat(Radius2, module.size / 2f); } // TODO: make LOD work diff --git a/NewHorizons/Builder/General/AstroObjectBuilder.cs b/NewHorizons/Builder/General/AstroObjectBuilder.cs index af538f32..77e6e08d 100644 --- a/NewHorizons/Builder/General/AstroObjectBuilder.cs +++ b/NewHorizons/Builder/General/AstroObjectBuilder.cs @@ -9,19 +9,19 @@ namespace NewHorizons.Builder.General public static NHAstroObject Make(GameObject body, AstroObject primaryBody, PlanetConfig config) { NHAstroObject astroObject = body.AddComponent(); - astroObject.HideDisplayName = !config.Base.HasMapMarker; + astroObject.HideDisplayName = !config.Base.hasMapMarker; if (config.Orbit != null) astroObject.SetOrbitalParametersFromConfig(config.Orbit); var type = AstroObject.Type.Planet; if (config.Orbit.IsMoon) type = AstroObject.Type.Moon; // else if (config.Base.IsSatellite) type = AstroObject.Type.Satellite; - else if (config.Base.HasCometTail) type = AstroObject.Type.Comet; + else if (config.Base.hasCometTail) type = AstroObject.Type.Comet; else if (config.Star != null) type = AstroObject.Type.Star; else if (config.FocalPoint != null) type = AstroObject.Type.None; astroObject._type = type; astroObject._name = AstroObject.Name.CustomString; - astroObject._customName = config.Name; + astroObject._customName = config.name; astroObject._primaryBody = primaryBody; // Expand gravitational sphere of influence of the primary to encompass this body if needed @@ -47,9 +47,9 @@ namespace NewHorizons.Builder.General } } - if (config.Base.CenterOfSolarSystem) + if (config.Base.centerOfSolarSystem) { - Logger.Log($"Setting center of universe to {config.Name}"); + Logger.Log($"Setting center of universe to {config.name}"); // By the time it runs we'll be able to get the OWRB with the method Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => Locator.GetCenterOfTheUniverse()._staticReferenceFrame = astroObject.GetAttachedOWRigidbody(), 2); } diff --git a/NewHorizons/Builder/General/DetectorBuilder.cs b/NewHorizons/Builder/General/DetectorBuilder.cs index b2809144..d71c30b4 100644 --- a/NewHorizons/Builder/General/DetectorBuilder.cs +++ b/NewHorizons/Builder/General/DetectorBuilder.cs @@ -19,13 +19,13 @@ namespace NewHorizons.Builder.General OWRB.RegisterAttachedForceDetector(forceDetector); // For falling into sun - if (!config.Base.InvulnerableToSun && config.Star == null && config.FocalPoint == null) + if (!config.Base.invulnerableToSun && config.Star == null && config.FocalPoint == null) { detectorGO.layer = LayerMask.NameToLayer("AdvancedDetector"); var fluidDetector = detectorGO.AddComponent(); var sphereCollider = detectorGO.AddComponent(); - sphereCollider.radius = config.Base.SurfaceSize; + sphereCollider.radius = config.Base.surfaceSize; var owCollider = detectorGO.AddComponent(); diff --git a/NewHorizons/Builder/General/GravityBuilder.cs b/NewHorizons/Builder/General/GravityBuilder.cs index 5f0fe48c..067a1a75 100644 --- a/NewHorizons/Builder/General/GravityBuilder.cs +++ b/NewHorizons/Builder/General/GravityBuilder.cs @@ -8,17 +8,17 @@ namespace NewHorizons.Builder.General { public static GravityVolume Make(GameObject planetGO, AstroObject ao, PlanetConfig config) { - var exponent = config.Base.GravityFallOff == GravityFallOff.Linear ? 1f : 2f; - var GM = config.Base.SurfaceGravity * Mathf.Pow(config.Base.SurfaceSize, exponent); + 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 var gravityRadius = GM / 0.1f; if (exponent == 2f) gravityRadius = Mathf.Sqrt(gravityRadius); // To let you actually orbit things the way you would expect we cap this at 4x the diameter if its not a star or black hole (this is what giants deep has) - if (config.Star == null && config.Singularity == null) gravityRadius = Mathf.Min(gravityRadius, 4 * config.Base.SurfaceSize); - else gravityRadius = Mathf.Min(gravityRadius, 15 * config.Base.SurfaceSize); - if (config.Base.SphereOfInfluence != 0f) gravityRadius = config.Base.SphereOfInfluence; + if (config.Star == null && config.Singularity == null) gravityRadius = Mathf.Min(gravityRadius, 4 * config.Base.surfaceSize); + else gravityRadius = Mathf.Min(gravityRadius, 15 * config.Base.surfaceSize); + if (config.Base.sphereOfInfluence != 0f) gravityRadius = config.Base.sphereOfInfluence; var gravityGO = new GameObject("GravityWell"); gravityGO.transform.parent = planetGO.transform; @@ -38,21 +38,21 @@ namespace NewHorizons.Builder.General var gravityVolume = gravityGO.AddComponent(); gravityVolume._cutoffAcceleration = 0.1f; - var falloff = config.Base.GravityFallOff == GravityFallOff.Linear? GravityVolume.FalloffType.linear : GravityVolume.FalloffType.inverseSquared; + var falloff = config.Base.gravityFallOff == GravityFallOff.Linear? GravityVolume.FalloffType.linear : GravityVolume.FalloffType.inverseSquared; gravityVolume._falloffType = falloff; // Radius where your feet turn to the planet - var alignmentRadius = config.Atmosphere?.Clouds?.OuterCloudRadius ?? 1.5f * config.Base.SurfaceSize; - if (config.Base.SurfaceGravity == 0) alignmentRadius = 0; + var alignmentRadius = config.Atmosphere?.clouds?.outerCloudRadius ?? 1.5f * config.Base.surfaceSize; + if (config.Base.surfaceGravity == 0) alignmentRadius = 0; gravityVolume._alignmentRadius = alignmentRadius; - gravityVolume._upperSurfaceRadius = config.Base.SurfaceSize; + gravityVolume._upperSurfaceRadius = config.Base.surfaceSize; gravityVolume._lowerSurfaceRadius = 0; gravityVolume._layer = 3; gravityVolume._priority = 0; gravityVolume._alignmentPriority = 0; - gravityVolume._surfaceAcceleration = config.Base.SurfaceGravity; + gravityVolume._surfaceAcceleration = config.Base.surfaceGravity; gravityVolume._inheritable = false; gravityVolume._isPlanetGravityVolume = true; gravityVolume._cutoffRadius = 0f; diff --git a/NewHorizons/Builder/General/MarkerBuilder.cs b/NewHorizons/Builder/General/MarkerBuilder.cs index 8fc0cc19..726e6f16 100644 --- a/NewHorizons/Builder/General/MarkerBuilder.cs +++ b/NewHorizons/Builder/General/MarkerBuilder.cs @@ -8,7 +8,7 @@ namespace NewHorizons.Builder.General public static void Make(GameObject body, string name, PlanetConfig config) { MapMarker mapMarker = body.AddComponent(); - mapMarker._labelID = (UITextType)TranslationHandler.AddUI(config.Name); + mapMarker._labelID = (UITextType)TranslationHandler.AddUI(config.name); var markerType = MapMarker.MarkerType.Planet; diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index 5236b793..05f6d7a4 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -9,19 +9,19 @@ namespace NewHorizons.Builder.General public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbody owRigidBody) { SpawnPoint playerSpawn = null; - if (!Main.Instance.IsWarping && module.PlayerSpawnPoint != null) + if (!Main.Instance.IsWarping && module.playerSpawnPoint != null) { GameObject spawnGO = new GameObject("PlayerSpawnPoint"); spawnGO.transform.parent = planetGO.transform; spawnGO.layer = 8; - spawnGO.transform.localPosition = module.PlayerSpawnPoint; + spawnGO.transform.localPosition = module.playerSpawnPoint; playerSpawn = spawnGO.AddComponent(); - if(module.PlayerSpawnRotation != null) + if(module.playerSpawnRotation != null) { - spawnGO.transform.rotation = Quaternion.Euler(module.PlayerSpawnRotation); + spawnGO.transform.rotation = Quaternion.Euler(module.playerSpawnRotation); } else { @@ -30,13 +30,13 @@ namespace NewHorizons.Builder.General spawnGO.transform.position = spawnGO.transform.position + spawnGO.transform.TransformDirection(Vector3.up) * 4f; } - if (module.ShipSpawnPoint != null) + if (module.shipSpawnPoint != null) { GameObject spawnGO = new GameObject("ShipSpawnPoint"); spawnGO.transform.parent = planetGO.transform; spawnGO.layer = 8; - spawnGO.transform.localPosition = module.ShipSpawnPoint; + spawnGO.transform.localPosition = module.shipSpawnPoint; var spawnPoint = spawnGO.AddComponent(); spawnPoint._isShipSpawn = true; @@ -44,9 +44,9 @@ namespace NewHorizons.Builder.General var ship = GameObject.Find("Ship_Body"); ship.transform.position = spawnPoint.transform.position; - if(module.ShipSpawnRotation != null) + if(module.shipSpawnRotation != null) { - ship.transform.rotation = Quaternion.Euler(module.ShipSpawnRotation); + ship.transform.rotation = Quaternion.Euler(module.shipSpawnRotation); } else { @@ -70,7 +70,7 @@ namespace NewHorizons.Builder.General playerSpawnGO.transform.localRotation = Quaternion.Euler(0, 0, 0); } } - if (!Main.Instance.IsWarping && module.StartWithSuit && !suitUpQueued) + if (!Main.Instance.IsWarping && module.startWithSuit && !suitUpQueued) { suitUpQueued = true; Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () => SuitUp()); diff --git a/NewHorizons/Builder/Orbital/FocalPointBuilder.cs b/NewHorizons/Builder/Orbital/FocalPointBuilder.cs index 65e71505..c217664e 100644 --- a/NewHorizons/Builder/Orbital/FocalPointBuilder.cs +++ b/NewHorizons/Builder/Orbital/FocalPointBuilder.cs @@ -15,8 +15,8 @@ namespace NewHorizons.Builder.Orbital var module = config.FocalPoint; var binary = go.AddComponent(); - binary.PrimaryName = module.Primary; - binary.SecondaryName = module.Secondary; + binary.PrimaryName = module.primary; + binary.SecondaryName = module.secondary; // Below is the stupid fix for making circumbinary planets or wtv @@ -25,11 +25,11 @@ namespace NewHorizons.Builder.Orbital NewHorizonsBody secondary = null; foreach (var body in Main.BodyDict[Main.Instance.CurrentStarSystem]) { - if (body.Config.Name == module.Primary) + if (body.Config.name == module.primary) { primary = body; } - else if (body.Config.Name == module.Secondary) + else if (body.Config.name == module.secondary) { secondary = body; } @@ -41,7 +41,7 @@ namespace NewHorizons.Builder.Orbital if (primary == null || secondary == null) { - Logger.LogError($"Couldn't make focal point between [{module.Primary} = {primary}] and [{module.Secondary} = {secondary}]"); + Logger.LogError($"Couldn't make focal point between [{module.primary} = {primary}] and [{module.secondary} = {secondary}]"); return; } @@ -51,15 +51,15 @@ namespace NewHorizons.Builder.Orbital var fakeMassConfig = new PlanetConfig(); // Now need to fake the 3 values to make it return this mass - fakeMassConfig.Base.SurfaceSize = 1; - fakeMassConfig.Base.SurfaceGravity = gravitationalMass * GravityVolume.GRAVITATIONAL_CONSTANT; - fakeMassConfig.Base.GravityFallOff = primary.Config.Base.GravityFallOff; + fakeMassConfig.Base.surfaceSize = 1; + fakeMassConfig.Base.surfaceGravity = gravitationalMass * GravityVolume.GRAVITATIONAL_CONSTANT; + fakeMassConfig.Base.gravityFallOff = primary.Config.Base.gravityFallOff; // Other stuff to make the fake barycenter not interact with anything in any way - fakeMassConfig.Name = config.Name + "_FakeBarycenterMass"; - fakeMassConfig.Base.SphereOfInfluence = 0; - fakeMassConfig.Base.HasMapMarker = false; - fakeMassConfig.Base.HasReferenceFrame = false; + fakeMassConfig.name = config.name + "_FakeBarycenterMass"; + fakeMassConfig.Base.sphereOfInfluence = 0; + fakeMassConfig.Base.hasMapMarker = false; + fakeMassConfig.Base.hasReferenceFrame = false; fakeMassConfig.Orbit = new OrbitModule(); fakeMassConfig.Orbit.CopyPropertiesFrom(config.Orbit); @@ -69,9 +69,9 @@ namespace NewHorizons.Builder.Orbital private static float GetGravitationalMass(PlanetConfig config) { - var surfaceAcceleration = config.Base.SurfaceGravity; - var upperSurfaceRadius = config.Base.SurfaceSize; - int falloffExponent = config.Base.GravityFallOff == GravityFallOff.Linear ? 1 : 2; + var surfaceAcceleration = config.Base.surfaceGravity; + var upperSurfaceRadius = config.Base.surfaceSize; + int falloffExponent = config.Base.gravityFallOff == GravityFallOff.Linear ? 1 : 2; return surfaceAcceleration * Mathf.Pow(upperSurfaceRadius, falloffExponent) / GravityVolume.GRAVITATIONAL_CONSTANT; } diff --git a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs index d8fda4d7..61a8b61a 100644 --- a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs +++ b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs @@ -58,12 +58,12 @@ namespace NewHorizons.Builder.Orbital var color = Color.white; if (config.Orbit.Tint != null) color = config.Orbit.Tint.ToColor32(); - else if (config.Star != null) color = config.Star.Tint.ToColor32(); - else if (config.Atmosphere?.Clouds?.Tint != null) color = config.Atmosphere.Clouds.Tint.ToColor32(); + else if (config.Star != null) color = config.Star.tint.ToColor32(); + else if (config.Atmosphere?.clouds?.tint != null) color = config.Atmosphere.clouds.tint.ToColor32(); else if (config.Singularity != null) color = new Color(1f, 0.5f, 1f); else if (config.Water != null) color = new Color(0.5f, 0.5f, 1f); else if (config.Lava != null) color = new Color(1f, 0.5f, 0.5f); - else if (config.Atmosphere != null && config.Atmosphere.FogTint != null) color = config.Atmosphere.FogTint.ToColor32(); + else if (config.Atmosphere != null && config.Atmosphere.fogTint != null) color = config.Atmosphere.fogTint.ToColor32(); var fade = isMoon; diff --git a/NewHorizons/Builder/Props/PropBuildManager.cs b/NewHorizons/Builder/Props/PropBuildManager.cs index b50ca21e..b3234099 100644 --- a/NewHorizons/Builder/Props/PropBuildManager.cs +++ b/NewHorizons/Builder/Props/PropBuildManager.cs @@ -10,7 +10,7 @@ namespace NewHorizons.Builder.Props { public static void Make(GameObject go, Sector sector, OWRigidbody planetBody, PlanetConfig config, IModBehaviour mod, string uniqueModName) { - if (config.Props.Scatter != null) + if (config.Props.scatter != null) { try { @@ -21,9 +21,9 @@ namespace NewHorizons.Builder.Props Logger.LogError($"Couldn't make planet scatter for [{go.name}] : {ex.Message}, {ex.StackTrace}"); } } - if (config.Props.Details != null) + if (config.Props.details != null) { - foreach (var detail in config.Props.Details) + foreach (var detail in config.Props.details) { try { @@ -35,9 +35,9 @@ namespace NewHorizons.Builder.Props } } } - if (config.Props.Geysers != null) + if (config.Props.geysers != null) { - foreach (var geyserInfo in config.Props.Geysers) + foreach (var geyserInfo in config.Props.geysers) { try { @@ -49,9 +49,9 @@ namespace NewHorizons.Builder.Props } } } - if (Main.HasDLC && config.Props.Rafts != null) + if (Main.HasDLC && config.Props.rafts != null) { - foreach (var raftInfo in config.Props.Rafts) + foreach (var raftInfo in config.Props.rafts) { try { @@ -63,13 +63,13 @@ namespace NewHorizons.Builder.Props } } } - if (config.Props.Tornados != null) + if (config.Props.tornados != null) { - foreach (var tornadoInfo in config.Props.Tornados) + foreach (var tornadoInfo in config.Props.tornados) { try { - TornadoBuilder.Make(go, sector, tornadoInfo, config.Atmosphere?.Clouds != null); + TornadoBuilder.Make(go, sector, tornadoInfo, config.Atmosphere?.clouds != null); } catch (Exception ex) { @@ -77,9 +77,9 @@ namespace NewHorizons.Builder.Props } } } - if (config.Props.Volcanoes != null) + if (config.Props.volcanoes != null) { - foreach (var volcanoInfo in config.Props.Volcanoes) + foreach (var volcanoInfo in config.Props.volcanoes) { try { @@ -92,9 +92,9 @@ namespace NewHorizons.Builder.Props } } // Reminder that dialogue has to be built after props if they're going to be using CharacterAnimController stuff - if (config.Props.Dialogue != null) + if (config.Props.dialogue != null) { - foreach (var dialogueInfo in config.Props.Dialogue) + foreach (var dialogueInfo in config.Props.dialogue) { try { @@ -106,9 +106,9 @@ namespace NewHorizons.Builder.Props } } } - if (config.Props.Reveal != null) + if (config.Props.reveal != null) { - foreach (var revealInfo in config.Props.Reveal) + foreach (var revealInfo in config.Props.reveal) { try { @@ -120,9 +120,9 @@ namespace NewHorizons.Builder.Props } } } - if (config.Props.EntryLocation != null) + if (config.Props.entryLocation != null) { - foreach (var entryLocationInfo in config.Props.EntryLocation) + foreach (var entryLocationInfo in config.Props.entryLocation) { try { @@ -134,9 +134,9 @@ namespace NewHorizons.Builder.Props } } } - if (config.Props.NomaiText != null) + if (config.Props.nomaiText != null) { - foreach (var nomaiTextInfo in config.Props.NomaiText) + foreach (var nomaiTextInfo in config.Props.nomaiText) { try { @@ -149,9 +149,9 @@ namespace NewHorizons.Builder.Props } } - if (Main.HasDLC && config.Props.SlideShows != null) + if (Main.HasDLC && config.Props.slideShows != null) { - foreach (var slideReelInfo in config.Props.SlideShows) + foreach (var slideReelInfo in config.Props.slideShows) { try { diff --git a/NewHorizons/Builder/Props/ScatterBuilder.cs b/NewHorizons/Builder/Props/ScatterBuilder.cs index 200c53db..f64faad5 100644 --- a/NewHorizons/Builder/Props/ScatterBuilder.cs +++ b/NewHorizons/Builder/Props/ScatterBuilder.cs @@ -11,7 +11,7 @@ namespace NewHorizons.Builder.Props { public static void Make(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, string uniqueModName) { - MakeScatter(go, config.Props.Scatter, config.Base.SurfaceSize, sector, mod, uniqueModName, config); + MakeScatter(go, config.Props.scatter, config.Base.surfaceSize, sector, mod, uniqueModName, config); } private static void MakeScatter(GameObject go, PropModule.ScatterInfo[] scatterInfo, float radius, Sector sector, IModBehaviour mod, string uniqueModName, PlanetConfig config) @@ -26,12 +26,12 @@ namespace NewHorizons.Builder.Props { try { - heightMapTexture = ImageUtilities.GetTexture(mod, heightMap.HeightMap); + heightMapTexture = ImageUtilities.GetTexture(mod, heightMap.heightMap); } catch (Exception) { } if (heightMapTexture == null) { - radius = heightMap.MaxHeight; + radius = heightMap.maxHeight; } } @@ -58,13 +58,13 @@ namespace NewHorizons.Builder.Props float sampleY = heightMapTexture.height * latitude / 180f; float relativeHeight = heightMapTexture.GetPixel((int)sampleX, (int)sampleY).r; - height = (relativeHeight * (heightMap.MaxHeight - heightMap.MinHeight) + heightMap.MinHeight); + height = (relativeHeight * (heightMap.maxHeight - heightMap.minHeight) + heightMap.minHeight); // Because heightmaps are dumb gotta rotate it 90 degrees around the x axis bc UHHHHHHHHHHHHH point = Quaternion.Euler(90, 0, 0) * point; // Keep things mostly above water - if (config.Water != null && height - 1f < config.Water.Size) continue; + if (config.Water != null && height - 1f < config.Water.size) continue; // Move it slightly into the ground height -= 0.1f; diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index 7febf1d8..7f38857e 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -126,7 +126,7 @@ namespace NewHorizons.Builder.Props public static void Make(GameObject body, Sector sector, SignalModule module, IModBehaviour mod) { - foreach (var info in module.Signals) + foreach (var info in module.signals) { Make(body, sector, info, mod); } @@ -134,10 +134,10 @@ namespace NewHorizons.Builder.Props public static void Make(GameObject planetGO, Sector sector, SignalModule.SignalInfo info, IModBehaviour mod) { - var signalGO = new GameObject($"Signal_{info.Name}"); + var signalGO = new GameObject($"Signal_{info.name}"); signalGO.SetActive(false); signalGO.transform.parent = sector?.transform ?? planetGO.transform; - signalGO.transform.position = planetGO.transform.TransformPoint(info.Position != null ? (Vector3)info.Position : Vector3.zero); + signalGO.transform.position = planetGO.transform.TransformPoint(info.position != null ? (Vector3)info.position : Vector3.zero); signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); var source = signalGO.AddComponent(); @@ -145,30 +145,30 @@ namespace NewHorizons.Builder.Props owAudioSource._audioSource = source; AudioSignal audioSignal; - if (info.InsideCloak) audioSignal = signalGO.AddComponent(); + if (info.insideCloak) audioSignal = signalGO.AddComponent(); else audioSignal = signalGO.AddComponent(); audioSignal._owAudioSource = owAudioSource; - var frequency = StringToFrequency(info.Frequency); - var name = StringToSignalName(info.Name); + var frequency = StringToFrequency(info.frequency); + var name = StringToSignalName(info.name); AudioClip clip = null; - if (info.AudioClip != null) clip = SearchUtilities.FindResourceOfTypeAndName(info.AudioClip); - else if (info.AudioFilePath != null) + if (info.audioClip != null) clip = SearchUtilities.FindResourceOfTypeAndName(info.audioClip); + else if (info.audioFilePath != null) { try { - clip = AudioUtilities.LoadAudio(mod.ModHelper.Manifest.ModFolderPath + "/" + info.AudioFilePath); + clip = AudioUtilities.LoadAudio(mod.ModHelper.Manifest.ModFolderPath + "/" + info.audioFilePath); } catch (Exception e) { - Logger.LogError($"Couldn't load audio file {info.AudioFilePath} : {e.Message}"); + Logger.LogError($"Couldn't load audio file {info.audioFilePath} : {e.Message}"); } } if (clip == null) { - Logger.LogError($"Couldn't find AudioClip {info.AudioClip} or AudioFile {info.AudioFilePath}"); + Logger.LogError($"Couldn't find AudioClip {info.audioClip} or AudioFile {info.audioFilePath}"); return; } @@ -178,10 +178,10 @@ namespace NewHorizons.Builder.Props audioSignal._frequency = frequency; audioSignal._name = name; - audioSignal._sourceRadius = info.SourceRadius; - audioSignal._revealFactID = info.Reveals; - audioSignal._onlyAudibleToScope = info.OnlyAudibleToScope; - audioSignal._identificationDistance = info.IdentificationRadius; + audioSignal._sourceRadius = info.sourceRadius; + audioSignal._revealFactID = info.reveals; + audioSignal._onlyAudibleToScope = info.onlyAudibleToScope; + audioSignal._identificationDistance = info.identificationRadius; audioSignal._canBePickedUpByScope = true; source.clip = clip; @@ -196,7 +196,7 @@ namespace NewHorizons.Builder.Props source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, _customCurve); // If it can be heard regularly then we play it immediately - source.playOnAwake = !info.OnlyAudibleToScope; + source.playOnAwake = !info.onlyAudibleToScope; source.spatialBlend = 1f; source.volume = 0.5f; source.dopplerLevel = 0; @@ -205,17 +205,17 @@ namespace NewHorizons.Builder.Props // Frequency detection trigger volume - var signalDetectionGO = new GameObject($"SignalDetectionTrigger_{info.Name}"); + var signalDetectionGO = new GameObject($"SignalDetectionTrigger_{info.name}"); signalDetectionGO.SetActive(false); signalDetectionGO.transform.parent = sector?.transform ?? planetGO.transform; - signalDetectionGO.transform.position = planetGO.transform.TransformPoint(info.Position != null ? (Vector3)info.Position : Vector3.zero); + signalDetectionGO.transform.position = planetGO.transform.TransformPoint(info.position != null ? (Vector3)info.position : Vector3.zero); signalDetectionGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); var sphereShape = signalDetectionGO.AddComponent(); var owTriggerVolume = signalDetectionGO.AddComponent(); var audioSignalDetectionTrigger = signalDetectionGO.AddComponent(); - sphereShape.radius = info.DetectionRadius == 0 ? info.SourceRadius + 30 : info.DetectionRadius; + sphereShape.radius = info.detectionRadius == 0 ? info.sourceRadius + 30 : info.detectionRadius; audioSignalDetectionTrigger._signal = audioSignal; audioSignalDetectionTrigger._trigger = owTriggerVolume; diff --git a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs index acdefd3b..5b13fe77 100644 --- a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs @@ -18,7 +18,7 @@ namespace NewHorizons.Builder.ShipLog { Material greyScaleMaterial = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/Sprite").GetComponent().material; List bodies = Main.BodyDict[systemName].Where( - b => !(b.Config.ShipLog?.mapMode?.remove ?? false) && !b.Config.IsQuantumState + b => !(b.Config.ShipLog?.mapMode?.remove ?? false) && !b.Config.isQuantumState ).ToList(); bool flagManualPositionUsed = systemName == "SolarSystem"; bool flagAutoPositionUsed = false; @@ -35,7 +35,7 @@ namespace NewHorizons.Builder.ShipLog flagManualPositionUsed = true; if (body.Config.ShipLog?.mapMode?.manualNavigationPosition == null) { - Logger.LogError("Navigation position is missing for: " + body.Config.Name); + Logger.LogError("Navigation position is missing for: " + body.Config.name); return null; } } @@ -82,7 +82,7 @@ namespace NewHorizons.Builder.ShipLog private static GameObject CreateMapModeGameObject(NewHorizonsBody body, GameObject parent, int layer, Vector2 position) { - GameObject newGameObject = new GameObject(body.Config.Name + "_ShipLog"); + GameObject newGameObject = new GameObject(body.Config.name + "_ShipLog"); newGameObject.layer = layer; newGameObject.transform.SetParent(parent.transform); @@ -116,8 +116,8 @@ namespace NewHorizons.Builder.ShipLog if (outlinePath != null) outline = ImageUtilities.GetTexture(body.Mod, outlinePath); if (outline == null) outline = ImageUtilities.MakeOutline(image, Color.white, 10); - astroObject._imageObj = CreateImage(gameObject, image, body.Config.Name + " Revealed", layer); - astroObject._outlineObj = CreateImage(gameObject, outline, body.Config.Name + " Outline", layer); + astroObject._imageObj = CreateImage(gameObject, image, body.Config.name + " Revealed", layer); + astroObject._outlineObj = CreateImage(gameObject, outline, body.Config.name + " Outline", layer); if (ShipLogHandler.BodyHasEntries(body)) { Image revealedImage = astroObject._imageObj.GetComponent(); @@ -220,8 +220,8 @@ namespace NewHorizons.Builder.ShipLog if (body.Config.ShipLog?.mapMode?.manualNavigationPosition == null) continue; // Sometimes they got other names idk - var name = body.Config.Name.Replace(" ", ""); - var existingBody = AstroObjectLocator.GetAstroObject(body.Config.Name); + var name = body.Config.name.Replace(" ", ""); + var existingBody = AstroObjectLocator.GetAstroObject(body.Config.name); if (existingBody != null) { var astroName = existingBody.GetAstroObjectName(); @@ -242,7 +242,7 @@ namespace NewHorizons.Builder.ShipLog else if (Main.Instance.CurrentStarSystem == "SolarSystem") { GameObject gameObject = SearchUtilities.CachedFind(ShipLogHandler.PAN_ROOT_PATH + "/" + name); - if (body.Config.Destroy || (body.Config.ShipLog?.mapMode?.remove ?? false)) + if (body.Config.destroy || (body.Config.ShipLog?.mapMode?.remove ?? false)) { ShipLogAstroObject astroObject = gameObject.GetComponent(); if (astroObject != null) @@ -363,7 +363,7 @@ namespace NewHorizons.Builder.ShipLog private static MapModeObject ConstructPrimaryNode(List bodies) { - foreach (NewHorizonsBody body in bodies.Where(b => b.Config.Base.CenterOfSolarSystem)) + foreach (NewHorizonsBody body in bodies.Where(b => b.Config.Base.centerOfSolarSystem)) { bodies.Sort((b, o) => b.Config.Orbit.SemiMajorAxis.CompareTo(o.Config.Orbit.SemiMajorAxis)); MapModeObject newNode = new MapModeObject @@ -388,7 +388,7 @@ namespace NewHorizons.Builder.ShipLog int newLevel = parent.level + 1; MapModeObject lastSibling = parent; - foreach (NewHorizonsBody body in searchList.Where(b => b.Config.Orbit.PrimaryBody == parent.mainBody.Config.Name || b.Config.Name == secondaryName)) + foreach (NewHorizonsBody body in searchList.Where(b => b.Config.Orbit.PrimaryBody == parent.mainBody.Config.name || b.Config.name == secondaryName)) { bool even = newLevel % 2 == 0; newX = even ? newX : newX + 1; @@ -405,8 +405,8 @@ namespace NewHorizons.Builder.ShipLog string newSecondaryName = ""; if (body.Config.FocalPoint != null) { - newNode.mainBody = searchList.Find(b => b.Config.Name == body.Config.FocalPoint.Primary); - newSecondaryName = searchList.Find(b => b.Config.Name == body.Config.FocalPoint.Secondary).Config.Name; + newNode.mainBody = searchList.Find(b => b.Config.name == body.Config.FocalPoint.primary); + newSecondaryName = searchList.Find(b => b.Config.name == body.Config.FocalPoint.secondary).Config.name; } newNode.children = ConstructChildrenNodes(newNode, searchList, newSecondaryName); @@ -512,7 +512,7 @@ namespace NewHorizons.Builder.ShipLog { try { - switch (body.Config?.Singularity?.Type) + switch (body.Config?.Singularity?.type) { case SingularityModule.SingularityType.BlackHole: return Color.black; @@ -520,27 +520,27 @@ namespace NewHorizons.Builder.ShipLog return Color.white; } - var starColor = body.Config?.Star?.Tint; + var starColor = body.Config?.Star?.tint; if (starColor != null) return starColor.ToColor(); - var atmoColor = body.Config.Atmosphere?.AtmosphereTint; - if (body.Config.Atmosphere?.Clouds != null && atmoColor != null) return atmoColor.ToColor(); + var atmoColor = body.Config.Atmosphere?.atmosphereTint; + if (body.Config.Atmosphere?.clouds != null && atmoColor != null) return atmoColor.ToColor(); - if (body.Config?.HeightMap?.TextureMap != null) + if (body.Config?.HeightMap?.textureMap != null) { try { - var texture = ImageUtilities.GetTexture(body.Mod, body.Config.HeightMap.TextureMap); + var texture = ImageUtilities.GetTexture(body.Mod, body.Config.HeightMap.textureMap); var landColor = ImageUtilities.GetAverageColor(texture); if (landColor != null) return landColor; } catch (Exception) { } } - var waterColor = body.Config.Water?.Tint; + var waterColor = body.Config.Water?.tint; if (waterColor != null) return waterColor.ToColor(); - var lavaColor = body.Config.Lava?.Tint; + var lavaColor = body.Config.Lava?.tint; if (lavaColor != null) return lavaColor.ToColor(); var sandColor = body.Config.Sand?.Tint; @@ -548,7 +548,7 @@ namespace NewHorizons.Builder.ShipLog } catch (Exception) { - Logger.LogWarning($"Something went wrong trying to pick the colour for {body.Config.Name} but I'm too lazy to fix it."); + Logger.LogWarning($"Something went wrong trying to pick the colour for {body.Config.name} but I'm too lazy to fix it."); } return Color.white; diff --git a/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs index 4dfa478b..23c50ea2 100644 --- a/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs @@ -51,7 +51,7 @@ namespace NewHorizons.Builder.ShipLog public static void AddBodyToShipLog(ShipLogManager manager, NewHorizonsBody body) { - string systemName = body.Config.StarSystem; + string systemName = body.Config.starSystem; XElement astroBodyFile = XElement.Load(body.Mod.ModHelper.Manifest.ModFolderPath + "/" + body.Config.ShipLog.xmlFile); XElement astroBodyId = astroBodyFile.Element("ID"); if (astroBodyId == null) diff --git a/NewHorizons/Components/MapSatelliteOrbitFix.cs b/NewHorizons/Components/MapSatelliteOrbitFix.cs index 190e1a75..1e8e0778 100644 --- a/NewHorizons/Components/MapSatelliteOrbitFix.cs +++ b/NewHorizons/Components/MapSatelliteOrbitFix.cs @@ -11,7 +11,7 @@ namespace NewHorizons.Components { Base = { - SurfaceSize = 10f + surfaceSize = 10f } }; diff --git a/NewHorizons/Components/Orbital/Gravity.cs b/NewHorizons/Components/Orbital/Gravity.cs index 029d50eb..9d7dc408 100644 --- a/NewHorizons/Components/Orbital/Gravity.cs +++ b/NewHorizons/Components/Orbital/Gravity.cs @@ -15,9 +15,9 @@ namespace NewHorizons.Components.Orbital public Gravity(BaseModule module) { - var surfaceAcceleration = module.SurfaceGravity; - var upperSurfaceRadius = module.SurfaceSize; - int falloffExponent = module.GravityFallOff == GravityFallOff.Linear ? 1 : 2; + var surfaceAcceleration = module.surfaceGravity; + var upperSurfaceRadius = module.surfaceSize; + int falloffExponent = module.gravityFallOff == GravityFallOff.Linear ? 1 : 2; Mass = surfaceAcceleration * Mathf.Pow(upperSurfaceRadius, falloffExponent) / GravityVolume.GRAVITATIONAL_CONSTANT; Power = falloffExponent; diff --git a/NewHorizons/Components/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLogStarChartMode.cs index 986d097b..251ce350 100644 --- a/NewHorizons/Components/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLogStarChartMode.cs @@ -67,7 +67,7 @@ namespace NewHorizons.Components // Conditions to allow warping into that system (either no planets (stock system) or has a ship spawn point) var flag = false; if (starSystem.Equals("SolarSystem")) flag = true; - else if (config.Spawn?.ShipSpawnPoint != null) flag = true; + else if (config.Spawn?.shipSpawnPoint != null) flag = true; if (!StarChartHandler.HasUnlockedSystem(starSystem)) continue; diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 1efd8520..af1eac0c 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -1,157 +1,153 @@ -using NewHorizons.External.Modules; +using System; +using System.ComponentModel; +using NewHorizons.External.Modules; using NewHorizons.External.Modules.VariableSize; using Newtonsoft.Json; -using NewHorizons.Utility; -using System.ComponentModel; -using UnityEngine; -using UnityEngine.Internal; namespace NewHorizons.External.Configs { /// - /// A planet or body to generate + /// Describes a body to generate /// - [JsonObject] + [JsonObject(Title = "Celestial Body")] public class PlanetConfig { - /// - /// 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 - /// - [System.ComponentModel.DefaultValue("SolarSystem")] - 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 - /// - [System.ComponentModel.DefaultValue(-1)] - 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 + /// Describes this Body's atmosphere /// - public StarModule Star; - + public AtmosphereModule Atmosphere; + + /// + /// Base Properties of this Body + /// + public BaseModule Base; + + /// + /// Set to a higher number if you wish for this body to be built sooner + /// + [DefaultValue(-1)] public int buildPriority = -1; + + /// + /// Should this planet ever be shown on the title screen? + /// + public bool canShowOnTitle = true; + + #region Obsolete + + [Obsolete("ChildrenToDestroy is deprecated, please use RemoveChildren instead")] + public string[] childrenToDestroy; + + #endregion Obsolete + + /// + /// `true` if you want to delete this planet + /// + public bool destroy; + /// /// 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 + /// + /// Generate the surface of this planet using a heightmap + /// + public HeightMapModule HeightMap; - [System.Obsolete("ChildrenToDestroy is deprecated, please use RemoveChildren instead")] - public string[] ChildrenToDestroy; + /// + /// Does this config describe a quantum state of a custom planet defined in another file? + /// + public bool isQuantumState; - #endregion Obsolete + /// + /// Add lava to this planet + /// + public LavaModule Lava; + + /// + /// Unique name of your planet + /// + public string name; + + /// + /// Describes this Body's orbit (or lack there of) + /// + public OrbitModule Orbit; + + /// + /// Procedural Generation + /// + public ProcGenModule ProcGen; + + /// + /// Spawn various objects on this body + /// + public PropModule Props; + + /// + /// A list of paths to child GameObjects to destroy on this planet + /// + public string[] removeChildren; + + /// + /// Creates a ring around the planet + /// + public RingModule Ring; + + /// + /// Add sand to this planet + /// + public SandModule Sand; + + /// + /// Add ship log entries to this planet and describe how it looks in map mode + /// + public ShipLogModule ShipLog; + + /// + /// 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; + + /// + /// Spawn the player at this planet + /// + public SpawnModule Spawn; + + /// + /// Make this body a star + /// + public StarModule Star; + + /// + /// Unique star system containing your planet + /// + [DefaultValue("SolarSystem")] public string starSystem = "SolarSystem"; + + /// + /// Version of New Horizons this config is using (Doesn't do anything) + /// + public string version; + + /// + /// Add water to this planet + /// + public WaterModule Water; public PlanetConfig() { @@ -164,91 +160,66 @@ namespace NewHorizons.External.Configs public void MigrateAndValidate() { // Validate - if (Base.CenterOfSolarSystem) Orbit.IsStatic = true; - if (Atmosphere?.Clouds?.LightningGradient != null) Atmosphere.Clouds.HasLightning = true; + if (Base.centerOfSolarSystem) Orbit.IsStatic = true; + if (Atmosphere?.clouds?.lightningGradient != null) Atmosphere.clouds.hasLightning = true; // Backwards compatability // Should be the only place that obsolete things are referenced #pragma warning disable 612, 618 - if (Base.WaterSize != 0) - { + if (Base.waterSize != 0) Water = new WaterModule { - Size = Base.WaterSize, - Tint = Base.WaterTint + size = Base.waterSize, + tint = Base.waterTint }; - } - if (Base.LavaSize != 0) - { + if (Base.lavaSize != 0) Lava = new LavaModule { - Size = Base.LavaSize + size = Base.lavaSize }; - } - if (Base.BlackHoleSize != 0) - { + if (Base.blackHoleSize != 0) Singularity = new SingularityModule { - Type = SingularityModule.SingularityType.BlackHole, - Size = Base.BlackHoleSize + type = SingularityModule.SingularityType.BlackHole, + size = Base.blackHoleSize }; - } - if (Base.IsSatellite) - { - Base.ShowMinimap = false; - } + if (Base.isSatellite) Base.showMinimap = false; - if (ChildrenToDestroy != null) - { - RemoveChildren = ChildrenToDestroy; - } + if (childrenToDestroy != null) removeChildren = childrenToDestroy; - if (Base.HasAmbientLight) - { - Base.AmbientLight = 0.5f; - } + if (Base.hasAmbientLight) Base.ambientLight = 0.5f; if (Atmosphere != null) { - if (!string.IsNullOrEmpty(Atmosphere.Cloud)) - { - Atmosphere.Clouds = new AtmosphereModule.CloudInfo() + if (!string.IsNullOrEmpty(Atmosphere.cloud)) + Atmosphere.clouds = new AtmosphereModule.CloudInfo { - OuterCloudRadius = Atmosphere.Size, - InnerCloudRadius = Atmosphere.Size * 0.9f, - Tint = Atmosphere.CloudTint, - TexturePath = Atmosphere.Cloud, - CapPath = Atmosphere.CloudCap, - RampPath = Atmosphere.CloudRamp, - FluidType = Atmosphere.FluidType, - UseBasicCloudShader = Atmosphere.UseBasicCloudShader, - Unlit = !Atmosphere.ShadowsOnClouds, + outerCloudRadius = Atmosphere.size, + innerCloudRadius = Atmosphere.size * 0.9f, + tint = Atmosphere.cloudTint, + texturePath = Atmosphere.cloud, + capPath = Atmosphere.cloudCap, + rampPath = Atmosphere.cloudRamp, + fluidType = Atmosphere.fluidType, + useBasicCloudShader = Atmosphere.useBasicCloudShader, + unlit = !Atmosphere.shadowsOnClouds }; - } // Validate - if (Atmosphere.Clouds?.LightningGradient != null) - { - Atmosphere.Clouds.HasLightning = true; - } + if (Atmosphere.clouds?.lightningGradient != null) Atmosphere.clouds.hasLightning = true; // Former is obsolete, latter is to validate - if (Atmosphere.HasAtmosphere || Atmosphere.AtmosphereTint != null) - { - Atmosphere.UseAtmosphereShader = true; - } + if (Atmosphere.hasAtmosphere || Atmosphere.atmosphereTint != null) + Atmosphere.useAtmosphereShader = true; } - if(Props?.Tornados != null) - { - foreach(var tornado in Props.Tornados) - { - if (tornado.downwards) tornado.type = PropModule.TornadoInfo.TornadoType.Downwards; - } - } + if (Props?.tornados != null) + foreach (var tornado in Props.tornados) + if (tornado.downwards) + tornado.type = PropModule.TornadoInfo.TornadoType.Downwards; } } } \ No newline at end of file diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index ca8359fb..23533a08 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; -using System.ComponentModel; +using System.ComponentModel; +using Newtonsoft.Json; namespace NewHorizons.External.Configs { @@ -9,21 +9,16 @@ namespace NewHorizons.External.Configs [JsonObject] public class StarSystemConfig { - /// - /// Relative path to the image file to use as the subtitle image (replaces the eote banner) - /// - public string subtitle; - /// /// Whether this system can be warped to via the warp drive /// public bool canEnterViaWarpDrive = true; - + /// - /// Set to `true` if you want to spawn here after dying, not Timber Hearth. You can still warp back to the main star system. + /// [DEPRECATED] Not implemented /// - public bool startHere; - + public NomaiCoordinates coords; + /// /// Do you want a clean slate for this star system? Or will it be a modified version of the original. /// @@ -32,29 +27,35 @@ namespace NewHorizons.External.Configs /// /// Should the time loop be enabled in this system? /// - [DefaultValue(true)] - public bool enableTimeLoop = true; - + [DefaultValue(true)] public bool enableTimeLoop = 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. + /// 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 not be able to view the map in this system? /// public bool mapRestricted; - - /// - /// [DEPRECATED] Not implemented - /// - public NomaiCoordinates coords; - + /// /// Customize the skybox for this system /// public SkyboxConfig skybox; + /// + /// 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; + + /// + /// Relative path to the image file to use as the subtitle image (replaces the eote banner) + /// + public string subtitle; + public class NomaiCoordinates { public int[] x; @@ -69,16 +70,16 @@ namespace NewHorizons.External.Configs /// 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; + + /// + /// Path to the material within the asset bundle specified by `assetBundle` to use for the skybox + /// + public string path; } } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Configs/TranslationConfig.cs b/NewHorizons/External/Configs/TranslationConfig.cs index b74de998..945bca42 100644 --- a/NewHorizons/External/Configs/TranslationConfig.cs +++ b/NewHorizons/External/Configs/TranslationConfig.cs @@ -1,30 +1,31 @@ -using Newtonsoft.Json.Linq; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; +using Newtonsoft.Json.Linq; + namespace NewHorizons.External.Configs { public class TranslationConfig { - public Dictionary DialogueDictionary; - public Dictionary ShipLogDictionary; - public Dictionary UIDictionary; + public Dictionary dialogueDictionary; + public Dictionary shipLogDictionary; + public Dictionary uiDictionary; public TranslationConfig(string filename) { - Dictionary dict = JObject.Parse(File.ReadAllText(filename)).ToObject>(); + var dict = JObject.Parse(File.ReadAllText(filename)).ToObject>(); - if (dict.ContainsKey(nameof(DialogueDictionary))) - { - DialogueDictionary = (Dictionary)(dict[nameof(DialogueDictionary)] as Newtonsoft.Json.Linq.JObject).ToObject(typeof(Dictionary)); - } - if (dict.ContainsKey(nameof(ShipLogDictionary))) - { - ShipLogDictionary = (Dictionary)(dict[nameof(ShipLogDictionary)] as Newtonsoft.Json.Linq.JObject).ToObject(typeof(Dictionary)); - } - if (dict.ContainsKey(nameof(UIDictionary))) - { - UIDictionary = (Dictionary)(dict[nameof(UIDictionary)] as Newtonsoft.Json.Linq.JObject).ToObject(typeof(Dictionary)); - } + if (dict.ContainsKey(nameof(dialogueDictionary))) + dialogueDictionary = + (Dictionary) (dict[nameof(dialogueDictionary)] as JObject).ToObject( + typeof(Dictionary)); + if (dict.ContainsKey(nameof(shipLogDictionary))) + shipLogDictionary = + (Dictionary) (dict[nameof(shipLogDictionary)] as JObject).ToObject( + typeof(Dictionary)); + if (dict.ContainsKey(nameof(uiDictionary))) + uiDictionary = + (Dictionary) (dict[nameof(uiDictionary)] as JObject).ToObject( + typeof(Dictionary)); } } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/AsteroidBeltModule.cs b/NewHorizons/External/Modules/AsteroidBeltModule.cs index 1b8fc86a..96bff135 100644 --- a/NewHorizons/External/Modules/AsteroidBeltModule.cs +++ b/NewHorizons/External/Modules/AsteroidBeltModule.cs @@ -1,56 +1,54 @@ -using Newtonsoft.Json; +using System.ComponentModel; +using Newtonsoft.Json; namespace NewHorizons.External.Modules { [JsonObject] public class AsteroidBeltModule { - /// - /// 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. - /// - [System.ComponentModel.DefaultValue(20)] - public float MinSize = 20; - - /// - /// Maximum size of the asteroids. - /// - [System.ComponentModel.DefaultValue(50)] - public float MaxSize = 50f; - /// /// Amount of asteroids to create. /// - [System.ComponentModel.DefaultValue(-1)] - public int Amount = -1; - + [DefaultValue(-1)] public int amount = -1; + /// /// Angle between the rings and the equatorial plane of the planet. /// - public float Inclination; - + public float inclination; + + /// + /// Lowest distance from the planet asteroids can spawn + /// + public float innerRadius; + /// /// Angle defining the point where the rings rise up from the planet's equatorial plane if inclination is nonzero. /// - public float LongitudeOfAscendingNode; - + public float longitudeOfAscendingNode; + /// - /// Number used to randomize asteroid positions + /// Maximum size of the asteroids. /// - public int RandomSeed; - + [DefaultValue(50)] public float maxSize = 50f; + + /// + /// Minimum size of the asteroids. + /// + [DefaultValue(20)] public float minSize = 20; + + /// + /// Greatest distance from the planet asteroids can spawn + /// + public float outerRadius; + /// /// How the asteroids are generated /// - public ProcGenModule ProcGen; + public ProcGenModule procGen; + + /// + /// Number used to randomize asteroid positions + /// + public int randomSeed; } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/AtmosphereModule.cs b/NewHorizons/External/Modules/AtmosphereModule.cs index 6811e144..543776ea 100644 --- a/NewHorizons/External/Modules/AtmosphereModule.cs +++ b/NewHorizons/External/Modules/AtmosphereModule.cs @@ -1,6 +1,7 @@ -using System.Runtime.Serialization; -using NewHorizons.Utility; +using System; using System.ComponentModel; +using System.Runtime.Serialization; +using NewHorizons.Utility; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -8,156 +9,169 @@ 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 + [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 { - /// - /// Scale height of the atmosphere - /// - public float Size; - /// /// Colour of atmospheric shader on the planet. /// - public MColor AtmosphereTint; + public MColor atmosphereTint; /// - /// Colour of fog on the planet, if you put fog. + /// Describes the clouds in the atmosphere /// - public MColor FogTint; + public CloudInfo clouds; /// /// How dense the fog is, if you put fog. /// // FIXME: Min & Max Needed! - public float FogDensity; - + public float fogDensity; + /// /// Radius of fog sphere, independent of the atmosphere. This has to be set for there to be fog. /// - public float FogSize; - + public float fogSize; + /// - /// Does this planet have rain? + /// Colour of fog on the planet, if you put fog. /// - public bool HasRain; - - /// - /// Does this planet have snow? - /// - public bool HasSnow; - + public MColor fogTint; + /// /// 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; + public bool hasOxygen; + /// + /// Does this planet have rain? + /// + public bool hasRain; - #region Obsolete - [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; - [DefaultValue(true)] [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 + /// + /// Does this planet have snow? + /// + public bool hasSnow; + + /// + /// Scale height of the atmosphere + /// + public float size; + + /// + /// Whether we use an atmospheric shader on the planet. Doesn't affect clouds, fog, rain, snow, oxygen, etc. Purely + /// visual. + /// + public bool useAtmosphereShader; public class AirInfo { - public float Scale; - public bool HasOxygen; - public bool IsRaining; - public bool IsSnowing; + public bool hasOxygen; + public bool isRaining; + public bool isSnowing; + public float scale; } [JsonObject] public class CloudInfo { - /// - /// 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; + public string capPath; /// /// 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; - + public CloudFluidType? fluidType = CloudFluidType.Cloud; + /// /// Add lightning to this planet like on Giant's Deep. /// - public bool HasLightning; - + public bool hasLightning; + + /// + /// Radius from the center to the inner layer of the clouds. + /// + public float innerCloudRadius; + /// /// Colour gradient of the lightning, time is in seconds. /// - public MGradient[] LightningGradient; + public MGradient[] lightningGradient; + + /// + /// Radius from the center to the outer layer of the clouds. + /// + public float outerCloudRadius; + + /// + /// 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; + + /// + /// Relative filepath to the cloud texture, if the planet has clouds. + /// + public string texturePath; + + /// + /// Colour of the inner cloud layer. + /// + public MColor tint; + + /// + /// If the top layer shouldn't have shadows. Set to true if you're making a brown dwarf for example. + /// + public bool unlit; + + /// + /// 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; } + + + #region Obsolete + + [Obsolete("CloudTint is deprecated, please use CloudInfo instead")] + public MColor cloudTint; + + [Obsolete("CloudTint is deprecated, please use CloudInfo instead")] + public string cloud; + + [Obsolete("CloudCap is deprecated, please use CloudInfo instead")] + public string cloudCap; + + [Obsolete("CloudRamp is deprecated, please use CloudInfo instead")] + public string cloudRamp; + + [Obsolete("CloudFluidType is deprecated, please use CloudInfo instead")] + [JsonConverter(typeof(StringEnumConverter))] + public CloudFluidType? fluidType; + + [Obsolete("UseBasicCloudShader is deprecated, please use CloudInfo instead")] + public bool useBasicCloudShader; + + [DefaultValue(true)] [Obsolete("ShadowsOnClouds is deprecated, please use CloudInfo instead")] + public bool shadowsOnClouds = true; + + [Obsolete("HasAtmosphere is deprecated, please use UseAtmosphereShader instead")] + public bool hasAtmosphere; + + #endregion Obsolete } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/BaseModule.cs b/NewHorizons/External/Modules/BaseModule.cs index eb956135..df25cbf2 100644 --- a/NewHorizons/External/Modules/BaseModule.cs +++ b/NewHorizons/External/Modules/BaseModule.cs @@ -1,103 +1,117 @@ -using System.Runtime.Serialization; +using System; +using System.ComponentModel; +using System.Runtime.Serialization; using NewHorizons.Utility; using Newtonsoft.Json; -using System.ComponentModel; -using UnityEngine.Internal; +using Newtonsoft.Json.Converters; namespace NewHorizons.External.Modules { public enum GravityFallOff { - [EnumMember(Value = @"linear")] - Linear = 0, - + [EnumMember(Value = @"linear")] Linear = 0, + [EnumMember(Value = @"inverseSquared")] InverseSquared = 1 } - + [JsonObject] public class BaseModule { - /// - /// 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; - + public float ambientLight; + /// - /// The acceleration due to gravity felt as the surfaceSize. Timber Hearth has 12 for reference + /// 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 float SurfaceGravity; - + public bool centerOfSolarSystem; + /// - /// How gravity falls off with distance. Most planets use linear but the sun and some moons use inverseSquared. + /// 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. /// - [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; - + public float cloakRadius; + /// /// If it has a comet tail, it'll be oriented according to these Euler angles. /// - public MVector3 CometTailRotation; - + public MVector3 cometTailRotation; + + /// + /// How gravity falls off with distance. Most planets use linear but the sun and some moons use inverseSquared. + /// + [JsonConverter(typeof(StringEnumConverter))] + public GravityFallOff gravityFallOff = GravityFallOff.Linear; + + /// + /// 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 the body should have a marker on the map screen. + /// + public bool hasMapMarker; + /// /// Allows the object to be targeted on the map. /// - [System.ComponentModel.DefaultValue(true)] - 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; - + [DefaultValue(true)] public bool hasReferenceFrame = true; + /// /// Can this planet survive entering a star? /// - public bool InvulnerableToSun; - + public bool invulnerableToSun; + /// /// Do we show the minimap when walking around this planet? /// - [System.ComponentModel.DefaultValue(true)] - public bool ShowMinimap = true; + [DefaultValue(true)] public bool showMinimap = true; + + /// + /// An override for the radius of the planet's gravitational sphere of influence. Optional + /// + public float sphereOfInfluence; + + /// + /// The acceleration due to gravity felt as the surfaceSize. Timber Hearth has 12 for reference + /// + public float surfaceGravity; + + /// + /// A scale height used for a number of things. Should be the approximate radius of the body. + /// + public float surfaceSize; #region Obsolete - [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; + + [Obsolete("IsSatellite is deprecated, please use ShowMinimap instead")] + public bool isSatellite; + + [Obsolete("BlackHoleSize is deprecated, please use SingularityModule instead")] + public float blackHoleSize; + + [Obsolete("LavaSize is deprecated, please use LavaModule instead")] + public float lavaSize; + + [Obsolete("WaterTint is deprecated, please use WaterModule instead")] + public float waterSize; + + [Obsolete("WaterTint is deprecated, please use WaterModule instead")] + public MColor waterTint; + + [Obsolete("HasAmbientLight is deprecated, please use AmbientLight instead")] + public bool hasAmbientLight; + #endregion Obsolete } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/FocalPointModule.cs b/NewHorizons/External/Modules/FocalPointModule.cs index 0ce3105b..05f5488d 100644 --- a/NewHorizons/External/Modules/FocalPointModule.cs +++ b/NewHorizons/External/Modules/FocalPointModule.cs @@ -8,11 +8,11 @@ namespace NewHorizons.External.Modules /// /// Name of the primary planet in this binary system /// - public string Primary; - + public string primary; + /// /// Name of the secondary planet in this binary system /// - public string Secondary; + public string secondary; } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/HeightMapModule.cs b/NewHorizons/External/Modules/HeightMapModule.cs index 1cb6b253..bb407959 100644 --- a/NewHorizons/External/Modules/HeightMapModule.cs +++ b/NewHorizons/External/Modules/HeightMapModule.cs @@ -1,4 +1,5 @@ using NewHorizons.Utility; + namespace NewHorizons.External.Modules { public class HeightMapModule @@ -6,26 +7,26 @@ namespace NewHorizons.External.Modules /// /// 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; - + public string heightMap; + /// /// The highest points on your planet will be at this height. /// - public float MaxHeight; - + public float maxHeight; + + /// + /// The lowest points on your planet will be at this height. + /// + public float minHeight; + /// /// The scale of the terrain. /// - public MVector3 Stretch; + public MVector3 stretch; + + /// + /// Relative filepath to the texture used for the terrain. + /// + public string textureMap; } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/OrbitModule.cs b/NewHorizons/External/Modules/OrbitModule.cs index 4a70e4ab..7b255e98 100644 --- a/NewHorizons/External/Modules/OrbitModule.cs +++ b/NewHorizons/External/Modules/OrbitModule.cs @@ -1,36 +1,81 @@ -using NewHorizons.Components.Orbital; +using System.ComponentModel; +using NewHorizons.Components.Orbital; using NewHorizons.Utility; -using Newtonsoft.Json; -using UnityEngine; -using System.ComponentModel; -using UnityEngine.Internal; 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. + /// 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. + /// + [DefaultValue(true)] + 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; } + + /// + /// 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; } + + /// + /// 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; } @@ -39,66 +84,22 @@ namespace NewHorizons.External.Modules /// // 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. + /// 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. - /// - [System.ComponentModel.DefaultValue(true)] - 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; } public OrbitalParameters GetOrbitalParameters(Gravity primaryGravity, Gravity secondaryGravity) { - return OrbitalParameters.FromTrueAnomaly(primaryGravity, secondaryGravity, Eccentricity, SemiMajorAxis, Inclination, ArgumentOfPeriapsis, LongitudeOfAscendingNode, TrueAnomaly); + return OrbitalParameters.FromTrueAnomaly(primaryGravity, secondaryGravity, Eccentricity, SemiMajorAxis, + Inclination, ArgumentOfPeriapsis, LongitudeOfAscendingNode, TrueAnomaly); } } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/ProcGenModule.cs b/NewHorizons/External/Modules/ProcGenModule.cs index 84c79902..06018b65 100644 --- a/NewHorizons/External/Modules/ProcGenModule.cs +++ b/NewHorizons/External/Modules/ProcGenModule.cs @@ -6,7 +6,7 @@ namespace NewHorizons.External.Modules [JsonObject] public class ProcGenModule { - public float Scale; - public MColor Color; + public MColor color; + public float scale; } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index eb22ec56..dfb84e05 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -1,166 +1,166 @@ -using System.Runtime.Serialization; +using System.ComponentModel; +using System.Runtime.Serialization; using NewHorizons.Utility; -using System.ComponentModel; using Newtonsoft.Json; using Newtonsoft.Json.Converters; namespace NewHorizons.External.Modules { [JsonObject] - public class PropModule + 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; - + public DetailInfo[] details; + /// /// Add dialogue triggers to this planet /// - public DialogueInfo[] Dialogue; - - /// - /// Add triggers that reveal parts of the ship log on this planet - /// - public RevealInfo[] Reveal; - + public DialogueInfo[] dialogue; + /// /// Add ship log entry locations on this planet /// - public EntryLocationInfo[] EntryLocation; - + public EntryLocationInfo[] entryLocation; + + /// + /// Add Geysers to this planet + /// + public GeyserInfo[] geysers; + /// /// Add translatable text to this planet /// - public NomaiTextInfo[] NomaiText; - - /// - /// Add slideshows (from the DLC) to the planet - /// - public ProjectionInfo[] SlideShows; - + public NomaiTextInfo[] nomaiText; + /// /// Details which will be shown from 50km away. Meant to be lower resolution. /// - public DetailInfo[] ProxyDetails; + public DetailInfo[] proxyDetails; + + /// + /// Add rafts to this planet + /// + public RaftInfo[] rafts; + + /// + /// Add triggers that reveal parts of the ship log on this planet + /// + public RevealInfo[] reveal; + + /// + /// Scatter props around this planet's surface + /// + public ScatterInfo[] scatter; + + /// + /// Add slideshows (from the DLC) to the planet + /// + public ProjectionInfo[] slideShows; + + /// + /// Add tornadoes to this planet + /// + public TornadoInfo[] tornados; + + /// + /// Add volcanoes to this planet + /// + public VolcanoInfo[] volcanoes; [JsonObject] public class ScatterInfo { /// - /// The number used as entropy for scattering the props + /// Relative filepath to an asset-bundle" /// - public int seed; - + public string assetBundle; + /// /// 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; - + + /// + /// 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; + /// /// Rotate this prop once it is placed /// public MVector3 rotation; - + /// /// Scale this prop once it is placed /// public float scale = 1f; + + /// + /// The number used as entropy for scattering the props + /// + public int seed; } [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 + /// Do we override rotation and try to automatically align this object to stand upright on the body's surface? /// - public string path; - - /// - /// [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; - + public bool alignToNormal; + /// /// Relative filepath to an asset-bundle to load the prefab defined in `path` from/ /// public string assetBundle; - + + /// + /// [DEPRECATED] Path to the .mtl file to load a 3d model from + /// + public string mtlFilePath; + + /// + /// [DEPRECATED] Path to the .obj file to load a 3d model from + /// + public string objFilePath; + + /// + /// 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; + /// /// Position of this prop relative to the body's center /// public MVector3 position; - - /// - /// Rotate this prop - /// - public MVector3 rotation; - - /// - /// Scale the prop - /// - [DefaultValue(1f)] - 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. + /// Do we reset all the components on this object? Useful for certain props that have dialogue components attached to + /// them. /// public bool removeComponents; + + /// + /// Rotate this prop + /// + public MVector3 rotation; + + /// + /// Scale the prop + /// + [DefaultValue(1f)] public float scale = 1f; } [JsonObject] @@ -186,32 +186,33 @@ namespace NewHorizons.External.Modules { public enum TornadoType { - [EnumMember(Value = @"downwards")] - Downwards = 0, - - [EnumMember(Value = @"upwards")] - Upwards = 1, - - [EnumMember(Value = @"hurricane")] - Hurricane = 2 + [EnumMember(Value = @"downwards")] Downwards = 0, + + [EnumMember(Value = @"upwards")] Upwards = 1, + + [EnumMember(Value = @"hurricane")] Hurricane = 2 } - + /// - /// Position of the tornado + /// [DEPRECATED] Should this tornado shoot you down instead of up? /// - public MVector3 position; - + public bool downwards; + /// /// Alternative to setting the position. Will choose a random place at this elevation. /// public float elevation; - + /// /// The height of this tornado. /// - [DefaultValue(30f)] - public float height = 30f; - + [DefaultValue(30f)] public float height = 30f; + + /// + /// Position of the tornado + /// + public MVector3 position; + /// /// The colour of the tornado. /// @@ -223,115 +224,113 @@ namespace NewHorizons.External.Modules [JsonConverter(typeof(StringEnumConverter))] public TornadoType type = TornadoType.Downwards; - /// - /// [DEPRECATED] Should this tornado shoot you down instead of up? - /// - 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; - /// /// Angular distance from the starting position that it will wander, in terms of the angle around the x-axis. /// - [DefaultValue(45f)] - public float wanderDegreesX = 45f; - + [DefaultValue(45f)] public float wanderDegreesX = 45f; + /// /// Angular distance from the starting position that it will wander, in terms of the angle around the z-axis. /// - [DefaultValue(45f)] - public float wanderDegreesZ = 45f; + [DefaultValue(45f)] public float wanderDegreesZ = 45f; + + /// + /// 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; } [JsonObject] public class VolcanoInfo { - /// - /// Position of this volcano - /// - public MVector3 position; - - /// - /// Scale of this volcano - /// - public float scale = 1; - - /// - /// 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; + + /// + /// Maximum random speed at which meteors are launched. + /// + public float maxLaunchSpeed = 150f; + + /// + /// Minimum time between meteor launches. + /// + public float minInterval = 5f; + + /// + /// Minimum random speed at which meteors are launched. + /// + public float minLaunchSpeed = 50f; + + /// + /// Position of this volcano + /// + public MVector3 position; + + /// + /// Scale of this volcano + /// + public float scale = 1; + + /// + /// The colour of the meteor's stone. + /// + public MColor stoneTint; } [JsonObject] public class DialogueInfo { + /// + /// 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 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; + + /// + /// 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; + /// /// 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. + /// 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. + /// The radius of the remote trigger volume. /// - public string blockAfterPersistentCondition; - + public float remoteTriggerRadius; + /// - /// If this dialogue is meant for a character, this is the relative path from the planet to that character's CharacterAnimController or SolanumAnimController. + /// Relative path to the xml file defining the dialogue. /// - 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; + public string xmlFile; } [JsonObject] @@ -339,61 +338,58 @@ namespace NewHorizons.External.Modules { public enum RevealVolumeType { - [EnumMember(Value = @"enter")] - Enter = 0, - - [EnumMember(Value = @"observe")] - Observe = 1, - - [EnumMember(Value = @"snapshot")] - Snapshot = 2 + [EnumMember(Value = @"enter")] Enter = 0, + + [EnumMember(Value = @"observe")] Observe = 1, + + [EnumMember(Value = @"snapshot")] Snapshot = 2 } - + + /// + /// 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 + + /// + /// 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 position to place this volume at + /// + public MVector3 position; + + /// + /// The radius of this reveal volume + /// + public float radius = 1f; + /// /// 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; - + + /// + /// ID of the entry this location relates to + /// + public string id; + /// /// The position of this entry location /// @@ -405,57 +401,53 @@ namespace NewHorizons.External.Modules { 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 + [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 + /// Additional information about each arc in the text /// - public MVector3 position; - + public NomaiTextArcInfo[] arcInfo; + /// /// 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. + /// Position of the root of this text + /// + public MVector3 position; + + /// + /// 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; - + + /// + /// The random seed used to pick what the text arcs will look like. + /// + public int seed; // For randomizing arcs + /// /// 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] @@ -463,30 +455,27 @@ namespace NewHorizons.External.Modules { public enum NomaiTextArcType { - [EnumMember(Value = @"adult")] - Adult = 0, - - [EnumMember(Value = @"child")] - Child = 1, - - [EnumMember(Value = @"stranger")] - Stranger = 2 + [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; - + /// /// The type of text to display. /// public NomaiTextArcType type = NomaiTextArcType.Adult; + + /// + /// The z euler angle for this arc. + /// + public float zRotation; } [JsonObject] @@ -494,118 +483,116 @@ namespace NewHorizons.External.Modules { public enum SlideShowType { - [EnumMember(Value = @"slideReel")] - SlideReel = 0, - - [EnumMember(Value = @"autoProjector")] - AutoProjector = 1 + [EnumMember(Value = @"slideReel")] SlideReel = 0, + + [EnumMember(Value = @"autoProjector")] AutoProjector = 1 } - + /// /// The position of this slideshow. /// public MVector3 position; - + + /// + /// The ship log entries revealed after finishing this slide reel. + /// + public string[] reveals; + /// /// The rotation of this slideshow. /// public MVector3 rotation; - + + /// + /// The list of slides for this object. + /// + public SlideInfo[] slides; + /// /// 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; } [JsonObject] public class SlideInfo { /// - /// The path to the image file for this slide. + /// Ambient light colour when viewing this slide. /// - public string imagePath; + public MColor ambientLightColor; + + + // SlideAmbientLightModule - // SlideBeatAudioModule - /// - /// The name of the AudioClip for a one-shot sound when opening the slide. + /// Ambient light intensity when viewing this slide. /// - public string beatAudio; - + public float ambientLightIntensity; + /// - /// The time delay until the one-shot audio + /// Ambient light range when viewing this slide. /// - public float beatDelay; + public float ambientLightRange; // 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; - + // SlideBeatAudioModule - // SlidePlayTimeModule - /// - /// Play-time duration for auto-projector slides. + /// The name of the AudioClip for a one-shot sound when opening the slide. /// - public float playTimeDuration; + public string beatAudio; + + /// + /// The time delay until the one-shot audio + /// + public float beatDelay; + - // SlideBlackFrameModule - + /// /// Before viewing this slide, there will be a black frame for this many seconds. /// public float blackFrameDuration; - + /// + /// The path to the image file for this slide. + /// + public string imagePath; + + + // SlidePlayTimeModule + + /// + /// Play-time duration for auto-projector slides. + /// + public float playTimeDuration; + + // SlideShipLogEntryModule - + /// /// Ship log entry revealed when viewing this slide /// public string reveal; + + /// + /// Spotlight intensity modifier when viewing this slide. + /// + public float spotIntensityMod; } } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/ShipLogModule.cs b/NewHorizons/External/Modules/ShipLogModule.cs index 232dd276..305ba7ca 100644 --- a/NewHorizons/External/Modules/ShipLogModule.cs +++ b/NewHorizons/External/Modules/ShipLogModule.cs @@ -1,120 +1,119 @@ -using NewHorizons.Utility; +using System.ComponentModel; +using NewHorizons.Utility; using Newtonsoft.Json; -using System.ComponentModel; namespace NewHorizons.External.Modules { [JsonObject] - public class ShipLogModule + 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; + /// + /// 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(); + + /// + /// A path to the folder where entry sprites are stored. + /// + public string spriteFolder; + + /// + /// The relative path to the xml file to load ship log entries from. + /// + public string xmlFile; + [JsonObject] public class MapModeInfo { /// - /// The path to the sprite to show when the planet is revealed in map mode. + /// Place non-selectable objects in map mode (like sand funnels). /// - 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. - /// - [DefaultValue(1f)] - public float scale = 1f; - + public ShipLogDetailInfo[] details; + /// /// Hide the planet completely if unexplored instead of showing an outline. /// public bool invisibleWhenHidden; - - /// - /// 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; - + + /// + /// Manually place this planet at the specified position. + /// + public MVector2 manualPosition; + + /// + /// Extra distance to apply to this object in map mode. + /// + public float offset; + + /// + /// The path to the sprite to show when the planet is unexplored in map mode. + /// + public string outlineSprite; + /// /// Completely remove this planet (and it's children) from map mode. /// public bool remove; - + /// - /// Place non-selectable objects in map mode (like sand funnels). + /// The path to the sprite to show when the planet is revealed in map mode. /// - public ShipLogDetailInfo[] details; + public string revealedSprite; + + /// + /// Scale to apply to the planet in map mode. + /// + [DefaultValue(1f)] public float scale = 1f; } [JsonObject] public class ShipLogDetailInfo { /// - /// The sprite to show when the parent AstroBody is revealed. + /// Whether to completely hide this detail when the parent AstroBody is unexplored. /// - public string revealedSprite; - + public bool invisibleWhenHidden; + /// /// The sprite to show when the parent AstroBody is rumored/unexplored. /// public string outlineSprite; - - /// - /// 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 sprite to show when the parent AstroBody is revealed. + /// + public string revealedSprite; + + /// + /// The angle in degrees to rotate the detail. + /// + public float rotation; + /// /// The amount to scale the x and y-axis of the detail by. /// @@ -124,20 +123,20 @@ namespace NewHorizons.External.Modules [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; + + /// + /// The ID of the curiosity to apply the color to. + /// + public string id; } [JsonObject] @@ -147,7 +146,7 @@ namespace NewHorizons.External.Modules /// The name of the entry to apply the position to. /// public string id; - + /// /// Position of the entry /// diff --git a/NewHorizons/External/Modules/SignalModule.cs b/NewHorizons/External/Modules/SignalModule.cs index 74fce0ce..45da2369 100644 --- a/NewHorizons/External/Modules/SignalModule.cs +++ b/NewHorizons/External/Modules/SignalModule.cs @@ -1,78 +1,76 @@ -using NewHorizons.Utility; +using System.ComponentModel; +using NewHorizons.Utility; using Newtonsoft.Json; -using System.ComponentModel; namespace NewHorizons.External.Modules { [JsonObject] - public class SignalModule + public class SignalModule { /// /// List of signals to add (Why did xen do it like this) /// - public SignalInfo[] Signals; + 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; - /// /// Name of an existing AudioClip in the game that will player over the signal. /// - public string AudioClip; - + public string audioClip; + /// /// Relative filepath to the .wav file to use as the audio. Mutually exclusive with audioClip. /// - public string AudioFilePath; - + public string audioFilePath; + /// - /// A ship log fact to reveal when the signal is identified. + /// How close the player must get to the signal to detect it. This is when you get the "Unknown Signal Detected" + /// notification. /// - [DefaultValue("")] - public string Reveals = ""; - + public float detectionRadius; + /// - /// Radius of the sphere giving off the signal. + /// 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. /// - [DefaultValue(1f)] - public float SourceRadius = 1f; - - /// - /// 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; - + public string frequency; + /// /// How close the player must get to the signal to identify it. This is when you learn its name. /// - [DefaultValue(10f)] - public float IdentificationRadius = 10f; - - /// - /// `false` if the player can hear the signal without equipping the signal-scope. - /// - [DefaultValue(true)] - public bool OnlyAudibleToScope = true; - + [DefaultValue(10f)] public float identificationRadius = 10f; + /// /// Only set to `true` if you are putting this signal inside a cloaking field. /// - public bool InsideCloak; + public bool insideCloak; + + /// + /// The unique ID of the signal. + /// + public string name; + + /// + /// `false` if the player can hear the signal without equipping the signal-scope. + /// + [DefaultValue(true)] public bool onlyAudibleToScope = true; + + /// + /// Position of the signal's source + /// + public MVector3 position; + + /// + /// A ship log fact to reveal when the signal is identified. + /// + [DefaultValue("")] public string reveals = ""; + + /// + /// Radius of the sphere giving off the signal. + /// + [DefaultValue(1f)] public float sourceRadius = 1f; } } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/SpawnModule.cs b/NewHorizons/External/Modules/SpawnModule.cs index 1161582a..be6c2bfd 100644 --- a/NewHorizons/External/Modules/SpawnModule.cs +++ b/NewHorizons/External/Modules/SpawnModule.cs @@ -7,28 +7,29 @@ namespace NewHorizons.External.Modules public class SpawnModule { /// - /// 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. + /// 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; - + public MVector3 playerSpawnPoint; + /// /// Euler angles by which the player will be oriented. /// - public MVector3 PlayerSpawnRotation; - + public MVector3 playerSpawnRotation; + /// /// Required for the system to be accessible by warp drive. /// - public MVector3 ShipSpawnPoint; - + public MVector3 shipSpawnPoint; + /// /// Euler angles by which the ship will be oriented. /// - public MVector3 ShipSpawnRotation; - + public MVector3 shipSpawnRotation; + /// /// If you spawn on a planet with no oxygen, you probably want to set this to true ;;) /// - public bool StartWithSuit; + public bool startWithSuit; } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/VariableSize/FunnelModule.cs b/NewHorizons/External/Modules/VariableSize/FunnelModule.cs index 7d268d07..b756d77a 100644 --- a/NewHorizons/External/Modules/VariableSize/FunnelModule.cs +++ b/NewHorizons/External/Modules/VariableSize/FunnelModule.cs @@ -7,37 +7,32 @@ 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 + [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 { - /// /// The planet the funnel will flow to /// - public string Target; - + public string target; + + /// + /// Tint of the funnel + /// + public MColor tint; + /// /// Type of fluid the funnel transfers /// [JsonConverter(typeof(StringEnumConverter))] - public FunnelType Type = FunnelType.Sand; - - /// - /// Tint of the funnel - /// - public MColor Tint; + public FunnelType type = FunnelType.Sand; } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/VariableSize/LavaModule.cs b/NewHorizons/External/Modules/VariableSize/LavaModule.cs index 2ddfda62..f43de819 100644 --- a/NewHorizons/External/Modules/VariableSize/LavaModule.cs +++ b/NewHorizons/External/Modules/VariableSize/LavaModule.cs @@ -9,11 +9,11 @@ namespace NewHorizons.External.Modules.VariableSize /// /// Size of the lava sphere /// - public float Size; + public float size; /// /// Tint of the lava /// - public MColor Tint; + public MColor tint; } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/VariableSize/RingModule.cs b/NewHorizons/External/Modules/VariableSize/RingModule.cs index 88ffdb4e..8eac1ed4 100644 --- a/NewHorizons/External/Modules/VariableSize/RingModule.cs +++ b/NewHorizons/External/Modules/VariableSize/RingModule.cs @@ -6,43 +6,43 @@ namespace NewHorizons.External.Modules.VariableSize public class RingModule : VariableSizeModule { /// - /// Inner radius of the disk + /// Fluid type for sounds/effects when colliding with this ring. /// - public float InnerRadius; - - /// - /// Outer radius of the disk - /// - public float OuterRadius; - + public CloudFluidType? fluidType = CloudFluidType.None; + /// /// Angle between the rings and the equatorial plane of the planet. /// - public float Inclination; - + public float inclination; + + /// + /// Inner radius of the disk + /// + public float innerRadius; + /// /// Angle defining the point where the rings rise up from the planet's equatorial plane if inclination is nonzero. /// - public float LongitudeOfAscendingNode; - + public float longitudeOfAscendingNode; + /// - /// Relative filepath to the texture used for the rings. + /// Outer radius of the disk /// - public string Texture; - - /// - /// Should this ring be unlit? - /// - public bool Unlit; - + public float outerRadius; + /// /// Allows the rings to rotate. /// - public float RotationSpeed; + public float rotationSpeed; /// - /// Fluid type for sounds/effects when colliding with this ring. + /// Relative filepath to the texture used for the rings. /// - public CloudFluidType? FluidType = CloudFluidType.None; + public string texture; + + /// + /// Should this ring be unlit? + /// + public bool unlit; } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/VariableSize/SandModule.cs b/NewHorizons/External/Modules/VariableSize/SandModule.cs index b53937fa..d163e102 100644 --- a/NewHorizons/External/Modules/VariableSize/SandModule.cs +++ b/NewHorizons/External/Modules/VariableSize/SandModule.cs @@ -1,4 +1,5 @@ using NewHorizons.Utility; + namespace NewHorizons.External.Modules.VariableSize { public class SandModule : VariableSizeModule @@ -7,10 +8,10 @@ namespace NewHorizons.External.Modules.VariableSize /// Size of the sand /// public float Size { get; set; } - + /// /// Tint of the sand /// public MColor Tint { get; set; } } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs index 11c8c1df..fb4719f5 100644 --- a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs +++ b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs @@ -1,8 +1,8 @@ -using System.Runtime.Serialization; +using System.ComponentModel; +using System.Runtime.Serialization; using NewHorizons.Utility; using Newtonsoft.Json; using Newtonsoft.Json.Converters; -using System.ComponentModel; namespace NewHorizons.External.Modules.VariableSize { @@ -11,43 +11,42 @@ namespace NewHorizons.External.Modules.VariableSize { public enum SingularityType { - [EnumMember(Value = @"BlackHole")] - BlackHole = 0, - - [EnumMember(Value = @"WhiteHole")] - WhiteHole = 1 + [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. + /// Only for White Holes. Should this white hole repel the player from it. /// - public float Size; - + [DefaultValue(true)] public bool makeZeroGVolume = true; + /// - /// 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 + /// 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; - + public string pairedSingularity; + + /// + /// Position of the singularity + /// + public MVector3 position; + + /// + /// 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; + /// /// If you want a black hole to load a new star system scene, put its name here. /// - public string TargetStarSystem; - + public string targetStarSystem; + /// /// 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. - /// - [DefaultValue(true)] - public bool MakeZeroGVolume = true; + public SingularityType type; } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/VariableSize/StarModule.cs b/NewHorizons/External/Modules/VariableSize/StarModule.cs index b2d03662..0d1a9342 100644 --- a/NewHorizons/External/Modules/VariableSize/StarModule.cs +++ b/NewHorizons/External/Modules/VariableSize/StarModule.cs @@ -1,55 +1,51 @@ -using NewHorizons.Utility; +using System.ComponentModel; +using NewHorizons.Utility; using Newtonsoft.Json; -using System.ComponentModel; -using UnityEngine.Internal; namespace NewHorizons.External.Modules.VariableSize { [JsonObject] public class StarModule : VariableSizeModule { - /// - /// Radius of the star. - /// - [System.ComponentModel.DefaultValue(2000f)] - 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. - /// - [System.ComponentModel.DefaultValue(1f)] - 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`. - /// - [System.ComponentModel.DefaultValue(true)] - public bool HasAtmosphere = true; - + public MColor endTint; + /// /// Should this star explode after 22 minutes? /// - [System.ComponentModel.DefaultValue(true)] - public bool GoSupernova = true; + [DefaultValue(true)] public bool goSupernova = true; + + /// + /// The default sun has its own atmosphere that is different from regular planets. If you want that, set this to + /// `true`. + /// + [DefaultValue(true)] public bool hasAtmosphere = true; + + /// + /// Colour of the light given off. + /// + public MColor lightTint; + + /// + /// Radius of the star. + /// + [DefaultValue(2000f)] public float size = 2000f; + + /// + /// Relative strength of the light compared to the sun. + /// + [DefaultValue(1f)] public float solarLuminosity = 1f; + + /// + /// The tint of the supernova this star creates when it dies. + /// + public MColor supernovaTint; + + /// + /// Colour of the star. + /// + public MColor tint; } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs b/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs index 57f1f16e..63ab3664 100644 --- a/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs +++ b/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs @@ -1,32 +1,29 @@ using Newtonsoft.Json; using UnityEngine; + namespace NewHorizons.External.Modules.VariableSize { [JsonObject] - public class VariableSizeModule + public class VariableSizeModule { /// /// Scale this module over time /// public TimeValuePair[] Curve { get; set; } + public AnimationCurve GetAnimationCurve(float size = 1f) + { + var curve = new AnimationCurve(); + if (Curve != null) + foreach (var pair in Curve) + curve.AddKey(new Keyframe(pair.Time, size * pair.Value)); + return curve; + } + public class TimeValuePair { public float Time { get; set; } public float Value { get; set; } } - - public AnimationCurve GetAnimationCurve(float size = 1f) - { - var curve = new AnimationCurve(); - if(Curve != null) - { - foreach (var pair in this.Curve) - { - curve.AddKey(new Keyframe(pair.Time, size * pair.Value)); - } - } - return curve; - } } -} +} \ No newline at end of file diff --git a/NewHorizons/External/Modules/VariableSize/WaterModule.cs b/NewHorizons/External/Modules/VariableSize/WaterModule.cs index 721b1ef8..82b7446b 100644 --- a/NewHorizons/External/Modules/VariableSize/WaterModule.cs +++ b/NewHorizons/External/Modules/VariableSize/WaterModule.cs @@ -9,11 +9,11 @@ namespace NewHorizons.External.Modules.VariableSize /// /// Size of the water sphere /// - public float Size; + public float size; /// /// Tint of the water /// - public MColor Tint; + public MColor tint; } -} +} \ No newline at end of file diff --git a/NewHorizons/External/NewHorizonsData.cs b/NewHorizons/External/NewHorizonsData.cs index 3e8fc289..2a1a3e63 100644 --- a/NewHorizons/External/NewHorizonsData.cs +++ b/NewHorizons/External/NewHorizonsData.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using Logger = NewHorizons.Utility.Logger; +using NewHorizons.Utility; namespace NewHorizons.External { @@ -9,20 +9,22 @@ namespace NewHorizons.External private static NewHorizonsSaveFile _saveFile; private static NewHorizonsProfile _activeProfile; private static string _activeProfileName; - private static string _fileName = "save.json"; + private static readonly string FileName = "save.json"; public static void Load() { _activeProfileName = StandaloneProfileManager.SharedInstance?.currentProfile?.profileName; if (_activeProfileName == null) { - Logger.LogError($"Couldn't find active profile, are you on Gamepass?"); + Logger.LogError("Couldn't find active profile, are you on Gamepass?"); _activeProfileName = "XboxGamepassDefaultProfile"; } + try { - _saveFile = Main.Instance.ModHelper.Storage.Load(_fileName); - if (!_saveFile.Profiles.ContainsKey(_activeProfileName)) _saveFile.Profiles.Add(_activeProfileName, new NewHorizonsProfile()); + _saveFile = Main.Instance.ModHelper.Storage.Load(FileName); + if (!_saveFile.Profiles.ContainsKey(_activeProfileName)) + _saveFile.Profiles.Add(_activeProfileName, new NewHorizonsProfile()); _activeProfile = _saveFile.Profiles[_activeProfileName]; Logger.Log($"Loaded save data for {_activeProfileName}"); } @@ -30,11 +32,11 @@ namespace NewHorizons.External { try { - Logger.Log($"Couldn't load save data from {_fileName}, creating a new file"); + Logger.Log($"Couldn't load save data from {FileName}, creating a new file"); _saveFile = new NewHorizonsSaveFile(); _saveFile.Profiles.Add(_activeProfileName, new NewHorizonsProfile()); _activeProfile = _saveFile.Profiles[_activeProfileName]; - Main.Instance.ModHelper.Storage.Save(_saveFile, _fileName); + Main.Instance.ModHelper.Storage.Save(_saveFile, FileName); Logger.Log($"Loaded save data for {_activeProfileName}"); } catch (Exception e) @@ -47,15 +49,12 @@ namespace NewHorizons.External public static void Save() { if (_saveFile == null) return; - Main.Instance.ModHelper.Storage.Save(_saveFile, _fileName); + Main.Instance.ModHelper.Storage.Save(_saveFile, FileName); } public static void Reset() { - if (_saveFile == null || _activeProfile == null) - { - Load(); - } + if (_saveFile == null || _activeProfile == null) Load(); Logger.Log($"Resetting save data for {_activeProfileName}"); _activeProfile = new NewHorizonsProfile(); _saveFile.Profiles[_activeProfileName] = _activeProfile; @@ -63,6 +62,31 @@ namespace NewHorizons.External Save(); } + private class NewHorizonsSaveFile + { + public NewHorizonsSaveFile() + { + Profiles = new Dictionary(); + } + + public Dictionary Profiles { get; } + } + + private class NewHorizonsProfile + { + public NewHorizonsProfile() + { + KnownFrequencies = new List(); + KnownSignals = new List(); + NewlyRevealedFactIDs = new List(); + } + + public List KnownFrequencies { get; } + public List KnownSignals { get; } + + public List NewlyRevealedFactIDs { get; } + } + #region Frequencies public static bool KnowsFrequency(string frequency) @@ -83,7 +107,7 @@ namespace NewHorizons.External public static bool KnowsMultipleFrequencies() { - return (_activeProfile != null && _activeProfile.KnownFrequencies.Count > 0); + return _activeProfile != null && _activeProfile.KnownFrequencies.Count > 0; } #endregion @@ -128,30 +152,5 @@ namespace NewHorizons.External } #endregion - - private class NewHorizonsSaveFile - { - public NewHorizonsSaveFile() - { - Profiles = new Dictionary(); - } - - public Dictionary Profiles { get; set; } - } - - private class NewHorizonsProfile - { - public NewHorizonsProfile() - { - KnownFrequencies = new List(); - KnownSignals = new List(); - NewlyRevealedFactIDs = new List(); - } - - public List KnownFrequencies { get; set; } - public List KnownSignals { get; set; } - - public List NewlyRevealedFactIDs { get; set; } - } } -} +} \ No newline at end of file diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 9132cfa8..ff132224 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -132,25 +132,25 @@ namespace NewHorizons.Handlers GameObject existingPlanet = null; try { - existingPlanet = AstroObjectLocator.GetAstroObject(body.Config.Name).gameObject; + existingPlanet = AstroObjectLocator.GetAstroObject(body.Config.name).gameObject; } catch (Exception) { - if (body?.Config?.Name == null) Logger.LogError($"How is there no name for {body}"); - else existingPlanet = GameObject.Find(body.Config.Name.Replace(" ", "") + "_Body"); + if (body?.Config?.name == null) Logger.LogError($"How is there no name for {body}"); + else existingPlanet = GameObject.Find(body.Config.name.Replace(" ", "") + "_Body"); } if (existingPlanet != null) { try { - if (body.Config.Destroy) + if (body.Config.destroy) { var ao = existingPlanet.GetComponent(); if (ao != null) Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => PlanetDestructionHandler.RemoveBody(ao), 2); else Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => existingPlanet.SetActive(false), 2); } - else if (body.Config.IsQuantumState) + else if (body.Config.isQuantumState) { try { @@ -193,7 +193,7 @@ namespace NewHorizons.Handlers } catch (Exception ex) { - Logger.LogError($"Couldn't make quantum state for [{body.Config.Name}] : {ex.Message}, {ex.StackTrace}"); + Logger.LogError($"Couldn't make quantum state for [{body.Config.name}] : {ex.Message}, {ex.StackTrace}"); return false; } } @@ -204,13 +204,13 @@ namespace NewHorizons.Handlers } catch (Exception e) { - Logger.LogError($"Couldn't update body {body.Config?.Name}: {e.Message}, {e.StackTrace}"); + Logger.LogError($"Couldn't update body {body.Config?.name}: {e.Message}, {e.StackTrace}"); return false; } } else { - if (body.Config.IsQuantumState) + if (body.Config.isQuantumState) { // If the ground state object isn't made yet do it later NextPassBodies.Add(body); @@ -226,7 +226,7 @@ namespace NewHorizons.Handlers } catch (Exception e) { - Logger.LogError($"Couldn't generate body {body.Config?.Name}: {e.Message}, {e.StackTrace}"); + Logger.LogError($"Couldn't generate body {body.Config?.name}: {e.Message}, {e.StackTrace}"); return false; } } @@ -248,9 +248,9 @@ namespace NewHorizons.Handlers UpdateBodyOrbit(body, go); } - if (body.Config.RemoveChildren != null && body.Config.RemoveChildren.Length > 0) + if (body.Config.removeChildren != null && body.Config.removeChildren.Length > 0) { - foreach (var child in body.Config.RemoveChildren) + foreach (var child in body.Config.removeChildren) { Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => GameObject.Find(go.name + "/" + child)?.SetActive(false), 2); } @@ -288,9 +288,9 @@ namespace NewHorizons.Handlers primaryBody = null; } - Logger.Log($"Begin generation sequence of [{body.Config.Name}]"); + Logger.Log($"Begin generation sequence of [{body.Config.name}]"); - var go = new GameObject(body.Config.Name.Replace(" ", "").Replace("'", "") + "_Body"); + var go = new GameObject(body.Config.name.Replace(" ", "").Replace("'", "") + "_Body"); go.SetActive(false); var owRigidBody = RigidBodyBuilder.Make(go, body.Config); @@ -301,19 +301,19 @@ namespace NewHorizons.Handlers var sector = MakeSector.Make(go, owRigidBody, sphereOfInfluence * 2f); ao._rootSector = sector; - if (body.Config.Base.SurfaceGravity != 0) + if (body.Config.Base.surfaceGravity != 0) { GravityBuilder.Make(go, ao, body.Config); } - if (body.Config.Base.HasReferenceFrame) + if (body.Config.Base.hasReferenceFrame) { RFVolumeBuilder.Make(go, owRigidBody, sphereOfInfluence); } - if (body.Config.Base.HasMapMarker) + if (body.Config.Base.hasMapMarker) { - MarkerBuilder.Make(go, body.Config.Name, body.Config); + MarkerBuilder.Make(go, body.Config.name, body.Config); } VolumesBuilder.Make(go, body.Config, sphereOfInfluence); @@ -338,7 +338,7 @@ namespace NewHorizons.Handlers if (body.Config.Spawn != null) { Logger.Log("Doing spawn point thing"); - Main.SystemDict[body.Config.StarSystem].SpawnPoint = SpawnPointBuilder.Make(go, body.Config.Spawn, owRigidBody); + Main.SystemDict[body.Config.starSystem].SpawnPoint = SpawnPointBuilder.Make(go, body.Config.Spawn, owRigidBody); } if (body.Config.Orbit.ShowOrbitLine && !body.Config.Orbit.IsStatic) @@ -366,9 +366,9 @@ namespace NewHorizons.Handlers private static float GetSphereOfInfluence(NewHorizonsBody body) { - var atmoSize = body.Config.Atmosphere != null ? body.Config.Atmosphere.Size : 0f; - float sphereOfInfluence = Mathf.Max(Mathf.Max(atmoSize, 50), body.Config.Base.SurfaceSize * 2f); - var overrideSOI = body.Config.Base.SphereOfInfluence; + var atmoSize = body.Config.Atmosphere != null ? body.Config.Atmosphere.size : 0f; + float sphereOfInfluence = Mathf.Max(Mathf.Max(atmoSize, 50), body.Config.Base.surfaceSize * 2f); + var overrideSOI = body.Config.Base.sphereOfInfluence; if (overrideSOI != 0) sphereOfInfluence = overrideSOI; return sphereOfInfluence; } @@ -378,14 +378,14 @@ namespace NewHorizons.Handlers { var sphereOfInfluence = GetSphereOfInfluence(body); - if (body.Config.Base.AmbientLight != 0) + if (body.Config.Base.ambientLight != 0) { - AmbientLightBuilder.Make(go, sector, sphereOfInfluence, body.Config.Base.AmbientLight); + AmbientLightBuilder.Make(go, sector, sphereOfInfluence, body.Config.Base.ambientLight); } - if (body.Config.Base.GroundSize != 0) + if (body.Config.Base.groundSize != 0) { - GeometryBuilder.Make(go, sector, body.Config.Base.GroundSize); + GeometryBuilder.Make(go, sector, body.Config.Base.groundSize); } if (body.Config.HeightMap != null) @@ -410,10 +410,10 @@ namespace NewHorizons.Handlers if (body.Config.AsteroidBelt != null) { - AsteroidBeltBuilder.Make(body.Config.Name, body.Config, body.Mod); + AsteroidBeltBuilder.Make(body.Config.name, body.Config, body.Mod); } - if (body.Config.Base.HasCometTail) + if (body.Config.Base.hasCometTail) { CometTailBuilder.Make(go, sector, body.Config); } @@ -437,26 +437,26 @@ namespace NewHorizons.Handlers { var airInfo = new AtmosphereModule.AirInfo() { - HasOxygen = body.Config.Atmosphere.HasOxygen, - IsRaining = body.Config.Atmosphere.HasRain, - IsSnowing = body.Config.Atmosphere.HasSnow, - Scale = body.Config.Atmosphere.Size + hasOxygen = body.Config.Atmosphere.hasOxygen, + isRaining = body.Config.Atmosphere.hasRain, + isSnowing = body.Config.Atmosphere.hasSnow, + scale = body.Config.Atmosphere.size }; - var surfaceSize = body.Config.Base.SurfaceSize; + var surfaceSize = body.Config.Base.surfaceSize; AirBuilder.Make(go, sector, airInfo); - if (!string.IsNullOrEmpty(body.Config.Atmosphere?.Clouds?.TexturePath)) + if (!string.IsNullOrEmpty(body.Config.Atmosphere?.clouds?.texturePath)) { CloudsBuilder.Make(go, sector, body.Config.Atmosphere, body.Mod); SunOverrideBuilder.Make(go, sector, body.Config.Atmosphere, surfaceSize); } - if (body.Config.Atmosphere.HasRain || body.Config.Atmosphere.HasSnow) + if (body.Config.Atmosphere.hasRain || body.Config.Atmosphere.hasSnow) EffectsBuilder.Make(go, sector, airInfo, surfaceSize); - if (body.Config.Atmosphere.FogSize != 0) + if (body.Config.Atmosphere.fogSize != 0) FogBuilder.Make(go, sector, body.Config.Atmosphere); AtmosphereBuilder.Make(go, sector, body.Config.Atmosphere, surfaceSize); @@ -483,9 +483,9 @@ namespace NewHorizons.Handlers } // Has to go last probably - if (body.Config.Base.CloakRadius != 0f) + if (body.Config.Base.cloakRadius != 0f) { - CloakBuilder.Make(go, sector, rb, body.Config.Base.CloakRadius); + CloakBuilder.Make(go, sector, rb, body.Config.Base.cloakRadius); } return go; @@ -493,7 +493,7 @@ namespace NewHorizons.Handlers public static void UpdateBodyOrbit(NewHorizonsBody body, GameObject go) { - Logger.Log($"Updating orbit of [{body.Config.Name}]"); + Logger.Log($"Updating orbit of [{body.Config.name}]"); try { @@ -595,7 +595,7 @@ namespace NewHorizons.Handlers } catch (Exception ex) { - Logger.LogError($"Couldn't update orbit of [{body.Config.Name}]: {ex.Message}, {ex.StackTrace}"); + Logger.LogError($"Couldn't update orbit of [{body.Config.name}]: {ex.Message}, {ex.StackTrace}"); // If it doesn't work here there's no point trying again so we'll still return true } diff --git a/NewHorizons/Handlers/PlanetGraphHandler.cs b/NewHorizons/Handlers/PlanetGraphHandler.cs index 92a2ed6a..28a7ffc1 100644 --- a/NewHorizons/Handlers/PlanetGraphHandler.cs +++ b/NewHorizons/Handlers/PlanetGraphHandler.cs @@ -27,7 +27,7 @@ namespace NewHorizons.Handlers public PlanetGraphHandler(IEnumerable iBodies) { var bodies = iBodies.ToArray(); - var centers = bodies.Where(b => b.Config.Base.CenterOfSolarSystem).ToArray(); + var centers = bodies.Where(b => b.Config.Base.centerOfSolarSystem).ToArray(); if (centers.Length == 1) { _rootNode = ConstructGraph(centers[0], bodies); @@ -37,7 +37,7 @@ namespace NewHorizons.Handlers if (centers.Length == 0 && Main.Instance.CurrentStarSystem == "SolarSystem") { var SunConfig = new PlanetConfig(); - SunConfig.Name = "Sun"; + SunConfig.name = "Sun"; _rootNode = ConstructGraph(new NewHorizonsBody(SunConfig, Main.Instance), bodies); } else @@ -51,7 +51,7 @@ namespace NewHorizons.Handlers public static List ConstructStockGraph(NewHorizonsBody[] bodies) { - var astroObjects = bodies.Select(x => AstroObjectLocator.GetAstroObject(x.Config.Name)).ToArray(); + var astroObjects = bodies.Select(x => AstroObjectLocator.GetAstroObject(x.Config.name)).ToArray(); var children = astroObjects.Select(x => AstroObjectLocator.GetChildren(x)).ToArray(); var nodeDict = new Dictionary(); @@ -74,7 +74,7 @@ namespace NewHorizons.Handlers childBodies.Add(bodies[j]); } // If uh the primary body straight up matches the name - else if (bodies[j].Config.Orbit.PrimaryBody == bodies[i].Config.Name) + else if (bodies[j].Config.Orbit.PrimaryBody == bodies[i].Config.name) { childBodies.Add(bodies[j]); } @@ -108,8 +108,8 @@ namespace NewHorizons.Handlers // Verifying it worked foreach (var node in nodeDict.Values.ToList()) { - var childrenString = String.Join(", ", node.children.Select(x => x?.body?.Config?.Name).ToList()); - Logger.Log($"NODE: [{node?.body?.Config?.Name}], [{node?.parent?.body?.Config?.Name}], [{childrenString}]"); + var childrenString = String.Join(", ", node.children.Select(x => x?.body?.Config?.name).ToList()); + Logger.Log($"NODE: [{node?.body?.Config?.name}], [{node?.parent?.body?.Config?.name}], [{childrenString}]"); } // Return all tree roots (no parents) @@ -118,11 +118,11 @@ namespace NewHorizons.Handlers private static bool DetermineIfChildOfFocal(NewHorizonsBody body, FocalPointNode node) { - var name = body.Config.Name.ToLower(); + var name = body.Config.name.ToLower(); var primary = (body.Config.Orbit?.PrimaryBody ?? "").ToLower(); - var primaryName = node.primary.body.Config.Name.ToLower(); - var secondaryName = node.secondary.body.Config.Name.ToLower(); - return name != primaryName && name != secondaryName && (primary == node.body.Config.Name.ToLower() || primary == primaryName || primary == secondaryName); + var primaryName = node.primary.body.Config.name.ToLower(); + var secondaryName = node.secondary.body.Config.name.ToLower(); + return name != primaryName && name != secondaryName && (primary == node.body.Config.name.ToLower() || primary == primaryName || primary == secondaryName); } @@ -134,7 +134,7 @@ namespace NewHorizons.Handlers { body = body, children = bodies - .Where(b => string.Equals(b.Config.Orbit.PrimaryBody, body.Config.Name, StringComparison.CurrentCultureIgnoreCase)) + .Where(b => string.Equals(b.Config.Orbit.PrimaryBody, body.Config.name, StringComparison.CurrentCultureIgnoreCase)) .Select(b => ConstructGraph(b, bodies)) }; } @@ -146,7 +146,7 @@ namespace NewHorizons.Handlers }; foreach (var child in bodies) { - if (string.Equals(child.Config.Name, body.Config.FocalPoint.Primary, StringComparison.CurrentCultureIgnoreCase)) + if (string.Equals(child.Config.name, body.Config.FocalPoint.primary, StringComparison.CurrentCultureIgnoreCase)) { newNode.primary = new PlanetNode { @@ -154,7 +154,7 @@ namespace NewHorizons.Handlers children = new List() }; } - else if (string.Equals(child.Config.Name, body.Config.FocalPoint.Secondary, StringComparison.CurrentCultureIgnoreCase)) + else if (string.Equals(child.Config.name, body.Config.FocalPoint.secondary, StringComparison.CurrentCultureIgnoreCase)) { newNode.secondary = new PlanetNode { diff --git a/NewHorizons/Handlers/ShipLogHandler.cs b/NewHorizons/Handlers/ShipLogHandler.cs index 98d323e7..2ef80633 100644 --- a/NewHorizons/Handlers/ShipLogHandler.cs +++ b/NewHorizons/Handlers/ShipLogHandler.cs @@ -44,16 +44,16 @@ namespace NewHorizons.Handlers public static bool IsVanillaBody(NewHorizonsBody body) { - var existingBody = AstroObjectLocator.GetAstroObject(body.Config.Name); + var existingBody = AstroObjectLocator.GetAstroObject(body.Config.name); if (existingBody != null && existingBody.GetAstroObjectName() != AstroObject.Name.CustomString) return true; - return _vanillaBodies.Contains(body.Config.Name.Replace(" ", "")); + return _vanillaBodies.Contains(body.Config.name.Replace(" ", "")); } public static string GetNameFromAstroID(string astroID) { - return CollectionUtilities.KeyByValue(_nhBodyToAstroIDs, astroID)?.Config.Name; + return CollectionUtilities.KeyByValue(_nhBodyToAstroIDs, astroID)?.Config.name; } public static NewHorizonsBody GetConfigFromEntryID(string entryID) @@ -75,24 +75,24 @@ namespace NewHorizons.Handlers { // Nice to be able to just get the AstroID from the body if (!_nhBodyToEntryIDs.ContainsKey(body)) _nhBodyToEntryIDs.Add(body, entryIDs); - else Logger.LogWarning($"Possible duplicate shiplog entry {body.Config.Name}"); + else Logger.LogWarning($"Possible duplicate shiplog entry {body.Config.name}"); // AstroID if (!_nhBodyToAstroIDs.ContainsKey(body)) _nhBodyToAstroIDs.Add(body, astroID); - else Logger.LogWarning($"Possible duplicate shiplog entry {astroID} for {body.Config.Name}"); + else Logger.LogWarning($"Possible duplicate shiplog entry {astroID} for {body.Config.name}"); // EntryID to Body foreach (var entryID in entryIDs) { if (!_entryIDsToNHBody.ContainsKey(entryID)) _entryIDsToNHBody.Add(entryID, body); - else Logger.LogWarning($"Possible duplicate shiplog entry {entryID} for {astroID} from NewHorizonsBody {body.Config.Name}"); + else Logger.LogWarning($"Possible duplicate shiplog entry {entryID} for {astroID} from NewHorizonsBody {body.Config.name}"); } } public static string GetAstroObjectId(NewHorizonsBody body) { if (_nhBodyToAstroIDs.ContainsKey(body)) return _nhBodyToAstroIDs[body]; - else return body.Config.Name; + else return body.Config.name; } public static bool BodyHasEntries(NewHorizonsBody body) diff --git a/NewHorizons/Handlers/StarChartHandler.cs b/NewHorizons/Handlers/StarChartHandler.cs index 627206fc..e22406d3 100644 --- a/NewHorizons/Handlers/StarChartHandler.cs +++ b/NewHorizons/Handlers/StarChartHandler.cs @@ -68,7 +68,7 @@ namespace NewHorizons.Handlers { foreach (var system in _systems) { - if (system.Config.canEnterViaWarpDrive && system.Spawn?.ShipSpawnPoint != null && HasUnlockedSystem(system.UniqueID)) + if (system.Config.canEnterViaWarpDrive && system.Spawn?.shipSpawnPoint != null && HasUnlockedSystem(system.UniqueID)) { return true; } diff --git a/NewHorizons/Handlers/TitleSceneHandler.cs b/NewHorizons/Handlers/TitleSceneHandler.cs index 9a28229b..2776c0f4 100644 --- a/NewHorizons/Handlers/TitleSceneHandler.cs +++ b/NewHorizons/Handlers/TitleSceneHandler.cs @@ -1,125 +1,125 @@ -using NewHorizons.Builder.Body; -using NewHorizons.External.Modules; -using NewHorizons.Utility; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using Logger = NewHorizons.Utility.Logger; -using NewHorizons.External.Modules.VariableSize; - -namespace NewHorizons.Handlers -{ - public static class TitleSceneHandler - { - public static void InitSubtitles() - { - GameObject subtitleContainer = GameObject.Find("TitleMenu/TitleCanvas/TitleLayoutGroup/Logo_EchoesOfTheEye"); - +using NewHorizons.Builder.Body; +using NewHorizons.External.Modules; +using NewHorizons.Utility; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using Logger = NewHorizons.Utility.Logger; +using NewHorizons.External.Modules.VariableSize; + +namespace NewHorizons.Handlers +{ + public static class TitleSceneHandler + { + public static void InitSubtitles() + { + GameObject subtitleContainer = GameObject.Find("TitleMenu/TitleCanvas/TitleLayoutGroup/Logo_EchoesOfTheEye"); + if (subtitleContainer == null) { Logger.LogError("No subtitle container found! Failed to load subtitles."); return; - } - - subtitleContainer.SetActive(true); - subtitleContainer.AddComponent(); - } - - public static void DisplayBodyOnTitleScreen(List bodies) - { - //Try loading one planet why not - //var eligible = BodyDict.Values.ToList().SelectMany(x => x).ToList().Where(b => (b.Config.HeightMap != null || b.Config.Atmosphere?.Cloud != null) && b.Config.Star == null).ToArray(); - var eligible = bodies.Where(b => (b.Config.HeightMap != null || b.Config.Atmosphere?.Clouds != null) && b.Config.Star == null && b.Config.CanShowOnTitle).ToArray(); - var eligibleCount = eligible.Count(); - if (eligibleCount == 0) return; - - var selectionCount = Mathf.Min(eligibleCount, 3); - var indices = RandomUtility.GetUniqueRandomArray(0, eligible.Count(), selectionCount); - - Logger.Log($"Displaying {selectionCount} bodies on the title screen"); - - GameObject body1, body2, body3; - - body1 = LoadTitleScreenBody(eligible[indices[0]]); - body1.transform.localRotation = Quaternion.Euler(15, 0, 0); - if (selectionCount > 1) - { - body1.transform.localScale = Vector3.one * (body1.transform.localScale.x) * 0.3f; - body1.transform.localPosition = new Vector3(0, -15, 0); - body1.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); - body2 = LoadTitleScreenBody(eligible[indices[1]]); - body2.transform.localScale = Vector3.one * (body2.transform.localScale.x) * 0.3f; - body2.transform.localPosition = new Vector3(7, 30, 0); - body2.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); - } - if (selectionCount > 2) - { - body3 = LoadTitleScreenBody(eligible[indices[2]]); - body3.transform.localScale = Vector3.one * (body3.transform.localScale.x) * 0.3f; - body3.transform.localPosition = new Vector3(-5, 10, 0); - body3.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); - } - - GameObject.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire").SetActive(false); - GameObject.Find("Scene/Background/PlanetPivot/PlanetRoot").SetActive(false); - - var lightGO = new GameObject("Light"); - lightGO.transform.parent = GameObject.Find("Scene/Background").transform; - lightGO.transform.localPosition = new Vector3(-47.9203f, 145.7596f, 43.1802f); - var light = lightGO.AddComponent(); - light.color = new Color(1f, 1f, 1f, 1f); - light.range = 100; - light.intensity = 0.8f; - } - - private static GameObject LoadTitleScreenBody(NewHorizonsBody body) - { - Logger.Log($"Displaying {body.Config.Name} on the title screen"); - GameObject titleScreenGO = new GameObject(body.Config.Name + "_TitleScreen"); - HeightMapModule heightMap = new HeightMapModule(); - var minSize = 15; - var maxSize = 30; - float size = minSize; - if (body.Config.HeightMap != null) - { - size = Mathf.Clamp(body.Config.HeightMap.MaxHeight / 10, minSize, maxSize); - heightMap.TextureMap = body.Config.HeightMap.TextureMap; - heightMap.HeightMap = body.Config.HeightMap.HeightMap; - heightMap.MaxHeight = size; - heightMap.MinHeight = body.Config.HeightMap.MinHeight * size / body.Config.HeightMap.MaxHeight; - } - if (body.Config.Atmosphere?.Clouds?.TexturePath != null) - { - // Hacky but whatever I just want a sphere - size = Mathf.Clamp(body.Config.Atmosphere.Size / 10, minSize, maxSize); - heightMap.MaxHeight = heightMap.MinHeight = size + 1; - heightMap.TextureMap = body.Config.Atmosphere.Clouds.TexturePath; - } - - HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod); - - GameObject pivot = GameObject.Instantiate(GameObject.Find("Scene/Background/PlanetPivot"), GameObject.Find("Scene/Background").transform); - pivot.GetComponent()._degreesPerSecond = 10f; - foreach (Transform child in pivot.transform) - { - GameObject.Destroy(child.gameObject); - } - pivot.name = "Pivot"; - - if (body.Config.Ring != null) - { - RingModule newRing = new RingModule(); - newRing.InnerRadius = size * 1.2f; - newRing.OuterRadius = size * 2f; - newRing.Texture = body.Config.Ring.Texture; - var ring = RingBuilder.Make(titleScreenGO, null, newRing, body.Mod); - titleScreenGO.transform.localScale = Vector3.one * 0.8f; - } - - titleScreenGO.transform.parent = pivot.transform; - titleScreenGO.transform.localPosition = Vector3.zero; - - return titleScreenGO; - } - } -} + } + + subtitleContainer.SetActive(true); + subtitleContainer.AddComponent(); + } + + public static void DisplayBodyOnTitleScreen(List bodies) + { + //Try loading one planet why not + //var eligible = BodyDict.Values.ToList().SelectMany(x => x).ToList().Where(b => (b.Config.HeightMap != null || b.Config.Atmosphere?.Cloud != null) && b.Config.Star == null).ToArray(); + var eligible = bodies.Where(b => (b.Config.HeightMap != null || b.Config.Atmosphere?.clouds != null) && b.Config.Star == null && b.Config.canShowOnTitle).ToArray(); + var eligibleCount = eligible.Count(); + if (eligibleCount == 0) return; + + var selectionCount = Mathf.Min(eligibleCount, 3); + var indices = RandomUtility.GetUniqueRandomArray(0, eligible.Count(), selectionCount); + + Logger.Log($"Displaying {selectionCount} bodies on the title screen"); + + GameObject body1, body2, body3; + + body1 = LoadTitleScreenBody(eligible[indices[0]]); + body1.transform.localRotation = Quaternion.Euler(15, 0, 0); + if (selectionCount > 1) + { + body1.transform.localScale = Vector3.one * (body1.transform.localScale.x) * 0.3f; + body1.transform.localPosition = new Vector3(0, -15, 0); + body1.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); + body2 = LoadTitleScreenBody(eligible[indices[1]]); + body2.transform.localScale = Vector3.one * (body2.transform.localScale.x) * 0.3f; + body2.transform.localPosition = new Vector3(7, 30, 0); + body2.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); + } + if (selectionCount > 2) + { + body3 = LoadTitleScreenBody(eligible[indices[2]]); + body3.transform.localScale = Vector3.one * (body3.transform.localScale.x) * 0.3f; + body3.transform.localPosition = new Vector3(-5, 10, 0); + body3.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); + } + + GameObject.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire").SetActive(false); + GameObject.Find("Scene/Background/PlanetPivot/PlanetRoot").SetActive(false); + + var lightGO = new GameObject("Light"); + lightGO.transform.parent = GameObject.Find("Scene/Background").transform; + lightGO.transform.localPosition = new Vector3(-47.9203f, 145.7596f, 43.1802f); + var light = lightGO.AddComponent(); + light.color = new Color(1f, 1f, 1f, 1f); + light.range = 100; + light.intensity = 0.8f; + } + + private static GameObject LoadTitleScreenBody(NewHorizonsBody body) + { + Logger.Log($"Displaying {body.Config.name} on the title screen"); + GameObject titleScreenGO = new GameObject(body.Config.name + "_TitleScreen"); + HeightMapModule heightMap = new HeightMapModule(); + var minSize = 15; + var maxSize = 30; + float size = minSize; + if (body.Config.HeightMap != null) + { + size = Mathf.Clamp(body.Config.HeightMap.maxHeight / 10, minSize, maxSize); + heightMap.textureMap = body.Config.HeightMap.textureMap; + heightMap.heightMap = body.Config.HeightMap.heightMap; + heightMap.maxHeight = size; + heightMap.minHeight = body.Config.HeightMap.minHeight * size / body.Config.HeightMap.maxHeight; + } + if (body.Config.Atmosphere?.clouds?.texturePath != null) + { + // Hacky but whatever I just want a sphere + size = Mathf.Clamp(body.Config.Atmosphere.size / 10, minSize, maxSize); + heightMap.maxHeight = heightMap.minHeight = size + 1; + heightMap.textureMap = body.Config.Atmosphere.clouds.texturePath; + } + + HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod); + + GameObject pivot = GameObject.Instantiate(GameObject.Find("Scene/Background/PlanetPivot"), GameObject.Find("Scene/Background").transform); + pivot.GetComponent()._degreesPerSecond = 10f; + foreach (Transform child in pivot.transform) + { + GameObject.Destroy(child.gameObject); + } + pivot.name = "Pivot"; + + if (body.Config.Ring != null) + { + RingModule newRing = new RingModule(); + newRing.innerRadius = size * 1.2f; + newRing.outerRadius = size * 2f; + newRing.texture = body.Config.Ring.texture; + var ring = RingBuilder.Make(titleScreenGO, null, newRing, body.Mod); + titleScreenGO.transform.localScale = Vector3.one * 0.8f; + } + + titleScreenGO.transform.parent = pivot.transform; + titleScreenGO.transform.localPosition = Vector3.zero; + + return titleScreenGO; + } + } +} diff --git a/NewHorizons/Handlers/TranslationHandler.cs b/NewHorizons/Handlers/TranslationHandler.cs index 3562f404..b313726e 100644 --- a/NewHorizons/Handlers/TranslationHandler.cs +++ b/NewHorizons/Handlers/TranslationHandler.cs @@ -61,39 +61,39 @@ namespace NewHorizons.Handlers public static void RegisterTranslation(TextTranslation.Language language, TranslationConfig config) { - if (config.ShipLogDictionary != null && config.ShipLogDictionary.Count() > 0) + if (config.shipLogDictionary != null && config.shipLogDictionary.Count() > 0) { if (!_shipLogTranslationDictionary.ContainsKey(language)) _shipLogTranslationDictionary.Add(language, new Dictionary()); - foreach (var originalKey in config.ShipLogDictionary.Keys) + foreach (var originalKey in config.shipLogDictionary.Keys) { var key = originalKey.Replace("<", "<").Replace(">", ">").Replace("", ""); - if (!_shipLogTranslationDictionary[language].ContainsKey(key)) _shipLogTranslationDictionary[language].Add(key, config.ShipLogDictionary[originalKey]); - else _shipLogTranslationDictionary[language][key] = config.ShipLogDictionary[originalKey]; + if (!_shipLogTranslationDictionary[language].ContainsKey(key)) _shipLogTranslationDictionary[language].Add(key, config.shipLogDictionary[originalKey]); + else _shipLogTranslationDictionary[language][key] = config.shipLogDictionary[originalKey]; } } - if (config.DialogueDictionary != null && config.DialogueDictionary.Count() > 0) + if (config.dialogueDictionary != null && config.dialogueDictionary.Count() > 0) { if (!_dialogueTranslationDictionary.ContainsKey(language)) _dialogueTranslationDictionary.Add(language, new Dictionary()); - foreach (var originalKey in config.DialogueDictionary.Keys) + foreach (var originalKey in config.dialogueDictionary.Keys) { var key = originalKey.Replace("<", "<").Replace(">", ">").Replace("", ""); - if (!_dialogueTranslationDictionary[language].ContainsKey(key)) _dialogueTranslationDictionary[language].Add(key, config.DialogueDictionary[originalKey]); - else _dialogueTranslationDictionary[language][key] = config.DialogueDictionary[originalKey]; + if (!_dialogueTranslationDictionary[language].ContainsKey(key)) _dialogueTranslationDictionary[language].Add(key, config.dialogueDictionary[originalKey]); + else _dialogueTranslationDictionary[language][key] = config.dialogueDictionary[originalKey]; } } - if (config.UIDictionary != null && config.UIDictionary.Count() > 0) + if (config.uiDictionary != null && config.uiDictionary.Count() > 0) { if (!_uiTranslationDictionary.ContainsKey(language)) _uiTranslationDictionary.Add(language, new Dictionary()); - foreach (var originalKey in config.UIDictionary.Keys) + foreach (var originalKey in config.uiDictionary.Keys) { var key = originalKey.Replace("<", "<").Replace(">", ">").Replace("", ""); - if (!_uiTranslationDictionary[language].ContainsKey(key)) _uiTranslationDictionary[language].Add(key, config.UIDictionary[originalKey]); - else _uiTranslationDictionary[language][key] = config.UIDictionary[originalKey]; + if (!_uiTranslationDictionary[language].ContainsKey(key)) _uiTranslationDictionary[language].Add(key, config.uiDictionary[originalKey]); + else _uiTranslationDictionary[language][key] = config.uiDictionary[originalKey]; } } } diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index f885bba1..6df9de2f 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -1,5 +1,4 @@ using HarmonyLib; -using NJsonSchema; using NewHorizons.Builder.Props; using NewHorizons.Components; using NewHorizons.External.Configs; @@ -13,23 +12,15 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; -using Newtonsoft.Json; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using Logger = NewHorizons.Utility.Logger; using NewHorizons.Utility.DebugUtilities; +using Newtonsoft.Json.Schema; namespace NewHorizons { - - // TODO: Test class, delete later - [JsonObject] - public class Test - { - [JsonProperty] - public string Name; - } public class Main : ModBehaviour { @@ -48,8 +39,6 @@ namespace NewHorizons public static float SecondsLeftInLoop = -1; - private static JsonSchema _bodySchema; - public static bool IsSystemReady { get; private set; } public static float FurthestOrbit { get; set; } = 50000f; @@ -160,10 +149,6 @@ namespace NewHorizons ResetConfigs(resetTranslation: false); Logger.Log("Begin load of config files...", Logger.LogType.Log); - - _bodySchema = JsonSchema.FromType(); - Logger.LogWarning(_bodySchema.ToString()); - try { @@ -367,11 +352,11 @@ namespace NewHorizons if (body != null) { // Wanna track the spawn point of each system - if (body.Config.Spawn != null) SystemDict[body.Config.StarSystem].Spawn = body.Config.Spawn; + if (body.Config.Spawn != null) SystemDict[body.Config.starSystem].Spawn = body.Config.Spawn; // Add the new planet to the planet dictionary - if (!BodyDict.ContainsKey(body.Config.StarSystem)) BodyDict[body.Config.StarSystem] = new List(); - BodyDict[body.Config.StarSystem].Add(body); + if (!BodyDict.ContainsKey(body.Config.starSystem)) BodyDict[body.Config.starSystem] = new List(); + BodyDict[body.Config.starSystem].Add(body); } } } @@ -422,20 +407,20 @@ namespace NewHorizons var config = mod.ModHelper.Storage.Load(relativeDirectory); config.MigrateAndValidate(); - Logger.Log($"Loaded {config.Name}"); + Logger.Log($"Loaded {config.name}"); - if (!SystemDict.ContainsKey(config.StarSystem)) + if (!SystemDict.ContainsKey(config.starSystem)) { // Since we didn't load it earlier there shouldn't be a star system config - var starSystemConfig = mod.ModHelper.Storage.Load($"systems/{config.StarSystem}.json"); + var starSystemConfig = mod.ModHelper.Storage.Load($"systems/{config.starSystem}.json"); if (starSystemConfig == null) starSystemConfig = new StarSystemConfig(); - else Logger.LogWarning($"Loaded system config for {config.StarSystem}. Why wasn't this loaded earlier?"); + else Logger.LogWarning($"Loaded system config for {config.starSystem}. Why wasn't this loaded earlier?"); - var system = new NewHorizonsSystem(config.StarSystem, starSystemConfig, mod); + var system = new NewHorizonsSystem(config.starSystem, starSystemConfig, mod); - SystemDict.Add(config.StarSystem, system); + SystemDict.Add(config.starSystem, system); - BodyDict.Add(config.StarSystem, new List()); + BodyDict.Add(config.starSystem, new List()); } body = new NewHorizonsBody(config, mod, relativeDirectory); diff --git a/NewHorizons/NewHorizons.csproj b/NewHorizons/NewHorizons.csproj index 6502d70b..2c5736c7 100644 --- a/NewHorizons/NewHorizons.csproj +++ b/NewHorizons/NewHorizons.csproj @@ -10,10 +10,14 @@ false - portable + portable + C:\Users\bwc67\AppData\Roaming\OuterWildsModManager\OWML\Mods\xen.NewHorizons\NewHorizons.xml + 1701;1702;1591 - none + none + C:\Users\bwc67\AppData\Roaming\OuterWildsModManager\OWML\Mods\xen.NewHorizons\NewHorizons.xml + 1701;1702;1591 diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index a93ad02b..260d32e6 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -43,8 +43,8 @@ namespace NewHorizons // Update it to point to their mod for textures and stuff body.Mod = mod ?? Main.Instance; - if (!Main.BodyDict.ContainsKey(body.Config.StarSystem)) Main.BodyDict.Add(body.Config.StarSystem, new List()); - Main.BodyDict[body.Config.StarSystem].Add(body); + if (!Main.BodyDict.ContainsKey(body.Config.starSystem)) Main.BodyDict.Add(body.Config.starSystem, new List()); + Main.BodyDict[body.Config.starSystem].Add(body); } catch(Exception ex) { @@ -59,7 +59,7 @@ namespace NewHorizons public GameObject GetPlanet(string name) { - return Main.BodyDict.Values.SelectMany(x => x)?.ToList()?.FirstOrDefault(x => x.Config.Name == name)?.Object; + return Main.BodyDict.Values.SelectMany(x => x)?.ToList()?.FirstOrDefault(x => x.Config.name == name)?.Object; } public string GetCurrentStarSystem() diff --git a/NewHorizons/Utility/DebugUtilities/DebugMenu.cs b/NewHorizons/Utility/DebugUtilities/DebugMenu.cs index 1046c194..eac4f31d 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugMenu.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugMenu.cs @@ -1,353 +1,353 @@ -using NewHorizons.External; -using NewHorizons.External.Configs; -using NewHorizons.External.Modules; +using NewHorizons.External; +using NewHorizons.External.Configs; +using NewHorizons.External.Modules; using NewHorizons.Handlers; -using Newtonsoft.Json; -using OWML.Common; -using OWML.Common.Menus; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; -using UnityEngine.InputSystem; - -namespace NewHorizons.Utility.DebugUtilities -{ - - // - // - // TODO: split this into two separate classes "DebugMenu" and "DebugPropPlacerMenu" - // - // - - [RequireComponent(typeof(DebugRaycaster))] - [RequireComponent(typeof(DebugPropPlacer))] - class DebugMenu : MonoBehaviour - { - private static IModButton pauseMenuButton; - - GUIStyle _editorMenuStyle; - Vector2 EditorMenuSize = new Vector2(600, 900); - bool menuOpen = false; - static bool openMenuOnPause; - static bool staticInitialized; - - DebugPropPlacer _dpp; - DebugRaycaster _drc; - - // menu params - private Vector2 recentPropsScrollPosition = Vector2.zero; - private HashSet favoriteProps = new HashSet(); - public static readonly char separatorCharacter = '☧'; // since no chars are illegal in game object names, I picked one that's extremely unlikely to be used to be a separator - private static readonly string favoritePropsPlayerPrefKey = "FavoriteProps"; - - private static IModBehaviour loadedMod = null; - private Dictionary loadedConfigFiles = new Dictionary(); - private bool saveButtonUnlocked = false; - private Vector2 recentModListScrollPosition = Vector2.zero; - - private static JsonSerializerSettings jsonSettings = new JsonSerializerSettings - { - NullValueHandling = NullValueHandling.Ignore, - DefaultValueHandling = DefaultValueHandling.Ignore, - Formatting = Formatting.Indented, - }; - - private void Awake() - { - _dpp = this.GetRequiredComponent(); - _drc = this.GetRequiredComponent(); - LoadFavoriteProps(); - } - - private void Start() - { - if (!staticInitialized) - { - staticInitialized = true; - - Main.Instance.ModHelper.Menus.PauseMenu.OnInit += PauseMenuInitHook; - Main.Instance.ModHelper.Menus.PauseMenu.OnClosed += CloseMenu; - Main.Instance.ModHelper.Menus.PauseMenu.OnOpened += RestoreMenuOpennessState; - - PauseMenuInitHook(); - - Main.Instance.OnChangeStarSystem.AddListener((string s) => SaveLoadedConfigsForRecentSystem()); - } - else - { - InitMenu(); - } - - if (loadedMod != null) - { - LoadMod(loadedMod); - } - } - - private void PauseMenuInitHook() - { - pauseMenuButton = Main.Instance.ModHelper.Menus.PauseMenu.OptionsButton.Duplicate(TranslationHandler.GetTranslation("Toggle Prop Placer Menu", TranslationHandler.TextType.UI).ToUpper()); - InitMenu(); - } - public static void UpdatePauseMenuButton() - { - if (pauseMenuButton != null) - { - if (Main.Debug) pauseMenuButton.Show(); - else pauseMenuButton.Hide(); - } - } - - private void RestoreMenuOpennessState() { menuOpen = openMenuOnPause; } - private void ToggleMenu() { menuOpen = !menuOpen; openMenuOnPause = !openMenuOnPause; } - - private void CloseMenu() { menuOpen = false; } - - private void LoadFavoriteProps() - { - string favoritePropsPlayerPref = PlayerPrefs.GetString(favoritePropsPlayerPrefKey); - - if (favoritePropsPlayerPref == null || favoritePropsPlayerPref == "") return; - - var favoritePropPaths = favoritePropsPlayerPref.Split(separatorCharacter); - foreach (string favoriteProp in favoritePropPaths) - { - DebugPropPlacer.RecentlyPlacedProps.Add(favoriteProp); - this.favoriteProps.Add(favoriteProp); - } - } - - private void OnGUI() - { - if (!menuOpen) return; - if (!Main.Debug) return; - - Vector2 menuPosition = new Vector2(10, 40); - - GUILayout.BeginArea(new Rect(menuPosition.x, menuPosition.y, EditorMenuSize.x, EditorMenuSize.y), _editorMenuStyle); - - // - // DebugPropPlacer - // - GUILayout.Label("Recently placed objects"); - _dpp.SetCurrentObject(GUILayout.TextArea(_dpp.currentObject)); - - GUILayout.Space(5); - - // List of recently placed objects - GUILayout.Label("Recently placed objects"); - recentPropsScrollPosition = GUILayout.BeginScrollView(recentPropsScrollPosition, GUILayout.Width(EditorMenuSize.x), GUILayout.Height(100)); - foreach (string propPath in DebugPropPlacer.RecentlyPlacedProps) - { - GUILayout.BeginHorizontal(); - - var propPathElements = propPath[propPath.Length-1] == '/' - ? propPath.Substring(0, propPath.Length-1).Split('/') - : propPath.Split('/'); - string propName = propPathElements[propPathElements.Length - 1]; - - string favoriteButtonIcon = favoriteProps.Contains(propPath) ? "★" : "☆"; - if (GUILayout.Button(favoriteButtonIcon, GUILayout.ExpandWidth(false))) - { - if (favoriteProps.Contains(propPath)) - { - favoriteProps.Remove(propPath); - } - else - { - favoriteProps.Add(propPath); - } - - string[] favoritePropsArray = favoriteProps.ToArray(); - PlayerPrefs.SetString(favoritePropsPlayerPrefKey, string.Join(separatorCharacter + "", favoritePropsArray)); - } - - if (GUILayout.Button(propName)) - { - _dpp.SetCurrentObject(propPath); - } - - GUILayout.EndHorizontal(); - } - GUILayout.EndScrollView(); - - GUILayout.Space(5); - - // continue working on existing mod - - GUILayout.Label("Name of your mod"); - if (loadedMod == null) - { - recentModListScrollPosition = GUILayout.BeginScrollView(recentModListScrollPosition, GUILayout.Width(EditorMenuSize.x), GUILayout.Height(100)); - - foreach (var mod in Main.MountedAddons) - { - if (GUILayout.Button(mod.ModHelper.Manifest.UniqueName)) - { - LoadMod(mod); - } - } - - GUILayout.EndScrollView(); - } - else - { - GUILayout.Label(loadedMod.ModHelper.Manifest.UniqueName); - } - - GUILayout.Space(5); - - // save your work - - { - GUILayout.BeginHorizontal(); - if (GUILayout.Button(saveButtonUnlocked ? " O " : " | ", GUILayout.ExpandWidth(false))) - { - saveButtonUnlocked = !saveButtonUnlocked; - } - GUI.enabled = saveButtonUnlocked; - if (GUILayout.Button("Update your mod's configs")) - { - SaveLoadedConfigsForRecentSystem(); - saveButtonUnlocked = false; - } - GUI.enabled = true; - GUILayout.EndHorizontal(); - } - - GUILayout.EndArea(); - } - - private void LoadMod(IModBehaviour mod) - { - loadedMod = mod; - DebugPropPlacer.active = true; - - var folder = loadedMod.ModHelper.Manifest.ModFolderPath; - - List bodiesForThisMod = Main.BodyDict.Values.SelectMany(x => x).Where(x => x.Mod == loadedMod).ToList(); - foreach (NewHorizonsBody body in bodiesForThisMod) - { - if (body.RelativePath == null) - { - Logger.Log("Error loading config for " + body.Config.Name + " in " + body.Config.StarSystem); - } - - loadedConfigFiles[folder + body.RelativePath] = (body.Config as PlanetConfig); - _dpp.FindAndRegisterPropsFromConfig(body.Config); - } - } - - private void SaveLoadedConfigsForRecentSystem() - { - UpdateLoadedConfigsForRecentSystem(); - - string backupFolderName = "configBackups\\" + DateTime.Now.ToString("yyyyMMddTHHmmss") + "\\"; - Logger.Log($"Potentially saving {loadedConfigFiles.Keys.Count} files"); - - foreach (var filePath in loadedConfigFiles.Keys) - { - Logger.Log("Possibly Saving... " + loadedConfigFiles[filePath].Name + " @ " + filePath); - if (loadedConfigFiles[filePath].StarSystem != Main.Instance.CurrentStarSystem) continue; - - var relativePath = filePath.Replace(loadedMod.ModHelper.Manifest.ModFolderPath, ""); - - var json = JsonConvert.SerializeObject(loadedConfigFiles[filePath], jsonSettings); - // Add the schema line - json = "{\n\t\"$schema\": \"https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/body_schema.json\"," + json.Substring(1); - - try - { - Logger.Log("Saving... " + relativePath + " to " + filePath); - var path = loadedMod.ModHelper.Manifest.ModFolderPath + relativePath; - var directoryName = Path.GetDirectoryName(path); - Directory.CreateDirectory(directoryName); - - File.WriteAllText(path, json); - } - catch (Exception e) { Logger.LogError("Failed to save file " + backupFolderName + relativePath); Logger.LogError(e.Message + "\n" + e.StackTrace); } - - try - { - var path = Main.Instance.ModHelper.Manifest.ModFolderPath + backupFolderName + relativePath; - var directoryName = Path.GetDirectoryName(path); - Directory.CreateDirectory(directoryName); - - File.WriteAllText(path, json); - } - catch (Exception e) { Logger.LogError("Failed to save backup file " + backupFolderName + relativePath); Logger.LogError(e.Message + "\n" + e.StackTrace); } - } - } - - private void UpdateLoadedConfigsForRecentSystem() - { - var newDetails = _dpp.GetPropsConfigByBody(); - - Logger.Log("Updating config files. New Details Counts by planet: " + string.Join(", ", newDetails.Keys.Select(x => x + $" ({newDetails[x].Length})"))); - - Dictionary planetToConfigPath = new Dictionary(); - - // Get all configs - foreach (var filePath in loadedConfigFiles.Keys) - { - Logger.Log("potentially updating copy of config at " + filePath); - - if (loadedConfigFiles[filePath].StarSystem != Main.Instance.CurrentStarSystem) return; - if (loadedConfigFiles[filePath].Name == null || AstroObjectLocator.GetAstroObject(loadedConfigFiles[filePath].Name) == null) { Logger.Log("Failed to update copy of config at " + filePath); continue; } - - var astroObjectName = DebugPropPlacer.GetAstroObjectName(loadedConfigFiles[filePath].Name); - planetToConfigPath[astroObjectName] = filePath; - - if (!newDetails.ContainsKey(astroObjectName)) continue; - - if (loadedConfigFiles[filePath].Props == null) loadedConfigFiles[filePath].Props = new External.Modules.PropModule(); - loadedConfigFiles[filePath].Props.Details = newDetails[astroObjectName]; - - Logger.Log("successfully updated copy of config file for " + astroObjectName); - } - - // find all new planets that do not yet have config paths - var planetsThatDoNotHaveConfigFiles = newDetails.Keys.Where(x => !planetToConfigPath.ContainsKey(x)).ToList(); - foreach (var astroObjectName in planetsThatDoNotHaveConfigFiles) - { - Logger.Log("Fabricating new config file for " + astroObjectName); - - var filepath = "planets/" + Main.Instance.CurrentStarSystem + "/" + astroObjectName + ".json"; - PlanetConfig c = new PlanetConfig(); - c.StarSystem = Main.Instance.CurrentStarSystem; - c.Name = astroObjectName; - c.Props = new PropModule(); - c.Props.Details = newDetails[astroObjectName]; - - loadedConfigFiles[filepath] = c; - } - } - - private void InitMenu() - { - if (_editorMenuStyle != null) return; - - UpdatePauseMenuButton(); - - // TODO: figure out how to clear this event list so that we don't pile up useless instances of the DebugMenu that can't get garbage collected - pauseMenuButton.OnClick += ToggleMenu; - - _dpp = this.GetRequiredComponent(); - _drc = this.GetRequiredComponent(); - - Texture2D bgTexture = ImageUtilities.MakeSolidColorTexture((int)EditorMenuSize.x, (int)EditorMenuSize.y, Color.black); - - _editorMenuStyle = new GUIStyle - { - normal = - { - background = bgTexture - } - }; - } - } -} +using Newtonsoft.Json; +using OWML.Common; +using OWML.Common.Menus; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using UnityEngine.InputSystem; + +namespace NewHorizons.Utility.DebugUtilities +{ + + // + // + // TODO: split this into two separate classes "DebugMenu" and "DebugPropPlacerMenu" + // + // + + [RequireComponent(typeof(DebugRaycaster))] + [RequireComponent(typeof(DebugPropPlacer))] + class DebugMenu : MonoBehaviour + { + private static IModButton pauseMenuButton; + + GUIStyle _editorMenuStyle; + Vector2 EditorMenuSize = new Vector2(600, 900); + bool menuOpen = false; + static bool openMenuOnPause; + static bool staticInitialized; + + DebugPropPlacer _dpp; + DebugRaycaster _drc; + + // menu params + private Vector2 recentPropsScrollPosition = Vector2.zero; + private HashSet favoriteProps = new HashSet(); + public static readonly char separatorCharacter = '☧'; // since no chars are illegal in game object names, I picked one that's extremely unlikely to be used to be a separator + private static readonly string favoritePropsPlayerPrefKey = "FavoriteProps"; + + private static IModBehaviour loadedMod = null; + private Dictionary loadedConfigFiles = new Dictionary(); + private bool saveButtonUnlocked = false; + private Vector2 recentModListScrollPosition = Vector2.zero; + + private static JsonSerializerSettings jsonSettings = new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore, + DefaultValueHandling = DefaultValueHandling.Ignore, + Formatting = Formatting.Indented, + }; + + private void Awake() + { + _dpp = this.GetRequiredComponent(); + _drc = this.GetRequiredComponent(); + LoadFavoriteProps(); + } + + private void Start() + { + if (!staticInitialized) + { + staticInitialized = true; + + Main.Instance.ModHelper.Menus.PauseMenu.OnInit += PauseMenuInitHook; + Main.Instance.ModHelper.Menus.PauseMenu.OnClosed += CloseMenu; + Main.Instance.ModHelper.Menus.PauseMenu.OnOpened += RestoreMenuOpennessState; + + PauseMenuInitHook(); + + Main.Instance.OnChangeStarSystem.AddListener((string s) => SaveLoadedConfigsForRecentSystem()); + } + else + { + InitMenu(); + } + + if (loadedMod != null) + { + LoadMod(loadedMod); + } + } + + private void PauseMenuInitHook() + { + pauseMenuButton = Main.Instance.ModHelper.Menus.PauseMenu.OptionsButton.Duplicate(TranslationHandler.GetTranslation("Toggle Prop Placer Menu", TranslationHandler.TextType.UI).ToUpper()); + InitMenu(); + } + public static void UpdatePauseMenuButton() + { + if (pauseMenuButton != null) + { + if (Main.Debug) pauseMenuButton.Show(); + else pauseMenuButton.Hide(); + } + } + + private void RestoreMenuOpennessState() { menuOpen = openMenuOnPause; } + private void ToggleMenu() { menuOpen = !menuOpen; openMenuOnPause = !openMenuOnPause; } + + private void CloseMenu() { menuOpen = false; } + + private void LoadFavoriteProps() + { + string favoritePropsPlayerPref = PlayerPrefs.GetString(favoritePropsPlayerPrefKey); + + if (favoritePropsPlayerPref == null || favoritePropsPlayerPref == "") return; + + var favoritePropPaths = favoritePropsPlayerPref.Split(separatorCharacter); + foreach (string favoriteProp in favoritePropPaths) + { + DebugPropPlacer.RecentlyPlacedProps.Add(favoriteProp); + this.favoriteProps.Add(favoriteProp); + } + } + + private void OnGUI() + { + if (!menuOpen) return; + if (!Main.Debug) return; + + Vector2 menuPosition = new Vector2(10, 40); + + GUILayout.BeginArea(new Rect(menuPosition.x, menuPosition.y, EditorMenuSize.x, EditorMenuSize.y), _editorMenuStyle); + + // + // DebugPropPlacer + // + GUILayout.Label("Recently placed objects"); + _dpp.SetCurrentObject(GUILayout.TextArea(_dpp.currentObject)); + + GUILayout.Space(5); + + // List of recently placed objects + GUILayout.Label("Recently placed objects"); + recentPropsScrollPosition = GUILayout.BeginScrollView(recentPropsScrollPosition, GUILayout.Width(EditorMenuSize.x), GUILayout.Height(100)); + foreach (string propPath in DebugPropPlacer.RecentlyPlacedProps) + { + GUILayout.BeginHorizontal(); + + var propPathElements = propPath[propPath.Length-1] == '/' + ? propPath.Substring(0, propPath.Length-1).Split('/') + : propPath.Split('/'); + string propName = propPathElements[propPathElements.Length - 1]; + + string favoriteButtonIcon = favoriteProps.Contains(propPath) ? "★" : "☆"; + if (GUILayout.Button(favoriteButtonIcon, GUILayout.ExpandWidth(false))) + { + if (favoriteProps.Contains(propPath)) + { + favoriteProps.Remove(propPath); + } + else + { + favoriteProps.Add(propPath); + } + + string[] favoritePropsArray = favoriteProps.ToArray(); + PlayerPrefs.SetString(favoritePropsPlayerPrefKey, string.Join(separatorCharacter + "", favoritePropsArray)); + } + + if (GUILayout.Button(propName)) + { + _dpp.SetCurrentObject(propPath); + } + + GUILayout.EndHorizontal(); + } + GUILayout.EndScrollView(); + + GUILayout.Space(5); + + // continue working on existing mod + + GUILayout.Label("Name of your mod"); + if (loadedMod == null) + { + recentModListScrollPosition = GUILayout.BeginScrollView(recentModListScrollPosition, GUILayout.Width(EditorMenuSize.x), GUILayout.Height(100)); + + foreach (var mod in Main.MountedAddons) + { + if (GUILayout.Button(mod.ModHelper.Manifest.UniqueName)) + { + LoadMod(mod); + } + } + + GUILayout.EndScrollView(); + } + else + { + GUILayout.Label(loadedMod.ModHelper.Manifest.UniqueName); + } + + GUILayout.Space(5); + + // save your work + + { + GUILayout.BeginHorizontal(); + if (GUILayout.Button(saveButtonUnlocked ? " O " : " | ", GUILayout.ExpandWidth(false))) + { + saveButtonUnlocked = !saveButtonUnlocked; + } + GUI.enabled = saveButtonUnlocked; + if (GUILayout.Button("Update your mod's configs")) + { + SaveLoadedConfigsForRecentSystem(); + saveButtonUnlocked = false; + } + GUI.enabled = true; + GUILayout.EndHorizontal(); + } + + GUILayout.EndArea(); + } + + private void LoadMod(IModBehaviour mod) + { + loadedMod = mod; + DebugPropPlacer.active = true; + + var folder = loadedMod.ModHelper.Manifest.ModFolderPath; + + List bodiesForThisMod = Main.BodyDict.Values.SelectMany(x => x).Where(x => x.Mod == loadedMod).ToList(); + foreach (NewHorizonsBody body in bodiesForThisMod) + { + if (body.RelativePath == null) + { + Logger.Log("Error loading config for " + body.Config.name + " in " + body.Config.starSystem); + } + + loadedConfigFiles[folder + body.RelativePath] = (body.Config as PlanetConfig); + _dpp.FindAndRegisterPropsFromConfig(body.Config); + } + } + + private void SaveLoadedConfigsForRecentSystem() + { + UpdateLoadedConfigsForRecentSystem(); + + string backupFolderName = "configBackups\\" + DateTime.Now.ToString("yyyyMMddTHHmmss") + "\\"; + Logger.Log($"Potentially saving {loadedConfigFiles.Keys.Count} files"); + + foreach (var filePath in loadedConfigFiles.Keys) + { + Logger.Log("Possibly Saving... " + loadedConfigFiles[filePath].name + " @ " + filePath); + if (loadedConfigFiles[filePath].starSystem != Main.Instance.CurrentStarSystem) continue; + + var relativePath = filePath.Replace(loadedMod.ModHelper.Manifest.ModFolderPath, ""); + + var json = JsonConvert.SerializeObject(loadedConfigFiles[filePath], jsonSettings); + // Add the schema line + json = "{\n\t\"$schema\": \"https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/body_schema.json\"," + json.Substring(1); + + try + { + Logger.Log("Saving... " + relativePath + " to " + filePath); + var path = loadedMod.ModHelper.Manifest.ModFolderPath + relativePath; + var directoryName = Path.GetDirectoryName(path); + Directory.CreateDirectory(directoryName); + + File.WriteAllText(path, json); + } + catch (Exception e) { Logger.LogError("Failed to save file " + backupFolderName + relativePath); Logger.LogError(e.Message + "\n" + e.StackTrace); } + + try + { + var path = Main.Instance.ModHelper.Manifest.ModFolderPath + backupFolderName + relativePath; + var directoryName = Path.GetDirectoryName(path); + Directory.CreateDirectory(directoryName); + + File.WriteAllText(path, json); + } + catch (Exception e) { Logger.LogError("Failed to save backup file " + backupFolderName + relativePath); Logger.LogError(e.Message + "\n" + e.StackTrace); } + } + } + + private void UpdateLoadedConfigsForRecentSystem() + { + var newDetails = _dpp.GetPropsConfigByBody(); + + Logger.Log("Updating config files. New Details Counts by planet: " + string.Join(", ", newDetails.Keys.Select(x => x + $" ({newDetails[x].Length})"))); + + Dictionary planetToConfigPath = new Dictionary(); + + // Get all configs + foreach (var filePath in loadedConfigFiles.Keys) + { + Logger.Log("potentially updating copy of config at " + filePath); + + if (loadedConfigFiles[filePath].starSystem != Main.Instance.CurrentStarSystem) return; + if (loadedConfigFiles[filePath].name == null || AstroObjectLocator.GetAstroObject(loadedConfigFiles[filePath].name) == null) { Logger.Log("Failed to update copy of config at " + filePath); continue; } + + var astroObjectName = DebugPropPlacer.GetAstroObjectName(loadedConfigFiles[filePath].name); + planetToConfigPath[astroObjectName] = filePath; + + if (!newDetails.ContainsKey(astroObjectName)) continue; + + if (loadedConfigFiles[filePath].Props == null) loadedConfigFiles[filePath].Props = new External.Modules.PropModule(); + loadedConfigFiles[filePath].Props.details = newDetails[astroObjectName]; + + Logger.Log("successfully updated copy of config file for " + astroObjectName); + } + + // find all new planets that do not yet have config paths + var planetsThatDoNotHaveConfigFiles = newDetails.Keys.Where(x => !planetToConfigPath.ContainsKey(x)).ToList(); + foreach (var astroObjectName in planetsThatDoNotHaveConfigFiles) + { + Logger.Log("Fabricating new config file for " + astroObjectName); + + var filepath = "planets/" + Main.Instance.CurrentStarSystem + "/" + astroObjectName + ".json"; + PlanetConfig c = new PlanetConfig(); + c.starSystem = Main.Instance.CurrentStarSystem; + c.name = astroObjectName; + c.Props = new PropModule(); + c.Props.details = newDetails[astroObjectName]; + + loadedConfigFiles[filepath] = c; + } + } + + private void InitMenu() + { + if (_editorMenuStyle != null) return; + + UpdatePauseMenuButton(); + + // TODO: figure out how to clear this event list so that we don't pile up useless instances of the DebugMenu that can't get garbage collected + pauseMenuButton.OnClick += ToggleMenu; + + _dpp = this.GetRequiredComponent(); + _drc = this.GetRequiredComponent(); + + Texture2D bgTexture = ImageUtilities.MakeSolidColorTexture((int)EditorMenuSize.x, (int)EditorMenuSize.y, Color.black); + + _editorMenuStyle = new GUIStyle + { + normal = + { + background = bgTexture + } + }; + } + } +} diff --git a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs index 26f595ea..fbebff18 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs @@ -150,16 +150,16 @@ namespace NewHorizons.Utility.DebugUtilities public void FindAndRegisterPropsFromConfig(PlanetConfig config) { - if (config.StarSystem != Main.Instance.CurrentStarSystem) return; + if (config.starSystem != Main.Instance.CurrentStarSystem) return; - AstroObject planet = AstroObjectLocator.GetAstroObject(config.Name); + AstroObject planet = AstroObjectLocator.GetAstroObject(config.name); if (planet == null) return; - if (config.Props == null || config.Props.Details == null) return; + if (config.Props == null || config.Props.details == null) return; - var astroObjectName = GetAstroObjectName(config.Name); + var astroObjectName = GetAstroObjectName(config.name); - foreach (var detail in config.Props.Details) + foreach (var detail in config.Props.details) { GameObject spawnedProp = DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail); diff --git a/SchemaExporter/SchemaExporter.cs b/SchemaExporter/SchemaExporter.cs new file mode 100644 index 00000000..3d1ec172 --- /dev/null +++ b/SchemaExporter/SchemaExporter.cs @@ -0,0 +1,64 @@ +using System; +using System.IO; +using NewHorizons.External.Configs; +using NJsonSchema; +using NJsonSchema.Generation; + + +namespace SchemaExporter; + +public static class SchemaExporter +{ + private struct Schema + { + private readonly JsonSchemaGeneratorSettings _generatorSettings; + private string _title; + private readonly string _outFileName; + + public Schema(string schemaTitle, string fileName, JsonSchemaGeneratorSettings settings) + { + _title = schemaTitle; + _outFileName = fileName; + _generatorSettings = settings; + } + + public void Output() + { + File.WriteAllText($"{_outFileName}.json", ToString()); + } + + public override string ToString() + { + return GetJsonSchema().ToJson(); + } + + public JsonSchema GetJsonSchema() + { + var schema = JsonSchema.FromType(_generatorSettings); + schema.Title = _title; + return schema; + } + } + + public static void Main(string[] args) + { + const string folderName = "Schemas"; + + Directory.CreateDirectory(folderName); + Console.WriteLine("Schema Generator: We're winning!"); + var settings = new JsonSchemaGeneratorSettings + { + IgnoreObsoleteProperties = true, + }; + Console.WriteLine("Outputting Body Schema"); + var bodySchema = new Schema("Celestial Body Schema", "body_schema", settings); + bodySchema.Output(); + Console.WriteLine("Outputting Star System Schema"); + var systemSchema = new Schema("Star System Schema", "star_system_schema", settings); + systemSchema.Output(); + Console.WriteLine("Outputting Translation Schema"); + var translationSchema = new Schema("Translation Schema", "translation_schema", settings); + translationSchema.Output(); + Console.WriteLine("Done!"); + } +} \ No newline at end of file diff --git a/SchemaExporter/SchemaExporter.csproj b/SchemaExporter/SchemaExporter.csproj new file mode 100644 index 00000000..c1610f90 --- /dev/null +++ b/SchemaExporter/SchemaExporter.csproj @@ -0,0 +1,32 @@ + + + + Exe + net48 + default + true + false + false + + + portable + + + none + + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + diff --git a/SchemaExporter/System.Runtime.Serialization.dll b/SchemaExporter/System.Runtime.Serialization.dll new file mode 100644 index 00000000..e9851b7d Binary files /dev/null and b/SchemaExporter/System.Runtime.Serialization.dll differ diff --git a/SchemaExporter/UnityEngine.CoreModule.dll b/SchemaExporter/UnityEngine.CoreModule.dll new file mode 100644 index 00000000..538a4fce Binary files /dev/null and b/SchemaExporter/UnityEngine.CoreModule.dll differ