bramble dimensions now override base planet generation and bramble nodes can now pair to dimensions

This commit is contained in:
FreezeDriedMangoes 2022-06-29 18:13:37 -04:00
parent d7b7e3226c
commit 925c048ec1
4 changed files with 121 additions and 15 deletions

View File

@ -5,17 +5,30 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using static NewHorizons.External.Modules.BrambleModule;
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);
//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");
dimensionSector.name = "Sector";
var atmo = SearchUtilities.FindChild(dimension, "Atmosphere_HubDimension");
@ -25,6 +38,7 @@ namespace NewHorizons.Builder.Body
var intr = SearchUtilities.FindChild(dimension, "Interactables_HubDimension");
var exitWarps = SearchUtilities.FindChild(intr, "OuterWarp_Hub");
exitWarps.name = "OuterWarp";
exitWarps.transform.parent = dimensionSector.transform;
atmo.name = "Atmosphere";
geom.name = "Geometry"; // disable this?
@ -33,7 +47,9 @@ namespace NewHorizons.Builder.Body
intr.name = "Interactibles";
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;
}
}
}

View File

@ -5,18 +5,64 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using static NewHorizons.External.Modules.BrambleModule;
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
// 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 PairUnpairedNodes()
{
// 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
@ -45,8 +91,9 @@ namespace NewHorizons.Builder.Props
var warpController = brambleNode.GetComponent<InnerFogWarpVolume>();
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._linkedOuterWarpVolume = the outer warp volume of the dimension this node leads to
// 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))
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))
var success = Pair(warpController, config.linksTo);
if (!success) unpairedNodes[config] = warpController;
//var exitPointsParent = SearchUtilities.FindChild(brambleNode, "FogWarpExitPoints"); // "ExitPoint", "ExitPoint (1)" ... "ExitPoint (5)"
//var exitPointsNames = new string[]
@ -68,6 +115,10 @@ namespace NewHorizons.Builder.Props
//
// TODO: support adding signals to these nodes
//
// Done!
return brambleNode;
}
}
}

View File

@ -51,6 +51,11 @@ namespace NewHorizons.External.Modules
/// </summary>
public MVector3 rotation;
/// <summary>
/// The physical scale of the node
/// </summary>
public float scale;
/// <summary>
/// The name of the planet that hosts the dimension this node links to
/// </summary>

View File

@ -264,7 +264,36 @@ namespace NewHorizons.Handlers
// Only called when making new planets
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;
if (body.Config.Orbit.primaryBody != null)
{
@ -399,6 +428,11 @@ namespace NewHorizons.Handlers
{
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)
{