From 2e6e9d729f3e09351ecbe2a5a103be6c92672b63 Mon Sep 17 00:00:00 2001 From: FreezeDriedMangoes Date: Sun, 3 Jul 2022 08:39:53 -0400 Subject: [PATCH] finished signal propogation and fixed bug where nodes wouldn't pair in some cases --- NewHorizons/Builder/Props/BrambleNodeBuilder.cs | 8 +++++++- NewHorizons/Handlers/PlanetCreationHandler.cs | 12 +++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index be7ae343..951684e0 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -35,10 +35,13 @@ namespace NewHorizons.Builder.Props public static void FinishPairingNodesForDimension(string dimensionName, AstroObject dimensionAO = null) { + Logger.Log("finishing paring nodes for dimension " + dimensionName); if (!unpairedNodes.ContainsKey(dimensionName)) return; + Logger.Log("continuing to paring nodes for dimension " + dimensionName); foreach (var nodeWarpController in unpairedNodes[dimensionName]) { + Logger.Log(". paring node for dimension" + dimensionName); PairEntrance(nodeWarpController, dimensionName, dimensionAO); } @@ -49,6 +52,7 @@ namespace NewHorizons.Builder.Props { if (!unpairedNodes.ContainsKey(linksTo)) unpairedNodes[linksTo] = new(); + Logger.Log("recording entrance for " + linksTo); unpairedNodes[linksTo].Add(warpVolume); } @@ -71,7 +75,7 @@ namespace NewHorizons.Builder.Props // 1) Run Floyd-Warshall on the dimensions (where each dimension is a vertex and each node is an edge) // 2) For each dimension A, if it's possible to reach dimension B, add dimension B's signals to the list propogatedSignals[A] - var allDimensions = new List(); // TODO: grab this list from Main or something, idk + var allDimensions = PlanetCreationHandler.allBodies.Where(body => body?.Config?.Bramble?.dimension != null).Select(body => body.Config).ToList(); // // Floyd Warshall @@ -132,6 +136,7 @@ namespace NewHorizons.Builder.Props private static bool PairEntrance(InnerFogWarpVolume nodeWarp, string destinationName, AstroObject dimensionAO = null) { + Logger.Log("Attempting to pair entrance to " + destinationName); var destinationAO = dimensionAO ?? AstroObjectLocator.GetAstroObject(destinationName); // find child "Sector/OuterWarp" if (destinationAO == null) return false; @@ -139,6 +144,7 @@ namespace NewHorizons.Builder.Props var destination = GetOuterFogWarpVolumeFromAstroObject(destinationAO.gameObject); if (destination == null) return false; + Logger.Log("Pairing entrance to " + destinationName); nodeWarp._linkedOuterWarpVolume = destination; destination.RegisterSenderWarp(nodeWarp); return true; diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 5649083e..843639e6 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -25,6 +25,8 @@ namespace NewHorizons.Handlers private static Dictionary _dict; private static Dictionary _dimensions; + public static List allBodies; + public static NewHorizonsBody GetNewHorizonsBody(AstroObject ao) { if (ao is NHAstroObject nhAO) @@ -44,6 +46,7 @@ namespace NewHorizons.Handlers ExistingAOConfigs = new Dictionary(); _dict = new Dictionary(); _dimensions = new Dictionary(); + allBodies = bodies; // Set up stars // Need to manage this when there are multiple stars @@ -461,13 +464,16 @@ namespace NewHorizons.Handlers StarLightController.AddStar(StarBuilder.Make(go, sector, body.Config.Star, body.Mod)); } - if (body.Config?.Bramble?.nodes != null) + if (body.Config?.Bramble != null) { - BrambleNodeBuilder.Make(go, sector, body.Config.Bramble.nodes, body.Mod); + if (body.Config.Bramble.nodes != null) + { + BrambleNodeBuilder.Make(go, sector, body.Config.Bramble.nodes, body.Mod); + } if (body.Config.Bramble.dimension != null) { - BrambleNodeBuilder.FinishPairingNodesForDimension(body.Config.name, body.Object.GetComponent()); + BrambleNodeBuilder.FinishPairingNodesForDimension(body.Config.name, go.GetComponent()); } }