Add optional mesh change for supernova planet effect

This commit is contained in:
Noah Pilarski 2022-08-18 19:22:58 -04:00
parent 8c937f67ef
commit 8d370ac546
4 changed files with 19 additions and 4 deletions

View File

@ -173,7 +173,7 @@ namespace NewHorizons.Builder.Body
NHSupernovaPlanetEffectController supernovaPlanetEffect = null; NHSupernovaPlanetEffectController supernovaPlanetEffect = null;
if ((body.Config.ShockEffect == null || body.Config.ShockEffect.hasSupernovaShockEffect) && body.Config.Star == null && body.Config.name != "Sun" && body.Config.FocalPoint == null && !body.Config.isStellarRemnant) if ((body.Config.ShockEffect == null || body.Config.ShockEffect.hasSupernovaShockEffect) && body.Config.Star == null && body.Config.name != "Sun" && body.Config.FocalPoint == null && !body.Config.isStellarRemnant)
{ {
supernovaPlanetEffect = SupernovaEffectBuilder.Make(proxy, null, body.Config, procGen, null, null, null, atmosphere, fog); supernovaPlanetEffect = SupernovaEffectBuilder.Make(proxy, null, body.Config, body.Mod, procGen, null, null, null, atmosphere, fog);
} }
// Remove all collisions if there are any // Remove all collisions if there are any

View File

@ -4,12 +4,13 @@ using NewHorizons.External.Configs;
using NewHorizons.Components; using NewHorizons.Components;
using System.Linq; using System.Linq;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using OWML.Common;
namespace NewHorizons.Builder.Body namespace NewHorizons.Builder.Body
{ {
public static class SupernovaEffectBuilder public static class SupernovaEffectBuilder
{ {
public static NHSupernovaPlanetEffectController Make(GameObject planetGO, Sector sector, PlanetConfig config, GameObject procGen, Light ambientLight, PlanetaryFogController fog, LODGroup atmosphere, Renderer atmosphereRenderer, Renderer fogImpostor) public static NHSupernovaPlanetEffectController Make(GameObject planetGO, Sector sector, PlanetConfig config, IModBehaviour mod, GameObject procGen, Light ambientLight, PlanetaryFogController fog, LODGroup atmosphere, Renderer atmosphereRenderer, Renderer fogImpostor)
{ {
var vanillaController = planetGO.GetComponentInChildren<SupernovaPlanetEffectController>(); var vanillaController = planetGO.GetComponentInChildren<SupernovaPlanetEffectController>();
if (vanillaController != null) if (vanillaController != null)
@ -139,6 +140,20 @@ namespace NewHorizons.Builder.Body
shockLayer.transform.rotation = Quaternion.Euler(90, 0, 0); shockLayer.transform.rotation = Quaternion.Euler(90, 0, 0);
} }
if (config.ShockEffect != null)
{
if (!string.IsNullOrWhiteSpace(config.ShockEffect.assetBundle) && !string.IsNullOrWhiteSpace(config.ShockEffect.meshPath))
{
var mesh = AssetBundleUtilities.Load<Mesh>(config.ShockEffect.assetBundle, config.ShockEffect.meshPath, mod);
if (mesh != null)
{
shockLayer.GetComponent<MeshFilter>().sharedMesh = mesh;
shockLayer.transform.localScale = Vector3.one * 1.1f;
shockLayer.transform.rotation = Quaternion.Euler(0, 0, 0);
}
}
}
return supernovaEffectController; return supernovaEffectController;
} }
} }

View File

@ -21,7 +21,7 @@ namespace NewHorizons.External.Modules
public string assetBundle; public string assetBundle;
/// <summary> /// <summary>
/// Path in the asset bundle that leads a replacement mesh for the planet's supernova shock effect /// Path to the replacement mesh for the planet's supernova shock effect in the supplied asset bundle
/// </summary> /// </summary>
public string meshPath; public string meshPath;
} }

View File

@ -599,7 +599,7 @@ namespace NewHorizons.Handlers
if ((body.Config.ShockEffect == null || body.Config.ShockEffect.hasSupernovaShockEffect) && body.Config.Star == null && body.Config.name != "Sun" && body.Config.FocalPoint == null) if ((body.Config.ShockEffect == null || body.Config.ShockEffect.hasSupernovaShockEffect) && body.Config.Star == null && body.Config.name != "Sun" && body.Config.FocalPoint == null)
{ {
SupernovaEffectBuilder.Make(go, sector, body.Config, procGen, ambientLight, fog, atmosphere, null, fog?._fogImpostor); SupernovaEffectBuilder.Make(go, sector, body.Config, body.Mod, procGen, ambientLight, fog, atmosphere, null, fog?._fogImpostor);
} }
return go; return go;