Only use primary body sector if its a binary focal point

This commit is contained in:
Nick 2023-01-23 08:48:22 -05:00
parent 7ebfd1ebf6
commit d42df46a33
2 changed files with 6 additions and 4 deletions

View File

@ -4,6 +4,7 @@ using NewHorizons.Utility;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
using NewHorizons.External.Modules.VariableSize;
using NewHorizons.Components.Orbital;
namespace NewHorizons.Builder.Body
{
@ -34,7 +35,7 @@ namespace NewHorizons.Builder.Body
if (_lavaMaterial == null) _lavaMaterial = new Material(SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere").GetComponent<MeshRenderer>().sharedMaterial).DontDestroyOnLoad();
}
public static void Make(GameObject planetGO, Sector sector, ConstantForceDetector detector, OWRigidbody rigidbody, FunnelModule module)
public static void Make(GameObject planetGO, Sector sector, OWRigidbody rigidbody, FunnelModule module)
{
InitPrefabs();
@ -55,7 +56,7 @@ namespace NewHorizons.Builder.Body
var detectorGO = new GameObject("Detector_Funnel");
detectorGO.transform.parent = funnelGO.transform;
var funnelDetector = detectorGO.AddComponent<ConstantForceDetector>();
funnelDetector._inheritDetector = detector;
funnelDetector._inheritDetector = planetGO.GetComponentInChildren<ConstantForceDetector>();
funnelDetector._detectableFields = new ForceVolume[0];
detectorGO.AddComponent<ForceApplier>();
@ -165,8 +166,9 @@ namespace NewHorizons.Builder.Body
break;
}
// We take the sector of the binary focal point if it exists for this funnel (like with the twins)
var primaryBody = planetGO.GetComponent<AstroObject>().GetPrimaryBody();
if (primaryBody != null) sector = primaryBody.GetRootSector();
if (primaryBody?.GetComponent<BinaryFocalPoint>() != null) sector = primaryBody.GetRootSector();
proxyGO.GetComponent<SectorProxy>().SetSector(sector);
geoGO.GetComponent<SectorCullGroup>().SetSector(sector);

View File

@ -638,7 +638,7 @@ namespace NewHorizons.Handlers
if (body.Config.Funnel != null)
{
FunnelBuilder.Make(go, sector, go.GetComponentInChildren<ConstantForceDetector>(), rb, body.Config.Funnel);
FunnelBuilder.Make(go, sector, rb, body.Config.Funnel);
}
// Has to go last probably