mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix moving the twins
This commit is contained in:
parent
0030b24750
commit
233bc50625
@ -16,7 +16,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using NewHorizons.Streaming;
|
||||||
|
|
||||||
namespace NewHorizons.Handlers
|
namespace NewHorizons.Handlers
|
||||||
{
|
{
|
||||||
@ -717,58 +717,22 @@ namespace NewHorizons.Handlers
|
|||||||
clonedSectorHGT.transform.parent = go.transform;
|
clonedSectorHGT.transform.parent = go.transform;
|
||||||
clonedSectorHGT.transform.localPosition = Vector3.zero;
|
clonedSectorHGT.transform.localPosition = Vector3.zero;
|
||||||
clonedSectorHGT.transform.localRotation = Quaternion.identity;
|
clonedSectorHGT.transform.localRotation = Quaternion.identity;
|
||||||
var hgtSector = clonedSectorHGT.GetComponent<Sector>();
|
|
||||||
|
|
||||||
var streamingGroupGO = hourglassTwinsFocal.GetComponentInChildren<StreamingGroup>().gameObject.Instantiate().Rename("StreamingGroup");
|
// Don't need this part
|
||||||
streamingGroupGO.transform.parent = go.transform;
|
GameObject.Destroy(clonedSectorHGT.GetComponentInChildren<SectorStreaming>().gameObject);
|
||||||
streamingGroupGO.transform.localPosition = Vector3.zero;
|
|
||||||
streamingGroupGO.transform.localRotation = Quaternion.identity;
|
|
||||||
|
|
||||||
// HGT streaming group is shared between the two so we have to move it onto the individual ones
|
// Take the hourglass twins shader effect controller off the focal body so it can stay active
|
||||||
// Inefficient because being on ember twin will have ash twin assets load regardless of distance but whatever
|
var shaderController = hourglassTwinsFocal.GetComponentInChildren<HourglassTwinsShaderController>();
|
||||||
var sectorStreaming = clonedSectorHGT.GetComponentInChildren<SectorStreaming>();
|
if (shaderController != null) shaderController.transform.parent = null;
|
||||||
sectorStreaming._streamingGroup = streamingGroupGO.GetComponent<StreamingGroup>();
|
|
||||||
sectorStreaming.SetSector(hgtSector);
|
|
||||||
|
|
||||||
hourglassTwinsFocal.SetActive(false);
|
hourglassTwinsFocal.SetActive(false);
|
||||||
|
|
||||||
// Remove the drift tracker since its unneeded now
|
// Remove the drift tracker since its unneeded now
|
||||||
Component.Destroy(go.GetComponent<DriftTracker>());
|
Component.Destroy(go.GetComponent<DriftTracker>());
|
||||||
|
|
||||||
// Fix anything pointing to the original HGT sector
|
// Fix sectors
|
||||||
foreach (var component in ao.GetComponentsInChildren<Component>(true))
|
VanillaStreamingFix.UnparentSectorStreaming(ao.GetRootSector(), ao.gameObject, AstroObject.Name.HourglassTwins, Sector.Name.HourglassTwins);
|
||||||
{
|
ao.GetRootSector().SetParentSector(null);
|
||||||
if (component is ISectorGroup sectorGroup)
|
|
||||||
{
|
|
||||||
if (sectorGroup.GetSector()?._name == Sector.Name.HourglassTwins)
|
|
||||||
{
|
|
||||||
sectorGroup.SetSector(hgtSector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (component is SectoredMonoBehaviour behaviour)
|
|
||||||
{
|
|
||||||
if (behaviour.GetSector()?._name == Sector.Name.HourglassTwins)
|
|
||||||
{
|
|
||||||
behaviour.SetSector(hgtSector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sector tweaks
|
|
||||||
if (aoName == AstroObject.Name.CaveTwin)
|
|
||||||
{
|
|
||||||
// Ember Twin hemisphere geometry only fully appears at 300 so we shrink the HGT sector to this size since it controls the proxy geometry
|
|
||||||
hgtSector.GetComponent<SphereShape>().radius = 300;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Update the parent sector
|
|
||||||
ao.GetRootSector().SetParentSector(hgtSector);
|
|
||||||
|
|
||||||
// Take the hourglass twins shader effect controller off the focal body so it can stay active
|
|
||||||
var shaderController = hourglassTwinsFocal.GetComponentInChildren<HourglassTwinsShaderController>();
|
|
||||||
if (shaderController != null) shaderController.transform.parent = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var owrb = go.GetComponent<OWRigidbody>();
|
var owrb = go.GetComponent<OWRigidbody>();
|
||||||
|
|||||||
@ -1,10 +1,4 @@
|
|||||||
using NewHorizons.Handlers;
|
using NewHorizons.Handlers;
|
||||||
using NewHorizons.Utility;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NewHorizons.Streaming;
|
namespace NewHorizons.Streaming;
|
||||||
@ -12,21 +6,31 @@ namespace NewHorizons.Streaming;
|
|||||||
internal static class VanillaStreamingFix
|
internal static class VanillaStreamingFix
|
||||||
{
|
{
|
||||||
internal static void UnparentSectorStreaming(Sector rootSector, AstroObject.Name streamingGroupName)
|
internal static void UnparentSectorStreaming(Sector rootSector, AstroObject.Name streamingGroupName)
|
||||||
|
=> UnparentSectorStreaming(rootSector, rootSector.gameObject, streamingGroupName, Sector.Name.Unnamed);
|
||||||
|
|
||||||
|
internal static void UnparentSectorStreaming(Sector rootSector, GameObject startingObject, AstroObject.Name streamingGroupName, Sector.Name originalParentSectorName)
|
||||||
{
|
{
|
||||||
foreach (var component in rootSector.GetComponentsInChildren<Component>(true))
|
// Set originalParentSectorName to unnamed to alter all sectors
|
||||||
|
foreach (var component in startingObject.GetComponentsInChildren<Component>(true))
|
||||||
{
|
{
|
||||||
if (component is ISectorGroup sectorGroup)
|
if (component is ISectorGroup sectorGroup)
|
||||||
{
|
{
|
||||||
sectorGroup.SetSector(rootSector);
|
if (sectorGroup.GetSector()?.GetName() == originalParentSectorName || originalParentSectorName == Sector.Name.Unnamed)
|
||||||
|
{
|
||||||
|
sectorGroup.SetSector(rootSector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component is SectoredMonoBehaviour behaviour)
|
if (component is SectoredMonoBehaviour behaviour)
|
||||||
{
|
{
|
||||||
behaviour.SetSector(rootSector);
|
if (behaviour.GetSector()?.GetName() == originalParentSectorName || originalParentSectorName == Sector.Name.Unnamed)
|
||||||
|
{
|
||||||
|
behaviour.SetSector(rootSector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var sectorStreamingObj = new GameObject("Sector_Streaming");
|
var sectorStreamingObj = new GameObject("Sector_Streaming");
|
||||||
sectorStreamingObj.transform.SetParent(rootSector.transform, false);
|
sectorStreamingObj.transform.SetParent(startingObject.transform, false);
|
||||||
|
|
||||||
var sectorStreaming = sectorStreamingObj.AddComponent<SectorStreaming>();
|
var sectorStreaming = sectorStreamingObj.AddComponent<SectorStreaming>();
|
||||||
sectorStreaming._streamingGroup = StreamingHandler.GetStreamingGroup(streamingGroupName);
|
sectorStreaming._streamingGroup = StreamingHandler.GetStreamingGroup(streamingGroupName);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user