mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Actually add the renaming and parenting stuff
This commit is contained in:
parent
25e9eaf16f
commit
97a2ccd258
@ -88,9 +88,8 @@ namespace NewHorizons.Builder.Body
|
|||||||
Vector3 localPosition = singularity?.position == null ? Vector3.zero : singularity.position;
|
Vector3 localPosition = singularity?.position == null ? Vector3.zero : singularity.position;
|
||||||
Vector3 localRotation = singularity?.rotation == null ? Vector3.zero : singularity.rotation;
|
Vector3 localRotation = singularity?.rotation == null ? Vector3.zero : singularity.rotation;
|
||||||
|
|
||||||
GameObject newSingularity = null;
|
GameObject newSingularity = MakeSingularity(go, sector, localPosition, localRotation, polarity, horizonRadius, distortRadius,
|
||||||
newSingularity = MakeSingularity(go, sector, localPosition, localRotation, polarity, horizonRadius, distortRadius,
|
hasHazardVolume, singularity.targetStarSystem, singularity.curve, singularity.hasWarpEffects, singularity.renderQueueOverride, singularity.rename, singularity.parentPath, singularity.isRelativeToParent);
|
||||||
hasHazardVolume, singularity.targetStarSystem, singularity.curve, singularity.hasWarpEffects, singularity.renderQueueOverride);
|
|
||||||
|
|
||||||
var uniqueID = string.IsNullOrEmpty(singularity.uniqueID) ? config.name : singularity.uniqueID;
|
var uniqueID = string.IsNullOrEmpty(singularity.uniqueID) ? config.name : singularity.uniqueID;
|
||||||
_singularitiesByID.Add(uniqueID, newSingularity);
|
_singularitiesByID.Add(uniqueID, newSingularity);
|
||||||
@ -134,14 +133,31 @@ namespace NewHorizons.Builder.Body
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject MakeSingularity(GameObject planetGO, Sector sector, Vector3 position, Vector3 rotation, bool polarity, float horizon, float distort,
|
public static GameObject MakeSingularity(GameObject planetGO, Sector sector, Vector3 position, Vector3 rotation, bool polarity, float horizon, float distort,
|
||||||
bool hasDestructionVolume, string targetStarSystem = null, TimeValuePair[] curve = null, bool warpEffects = true, int renderQueue = 2985)
|
bool hasDestructionVolume, string targetStarSystem = null, TimeValuePair[] curve = null, bool warpEffects = true, int renderQueue = 2985, string rename = null, string parentPath = null, bool isRelativeToParent = false)
|
||||||
{
|
{
|
||||||
InitPrefabs();
|
InitPrefabs();
|
||||||
|
|
||||||
// polarity true = black, false = white
|
// polarity true = black, false = white
|
||||||
|
|
||||||
var singularity = new GameObject(polarity ? "BlackHole" : "WhiteHole");
|
var singularity = new GameObject(!string.IsNullOrEmpty(rename) ? rename : (polarity ? "BlackHole" : "WhiteHole"));
|
||||||
singularity.transform.parent = sector?.transform ?? planetGO.transform;
|
singularity.transform.parent = sector?.transform ?? planetGO.transform;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(parentPath))
|
||||||
|
{
|
||||||
|
var newParent = planetGO.transform.Find(parentPath);
|
||||||
|
if (newParent != null)
|
||||||
|
{
|
||||||
|
singularity.transform.parent = newParent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Cannot find parent object at path: {planetGO.name}/{parentPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRelativeToParent)
|
||||||
|
singularity.transform.localPosition = position;
|
||||||
|
else
|
||||||
singularity.transform.position = planetGO.transform.TransformPoint(position);
|
singularity.transform.position = planetGO.transform.TransformPoint(position);
|
||||||
|
|
||||||
var singularityRenderer = MakeSingularityGraphics(singularity, polarity, horizon, distort, renderQueue);
|
var singularityRenderer = MakeSingularityGraphics(singularity, polarity, horizon, distort, renderQueue);
|
||||||
@ -257,7 +273,11 @@ namespace NewHorizons.Builder.Body
|
|||||||
whiteHoleFluidVolume.enabled = true;
|
whiteHoleFluidVolume.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
singularity.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(rotation));
|
var rot = Quaternion.Euler(rotation);
|
||||||
|
if (isRelativeToParent)
|
||||||
|
singularity.transform.localRotation = rot;
|
||||||
|
else
|
||||||
|
singularity.transform.rotation = planetGO.transform.TransformRotation(rot);
|
||||||
|
|
||||||
singularity.SetActive(true);
|
singularity.SetActive(true);
|
||||||
return singularity;
|
return singularity;
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
using NewHorizons.External.Modules;
|
using NewHorizons.External.Modules;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Props
|
namespace NewHorizons.Builder.Props
|
||||||
{
|
{
|
||||||
public static class GeyserBuilder
|
public static class GeyserBuilder
|
||||||
@ -17,8 +19,21 @@ namespace NewHorizons.Builder.Props
|
|||||||
InitPrefab();
|
InitPrefab();
|
||||||
|
|
||||||
var geyserGO = _geyserPrefab.InstantiateInactive();
|
var geyserGO = _geyserPrefab.InstantiateInactive();
|
||||||
|
geyserGO.name = !string.IsNullOrEmpty(info.rename) ? info.rename : "Geyser";
|
||||||
geyserGO.transform.parent = sector?.transform ?? planetGO.transform;
|
geyserGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||||
geyserGO.name = "Geyser";
|
|
||||||
|
if (!string.IsNullOrEmpty(info.parentPath))
|
||||||
|
{
|
||||||
|
var newParent = planetGO.transform.Find(info.parentPath);
|
||||||
|
if (newParent != null)
|
||||||
|
{
|
||||||
|
geyserGO.transform.parent = newParent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var pos = (Vector3)info.position;
|
var pos = (Vector3)info.position;
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
if (_slideReelPrefab == null) return null;
|
if (_slideReelPrefab == null) return null;
|
||||||
|
|
||||||
var slideReelObj = _slideReelPrefab.InstantiateInactive();
|
var slideReelObj = _slideReelPrefab.InstantiateInactive();
|
||||||
slideReelObj.name = $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}";
|
slideReelObj.name = !string.IsNullOrEmpty(info.rename) ? info.rename : $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}";
|
||||||
|
|
||||||
var slideReel = slideReelObj.GetComponent<SlideReelItem>();
|
var slideReel = slideReelObj.GetComponent<SlideReelItem>();
|
||||||
slideReel.SetSector(sector);
|
slideReel.SetSector(sector);
|
||||||
@ -196,7 +196,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
if (_autoPrefab == null) return null;
|
if (_autoPrefab == null) return null;
|
||||||
|
|
||||||
var projectorObj = _autoPrefab.InstantiateInactive();
|
var projectorObj = _autoPrefab.InstantiateInactive();
|
||||||
projectorObj.name = $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}";
|
projectorObj.name = !string.IsNullOrEmpty(info.rename) ? info.rename : $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}";
|
||||||
|
|
||||||
var autoProjector = projectorObj.GetComponent<AutoSlideProjector>();
|
var autoProjector = projectorObj.GetComponent<AutoSlideProjector>();
|
||||||
autoProjector._sector = sector;
|
autoProjector._sector = sector;
|
||||||
@ -276,7 +276,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
g.name = "VisionStaffDetector";
|
g.name = !string.IsNullOrEmpty(info.rename) ? info.rename : "VisionStaffDetector";
|
||||||
|
|
||||||
// The number of slides is unlimited, 15 is only for texturing the actual slide reel item. This is not a slide reel item
|
// The number of slides is unlimited, 15 is only for texturing the actual slide reel item. This is not a slide reel item
|
||||||
var slides = info.slides;
|
var slides = info.slides;
|
||||||
@ -312,7 +312,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
position = info.position,
|
position = info.position,
|
||||||
rotation = info.rotation,
|
rotation = info.rotation,
|
||||||
parentPath = info.parentPath,
|
parentPath = info.parentPath,
|
||||||
isRelativeToParent = info.isRelativeToParent
|
isRelativeToParent = info.isRelativeToParent,
|
||||||
|
rename = info.rename
|
||||||
};
|
};
|
||||||
var standingTorch = DetailBuilder.Make(planetGO, sector, _standingVisionTorchPrefab, detailInfo);
|
var standingTorch = DetailBuilder.Make(planetGO, sector, _standingVisionTorchPrefab, detailInfo);
|
||||||
|
|
||||||
|
|||||||
@ -53,10 +53,34 @@ namespace NewHorizons.Builder.Props
|
|||||||
if (_prefab == null || sector == null) return null;
|
if (_prefab == null || sector == null) return null;
|
||||||
|
|
||||||
GameObject raftObject = _prefab.InstantiateInactive();
|
GameObject raftObject = _prefab.InstantiateInactive();
|
||||||
raftObject.name = "Raft_Body";
|
raftObject.name = !string.IsNullOrEmpty(info.rename) ? info.rename : "Raft_Body";
|
||||||
raftObject.transform.parent = sector?.transform ?? planetGO.transform;
|
raftObject.transform.parent = sector?.transform ?? planetGO.transform;
|
||||||
raftObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero);
|
|
||||||
raftObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.identity);
|
if (!string.IsNullOrEmpty(info.parentPath))
|
||||||
|
{
|
||||||
|
var newParent = planetGO.transform.Find(info.parentPath);
|
||||||
|
if (newParent != null)
|
||||||
|
{
|
||||||
|
raftObject.transform.parent = newParent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pos = (Vector3)(info.position ?? Vector3.zero);
|
||||||
|
var rot = Quaternion.identity;
|
||||||
|
if (info.isRelativeToParent)
|
||||||
|
{
|
||||||
|
raftObject.transform.localPosition = pos;
|
||||||
|
raftObject.transform.localRotation = rot;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
raftObject.transform.position = planetGO.transform.TransformPoint(pos);
|
||||||
|
raftObject.transform.rotation = planetGO.transform.TransformRotation(rot);
|
||||||
|
}
|
||||||
|
|
||||||
StreamingHandler.SetUpStreaming(raftObject, sector);
|
StreamingHandler.SetUpStreaming(raftObject, sector);
|
||||||
|
|
||||||
|
|||||||
@ -252,14 +252,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
var shareStone = _shareStonePrefab.InstantiateInactive();
|
var shareStone = _shareStonePrefab.InstantiateInactive();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.rename))
|
shareStone.name = !string.IsNullOrEmpty(info.rename) ? info.rename : ("ShareStone_" + id.ToString());
|
||||||
{
|
|
||||||
shareStone.name = info.rename;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shareStone.name = "ShareStone_" + id.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
shareStone.transform.parent = sector?.transform ?? go.transform;
|
shareStone.transform.parent = sector?.transform ?? go.transform;
|
||||||
|
|
||||||
|
|||||||
@ -99,7 +99,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool downwards)
|
private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool downwards)
|
||||||
{
|
{
|
||||||
var tornadoGO = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive();
|
var tornadoGO = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive();
|
||||||
tornadoGO.name = downwards ? "Tornado_Down" : "Tornado_Up";
|
tornadoGO.name = !string.IsNullOrEmpty(info.rename) ? info.rename : (downwards ? "Tornado_Down" : "Tornado_Up");
|
||||||
tornadoGO.transform.parent = sector?.transform ?? planetGO.transform;
|
tornadoGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||||
tornadoGO.transform.position = planetGO.transform.TransformPoint(position);
|
tornadoGO.transform.position = planetGO.transform.TransformPoint(position);
|
||||||
tornadoGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, planetGO.transform.TransformDirection(position.normalized));
|
tornadoGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, planetGO.transform.TransformDirection(position.normalized));
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
using NewHorizons.External.Modules;
|
using NewHorizons.External.Modules;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Props
|
namespace NewHorizons.Builder.Props
|
||||||
{
|
{
|
||||||
public static class VolcanoBuilder
|
public static class VolcanoBuilder
|
||||||
@ -44,10 +46,30 @@ namespace NewHorizons.Builder.Props
|
|||||||
InitPrefab();
|
InitPrefab();
|
||||||
|
|
||||||
var launcherGO = _meteorLauncherPrefab.InstantiateInactive();
|
var launcherGO = _meteorLauncherPrefab.InstantiateInactive();
|
||||||
|
launcherGO.name = !string.IsNullOrEmpty(info.rename) ? info.rename : "MeteorLauncher";
|
||||||
launcherGO.transform.parent = sector?.transform ?? planetGO.transform;
|
launcherGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||||
launcherGO.transform.position = planetGO.transform.TransformPoint(info.position == null ? Vector3.zero : (Vector3)info.position);
|
launcherGO.transform.position = planetGO.transform.TransformPoint(info.position == null ? Vector3.zero : (Vector3)info.position);
|
||||||
launcherGO.transform.rotation = Quaternion.FromToRotation(launcherGO.transform.TransformDirection(Vector3.up), ((Vector3)info.position).normalized).normalized;
|
|
||||||
launcherGO.name = "MeteorLauncher";
|
if (!string.IsNullOrEmpty(info.parentPath))
|
||||||
|
{
|
||||||
|
var newParent = planetGO.transform.Find(info.parentPath);
|
||||||
|
if (newParent != null)
|
||||||
|
{
|
||||||
|
launcherGO.transform.parent = newParent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pos = (Vector3)(info.position ?? Vector3.zero);
|
||||||
|
if (info.isRelativeToParent)
|
||||||
|
launcherGO.transform.localPosition = pos;
|
||||||
|
else
|
||||||
|
launcherGO.transform.position = planetGO.transform.TransformPoint(pos);
|
||||||
|
|
||||||
|
launcherGO.transform.rotation = Quaternion.FromToRotation(launcherGO.transform.TransformDirection(Vector3.up), pos.normalized).normalized;
|
||||||
|
|
||||||
var meteorLauncher = launcherGO.GetComponent<MeteorLauncher>();
|
var meteorLauncher = launcherGO.GetComponent<MeteorLauncher>();
|
||||||
meteorLauncher._audioSector = sector;
|
meteorLauncher._audioSector = sector;
|
||||||
|
|||||||
@ -2,6 +2,8 @@ using NewHorizons.External.Modules;
|
|||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.ShipLog
|
namespace NewHorizons.Builder.ShipLog
|
||||||
{
|
{
|
||||||
public static class EntryLocationBuilder
|
public static class EntryLocationBuilder
|
||||||
@ -9,10 +11,29 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
private static readonly List<ShipLogEntryLocation> _locationsToInitialize = new List<ShipLogEntryLocation>();
|
private static readonly List<ShipLogEntryLocation> _locationsToInitialize = new List<ShipLogEntryLocation>();
|
||||||
public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModBehaviour mod)
|
public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
GameObject entryLocationGameObject = new GameObject("Entry Location (" + info.id + ")");
|
GameObject entryLocationGameObject = new GameObject(!string.IsNullOrEmpty(info.rename) ? info.rename : ("Entry Location (" + info.id + ")"));
|
||||||
entryLocationGameObject.SetActive(false);
|
entryLocationGameObject.SetActive(false);
|
||||||
entryLocationGameObject.transform.parent = sector?.transform ?? go.transform;
|
entryLocationGameObject.transform.parent = sector?.transform ?? go.transform;
|
||||||
entryLocationGameObject.transform.position = go.transform.TransformPoint(info.position ?? Vector3.zero);
|
|
||||||
|
if (!string.IsNullOrEmpty(info.parentPath))
|
||||||
|
{
|
||||||
|
var newParent = go.transform.Find(info.parentPath);
|
||||||
|
if (newParent != null)
|
||||||
|
{
|
||||||
|
entryLocationGameObject.transform.parent = newParent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Cannot find parent object at path: {go.name}/{info.parentPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pos = (Vector3)(info.position ?? Vector3.zero);
|
||||||
|
if (info.isRelativeToParent)
|
||||||
|
entryLocationGameObject.transform.localPosition = pos;
|
||||||
|
else
|
||||||
|
entryLocationGameObject.transform.position = go.transform.TransformPoint(pos);
|
||||||
|
|
||||||
ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent<ShipLogEntryLocation>();
|
ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent<ShipLogEntryLocation>();
|
||||||
newLocation._entryID = info.id;
|
newLocation._entryID = info.id;
|
||||||
newLocation._outerFogWarpVolume = go.GetComponentInChildren<OuterFogWarpVolume>();
|
newLocation._outerFogWarpVolume = go.GetComponentInChildren<OuterFogWarpVolume>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user