diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 435f731b..011a3993 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -47,6 +47,9 @@ namespace NewHorizons.Builder.Body intr.name = "Interactibles"; GameObject.Destroy(intr); + exitWarps.GetComponent()._senderWarps.Clear(); + exitWarps.GetComponent()._linkedInnerWarpVolume = null; + // TODO MAYBE: set "exitWarps/ExitPoint", "exitWarp/ExitPoint (1)", ... "exitWarp/ExitPoint (5)" return dimension; diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index dc4d752d..53950272 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -16,16 +16,27 @@ namespace NewHorizons.Builder.Props // unpairedNodes[name of dimension that doesn't exist yet] => List{warp controller for node that links to that dimension, ...} private static Dictionary> unpairedNodes = new(); - public static void PairUnpairedNodesForDimension(string dimensionName, AstroObject dimensionAO = null) - { - if (!unpairedNodes.ContainsKey(dimensionName)) return; + public static Dictionary namedNodes = new(); - foreach (var warpVolume in unpairedNodes[dimensionName]) + public static void FinishPairingNodesForDimension(string dimensionName, AstroObject dimensionAO = null, BrambleDimensionInfo dimensionInfo = null) + { + // pair node->dimension (entrances) + if (unpairedNodes.ContainsKey(dimensionName)) { - Pair(warpVolume, dimensionName, dimensionAO); + foreach (var nodeWarpController in unpairedNodes[dimensionName]) + { + Pair(nodeWarpController, dimensionName, dimensionAO); + } + + unpairedNodes.Remove(dimensionName); } - unpairedNodes.Remove(dimensionName); + // pair dimension->node (exit) + if (dimensionInfo != null && dimensionAO != null && namedNodes.ContainsKey(dimensionInfo.linksTo)) + { + var dimensionWarpController = dimensionAO.GetComponentInChildren(); + dimensionWarpController._linkedInnerWarpVolume = namedNodes[dimensionInfo.linksTo]; + } } private static void RecordUnpairedNode(InnerFogWarpVolume warpVolume, string linksTo) @@ -56,6 +67,7 @@ namespace NewHorizons.Builder.Props if (destination == null) return false; nodeWarp._linkedOuterWarpVolume = destination; + destination._senderWarps.Add(nodeWarp); return true; } diff --git a/NewHorizons/External/Modules/BrambleModule.cs b/NewHorizons/External/Modules/BrambleModule.cs index 43e8a076..50015dd5 100644 --- a/NewHorizons/External/Modules/BrambleModule.cs +++ b/NewHorizons/External/Modules/BrambleModule.cs @@ -35,6 +35,11 @@ namespace NewHorizons.External.Modules /// The color of the fog inside this dimension. Leave blank for the default yellowish color /// public MColor fogTint; + + /// + /// The name of the *node* that the player is taken to when exiting this dimension. + /// + public string linksTo; } @@ -61,10 +66,15 @@ namespace NewHorizons.External.Modules /// public string linksTo; + /// + /// The name of this node. Only required if this node should serve as an exit. + /// + public string name; + /// /// Set this to true to make this node a seed instead of a node the player can enter /// - public bool seed; + public bool isSeed; /// /// The color of the fog inside the node. Leave blank for the default yellowish color diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 79a1c191..1cb872e0 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -435,7 +435,7 @@ namespace NewHorizons.Handlers if (body.Config.Bramble.dimension != null) { - BrambleNodeBuilder.PairUnpairedNodesForDimension(body.Config.name, body.Object.GetComponent()); + BrambleNodeBuilder.FinishPairingNodesForDimension(body.Config.name, body.Object.GetComponent()); } }