mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
bramble dimensions now override base planet generation and bramble nodes can now pair to dimensions
This commit is contained in:
parent
d7b7e3226c
commit
925c048ec1
@ -5,17 +5,30 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using static NewHorizons.External.Modules.BrambleModule;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Body
|
namespace NewHorizons.Builder.Body
|
||||||
{
|
{
|
||||||
public class BrambleDimensionBuilder
|
public static class BrambleDimensionBuilder
|
||||||
{
|
{
|
||||||
public void Make()
|
public static GameObject Make(NewHorizonsBody body)
|
||||||
{
|
{
|
||||||
var dimensionPrefab = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension");
|
var config = body.Config.Bramble.dimension;
|
||||||
|
|
||||||
|
// spawn the dimension body
|
||||||
|
var dimensionPrefab = SearchUtilities.Find("DB_HubDimension_Body");
|
||||||
var dimension = GameObject.Instantiate(dimensionPrefab);
|
var dimension = GameObject.Instantiate(dimensionPrefab);
|
||||||
//dimension.name = config.rename ?? "Custom Bramble Dimension";
|
var ao = dimension.GetComponent<AstroObject>();
|
||||||
|
|
||||||
|
// fix name
|
||||||
|
var name = body.Config.name ?? "Custom Bramble Dimension";
|
||||||
|
ao._customName = name;
|
||||||
|
ao._name = AstroObject.Name.CustomString;
|
||||||
|
dimension.name = name.Replace(" ", "").Replace("'", "") + "_Body";
|
||||||
|
|
||||||
|
// TODO: radius (need to determine what the base radius is first)
|
||||||
|
|
||||||
|
// fix children's names and remove base game props (mostly just bramble nodes that are children to Interactibles) and set up the OuterWarp child
|
||||||
var dimensionSector = SearchUtilities.FindChild(dimension, "Sector_HubDimension");
|
var dimensionSector = SearchUtilities.FindChild(dimension, "Sector_HubDimension");
|
||||||
dimensionSector.name = "Sector";
|
dimensionSector.name = "Sector";
|
||||||
var atmo = SearchUtilities.FindChild(dimension, "Atmosphere_HubDimension");
|
var atmo = SearchUtilities.FindChild(dimension, "Atmosphere_HubDimension");
|
||||||
@ -25,6 +38,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
var intr = SearchUtilities.FindChild(dimension, "Interactables_HubDimension");
|
var intr = SearchUtilities.FindChild(dimension, "Interactables_HubDimension");
|
||||||
var exitWarps = SearchUtilities.FindChild(intr, "OuterWarp_Hub");
|
var exitWarps = SearchUtilities.FindChild(intr, "OuterWarp_Hub");
|
||||||
|
|
||||||
|
exitWarps.name = "OuterWarp";
|
||||||
exitWarps.transform.parent = dimensionSector.transform;
|
exitWarps.transform.parent = dimensionSector.transform;
|
||||||
atmo.name = "Atmosphere";
|
atmo.name = "Atmosphere";
|
||||||
geom.name = "Geometry"; // disable this?
|
geom.name = "Geometry"; // disable this?
|
||||||
@ -33,7 +47,9 @@ namespace NewHorizons.Builder.Body
|
|||||||
intr.name = "Interactibles";
|
intr.name = "Interactibles";
|
||||||
GameObject.Destroy(intr);
|
GameObject.Destroy(intr);
|
||||||
|
|
||||||
// TODO: set "exitWarps/ExitPoint", "exitWarp/ExitPoint (1)", ... "exitWarp/ExitPoint (5)"
|
// TODO MAYBE: set "exitWarps/ExitPoint", "exitWarp/ExitPoint (1)", ... "exitWarp/ExitPoint (5)"
|
||||||
|
|
||||||
|
return dimension;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,18 +5,64 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using static NewHorizons.External.Modules.BrambleModule;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Props
|
namespace NewHorizons.Builder.Props
|
||||||
{
|
{
|
||||||
public class BrambleNodeBuilder
|
public static class BrambleNodeBuilder
|
||||||
{
|
{
|
||||||
|
private static Dictionary<BrambleNodeInfo, InnerFogWarpVolume> unpairedNodes = new Dictionary<BrambleNodeInfo, InnerFogWarpVolume>();
|
||||||
|
|
||||||
// DB_EscapePodDimension_Body/Sector_EscapePodDimension/Interactables_EscapePodDimension/InnerWarp_ToAnglerNest // need to change the light shaft color
|
public static void PairUnpairedNodes()
|
||||||
// DB_ExitOnlyDimension_Body/Sector_ExitOnlyDimension/Interactables_ExitOnlyDimension/InnerWarp_ToExitOnly // need to change the colors
|
{
|
||||||
// DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/InnerWarp_ToCluster // need to delete the child "Signal_Harmonica"
|
// copy the keys since we'll be modifying the dictionary as we loop over it
|
||||||
|
var configsToCheck = unpairedNodes.Keys.ToList();
|
||||||
|
|
||||||
|
foreach (var config in configsToCheck)
|
||||||
|
{
|
||||||
|
var success = Pair(unpairedNodes[config], config.linksTo);
|
||||||
|
if (success) unpairedNodes.Remove(config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Make(GameObject go, Sector sector, BrambleNodeConfig config)
|
private static OuterFogWarpVolume GetOuterFogWarpVolumeFromAstroObject(GameObject go)
|
||||||
|
{
|
||||||
|
var sector = SearchUtilities.FindChild(go, "Sector");
|
||||||
|
if (sector == null) return null;
|
||||||
|
|
||||||
|
var outerWarpGO = SearchUtilities.FindChild(sector, "OuterWarp");
|
||||||
|
if (outerWarpGO == null) return null;
|
||||||
|
|
||||||
|
var outerFogWarpVolume = outerWarpGO.GetComponent<OuterFogWarpVolume>();
|
||||||
|
return outerFogWarpVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool Pair(InnerFogWarpVolume nodeWarp, string destinationName)
|
||||||
|
{
|
||||||
|
var destinationAO = AstroObjectLocator.GetAstroObject(destinationName); // find child "Sector/OuterWarp"
|
||||||
|
if (destinationAO == null) return false;
|
||||||
|
|
||||||
|
var destination = GetOuterFogWarpVolumeFromAstroObject(destinationAO.gameObject);
|
||||||
|
if (destination == null) return false;
|
||||||
|
|
||||||
|
nodeWarp._linkedOuterWarpVolume = destination;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DB_EscapePodDimension_Body/Sector_EscapePodDimension/Interactables_EscapePodDimension/InnerWarp_ToAnglerNest // need to change the light shaft color
|
||||||
|
// DB_ExitOnlyDimension_Body/Sector_ExitOnlyDimension/Interactables_ExitOnlyDimension/InnerWarp_ToExitOnly // need to change the colors
|
||||||
|
// DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/InnerWarp_ToCluster // need to delete the child "Signal_Harmonica"
|
||||||
|
|
||||||
|
public static void Make(GameObject go, Sector sector, BrambleNodeInfo[] configs)
|
||||||
|
{
|
||||||
|
foreach(var config in configs)
|
||||||
|
{
|
||||||
|
Make(go, sector, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameObject Make(GameObject go, Sector sector, BrambleNodeInfo config)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// spawn the bramble node
|
// spawn the bramble node
|
||||||
@ -45,8 +91,9 @@ namespace NewHorizons.Builder.Props
|
|||||||
var warpController = brambleNode.GetComponent<InnerFogWarpVolume>();
|
var warpController = brambleNode.GetComponent<InnerFogWarpVolume>();
|
||||||
warpController._sector = sector;
|
warpController._sector = sector;
|
||||||
warpController._attachedBody = go.GetComponent<OWRigidbody>(); // I don't think this is necessary, it seems to be set correctly on its own
|
warpController._attachedBody = go.GetComponent<OWRigidbody>(); // I don't think this is necessary, it seems to be set correctly on its own
|
||||||
// warpController._linkedOuterWarpVolume = the outer warp volume of the dimension this node leads to
|
warpController._containerWarpVolume = GetOuterFogWarpVolumeFromAstroObject(go); // the OuterFogWarpVolume of the dimension this node is inside of (null if this node is not inside of a bramble dimension (eg it's sitting on a planet or something))
|
||||||
// warpController._containerWarpVolume = the OuterFogWarpVolume of the dimension this node is inside of (null if this node is not inside of a bramble dimension (eg it's sitting on a planet or something))
|
var success = Pair(warpController, config.linksTo);
|
||||||
|
if (!success) unpairedNodes[config] = warpController;
|
||||||
|
|
||||||
//var exitPointsParent = SearchUtilities.FindChild(brambleNode, "FogWarpExitPoints"); // "ExitPoint", "ExitPoint (1)" ... "ExitPoint (5)"
|
//var exitPointsParent = SearchUtilities.FindChild(brambleNode, "FogWarpExitPoints"); // "ExitPoint", "ExitPoint (1)" ... "ExitPoint (5)"
|
||||||
//var exitPointsNames = new string[]
|
//var exitPointsNames = new string[]
|
||||||
@ -68,6 +115,10 @@ namespace NewHorizons.Builder.Props
|
|||||||
//
|
//
|
||||||
// TODO: support adding signals to these nodes
|
// TODO: support adding signals to these nodes
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Done!
|
||||||
|
return brambleNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,6 +51,11 @@ namespace NewHorizons.External.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public MVector3 rotation;
|
public MVector3 rotation;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The physical scale of the node
|
||||||
|
/// </summary>
|
||||||
|
public float scale;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of the planet that hosts the dimension this node links to
|
/// The name of the planet that hosts the dimension this node links to
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -264,7 +264,36 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
// Only called when making new planets
|
// Only called when making new planets
|
||||||
public static GameObject GenerateBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
public static GameObject GenerateBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
||||||
{
|
{
|
||||||
|
if (body.Config?.Bramble?.dimension != null)
|
||||||
|
{
|
||||||
|
return GenerateBrambleDimensionBody(body);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GenerateStandardBody(body, defaultPrimaryToSun);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameObject GenerateBrambleDimensionBody(NewHorizonsBody body)
|
||||||
|
{
|
||||||
|
var go = BrambleDimensionBuilder.Make(body);
|
||||||
|
var ao = go.GetComponent<AstroObject>();
|
||||||
|
var sector = SearchUtilities.FindChild(go, "Sector").GetComponent<Sector>();
|
||||||
|
var owRigidBody = go.GetComponent<OWRigidbody>();
|
||||||
|
|
||||||
|
go = SharedGenerateBody(body, go, sector, owRigidBody);
|
||||||
|
|
||||||
|
if (ao.GetAstroObjectName() == AstroObject.Name.CustomString)
|
||||||
|
{
|
||||||
|
AstroObjectLocator.RegisterCustomAstroObject(ao);
|
||||||
|
}
|
||||||
|
|
||||||
|
return go;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameObject GenerateStandardBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
||||||
|
{
|
||||||
AstroObject primaryBody;
|
AstroObject primaryBody;
|
||||||
if (body.Config.Orbit.primaryBody != null)
|
if (body.Config.Orbit.primaryBody != null)
|
||||||
{
|
{
|
||||||
@ -399,6 +428,11 @@ namespace NewHorizons.Handlers
|
|||||||
{
|
{
|
||||||
StarLightController.AddStar(StarBuilder.Make(go, sector, body.Config.Star));
|
StarLightController.AddStar(StarBuilder.Make(go, sector, body.Config.Star));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (body.Config?.Bramble?.nodes != null)
|
||||||
|
{
|
||||||
|
BrambleNodeBuilder.Make(go, sector, body.Config.Bramble.nodes);
|
||||||
|
}
|
||||||
|
|
||||||
if (body.Config.Ring != null)
|
if (body.Config.Ring != null)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user