mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
More attempts at funnels
This commit is contained in:
parent
73de80bcc0
commit
022fc643da
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Body
|
namespace NewHorizons.Builder.Body
|
||||||
{
|
{
|
||||||
@ -19,7 +20,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
STAR
|
STAR
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Make(GameObject go, ConstantForceDetector detector, FunnelModule module)
|
public static void Make(GameObject go, ConstantForceDetector detector, InitialMotion initialMotion, FunnelModule module)
|
||||||
{
|
{
|
||||||
var funnelType = FunnelType.SAND;
|
var funnelType = FunnelType.SAND;
|
||||||
if (module.Type.ToUpper().Equals("WATER")) funnelType = FunnelType.WATER;
|
if (module.Type.ToUpper().Equals("WATER")) funnelType = FunnelType.WATER;
|
||||||
@ -28,11 +29,16 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
var funnelGO = new GameObject($"{go.name.Replace("_Body", "")}Funnel_Body");
|
var funnelGO = new GameObject($"{go.name.Replace("_Body", "")}Funnel_Body");
|
||||||
funnelGO.SetActive(false);
|
funnelGO.SetActive(false);
|
||||||
|
|
||||||
var owrb = funnelGO.AddComponent<OWRigidbody>();
|
var owrb = funnelGO.AddComponent<OWRigidbody>();
|
||||||
var alignment = funnelGO.AddComponent<AlignWithTargetBody>();
|
var alignment = funnelGO.AddComponent<AlignWithTargetBody>();
|
||||||
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => alignment.SetTargetBody(AstroObjectLocator.GetAstroObject(module.Target)?.GetAttachedOWRigidbody()));
|
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => alignment.SetTargetBody(AstroObjectLocator.GetAstroObject(module.Target)?.GetAttachedOWRigidbody()));
|
||||||
funnelGO.AddComponent<InitialMotion>();
|
|
||||||
|
var im = funnelGO.AddComponent<InitialMotion>();
|
||||||
|
var velocity = initialMotion.GetInitVelocity();
|
||||||
|
im._initLinearDirection = initialMotion._initLinearDirection;
|
||||||
|
im._initLinearSpeed = initialMotion._initLinearSpeed;
|
||||||
|
|
||||||
funnelGO.AddComponent<SandFunnelController>();
|
funnelGO.AddComponent<SandFunnelController>();
|
||||||
funnelGO.AddComponent<CenterOfTheUniverseOffsetApplier>();
|
funnelGO.AddComponent<CenterOfTheUniverseOffsetApplier>();
|
||||||
funnelGO.AddComponent<KinematicRigidbody>();
|
funnelGO.AddComponent<KinematicRigidbody>();
|
||||||
@ -40,12 +46,13 @@ namespace NewHorizons.Builder.Body
|
|||||||
var detectorGO = new GameObject("Detector_Funnel");
|
var detectorGO = new GameObject("Detector_Funnel");
|
||||||
detectorGO.transform.parent = funnelGO.transform;
|
detectorGO.transform.parent = funnelGO.transform;
|
||||||
var funnelDetector = detectorGO.AddComponent<ConstantForceDetector>();
|
var funnelDetector = detectorGO.AddComponent<ConstantForceDetector>();
|
||||||
funnelDetector._inheritDetector = detector;
|
funnelDetector._inheritDetector = detector;
|
||||||
|
funnelDetector._detectableFields = new ForceVolume[0];
|
||||||
|
|
||||||
detectorGO.AddComponent<ForceApplier>();
|
detectorGO.AddComponent<ForceApplier>();
|
||||||
|
|
||||||
var scaleRoot = new GameObject("ScaleRoot");
|
var scaleRoot = new GameObject("ScaleRoot");
|
||||||
scaleRoot.transform.parent = go.transform;
|
scaleRoot.transform.parent = funnelGO.transform;
|
||||||
|
|
||||||
var proxyGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Proxy_SandFunnel"), scaleRoot.transform);
|
var proxyGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Proxy_SandFunnel"), scaleRoot.transform);
|
||||||
proxyGO.name = "Proxy_Funnel";
|
proxyGO.name = "Proxy_Funnel";
|
||||||
@ -55,7 +62,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
var volumesGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Volumes_SandFunnel"), scaleRoot.transform);
|
var volumesGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Volumes_SandFunnel"), scaleRoot.transform);
|
||||||
volumesGO.name = "Volumes_Funnel";
|
volumesGO.name = "Volumes_Funnel";
|
||||||
var sfv = volumesGO.GetComponent<SimpleFluidVolume>();
|
var sfv = volumesGO.GetComponentInChildren<SimpleFluidVolume>();
|
||||||
switch(funnelType)
|
switch(funnelType)
|
||||||
{
|
{
|
||||||
case FunnelType.SAND:
|
case FunnelType.SAND:
|
||||||
@ -71,7 +78,9 @@ namespace NewHorizons.Builder.Body
|
|||||||
sfv._fluidType = FluidVolume.Type.PLASMA;
|
sfv._fluidType = FluidVolume.Type.PLASMA;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
funnelGO.transform.position = go.transform.position;
|
||||||
|
funnelGO.SetActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,9 @@ namespace NewHorizons.Builder.General
|
|||||||
owRigidBody.SetValue("_maintainOriginalCenterOfMass", true);
|
owRigidBody.SetValue("_maintainOriginalCenterOfMass", true);
|
||||||
owRigidBody.SetValue("_rigidbody", rigidBody);
|
owRigidBody.SetValue("_rigidbody", rigidBody);
|
||||||
owRigidBody.SetValue("_kinematicRigidbody", kinematicRigidBody);
|
owRigidBody.SetValue("_kinematicRigidbody", kinematicRigidBody);
|
||||||
|
owRigidBody._origParent = GameObject.Find("SolarSystemRoot").transform;
|
||||||
|
owRigidBody.EnableKinematicSimulation();
|
||||||
|
owRigidBody.MakeKinematic();
|
||||||
|
|
||||||
ParameterizedAstroObject astroObject = body.AddComponent<ParameterizedAstroObject>();
|
ParameterizedAstroObject astroObject = body.AddComponent<ParameterizedAstroObject>();
|
||||||
|
|
||||||
|
|||||||
@ -497,7 +497,7 @@ namespace NewHorizons
|
|||||||
if (!body.Config.Orbit.IsStatic) DetectorBuilder.Make(go, owRigidBody, primaryBody, ao);
|
if (!body.Config.Orbit.IsStatic) DetectorBuilder.Make(go, owRigidBody, primaryBody, ao);
|
||||||
|
|
||||||
if (body.Config.Funnel != null)
|
if (body.Config.Funnel != null)
|
||||||
FunnelBuilder.Make(go, go.GetComponentInChildren<ConstantForceDetector>(), body.Config.Funnel);
|
FunnelBuilder.Make(go, go.GetComponentInChildren<ConstantForceDetector>(), initialMotion, body.Config.Funnel);
|
||||||
|
|
||||||
if (ao.GetAstroObjectName() == AstroObject.Name.CustomString) AstroObjectLocator.RegisterCustomAstroObject(ao);
|
if (ao.GetAstroObjectName() == AstroObject.Name.CustomString) AstroObjectLocator.RegisterCustomAstroObject(ao);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user