Not gonna use detail builder

This commit is contained in:
Nick 2022-07-09 15:58:11 -04:00
parent ec9fe20c7c
commit f283a8b2c8
3 changed files with 69 additions and 81 deletions

View File

@ -175,7 +175,7 @@ namespace NewHorizons.Builder.Props
public static void Make(GameObject go, Sector sector, BrambleNodeInfo[] configs, IModBehaviour mod)
{
foreach(var config in configs)
foreach (var config in configs)
{
Make(go, sector, config, mod);
}
@ -183,26 +183,22 @@ namespace NewHorizons.Builder.Props
public static GameObject Make(GameObject go, Sector sector, BrambleNodeInfo config, IModBehaviour mod)
{
//
// spawn the bramble node
//
// Spawn the bramble node
var brambleSeedPrefabPath = "DB_PioneerDimension_Body/Sector_PioneerDimension/Interactables_PioneerDimension/SeedWarp_ToPioneer (1)";
var brambleNodePrefabPath = "DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/InnerWarp_ToCluster";
var path = config.isSeed ? brambleSeedPrefabPath : brambleNodePrefabPath;
var brambleNode = DetailBuilder.MakeDetail(go, sector, path, config.position, config.rotation, 1, false, leaveInactive:true);
var brambleNode = SearchUtilities.Find(path).InstantiateInactive();
brambleNode.transform.parent = sector.transform;
brambleNode.transform.position = go.transform.TransformPoint(config.position);
brambleNode.transform.rotation = go.transform.TransformRotation(Quaternion.Euler(config.rotation));
brambleNode.name = "Bramble Node to " + config.linksTo;
var warpController = brambleNode.GetComponent<InnerFogWarpVolume>();
// this node comes with Feldspar's signal, we don't want that though
// This node comes with Feldspar's signal, we don't want that though
GameObject.Destroy(brambleNode.FindChild("Signal_Harmonica"));
//
// Fix some components
//
var fogLight = brambleNode.GetComponent<FogLight>();
fogLight._parentBody = go.GetComponent<OWRigidbody>();
fogLight._sector = sector;
@ -212,20 +208,18 @@ namespace NewHorizons.Builder.Props
sector.RegisterFogLight(fogLight);
//
// Set the scale
//
brambleNode.transform.localScale = Vector3.one * config.scale;
warpController._warpRadius *= config.scale;
warpController._exitRadius *= config.scale;
// seed fog works differently, so it doesn't need to be fixed (it's also located on a different child path, so the below FindChild calls wouldn't work)
// Seed fog works differently, so it doesn't need to be fixed (it's also located on a different child path, so the below FindChild calls wouldn't work)
if (!config.isSeed)
{
var fog = brambleNode.FindChild("Effects").FindChild("InnerWarpFogSphere");
var fogMaterial = fog.GetComponent<MeshRenderer>().sharedMaterial;
fog.transform.localScale /= config.scale;
fogMaterial.SetFloat("_Radius", fogMaterial.GetFloat("_Radius") * config.scale);
fogMaterial.SetFloat("_Radius", fogMaterial.GetFloat("_Radius") * config.scale);
fogMaterial.SetFloat("_Density", fogMaterial.GetFloat("_Density") / config.scale);
}
@ -237,45 +231,32 @@ namespace NewHorizons.Builder.Props
// found under FogWarpDetector.FixedUpdate()
// FogWarpVolume fogWarpVolume = _warpVolumes[i];
// float num2 = Mathf.Abs(fogWarpVolume.CheckWarpProximity(this));
// float b = Mathf.Clamp01(1f - Mathf.Abs(num2) / fogWarpVolume.GetFogThickness());
// _targetFogFraction = Mathf.Max(_targetFogFraction, b);
// float num2 = Mathf.Abs(fogWarpVolume.CheckWarpProximity(this));
// float b = Mathf.Clamp01(1f - Mathf.Abs(num2) / fogWarpVolume.GetFogThickness());
// _targetFogFraction = Mathf.Max(_targetFogFraction, b);
// this means that either CheckWarpProximity() or GetFogThickness() is incorrect for the InnerWarpFogSpheres.
// most likely it's CheckWarpProximity()
//
// change the colors
//
// Change the colors
if (config.isSeed) SetSeedColors(brambleNode, config.fogTint?.ToColor(), config.lightTint?.ToColor());
else SetNodeColors(brambleNode, config.fogTint?.ToColor(), config.lightTint?.ToColor());
//
// set up warps
//
else SetNodeColors(brambleNode, config.fogTint?.ToColor(), config.lightTint?.ToColor());
// Set up warps
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._containerWarpVolume = GetOuterFogWarpVolumeFromAstroObject(go); // 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 success = PairEntrance(warpController, config.linksTo);
if (!success) RecordUnpairedNode(warpController, config.linksTo);
warpController.Awake(); // I can't spawn this game object disabled, but Awake needs to run after _sector is set. That means I need to call Awake myself
//
// Cleanup for dimension exits
//
if (config.name != null)
{
NamedNodes[config.name] = warpController;
BrambleDimensionBuilder.FinishPairingDimensionsForExitNode(config.name);
}
//
// Make signals
//
if (_propogatedSignals == null) PropogateSignals();
foreach (var signalConfig in _propogatedSignals[config.linksTo])
{

View File

@ -94,14 +94,14 @@ namespace NewHorizons.Builder.Props
detailInfoToCorrespondingSpawnedGameObject[detail] = detailGO;
}
public static GameObject MakeDetail(GameObject go, Sector sector, string propToClone, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal, bool leaveInactive=false)
public static GameObject MakeDetail(GameObject go, Sector sector, string propToClone, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal)
{
var prefab = SearchUtilities.Find(propToClone);
if (prefab == null) Logger.LogError($"Couldn't find detail {propToClone}");
return MakeDetail(go, sector, prefab, position, rotation, scale, alignWithNormal, leaveInactive);
return MakeDetail(go, sector, prefab, position, rotation, scale, alignWithNormal);
}
public static GameObject MakeDetail(GameObject planetGO, Sector sector, GameObject prefab, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal, bool leaveInactive=false)
public static GameObject MakeDetail(GameObject planetGO, Sector sector, GameObject prefab, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal)
{
if (prefab == null) return null;
@ -271,7 +271,7 @@ namespace NewHorizons.Builder.Props
prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale;
if (!leaveInactive) prop.SetActive(true);
prop.SetActive(true);
return prop;
}

View File

@ -389,7 +389,14 @@ namespace NewHorizons.Handlers
body.Object = go;
// Now that we're done move the planet into place
UpdatePosition(go, body.Config.Orbit, primaryBody, ao);
if (body.Config.Orbit?.staticPosition != null)
{
SetPositionFromVector(go, body.Config.Orbit.staticPosition);
}
else
{
UpdatePosition(go, body.Config.Orbit, primaryBody, ao);
}
// Have to do this after setting position
var initialMotion = InitialMotionBuilder.Make(go, primaryBody, ao, owRigidBody, body.Config.Orbit);
@ -410,11 +417,6 @@ namespace NewHorizons.Handlers
{
DetectorBuilder.Make(go, owRigidBody, primaryBody, ao, body.Config);
}
else if (body.Config.Orbit.staticPosition != null)
{
// NH doesn't set the value of _centerOfTheUniverse for a few frames
ao.transform.position = body.Config.Orbit.staticPosition + Locator._centerOfTheUniverse._staticReferenceFrame._lastPosition;
}
if (ao.GetAstroObjectName() == AstroObject.Name.CustomString)
{
@ -687,19 +689,24 @@ namespace NewHorizons.Handlers
{
Logger.LogVerbose($"Placing [{secondaryBody?.name}] around [{primaryBody?.name}]");
go.transform.parent = Locator.GetRootTransform();
if (primaryBody != null)
{
var primaryGravity = new Gravity(primaryBody.GetGravityVolume());
var secondaryGravity = new Gravity(secondaryBody.GetGravityVolume());
go.transform.position = orbit.GetOrbitalParameters(primaryGravity, secondaryGravity).InitialPosition + primaryBody.transform.position;
var pos = orbit.GetOrbitalParameters(primaryGravity, secondaryGravity).InitialPosition + primaryBody.transform.position;
SetPositionFromVector(go, pos);
}
else
{
go.transform.position = Vector3.zero;
SetPositionFromVector(go, Vector3.zero);
}
}
public static void SetPositionFromVector(GameObject go, Vector3 position)
{
go.transform.parent = Locator.GetRootTransform();
go.transform.position = position;
if (go.transform.position.magnitude > Main.FurthestOrbit)
{