diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml index 513d04da..f90bb8ee 100644 --- a/.github/workflows/release_build.yml +++ b/.github/workflows/release_build.yml @@ -22,7 +22,7 @@ on: jobs: Build: - if: ${{ github.ref == 'refs/heads/main' || (github.event.pull_request.draft == 'false' && contains(github.event.pull_request.labels.*.name, 'update-pr')) }} + if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'update-pr') }} uses: ./.github/workflows/build.yaml with: build_type: Release @@ -43,7 +43,7 @@ jobs: Update_Release: name: 'Create/Update Release Asset' needs: Build - if: ${{ github.ref != 'refs/heads/main' && github.event.pull_request.draft == 'false' && contains(github.event.pull_request.labels.*.name, 'update-pr') }} + if: ${{ github.ref != 'refs/heads/main' && contains(github.event.pull_request.labels.*.name, 'update-pr') }} runs-on: ubuntu-latest steps: - name: Download Asset diff --git a/.github/workflows/update_release.yml b/.github/workflows/update_release.yml index 7428c467..1bad2aae 100644 --- a/.github/workflows/update_release.yml +++ b/.github/workflows/update_release.yml @@ -11,7 +11,7 @@ on: jobs: Update_Release: name: Create/Update Release - if: ${{ github.event.pull_request.draft == 'false' && contains(github.event.pull_request.labels.*.name, 'update-pr') }} + if: contains(github.event.pull_request.labels.*.name, 'update-pr') runs-on: ubuntu-latest steps: - name: Create/Update Release @@ -26,4 +26,4 @@ jobs: **Generated From PR: ${{ github.event.pull_request.html_url }}** draft: true - prerelease: false \ No newline at end of file + prerelease: false diff --git a/NewHorizons/Builder/Atmosphere/AirBuilder.cs b/NewHorizons/Builder/Atmosphere/AirBuilder.cs index 2ec48cb4..b3cda09b 100644 --- a/NewHorizons/Builder/Atmosphere/AirBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/AirBuilder.cs @@ -1,10 +1,11 @@ +using NewHorizons.External.Configs; using NewHorizons.External.Modules; using UnityEngine; namespace NewHorizons.Builder.Atmosphere { public static class AirBuilder { - public static void Make(GameObject planetGO, Sector sector, AtmosphereModule.AirInfo info) + public static void Make(GameObject planetGO, Sector sector, PlanetConfig config) { GameObject airGO = new GameObject("Air"); airGO.SetActive(false); @@ -13,7 +14,7 @@ namespace NewHorizons.Builder.Atmosphere SphereCollider sc = airGO.AddComponent(); sc.isTrigger = true; - sc.radius = info.scale; + sc.radius = config.Atmosphere.size; SimpleFluidVolume sfv = airGO.AddComponent(); sfv._layer = 5; @@ -26,15 +27,29 @@ namespace NewHorizons.Builder.Atmosphere ShockLayerRuleset shockLayerRuleset = planetGO.GetComponentInChildren().gameObject.AddComponent(); shockLayerRuleset._type = ShockLayerRuleset.ShockType.Atmospheric; shockLayerRuleset._radialCenter = airGO.transform; - shockLayerRuleset._innerRadius = 0; - shockLayerRuleset._outerRadius = info.scale; + shockLayerRuleset._minShockSpeed = config.Atmosphere.minShockSpeed; + shockLayerRuleset._maxShockSpeed = config.Atmosphere.maxShockSpeed; - if (info.hasOxygen) + if (config.Atmosphere.clouds != null) + { + shockLayerRuleset._innerRadius = config.Atmosphere.clouds.innerCloudRadius; + shockLayerRuleset._outerRadius = config.Atmosphere.clouds.outerCloudRadius; + } + else + { + var bottom = config.Base.surfaceSize; + var top = config.Atmosphere.size; + + shockLayerRuleset._innerRadius = (bottom + top) / 2f; + shockLayerRuleset._outerRadius = top; + } + + if (config.Atmosphere.hasOxygen) { airGO.AddComponent(); } - if (info.isRaining) + if (config.Atmosphere.hasRain) { var vref = airGO.AddComponent(); vref._rainDirection = VisorRainEffectVolume.RainDirection.Radial; diff --git a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs index 1ff3df9e..0271e8ed 100644 --- a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs @@ -1,11 +1,12 @@ -using NewHorizons.External.Modules; +using NewHorizons.External.Configs; +using NewHorizons.External.Modules; using NewHorizons.Utility; using UnityEngine; namespace NewHorizons.Builder.Atmosphere { public static class EffectsBuilder { - public static void Make(GameObject planetGO, Sector sector, AtmosphereModule.AirInfo info, float surfaceSize) + public static void Make(GameObject planetGO, Sector sector, PlanetConfig config, float surfaceSize) { GameObject effectsGO = new GameObject("Effects"); effectsGO.SetActive(false); @@ -19,7 +20,7 @@ namespace NewHorizons.Builder.Atmosphere SCG._dynamicCullingBounds = false; SCG._waitForStreaming = false; - if (info.isRaining) + if (config.Atmosphere.hasRain) { var rainGO = GameObject.Instantiate(SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain"), effectsGO.transform); rainGO.transform.position = planetGO.transform.position; @@ -29,7 +30,7 @@ namespace NewHorizons.Builder.Atmosphere { new Keyframe(surfaceSize - 0.5f, 0), new Keyframe(surfaceSize, 10f), - new Keyframe(info.scale, 0f) + new Keyframe(config.Atmosphere.size, 0f) }); rainGO.GetComponent()._activeInSector = sector; @@ -37,7 +38,7 @@ namespace NewHorizons.Builder.Atmosphere rainGO.SetActive(true); } - if (info.isSnowing) + if (config.Atmosphere.hasSnow) { var snowGO = new GameObject("SnowEffects"); snowGO.transform.parent = effectsGO.transform; @@ -53,7 +54,7 @@ namespace NewHorizons.Builder.Atmosphere { new Keyframe(surfaceSize - 0.5f, 0), new Keyframe(surfaceSize, 10f), - new Keyframe(info.scale, 0f) + new Keyframe(config.Atmosphere.size, 0f) }); snowEmitter.GetComponent()._activeInSector = sector; diff --git a/NewHorizons/Builder/Atmosphere/FogBuilder.cs b/NewHorizons/Builder/Atmosphere/FogBuilder.cs index d5fd4cd1..4de64a9e 100644 --- a/NewHorizons/Builder/Atmosphere/FogBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/FogBuilder.cs @@ -7,6 +7,13 @@ namespace NewHorizons.Builder.Atmosphere { private static Texture2D _ramp; + private static readonly int FogTexture = Shader.PropertyToID("_FogTex"); + private static readonly int Tint = Shader.PropertyToID("_Tint"); + private static readonly int Radius = Shader.PropertyToID("_Radius"); + private static readonly int Density = Shader.PropertyToID("_Density"); + private static readonly int DensityExponent = Shader.PropertyToID("_DensityExp"); + private static readonly int ColorRampTexture = Shader.PropertyToID("_ColorRampTex"); + public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo) { if (_ramp == null) _ramp = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/FogColorRamp.png"); @@ -14,7 +21,7 @@ namespace NewHorizons.Builder.Atmosphere GameObject fogGO = new GameObject("FogSphere"); fogGO.SetActive(false); fogGO.transform.parent = sector?.transform ?? planetGO.transform; - fogGO.transform.localScale = Vector3.one; + fogGO.transform.localScale = Vector3.one * atmo.fogSize; // Going to copy from dark bramble var dbFog = SearchUtilities.Find("DarkBramble_Body/Atmosphere_DB/FogLOD"); @@ -28,14 +35,23 @@ namespace NewHorizons.Builder.Atmosphere MR.allowOcclusionWhenDynamic = true; PlanetaryFogController PFC = fogGO.AddComponent(); + PFC._fogImpostor = MR; PFC.fogLookupTexture = dbPlanetaryFogController.fogLookupTexture; PFC.fogRadius = atmo.fogSize; + PFC.lodFadeDistance = PFC.fogRadius * 0.5f; PFC.fogDensity = atmo.fogDensity; PFC.fogExponent = 1f; - PFC.fogColorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); + var colorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); + PFC.fogColorRampTexture = colorRampTexture; PFC.fogColorRampIntensity = 1f; PFC.fogTint = atmo.fogTint.ToColor(); + MR.material.SetColor(Tint, atmo.fogTint.ToColor()); + MR.material.SetFloat(Radius, atmo.fogSize); + MR.material.SetFloat(Density, atmo.fogDensity); + MR.material.SetFloat(DensityExponent, 1); + MR.material.SetTexture(ColorRampTexture, colorRampTexture); + fogGO.transform.position = planetGO.transform.position; fogGO.SetActive(true); diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 8e7e3750..237335bb 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -235,6 +235,11 @@ namespace NewHorizons.Builder.Body fog._fogRadius *= scale; fog._fogDensity *= scale; + var volumesShape = volumes.FindChild("ZeroG_Fluid_Audio_Volume"); + var sphereShape = volumesShape.GetComponent(); + sphereShape.enabled = true; // this starts disabled for some fucking reason + sphereShape.radius *= scale; + // Change fog color if (body.Config.Bramble.dimension.fogTint != null) { @@ -248,7 +253,13 @@ namespace NewHorizons.Builder.Body var cloak = repelVolume.gameObject.GetComponentInChildren(); cloak.transform.localScale = Vector3.one * 4000f; cloak._sectors = new Sector[] { sector }; + cloak.GetComponent().enabled = true; + // fix the fog backdrop + atmo.GetComponent()._sector = sector; + atmo.GetComponent()._sector = sector; + + // finalize atmo.SetActive(true); volumes.SetActive(true); effects.SetActive(true); diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 270b9915..8266b9d4 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -16,8 +16,6 @@ namespace NewHorizons.Builder.Body private static Texture2D _colorOverTime; private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp"); private static readonly int SkyColor = Shader.PropertyToID("_SkyColor"); - private static readonly int AtmosFar = Shader.PropertyToID("_AtmosFar"); - private static readonly int AtmosNear = Shader.PropertyToID("_AtmosNear"); private static readonly int Tint = Shader.PropertyToID("_Tint"); private static readonly int Radius = Shader.PropertyToID("_Radius"); private static readonly int InnerRadius = Shader.PropertyToID("_InnerRadius"); @@ -54,8 +52,6 @@ namespace NewHorizons.Builder.Body 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); } diff --git a/NewHorizons/Components/QuantumPlanet.cs b/NewHorizons/Components/QuantumPlanet.cs index bce7d9a2..2b853b76 100644 --- a/NewHorizons/Components/QuantumPlanet.cs +++ b/NewHorizons/Components/QuantumPlanet.cs @@ -53,7 +53,7 @@ namespace NewHorizons.Components public int GetRandomNewState() { - var range = Enumerable.Range(0, states.Count - 1).Where(i => i != CurrentIndex); + var range = Enumerable.Range(0, states.Count).Where(i => i != CurrentIndex); var index = Random.Range(0, range.Count()); return range.ElementAt(index); } diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index 0a0e2024..2da729c6 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -55,6 +55,8 @@ namespace NewHorizons.Components.SizeControllers private float maxScale; private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp"); + private Color _currentColour; + void Start() { var sun = GameObject.FindObjectOfType(); @@ -114,7 +116,7 @@ namespace NewHorizons.Components.SizeControllers _atmosphereRenderers = atmosphere?.transform?.Find("AtmoSphere")?.GetComponentsInChildren(); } - if (WillExplode) GlobalMessenger.AddListener("TriggerSupernova", Die); + if (WillExplode) GlobalMessenger.AddListener("TriggerSupernova", StartCollapse); if (scaleCurve != null) { @@ -132,7 +134,7 @@ namespace NewHorizons.Components.SizeControllers public void OnDestroy() { - if (WillExplode) GlobalMessenger.RemoveListener("TriggerSupernova", Die); + if (WillExplode) GlobalMessenger.RemoveListener("TriggerSupernova", StartCollapse); } public void SetProxy(StarEvolutionController proxy) @@ -141,88 +143,111 @@ namespace NewHorizons.Components.SizeControllers _proxy.supernova.SetIsProxy(true); } - public void Die() + private void UpdateMainSequence() { + // Only do colour transition stuff if they set an end colour + if (EndColour != null) + { + // Use the age if theres no resizing happening, else make it get redder the larger it is or wtv + var t = _age / (lifespan * 60f); + if (maxScale > 0) t = CurrentScale / maxScale; + if (t < 1f) + { + _currentColour = Color.Lerp(_startColour, _endColour, t); + supernova._surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, t); + } + else + { + _currentColour = _endColour; + } + } + else + { + _currentColour = _startColour; + } + + if (_flareEmitter != null) _flareEmitter._tint = _currentColour; + } + + private void UpdateCollapse() + { + // When its collapsing we directly take over the scale + var t = _collapseTimer / collapseTime; + CurrentScale = Mathf.Lerp(_collapseStartSize, 0, t); + transform.localScale = Vector3.one * CurrentScale; + _collapseTimer += Time.deltaTime; + + _currentColour = Color.Lerp(_endColour, Color.white, t); + + supernova._surface._materials[0].Lerp(_collapseStartSurfaceMaterial, _collapseEndSurfaceMaterial, t); + + // After the collapse is done we go supernova + if (_collapseTimer > collapseTime) StartSupernova(); + } + + private void UpdateSupernova() + { + // Reset the scale back to normal bc now its just the supernova scaling itself + destruction and heat volumes + transform.localScale = Vector3.one; + + // Make the destruction volume scale slightly smaller so you really have to be in the supernova to die + if (_destructionVolume != null) _destructionVolume.transform.localScale = Vector3.one * supernova.GetSupernovaRadius() * 0.9f; + if (_heatVolume != null) _heatVolume.transform.localScale = Vector3.one * supernova.GetSupernovaRadius(); + + if (Time.time > _supernovaStartTime + 45f) + { + // Just turn off the star entirely + base.gameObject.SetActive(false); + } + } + + public void StartCollapse() + { + Logger.LogVerbose($"{gameObject.transform.root.name} started collapse"); + _isCollapsing = true; _collapseStartSize = CurrentScale; _collapseTimer = 0f; supernova._surface._materials[0].CopyPropertiesFromMaterial(_collapseStartSurfaceMaterial); - if (_proxy != null) _proxy.Die(); + if (_proxy != null) _proxy.StartCollapse(); + } + + private void StartSupernova() + { + Logger.LogVerbose($"{gameObject.transform.root.name} started supernova"); + + SupernovaStart.Invoke(); + supernova.enabled = true; + _isSupernova = true; + _supernovaStartTime = Time.time; + if (atmosphere != null) atmosphere.SetActive(false); + if (_destructionVolume != null) _destructionVolume._deathType = DeathType.Supernova; } protected new void FixedUpdate() { _age += Time.deltaTime; - var ageValue = _age / (lifespan * 60f); - // If we've gone supernova and its been 45 seconds that means it has faded out and is gone // The 45 is from the animation curve used for the supernova alpha if (_isSupernova) { - // Reset the scale back to normal bc now its just the supernova scaling itself + destruction and heat volumes - transform.localScale = Vector3.one; - - // Make the destruction volume scale slightly smaller so you really have to be in the supernova to die - if (_destructionVolume != null) _destructionVolume.transform.localScale = Vector3.one * supernova.GetSupernovaRadius() * 0.9f; - if (_heatVolume != null) _heatVolume.transform.localScale = Vector3.one * supernova.GetSupernovaRadius(); - - if (Time.time > _supernovaStartTime + 45f) - { - // Just turn off the star entirely - base.gameObject.SetActive(false); - } + UpdateSupernova(); return; } - - Color currentColour; - + if (!_isCollapsing) { base.FixedUpdate(); - - // Only do colour transition stuff if they set an end colour - if (EndColour != null) - { - // Use the age if theres no resizing happening, else make it get redder the larger it is or wtv - var t = ageValue; - if (maxScale > 0) t = CurrentScale / maxScale; - currentColour = Color.Lerp(_startColour, _endColour, t); - supernova._surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, t); - } - else - { - currentColour = _startColour; - } - - if (_flareEmitter != null) _flareEmitter._tint = currentColour; + UpdateMainSequence(); } else { - // When its collapsing we directly take over the scale - var t = _collapseTimer / collapseTime; - CurrentScale = Mathf.Lerp(_collapseStartSize, 0, t); - transform.localScale = Vector3.one * CurrentScale; - _collapseTimer += Time.deltaTime; - - currentColour = Color.Lerp(_endColour, Color.white, t); - - supernova._surface._materials[0].Lerp(_collapseStartSurfaceMaterial, _collapseEndSurfaceMaterial, t); - - // After the collapse is done we go supernova - if (_collapseTimer > collapseTime) - { - SupernovaStart.Invoke(); - supernova.enabled = true; - _isSupernova = true; - _supernovaStartTime = Time.time; - if (atmosphere != null) atmosphere.SetActive(false); - if (_destructionVolume != null) _destructionVolume._deathType = DeathType.Supernova; - return; - } + UpdateCollapse(); + if (_isSupernova) return; } - + // This is just all the scales stuff for the atmosphere effects if (_fog != null) { @@ -230,8 +255,8 @@ namespace NewHorizons.Components.SizeControllers _fog.lodFadeDistance = CurrentScale * StarBuilder.OuterRadiusRatio / 3f; // The colour thing goes over one - var max = Math.Max(currentColour.g, Math.Max(currentColour.b, currentColour.r)); - var fogColour = currentColour / max / 1.5f; + var max = Math.Max(_currentColour.g, Math.Max(_currentColour.b, _currentColour.r)); + var fogColour = _currentColour / max / 1.5f; fogColour.a = 1f; _fog.fogTint = fogColour; _fog._fogTint = fogColour; @@ -243,9 +268,9 @@ namespace NewHorizons.Components.SizeControllers { lod.material.SetFloat("_InnerRadius", CurrentScale); lod.material.SetFloat("_OuterRadius", CurrentScale * StarBuilder.OuterRadiusRatio); - lod.material.SetColor("_AtmosFar", currentColour); - lod.material.SetColor("_AtmosNear", currentColour); - lod.material.SetColor("_SkyColor", currentColour); + + // These break once it reaches endColour and I have no idea why + //lod.material.SetColor("_SkyColor", _currentColour); } } } diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index d4ef8224..7f662072 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -182,6 +182,54 @@ namespace NewHorizons.External.Configs if (Atmosphere?.clouds?.lightningGradient != null) Atmosphere.clouds.hasLightning = true; if (Bramble?.dimension != null && Orbit?.staticPosition == null) throw new Exception($"Dimension {name} must have Orbit.staticPosition defined."); if (Orbit?.staticPosition != null) Orbit.isStatic = true; + + // For each quantum group, verify the following: + // this group's id should be unique + // if type == sockets, group.sockets should not be null or empty + // if type == sockets, count every prop that references this group. the number should be < group.sockets.Count + // if type == sockets, for each socket, if rotation == null, rotation = Vector3.zero + // if type == sockets, for each socket, position must not be null + // For each detail prop, + // if detail.quantumGroupID != null, there exists a quantum group with that id + if (Props?.quantumGroups != null && Props?.details != null) + { + Dictionary existingGroups = new Dictionary(); + foreach (var quantumGroup in Props.quantumGroups) + { + if (existingGroups.ContainsKey(quantumGroup.id)) { Logger.LogWarning($"Duplicate quantumGroup id found: {quantumGroup.id}"); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } + + existingGroups[quantumGroup.id] = quantumGroup; + if (quantumGroup.type == PropModule.QuantumGroupType.Sockets) + { + if (quantumGroup.sockets?.Length == 0) { Logger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" but has no defined sockets."); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } + else + { + foreach (var socket in quantumGroup.sockets) + { + if (socket.rotation == null) socket.rotation = UnityEngine.Vector3.zero; + if (socket.position == null) { Logger.LogError($"quantumGroup {quantumGroup.id} has a socket without a position."); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } + } + } + } + } + + Dictionary existingGroupsPropCounts = new Dictionary(); + foreach (var prop in Props?.details) + { + if (prop.quantumGroupID == null) continue; + if (!existingGroups.ContainsKey(prop.quantumGroupID)) Logger.LogWarning($"A prop wants to be a part of quantum group {prop.quantumGroupID}, but this group does not exist."); + else existingGroupsPropCounts[prop.quantumGroupID] = existingGroupsPropCounts.GetValueOrDefault(prop.quantumGroupID) + 1; + } + + foreach (var quantumGroup in Props.quantumGroups) + { + if (quantumGroup.type == PropModule.QuantumGroupType.Sockets && existingGroupsPropCounts.GetValueOrDefault(quantumGroup.id) >= quantumGroup.sockets?.Length) + { + Logger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" and has more props than sockets."); + quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; + } + } + } } public void Migrate() @@ -258,55 +306,6 @@ namespace NewHorizons.External.Configs if (Base.sphereOfInfluence != 0f) Base.soiOverride = Base.sphereOfInfluence; - // for each quantum group, verify the following: - // this group's id should be unique - // if type == sockets, group.sockets should not be null or empty - // if type == sockets, count every prop that references this group. the number should be < group.sockets.Count - // if type == sockets, for each socket, if rotation == null, rotation = Vector3.zero - // if type == sockets, for each socket, position must not be null - // for each detail prop, - // if detail.quantumGroupID != null, there exists a quantum group with that id - - if (Props?.quantumGroups != null && Props?.details != null) - { - Dictionary existingGroups = new Dictionary(); - foreach (var quantumGroup in Props.quantumGroups) - { - if (existingGroups.ContainsKey(quantumGroup.id)) { NewHorizons.Utility.Logger.LogWarning($"Duplicate quantumGroup id found: {quantumGroup.id}"); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } - - existingGroups[quantumGroup.id] = quantumGroup; - if (quantumGroup.type == PropModule.QuantumGroupType.Sockets) - { - if (quantumGroup.sockets?.Length == 0) { NewHorizons.Utility.Logger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" but has no defined sockets."); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } - else - { - foreach (var socket in quantumGroup.sockets) - { - if (socket.rotation == null) socket.rotation = UnityEngine.Vector3.zero; - if (socket.position == null) { NewHorizons.Utility.Logger.LogError($"quantumGroup {quantumGroup.id} has a socket without a position."); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } - } - } - } - } - - Dictionary existingGroupsPropCounts = new Dictionary(); - foreach (var prop in Props?.details) - { - if (prop.quantumGroupID == null) continue; - if (!existingGroups.ContainsKey(prop.quantumGroupID)) NewHorizons.Utility.Logger.LogWarning($"A prop wants to be a part of quantum group {prop.quantumGroupID}, but this group does not exist."); - else existingGroupsPropCounts[prop.quantumGroupID] = existingGroupsPropCounts.GetValueOrDefault(prop.quantumGroupID)+1; - } - - foreach (var quantumGroup in Props.quantumGroups) - { - if (quantumGroup.type == PropModule.QuantumGroupType.Sockets && existingGroupsPropCounts.GetValueOrDefault(quantumGroup.id) >= quantumGroup.sockets?.Length) - { - NewHorizons.Utility.Logger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" and has more props than sockets."); - quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; - } - } - } - // Moved a bunch of stuff off of shiplog module to star system module because it didnt exist when we made this if (ShipLog != null) { diff --git a/NewHorizons/External/Modules/AtmosphereModule.cs b/NewHorizons/External/Modules/AtmosphereModule.cs index c22a4c14..b0f31bc9 100644 --- a/NewHorizons/External/Modules/AtmosphereModule.cs +++ b/NewHorizons/External/Modules/AtmosphereModule.cs @@ -86,14 +86,15 @@ namespace NewHorizons.External.Modules /// public bool useAtmosphereShader; - // not an actual config thing, rip - public class AirInfo - { - public bool hasOxygen; - public bool isRaining; - public bool isSnowing; - public float scale; - } + /// + /// Minimum speed that your ship can go in the atmosphere where flames will appear. + /// + [DefaultValue(100f)] public float minShockSpeed = 100f; + + /// + /// Maximum speed that your ship can go in the atmosphere where flames will appear at their brightest. + /// + [DefaultValue(300f)] public float maxShockSpeed = 300f; [JsonObject] public class CloudInfo diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 91b10b3f..2bfb3532 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -529,17 +529,9 @@ namespace NewHorizons.Handlers if (body.Config.Atmosphere != null) { - 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 - }; - var surfaceSize = body.Config.Base.surfaceSize; - AirBuilder.Make(go, sector, airInfo); + AirBuilder.Make(go, sector, body.Config); if (!string.IsNullOrEmpty(body.Config.Atmosphere?.clouds?.texturePath)) { @@ -548,7 +540,7 @@ namespace NewHorizons.Handlers } if (body.Config.Atmosphere.hasRain || body.Config.Atmosphere.hasSnow) - EffectsBuilder.Make(go, sector, airInfo, surfaceSize); + EffectsBuilder.Make(go, sector, body.Config, surfaceSize); if (body.Config.Atmosphere.fogSize != 0) FogBuilder.Make(go, sector, body.Config.Atmosphere); diff --git a/NewHorizons/Patches/BramblePatches.cs b/NewHorizons/Patches/BramblePatches.cs new file mode 100644 index 00000000..bbd5e33b --- /dev/null +++ b/NewHorizons/Patches/BramblePatches.cs @@ -0,0 +1,31 @@ +using HarmonyLib; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NewHorizons.Patches +{ + [HarmonyPatch] + public class BramblePatches + { + [HarmonyPrefix] + [HarmonyPatch(typeof(SphericalFogWarpVolume), nameof(SphericalFogWarpVolume.IsProbeOnly))] + public static bool SphericalFogWarpVolume_IsProbeOnly(SphericalFogWarpVolume __instance, ref bool __result) + { + __result = false; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(FogWarpVolume), nameof(FogWarpVolume.GetFogThickness))] + public static bool FogWarpVolume_GetFogThickness(FogWarpVolume __instance, ref float __result) + { + if (__instance is InnerFogWarpVolume sph) __result = sph._exitRadius; + else __result = 50; // 50f is hardcoded as the return value in the base game + + return false; + } + } +} diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 1184fc26..a28c26ca 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -286,6 +286,18 @@ "useAtmosphereShader": { "type": "boolean", "description": "Whether we use an atmospheric shader on the planet. Doesn't affect clouds, fog, rain, snow, oxygen, etc. Purely\nvisual." + }, + "minShockSpeed": { + "type": "number", + "description": "Minimum speed that your ship can go in the atmosphere where flames will appear.", + "format": "float", + "default": 100.0 + }, + "maxShockSpeed": { + "type": "number", + "description": "Maximum speed that your ship can go in the atmosphere where flames will appear at their brightest.", + "format": "float", + "default": 300.0 } } },