mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Merge branch 'dev' of https://github.com/xen-42/outer-wilds-new-horizons into dev
This commit is contained in:
commit
baf4cff8d5
@ -2,7 +2,7 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
namespace NewHorizons.Builder.General
|
namespace NewHorizons.Builder.General
|
||||||
{
|
{
|
||||||
public static class MakeSector
|
public static class SectorBuilder
|
||||||
{
|
{
|
||||||
public static Sector Make(GameObject planetBody, OWRigidbody owRigidBody, float sphereOfInfluence)
|
public static Sector Make(GameObject planetBody, OWRigidbody owRigidBody, float sphereOfInfluence)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -187,8 +187,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
var path = config.isSeed ? brambleSeedPrefabPath : brambleNodePrefabPath;
|
var path = config.isSeed ? brambleSeedPrefabPath : brambleNodePrefabPath;
|
||||||
var brambleNode = SearchUtilities.Find(path).InstantiateInactive();
|
var brambleNode = SearchUtilities.Find(path).InstantiateInactive();
|
||||||
|
|
||||||
OWAssetHandler.LoadObject(brambleNode);
|
StreamingHandler.HookStreaming(brambleNode);
|
||||||
sector.OnOccupantEnterSector += (sd) => OWAssetHandler.OnOccupantEnterSector(brambleNode, sd, sector);
|
sector.OnOccupantEnterSector += (sd) => StreamingHandler.OnOccupantEnterSector(brambleNode, sd, sector);
|
||||||
|
|
||||||
brambleNode.transform.parent = sector.transform;
|
brambleNode.transform.parent = sector.transform;
|
||||||
brambleNode.transform.position = go.transform.TransformPoint(config.position);
|
brambleNode.transform.position = go.transform.TransformPoint(config.position);
|
||||||
|
|||||||
@ -109,8 +109,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
prop.transform.parent = sector?.transform ?? planetGO.transform;
|
prop.transform.parent = sector?.transform ?? planetGO.transform;
|
||||||
prop.SetActive(false);
|
prop.SetActive(false);
|
||||||
|
|
||||||
if (sector != null) sector.OnOccupantEnterSector += (SectorDetector sd) => OWAssetHandler.OnOccupantEnterSector(prop, sd, sector);
|
if (sector != null) sector.OnOccupantEnterSector += (SectorDetector sd) => StreamingHandler.OnOccupantEnterSector(prop, sd, sector);
|
||||||
OWAssetHandler.LoadObject(prop);
|
StreamingHandler.HookStreaming(prop);
|
||||||
|
|
||||||
foreach (var component in prop.GetComponents<Component>().Concat(prop.GetComponentsInChildren<Component>()))
|
foreach (var component in prop.GetComponents<Component>().Concat(prop.GetComponentsInChildren<Component>()))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -201,8 +201,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
AddTranslation(xmlPath);
|
AddTranslation(xmlPath);
|
||||||
|
|
||||||
// Make sure the computer model is loaded
|
// Make sure the computer model is loaded
|
||||||
OWAssetHandler.LoadObject(computerObject);
|
StreamingHandler.HookStreaming(computerObject);
|
||||||
sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(computerObject));
|
sector.OnOccupantEnterSector.AddListener((x) => StreamingHandler.HookStreaming(computerObject));
|
||||||
|
|
||||||
computerObject.SetActive(true);
|
computerObject.SetActive(true);
|
||||||
conversationInfoToCorrespondingSpawnedGameObject[info] = computerObject;
|
conversationInfoToCorrespondingSpawnedGameObject[info] = computerObject;
|
||||||
@ -249,8 +249,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
AddTranslation(xmlPath);
|
AddTranslation(xmlPath);
|
||||||
|
|
||||||
// Make sure the computer model is loaded
|
// Make sure the computer model is loaded
|
||||||
OWAssetHandler.LoadObject(cairnObject);
|
StreamingHandler.HookStreaming(cairnObject);
|
||||||
sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(cairnObject));
|
sector.OnOccupantEnterSector.AddListener((x) => StreamingHandler.HookStreaming(cairnObject));
|
||||||
conversationInfoToCorrespondingSpawnedGameObject[info] = cairnObject;
|
conversationInfoToCorrespondingSpawnedGameObject[info] = cairnObject;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -281,8 +281,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
AddTranslation(xmlPath);
|
AddTranslation(xmlPath);
|
||||||
|
|
||||||
// Make sure the recorder model is loaded
|
// Make sure the recorder model is loaded
|
||||||
OWAssetHandler.LoadObject(recorderObject);
|
StreamingHandler.HookStreaming(recorderObject);
|
||||||
sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(recorderObject));
|
sector.OnOccupantEnterSector.AddListener((x) => StreamingHandler.HookStreaming(recorderObject));
|
||||||
|
|
||||||
recorderObject.SetActive(true);
|
recorderObject.SetActive(true);
|
||||||
|
|
||||||
|
|||||||
@ -129,8 +129,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
// Idk why but it wants reveals to be comma delimited not a list
|
// Idk why but it wants reveals to be comma delimited not a list
|
||||||
if (info.reveals != null) slideCollectionContainer._shipLogOnComplete = string.Join(",", info.reveals);
|
if (info.reveals != null) slideCollectionContainer._shipLogOnComplete = string.Join(",", info.reveals);
|
||||||
|
|
||||||
OWAssetHandler.LoadObject(slideReelObj);
|
StreamingHandler.HookStreaming(slideReelObj);
|
||||||
sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(slideReelObj));
|
sector.OnOccupantEnterSector.AddListener((x) => StreamingHandler.HookStreaming(slideReelObj));
|
||||||
|
|
||||||
slideReelObj.SetActive(true);
|
slideReelObj.SetActive(true);
|
||||||
}
|
}
|
||||||
@ -180,8 +180,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
slideCollectionContainer.slideCollection = slideCollection;
|
slideCollectionContainer.slideCollection = slideCollection;
|
||||||
|
|
||||||
OWAssetHandler.LoadObject(projectorObj);
|
StreamingHandler.HookStreaming(projectorObj);
|
||||||
sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(projectorObj));
|
sector.OnOccupantEnterSector.AddListener((x) => StreamingHandler.HookStreaming(projectorObj));
|
||||||
|
|
||||||
// Change the picture on the lens
|
// Change the picture on the lens
|
||||||
var lens = projectorObj.transform.Find("Spotlight/Prop_IP_SingleSlideProjector/Projector_Lens").GetComponent<MeshRenderer>();
|
var lens = projectorObj.transform.Find("Spotlight/Prop_IP_SingleSlideProjector/Projector_Lens").GetComponent<MeshRenderer>();
|
||||||
|
|||||||
@ -29,8 +29,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
raftObject.transform.position = planetGO.transform.TransformPoint(info.position);
|
raftObject.transform.position = planetGO.transform.TransformPoint(info.position);
|
||||||
raftObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.identity);
|
raftObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.identity);
|
||||||
|
|
||||||
sector.OnOccupantEnterSector += (sd) => OWAssetHandler.OnOccupantEnterSector(raftObject, sd, sector);
|
sector.OnOccupantEnterSector += (sd) => StreamingHandler.OnOccupantEnterSector(raftObject, sd, sector);
|
||||||
OWAssetHandler.LoadObject(raftObject);
|
StreamingHandler.HookStreaming(raftObject);
|
||||||
|
|
||||||
var raftController = raftObject.GetComponent<RaftController>();
|
var raftController = raftObject.GetComponent<RaftController>();
|
||||||
// Since awake already ran we have to unhook these events
|
// Since awake already ran we have to unhook these events
|
||||||
|
|||||||
@ -136,8 +136,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
controller._midBone.localPosition = controller._midStartPos;
|
controller._midBone.localPosition = controller._midStartPos;
|
||||||
controller._topBone.localPosition = controller._topStartPos;
|
controller._topBone.localPosition = controller._topStartPos;
|
||||||
|
|
||||||
OWAssetHandler.LoadObject(tornadoGO);
|
StreamingHandler.HookStreaming(tornadoGO);
|
||||||
sector.OnOccupantEnterSector += (sd) => OWAssetHandler.LoadObject(tornadoGO);
|
sector.OnOccupantEnterSector += (sd) => StreamingHandler.HookStreaming(tornadoGO);
|
||||||
|
|
||||||
tornadoGO.GetComponentInChildren<CapsuleShape>().enabled = true;
|
tornadoGO.GetComponentInChildren<CapsuleShape>().enabled = true;
|
||||||
|
|
||||||
|
|||||||
@ -195,7 +195,7 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
var rb = existingPlanet.GetComponent<OWRigidbody>();
|
var rb = existingPlanet.GetComponent<OWRigidbody>();
|
||||||
|
|
||||||
var sector = MakeSector.Make(existingPlanet, rb, GetSphereOfInfluence(body));
|
var sector = SectorBuilder.Make(existingPlanet, rb, GetSphereOfInfluence(body));
|
||||||
sector.name = $"Sector-{existingPlanet.GetComponentsInChildren<Sector>().Count()}";
|
sector.name = $"Sector-{existingPlanet.GetComponentsInChildren<Sector>().Count()}";
|
||||||
|
|
||||||
SharedGenerateBody(body, existingPlanet, sector, rb);
|
SharedGenerateBody(body, existingPlanet, sector, rb);
|
||||||
@ -310,7 +310,7 @@ namespace NewHorizons.Handlers
|
|||||||
var owRigidBody = RigidBodyBuilder.Make(go, body.Config);
|
var owRigidBody = RigidBodyBuilder.Make(go, body.Config);
|
||||||
var ao = AstroObjectBuilder.Make(go, null, body.Config);
|
var ao = AstroObjectBuilder.Make(go, null, body.Config);
|
||||||
|
|
||||||
var sector = MakeSector.Make(go, owRigidBody, 2000f);
|
var sector = SectorBuilder.Make(go, owRigidBody, 2000f);
|
||||||
ao._rootSector = sector;
|
ao._rootSector = sector;
|
||||||
ao._type = AstroObject.Type.None;
|
ao._type = AstroObject.Type.None;
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
var sphereOfInfluence = GetSphereOfInfluence(body);
|
var sphereOfInfluence = GetSphereOfInfluence(body);
|
||||||
|
|
||||||
var sector = MakeSector.Make(go, owRigidBody, sphereOfInfluence * 2f);
|
var sector = SectorBuilder.Make(go, owRigidBody, sphereOfInfluence * 2f);
|
||||||
ao._rootSector = sector;
|
ao._rootSector = sector;
|
||||||
|
|
||||||
if (body.Config.Base.surfaceGravity != 0)
|
if (body.Config.Base.surfaceGravity != 0)
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace NewHorizons.Handlers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// handles streaming meshes so they stay loaded
|
/// handles streaming meshes so they stay loaded
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class OWAssetHandler
|
public static class StreamingHandler
|
||||||
{
|
{
|
||||||
private static Dictionary<Material, string> _materialCache;
|
private static Dictionary<Material, string> _materialCache;
|
||||||
private static Dictionary<GameObject, List<string>> _objectCache;
|
private static Dictionary<GameObject, List<string>> _objectCache;
|
||||||
@ -19,7 +19,7 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
public static void OnOccupantEnterSector(GameObject obj, SectorDetector sd, Sector sector)
|
public static void OnOccupantEnterSector(GameObject obj, SectorDetector sd, Sector sector)
|
||||||
{
|
{
|
||||||
LoadObject(obj);
|
HookStreaming(obj);
|
||||||
|
|
||||||
// If its too laggy put this back idk
|
// If its too laggy put this back idk
|
||||||
/*
|
/*
|
||||||
@ -30,7 +30,10 @@ namespace NewHorizons.Handlers
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadObject(GameObject obj)
|
/// <summary>
|
||||||
|
/// makes it so that this object's streaming stuff will be connected to the given sector
|
||||||
|
/// </summary>
|
||||||
|
public static void HookStreaming(GameObject obj, Sector sector = null)
|
||||||
{
|
{
|
||||||
var assetBundles = new List<string>();
|
var assetBundles = new List<string>();
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ namespace NewHorizons
|
|||||||
BrambleDimensionBuilder.Init();
|
BrambleDimensionBuilder.Init();
|
||||||
BrambleNodeBuilder.Init();
|
BrambleNodeBuilder.Init();
|
||||||
AstroObjectLocator.Init();
|
AstroObjectLocator.Init();
|
||||||
OWAssetHandler.Init();
|
StreamingHandler.Init();
|
||||||
PlanetCreationHandler.Init(BodyDict[CurrentStarSystem]);
|
PlanetCreationHandler.Init(BodyDict[CurrentStarSystem]);
|
||||||
VesselWarpHandler.LoadVessel();
|
VesselWarpHandler.LoadVessel();
|
||||||
SystemCreationHandler.LoadSystem(SystemDict[CurrentStarSystem]);
|
SystemCreationHandler.LoadSystem(SystemDict[CurrentStarSystem]);
|
||||||
|
|||||||
@ -88,13 +88,18 @@ namespace NewHorizons.Utility
|
|||||||
public static GameObject FindChild(this GameObject g, string childPath) =>
|
public static GameObject FindChild(this GameObject g, string childPath) =>
|
||||||
g.transform.Find(childPath)?.gameObject;
|
g.transform.Find(childPath)?.gameObject;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// finds active or inactive object by path,
|
||||||
|
/// or recursively finds an active object by name
|
||||||
|
/// </summary>
|
||||||
public static GameObject Find(string path, bool warn = true)
|
public static GameObject Find(string path, bool warn = true)
|
||||||
{
|
{
|
||||||
if (CachedGameObjects.TryGetValue(path, out var go)) return go;
|
if (CachedGameObjects.TryGetValue(path, out var go)) return go;
|
||||||
|
|
||||||
go = GameObject.Find(path);
|
go = GameObject.Find(path);
|
||||||
if (go != null) return go;
|
if (go == null)
|
||||||
|
{
|
||||||
|
// find inactive use root + transform.find
|
||||||
var names = path.Split('/');
|
var names = path.Split('/');
|
||||||
var rootName = names[0];
|
var rootName = names[0];
|
||||||
var root = SceneManager.GetActiveScene().GetRootGameObjects().FirstOrDefault(x => x.name == rootName);
|
var root = SceneManager.GetActiveScene().GetRootGameObjects().FirstOrDefault(x => x.name == rootName);
|
||||||
@ -108,9 +113,9 @@ namespace NewHorizons.Utility
|
|||||||
go = root.FindChild(childPath);
|
go = root.FindChild(childPath);
|
||||||
if (go == null)
|
if (go == null)
|
||||||
{
|
{
|
||||||
var name = names.Last();
|
if (warn) Logger.LogWarning($"Couldn't find child object in path ({path})");
|
||||||
if (warn) Logger.LogWarning($"Couldn't find object in path ({path}), will look for potential matches for name {name}");
|
return null;
|
||||||
go = FindObjectOfTypeAndName<GameObject>(name);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedGameObjects.Add(path, go);
|
CachedGameObjects.Add(path, go);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user