## Bug fixes

- Fix looping crash of obsolete effects builder method
- Re-added even more missing method signatures that were breaking
Dreamstalker (just update your mod xen!)
- Tessellated renderers in asset bundles will now have their shaders
replaced just like normal renderers
This commit is contained in:
Noah Pilarski 2024-01-02 00:47:33 -05:00 committed by GitHub
commit e8aecf2890
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 78 additions and 27 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;
@ -55,15 +56,15 @@ namespace NewHorizons.Builder.Atmosphere
#region obsolete
// Never change method signatures, people directly reference the NH dll and it can break backwards compatability
// Never change method signatures, people directly reference the NH dll and it can break backwards compatibility
// Dreamstalker needed this one
[Obsolete]
public static void Make(GameObject planetGO, Sector sector, PlanetConfig config, float surfaceHeight)
=> Make(planetGO, sector, config, surfaceHeight);
=> InternalMake(planetGO, sector, config, surfaceHeight);
#endregion
public static void Make(GameObject planetGO, Sector sector, PlanetConfig config)
=> Make(planetGO, sector, config, null);
=> InternalMake(planetGO, sector, config, null);
/// <summary>
/// Nullable surface height for backwards compat
@ -72,7 +73,7 @@ namespace NewHorizons.Builder.Atmosphere
/// <param name="sector"></param>
/// <param name="config"></param>
/// <param name="surfaceHeight"></param>
private static void Make(GameObject planetGO, Sector sector, PlanetConfig config, float? surfaceHeight)
private static void InternalMake(GameObject planetGO, Sector sector, PlanetConfig config, float? surfaceHeight)
{
InitPrefabs();
@ -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

@ -28,7 +28,7 @@ namespace NewHorizons.Builder.Props
}
#region obsolete
// Never change method signatures, people directly reference the NH dll and it can break backwards compatability
// Never change method signatures, people directly reference the NH dll and it can break backwards compatibility
// In particular, Outer Wives needs this method signature
[Obsolete]
public static GameObject Make(GameObject go, Sector sector, GameObject prefab, DetailInfo detail)

View File

@ -281,7 +281,7 @@ namespace NewHorizons.External.Configs
public void Migrate()
{
// Backwards compatability
// Backwards compatibility
// Should be the only place that obsolete things are referenced
#pragma warning disable 612, 618
if (Base.waterSize != 0)

View File

@ -309,7 +309,7 @@ namespace NewHorizons.External.Configs
public void Migrate()
{
// Backwards compatability
// Backwards compatibility
// Should be the only place that obsolete things are referenced
#pragma warning disable 612, 618
if (!string.IsNullOrEmpty(travelAudioClip)) travelAudio = travelAudioClip;

View File

@ -949,7 +949,13 @@ namespace NewHorizons.Handlers
{
flag = false;
// idk why we wait here but we do
Delay.FireInNUpdates(() => childObj.gameObject.SetActive(false), 2);
Delay.FireInNUpdates(() =>
{
if (childObj != null && childObj.gameObject != null)
{
childObj.gameObject.SetActive(false);
}
}, 2);
}
if (flag) NHLogger.LogWarning($"Couldn't find \"{childPath}\".");

View File

@ -96,6 +96,32 @@ namespace NewHorizons.Utility.Files
}
}
}
foreach (var trenderer in prefab.GetComponentsInChildren<TessellatedRenderer>(true))
{
foreach (var material in trenderer.sharedMaterials)
{
if (material == null) continue;
var replacementShader = Shader.Find(material.shader.name);
if (replacementShader == null) continue;
// preserve override tag and render queue (for Standard shader)
// keywords and properties are already preserved
if (material.renderQueue != material.shader.renderQueue)
{
var renderType = material.GetTag("RenderType", false);
var renderQueue = material.renderQueue;
material.shader = replacementShader;
material.SetOverrideTag("RenderType", renderType);
material.renderQueue = renderQueue;
}
else
{
material.shader = replacementShader;
}
}
}
}
}
}

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

View File

@ -4,7 +4,7 @@
"author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book",
"name": "New Horizons",
"uniqueName": "xen.NewHorizons",
"version": "1.18.1",
"version": "1.18.2",
"owmlVersion": "2.9.8",
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ],