Fix ramp being null for some reason

This commit is contained in:
Nick 2024-03-23 15:53:45 -04:00
parent ad63eacbd8
commit 44141ad5c4

View File

@ -1,10 +1,10 @@
using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props;
using NewHorizons.Utility;
using NewHorizons.Utility.Files;
using OWML.Common;
using System;
using UnityEngine;
namespace NewHorizons.Builder.Atmosphere
{
public static class FogBuilder
@ -26,7 +26,9 @@ namespace NewHorizons.Builder.Atmosphere
internal static void InitPrefabs()
{
if (_ramp == null) _ramp = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/FogColorRamp.png");
// Checking null here it was getting destroyed and wouldnt reload and never worked outside of the first loop
// GetTexture caches itself anyway so it doesn't matter that this gets called multiple times
_ramp = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/FogColorRamp.png");
if (_isInit) return;
@ -73,6 +75,7 @@ namespace NewHorizons.Builder.Atmosphere
atmo.fogRampPath != null ? ImageUtilities.GetTexture(mod, atmo.fogRampPath) :
atmo.fogTint != null ? ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()) :
_ramp;
PFC.fogColorRampTexture = colorRampTexture;
PFC.fogColorRampIntensity = 1f;
if (atmo.fogTint != null)