diff --git a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs index 9ac3a509..fdb4b923 100644 --- a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.External.Configs; using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.OWML; using System; using UnityEngine; @@ -92,27 +93,30 @@ namespace NewHorizons.Builder.Atmosphere // min height override for backwards compat minHeight = surfaceHeight ?? minHeight; - foreach (var particleField in config.ParticleFields) + if (config.ParticleFields != null) { - var prefab = GetPrefabByType(particleField.type); - var emitter = GameObject.Instantiate(prefab, effectsGO.transform); - emitter.name = !string.IsNullOrWhiteSpace(particleField.rename) ? particleField.rename : prefab.name.Replace("Prefab_", ""); - emitter.transform.position = planetGO.transform.position; - - var vfe = emitter.GetComponent(); - var pvc = emitter.GetComponent(); - pvc._vectionFieldEmitter = vfe; - pvc._densityByHeight = particleField.densityByHeightCurve != null ? particleField.densityByHeightCurve.ToAnimationCurve() : new AnimationCurve(new Keyframe[] + foreach (var particleField in config.ParticleFields) { - new Keyframe(minHeight - 0.5f, 0), - new Keyframe(minHeight, 10f), - new Keyframe(maxHeight, 0f) - }); - pvc._followTarget = particleField.followTarget == ParticleFieldModule.FollowTarget.Probe ? PlanetaryVectionController.FollowTarget.Probe : PlanetaryVectionController.FollowTarget.Player; - pvc._activeInSector = sector; - pvc._exclusionSectors = new Sector[] { }; + var prefab = GetPrefabByType(particleField.type); + var emitter = GameObject.Instantiate(prefab, effectsGO.transform); + emitter.name = !string.IsNullOrWhiteSpace(particleField.rename) ? particleField.rename : prefab.name.Replace("Prefab_", ""); + emitter.transform.position = planetGO.transform.position; - emitter.SetActive(true); + var vfe = emitter.GetComponent(); + var pvc = emitter.GetComponent(); + pvc._vectionFieldEmitter = vfe; + pvc._densityByHeight = particleField.densityByHeightCurve != null ? particleField.densityByHeightCurve.ToAnimationCurve() : new AnimationCurve(new Keyframe[] + { + new Keyframe(minHeight - 0.5f, 0), + new Keyframe(minHeight, 10f), + new Keyframe(maxHeight, 0f) + }); + pvc._followTarget = particleField.followTarget == ParticleFieldModule.FollowTarget.Probe ? PlanetaryVectionController.FollowTarget.Probe : PlanetaryVectionController.FollowTarget.Player; + pvc._activeInSector = sector; + pvc._exclusionSectors = new Sector[] { }; + + emitter.SetActive(true); + } } effectsGO.transform.position = planetGO.transform.position; diff --git a/NewHorizons/Builder/Atmosphere/FogBuilder.cs b/NewHorizons/Builder/Atmosphere/FogBuilder.cs index 8c1025bc..9f1d7da8 100644 --- a/NewHorizons/Builder/Atmosphere/FogBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/FogBuilder.cs @@ -1,7 +1,9 @@ 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 { @@ -36,6 +38,14 @@ namespace NewHorizons.Builder.Atmosphere if (_dbImpostorMaterials == null) _dbImpostorMaterials = SearchUtilities.Find("DarkBramble_Body/Atmosphere_DB/FogLOD").GetComponent().sharedMaterials.MakePrefabMaterials(); } + #region obsolete + // Never change method signatures, people directly reference the NH dll and it can break backwards compatibility + // Dreamstalker needs this method signature + [Obsolete] + public static PlanetaryFogController Make(GameObject planetGO, Sector sector, AtmosphereModule atmo) + => Make(planetGO, sector, atmo, null); + #endregion + public static PlanetaryFogController Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod) { InitPrefabs(); diff --git a/NewHorizons/Utility/Files/ImageUtilities.cs b/NewHorizons/Utility/Files/ImageUtilities.cs index 413690ce..742e5310 100644 --- a/NewHorizons/Utility/Files/ImageUtilities.cs +++ b/NewHorizons/Utility/Files/ImageUtilities.cs @@ -33,6 +33,11 @@ namespace NewHorizons.Utility.Files // bug: cache only considers file path, not wrap/mips/linear. oh well public static Texture2D GetTexture(IModBehaviour mod, string filename, bool useMipmaps = true, bool wrap = false, bool linear = false) { + if (mod == null) + { + NHLogger.LogError("Couldn't get texture, mod is null."); + return null; + } // Copied from OWML but without the print statement lol var path = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, filename); var key = GetKey(path);