From 71abd4495e1878cf31dc232f3ba5a3d3258db54b Mon Sep 17 00:00:00 2001 From: FreezeDriedMangoes Date: Fri, 1 Jul 2022 15:26:40 -0400 Subject: [PATCH] fixed bramble signals and created a dictionary in planetcreationhandler for dimensions (non-body bodies, like bramble dimensions for example) and a lookup function for them --- .../Builder/Props/BrambleNodeBuilder.cs | 4 ++- NewHorizons/Builder/Props/SignalBuilder.cs | 3 ++- NewHorizons/Handlers/PlanetCreationHandler.cs | 25 ++++++++++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index 46512f57..2d108a80 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -1,5 +1,6 @@ using HarmonyLib; using NewHorizons.Builder.Body; +using NewHorizons.Handlers; using NewHorizons.Utility; using System; using System.Collections.Generic; @@ -66,7 +67,7 @@ namespace NewHorizons.Builder.Props if (destinationAO == null) return false; // add the destination dimension's signals to this node - var dimensionNewHorizonsBody = destinationAO.GetComponent(); + var dimensionNewHorizonsBody = PlanetCreationHandler.GetNewHorizonsBody(destinationAO); if (dimensionNewHorizonsBody != null && dimensionNewHorizonsBody.Config?.Signal?.signals != null) { var body = nodeWarp.GetComponentInParent().gameObject; @@ -76,6 +77,7 @@ namespace NewHorizons.Builder.Props { var signalGO = SignalBuilder.Make(body, sector, signalConfig, dimensionNewHorizonsBody.Mod); signalGO.GetComponent()._identificationDistance = 0; + signalGO.GetComponent()._sourceRadius = 1; signalGO.transform.position = nodeWarp.transform.position; } } diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index 6f142830..b26925d9 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -180,7 +180,8 @@ namespace NewHorizons.Builder.Props audioSignal._revealFactID = info.reveals; audioSignal._onlyAudibleToScope = info.onlyAudibleToScope; audioSignal._identificationDistance = info.identificationRadius; - audioSignal._canBePickedUpByScope = true; + audioSignal._canBePickedUpByScope = true; + audioSignal._outerFogWarpVolume = planetGO.GetComponentInChildren(); // shouldn't break non-bramble signals source.clip = clip; source.loop = true; diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 7b6f4fb8..ce7feb7b 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -22,14 +22,28 @@ namespace NewHorizons.Handlers // I literally forget what this is for private static Dictionary ExistingAOConfigs; - private static Dictionary _dict; + private static Dictionary _dict; + private static Dictionary _dimensions; + + public static NewHorizonsBody GetNewHorizonsBody(AstroObject ao) + { + if (ao is NHAstroObject nhAO) + { + if (_dict.ContainsKey(nhAO)) return _dict[nhAO]; + } + + if (!_dimensions.ContainsKey(ao)) return null; + + return _dimensions[ao]; + } public static void Init(List bodies) { Main.FurthestOrbit = 30000; ExistingAOConfigs = new Dictionary(); - _dict = new Dictionary(); + _dict = new Dictionary(); + _dimensions = new Dictionary(); // Set up stars // Need to manage this when there are multiple stars @@ -222,8 +236,10 @@ namespace NewHorizons.Handlers GameObject planetObject = GenerateBody(body, defaultPrimaryToSun); if (planetObject == null) return false; planetObject.SetActive(true); - var nhAO = planetObject.GetComponent(); - if (nhAO != null) _dict.Add(nhAO, body); + var nhAO = planetObject.GetComponent(); + var owAO = planetObject.GetComponent(); + if (nhAO != null) _dict.Add(nhAO, body); + else if (owAO != null) _dimensions.Add(owAO, body); } catch (Exception e) { @@ -290,6 +306,7 @@ namespace NewHorizons.Handlers var owRigidBody = go.GetComponent(); go = SharedGenerateBody(body, go, sector, owRigidBody); + body.Object = go; if (ao.GetAstroObjectName() == AstroObject.Name.CustomString) {