From 3e99fb5bd835245b8c498ed279a9a580dc3c986d Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Thu, 14 Jul 2022 16:45:22 -0500 Subject: [PATCH 01/12] Star collapse ramp texture and fix end color --- NewHorizons/Builder/Body/StarBuilder.cs | 20 ++++++-- .../StarEvolutionController.cs | 48 +++++++++++++------ .../Modules/VariableSize/StarModule.cs | 5 ++ NewHorizons/Schemas/body_schema.json | 4 ++ 4 files changed, 58 insertions(+), 19 deletions(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 27d52206..143f52dc 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -137,9 +137,19 @@ namespace NewHorizons.Builder.Body 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?.ToColor(); + controller.endColour = starModule.tint != null ? starModule.tint.ToColor() * 4.5948f : null; + controller.willExplode = starModule.goSupernova; + if (!string.IsNullOrEmpty(starModule.starRampTexture)) + { + var ramp = ImageUtilities.GetTexture(mod, starModule.starRampTexture); + controller.normalRamp = ramp; + } + if (!string.IsNullOrEmpty(starModule.starCollapseRampTexture)) + { + var ramp = ImageUtilities.GetTexture(mod, starModule.starCollapseRampTexture); + controller.collapseRamp = ramp; + } surfaceAudio.SetStarEvolutionController(controller); starGO.SetActive(true); @@ -177,8 +187,8 @@ namespace NewHorizons.Builder.Body if (starModule.curve != null) controller.SetScaleCurve(starModule.curve); controller.size = starModule.size; controller.supernova = supernova; - controller.StartColour = starModule.tint; - controller.EndColour = starModule.endTint; + controller.startColour = starModule.tint?.ToColor(); + controller.endColour = starModule.tint != null ? starModule.tint.ToColor() * 4.5948f : null; controller.enabled = true; starGO.SetActive(true); diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index d27486fb..054ade43 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -15,9 +15,11 @@ namespace NewHorizons.Components.SizeControllers { public GameObject atmosphere; public SupernovaEffectController supernova; - public bool WillExplode { get; set; } - public MColor StartColour { get; set; } - public MColor EndColour { get; set; } + public bool willExplode; + public Color? startColour; + public Color? endColour; + public Texture normalRamp; + public Texture collapseRamp; private Color _startColour; private Color _endColour; @@ -43,6 +45,8 @@ namespace NewHorizons.Components.SizeControllers private Material _collapseEndSurfaceMaterial; private Material _startSurfaceMaterial; private Material _endSurfaceMaterial; + private Texture _normalRamp; + private Texture _collapseRamp; private StarEvolutionController _proxy; @@ -60,31 +64,45 @@ namespace NewHorizons.Components.SizeControllers _endSurfaceMaterial = new Material(sun._endSurfaceMaterial); var supernovaSurfaceColorRamp = supernova._surface.sharedMaterial.GetTexture(ColorRamp); + if (normalRamp == null) + { + _normalRamp = supernovaSurfaceColorRamp; + } else + { + _normalRamp = normalRamp; + } + if (collapseRamp == null) + { + _collapseRamp = supernovaSurfaceColorRamp; + } else + { + _collapseRamp = collapseRamp; + } // Copy over the material that was set in star builder - _collapseStartSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); - _collapseEndSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); - _startSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); - _endSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); + _collapseStartSurfaceMaterial.SetTexture(ColorRamp, _collapseRamp); + _collapseEndSurfaceMaterial.SetTexture(ColorRamp, _collapseRamp); + _startSurfaceMaterial.SetTexture(ColorRamp, _normalRamp); + _endSurfaceMaterial.SetTexture(ColorRamp, _normalRamp); - if (StartColour == null) + if (startColour == null) { _startColour = _startSurfaceMaterial.color; } else { - _startColour = StartColour.ToColor(); + _startColour = startColour.Value; _startSurfaceMaterial.color = _startColour; } - if (EndColour == null) + if (endColour == null) { _endColour = _startColour; _endSurfaceMaterial.color = _startColour; } else { - _endColour = EndColour.ToColor(); + _endColour = endColour.Value; _endSurfaceMaterial.color = _endColour; } @@ -97,7 +115,7 @@ namespace NewHorizons.Components.SizeControllers _atmosphereRenderers = atmosphere?.transform?.Find("AtmoSphere")?.GetComponentsInChildren(); } - if (WillExplode) GlobalMessenger.AddListener("TriggerSupernova", Die); + if (willExplode) GlobalMessenger.AddListener("TriggerSupernova", Die); if (scaleCurve != null) { @@ -115,7 +133,7 @@ namespace NewHorizons.Components.SizeControllers public void OnDestroy() { - if (WillExplode) GlobalMessenger.RemoveListener("TriggerSupernova", Die); + if (willExplode) GlobalMessenger.RemoveListener("TriggerSupernova", Die); } public void SetProxy(StarEvolutionController proxy) @@ -165,12 +183,13 @@ namespace NewHorizons.Components.SizeControllers base.FixedUpdate(); // Only do colour transition stuff if they set an end colour - if (EndColour != null) + 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].SetTexture(ColorRamp, _normalRamp); supernova._surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, t); } else @@ -190,6 +209,7 @@ namespace NewHorizons.Components.SizeControllers currentColour = Color.Lerp(_endColour, Color.white, t); + supernova._surface._materials[0].SetTexture(ColorRamp, _collapseRamp); supernova._surface._materials[0].Lerp(_collapseStartSurfaceMaterial, _collapseEndSurfaceMaterial, t); // After the collapse is done we go supernova diff --git a/NewHorizons/External/Modules/VariableSize/StarModule.cs b/NewHorizons/External/Modules/VariableSize/StarModule.cs index 627fca8c..ea303ab0 100644 --- a/NewHorizons/External/Modules/VariableSize/StarModule.cs +++ b/NewHorizons/External/Modules/VariableSize/StarModule.cs @@ -61,6 +61,11 @@ namespace NewHorizons.External.Modules.VariableSize /// public string starRampTexture; + /// + /// Path to the texture to put as the star ramp while it is collapsing. Optional. + /// + public string starCollapseRampTexture; + /// /// How far the light from the star can reach. /// diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 61b75b12..9626080c 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1968,6 +1968,10 @@ "type": "string", "description": "Path to the texture to put as the star ramp. Optional." }, + "starRampCollapseTexture": { + "type": "string", + "description": "Path to the texture to put as the star ramp while it is collapsing. Optional." + }, "lightRadius": { "type": "number", "description": "How far the light from the star can reach.", From 2e00233253ebed84a20b630f110ea147136e8f99 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 14 Jul 2022 21:48:18 +0000 Subject: [PATCH 02/12] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 9626080c..7e079ea6 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1968,7 +1968,7 @@ "type": "string", "description": "Path to the texture to put as the star ramp. Optional." }, - "starRampCollapseTexture": { + "starCollapseRampTexture": { "type": "string", "description": "Path to the texture to put as the star ramp while it is collapsing. Optional." }, From ee1efa4d50e0b00326f5776d85792a454f7bc25c Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Thu, 14 Jul 2022 16:50:21 -0500 Subject: [PATCH 03/12] Get default ramps --- .../Components/SizeControllers/StarEvolutionController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index 054ade43..698ae02d 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -66,14 +66,14 @@ namespace NewHorizons.Components.SizeControllers var supernovaSurfaceColorRamp = supernova._surface.sharedMaterial.GetTexture(ColorRamp); if (normalRamp == null) { - _normalRamp = supernovaSurfaceColorRamp; + _normalRamp = sun._startSurfaceMaterial.GetTexture(ColorRamp); } else { _normalRamp = normalRamp; } if (collapseRamp == null) { - _collapseRamp = supernovaSurfaceColorRamp; + _collapseRamp = sun._collapseStartSurfaceMaterial.GetTexture(ColorRamp); } else { _collapseRamp = collapseRamp; From 71c18ac3f03fadf9ca04891721d0d88587ebf128 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Thu, 14 Jul 2022 16:53:35 -0500 Subject: [PATCH 04/12] Only override collapse ramp --- .../Components/SizeControllers/StarEvolutionController.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index 698ae02d..89cf8e99 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -147,6 +147,7 @@ namespace NewHorizons.Components.SizeControllers _isCollapsing = true; _collapseStartSize = CurrentScale; _collapseTimer = 0f; + supernova._surface._materials[0].SetTexture(ColorRamp, _collapseRamp); if (_proxy != null) _proxy.Die(); } @@ -189,7 +190,6 @@ namespace NewHorizons.Components.SizeControllers var t = ageValue; if (maxScale > 0) t = CurrentScale / maxScale; currentColour = Color.Lerp(_startColour, _endColour, t); - supernova._surface._materials[0].SetTexture(ColorRamp, _normalRamp); supernova._surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, t); } else @@ -209,7 +209,6 @@ namespace NewHorizons.Components.SizeControllers currentColour = Color.Lerp(_endColour, Color.white, t); - supernova._surface._materials[0].SetTexture(ColorRamp, _collapseRamp); supernova._surface._materials[0].Lerp(_collapseStartSurfaceMaterial, _collapseEndSurfaceMaterial, t); // After the collapse is done we go supernova From 124d2dc4a1f37f5470a6e74acb8fb373c66ce371 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Thu, 14 Jul 2022 16:57:46 -0500 Subject: [PATCH 05/12] Remove unused mat --- .../Components/SizeControllers/StarEvolutionController.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index 89cf8e99..525b13f0 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -63,7 +63,6 @@ namespace NewHorizons.Components.SizeControllers _startSurfaceMaterial = new Material(sun._startSurfaceMaterial); _endSurfaceMaterial = new Material(sun._endSurfaceMaterial); - var supernovaSurfaceColorRamp = supernova._surface.sharedMaterial.GetTexture(ColorRamp); if (normalRamp == null) { _normalRamp = sun._startSurfaceMaterial.GetTexture(ColorRamp); @@ -147,7 +146,7 @@ namespace NewHorizons.Components.SizeControllers _isCollapsing = true; _collapseStartSize = CurrentScale; _collapseTimer = 0f; - supernova._surface._materials[0].SetTexture(ColorRamp, _collapseRamp); + supernova._surface._materials[0].CopyPropertiesFromMaterial(_collapseStartSurfaceMaterial); if (_proxy != null) _proxy.Die(); } From 8f63a67c84a27f0adc5adedc004f1ef78492c96c Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Thu, 14 Jul 2022 19:30:42 -0400 Subject: [PATCH 06/12] Turn down by a lot --- NewHorizons/Builder/Body/StarBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 143f52dc..38fb6310 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -222,7 +222,7 @@ namespace NewHorizons.Builder.Body foreach (var controller in solarFlareEmitter.GetComponentsInChildren()) { // It multiplies color by tint but wants something very bright idk - controller._color = new Color(11, 11, 11); + controller._color = new Color(2, 2, 2); controller.GetComponent().sharedMaterial.SetColor("_Color", controller._color); controller._tint = flareTint; } From d64d5d11724ded1ef969c705811e656373daddb2 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Thu, 14 Jul 2022 19:44:54 -0400 Subject: [PATCH 07/12] Just make it 1 --- NewHorizons/Builder/Body/StarBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 38fb6310..d7a1d994 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -222,7 +222,7 @@ namespace NewHorizons.Builder.Body foreach (var controller in solarFlareEmitter.GetComponentsInChildren()) { // It multiplies color by tint but wants something very bright idk - controller._color = new Color(2, 2, 2); + controller._color = new Color(1, 1, 1); controller.GetComponent().sharedMaterial.SetColor("_Color", controller._color); controller._tint = flareTint; } From 3f4c71a935eb8c677c8563026da97b21d02b4cda Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Thu, 14 Jul 2022 19:02:08 -0500 Subject: [PATCH 08/12] Revert changes --- NewHorizons/Builder/Body/StarBuilder.cs | 10 +++++----- .../StarEvolutionController.cs | 20 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 143f52dc..d7c60fe6 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -137,9 +137,9 @@ namespace NewHorizons.Builder.Body controller.size = starModule.size; controller.atmosphere = sunAtmosphere; controller.supernova = supernova; - controller.startColour = starModule.tint?.ToColor(); - controller.endColour = starModule.tint != null ? starModule.tint.ToColor() * 4.5948f : null; - controller.willExplode = starModule.goSupernova; + controller.StartColour = starModule.tint; + controller.EndColour = starModule.endTint; + controller.WillExplode = starModule.goSupernova; if (!string.IsNullOrEmpty(starModule.starRampTexture)) { var ramp = ImageUtilities.GetTexture(mod, starModule.starRampTexture); @@ -187,8 +187,8 @@ namespace NewHorizons.Builder.Body if (starModule.curve != null) controller.SetScaleCurve(starModule.curve); controller.size = starModule.size; controller.supernova = supernova; - controller.startColour = starModule.tint?.ToColor(); - controller.endColour = starModule.tint != null ? starModule.tint.ToColor() * 4.5948f : null; + controller.StartColour = starModule.tint; + controller.EndColour = starModule.endTint; controller.enabled = true; starGO.SetActive(true); diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index 525b13f0..dc1cf7d6 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -15,9 +15,9 @@ namespace NewHorizons.Components.SizeControllers { public GameObject atmosphere; public SupernovaEffectController supernova; - public bool willExplode; - public Color? startColour; - public Color? endColour; + public bool WillExplode { get; set; } + public MColor StartColour { get; set; } + public MColor EndColour { get; set; } public Texture normalRamp; public Texture collapseRamp; @@ -84,24 +84,24 @@ namespace NewHorizons.Components.SizeControllers _startSurfaceMaterial.SetTexture(ColorRamp, _normalRamp); _endSurfaceMaterial.SetTexture(ColorRamp, _normalRamp); - if (startColour == null) + if (StartColour == null) { _startColour = _startSurfaceMaterial.color; } else { - _startColour = startColour.Value; + _startColour = StartColour.ToColor(); _startSurfaceMaterial.color = _startColour; } - if (endColour == null) + if (EndColour == null) { _endColour = _startColour; _endSurfaceMaterial.color = _startColour; } else { - _endColour = endColour.Value; + _endColour = EndColour.ToColor(); _endSurfaceMaterial.color = _endColour; } @@ -114,7 +114,7 @@ namespace NewHorizons.Components.SizeControllers _atmosphereRenderers = atmosphere?.transform?.Find("AtmoSphere")?.GetComponentsInChildren(); } - if (willExplode) GlobalMessenger.AddListener("TriggerSupernova", Die); + if (WillExplode) GlobalMessenger.AddListener("TriggerSupernova", Die); if (scaleCurve != null) { @@ -132,7 +132,7 @@ namespace NewHorizons.Components.SizeControllers public void OnDestroy() { - if (willExplode) GlobalMessenger.RemoveListener("TriggerSupernova", Die); + if (WillExplode) GlobalMessenger.RemoveListener("TriggerSupernova", Die); } public void SetProxy(StarEvolutionController proxy) @@ -183,7 +183,7 @@ namespace NewHorizons.Components.SizeControllers base.FixedUpdate(); // Only do colour transition stuff if they set an end colour - if (endColour != null) + 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; From d145e43a776ce3e5c74244984b05bd8c6af4a164 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Thu, 14 Jul 2022 19:02:23 -0500 Subject: [PATCH 09/12] Make surface end color based on start color --- .../Components/SizeControllers/StarEvolutionController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index dc1cf7d6..0a0e2024 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -102,7 +102,7 @@ namespace NewHorizons.Components.SizeControllers else { _endColour = EndColour.ToColor(); - _endSurfaceMaterial.color = _endColour; + _endSurfaceMaterial.color = _startColour * 4.5948f; } _heatVolume = GetComponentInChildren(); From a3501190ae39ef0b593d7cf69a15ad243091adab Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Thu, 14 Jul 2022 20:21:22 -0400 Subject: [PATCH 10/12] Fix impostor fog --- NewHorizons/Builder/Body/StarBuilder.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index fa58a597..f747742d 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -18,6 +18,8 @@ namespace NewHorizons.Builder.Body 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"); private static readonly int OuterRadius = Shader.PropertyToID("_OuterRadius"); @@ -44,9 +46,11 @@ namespace NewHorizons.Builder.Body sunAtmosphere.transform.localScale = Vector3.one * OuterRadiusRatio; sunAtmosphere.name = "Atmosphere_Star"; var fog = sunAtmosphere.transform.Find("FogSphere").GetComponent(); + var fogFar = fog.fogImpostor.material; if (starModule.tint != null) { fog.fogTint = starModule.tint.ToColor(); + fog.fogImpostor.material.SetColor(Tint, starModule.tint.ToColor()); sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one; foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren()) { @@ -60,6 +64,7 @@ namespace NewHorizons.Builder.Body fog.transform.localScale = Vector3.one; fog.fogRadius = starModule.size * OuterRadiusRatio; fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f); + fog.fogImpostor.material.SetFloat(Radius, starModule.size * OuterRadiusRatio); } var ambientLightGO = Object.Instantiate(SearchUtilities.Find("Sun_Body/AmbientLight_SUN"), starGO.transform); From 164c7417fd429ccc9d83aae4dbf482cde078cdfb Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Thu, 14 Jul 2022 20:24:24 -0400 Subject: [PATCH 11/12] Forgor --- NewHorizons/Builder/Body/StarBuilder.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index f747742d..270b9915 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -46,7 +46,6 @@ namespace NewHorizons.Builder.Body sunAtmosphere.transform.localScale = Vector3.one * OuterRadiusRatio; sunAtmosphere.name = "Atmosphere_Star"; var fog = sunAtmosphere.transform.Find("FogSphere").GetComponent(); - var fogFar = fog.fogImpostor.material; if (starModule.tint != null) { fog.fogTint = starModule.tint.ToColor(); From 04c1d7cce07a1e55d8b58cf7c7a4130a1392bcac Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 14 Jul 2022 20:25:54 -0400 Subject: [PATCH 12/12] Fix NRE in NomaiTextBuilder --- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index 435e13fa..8f71830c 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -365,43 +365,42 @@ namespace NewHorizons.Builder.Props { GameObject arc; var type = arcInfo != null ? arcInfo.type : PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult; - var variation = arcInfo.variation; + var variation = arcInfo == null ? arcInfo.variation : -1; switch (type) { case PropModule.NomaiTextArcInfo.NomaiTextArcType.Child: - variation = arcInfo.variation < 0 + variation = variation < 0 ? Random.Range(0, _childArcPrefabs.Count()) - : (arcInfo.variation % _childArcPrefabs.Count()); + : (variation % _childArcPrefabs.Count()); arc = _childArcPrefabs[variation].InstantiateInactive(); break; case PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcPrefabs.Any(): - variation = arcInfo.variation < 0 + variation = variation < 0 ? Random.Range(0, _ghostArcPrefabs.Count()) - : (arcInfo.variation % _ghostArcPrefabs.Count()); + : (variation % _ghostArcPrefabs.Count()); arc = _ghostArcPrefabs[variation].InstantiateInactive(); break; case PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult: default: - variation = arcInfo.variation < 0 + variation = variation < 0 ? Random.Range(0, _arcPrefabs.Count()) - : (arcInfo.variation % _arcPrefabs.Count()); + : (variation % _arcPrefabs.Count()); arc = _arcPrefabs[variation].InstantiateInactive(); break; } - arcInfo.variation = variation; arc.transform.parent = conversationZone.transform; arc.GetComponent()._prebuilt = false; if (arcInfo != null) { - var a = arcInfo; - if (a.position == null) arc.transform.localPosition = Vector3.zero; - else arc.transform.localPosition = new Vector3(a.position.x, a.position.y, 0); + arcInfo.variation = variation; + if (arcInfo.position == null) arc.transform.localPosition = Vector3.zero; + else arc.transform.localPosition = new Vector3(arcInfo.position.x, arcInfo.position.y, 0); - arc.transform.localRotation = Quaternion.Euler(0, 0, a.zRotation); + arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation); - if (a.mirror) arc.transform.localScale = new Vector3(-1, 1, 1); + if (arcInfo.mirror) arc.transform.localScale = new Vector3(-1, 1, 1); } // Try auto I guess else @@ -425,7 +424,7 @@ namespace NewHorizons.Builder.Props arc.SetActive(true); - arcInfoToCorrespondingSpawnedGameObject[arcInfo] = arc; + if (arcInfo != null) arcInfoToCorrespondingSpawnedGameObject[arcInfo] = arc; return arc; }