Manually set attached components

This commit is contained in:
Noah Pilarski 2022-05-27 05:49:41 -04:00
parent 745b773389
commit 74873efc11
4 changed files with 12 additions and 7 deletions

View File

@ -1,4 +1,4 @@
using NewHorizons.Components.Orbital; using NewHorizons.Components.Orbital;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
@ -31,6 +31,8 @@ namespace NewHorizons.Builder.General
fluidDetector._collider = sphereCollider; fluidDetector._collider = sphereCollider;
OWRB.RegisterAttachedFluidDetector(fluidDetector);
// Could copy the splash from the interloper as well some day // Could copy the splash from the interloper as well some day
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
@ -6,7 +6,7 @@ namespace NewHorizons.Builder.General
{ {
public static class GravityBuilder public static class GravityBuilder
{ {
public static GravityVolume Make(GameObject planetGO, AstroObject ao, PlanetConfig config) public static GravityVolume Make(GameObject planetGO, AstroObject ao, OWRigidbody owrb, PlanetConfig config)
{ {
var exponent = config.Base.gravityFallOff == GravityFallOff.Linear ? 1f : 2f; var exponent = config.Base.gravityFallOff == GravityFallOff.Linear ? 1f : 2f;
var GM = config.Base.surfaceGravity * Mathf.Pow(config.Base.surfaceSize, exponent); var GM = config.Base.surfaceGravity * Mathf.Pow(config.Base.surfaceSize, exponent);
@ -60,6 +60,7 @@ namespace NewHorizons.Builder.General
gravityGO.SetActive(true); gravityGO.SetActive(true);
ao._gravityVolume = gravityVolume; ao._gravityVolume = gravityVolume;
owrb.RegisterAttachedGravityVolume(gravityVolume);
return gravityVolume; return gravityVolume;
} }

View File

@ -1,10 +1,10 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
{ {
public static class RFVolumeBuilder public static class RFVolumeBuilder
{ {
public static void Make(GameObject planetGO, OWRigidbody owRigidBody, float sphereOfInfluence) public static void Make(GameObject planetGO, OWRigidbody owrb, float sphereOfInfluence)
{ {
var rfGO = new GameObject("RFVolume"); var rfGO = new GameObject("RFVolume");
rfGO.transform.parent = planetGO.transform; rfGO.transform.parent = planetGO.transform;
@ -18,7 +18,7 @@ namespace NewHorizons.Builder.General
var RFV = rfGO.AddComponent<ReferenceFrameVolume>(); var RFV = rfGO.AddComponent<ReferenceFrameVolume>();
var RV = new ReferenceFrame(owRigidBody); var RV = new ReferenceFrame(owrb);
RV._minSuitTargetDistance = sphereOfInfluence; RV._minSuitTargetDistance = sphereOfInfluence;
RV._maxTargetDistance = 0; RV._maxTargetDistance = 0;
RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence; RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence;
@ -36,6 +36,8 @@ namespace NewHorizons.Builder.General
RFV._isPrimaryVolume = true; RFV._isPrimaryVolume = true;
RFV._isCloseRangeVolume = false; RFV._isCloseRangeVolume = false;
owrb.SetAttachedReferenceFrameVolume(RFV);
rfGO.SetActive(true); rfGO.SetActive(true);
} }
} }

View File

@ -303,7 +303,7 @@ namespace NewHorizons.Handlers
if (body.Config.Base.surfaceGravity != 0) if (body.Config.Base.surfaceGravity != 0)
{ {
GravityBuilder.Make(go, ao, body.Config); GravityBuilder.Make(go, ao, owRigidBody, body.Config);
} }
if (body.Config.Base.hasReferenceFrame) if (body.Config.Base.hasReferenceFrame)