Merge branch 'dev' into height-map-resolution

This commit is contained in:
JohnCorby 2022-07-14 21:01:00 -07:00
commit 6c4d4154c1
14 changed files with 253 additions and 154 deletions

View File

@ -22,7 +22,7 @@ on:
jobs: jobs:
Build: 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 uses: ./.github/workflows/build.yaml
with: with:
build_type: Release build_type: Release
@ -43,7 +43,7 @@ jobs:
Update_Release: Update_Release:
name: 'Create/Update Release Asset' name: 'Create/Update Release Asset'
needs: Build 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 runs-on: ubuntu-latest
steps: steps:
- name: Download Asset - name: Download Asset

View File

@ -11,7 +11,7 @@ on:
jobs: jobs:
Update_Release: Update_Release:
name: Create/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 runs-on: ubuntu-latest
steps: steps:
- name: Create/Update Release - name: Create/Update Release

View File

@ -1,10 +1,11 @@
using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Atmosphere namespace NewHorizons.Builder.Atmosphere
{ {
public static class AirBuilder 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"); GameObject airGO = new GameObject("Air");
airGO.SetActive(false); airGO.SetActive(false);
@ -13,7 +14,7 @@ namespace NewHorizons.Builder.Atmosphere
SphereCollider sc = airGO.AddComponent<SphereCollider>(); SphereCollider sc = airGO.AddComponent<SphereCollider>();
sc.isTrigger = true; sc.isTrigger = true;
sc.radius = info.scale; sc.radius = config.Atmosphere.size;
SimpleFluidVolume sfv = airGO.AddComponent<SimpleFluidVolume>(); SimpleFluidVolume sfv = airGO.AddComponent<SimpleFluidVolume>();
sfv._layer = 5; sfv._layer = 5;
@ -26,15 +27,29 @@ namespace NewHorizons.Builder.Atmosphere
ShockLayerRuleset shockLayerRuleset = planetGO.GetComponentInChildren<PlanetoidRuleset>().gameObject.AddComponent<ShockLayerRuleset>(); ShockLayerRuleset shockLayerRuleset = planetGO.GetComponentInChildren<PlanetoidRuleset>().gameObject.AddComponent<ShockLayerRuleset>();
shockLayerRuleset._type = ShockLayerRuleset.ShockType.Atmospheric; shockLayerRuleset._type = ShockLayerRuleset.ShockType.Atmospheric;
shockLayerRuleset._radialCenter = airGO.transform; shockLayerRuleset._radialCenter = airGO.transform;
shockLayerRuleset._innerRadius = 0; shockLayerRuleset._minShockSpeed = config.Atmosphere.minShockSpeed;
shockLayerRuleset._outerRadius = info.scale; 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<OxygenVolume>(); airGO.AddComponent<OxygenVolume>();
} }
if (info.isRaining) if (config.Atmosphere.hasRain)
{ {
var vref = airGO.AddComponent<VisorRainEffectVolume>(); var vref = airGO.AddComponent<VisorRainEffectVolume>();
vref._rainDirection = VisorRainEffectVolume.RainDirection.Radial; vref._rainDirection = VisorRainEffectVolume.RainDirection.Radial;

View File

@ -1,11 +1,12 @@
using NewHorizons.External.Modules; using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Atmosphere namespace NewHorizons.Builder.Atmosphere
{ {
public static class EffectsBuilder 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"); GameObject effectsGO = new GameObject("Effects");
effectsGO.SetActive(false); effectsGO.SetActive(false);
@ -19,7 +20,7 @@ namespace NewHorizons.Builder.Atmosphere
SCG._dynamicCullingBounds = false; SCG._dynamicCullingBounds = false;
SCG._waitForStreaming = 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); 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; rainGO.transform.position = planetGO.transform.position;
@ -29,7 +30,7 @@ namespace NewHorizons.Builder.Atmosphere
{ {
new Keyframe(surfaceSize - 0.5f, 0), new Keyframe(surfaceSize - 0.5f, 0),
new Keyframe(surfaceSize, 10f), new Keyframe(surfaceSize, 10f),
new Keyframe(info.scale, 0f) new Keyframe(config.Atmosphere.size, 0f)
}); });
rainGO.GetComponent<PlanetaryVectionController>()._activeInSector = sector; rainGO.GetComponent<PlanetaryVectionController>()._activeInSector = sector;
@ -37,7 +38,7 @@ namespace NewHorizons.Builder.Atmosphere
rainGO.SetActive(true); rainGO.SetActive(true);
} }
if (info.isSnowing) if (config.Atmosphere.hasSnow)
{ {
var snowGO = new GameObject("SnowEffects"); var snowGO = new GameObject("SnowEffects");
snowGO.transform.parent = effectsGO.transform; snowGO.transform.parent = effectsGO.transform;
@ -53,7 +54,7 @@ namespace NewHorizons.Builder.Atmosphere
{ {
new Keyframe(surfaceSize - 0.5f, 0), new Keyframe(surfaceSize - 0.5f, 0),
new Keyframe(surfaceSize, 10f), new Keyframe(surfaceSize, 10f),
new Keyframe(info.scale, 0f) new Keyframe(config.Atmosphere.size, 0f)
}); });
snowEmitter.GetComponent<PlanetaryVectionController>()._activeInSector = sector; snowEmitter.GetComponent<PlanetaryVectionController>()._activeInSector = sector;

View File

@ -7,6 +7,13 @@ namespace NewHorizons.Builder.Atmosphere
{ {
private static Texture2D _ramp; 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) public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo)
{ {
if (_ramp == null) _ramp = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/FogColorRamp.png"); 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"); GameObject fogGO = new GameObject("FogSphere");
fogGO.SetActive(false); fogGO.SetActive(false);
fogGO.transform.parent = sector?.transform ?? planetGO.transform; 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 // Going to copy from dark bramble
var dbFog = SearchUtilities.Find("DarkBramble_Body/Atmosphere_DB/FogLOD"); var dbFog = SearchUtilities.Find("DarkBramble_Body/Atmosphere_DB/FogLOD");
@ -28,14 +35,23 @@ namespace NewHorizons.Builder.Atmosphere
MR.allowOcclusionWhenDynamic = true; MR.allowOcclusionWhenDynamic = true;
PlanetaryFogController PFC = fogGO.AddComponent<PlanetaryFogController>(); PlanetaryFogController PFC = fogGO.AddComponent<PlanetaryFogController>();
PFC._fogImpostor = MR;
PFC.fogLookupTexture = dbPlanetaryFogController.fogLookupTexture; PFC.fogLookupTexture = dbPlanetaryFogController.fogLookupTexture;
PFC.fogRadius = atmo.fogSize; PFC.fogRadius = atmo.fogSize;
PFC.lodFadeDistance = PFC.fogRadius * 0.5f;
PFC.fogDensity = atmo.fogDensity; PFC.fogDensity = atmo.fogDensity;
PFC.fogExponent = 1f; 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.fogColorRampIntensity = 1f;
PFC.fogTint = atmo.fogTint.ToColor(); 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.transform.position = planetGO.transform.position;
fogGO.SetActive(true); fogGO.SetActive(true);

View File

@ -235,6 +235,11 @@ namespace NewHorizons.Builder.Body
fog._fogRadius *= scale; fog._fogRadius *= scale;
fog._fogDensity *= scale; fog._fogDensity *= scale;
var volumesShape = volumes.FindChild("ZeroG_Fluid_Audio_Volume");
var sphereShape = volumesShape.GetComponent<SphereShape>();
sphereShape.enabled = true; // this starts disabled for some fucking reason
sphereShape.radius *= scale;
// Change fog color // Change fog color
if (body.Config.Bramble.dimension.fogTint != null) if (body.Config.Bramble.dimension.fogTint != null)
{ {
@ -248,7 +253,13 @@ namespace NewHorizons.Builder.Body
var cloak = repelVolume.gameObject.GetComponentInChildren<DarkBrambleCloakSphere>(); var cloak = repelVolume.gameObject.GetComponentInChildren<DarkBrambleCloakSphere>();
cloak.transform.localScale = Vector3.one * 4000f; cloak.transform.localScale = Vector3.one * 4000f;
cloak._sectors = new Sector[] { sector }; cloak._sectors = new Sector[] { sector };
cloak.GetComponent<Renderer>().enabled = true;
// fix the fog backdrop
atmo.GetComponent<SectorCullGroup>()._sector = sector;
atmo.GetComponent<SectorLightsCullGroup>()._sector = sector;
// finalize
atmo.SetActive(true); atmo.SetActive(true);
volumes.SetActive(true); volumes.SetActive(true);
effects.SetActive(true); effects.SetActive(true);

View File

@ -16,8 +16,6 @@ namespace NewHorizons.Builder.Body
private static Texture2D _colorOverTime; private static Texture2D _colorOverTime;
private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp"); private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp");
private static readonly int SkyColor = Shader.PropertyToID("_SkyColor"); 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 Tint = Shader.PropertyToID("_Tint");
private static readonly int Radius = Shader.PropertyToID("_Radius"); private static readonly int Radius = Shader.PropertyToID("_Radius");
private static readonly int InnerRadius = Shader.PropertyToID("_InnerRadius"); 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<MeshRenderer>()) foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren<MeshRenderer>())
{ {
lod.material.SetColor(SkyColor, starModule.tint.ToColor()); 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(InnerRadius, starModule.size);
lod.material.SetFloat(OuterRadius, starModule.size * OuterRadiusRatio); lod.material.SetFloat(OuterRadius, starModule.size * OuterRadiusRatio);
} }

View File

@ -53,7 +53,7 @@ namespace NewHorizons.Components
public int GetRandomNewState() 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()); var index = Random.Range(0, range.Count());
return range.ElementAt(index); return range.ElementAt(index);
} }

View File

@ -55,6 +55,8 @@ namespace NewHorizons.Components.SizeControllers
private float maxScale; private float maxScale;
private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp"); private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp");
private Color _currentColour;
void Start() void Start()
{ {
var sun = GameObject.FindObjectOfType<SunController>(); var sun = GameObject.FindObjectOfType<SunController>();
@ -114,7 +116,7 @@ namespace NewHorizons.Components.SizeControllers
_atmosphereRenderers = atmosphere?.transform?.Find("AtmoSphere")?.GetComponentsInChildren<MeshRenderer>(); _atmosphereRenderers = atmosphere?.transform?.Find("AtmoSphere")?.GetComponentsInChildren<MeshRenderer>();
} }
if (WillExplode) GlobalMessenger.AddListener("TriggerSupernova", Die); if (WillExplode) GlobalMessenger.AddListener("TriggerSupernova", StartCollapse);
if (scaleCurve != null) if (scaleCurve != null)
{ {
@ -132,7 +134,7 @@ namespace NewHorizons.Components.SizeControllers
public void OnDestroy() public void OnDestroy()
{ {
if (WillExplode) GlobalMessenger.RemoveListener("TriggerSupernova", Die); if (WillExplode) GlobalMessenger.RemoveListener("TriggerSupernova", StartCollapse);
} }
public void SetProxy(StarEvolutionController proxy) public void SetProxy(StarEvolutionController proxy)
@ -141,25 +143,49 @@ namespace NewHorizons.Components.SizeControllers
_proxy.supernova.SetIsProxy(true); _proxy.supernova.SetIsProxy(true);
} }
public void Die() private void UpdateMainSequence()
{ {
_isCollapsing = true; // Only do colour transition stuff if they set an end colour
_collapseStartSize = CurrentScale; if (EndColour != null)
_collapseTimer = 0f; {
supernova._surface._materials[0].CopyPropertiesFromMaterial(_collapseStartSurfaceMaterial); // 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 (_proxy != null) _proxy.Die(); 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;
} }
protected new void FixedUpdate() if (_flareEmitter != null) _flareEmitter._tint = _currentColour;
}
private void UpdateCollapse()
{ {
_age += Time.deltaTime; // 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;
var ageValue = _age / (lifespan * 60f); _currentColour = Color.Lerp(_endColour, Color.white, t);
// If we've gone supernova and its been 45 seconds that means it has faded out and is gone supernova._surface._materials[0].Lerp(_collapseStartSurfaceMaterial, _collapseEndSurfaceMaterial, t);
// The 45 is from the animation curve used for the supernova alpha
if (_isSupernova) // 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 // Reset the scale back to normal bc now its just the supernova scaling itself + destruction and heat volumes
transform.localScale = Vector3.one; transform.localScale = Vector3.one;
@ -173,54 +199,53 @@ namespace NewHorizons.Components.SizeControllers
// Just turn off the star entirely // Just turn off the star entirely
base.gameObject.SetActive(false); base.gameObject.SetActive(false);
} }
return;
} }
Color currentColour; public void StartCollapse()
{
Logger.LogVerbose($"{gameObject.transform.root.name} started collapse");
if (!_isCollapsing) _isCollapsing = true;
{ _collapseStartSize = CurrentScale;
base.FixedUpdate(); _collapseTimer = 0f;
supernova._surface._materials[0].CopyPropertiesFromMaterial(_collapseStartSurfaceMaterial);
// Only do colour transition stuff if they set an end colour if (_proxy != null) _proxy.StartCollapse();
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; private void StartSupernova()
}
else
{ {
// When its collapsing we directly take over the scale Logger.LogVerbose($"{gameObject.transform.root.name} started supernova");
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(); SupernovaStart.Invoke();
supernova.enabled = true; supernova.enabled = true;
_isSupernova = true; _isSupernova = true;
_supernovaStartTime = Time.time; _supernovaStartTime = Time.time;
if (atmosphere != null) atmosphere.SetActive(false); if (atmosphere != null) atmosphere.SetActive(false);
if (_destructionVolume != null) _destructionVolume._deathType = DeathType.Supernova; if (_destructionVolume != null) _destructionVolume._deathType = DeathType.Supernova;
}
protected new void FixedUpdate()
{
_age += Time.deltaTime;
// 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)
{
UpdateSupernova();
return; return;
} }
if (!_isCollapsing)
{
base.FixedUpdate();
UpdateMainSequence();
}
else
{
UpdateCollapse();
if (_isSupernova) return;
} }
// This is just all the scales stuff for the atmosphere effects // This is just all the scales stuff for the atmosphere effects
@ -230,8 +255,8 @@ namespace NewHorizons.Components.SizeControllers
_fog.lodFadeDistance = CurrentScale * StarBuilder.OuterRadiusRatio / 3f; _fog.lodFadeDistance = CurrentScale * StarBuilder.OuterRadiusRatio / 3f;
// The colour thing goes over one // The colour thing goes over one
var max = Math.Max(currentColour.g, Math.Max(currentColour.b, currentColour.r)); var max = Math.Max(_currentColour.g, Math.Max(_currentColour.b, _currentColour.r));
var fogColour = currentColour / max / 1.5f; var fogColour = _currentColour / max / 1.5f;
fogColour.a = 1f; fogColour.a = 1f;
_fog.fogTint = fogColour; _fog.fogTint = fogColour;
_fog._fogTint = fogColour; _fog._fogTint = fogColour;
@ -243,9 +268,9 @@ namespace NewHorizons.Components.SizeControllers
{ {
lod.material.SetFloat("_InnerRadius", CurrentScale); lod.material.SetFloat("_InnerRadius", CurrentScale);
lod.material.SetFloat("_OuterRadius", CurrentScale * StarBuilder.OuterRadiusRatio); lod.material.SetFloat("_OuterRadius", CurrentScale * StarBuilder.OuterRadiusRatio);
lod.material.SetColor("_AtmosFar", currentColour);
lod.material.SetColor("_AtmosNear", currentColour); // These break once it reaches endColour and I have no idea why
lod.material.SetColor("_SkyColor", currentColour); //lod.material.SetColor("_SkyColor", _currentColour);
} }
} }
} }

View File

@ -182,6 +182,54 @@ namespace NewHorizons.External.Configs
if (Atmosphere?.clouds?.lightningGradient != null) Atmosphere.clouds.hasLightning = true; 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 (Bramble?.dimension != null && Orbit?.staticPosition == null) throw new Exception($"Dimension {name} must have Orbit.staticPosition defined.");
if (Orbit?.staticPosition != null) Orbit.isStatic = true; 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<string, PropModule.QuantumGroupInfo> existingGroups = new Dictionary<string, PropModule.QuantumGroupInfo>();
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<string, int> existingGroupsPropCounts = new Dictionary<string, int>();
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() public void Migrate()
@ -258,55 +306,6 @@ namespace NewHorizons.External.Configs
if (Base.sphereOfInfluence != 0f) Base.soiOverride = Base.sphereOfInfluence; 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<string, PropModule.QuantumGroupInfo> existingGroups = new Dictionary<string, PropModule.QuantumGroupInfo>();
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<string, int> existingGroupsPropCounts = new Dictionary<string, int>();
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 // Moved a bunch of stuff off of shiplog module to star system module because it didnt exist when we made this
if (ShipLog != null) if (ShipLog != null)
{ {

View File

@ -86,14 +86,15 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
public bool useAtmosphereShader; public bool useAtmosphereShader;
// not an actual config thing, rip /// <summary>
public class AirInfo /// Minimum speed that your ship can go in the atmosphere where flames will appear.
{ /// </summary>
public bool hasOxygen; [DefaultValue(100f)] public float minShockSpeed = 100f;
public bool isRaining;
public bool isSnowing; /// <summary>
public float scale; /// Maximum speed that your ship can go in the atmosphere where flames will appear at their brightest.
} /// </summary>
[DefaultValue(300f)] public float maxShockSpeed = 300f;
[JsonObject] [JsonObject]
public class CloudInfo public class CloudInfo

View File

@ -529,17 +529,9 @@ namespace NewHorizons.Handlers
if (body.Config.Atmosphere != null) 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; 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)) if (!string.IsNullOrEmpty(body.Config.Atmosphere?.clouds?.texturePath))
{ {
@ -548,7 +540,7 @@ namespace NewHorizons.Handlers
} }
if (body.Config.Atmosphere.hasRain || body.Config.Atmosphere.hasSnow) 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) if (body.Config.Atmosphere.fogSize != 0)
FogBuilder.Make(go, sector, body.Config.Atmosphere); FogBuilder.Make(go, sector, body.Config.Atmosphere);

View File

@ -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;
}
}
}

View File

@ -286,6 +286,18 @@
"useAtmosphereShader": { "useAtmosphereShader": {
"type": "boolean", "type": "boolean",
"description": "Whether we use an atmospheric shader on the planet. Doesn't affect clouds, fog, rain, snow, oxygen, etc. Purely\nvisual." "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
} }
} }
}, },