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"; intr.name = "Interactibles";
GameObject.Destroy(intr); GameObject.Destroy(intr);
exitWarps.GetComponent<OuterFogWarpVolume>()._senderWarps.Clear();
exitWarps.GetComponent<OuterFogWarpVolume>()._linkedInnerWarpVolume = null;
// TODO MAYBE: set "exitWarps/ExitPoint", "exitWarp/ExitPoint (1)", ... "exitWarp/ExitPoint (5)" // TODO MAYBE: set "exitWarps/ExitPoint", "exitWarp/ExitPoint (1)", ... "exitWarp/ExitPoint (5)"
return dimension; return dimension;

View File

@ -16,16 +16,27 @@ namespace NewHorizons.Builder.Props
// unpairedNodes[name of dimension that doesn't exist yet] => List{warp controller for node that links to that dimension, ...} // 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(); private static Dictionary<string, List<InnerFogWarpVolume>> unpairedNodes = new();
public static void PairUnpairedNodesForDimension(string dimensionName, AstroObject dimensionAO = null) public static Dictionary<string, InnerFogWarpVolume> namedNodes = new();
{
if (!unpairedNodes.ContainsKey(dimensionName)) return;
foreach (var warpVolume in unpairedNodes[dimensionName]) public static void FinishPairingNodesForDimension(string dimensionName, AstroObject dimensionAO = null, BrambleDimensionInfo dimensionInfo = null)
{
// pair node->dimension (entrances)
if (unpairedNodes.ContainsKey(dimensionName))
{ {
Pair(warpVolume, dimensionName, dimensionAO); foreach (var nodeWarpController in unpairedNodes[dimensionName])
{
Pair(nodeWarpController, dimensionName, dimensionAO);
}
unpairedNodes.Remove(dimensionName);
} }
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) private static void RecordUnpairedNode(InnerFogWarpVolume warpVolume, string linksTo)
@ -56,6 +67,7 @@ namespace NewHorizons.Builder.Props
if (destination == null) return false; if (destination == null) return false;
nodeWarp._linkedOuterWarpVolume = destination; nodeWarp._linkedOuterWarpVolume = destination;
destination._senderWarps.Add(nodeWarp);
return true; 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 /// The color of the fog inside this dimension. Leave blank for the default yellowish color
/// </summary> /// </summary>
public MColor fogTint; 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> /// </summary>
public string linksTo; public string linksTo;
/// <summary>
/// The name of this node. Only required if this node should serve as an exit.
/// </summary>
public string name;
/// <summary> /// <summary>
/// Set this to true to make this node a seed instead of a node the player can enter /// Set this to true to make this node a seed instead of a node the player can enter
/// </summary> /// </summary>
public bool seed; public bool isSeed;
/// <summary> /// <summary>
/// The color of the fog inside the node. Leave blank for the default yellowish color /// 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) if (body.Config.Bramble.dimension != null)
{ {
BrambleNodeBuilder.PairUnpairedNodesForDimension(body.Config.name, body.Object.GetComponent<AstroObject>()); BrambleNodeBuilder.FinishPairingNodesForDimension(body.Config.name, body.Object.GetComponent<AstroObject>());
} }
} }