mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
commit
92fdb379cf
@ -85,6 +85,8 @@ namespace NewHorizons.Builder.General
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (ao.GetAstroObjectName() == AstroObject.Name.CaveTwin || ao.GetAstroObjectName() == AstroObject.Name.TowerTwin)
|
||||
{
|
||||
if (ao.GetAstroObjectName() == AstroObject.Name.TowerTwin)
|
||||
@ -173,6 +175,11 @@ namespace NewHorizons.Builder.General
|
||||
GameObject.Find("BackRaft_Body").SetActive(false);
|
||||
GameObject.Find("SealRaft_Body").SetActive(false);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.LogWarning($"Exception thrown when trying to delete bodies related to [{ao.name}]: {e.Message}, {e.StackTrace}");
|
||||
}
|
||||
|
||||
// Deal with proxies
|
||||
foreach (var p in GameObject.FindObjectsOfType<ProxyOrbiter>())
|
||||
@ -185,7 +192,8 @@ namespace NewHorizons.Builder.General
|
||||
}
|
||||
RemoveProxy(ao.name.Replace("_Body", ""));
|
||||
|
||||
ao.transform.root.gameObject.SetActive(false);
|
||||
// For TH we wait until the player is fully loaded in
|
||||
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () => ao.transform.root.gameObject.SetActive(false));
|
||||
|
||||
foreach (ProxyBody proxy in GameObject.FindObjectsOfType<ProxyBody>())
|
||||
{
|
||||
|
||||
@ -60,7 +60,7 @@ namespace NewHorizons.Builder.General
|
||||
if(!Main.Instance.IsWarping && module.StartWithSuit && !suitUpQueued)
|
||||
{
|
||||
suitUpQueued = true;
|
||||
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => SuitUp(), 4);
|
||||
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () => SuitUp());
|
||||
}
|
||||
|
||||
Logger.Log("Made spawnpoint on [" + body.name + "]");
|
||||
|
||||
@ -10,6 +10,7 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
using NewHorizons.External;
|
||||
using OWML.Common;
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.Handlers;
|
||||
|
||||
namespace NewHorizons.Builder.Props
|
||||
{
|
||||
@ -63,21 +64,8 @@ namespace NewHorizons.Builder.Props
|
||||
GameObject prop = GameObject.Instantiate(prefab, sector.transform);
|
||||
prop.SetActive(false);
|
||||
|
||||
List<string> assetBundles = new List<string>();
|
||||
foreach (var streamingHandle in prop.GetComponentsInChildren<StreamingMeshHandle>())
|
||||
{
|
||||
var assetBundle = streamingHandle.assetBundle;
|
||||
if (!assetBundles.Contains(assetBundle))
|
||||
{
|
||||
assetBundles.Add(assetBundle);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var assetBundle in assetBundles)
|
||||
{
|
||||
sector.OnOccupantEnterSector += (SectorDetector sd) => StreamingManager.LoadStreamingAssets(assetBundle);
|
||||
StreamingManager.LoadStreamingAssets(assetBundle);
|
||||
}
|
||||
sector.OnOccupantEnterSector += (SectorDetector sd) => OWAssetHandler.OnOccupantEnterSector(prop, sd, sector);
|
||||
OWAssetHandler.LoadObject(prop);
|
||||
|
||||
foreach (var component in prop.GetComponents<Component>().Concat(prop.GetComponentsInChildren<Component>()))
|
||||
{
|
||||
@ -93,7 +81,7 @@ namespace NewHorizons.Builder.Props
|
||||
if(component is AnglerfishAnimController && component.GetComponentInParent<AnglerfishController>() == null)
|
||||
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => (component as AnglerfishAnimController).enabled = false);
|
||||
|
||||
if (component is Animator) Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => (component as Animator).enabled = true, 5);
|
||||
if (component is Animator) Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () => (component as Animator).enabled = true);
|
||||
if (component is Collider) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => (component as Collider).enabled = true);
|
||||
|
||||
if(component is Shape) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => (component as Shape).enabled = true);
|
||||
|
||||
89
NewHorizons/Handlers/OWAssetHandler.cs
Normal file
89
NewHorizons/Handlers/OWAssetHandler.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Handlers
|
||||
{
|
||||
public static class OWAssetHandler
|
||||
{
|
||||
private static Dictionary<Material, string> _materialCache;
|
||||
private static Dictionary<GameObject, List<string>> _objectCache;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_materialCache = new Dictionary<Material, string>();
|
||||
_objectCache = new Dictionary<GameObject, List<string>>();
|
||||
}
|
||||
|
||||
public static void OnOccupantEnterSector(GameObject obj, SectorDetector sd, Sector sector)
|
||||
{
|
||||
LoadObject(obj);
|
||||
|
||||
// If its too laggy put this back idk
|
||||
/*
|
||||
if (sector.GetOccupants().Count > 0 || sd._occupantType == DynamicOccupant.Player)
|
||||
{
|
||||
LoadObject(obj);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static void LoadObject(GameObject obj)
|
||||
{
|
||||
var assetBundles = new List<string>();
|
||||
|
||||
if (_objectCache.ContainsKey(obj))
|
||||
{
|
||||
assetBundles = _objectCache[obj];
|
||||
}
|
||||
else
|
||||
{
|
||||
var tables = Resources.FindObjectsOfTypeAll<StreamingMaterialTable>();
|
||||
foreach (var streamingHandle in obj.GetComponentsInChildren<StreamingMeshHandle>())
|
||||
{
|
||||
var assetBundle = streamingHandle.assetBundle;
|
||||
if (!assetBundles.Contains(assetBundle))
|
||||
{
|
||||
assetBundles.Add(assetBundle);
|
||||
}
|
||||
if (streamingHandle is StreamingRenderMeshHandle || streamingHandle is StreamingSkinnedMeshHandle)
|
||||
{
|
||||
var materials = streamingHandle.GetComponent<Renderer>().sharedMaterials;
|
||||
|
||||
if (materials.Length == 0) continue;
|
||||
|
||||
// Gonna assume that if theres more than one material its probably in the same asset bundle anyway right
|
||||
if (_materialCache.TryGetValue(materials[0], out assetBundle))
|
||||
{
|
||||
assetBundles.Add(assetBundle);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var table in tables)
|
||||
{
|
||||
foreach (var x in table._materialPropertyLookups)
|
||||
{
|
||||
if (materials.Contains(x.material))
|
||||
{
|
||||
_materialCache.SafeAdd(x.material, table.assetBundle);
|
||||
assetBundles.SafeAdd(table.assetBundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_objectCache[obj] = assetBundles;
|
||||
}
|
||||
|
||||
foreach (var assetBundle in assetBundles)
|
||||
{
|
||||
StreamingManager.LoadStreamingAssets(assetBundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -43,6 +43,7 @@ namespace NewHorizons
|
||||
public static Dictionary<string, AssetBundle> AssetBundles = new Dictionary<string, AssetBundle>();
|
||||
public static List<IModBehaviour> MountedAddons = new List<IModBehaviour>();
|
||||
|
||||
public static bool IsSystemReady { get; private set; }
|
||||
public static float FurthestOrbit { get; set; } = 50000f;
|
||||
|
||||
public string CurrentStarSystem { get { return Instance._currentStarSystem; } }
|
||||
@ -91,6 +92,7 @@ namespace NewHorizons
|
||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
Instance = this;
|
||||
GlobalMessenger<DeathType>.AddListener("PlayerDeath", OnDeath);
|
||||
GlobalMessenger.AddListener("WakeUp", new Callback(OnWakeUp));
|
||||
ShaderBundle = Main.Instance.ModHelper.Assets.LoadBundle("AssetBundle/shader");
|
||||
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
|
||||
SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig(null), this);
|
||||
@ -170,6 +172,12 @@ namespace NewHorizons
|
||||
Logger.Log($"Destroying NewHorizons");
|
||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
GlobalMessenger<DeathType>.RemoveListener("PlayerDeath", OnDeath);
|
||||
GlobalMessenger.RemoveListener("WakeUp", new Callback(OnWakeUp));
|
||||
}
|
||||
|
||||
private static void OnWakeUp()
|
||||
{
|
||||
IsSystemReady = true;
|
||||
}
|
||||
|
||||
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
@ -185,10 +193,13 @@ namespace NewHorizons
|
||||
|
||||
if(scene.name == "SolarSystem")
|
||||
{
|
||||
IsSystemReady = false;
|
||||
|
||||
HeavenlyBodyBuilder.Reset();
|
||||
NewHorizonsData.Load();
|
||||
SignalBuilder.Init();
|
||||
AstroObjectLocator.RefreshList();
|
||||
OWAssetHandler.Init();
|
||||
PlanetCreationHandler.Init(BodyDict[CurrentStarSystem]);
|
||||
LoadTranslations(ModHelper.Manifest.ModFolderPath + "AssetBundle/", this);
|
||||
|
||||
@ -202,8 +213,8 @@ namespace NewHorizons
|
||||
if (HasWarpDrive == true) EnableWarpDrive();
|
||||
|
||||
Logger.Log($"Is the player warping in? {IsWarping}");
|
||||
if (IsWarping && _shipWarpController) Instance.ModHelper.Events.Unity.FireInNUpdates(() => _shipWarpController.WarpIn(WearingSuit), 5);
|
||||
else Instance.ModHelper.Events.Unity.FireInNUpdates(() => GameObject.FindObjectOfType<PlayerSpawner>().DebugWarp(SystemDict[_currentStarSystem].SpawnPoint), 5);
|
||||
if (IsWarping && _shipWarpController) Instance.ModHelper.Events.Unity.RunWhen(() => IsSystemReady, () => _shipWarpController.WarpIn(WearingSuit));
|
||||
else Instance.ModHelper.Events.Unity.RunWhen(() => IsSystemReady, () => FindObjectOfType<PlayerSpawner>().DebugWarp(SystemDict[_currentStarSystem].SpawnPoint));
|
||||
IsWarping = false;
|
||||
|
||||
var map = GameObject.FindObjectOfType<MapController>();
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
"author": "xen, Idiot, & Book",
|
||||
"name": "New Horizons",
|
||||
"uniqueName": "xen.NewHorizons",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.3",
|
||||
"owmlVersion": "2.1.0",
|
||||
"dependencies": [ "PacificEngine.OW_CommonResources" ],
|
||||
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.OuterWildsMMO", "Vesper.AutoResume" ]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user