mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix null stuff + NHAO
This commit is contained in:
parent
2fabfcb1a5
commit
0c420e61e7
@ -26,12 +26,12 @@ namespace NewHorizons.Builder.Body
|
|||||||
// keys are all node names that have been referenced as an exit by at least one dimension but do not (yet) exist
|
// 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
|
// 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, ...}
|
// 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();
|
private static Dictionary<string, List<OuterFogWarpVolume>> _unpairedDimensions;
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
// Just in case something went wrong and a dimension never got paired last time
|
// Just in case something went wrong and a dimension never got paired last time
|
||||||
_unpairedDimensions.Clear();
|
_unpairedDimensions = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject Make(NewHorizonsBody body)
|
public static GameObject Make(NewHorizonsBody body)
|
||||||
@ -42,19 +42,18 @@ namespace NewHorizons.Builder.Body
|
|||||||
var dimensionPrefab = SearchUtilities.Find("DB_HubDimension_Body");
|
var dimensionPrefab = SearchUtilities.Find("DB_HubDimension_Body");
|
||||||
var dimension = dimensionPrefab.InstantiateInactive();
|
var dimension = dimensionPrefab.InstantiateInactive();
|
||||||
|
|
||||||
PlanetCreationHandler.UpdateBodyOrbit(body, dimension);
|
// Fix AO
|
||||||
|
var ao = dimension.GetComponent<AstroObject>();
|
||||||
|
var nhao = dimension.AddComponent<NHAstroObject>();
|
||||||
|
nhao.CopyPropertiesFrom(ao);
|
||||||
|
Component.Destroy(ao);
|
||||||
|
|
||||||
// fix name
|
nhao.IsDimension = true;
|
||||||
var ao = dimension.GetComponent<NHAstroObject>();
|
|
||||||
ao.IsDimension = true;
|
|
||||||
var name = body.Config.name ?? "Custom Bramble Dimension";
|
var name = body.Config.name ?? "Custom Bramble Dimension";
|
||||||
ao._customName = name;
|
nhao._customName = name;
|
||||||
ao._name = AstroObject.Name.CustomString;
|
nhao._name = AstroObject.Name.CustomString;
|
||||||
dimension.name = name.Replace(" ", "").Replace("'", "") + "_Body";
|
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
|
// 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");
|
var dimensionSector = dimension.FindChild("Sector_HubDimension");
|
||||||
dimensionSector.name = "Sector";
|
dimensionSector.name = "Sector";
|
||||||
@ -74,9 +73,9 @@ namespace NewHorizons.Builder.Body
|
|||||||
intr.name = "Interactibles";
|
intr.name = "Interactibles";
|
||||||
GameObject.Destroy(intr);
|
GameObject.Destroy(intr);
|
||||||
|
|
||||||
// set up warps
|
// Set up warps
|
||||||
var outerFogWarpVolume = exitWarps.GetComponent<OuterFogWarpVolume>();
|
var outerFogWarpVolume = exitWarps.GetComponent<OuterFogWarpVolume>();
|
||||||
outerFogWarpVolume._senderWarps.Clear();
|
outerFogWarpVolume._senderWarps = new List<InnerFogWarpVolume>();
|
||||||
outerFogWarpVolume._linkedInnerWarpVolume = null;
|
outerFogWarpVolume._linkedInnerWarpVolume = null;
|
||||||
outerFogWarpVolume._name = OuterFogWarpVolume.Name.None;
|
outerFogWarpVolume._name = OuterFogWarpVolume.Name.None;
|
||||||
|
|
||||||
@ -97,14 +96,14 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
public static void PairExit(string exitName, OuterFogWarpVolume warpController)
|
public static void PairExit(string exitName, OuterFogWarpVolume warpController)
|
||||||
{
|
{
|
||||||
if (!BrambleNodeBuilder.namedNodes.ContainsKey(exitName))
|
if (!BrambleNodeBuilder.NamedNodes.ContainsKey(exitName))
|
||||||
{
|
{
|
||||||
if (!_unpairedDimensions.ContainsKey(exitName)) _unpairedDimensions[exitName] = new();
|
if (!_unpairedDimensions.ContainsKey(exitName)) _unpairedDimensions[exitName] = new();
|
||||||
_unpairedDimensions[exitName].Add(warpController);
|
_unpairedDimensions[exitName].Add(warpController);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
warpController._linkedInnerWarpVolume = BrambleNodeBuilder.namedNodes[exitName];
|
warpController._linkedInnerWarpVolume = BrambleNodeBuilder.NamedNodes[exitName];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void FinishPairingDimensionsForExitNode(string nodeName)
|
public static void FinishPairingDimensionsForExitNode(string nodeName)
|
||||||
|
|||||||
@ -23,15 +23,15 @@ namespace NewHorizons.Builder.Props
|
|||||||
private static Dictionary<string, List<InnerFogWarpVolume>> _unpairedNodes = new();
|
private static Dictionary<string, List<InnerFogWarpVolume>> _unpairedNodes = new();
|
||||||
private static Dictionary<string, List<SignalInfo>> _propogatedSignals = null;
|
private static Dictionary<string, List<SignalInfo>> _propogatedSignals = null;
|
||||||
|
|
||||||
public static readonly Dictionary<string, InnerFogWarpVolume> namedNodes = new();
|
public static Dictionary<string, InnerFogWarpVolume> NamedNodes { get; private set; }
|
||||||
public static readonly Dictionary<BrambleNodeInfo, GameObject> builtBrambleNodes = new();
|
public static Dictionary<BrambleNodeInfo, GameObject> BuiltBrambleNodes { get; private set; }
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
_unpairedNodes.Clear();
|
_unpairedNodes = new();
|
||||||
_propogatedSignals.Clear();
|
_propogatedSignals = null;
|
||||||
namedNodes.Clear();
|
NamedNodes = new();
|
||||||
builtBrambleNodes.Clear();
|
BuiltBrambleNodes = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void FinishPairingNodesForDimension(string dimensionName, AstroObject dimensionAO = null)
|
public static void FinishPairingNodesForDimension(string dimensionName, AstroObject dimensionAO = null)
|
||||||
@ -199,7 +199,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
//
|
//
|
||||||
if (config.name != null)
|
if (config.name != null)
|
||||||
{
|
{
|
||||||
namedNodes[config.name] = warpController;
|
NamedNodes[config.name] = warpController;
|
||||||
BrambleDimensionBuilder.FinishPairingDimensionsForExitNode(config.name);
|
BrambleDimensionBuilder.FinishPairingDimensionsForExitNode(config.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -611,7 +611,8 @@ namespace NewHorizons.Handlers
|
|||||||
newAO._primaryBody = primary;
|
newAO._primaryBody = primary;
|
||||||
|
|
||||||
// Since we destroyed the AO we have to replace links to it in other places
|
// Since we destroyed the AO we have to replace links to it in other places
|
||||||
newAO.gameObject.GetComponentInChildren<ReferenceFrameVolume>()._referenceFrame._attachedAstroObject = newAO;
|
var referenceFrame = newAO.gameObject.GetComponentInChildren<ReferenceFrameVolume>()._referenceFrame;
|
||||||
|
if (referenceFrame != null) referenceFrame._attachedAstroObject = newAO;
|
||||||
|
|
||||||
// QM and stuff don't have orbit lines
|
// QM and stuff don't have orbit lines
|
||||||
var orbitLine = go.GetComponentInChildren<OrbitLine>()?.gameObject;
|
var orbitLine = go.GetComponentInChildren<OrbitLine>()?.gameObject;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user