mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
1.16.0 (#715)
## Major features - API now allows you to register a custom builder method. This method takes the planet game object and the json string of its `extras` module, allowing you to alter your planet accordingly. ## Improvements - Can now update the orbits of the HGT. Implements #225
This commit is contained in:
commit
d8f9d68281
@ -42,11 +42,6 @@ namespace NewHorizons.Builder.Body
|
||||
case StellarRemnantType.NeutronStar:
|
||||
MakeNeutronStar(go, sector, mod, star.Config.Star);
|
||||
|
||||
break;
|
||||
case StellarRemnantType.Pulsar:
|
||||
MakeNeutronStar(go, sector, mod, star.Config.Star);
|
||||
// TODO: add jets, up rotation speed (use a RotateTransform on the star instead of changing sidereal period)
|
||||
|
||||
break;
|
||||
case StellarRemnantType.BlackHole:
|
||||
MakeBlackhole(go, sector, star.Config.Star);
|
||||
@ -146,8 +141,6 @@ namespace NewHorizons.Builder.Body
|
||||
return MakeWhiteDwarf(planet, null, mod, progenitor, proxy);
|
||||
case StellarRemnantType.NeutronStar:
|
||||
return MakeNeutronStar(planet, null, mod, progenitor, proxy);
|
||||
case StellarRemnantType.Pulsar:
|
||||
return MakeNeutronStar(planet, null, mod, progenitor, proxy);
|
||||
case StellarRemnantType.BlackHole:
|
||||
return MakeBlackhole(planet, null, progenitor, proxy);
|
||||
default:
|
||||
|
||||
@ -164,7 +164,7 @@ namespace NewHorizons.Builder.Body
|
||||
fluidVolume.gameObject.AddComponent<WaterCloakFixerVolume>().material = TSR.sharedMaterials.First(x => x.name == "Ocean_GD_Surface_mat");
|
||||
}
|
||||
|
||||
// TODO: fix ruleset making the sand bubble pop up
|
||||
// TODO: fix ruleset making the sand bubble pop up when editing the twins
|
||||
|
||||
waterGO.transform.position = planetGO.transform.position;
|
||||
waterGO.SetActive(true);
|
||||
|
||||
@ -154,7 +154,6 @@ namespace NewHorizons.External.Modules.VariableSize
|
||||
[EnumMember(Value = @"default")] Default,
|
||||
[EnumMember(Value = @"whiteDwarf")] WhiteDwarf,
|
||||
[EnumMember(Value = @"neutronStar")] NeutronStar,
|
||||
[EnumMember(Value = @"pulsar")] Pulsar,
|
||||
[EnumMember(Value = @"blackHole")] BlackHole,
|
||||
[EnumMember(Value = @"custom")] Custom
|
||||
}
|
||||
|
||||
@ -16,7 +16,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
using NewHorizons.Streaming;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NewHorizons.Handlers
|
||||
{
|
||||
@ -34,6 +35,8 @@ namespace NewHorizons.Handlers
|
||||
public static float SolarSystemRadius { get; private set; }
|
||||
public static float DefaultFurthestOrbit => 30000f;
|
||||
|
||||
public static List<Action<GameObject, string>> CustomBuilders;
|
||||
|
||||
public static void Init(List<NewHorizonsBody> bodies)
|
||||
{
|
||||
// Start by destroying all planets if need be
|
||||
@ -701,6 +704,21 @@ namespace NewHorizons.Handlers
|
||||
FunnelBuilder.Make(go, sector, rb, body.Config.Funnel);
|
||||
}
|
||||
|
||||
if (body.Config.extras != null)
|
||||
{
|
||||
foreach (var customBuilder in CustomBuilders)
|
||||
{
|
||||
try
|
||||
{
|
||||
customBuilder.Invoke(go, JsonConvert.SerializeObject(body.Config.extras));
|
||||
}
|
||||
catch
|
||||
{
|
||||
NHLogger.LogError($"Failed to use custom builder on body {body.Config.name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Has to go last probably
|
||||
if (willHaveCloak)
|
||||
{
|
||||
@ -728,6 +746,37 @@ namespace NewHorizons.Handlers
|
||||
var aoName = ao.GetAstroObjectName();
|
||||
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);
|
||||
// Not to be confused with Sector.GetRootSector, this returns the highest sector on the astro object not in the chain
|
||||
// CaveTwin/TowerTwin sectors both have HGT as parent so we want to get rid of that link
|
||||
ao.GetRootSector().SetParentSector(null);
|
||||
}
|
||||
|
||||
var owrb = go.GetComponent<OWRigidbody>();
|
||||
|
||||
var im = go.GetComponent<InitialMotion>();
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using NewHorizons.Utility;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
@ -143,7 +144,7 @@ namespace NewHorizons.Handlers
|
||||
{
|
||||
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
|
||||
{
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using NewHorizons.Handlers;
|
||||
using OWML.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -92,6 +93,11 @@ namespace NewHorizons
|
||||
/// Uses JSONPath to query the current star system
|
||||
///</summary>
|
||||
T QuerySystem<T>(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Register your own builder that will act on the given GameObject by reading the json string of its "extras" module
|
||||
/// </summary>
|
||||
void RegisterCustomBuilder(Action<GameObject, string> builder);
|
||||
#endregion
|
||||
|
||||
#region Spawn props
|
||||
|
||||
@ -15,6 +15,7 @@ using NewHorizons.OtherMods.AchievementsPlus;
|
||||
using NewHorizons.OtherMods.MenuFramework;
|
||||
using NewHorizons.OtherMods.OWRichPresence;
|
||||
using NewHorizons.OtherMods.VoiceActing;
|
||||
using NewHorizons.Streaming;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.Utility.DebugTools;
|
||||
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)
|
||||
|
||||
//Fix attlerock vanilla sector components (they were set to timber hearth's sector)
|
||||
var thm = SearchUtilities.Find("Moon_Body/Sector_THM").GetComponent<Sector>();
|
||||
foreach (var component in thm.GetComponentsInChildren<Component>(true))
|
||||
{
|
||||
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 moon vanilla sector components (they were set to their primaries' sectors)
|
||||
VanillaStreamingFix.UnparentSectorStreaming(SearchUtilities.Find("Moon_Body/Sector_THM").GetComponent<Sector>(), AstroObject.Name.TimberHearth);
|
||||
VanillaStreamingFix.UnparentSectorStreaming(SearchUtilities.Find("VolcanicMoon_Body/Sector_VM").GetComponent<Sector>(), AstroObject.Name.BrittleHollow);
|
||||
|
||||
//Fix brittle hollow north pole projection platform
|
||||
var northPoleSurface = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_NorthPoleSurface").GetComponent<Sector>();
|
||||
|
||||
@ -10,6 +10,7 @@ using NewHorizons.External.Modules.Props.Audio;
|
||||
using NewHorizons.External.Modules.Props.Dialogue;
|
||||
using NewHorizons.External.Modules.TranslatorText;
|
||||
using NewHorizons.External.SerializableData;
|
||||
using NewHorizons.Handlers;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.Utility.OWML;
|
||||
using Newtonsoft.Json;
|
||||
@ -315,5 +316,11 @@ namespace NewHorizons
|
||||
|
||||
RumorModeBuilder.AddShipLogXML(GameObject.FindObjectOfType<ShipLogManager>(), xml, body);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register your own builder that will act on the given GameObject by reading its raw json string
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
public void RegisterCustomBuilder(Action<GameObject, string> builder) => PlanetCreationHandler.CustomBuilders.Add(builder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3509,7 +3509,6 @@
|
||||
"Default",
|
||||
"WhiteDwarf",
|
||||
"NeutronStar",
|
||||
"Pulsar",
|
||||
"BlackHole",
|
||||
"Custom"
|
||||
],
|
||||
@ -3517,7 +3516,6 @@
|
||||
"default",
|
||||
"whiteDwarf",
|
||||
"neutronStar",
|
||||
"pulsar",
|
||||
"blackHole",
|
||||
"custom"
|
||||
]
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@
|
||||
"author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book",
|
||||
"name": "New Horizons",
|
||||
"uniqueName": "xen.NewHorizons",
|
||||
"version": "1.15.1",
|
||||
"version": "1.16.0",
|
||||
"owmlVersion": "2.9.3",
|
||||
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
|
||||
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user