mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Merge branch 'dev' into no-more-CR
This commit is contained in:
commit
100b3f1b46
@ -1,12 +1,63 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using NewHorizons.External.Configs;
|
||||||
using System.Linq;
|
using NewHorizons.Utility;
|
||||||
using System.Text;
|
using OWML.Common;
|
||||||
using System.Threading.Tasks;
|
using UnityEngine;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
using Object = System.Object;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.StarSystem
|
namespace NewHorizons.Builder.StarSystem
|
||||||
{
|
{
|
||||||
class SkyboxBuilder
|
internal class SkyboxBuilder
|
||||||
{
|
{
|
||||||
|
public static Material LoadMaterial(string assetBundle, string path, string uniqueModName, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
string key = uniqueModName + "." + assetBundle;
|
||||||
|
AssetBundle bundle;
|
||||||
|
Material cubemap;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Main.AssetBundles.ContainsKey(key)) bundle = Main.AssetBundles[key];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bundle = mod.ModHelper.Assets.LoadBundle(assetBundle);
|
||||||
|
Main.AssetBundles[key] = bundle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Couldn't load AssetBundle {assetBundle} : {e.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cubemap = bundle.LoadAsset<Material>(path);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Log($"Couldn't load asset {path} from AssetBundle {assetBundle} : {e.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cubemap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Make(StarSystemConfig.SkyboxConfig info, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
Logger.Log("Building Skybox");
|
||||||
|
Material skyBoxMaterial = LoadMaterial(info.assetBundle, info.path, mod.ModHelper.Manifest.UniqueName, mod);
|
||||||
|
RenderSettings.skybox = skyBoxMaterial;
|
||||||
|
DynamicGI.UpdateEnvironment();
|
||||||
|
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() =>
|
||||||
|
{
|
||||||
|
foreach (var camera in Resources.FindObjectsOfTypeAll<OWCamera>())
|
||||||
|
{
|
||||||
|
camera.clearFlags = CameraClearFlags.Skybox;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ namespace NewHorizons.External.Configs
|
|||||||
public bool destroyStockPlanets = true;
|
public bool destroyStockPlanets = true;
|
||||||
public string factRequiredForWarp;
|
public string factRequiredForWarp;
|
||||||
public NomaiCoordinates coords;
|
public NomaiCoordinates coords;
|
||||||
|
public SkyboxConfig skybox;
|
||||||
|
|
||||||
public class NomaiCoordinates
|
public class NomaiCoordinates
|
||||||
{
|
{
|
||||||
@ -22,6 +23,14 @@ namespace NewHorizons.External.Configs
|
|||||||
public int[] z;
|
public int[] z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SkyboxConfig
|
||||||
|
{
|
||||||
|
public string assetBundle = null;
|
||||||
|
public string path = null;
|
||||||
|
public bool destroyStarField = false;
|
||||||
|
}
|
||||||
|
|
||||||
public StarSystemConfig(Dictionary<string, object> dict) : base(dict) { }
|
public StarSystemConfig(Dictionary<string, object> dict) : base(dict) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,10 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using NewHorizons.Builder.StarSystem;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace NewHorizons.Handlers
|
namespace NewHorizons.Handlers
|
||||||
{
|
{
|
||||||
@ -17,23 +20,15 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
var skybox = GameObject.Find("Skybox/Starfield");
|
var skybox = GameObject.Find("Skybox/Starfield");
|
||||||
|
|
||||||
/*
|
if (system.Config.skybox?.destroyStarField ?? false)
|
||||||
skybox.GetComponent<MeshRenderer>().material.shader = Shader.Find("Standard");
|
{
|
||||||
*/
|
Object.Destroy(skybox);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
if (system.Config.skybox?.assetBundle != null && system.Config.skybox?.path != null)
|
||||||
var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
|
{
|
||||||
GameObject.Destroy(sphere.GetComponent<SphereCollider>());
|
SkyboxBuilder.Make(system.Config.skybox, system.Mod);
|
||||||
|
}
|
||||||
sphere.transform.parent = skybox.transform;
|
|
||||||
sphere.transform.localPosition = Vector3.zero;
|
|
||||||
|
|
||||||
var meshFilter = sphere.GetComponent<MeshFilter>();
|
|
||||||
meshFilter.mesh.triangles = meshFilter.mesh.triangles.Reverse().ToArray();
|
|
||||||
|
|
||||||
var meshRenderer = sphere.GetComponent<MeshRenderer>();
|
|
||||||
meshRenderer.material.color = Color.green;
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,6 +95,30 @@ namespace NewHorizons
|
|||||||
_wasConfigured = true;
|
_wasConfigured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ResetConfigs(bool resetTranslation = true)
|
||||||
|
{
|
||||||
|
BodyDict.Clear();
|
||||||
|
SystemDict.Clear();
|
||||||
|
|
||||||
|
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
|
||||||
|
BodyDict["EyeOfTheUniverse"] = new List<NewHorizonsBody>(); // Keep this empty tho fr
|
||||||
|
SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig(null), Instance)
|
||||||
|
{
|
||||||
|
Config =
|
||||||
|
{
|
||||||
|
destroyStockPlanets = false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
foreach (AssetBundle bundle in AssetBundles.Values)
|
||||||
|
{
|
||||||
|
bundle.Unload(true);
|
||||||
|
}
|
||||||
|
AssetBundles.Clear();
|
||||||
|
if (!resetTranslation) return;
|
||||||
|
TranslationHandler.ClearTables();
|
||||||
|
TextTranslation.Get().SetLanguage(TextTranslation.Get().GetLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
// Patches
|
// Patches
|
||||||
@ -111,12 +135,8 @@ namespace NewHorizons
|
|||||||
GlobalMessenger.AddListener("WakeUp", new Callback(OnWakeUp));
|
GlobalMessenger.AddListener("WakeUp", new Callback(OnWakeUp));
|
||||||
ShaderBundle = Main.Instance.ModHelper.Assets.LoadBundle("AssetBundle/shader");
|
ShaderBundle = Main.Instance.ModHelper.Assets.LoadBundle("AssetBundle/shader");
|
||||||
|
|
||||||
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
|
ResetConfigs(resetTranslation: false);
|
||||||
BodyDict["EyeOfTheUniverse"] = new List<NewHorizonsBody>(); // Keep this empty tho fr
|
|
||||||
|
|
||||||
SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig(null), this);
|
|
||||||
SystemDict["SolarSystem"].Config.destroyStockPlanets = false;
|
|
||||||
|
|
||||||
Logger.Log("Begin load of config files...", Logger.LogType.Log);
|
Logger.Log("Begin load of config files...", Logger.LogType.Log);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
@ -31,20 +31,9 @@ namespace NewHorizons.Utility
|
|||||||
|
|
||||||
private static void ReloadConfigs()
|
private static void ReloadConfigs()
|
||||||
{
|
{
|
||||||
Main.BodyDict.Clear();
|
|
||||||
Main.SystemDict.Clear();
|
|
||||||
|
|
||||||
Main.BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
|
|
||||||
Main.SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig(null), Main.Instance);
|
|
||||||
foreach (AssetBundle bundle in Main.AssetBundles.Values)
|
|
||||||
{
|
|
||||||
bundle.Unload(true);
|
|
||||||
}
|
|
||||||
Main.AssetBundles.Clear();
|
|
||||||
TranslationHandler.ClearTables();
|
|
||||||
TextTranslation.Get().SetLanguage(TextTranslation.Get().GetLanguage());
|
|
||||||
|
|
||||||
Logger.Log("Begin reload of config files...", Logger.LogType.Log);
|
Logger.Log("Begin reload of config files...", Logger.LogType.Log);
|
||||||
|
|
||||||
|
Main.ResetConfigs();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
"author": "xen, Bwc9876, & Book",
|
"author": "xen, Bwc9876, & Book",
|
||||||
"name": "New Horizons",
|
"name": "New Horizons",
|
||||||
"uniqueName": "xen.NewHorizons",
|
"uniqueName": "xen.NewHorizons",
|
||||||
"version": "0.13.0",
|
"version": "0.13.1",
|
||||||
"owmlVersion": "2.1.0",
|
"owmlVersion": "2.1.0",
|
||||||
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.AutoResume" ],
|
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.AutoResume" ],
|
||||||
"pathsToPreserve": [ "planets", "systems", "translations" ]
|
"pathsToPreserve": [ "planets", "systems", "translations" ]
|
||||||
|
|||||||
@ -19,6 +19,25 @@
|
|||||||
"destroyStockPlanets": {
|
"destroyStockPlanets": {
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"description": "Do you want a clean slate for this star system? Or will it be a modified version of the original."
|
"description": "Do you want a clean slate for this star system? Or will it be a modified version of the original."
|
||||||
|
},
|
||||||
|
"skybox": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Options for the skybox of your system",
|
||||||
|
"properties": {
|
||||||
|
"destroyStarField": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Whether to destroy the star field around the player (always set to true if `assetBundle` and `path` is set)",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
"assetBundle": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path to the Unity asset bundle to load the skybox material from"
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path to the material within the asset bundle specified by `assetBundle` to use for the skybox"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user