curse you stalker of dreams

This commit is contained in:
Noah Pilarski 2024-01-01 23:55:16 -05:00
parent bcfe939d9d
commit aedeb80f16
3 changed files with 37 additions and 18 deletions

View File

@ -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<VectionFieldEmitter>();
var pvc = emitter.GetComponent<PlanetaryVectionController>();
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<VectionFieldEmitter>();
var pvc = emitter.GetComponent<PlanetaryVectionController>();
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;

View File

@ -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<MeshRenderer>().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();

View File

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