allow ghosts to work in bundles maybe (#731)

<!-- A new module or something else important -->
## Major features
-

<!-- A new parameter added to a module, or API feature -->
## Minor features
-

<!-- Some improvement that requires no action on the part of add-on
creators i.e., improved star graphics -->
## Improvements
- Ghost animator components don't always get removed now (except when
they need to be)

<!-- Be sure to reference the existing issue if it exists -->
## Bug fixes
- fix bug where ParticleFields assumes you have an Atmosphere and fails
to build your planet if you dont
- Reload configs always reload bundles now
This commit is contained in:
Nick 2023-09-27 17:49:51 -04:00 committed by GitHub
commit 9c1741622d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 27 deletions

View File

@ -2,6 +2,7 @@ using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using UnityEngine;
namespace NewHorizons.Builder.Atmosphere
{
public static class EffectsBuilder
@ -55,29 +56,19 @@ namespace NewHorizons.Builder.Atmosphere
{
InitPrefabs();
GameObject effectsGO = new GameObject("Effects");
var effectsGO = new GameObject("Effects");
effectsGO.SetActive(false);
effectsGO.transform.parent = sector?.transform ?? planetGO.transform;
effectsGO.transform.position = planetGO.transform.position;
SectorCullGroup SCG = effectsGO.AddComponent<SectorCullGroup>();
SCG._sector = sector;
SCG._particleSystemSuspendMode = CullGroup.ParticleSystemSuspendMode.Stop;
SCG._occlusionCulling = false;
SCG._dynamicCullingBounds = false;
SCG._waitForStreaming = false;
var sectorCullGroup = effectsGO.AddComponent<SectorCullGroup>();
sectorCullGroup._sector = sector;
sectorCullGroup._particleSystemSuspendMode = CullGroup.ParticleSystemSuspendMode.Stop;
sectorCullGroup._occlusionCulling = false;
sectorCullGroup._dynamicCullingBounds = false;
sectorCullGroup._waitForStreaming = false;
var minHeight = config.Base.surfaceSize;
if (config.HeightMap?.minHeight != null)
{
if (config.Water?.size >= config.HeightMap.minHeight) minHeight = config.Water.size; // use sea level if its higher
else minHeight = config.HeightMap.minHeight;
}
else if (config.Water?.size != null) minHeight = config.Water.size;
else if (config.Lava?.size != null) minHeight = config.Lava.size;
var maxHeight = config.Atmosphere.size;
if (config.Atmosphere.clouds?.outerCloudRadius != null) maxHeight = config.Atmosphere.clouds.outerCloudRadius;
var (minHeight, maxHeight) = GetDefaultHeightRange(config);
foreach (var particleField in config.ParticleFields)
{
@ -130,5 +121,48 @@ namespace NewHorizons.Builder.Atmosphere
_ => null,
};
}
private static (float, float) GetDefaultHeightRange(PlanetConfig config)
{
var minHeight = 0f;
if (config.HeightMap?.minHeight != null)
{
if (config.Water?.size >= config.HeightMap.minHeight) minHeight = config.Water.size; // use sea level if its higher
else minHeight = config.HeightMap.minHeight;
}
else if (config.Water?.size != null)
{
minHeight = config.Water.size;
}
else if (config.Lava?.size != null)
{
minHeight = config.Lava.size;
}
else if (config.Base != null)
{
minHeight = config.Base.surfaceSize;
}
var maxHeight = 100f;
if (config.Atmosphere != null)
{
if (config.Atmosphere.clouds?.outerCloudRadius != null)
{
maxHeight = config.Atmosphere.clouds.outerCloudRadius;
}
else
{
maxHeight = config.Atmosphere.size;
}
}
else if (minHeight != 0f)
{
maxHeight = minHeight * 2f;
}
return (minHeight, maxHeight);
}
}
}

View File

@ -339,12 +339,6 @@ namespace NewHorizons.Builder.Props
component.gameObject.layer = Layer.IgnoreSun;
}
}
// I forget why this is here
else if (component is GhostIK or GhostEffects)
{
UnityEngine.Object.DestroyImmediate(component);
return;
}
else if (component is DarkMatterVolume)
{
var probeVisuals = component.gameObject.transform.Find("ProbeVisuals");
@ -400,8 +394,15 @@ namespace NewHorizons.Builder.Props
else if (component is Renderer renderer && component.gameObject.GetComponent<ElectricityEffect>() == null) renderer.enabled = true;
else if(component is Shape shape) shape.enabled = true;
// If it's not a moving anglerfish make sure the anim controller is regular
else if(component is AnglerfishAnimController && component.transform.parent.GetComponent<AnglerfishController>() == null) //Manual parent chain so we can find inactive
// If it's not a moving ghostbird (ie Prefab_IP_GhostBird/Ghostbird_IP_ANIM) make sure it doesnt spam NREs
// Manual parent chain so we can find inactive
else if (component is GhostIK or GhostEffects && component.transform.parent.GetComponent<GhostBrain>() == null)
{
UnityEngine.Object.DestroyImmediate(component);
}
// If it's not a moving anglerfish (ie Anglerfish_Body/Beast_Anglerfish) make sure the anim controller is regular
// Manual parent chain so we can find inactive
else if(component is AnglerfishAnimController && component.transform.parent.GetComponent<AnglerfishController>() == null)
{
component.gameObject.AddComponent<AnglerAnimFixer>();
}

View File

@ -97,6 +97,7 @@ namespace NewHorizons
private bool _playerAwake;
public bool PlayerSpawned { get; set; }
public bool ForceClearCaches { get; set; } // for reloading configs
public ShipWarpController ShipWarpController { get; private set; }
@ -288,8 +289,10 @@ namespace NewHorizons
EnumUtilities.ClearCache();
// Caches of other assets only have to be cleared if we changed star systems
if (CurrentStarSystem != _previousStarSystem)
if (ForceClearCaches || CurrentStarSystem != _previousStarSystem)
{
ForceClearCaches = false;
NHLogger.Log($"Changing star system from {_previousStarSystem} to {CurrentStarSystem} - Clearing system-specific caches!");
ImageUtilities.ClearCache();
AudioUtilities.ClearCache();

View File

@ -1,4 +1,5 @@
using NewHorizons.Handlers;
using NewHorizons.Utility.Files;
using NewHorizons.Utility.OWML;
using OWML.Common;
using OWML.Common.Menus;
@ -47,6 +48,7 @@ namespace NewHorizons.Utility.DebugTools
SearchUtilities.Find("/PauseMenu/PauseMenuManagers").GetComponent<PauseMenuManager>().OnSkipToNextTimeLoop();
Main.Instance.ForceClearCaches = true;
Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem);
Main.SecondsElapsedInLoop = -1f;