mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
119 lines
4.9 KiB
C#
119 lines
4.9 KiB
C#
using NewHorizons.Builder.Props;
|
|
using NewHorizons.Utility;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using static NewHorizons.External.Modules.BrambleModule;
|
|
using Logger = NewHorizons.Utility.Logger;
|
|
|
|
namespace NewHorizons.Builder.Body
|
|
{
|
|
public static class BrambleDimensionBuilder
|
|
{
|
|
public static readonly float BASE_DIMENSION_RADIUS = 1705f;
|
|
|
|
// location of all vanilla bramble dimensions
|
|
//-9116.795 -19873.44 2480.327
|
|
//-8460.688 -19873.44 6706.444
|
|
//-5015.165 -19873.44 4142.816
|
|
//-8993.414 -17059.44 4521.747
|
|
//-7044.813 -17135.44 3272.149
|
|
//-6904.48 -17048.44 5574.479
|
|
//-11096.95 -22786.44 4657.534
|
|
//-8716.807 -22786.44 4496.394
|
|
|
|
|
|
// keys are all node names that have been referenced as an exit by at least one dimension but do not (yet) exist
|
|
// values are all dimensions' warp controllers that link to a given dimension
|
|
// unpairedNodes[name of node that doesn't exist yet] => List{warp controller for dimension that exits to that node, ...}
|
|
private static Dictionary<string, List<OuterFogWarpVolume>> unpairedDimensions = new();
|
|
|
|
public static GameObject Make(NewHorizonsBody body)
|
|
{
|
|
var config = body.Config.Bramble.dimension;
|
|
|
|
// spawn the dimension body
|
|
var dimensionPrefab = SearchUtilities.Find("DB_HubDimension_Body");
|
|
var dimension = GameObject.Instantiate(dimensionPrefab);
|
|
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";
|
|
|
|
// set position
|
|
ao.transform.position = body.Config.Orbit.staticPosition;
|
|
|
|
// 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 = dimension.FindChild("Sector_HubDimension");
|
|
dimensionSector.name = "Sector";
|
|
var atmo = dimensionSector.FindChild("Atmosphere_HubDimension");
|
|
var geom = dimensionSector.FindChild("Geometry_HubDimension");
|
|
var vols = dimensionSector.FindChild("Volumes_HubDimension");
|
|
var efxs = dimensionSector.FindChild("Effects_HubDimension");
|
|
var intr = dimensionSector.FindChild("Interactables_HubDimension");
|
|
var exitWarps = intr.FindChild("OuterWarp_Hub");
|
|
|
|
exitWarps.name = "OuterWarp";
|
|
exitWarps.transform.parent = dimensionSector.transform;
|
|
atmo.name = "Atmosphere";
|
|
geom.name = "Geometry"; // disable this?
|
|
vols.name = "Volumes";
|
|
efxs.name = "Effects";
|
|
intr.name = "Interactibles";
|
|
GameObject.Destroy(intr);
|
|
|
|
// set up warps
|
|
var outerFogWarpVolume = exitWarps.GetComponent<OuterFogWarpVolume>();
|
|
outerFogWarpVolume._senderWarps.Clear();
|
|
outerFogWarpVolume._linkedInnerWarpVolume = null;
|
|
outerFogWarpVolume._name = OuterFogWarpVolume.Name.None;
|
|
|
|
PairExit(config.linksTo, outerFogWarpVolume);
|
|
|
|
// change fog color
|
|
if (body.Config.Bramble.dimension.fogTint != null)
|
|
{
|
|
var fogGO = atmo.FindChild("FogSphere_Hub");
|
|
var fog = fogGO.GetComponent<PlanetaryFogController>();
|
|
fog.fogTint = body.Config.Bramble.dimension.fogTint.ToColor();
|
|
}
|
|
|
|
|
|
return dimension;
|
|
}
|
|
|
|
public static void PairExit(string exitName, OuterFogWarpVolume warpController)
|
|
{
|
|
Logger.Log($"attempting to pair exit {exitName}");
|
|
if (!BrambleNodeBuilder.namedNodes.ContainsKey(exitName))
|
|
{
|
|
if (!unpairedDimensions.ContainsKey(exitName)) unpairedDimensions[exitName] = new();
|
|
unpairedDimensions[exitName].Add(warpController);
|
|
return;
|
|
}
|
|
Logger.Log($"pairing exit {exitName}");
|
|
warpController._linkedInnerWarpVolume = BrambleNodeBuilder.namedNodes[exitName];
|
|
}
|
|
|
|
public static void FinishPairingDimensionsForExitNode(string nodeName)
|
|
{
|
|
if (!unpairedDimensions.ContainsKey(nodeName)) return;
|
|
|
|
var warpControllers = unpairedDimensions[nodeName].ToList();
|
|
foreach (var dimensionWarpController in warpControllers)
|
|
{
|
|
PairExit(nodeName, dimensionWarpController);
|
|
}
|
|
|
|
//unpairedDimensions.Remove(nodeName);
|
|
}
|
|
|
|
}
|
|
}
|