mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Not gonna use detail builder
This commit is contained in:
parent
ec9fe20c7c
commit
f283a8b2c8
@ -175,7 +175,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
public static void Make(GameObject go, Sector sector, BrambleNodeInfo[] configs, IModBehaviour mod)
|
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);
|
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)
|
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 brambleSeedPrefabPath = "DB_PioneerDimension_Body/Sector_PioneerDimension/Interactables_PioneerDimension/SeedWarp_ToPioneer (1)";
|
||||||
var brambleNodePrefabPath = "DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/InnerWarp_ToCluster";
|
var brambleNodePrefabPath = "DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/InnerWarp_ToCluster";
|
||||||
|
|
||||||
var path = config.isSeed ? brambleSeedPrefabPath : brambleNodePrefabPath;
|
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;
|
brambleNode.name = "Bramble Node to " + config.linksTo;
|
||||||
var warpController = brambleNode.GetComponent<InnerFogWarpVolume>();
|
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"));
|
GameObject.Destroy(brambleNode.FindChild("Signal_Harmonica"));
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Fix some components
|
// Fix some components
|
||||||
//
|
|
||||||
|
|
||||||
var fogLight = brambleNode.GetComponent<FogLight>();
|
var fogLight = brambleNode.GetComponent<FogLight>();
|
||||||
fogLight._parentBody = go.GetComponent<OWRigidbody>();
|
fogLight._parentBody = go.GetComponent<OWRigidbody>();
|
||||||
fogLight._sector = sector;
|
fogLight._sector = sector;
|
||||||
@ -212,14 +208,12 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
sector.RegisterFogLight(fogLight);
|
sector.RegisterFogLight(fogLight);
|
||||||
|
|
||||||
//
|
|
||||||
// Set the scale
|
// Set the scale
|
||||||
//
|
|
||||||
brambleNode.transform.localScale = Vector3.one * config.scale;
|
brambleNode.transform.localScale = Vector3.one * config.scale;
|
||||||
warpController._warpRadius *= config.scale;
|
warpController._warpRadius *= config.scale;
|
||||||
warpController._exitRadius *= 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)
|
if (!config.isSeed)
|
||||||
{
|
{
|
||||||
var fog = brambleNode.FindChild("Effects").FindChild("InnerWarpFogSphere");
|
var fog = brambleNode.FindChild("Effects").FindChild("InnerWarpFogSphere");
|
||||||
@ -244,38 +238,25 @@ namespace NewHorizons.Builder.Props
|
|||||||
// this means that either CheckWarpProximity() or GetFogThickness() is incorrect for the InnerWarpFogSpheres.
|
// this means that either CheckWarpProximity() or GetFogThickness() is incorrect for the InnerWarpFogSpheres.
|
||||||
// most likely it's CheckWarpProximity()
|
// most likely it's CheckWarpProximity()
|
||||||
|
|
||||||
|
// Change the colors
|
||||||
//
|
|
||||||
// change the colors
|
|
||||||
//
|
|
||||||
|
|
||||||
if (config.isSeed) SetSeedColors(brambleNode, config.fogTint?.ToColor(), config.lightTint?.ToColor());
|
if (config.isSeed) SetSeedColors(brambleNode, config.fogTint?.ToColor(), config.lightTint?.ToColor());
|
||||||
else SetNodeColors(brambleNode, config.fogTint?.ToColor(), config.lightTint?.ToColor());
|
else SetNodeColors(brambleNode, config.fogTint?.ToColor(), config.lightTint?.ToColor());
|
||||||
|
|
||||||
//
|
// Set up warps
|
||||||
// set up warps
|
|
||||||
//
|
|
||||||
|
|
||||||
warpController._sector = sector;
|
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._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))
|
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);
|
var success = PairEntrance(warpController, config.linksTo);
|
||||||
if (!success) RecordUnpairedNode(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
|
// Cleanup for dimension exits
|
||||||
//
|
|
||||||
if (config.name != null)
|
if (config.name != null)
|
||||||
{
|
{
|
||||||
NamedNodes[config.name] = warpController;
|
NamedNodes[config.name] = warpController;
|
||||||
BrambleDimensionBuilder.FinishPairingDimensionsForExitNode(config.name);
|
BrambleDimensionBuilder.FinishPairingDimensionsForExitNode(config.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Make signals
|
// Make signals
|
||||||
//
|
|
||||||
if (_propogatedSignals == null) PropogateSignals();
|
if (_propogatedSignals == null) PropogateSignals();
|
||||||
foreach (var signalConfig in _propogatedSignals[config.linksTo])
|
foreach (var signalConfig in _propogatedSignals[config.linksTo])
|
||||||
{
|
{
|
||||||
|
|||||||
@ -94,14 +94,14 @@ namespace NewHorizons.Builder.Props
|
|||||||
detailInfoToCorrespondingSpawnedGameObject[detail] = detailGO;
|
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);
|
var prefab = SearchUtilities.Find(propToClone);
|
||||||
if (prefab == null) Logger.LogError($"Couldn't find detail {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;
|
if (prefab == null) return null;
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale;
|
prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale;
|
||||||
|
|
||||||
if (!leaveInactive) prop.SetActive(true);
|
prop.SetActive(true);
|
||||||
|
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -389,7 +389,14 @@ namespace NewHorizons.Handlers
|
|||||||
body.Object = go;
|
body.Object = go;
|
||||||
|
|
||||||
// Now that we're done move the planet into place
|
// Now that we're done move the planet into place
|
||||||
|
if (body.Config.Orbit?.staticPosition != null)
|
||||||
|
{
|
||||||
|
SetPositionFromVector(go, body.Config.Orbit.staticPosition);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
UpdatePosition(go, body.Config.Orbit, primaryBody, ao);
|
UpdatePosition(go, body.Config.Orbit, primaryBody, ao);
|
||||||
|
}
|
||||||
|
|
||||||
// Have to do this after setting position
|
// Have to do this after setting position
|
||||||
var initialMotion = InitialMotionBuilder.Make(go, primaryBody, ao, owRigidBody, body.Config.Orbit);
|
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);
|
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)
|
if (ao.GetAstroObjectName() == AstroObject.Name.CustomString)
|
||||||
{
|
{
|
||||||
@ -687,19 +689,24 @@ namespace NewHorizons.Handlers
|
|||||||
{
|
{
|
||||||
Logger.LogVerbose($"Placing [{secondaryBody?.name}] around [{primaryBody?.name}]");
|
Logger.LogVerbose($"Placing [{secondaryBody?.name}] around [{primaryBody?.name}]");
|
||||||
|
|
||||||
go.transform.parent = Locator.GetRootTransform();
|
|
||||||
|
|
||||||
if (primaryBody != null)
|
if (primaryBody != null)
|
||||||
{
|
{
|
||||||
var primaryGravity = new Gravity(primaryBody.GetGravityVolume());
|
var primaryGravity = new Gravity(primaryBody.GetGravityVolume());
|
||||||
var secondaryGravity = new Gravity(secondaryBody.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
|
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)
|
if (go.transform.position.magnitude > Main.FurthestOrbit)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user