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.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using System; using System;
using UnityEngine; using UnityEngine;
@ -92,27 +93,30 @@ namespace NewHorizons.Builder.Atmosphere
// min height override for backwards compat // min height override for backwards compat
minHeight = surfaceHeight ?? minHeight; minHeight = surfaceHeight ?? minHeight;
foreach (var particleField in config.ParticleFields) if (config.ParticleFields != null)
{ {
var prefab = GetPrefabByType(particleField.type); foreach (var particleField in config.ParticleFields)
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[]
{ {
new Keyframe(minHeight - 0.5f, 0), var prefab = GetPrefabByType(particleField.type);
new Keyframe(minHeight, 10f), var emitter = GameObject.Instantiate(prefab, effectsGO.transform);
new Keyframe(maxHeight, 0f) emitter.name = !string.IsNullOrWhiteSpace(particleField.rename) ? particleField.rename : prefab.name.Replace("Prefab_", "");
}); emitter.transform.position = planetGO.transform.position;
pvc._followTarget = particleField.followTarget == ParticleFieldModule.FollowTarget.Probe ? PlanetaryVectionController.FollowTarget.Probe : PlanetaryVectionController.FollowTarget.Player;
pvc._activeInSector = sector;
pvc._exclusionSectors = new Sector[] { };
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; effectsGO.transform.position = planetGO.transform.position;

View File

@ -1,7 +1,9 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props;
using NewHorizons.Utility; using NewHorizons.Utility;
using NewHorizons.Utility.Files; using NewHorizons.Utility.Files;
using OWML.Common; using OWML.Common;
using System;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Atmosphere 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(); 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) public static PlanetaryFogController Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
{ {
InitPrefabs(); InitPrefabs();

View File

@ -33,6 +33,11 @@ namespace NewHorizons.Utility.Files
// bug: cache only considers file path, not wrap/mips/linear. oh well // 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) 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 // Copied from OWML but without the print statement lol
var path = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, filename); var path = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, filename);
var key = GetKey(path); var key = GetKey(path);