Fix some stuff add more clouds

This commit is contained in:
Nick 2024-02-03 19:08:12 -05:00
parent 95641bc249
commit a091c88a93
3 changed files with 32 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

View File

@ -30,6 +30,8 @@ public class SplashColourizer : MonoBehaviour
private bool _probeInsideVolume;
private List<Texture> _customTextures = new();
public void Awake()
{
var volume = new GameObject("Volume");
@ -210,6 +212,12 @@ public class SplashColourizer : MonoBehaviour
var meshRenderers = prefab.GetComponentsInChildren<MeshRenderer>(true);
foreach (var meshRenderer in meshRenderers)
{
if (_customTextures.Contains(meshRenderer.material.mainTexture))
{
// Might be some shared material stuff? This image is already tinted, so skip it
continue;
}
// Can't access the textures in memory so we need to have our own copies
var texture = ImageUtilities.GetTexture(Main.Instance, $"Assets/textures/{meshRenderer.material.mainTexture.name}.png");
if (texture == null)
@ -218,6 +226,9 @@ public class SplashColourizer : MonoBehaviour
GameObject.Destroy(prefab);
flagError = true;
}
_customTextures.Add(texture);
meshRenderer.material = new(meshRenderer.material)
{
color = Color.white,
@ -251,6 +262,16 @@ public class SplashColourizer : MonoBehaviour
}
public void SetProbeSplashEffects(bool entering)
{
_probeInsideVolume = entering;
if (_probeDetector != null)
{
SetSplashEffects(_probeDetector, entering);
}
}
public void Update()
{
// Probe detector keeps being null, I hate my life
if (_probeDetector == null)
@ -261,12 +282,5 @@ public class SplashColourizer : MonoBehaviour
CachePrefabs(_probeDetector);
}
}
_probeInsideVolume = entering;
if (_probeDetector != null)
{
SetSplashEffects(_probeDetector, entering);
}
}
}

View File

@ -39,7 +39,17 @@ namespace NewHorizons.Utility.Files
return null;
}
// Copied from OWML but without the print statement lol
var path = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, filename);
string path;
try
{
path = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, filename);
}
catch (Exception e)
{
NHLogger.LogError($"Invalid path: Couldn't combine {mod.ModHelper.Manifest.ModFolderPath} {filename} - {e}");
return null;
}
var key = GetKey(path);
if (_textureCache.TryGetValue(key, out var existingTexture))
{