mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add custom builders
This commit is contained in:
parent
8dabc7934e
commit
e44efdbcca
@ -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 Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NewHorizons.Handlers
|
namespace NewHorizons.Handlers
|
||||||
{
|
{
|
||||||
@ -34,6 +34,8 @@ namespace NewHorizons.Handlers
|
|||||||
public static float SolarSystemRadius { get; private set; }
|
public static float SolarSystemRadius { get; private set; }
|
||||||
public static float DefaultFurthestOrbit => 30000f;
|
public static float DefaultFurthestOrbit => 30000f;
|
||||||
|
|
||||||
|
public static List<Action<GameObject, string>> CustomBuilders;
|
||||||
|
|
||||||
public static void Init(List<NewHorizonsBody> bodies)
|
public static void Init(List<NewHorizonsBody> bodies)
|
||||||
{
|
{
|
||||||
// Start by destroying all planets if need be
|
// Start by destroying all planets if need be
|
||||||
@ -701,6 +703,21 @@ namespace NewHorizons.Handlers
|
|||||||
FunnelBuilder.Make(go, sector, rb, body.Config.Funnel);
|
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
|
// Has to go last probably
|
||||||
if (willHaveCloak)
|
if (willHaveCloak)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using NewHorizons.Handlers;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -92,6 +93,11 @@ namespace NewHorizons
|
|||||||
/// Uses JSONPath to query the current star system
|
/// Uses JSONPath to query the current star system
|
||||||
///</summary>
|
///</summary>
|
||||||
T QuerySystem<T>(string path);
|
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
|
#endregion
|
||||||
|
|
||||||
#region Spawn props
|
#region Spawn props
|
||||||
|
|||||||
@ -10,6 +10,7 @@ using NewHorizons.External.Modules.Props.Audio;
|
|||||||
using NewHorizons.External.Modules.Props.Dialogue;
|
using NewHorizons.External.Modules.Props.Dialogue;
|
||||||
using NewHorizons.External.Modules.TranslatorText;
|
using NewHorizons.External.Modules.TranslatorText;
|
||||||
using NewHorizons.External.SerializableData;
|
using NewHorizons.External.SerializableData;
|
||||||
|
using NewHorizons.Handlers;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using NewHorizons.Utility.OWML;
|
using NewHorizons.Utility.OWML;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@ -315,5 +316,11 @@ namespace NewHorizons
|
|||||||
|
|
||||||
RumorModeBuilder.AddShipLogXML(GameObject.FindObjectOfType<ShipLogManager>(), xml, body);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
"author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book",
|
"author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book",
|
||||||
"name": "New Horizons",
|
"name": "New Horizons",
|
||||||
"uniqueName": "xen.NewHorizons",
|
"uniqueName": "xen.NewHorizons",
|
||||||
"version": "1.15.1",
|
"version": "1.16.0",
|
||||||
"owmlVersion": "2.9.3",
|
"owmlVersion": "2.9.3",
|
||||||
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
|
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
|
||||||
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ],
|
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user