Make details high LOD

This commit is contained in:
Nick 2022-03-04 01:38:46 -05:00
parent 80ca144793
commit 4efba911b3
3 changed files with 57 additions and 15 deletions

View File

@ -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.LoadObject(prop);
OWAssetHandler.LoadObject(prop);
foreach (var component in prop.GetComponents<Component>().Concat(prop.GetComponentsInChildren<Component>()))
{

View File

@ -0,0 +1,53 @@
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
{
public static void Init()
{
}
public static void LoadObject(GameObject obj)
{
var assetBundles = new List<string>();
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;
foreach (var table in tables)
{
foreach(var x in table._materialPropertyLookups)
{
if(materials.Contains(x.material))
{
assetBundles.SafeAdd(table.assetBundle);
}
}
}
}
}
foreach (var assetBundle in assetBundles)
{
Logger.Log($"Loading {assetBundles.Count} : {assetBundle}");
StreamingManager.LoadStreamingAssets(assetBundle);
}
}
}
}

View File

@ -190,6 +190,7 @@ namespace NewHorizons
SignalBuilder.Init();
AstroObjectLocator.RefreshList();
PlanetCreationHandler.Init(BodyDict[CurrentStarSystem]);
OWAssetHandler.Init();
LoadTranslations(ModHelper.Manifest.ModFolderPath + "AssetBundle/", this);
Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => Locator.GetPlayerBody().gameObject.AddComponent<DebugRaycaster>());