set up basics for building bramble dimensions and bramble nodes

This commit is contained in:
FreezeDriedMangoes 2022-06-29 09:43:39 -04:00
parent 61ad85c685
commit c65600ab1f
3 changed files with 147 additions and 1 deletions

View File

@ -0,0 +1,39 @@
using NewHorizons.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Builder.Body
{
public class BrambleDimensionBuilder
{
public void Make()
{
var dimensionPrefab = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension");
var dimension = GameObject.Instantiate(dimensionPrefab);
//dimension.name = config.rename ?? "Custom Bramble Dimension";
var dimensionSector = SearchUtilities.FindChild(dimension, "Sector_HubDimension");
dimensionSector.name = "Sector";
var atmo = SearchUtilities.FindChild(dimension, "Atmosphere_HubDimension");
var geom = SearchUtilities.FindChild(dimension, "Geometry_HubDimension");
var vols = SearchUtilities.FindChild(dimension, "Volumes_HubDimension");
var efxs = SearchUtilities.FindChild(dimension, "Effects_HubDimension");
var intr = SearchUtilities.FindChild(dimension, "Interactables_HubDimension");
var exitWarps = SearchUtilities.FindChild(intr, "OuterWarp_Hub");
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);
// TODO: set "exitWarps/ExitPoint", "exitWarp/ExitPoint (1)", ... "exitWarp/ExitPoint (5)"
}
}
}

View File

@ -0,0 +1,73 @@
using NewHorizons.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Builder.Props
{
public class BrambleNodeBuilder
{
// DB_EscapePodDimension_Body/Sector_EscapePodDimension/Interactables_EscapePodDimension/InnerWarp_ToAnglerNest // need to change the light shaft color
// DB_ExitOnlyDimension_Body/Sector_ExitOnlyDimension/Interactables_ExitOnlyDimension/InnerWarp_ToExitOnly // need to change the colors
// DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/InnerWarp_ToCluster // need to delete the child "Signal_Harmonica"
public void Make(GameObject go, Sector sector, BrambleNodeConfig config)
{
//
// spawn the bramble node
//
var brambleNodePrefabPath = "DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/InnerWarp_ToCluster";
var brambleNode = DetailBuilder.MakeDetail(go, sector, brambleNodePrefabPath, config.position, config.rotation, config.scale, false);
// this node comes with Feldspar's signal, we don't want that though
GameObject.Destroy(SearchUtilities.FindChild(brambleNode, "Signal_Harmonica"));
//
// TODO: change the colors
//
//var effects = SearchUtilities.FindChild(brambleNode, "Effects");
//var fogRenderer = SearchUtilities.FindChild(effects, "InnerWarpFogSphere");
//var lightShafts = SearchUtilities.FindChild(effects, "DB_BrambleLightShafts");
//var lightShaft1 = SearchUtilities.FindChild(lightShafts, "BrambleLightShaft1");
//
// set up warps
//
var warpController = brambleNode.GetComponent<InnerFogWarpVolume>();
warpController._sector = sector;
warpController._attachedBody = go.GetComponent<OWRigidbody>(); // I don't think this is necessary, it seems to be set correctly on its own
// warpController._linkedOuterWarpVolume = the outer warp volume of the dimension this node leads to
// warpController._containerWarpVolume = the OuterFogWarpVolume of the dimension this node is inside of (null if this node is not inside of a bramble dimension (eg it's sitting on a planet or something))
//var exitPointsParent = SearchUtilities.FindChild(brambleNode, "FogWarpExitPoints"); // "ExitPoint", "ExitPoint (1)" ... "ExitPoint (5)"
//var exitPointsNames = new string[]
//{
// "ExitPoint",
// "ExitPoint (1)",
// "ExitPoint (2)",
// "ExitPoint (3)",
// "ExitPoint (4)",
// "ExitPoint (5)",
//};
//for (int i = 0; i < 6; i++)
//{
// var exitPoint = SearchUtilities.FindChild(exitPointsParent, exitPointsNames[i]);
// var sphericalFogWarpExit = exitPoint.GetComponent<SphericalFogWarpExit>();
// // I don't think anything actually needs to be done here
//}
//
// TODO: support adding signals to these nodes
//
}
}
}

View File

@ -142,7 +142,7 @@ namespace NewHorizons.Utility.DebugMenu
Vector3 latestPropSphericalPosDelta = VectorInput(mostRecentlyPlacedPropSphericalPos, propSphericalPosDelta, out propSphericalPosDelta, "lat ", "lon ", "height"); Vector3 latestPropSphericalPosDelta = VectorInput(mostRecentlyPlacedPropSphericalPos, propSphericalPosDelta, out propSphericalPosDelta, "lat ", "lon ", "height");
if (latestPropSphericalPosDelta != Vector3.zero) if (latestPropSphericalPosDelta != Vector3.zero)
{ {
DeltaSphericalPosition(mostRecentlyPlacedProp, latestPropSphericalPosDelta); SetSphericalPosition(mostRecentlyPlacedProp, mostRecentlyPlacedPropSphericalPos + latestPropSphericalPosDelta);
mostRecentlyPlacedPropSphericalPos = mostRecentlyPlacedPropSphericalPos + latestPropSphericalPosDelta; mostRecentlyPlacedPropSphericalPos = mostRecentlyPlacedPropSphericalPos + latestPropSphericalPosDelta;
} }
@ -209,6 +209,40 @@ namespace NewHorizons.Utility.DebugMenu
return newSpherical; return newSpherical;
} }
// DB_EscapePodDimension_Body/Sector_EscapePodDimension/Interactables_EscapePodDimension/InnerWarp_ToAnglerNest
// DB_ExitOnlyDimension_Body/Sector_ExitOnlyDimension/Interactables_ExitOnlyDimension/InnerWarp_ToExitOnly // need to change the colors
// DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/InnerWarp_ToCluster // need to delete the child "Signal_Harmonica"
private Vector3 SetSphericalPosition(GameObject prop, Vector3 newSpherical)
{
Transform astroObject = prop.transform.parent.parent;
Transform sector = prop.transform.parent;
Vector3 originalLocalPos = astroObject.InverseTransformPoint(prop.transform.position); // parent is the sector, this gives localPos relative to the astroobject (what the DetailBuilder asks for)
Vector3 sphericalPos = CoordinateUtilities.CartesianToSpherical(originalLocalPos);
if (newSpherical == sphericalPos) return sphericalPos;
Vector3 finalLocalPosition = CoordinateUtilities.SphericalToCartesian(newSpherical);
Vector3 finalAbsolutePosition = astroObject.TransformPoint(finalLocalPosition);
prop.transform.localPosition = prop.transform.parent.InverseTransformPoint(finalAbsolutePosition);
Logger.Log("new position: " + prop.transform.localPosition);
var onlyChangingRAndRIsNegative = false;
// first, rotate the object by the astroObject's rotation, that means anything afterwards is relative to this rotation (ie, we can pretend the astroObject has 0 rotation)
// then, rotate by the difference in position, basically accounting for the curvature of a sphere
// then re-apply the local rotations of the hierarchy down to the prop (apply the sector local rotation, then the prop local rotation)
// since we're doing all rotation relative to the astro object, we start with its absolute rotation
// then we apply the rotation about the astroobject using FromTooRotation
// then we reapply the local rotations down through the hierarchy
Vector3 originalLocalPos_ForcedPositiveR = CoordinateUtilities.SphericalToCartesian(new Vector3(sphericalPos.x, sphericalPos.y, Mathf.Abs(sphericalPos.z)));
Vector3 finalLocalPos_ForcedPositiveR = CoordinateUtilities.SphericalToCartesian(new Vector3(newSpherical.x, newSpherical.y, Mathf.Abs(newSpherical.z)));
if (!onlyChangingRAndRIsNegative) prop.transform.rotation = astroObject.rotation * Quaternion.FromToRotation(originalLocalPos_ForcedPositiveR.normalized, finalLocalPos_ForcedPositiveR.normalized) * sector.localRotation * prop.transform.localRotation;
return newSpherical;
}
private Vector3 VectorInput(Vector3 input, Vector3 deltaControls, out Vector3 deltaControlsOut, string labelX, string labelY, string labelZ) private Vector3 VectorInput(Vector3 input, Vector3 deltaControls, out Vector3 deltaControlsOut, string labelX, string labelY, string labelZ)
{ {
var dx = deltaControls.x; var dx = deltaControls.x;