I don't know how I should structure this

This commit is contained in:
Noah Pilarski 2022-08-18 08:51:09 -04:00
parent e397cbc7c5
commit 48f501947c
2 changed files with 12 additions and 25 deletions

View File

@ -190,11 +190,6 @@ namespace NewHorizons.Builder.Body
shockLayerRuleset._outerRadius = starModule.size * OuterRadiusRatio; shockLayerRuleset._outerRadius = starModule.size * OuterRadiusRatio;
if (starModule.tint != null) shockLayerRuleset._color *= starModule.tint.ToColor(); if (starModule.tint != null) shockLayerRuleset._color *= starModule.tint.ToColor();
var stellarRemnant = MakeStellarRemnant(planetGO, sector, starModule);
controller.SetStellarRemnantController(stellarRemnant);
return starController; return starController;
} }
@ -228,12 +223,6 @@ namespace NewHorizons.Builder.Body
planet.GetComponentInChildren<StarEvolutionController>(true).SetProxy(controller); planet.GetComponentInChildren<StarEvolutionController>(true).SetProxy(controller);
var stellarRemnant = MakeStellarRemnant(proxyGO, null, starModule);
planet.GetComponentInChildren<StellarRemnantController>(true).SetProxy(stellarRemnant);
controller.SetStellarRemnantController(stellarRemnant);
return proxyGO; return proxyGO;
} }
@ -354,19 +343,5 @@ namespace NewHorizons.Builder.Body
return supernova; return supernova;
} }
public static StellarRemnantController MakeStellarRemnant(GameObject rootObject, Sector sector, StarModule starModule)
{
var stellarRemnant = new GameObject("StellarRemnant");
stellarRemnant.transform.SetParent(sector?.transform ?? rootObject.transform, false);
stellarRemnant.SetActive(false);
var controller = stellarRemnant.AddComponent<StellarRemnantController>();
controller.SetStarEvolutionController(rootObject.GetComponentInChildren<StarEvolutionController>());
stellarRemnant.SetActive(true);
return controller;
}
} }
} }

View File

@ -5,6 +5,7 @@ using NewHorizons.Builder.Orbital;
using NewHorizons.Builder.Props; using NewHorizons.Builder.Props;
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Components.Orbital; using NewHorizons.Components.Orbital;
using NewHorizons.Components.SizeControllers;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using System; using System;
@ -203,6 +204,17 @@ namespace NewHorizons.Handlers
{ {
try try
{ {
var rb = existingPlanet.GetComponent<OWRigidbody>();
var sector = SectorBuilder.Make(existingPlanet, rb, GetSphereOfInfluence(body));
sector.name = $"StellarRemnant";
var stellarRemnantController = sector.gameObject.AddComponent<StellarRemnantController>();
var starEvolutionController = existingPlanet.GetComponentInChildren<StarEvolutionController>(true);
stellarRemnantController.SetStarEvolutionController(starEvolutionController);
starEvolutionController.SetStellarRemnantController(stellarRemnantController);
SharedGenerateBody(body, existingPlanet, sector, rb);
} }
catch (Exception ex) catch (Exception ex)
{ {