added exit pairing for dimensions

This commit is contained in:
FreezeDriedMangoes 2022-06-29 21:48:50 -04:00
parent 5625fd394e
commit ce9522e90a
4 changed files with 33 additions and 8 deletions

View File

@ -47,6 +47,9 @@ namespace NewHorizons.Builder.Body
intr.name = "Interactibles";
GameObject.Destroy(intr);
exitWarps.GetComponent<OuterFogWarpVolume>()._senderWarps.Clear();
exitWarps.GetComponent<OuterFogWarpVolume>()._linkedInnerWarpVolume = null;
// TODO MAYBE: set "exitWarps/ExitPoint", "exitWarp/ExitPoint (1)", ... "exitWarp/ExitPoint (5)"
return dimension;

View File

@ -16,18 +16,29 @@ namespace NewHorizons.Builder.Props
// unpairedNodes[name of dimension that doesn't exist yet] => List{warp controller for node that links to that dimension, ...}
private static Dictionary<string, List<InnerFogWarpVolume>> unpairedNodes = new();
public static void PairUnpairedNodesForDimension(string dimensionName, AstroObject dimensionAO = null)
{
if (!unpairedNodes.ContainsKey(dimensionName)) return;
public static Dictionary<string, InnerFogWarpVolume> namedNodes = new();
foreach (var warpVolume in unpairedNodes[dimensionName])
public static void FinishPairingNodesForDimension(string dimensionName, AstroObject dimensionAO = null, BrambleDimensionInfo dimensionInfo = null)
{
Pair(warpVolume, dimensionName, dimensionAO);
// pair node->dimension (entrances)
if (unpairedNodes.ContainsKey(dimensionName))
{
foreach (var nodeWarpController in unpairedNodes[dimensionName])
{
Pair(nodeWarpController, dimensionName, dimensionAO);
}
unpairedNodes.Remove(dimensionName);
}
// pair dimension->node (exit)
if (dimensionInfo != null && dimensionAO != null && namedNodes.ContainsKey(dimensionInfo.linksTo))
{
var dimensionWarpController = dimensionAO.GetComponentInChildren<OuterFogWarpVolume>();
dimensionWarpController._linkedInnerWarpVolume = namedNodes[dimensionInfo.linksTo];
}
}
private static void RecordUnpairedNode(InnerFogWarpVolume warpVolume, string linksTo)
{
if (!unpairedNodes.ContainsKey(linksTo)) unpairedNodes[linksTo] = new();
@ -56,6 +67,7 @@ namespace NewHorizons.Builder.Props
if (destination == null) return false;
nodeWarp._linkedOuterWarpVolume = destination;
destination._senderWarps.Add(nodeWarp);
return true;
}

View File

@ -35,6 +35,11 @@ namespace NewHorizons.External.Modules
/// The color of the fog inside this dimension. Leave blank for the default yellowish color
/// </summary>
public MColor fogTint;
/// <summary>
/// The name of the *node* that the player is taken to when exiting this dimension.
/// </summary>
public string linksTo;
}
@ -61,10 +66,15 @@ namespace NewHorizons.External.Modules
/// </summary>
public string linksTo;
/// <summary>
/// The name of this node. Only required if this node should serve as an exit.
/// </summary>
public string name;
/// <summary>
/// Set this to true to make this node a seed instead of a node the player can enter
/// </summary>
public bool seed;
public bool isSeed;
/// <summary>
/// The color of the fog inside the node. Leave blank for the default yellowish color

View File

@ -435,7 +435,7 @@ namespace NewHorizons.Handlers
if (body.Config.Bramble.dimension != null)
{
BrambleNodeBuilder.PairUnpairedNodesForDimension(body.Config.name, body.Object.GetComponent<AstroObject>());
BrambleNodeBuilder.FinishPairingNodesForDimension(body.Config.name, body.Object.GetComponent<AstroObject>());
}
}