mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add remote builder to multi pass
Do not try catch anymore This would cause some addon devs to just ignore an error when they really shouldn't. Now it will show the body where this error occurs since the error gets handled higher up.
This commit is contained in:
parent
3cf384accf
commit
96bb04ef6b
@ -128,6 +128,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
MakeGeneralProps(go, config.Props.warpReceivers, (warpReceiver) => WarpPadBuilder.Make(go, sector, mod, warpReceiver), (warpReceiver) => warpReceiver.frequency);
|
MakeGeneralProps(go, config.Props.warpReceivers, (warpReceiver) => WarpPadBuilder.Make(go, sector, mod, warpReceiver), (warpReceiver) => warpReceiver.frequency);
|
||||||
MakeGeneralProps(go, config.Props.warpTransmitters, (warpTransmitter) => WarpPadBuilder.Make(go, sector, mod, warpTransmitter), (warpTransmitter) => warpTransmitter.frequency);
|
MakeGeneralProps(go, config.Props.warpTransmitters, (warpTransmitter) => WarpPadBuilder.Make(go, sector, mod, warpTransmitter), (warpTransmitter) => warpTransmitter.frequency);
|
||||||
MakeGeneralProps(go, config.Props.audioSources, (audioSource) => AudioSourceBuilder.Make(go, sector, audioSource, mod), (audioSource) => audioSource.audio);
|
MakeGeneralProps(go, config.Props.audioSources, (audioSource) => AudioSourceBuilder.Make(go, sector, audioSource, mod), (audioSource) => audioSource.audio);
|
||||||
|
RemoteBuilder.InternalMake(go, sector, config.Props.remotes, nhBody);
|
||||||
|
|
||||||
RunMultiPass();
|
RunMultiPass();
|
||||||
|
|
||||||
@ -177,21 +178,6 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.Props.remotes != null)
|
|
||||||
{
|
|
||||||
foreach (var remoteInfo in config.Props.remotes)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
RemoteBuilder.Make(go, sector, remoteInfo, nhBody);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
NHLogger.LogError($"Couldn't make remote [{remoteInfo.id}] for [{go.name}]:\n{ex}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool DoesParentExist(GameObject go, BasePropInfo prop)
|
private static bool DoesParentExist(GameObject go, BasePropInfo prop)
|
||||||
|
|||||||
@ -12,6 +12,7 @@ using NewHorizons.Utility.OWML;
|
|||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using NewHorizons.External.Modules;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Props
|
namespace NewHorizons.Builder.Props
|
||||||
{
|
{
|
||||||
@ -122,10 +123,35 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static void InternalMake(GameObject go, Sector sector, RemoteInfo[] remotes, NewHorizonsBody nhBody)
|
||||||
|
{
|
||||||
|
if (remotes != null)
|
||||||
|
{
|
||||||
|
foreach (var remoteInfo in remotes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var mod = nhBody.Mod;
|
||||||
|
var id = RemoteHandler.GetPlatformID(remoteInfo.id);
|
||||||
|
|
||||||
|
Texture2D decal = Texture2D.whiteTexture;
|
||||||
|
if (!string.IsNullOrWhiteSpace(remoteInfo.decalPath)) decal = ImageUtilities.GetTexture(mod, remoteInfo.decalPath, false, false);
|
||||||
|
else NHLogger.LogError($"Missing decal path on [{remoteInfo.id}] for [{go.name}]");
|
||||||
|
|
||||||
|
PropBuildManager.MakeGeneralProp(go, remoteInfo.platform, (platform) => MakePlatform(go, sector, id, decal, platform, mod), (platform) => remoteInfo.id);
|
||||||
|
PropBuildManager.MakeGeneralProp(go, remoteInfo.whiteboard, (whiteboard) => MakeWhiteboard(go, sector, id, decal, whiteboard, nhBody), (whiteboard) => remoteInfo.id);
|
||||||
|
PropBuildManager.MakeGeneralProps(go, remoteInfo.stones, (stone) => MakeStone(go, sector, id, decal, stone, mod), (stone) => remoteInfo.id);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
NHLogger.LogError($"Couldn't make remote [{remoteInfo.id}] for [{go.name}]:\n{ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void Make(GameObject go, Sector sector, RemoteInfo info, NewHorizonsBody nhBody)
|
public static void Make(GameObject go, Sector sector, RemoteInfo info, NewHorizonsBody nhBody)
|
||||||
{
|
{
|
||||||
InitPrefabs();
|
|
||||||
|
|
||||||
var mod = nhBody.Mod;
|
var mod = nhBody.Mod;
|
||||||
var id = RemoteHandler.GetPlatformID(info.id);
|
var id = RemoteHandler.GetPlatformID(info.id);
|
||||||
|
|
||||||
@ -149,7 +175,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MakeWhiteboard(go, sector, nhBody.Mod, id, decal, info.whiteboard, nhBody);
|
MakeWhiteboard(go, sector, id, decal, info.whiteboard, nhBody);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -173,8 +199,10 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MakeWhiteboard(GameObject go, Sector sector, IModBehaviour mod, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemoteWhiteboardInfo info, NewHorizonsBody nhBody)
|
public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemoteWhiteboardInfo info, NewHorizonsBody nhBody)
|
||||||
{
|
{
|
||||||
|
InitPrefabs();
|
||||||
|
var mod = nhBody.Mod;
|
||||||
var whiteboard = DetailBuilder.Make(go, sector, mod, _whiteboardPrefab, new DetailInfo(info));
|
var whiteboard = DetailBuilder.Make(go, sector, mod, _whiteboardPrefab, new DetailInfo(info));
|
||||||
whiteboard.SetActive(false);
|
whiteboard.SetActive(false);
|
||||||
|
|
||||||
@ -213,8 +241,9 @@ namespace NewHorizons.Builder.Props
|
|||||||
whiteboard.SetActive(true);
|
whiteboard.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PlatformInfo info, IModBehaviour mod)
|
public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemotePlatformInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
|
InitPrefabs();
|
||||||
var platform = DetailBuilder.Make(go, sector, mod, _remoteCameraPlatformPrefab, new DetailInfo(info));
|
var platform = DetailBuilder.Make(go, sector, mod, _remoteCameraPlatformPrefab, new DetailInfo(info));
|
||||||
platform.SetActive(false);
|
platform.SetActive(false);
|
||||||
|
|
||||||
@ -239,8 +268,9 @@ namespace NewHorizons.Builder.Props
|
|||||||
platform.SetActive(true);
|
platform.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, StoneInfo info, IModBehaviour mod)
|
public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, ProjectionStoneInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
|
InitPrefabs();
|
||||||
var shareStone = GeneralPropBuilder.MakeFromPrefab(_shareStonePrefab, "ShareStone_" + id.ToString(), go, sector, info);
|
var shareStone = GeneralPropBuilder.MakeFromPrefab(_shareStonePrefab, "ShareStone_" + id.ToString(), go, sector, info);
|
||||||
|
|
||||||
shareStone.GetComponent<SharedStone>()._connectedPlatform = id;
|
shareStone.GetComponent<SharedStone>()._connectedPlatform = id;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ using Newtonsoft.Json;
|
|||||||
namespace NewHorizons.External.Modules.Props.Remote
|
namespace NewHorizons.External.Modules.Props.Remote
|
||||||
{
|
{
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class StoneInfo : GeneralPropInfo
|
public class ProjectionStoneInfo : GeneralPropInfo
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -23,11 +23,11 @@ namespace NewHorizons.External.Modules.Props.Remote
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Camera platform that the stones can project to and from
|
/// Camera platform that the stones can project to and from
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PlatformInfo platform;
|
public RemotePlatformInfo platform;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Projection stones
|
/// Projection stones
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public StoneInfo[] stones;
|
public ProjectionStoneInfo[] stones;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using System.ComponentModel;
|
|||||||
namespace NewHorizons.External.Modules.Props.Remote
|
namespace NewHorizons.External.Modules.Props.Remote
|
||||||
{
|
{
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class PlatformInfo : GeneralPropInfo
|
public class RemotePlatformInfo : GeneralPropInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A ship log fact to reveal when the platform is connected to.
|
/// A ship log fact to reveal when the platform is connected to.
|
||||||
@ -2,6 +2,7 @@ using NewHorizons.Utility.OWML;
|
|||||||
using OWML.Utils;
|
using OWML.Utils;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
|
||||||
namespace NewHorizons.Handlers
|
namespace NewHorizons.Handlers
|
||||||
@ -33,11 +34,27 @@ namespace NewHorizons.Handlers
|
|||||||
return id.ToString();
|
return id.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NomaiRemoteCameraPlatform.ID GetPlatformID(string id)
|
public static bool TryGetPlatformID(string id, out NomaiRemoteCameraPlatform.ID platformID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NomaiRemoteCameraPlatform.ID platformID;
|
if (!(_customPlatformIDs.TryGetValue(id, out platformID) || EnumUtils.TryParse<NomaiRemoteCameraPlatform.ID>(id, out platformID)))
|
||||||
|
{
|
||||||
|
platformID = AddCustomPlatformID(id);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
NHLogger.LogError($"Couldn't load platform id [{id}]:\n{e}");
|
||||||
|
platformID = NomaiRemoteCameraPlatform.ID.None;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NomaiRemoteCameraPlatform.ID GetPlatformID(string id)
|
||||||
|
{
|
||||||
|
NomaiRemoteCameraPlatform.ID platformID = NomaiRemoteCameraPlatform.ID.None;
|
||||||
if (_customPlatformIDs.TryGetValue(id, out platformID) || EnumUtils.TryParse<NomaiRemoteCameraPlatform.ID>(id, out platformID))
|
if (_customPlatformIDs.TryGetValue(id, out platformID) || EnumUtils.TryParse<NomaiRemoteCameraPlatform.ID>(id, out platformID))
|
||||||
{
|
{
|
||||||
return platformID;
|
return platformID;
|
||||||
@ -47,12 +64,6 @@ namespace NewHorizons.Handlers
|
|||||||
return AddCustomPlatformID(id);
|
return AddCustomPlatformID(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
NHLogger.LogError($"Couldn't load platform id [{id}]:\n{e}");
|
|
||||||
return NomaiRemoteCameraPlatform.ID.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NomaiRemoteCameraPlatform.ID AddCustomPlatformID(string id)
|
public static NomaiRemoteCameraPlatform.ID AddCustomPlatformID(string id)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user