mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Update HGT orbits (#706)
## Improvements - Can now update the orbits of the HGT. Implements #225
This commit is contained in:
commit
809ad184ea
@ -16,6 +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;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NewHorizons.Handlers
|
namespace NewHorizons.Handlers
|
||||||
@ -745,6 +746,35 @@ namespace NewHorizons.Handlers
|
|||||||
var aoName = ao.GetAstroObjectName();
|
var aoName = ao.GetAstroObjectName();
|
||||||
var aoType = ao.GetAstroObjectType();
|
var aoType = ao.GetAstroObjectType();
|
||||||
|
|
||||||
|
// When updating orbits of the twins be sure the FocalBody is gone
|
||||||
|
// Don't do it if it's already an NHAstroObject since that means this was already done
|
||||||
|
if (ao is not NHAstroObject && (aoName == AstroObject.Name.TowerTwin || aoName == AstroObject.Name.CaveTwin))
|
||||||
|
{
|
||||||
|
var hourglassTwinsFocal = SearchUtilities.Find("FocalBody");
|
||||||
|
|
||||||
|
// Have to copy the HGT sector bc it has some ruleset stuff on it we want
|
||||||
|
var clonedSectorHGT = hourglassTwinsFocal.FindChild("Sector_HGT").Instantiate().Rename("Sector_HGT");
|
||||||
|
clonedSectorHGT.transform.parent = go.transform;
|
||||||
|
clonedSectorHGT.transform.localPosition = Vector3.zero;
|
||||||
|
clonedSectorHGT.transform.localRotation = Quaternion.identity;
|
||||||
|
|
||||||
|
// Don't need this part
|
||||||
|
GameObject.Destroy(clonedSectorHGT.GetComponentInChildren<SectorStreaming>().gameObject);
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
hourglassTwinsFocal.SetActive(false);
|
||||||
|
|
||||||
|
// Remove the drift tracker since its unneeded now
|
||||||
|
Component.Destroy(go.GetComponent<DriftTracker>());
|
||||||
|
|
||||||
|
// Fix sectors
|
||||||
|
VanillaStreamingFix.UnparentSectorStreaming(ao.GetRootSector(), ao.gameObject, AstroObject.Name.HourglassTwins, Sector.Name.HourglassTwins);
|
||||||
|
ao.GetRootSector().SetParentSector(null);
|
||||||
|
}
|
||||||
|
|
||||||
var owrb = go.GetComponent<OWRigidbody>();
|
var owrb = go.GetComponent<OWRigidbody>();
|
||||||
|
|
||||||
var im = go.GetComponent<InitialMotion>();
|
var im = go.GetComponent<InitialMotion>();
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using NewHorizons.Utility;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -143,7 +144,7 @@ namespace NewHorizons.Handlers
|
|||||||
{
|
{
|
||||||
if (name is AstroObject.Name.CaveTwin or AstroObject.Name.TowerTwin)
|
if (name is AstroObject.Name.CaveTwin or AstroObject.Name.TowerTwin)
|
||||||
{
|
{
|
||||||
return GameObject.Find("FocalBody/StreamingGroup_HGT").GetComponent<StreamingGroup>();
|
return SearchUtilities.Find("FocalBody/StreamingGroup_HGT").GetComponent<StreamingGroup>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,6 +15,7 @@ using NewHorizons.OtherMods.AchievementsPlus;
|
|||||||
using NewHorizons.OtherMods.MenuFramework;
|
using NewHorizons.OtherMods.MenuFramework;
|
||||||
using NewHorizons.OtherMods.OWRichPresence;
|
using NewHorizons.OtherMods.OWRichPresence;
|
||||||
using NewHorizons.OtherMods.VoiceActing;
|
using NewHorizons.OtherMods.VoiceActing;
|
||||||
|
using NewHorizons.Streaming;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using NewHorizons.Utility.DebugTools;
|
using NewHorizons.Utility.DebugTools;
|
||||||
using NewHorizons.Utility.DebugTools.Menu;
|
using NewHorizons.Utility.DebugTools.Menu;
|
||||||
@ -478,46 +479,9 @@ namespace NewHorizons
|
|||||||
|
|
||||||
// Sector changes (so that projection pools actually turn off proxies and cull groups on these moons)
|
// Sector changes (so that projection pools actually turn off proxies and cull groups on these moons)
|
||||||
|
|
||||||
//Fix attlerock vanilla sector components (they were set to timber hearth's sector)
|
// Fix moon vanilla sector components (they were set to their primaries' sectors)
|
||||||
var thm = SearchUtilities.Find("Moon_Body/Sector_THM").GetComponent<Sector>();
|
VanillaStreamingFix.UnparentSectorStreaming(SearchUtilities.Find("Moon_Body/Sector_THM").GetComponent<Sector>(), AstroObject.Name.TimberHearth);
|
||||||
foreach (var component in thm.GetComponentsInChildren<Component>(true))
|
VanillaStreamingFix.UnparentSectorStreaming(SearchUtilities.Find("VolcanicMoon_Body/Sector_VM").GetComponent<Sector>(), AstroObject.Name.BrittleHollow);
|
||||||
{
|
|
||||||
if (component is ISectorGroup sectorGroup)
|
|
||||||
{
|
|
||||||
sectorGroup.SetSector(thm);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (component is SectoredMonoBehaviour behaviour)
|
|
||||||
{
|
|
||||||
behaviour.SetSector(thm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var thm_ss_obj = new GameObject("Sector_Streaming");
|
|
||||||
thm_ss_obj.transform.SetParent(thm.transform, false);
|
|
||||||
var thm_ss = thm_ss_obj.AddComponent<SectorStreaming>();
|
|
||||||
thm_ss._streamingGroup = SearchUtilities.Find("TimberHearth_Body/StreamingGroup_TH").GetComponent<StreamingGroup>();
|
|
||||||
thm_ss.SetSector(thm);
|
|
||||||
|
|
||||||
|
|
||||||
//Fix hollow's lantern vanilla sector components (they were set to brittle hollow's sector)
|
|
||||||
var vm = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM").GetComponent<Sector>();
|
|
||||||
foreach (var component in vm.GetComponentsInChildren<Component>(true))
|
|
||||||
{
|
|
||||||
if (component is ISectorGroup sectorGroup)
|
|
||||||
{
|
|
||||||
sectorGroup.SetSector(vm);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (component is SectoredMonoBehaviour behaviour)
|
|
||||||
{
|
|
||||||
behaviour.SetSector(vm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var vm_ss_obj = new GameObject("Sector_Streaming");
|
|
||||||
vm_ss_obj.transform.SetParent(vm.transform, false);
|
|
||||||
var vm_ss = vm_ss_obj.AddComponent<SectorStreaming>();
|
|
||||||
vm_ss._streamingGroup = SearchUtilities.Find("BrittleHollow_Body/StreamingGroup_BH").GetComponent<StreamingGroup>();
|
|
||||||
vm_ss.SetSector(vm);
|
|
||||||
|
|
||||||
//Fix brittle hollow north pole projection platform
|
//Fix brittle hollow north pole projection platform
|
||||||
var northPoleSurface = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_NorthPoleSurface").GetComponent<Sector>();
|
var northPoleSurface = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_NorthPoleSurface").GetComponent<Sector>();
|
||||||
|
|||||||
39
NewHorizons/Streaming/VanillaStreamingFix.cs
Normal file
39
NewHorizons/Streaming/VanillaStreamingFix.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using NewHorizons.Handlers;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NewHorizons.Streaming;
|
||||||
|
|
||||||
|
internal static class VanillaStreamingFix
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// Set originalParentSectorName to unnamed to alter all sectors
|
||||||
|
foreach (var component in startingObject.GetComponentsInChildren<Component>(true))
|
||||||
|
{
|
||||||
|
if (component is ISectorGroup sectorGroup)
|
||||||
|
{
|
||||||
|
if (sectorGroup.GetSector()?.GetName() == originalParentSectorName || originalParentSectorName == Sector.Name.Unnamed)
|
||||||
|
{
|
||||||
|
sectorGroup.SetSector(rootSector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (component is SectoredMonoBehaviour behaviour)
|
||||||
|
{
|
||||||
|
if (behaviour.GetSector()?.GetName() == originalParentSectorName || originalParentSectorName == Sector.Name.Unnamed)
|
||||||
|
{
|
||||||
|
behaviour.SetSector(rootSector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var sectorStreamingObj = new GameObject("Sector_Streaming");
|
||||||
|
sectorStreamingObj.transform.SetParent(startingObject.transform, false);
|
||||||
|
|
||||||
|
var sectorStreaming = sectorStreamingObj.AddComponent<SectorStreaming>();
|
||||||
|
sectorStreaming._streamingGroup = StreamingHandler.GetStreamingGroup(streamingGroupName);
|
||||||
|
sectorStreaming.SetSector(rootSector);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user