mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Preliminary funnel stuff
This commit is contained in:
parent
1316395ca3
commit
ec19fc8aa4
77
NewHorizons/Builder/Body/FunnelBuilder.cs
Normal file
77
NewHorizons/Builder/Body/FunnelBuilder.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using NewHorizons.External.VariableSize;
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
public static class FunnelBuilder
|
||||
{
|
||||
private enum FunnelType
|
||||
{
|
||||
SAND,
|
||||
WATER,
|
||||
LAVA,
|
||||
STAR
|
||||
}
|
||||
|
||||
public static void Make(GameObject go, ConstantForceDetector detector, FunnelModule module)
|
||||
{
|
||||
var funnelType = FunnelType.SAND;
|
||||
if (module.Type.ToUpper().Equals("WATER")) funnelType = FunnelType.WATER;
|
||||
else if (module.Type.ToUpper().Equals("LAVA")) funnelType = FunnelType.LAVA;
|
||||
else if (module.Type.ToUpper().Equals("STAR")) funnelType = FunnelType.STAR;
|
||||
|
||||
var funnelGO = new GameObject($"{go.name.Replace("_Body", "")}Funnel_Body");
|
||||
funnelGO.SetActive(false);
|
||||
|
||||
var owrb = funnelGO.AddComponent<OWRigidbody>();
|
||||
var alignment = funnelGO.AddComponent<AlignWithTargetBody>();
|
||||
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => alignment.SetTargetBody(AstroObjectLocator.GetAstroObject(module.Target)?.GetAttachedOWRigidbody()));
|
||||
funnelGO.AddComponent<InitialMotion>();
|
||||
funnelGO.AddComponent<SandFunnelController>();
|
||||
funnelGO.AddComponent<CenterOfTheUniverseOffsetApplier>();
|
||||
funnelGO.AddComponent<KinematicRigidbody>();
|
||||
|
||||
var detectorGO = new GameObject("Detector_Funnel");
|
||||
detectorGO.transform.parent = funnelGO.transform;
|
||||
var funnelDetector = detectorGO.AddComponent<ConstantForceDetector>();
|
||||
funnelDetector._inheritDetector = detector;
|
||||
|
||||
detectorGO.AddComponent<ForceApplier>();
|
||||
|
||||
var scaleRoot = new GameObject("ScaleRoot");
|
||||
scaleRoot.transform.parent = go.transform;
|
||||
|
||||
var proxyGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Proxy_SandFunnel"), scaleRoot.transform);
|
||||
proxyGO.name = "Proxy_Funnel";
|
||||
|
||||
var geoGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Geo_SandFunnel"), scaleRoot.transform);
|
||||
geoGO.name = "Geo_Funnel";
|
||||
|
||||
var volumesGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Volumes_SandFunnel"), scaleRoot.transform);
|
||||
volumesGO.name = "Volumes_Funnel";
|
||||
var sfv = volumesGO.GetComponent<SimpleFluidVolume>();
|
||||
switch(funnelType)
|
||||
{
|
||||
case FunnelType.SAND:
|
||||
sfv._fluidType = FluidVolume.Type.SAND;
|
||||
break;
|
||||
case FunnelType.WATER:
|
||||
sfv._fluidType = FluidVolume.Type.WATER;
|
||||
break;
|
||||
case FunnelType.LAVA:
|
||||
sfv._fluidType = FluidVolume.Type.PLASMA;
|
||||
break;
|
||||
case FunnelType.STAR:
|
||||
sfv._fluidType = FluidVolume.Type.PLASMA;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
1
NewHorizons/External/IPlanetConfig.cs
vendored
1
NewHorizons/External/IPlanetConfig.cs
vendored
@ -25,5 +25,6 @@ namespace NewHorizons.External
|
||||
LavaModule Lava { get; }
|
||||
SandModule Sand { get; }
|
||||
WaterModule Water { get; }
|
||||
FunnelModule Funnel { get; }
|
||||
}
|
||||
}
|
||||
|
||||
1
NewHorizons/External/PlanetConfig.cs
vendored
1
NewHorizons/External/PlanetConfig.cs
vendored
@ -28,6 +28,7 @@ namespace NewHorizons.External
|
||||
public LavaModule Lava { get; set; }
|
||||
public WaterModule Water { get; set; }
|
||||
public SandModule Sand { get; set; }
|
||||
public FunnelModule Funnel { get; set; }
|
||||
|
||||
public PlanetConfig(Dictionary<string, object> dict)
|
||||
{
|
||||
|
||||
16
NewHorizons/External/VariableSize/FunnelModule.cs
vendored
Normal file
16
NewHorizons/External/VariableSize/FunnelModule.cs
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.External.VariableSize
|
||||
{
|
||||
public class FunnelModule : VariableSizeModule
|
||||
{
|
||||
public string Target { get; set; }
|
||||
public string Type { get; set; } = "Sand";
|
||||
public MColor32 Tint { get; set; }
|
||||
}
|
||||
}
|
||||
@ -489,6 +489,9 @@ namespace NewHorizons
|
||||
|
||||
if (!body.Config.Orbit.IsStatic) DetectorBuilder.Make(go, owRigidBody, primaryBody, ao);
|
||||
|
||||
if (body.Config.Funnel != null)
|
||||
FunnelBuilder.Make(go, go.GetComponentInChildren<ConstantForceDetector>(), body.Config.Funnel);
|
||||
|
||||
if (ao.GetAstroObjectName() == AstroObject.Name.CustomString) AstroObjectLocator.RegisterCustomAstroObject(ao);
|
||||
|
||||
HeavenlyBodyBuilder.Make(go, body.Config, sphereOfInfluence, gv, initialMotion);
|
||||
|
||||
@ -228,7 +228,7 @@
|
||||
"description": "The average distance between the planet and its primary body."
|
||||
},
|
||||
"inclination": {
|
||||
"type": "integer",
|
||||
"type": "number",
|
||||
"default": 0,
|
||||
"description": "The angle (in degrees) between the body's orbit and the plane of the star system"
|
||||
},
|
||||
@ -989,6 +989,70 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Funnel": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"target": {
|
||||
"type": "string",
|
||||
"description": "The body that the funnel is pouring onto"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Sand",
|
||||
"Water",
|
||||
"Lava",
|
||||
"Star"
|
||||
],
|
||||
"default": "Sand"
|
||||
}
|
||||
"tint": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"R": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"G": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"B": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"A": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"curve": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"time": {
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
},
|
||||
"value": {
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user