mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add shared stones, projection platforms, and shared whiteboards.
This commit is contained in:
parent
aeca3d8698
commit
0cd726c2bc
@ -148,7 +148,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
/// <param name="sector"></param>
|
/// <param name="sector"></param>
|
||||||
/// <param name="isTorch"></param>
|
/// <param name="isTorch"></param>
|
||||||
private static void FixSectoredComponent(Component component, Sector sector, bool isTorch)
|
private static void FixSectoredComponent(Component component, Sector sector, bool isTorch = false)
|
||||||
{
|
{
|
||||||
if (component is Sector s)
|
if (component is Sector s)
|
||||||
{
|
{
|
||||||
@ -181,6 +181,11 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
sector.OnOccupantEnterSector.AddListener(_ => container.LoadStreamingTextures());
|
sector.OnOccupantEnterSector.AddListener(_ => container.LoadStreamingTextures());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (component is NomaiRemoteCameraPlatform remoteCameraPlatform)
|
||||||
|
{
|
||||||
|
remoteCameraPlatform._visualSector = sector;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -220,6 +220,20 @@ namespace NewHorizons.Builder.Props
|
|||||||
SignalBuilder.Make(go, sector, signal, mod);
|
SignalBuilder.Make(go, sector, signal, mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (config.Props.remotes != null)
|
||||||
|
{
|
||||||
|
foreach (var remoteInfo in config.Props.remotes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RemoteBuilder.Make(go, sector, remoteInfo, mod);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Couldn't make remote [{remoteInfo.id}] for [{go.name}]:\n{ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
294
NewHorizons/Builder/Props/RemoteBuilder.cs
Normal file
294
NewHorizons/Builder/Props/RemoteBuilder.cs
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
using NewHorizons.External.Modules;
|
||||||
|
using NewHorizons.Handlers;
|
||||||
|
using NewHorizons.Utility;
|
||||||
|
using OWML.Common;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
|
namespace NewHorizons.Builder.Props
|
||||||
|
{
|
||||||
|
public static class RemoteBuilder
|
||||||
|
{
|
||||||
|
private static Material _decalMaterial;
|
||||||
|
private static Material _decalMaterialGold;
|
||||||
|
private static GameObject _remoteCameraPlatformPrefab;
|
||||||
|
private static GameObject _whiteboardPrefab;
|
||||||
|
private static GameObject _shareStonePrefab;
|
||||||
|
|
||||||
|
private static void InitPrefabs()
|
||||||
|
{
|
||||||
|
_decalMaterial = new Material(Shader.Find("Standard (Decal)"));
|
||||||
|
_decalMaterial.name = "Decal";
|
||||||
|
_decalMaterial.SetTexture("_MainTex", Texture2D.whiteTexture);
|
||||||
|
_decalMaterial.SetTexture("_EmissionMap", Texture2D.whiteTexture);
|
||||||
|
_decalMaterial.SetFloat("_Glossiness", 0);
|
||||||
|
_decalMaterial.SetFloat("_BumpScale", 0);
|
||||||
|
_decalMaterial.SetColor("_Color", new Color(0.3529412f, 0.3843137f, 1));
|
||||||
|
_decalMaterial.SetColor("_EmissionColor", new Color(0.2422811f, 0.2917706f, 2.440062f));
|
||||||
|
_decalMaterialGold = new Material(_decalMaterial);
|
||||||
|
_decalMaterialGold.name = "DecalGold";
|
||||||
|
_decalMaterialGold.SetColor("_Color", new Color(1, 0.6392157f, 0.3803922f));
|
||||||
|
_decalMaterialGold.SetColor("_EmissionColor", new Color(1, 0.3662527f, 0.1195384f));
|
||||||
|
|
||||||
|
_remoteCameraPlatformPrefab = SearchUtilities.Find("OrbitalProbeCannon_Body/Sector_OrbitalProbeCannon/Sector_Module_Broken/Interactables_Module_Broken/Prefab_NOM_RemoteViewer").InstantiateInactive();
|
||||||
|
_remoteCameraPlatformPrefab.name = "Prefab_NOM_RemoteViewer";
|
||||||
|
var remoteCameraPlatform = _remoteCameraPlatformPrefab.GetComponent<NomaiRemoteCameraPlatform>();
|
||||||
|
remoteCameraPlatform.enabled = true;
|
||||||
|
remoteCameraPlatform._id = NomaiRemoteCameraPlatform.ID.None;
|
||||||
|
var AstroBodySymbolRenderer = _remoteCameraPlatformPrefab.FindChild("PedestalAnchor/Prefab_NOM_SharedPedestal/SharedPedestal_side01_bottom_jnt/SharedPedestal_side01_top_jnt/AstroBodySymbolRenderer");
|
||||||
|
var quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
|
||||||
|
quad.transform.parent = AstroBodySymbolRenderer.transform.parent;
|
||||||
|
quad.transform.localPosition = AstroBodySymbolRenderer.transform.localPosition;
|
||||||
|
quad.transform.localRotation = AstroBodySymbolRenderer.transform.localRotation;
|
||||||
|
quad.transform.localScale = AstroBodySymbolRenderer.transform.localScale;
|
||||||
|
quad.AddComponent<OWRenderer>();
|
||||||
|
quad.GetComponent<MeshRenderer>().sharedMaterial = _decalMaterial;
|
||||||
|
quad.name = "AstroBodySymbolRenderer";
|
||||||
|
GameObject.DestroyImmediate(AstroBodySymbolRenderer);
|
||||||
|
|
||||||
|
_whiteboardPrefab = SearchUtilities.Find("OrbitalProbeCannon_Body/Sector_OrbitalProbeCannon/Sector_Module_Broken/Interactables_Module_Broken/Prefab_NOM_Whiteboard_Shared").InstantiateInactive();
|
||||||
|
_whiteboardPrefab.name = "Prefab_NOM_Whiteboard_Shared";
|
||||||
|
var whiteboard = _whiteboardPrefab.GetComponent<NomaiSharedWhiteboard>();
|
||||||
|
whiteboard.enabled = true;
|
||||||
|
whiteboard._id = NomaiRemoteCameraPlatform.ID.None;
|
||||||
|
_whiteboardPrefab.FindChild("ArcSocket").transform.DestroyAllChildrenImmediate();
|
||||||
|
whiteboard._remoteIDs = new NomaiRemoteCameraPlatform.ID[0];
|
||||||
|
whiteboard._nomaiTexts = new NomaiWallText[0];
|
||||||
|
var AstroBodySymbolRendererW = _whiteboardPrefab.FindChild("PedestalAnchor/Prefab_NOM_SharedPedestal/SharedPedestal_side01_bottom_jnt/SharedPedestal_side01_top_jnt/AstroBodySymbolRenderer");
|
||||||
|
var quadW = GameObject.CreatePrimitive(PrimitiveType.Quad);
|
||||||
|
quadW.transform.parent = AstroBodySymbolRendererW.transform.parent;
|
||||||
|
quadW.transform.localPosition = AstroBodySymbolRendererW.transform.localPosition;
|
||||||
|
quadW.transform.localRotation = AstroBodySymbolRendererW.transform.localRotation;
|
||||||
|
quadW.transform.localScale = AstroBodySymbolRendererW.transform.localScale;
|
||||||
|
quadW.AddComponent<OWRenderer>();
|
||||||
|
quadW.GetComponent<MeshRenderer>().sharedMaterial = _decalMaterial;
|
||||||
|
quadW.name = "AstroBodySymbolRenderer";
|
||||||
|
GameObject.DestroyImmediate(AstroBodySymbolRendererW);
|
||||||
|
|
||||||
|
GameObject stone = new GameObject("ShareStoneFallback");
|
||||||
|
stone.SetActive(false);
|
||||||
|
SphereCollider sc = stone.AddComponent<SphereCollider>();
|
||||||
|
sc.center = Vector3.zero;
|
||||||
|
sc.radius = 0.4f;
|
||||||
|
sc.isTrigger = false;
|
||||||
|
OWCollider owc = stone.AddComponent<OWCollider>();
|
||||||
|
owc._collider = sc;
|
||||||
|
SharedStone item = stone.AddComponent<SharedStone>();
|
||||||
|
item._connectedPlatform = NomaiRemoteCameraPlatform.ID.None;
|
||||||
|
item._animDuration = 0.4f;
|
||||||
|
item._animOffsetY = 0.08f;
|
||||||
|
GameObject animRoot = new GameObject("AnimRoot");
|
||||||
|
animRoot.transform.parent = stone.transform;
|
||||||
|
TransformAnimator transformAnimator = animRoot.AddComponent<TransformAnimator>();
|
||||||
|
item._animator = transformAnimator;
|
||||||
|
OWRenderer renderer = SearchUtilities.FindResourceOfTypeAndName<OWRenderer>("Props_NOM_SharedStone");
|
||||||
|
if (renderer != null) GameObject.Instantiate(renderer.gameObject, animRoot.transform);
|
||||||
|
GameObject planetDecal = GameObject.CreatePrimitive(PrimitiveType.Quad);
|
||||||
|
planetDecal.name = "PlanetDecal";
|
||||||
|
planetDecal.transform.parent = animRoot.transform;
|
||||||
|
planetDecal.transform.localPosition = new Vector3(0, 0.053f, 0);
|
||||||
|
planetDecal.transform.localEulerAngles = new Vector3(90, 0, 0);
|
||||||
|
planetDecal.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f);
|
||||||
|
planetDecal.AddComponent<OWRenderer>();
|
||||||
|
planetDecal.GetComponent<MeshRenderer>().sharedMaterial = _decalMaterialGold;
|
||||||
|
_shareStonePrefab = stone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Make(GameObject go, Sector sector, PropModule.RemoteInfo info, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
if (_shareStonePrefab == null) InitPrefabs();
|
||||||
|
|
||||||
|
var id = RemoteHandler.GetPlatformID(info.id);
|
||||||
|
|
||||||
|
var decal = ImageUtilities.GetTexture(mod, info.decalPath, false, false);
|
||||||
|
|
||||||
|
if (info.platform != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RemoteBuilder.MakePlatform(go, sector, id, decal, info.platform, mod);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Couldn't make remote platform [{info.id}] for [{go.name}]:\n{ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.whiteboard != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RemoteBuilder.MakeWhiteboard(go, sector, id, decal, info.whiteboard, mod);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Couldn't make remote whiteboard [{info.id}] for [{go.name}]:\n{ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.stones != null)
|
||||||
|
{
|
||||||
|
foreach (var stoneInfo in info.stones)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RemoteBuilder.MakeStone(go, sector, id, decal, stoneInfo, mod);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Couldn't make remote stone [{info.id}] for [{go.name}]:\n{ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.WhiteboardInfo info, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
var detailInfo = new PropModule.DetailInfo()
|
||||||
|
{
|
||||||
|
position = info.position,
|
||||||
|
rotation = info.rotation
|
||||||
|
};
|
||||||
|
var whiteboard = DetailBuilder.MakeDetail(go, sector, _whiteboardPrefab, detailInfo);
|
||||||
|
whiteboard.SetActive(false);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(info.rename))
|
||||||
|
{
|
||||||
|
whiteboard.name = info.rename;
|
||||||
|
}
|
||||||
|
|
||||||
|
whiteboard.transform.parent = sector?.transform ?? go.transform;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(info.parentPath))
|
||||||
|
{
|
||||||
|
var newParent = go.transform.Find(info.parentPath);
|
||||||
|
if (newParent != null)
|
||||||
|
{
|
||||||
|
whiteboard.transform.parent = newParent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Cannot find parent object at path: {go.name}/{info.parentPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var decalMat = new Material(_decalMaterial);
|
||||||
|
decalMat.SetTexture("_MainTex", decal);
|
||||||
|
decalMat.SetTexture("_EmissionMap", decal);
|
||||||
|
whiteboard.FindChild("PedestalAnchor/Prefab_NOM_SharedPedestal/SharedPedestal_side01_bottom_jnt/SharedPedestal_side01_top_jnt/AstroBodySymbolRenderer").GetComponent<OWRenderer>().sharedMaterial = decalMat;
|
||||||
|
|
||||||
|
var component = whiteboard.GetComponent<NomaiSharedWhiteboard>();
|
||||||
|
component._id = id;
|
||||||
|
|
||||||
|
component._remoteIDs = new NomaiRemoteCameraPlatform.ID[info.nomaiText.Length];
|
||||||
|
component._nomaiTexts = new NomaiWallText[info.nomaiText.Length];
|
||||||
|
for (int i = 0; i < info.nomaiText.Length; i++)
|
||||||
|
{
|
||||||
|
var textInfo = info.nomaiText[i];
|
||||||
|
component._remoteIDs[i] = RemoteHandler.GetPlatformID(textInfo.id);
|
||||||
|
var wallText = NomaiTextBuilder.Make(whiteboard, sector, new PropModule.NomaiTextInfo
|
||||||
|
{
|
||||||
|
arcInfo = textInfo.arcInfo,
|
||||||
|
location = textInfo.location,
|
||||||
|
parentPath = "ArcSocket",
|
||||||
|
position = new MVector3(0, 1, 0),
|
||||||
|
rename = textInfo.rename,
|
||||||
|
rotation = Vector3.zero,
|
||||||
|
seed = textInfo.seed,
|
||||||
|
type = PropModule.NomaiTextInfo.NomaiTextType.Wall,
|
||||||
|
xmlFile = textInfo.xmlFile
|
||||||
|
}, mod).GetComponent<NomaiWallText>();
|
||||||
|
wallText._showTextOnStart = false;
|
||||||
|
component._nomaiTexts[i] = wallText;
|
||||||
|
}
|
||||||
|
|
||||||
|
whiteboard.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.PlatformInfo info, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
var detailInfo = new PropModule.DetailInfo()
|
||||||
|
{
|
||||||
|
position = info.position,
|
||||||
|
rotation = info.rotation
|
||||||
|
};
|
||||||
|
var platform = DetailBuilder.MakeDetail(go, sector, _remoteCameraPlatformPrefab, detailInfo);
|
||||||
|
platform.SetActive(false);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(info.rename))
|
||||||
|
{
|
||||||
|
platform.name = info.rename;
|
||||||
|
}
|
||||||
|
|
||||||
|
platform.transform.parent = sector?.transform ?? go.transform;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(info.parentPath))
|
||||||
|
{
|
||||||
|
var newParent = go.transform.Find(info.parentPath);
|
||||||
|
if (newParent != null)
|
||||||
|
{
|
||||||
|
platform.transform.parent = newParent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Cannot find parent object at path: {go.name}/{info.parentPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var decalMat = new Material(_decalMaterial);
|
||||||
|
decalMat.SetTexture("_MainTex", decal);
|
||||||
|
decalMat.SetTexture("_EmissionMap", decal);
|
||||||
|
platform.FindChild("PedestalAnchor/Prefab_NOM_SharedPedestal/SharedPedestal_side01_bottom_jnt/SharedPedestal_side01_top_jnt/AstroBodySymbolRenderer").GetComponent<OWRenderer>().sharedMaterial = decalMat;
|
||||||
|
|
||||||
|
var component = platform.GetComponent<NomaiRemoteCameraPlatform>();
|
||||||
|
component._id = id;
|
||||||
|
component._visualSector = sector;
|
||||||
|
component._dataPointID = info.reveals;
|
||||||
|
|
||||||
|
platform.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.StoneInfo info, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
var shareStone = _shareStonePrefab.InstantiateInactive();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(info.rename))
|
||||||
|
{
|
||||||
|
shareStone.name = info.rename;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shareStone.name = "ShareStone_" + id.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
shareStone.transform.parent = sector?.transform ?? go.transform;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(info.parentPath))
|
||||||
|
{
|
||||||
|
var newParent = go.transform.Find(info.parentPath);
|
||||||
|
if (newParent != null)
|
||||||
|
{
|
||||||
|
shareStone.transform.parent = newParent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Cannot find parent object at path: {go.name}/{info.parentPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shareStone.transform.position = go.transform.TransformPoint((Vector3)(info.position ?? Vector3.zero));
|
||||||
|
shareStone.transform.rotation = go.transform.TransformRotation(Quaternion.Euler((Vector3)(info.rotation ?? Vector3.zero)));
|
||||||
|
|
||||||
|
shareStone.GetComponent<SharedStone>()._connectedPlatform = id;
|
||||||
|
|
||||||
|
var decalMat = new Material(_decalMaterialGold);
|
||||||
|
decalMat.SetTexture("_MainTex", decal);
|
||||||
|
decalMat.SetTexture("_EmissionMap", decal);
|
||||||
|
shareStone.FindChild("AnimRoot/PlanetDecal").GetComponent<OWRenderer>().sharedMaterial = decalMat;
|
||||||
|
|
||||||
|
shareStone.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
151
NewHorizons/External/Modules/PropModule.cs
vendored
151
NewHorizons/External/Modules/PropModule.cs
vendored
@ -93,6 +93,11 @@ namespace NewHorizons.External.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public SignalModule.SignalInfo[] signals;
|
public SignalModule.SignalInfo[] signals;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add projection pools/platforms, whiteboards, and stones to this planet
|
||||||
|
/// </summary>
|
||||||
|
public RemoteInfo[] remotes;
|
||||||
|
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class ScatterInfo
|
public class ScatterInfo
|
||||||
{
|
{
|
||||||
@ -547,7 +552,6 @@ namespace NewHorizons.External.Modules
|
|||||||
/// An optional rename of this object
|
/// An optional rename of this object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string rename;
|
public string rename;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
@ -805,6 +809,151 @@ namespace NewHorizons.External.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue("environment")] public AudioMixerTrackName track = AudioMixerTrackName.Environment;
|
[DefaultValue("environment")] public AudioMixerTrackName track = AudioMixerTrackName.Environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonObject]
|
||||||
|
public class RemoteInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The unique remote id
|
||||||
|
/// </summary>
|
||||||
|
public string id;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Icon that the will show on the stone, pedastal of the whiteboard, and pedastal of the platform.
|
||||||
|
/// </summary>
|
||||||
|
public string decalPath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// whiteboard that the stones can put text onto
|
||||||
|
/// </summary>
|
||||||
|
public WhiteboardInfo whiteboard;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// camera platform that the stones can project to
|
||||||
|
/// </summary>
|
||||||
|
public PlatformInfo platform;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// projection stones
|
||||||
|
/// </summary>
|
||||||
|
public StoneInfo[] stones;
|
||||||
|
|
||||||
|
[JsonObject]
|
||||||
|
public class WhiteboardInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The text for each stone
|
||||||
|
/// </summary>
|
||||||
|
public SharedNomaiTextInfo[] nomaiText;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The location of this platform.
|
||||||
|
/// </summary>
|
||||||
|
public MVector3 position;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The rotation of this platform.
|
||||||
|
/// </summary>
|
||||||
|
public MVector3 rotation;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The relative path from the planet to the parent of this object. Optional (will default to the root sector).
|
||||||
|
/// </summary>
|
||||||
|
public string parentPath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An optional rename of this object
|
||||||
|
/// </summary>
|
||||||
|
public string rename;
|
||||||
|
|
||||||
|
[JsonObject]
|
||||||
|
public class SharedNomaiTextInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The id of the stone this text will appear for
|
||||||
|
/// </summary>
|
||||||
|
public string id;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Additional information about each arc in the text
|
||||||
|
/// </summary>
|
||||||
|
public NomaiTextArcInfo[] arcInfo;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The random seed used to pick what the text arcs will look like.
|
||||||
|
/// </summary>
|
||||||
|
public int seed; // For randomizing arcs
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The location of this object.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue("unspecified")] public NomaiTextInfo.NomaiTextLocation location = NomaiTextInfo.NomaiTextLocation.UNSPECIFIED;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The relative path to the xml file for this object.
|
||||||
|
/// </summary>
|
||||||
|
public string xmlFile;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An optional rename of this object
|
||||||
|
/// </summary>
|
||||||
|
public string rename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonObject]
|
||||||
|
public class PlatformInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The location of this platform.
|
||||||
|
/// </summary>
|
||||||
|
public MVector3 position;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The rotation of this platform.
|
||||||
|
/// </summary>
|
||||||
|
public MVector3 rotation;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The relative path from the planet to the parent of this object. Optional (will default to the root sector).
|
||||||
|
/// </summary>
|
||||||
|
public string parentPath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An optional rename of this object
|
||||||
|
/// </summary>
|
||||||
|
public string rename;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A ship log fact to reveal when the platform is connected to.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue("")] public string reveals = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonObject]
|
||||||
|
public class StoneInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The location of this stone.
|
||||||
|
/// </summary>
|
||||||
|
public MVector3 position;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The rotation of this stone.
|
||||||
|
/// </summary>
|
||||||
|
public MVector3 rotation;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The relative path from the planet to the parent of this object. Optional (will default to the root sector).
|
||||||
|
/// </summary>
|
||||||
|
public string parentPath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An optional rename of this object
|
||||||
|
/// </summary>
|
||||||
|
public string rename;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
|||||||
62
NewHorizons/Handlers/RemoteHandler.cs
Normal file
62
NewHorizons/Handlers/RemoteHandler.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using NewHorizons.Utility;
|
||||||
|
using OWML.Common;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
|
namespace NewHorizons.Handlers
|
||||||
|
{
|
||||||
|
public static class RemoteHandler
|
||||||
|
{
|
||||||
|
private static Dictionary<string, NomaiRemoteCameraPlatform.ID> _customPlatformIDs;
|
||||||
|
private static readonly int _startingInt = 19;
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
_customPlatformIDs = new Dictionary<string, NomaiRemoteCameraPlatform.ID>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetPlatformIDName(NomaiRemoteCameraPlatform.ID id)
|
||||||
|
{
|
||||||
|
foreach (var pair in _customPlatformIDs)
|
||||||
|
{
|
||||||
|
if (pair.Value == id) return TranslationHandler.GetTranslation(pair.Key, TranslationHandler.TextType.UI);
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NomaiRemoteCameraPlatform.ID GetPlatformID(string id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NomaiRemoteCameraPlatform.ID platformID;
|
||||||
|
if (_customPlatformIDs.TryGetValue(id, out platformID) || Enum.TryParse(id, true, out platformID))
|
||||||
|
{
|
||||||
|
return platformID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return AddCustomPlatformID(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Couldn't load platform id:\n{e}");
|
||||||
|
return NomaiRemoteCameraPlatform.ID.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NomaiRemoteCameraPlatform.ID AddCustomPlatformID(string id)
|
||||||
|
{
|
||||||
|
var platformID = (NomaiRemoteCameraPlatform.ID)_startingInt + _customPlatformIDs.Count();
|
||||||
|
|
||||||
|
Logger.LogVerbose($"Registering custom platform id {id} as {platformID}");
|
||||||
|
|
||||||
|
_customPlatformIDs.Add(id, platformID);
|
||||||
|
|
||||||
|
return platformID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -296,6 +296,7 @@ namespace NewHorizons
|
|||||||
AstroObjectLocator.Init();
|
AstroObjectLocator.Init();
|
||||||
StreamingHandler.Init();
|
StreamingHandler.Init();
|
||||||
AudioTypeHandler.Init();
|
AudioTypeHandler.Init();
|
||||||
|
RemoteHandler.Init();
|
||||||
AtmosphereBuilder.Init();
|
AtmosphereBuilder.Init();
|
||||||
BrambleNodeBuilder.Init(BodyDict[CurrentStarSystem].Select(x => x.Config).Where(x => x.Bramble?.dimension != null).ToArray());
|
BrambleNodeBuilder.Init(BodyDict[CurrentStarSystem].Select(x => x.Config).Where(x => x.Bramble?.dimension != null).ToArray());
|
||||||
|
|
||||||
@ -330,6 +331,9 @@ namespace NewHorizons
|
|||||||
// Fix the map satellite
|
// Fix the map satellite
|
||||||
SearchUtilities.Find("HearthianMapSatellite_Body", false).AddComponent<MapSatelliteOrbitFix>();
|
SearchUtilities.Find("HearthianMapSatellite_Body", false).AddComponent<MapSatelliteOrbitFix>();
|
||||||
|
|
||||||
|
|
||||||
|
// Sector changes (so that projection pools actually turn off proxies and cull groups on these moons)
|
||||||
|
|
||||||
//Fix attlerock vanilla sector components (they were set to timber hearth's sector)
|
//Fix attlerock vanilla sector components (they were set to timber hearth's sector)
|
||||||
var thm = SearchUtilities.Find("Moon_Body/Sector_THM").GetComponent<Sector>();
|
var thm = SearchUtilities.Find("Moon_Body/Sector_THM").GetComponent<Sector>();
|
||||||
foreach (var component in thm.GetComponentsInChildren<Component>(true))
|
foreach (var component in thm.GetComponentsInChildren<Component>(true))
|
||||||
|
|||||||
66
NewHorizons/Patches/RemotePatches.cs
Normal file
66
NewHorizons/Patches/RemotePatches.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using NewHorizons.Components;
|
||||||
|
using NewHorizons.Handlers;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NewHorizons.Patches
|
||||||
|
{
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class RemotePatches
|
||||||
|
{
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(NomaiRemoteCameraPlatform), nameof(NomaiRemoteCameraPlatform.IDToPlanetString))]
|
||||||
|
public static bool NomaiRemoteCameraPlatform_IDToPlanetString(NomaiRemoteCameraPlatform.ID id, out string __result)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case NomaiRemoteCameraPlatform.ID.None:
|
||||||
|
__result = "None";
|
||||||
|
break;
|
||||||
|
case NomaiRemoteCameraPlatform.ID.SunStation:
|
||||||
|
__result = UITextLibrary.GetString(UITextType.LocationSS);
|
||||||
|
break;
|
||||||
|
case NomaiRemoteCameraPlatform.ID.HGT_TimeLoop:
|
||||||
|
__result = UITextLibrary.GetString(UITextType.LocationTT);
|
||||||
|
break;
|
||||||
|
case NomaiRemoteCameraPlatform.ID.TH_Mine:
|
||||||
|
__result = UITextLibrary.GetString(UITextType.LocationTH);
|
||||||
|
break;
|
||||||
|
case NomaiRemoteCameraPlatform.ID.THM_EyeLocator:
|
||||||
|
__result = UITextLibrary.GetString(UITextType.LocationTHMoon);
|
||||||
|
break;
|
||||||
|
case NomaiRemoteCameraPlatform.ID.BH_Observatory:
|
||||||
|
case NomaiRemoteCameraPlatform.ID.BH_GravityCannon:
|
||||||
|
case NomaiRemoteCameraPlatform.ID.BH_QuantumFragment:
|
||||||
|
case NomaiRemoteCameraPlatform.ID.BH_BlackHoleForge:
|
||||||
|
case NomaiRemoteCameraPlatform.ID.BH_NorthPole:
|
||||||
|
__result = UITextLibrary.GetString(UITextType.LocationBH);
|
||||||
|
break;
|
||||||
|
case NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland1:
|
||||||
|
case NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland2:
|
||||||
|
case NomaiRemoteCameraPlatform.ID.GD_StatueIsland:
|
||||||
|
__result = UITextLibrary.GetString(UITextType.LocationGD);
|
||||||
|
break;
|
||||||
|
case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonSunkenModule:
|
||||||
|
__result = UITextLibrary.GetString(UITextType.LocationOPC_Module3);
|
||||||
|
break;
|
||||||
|
case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonDamagedModule:
|
||||||
|
__result = UITextLibrary.GetString(UITextType.LocationOPC_Module2);
|
||||||
|
break;
|
||||||
|
case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonIntactModule:
|
||||||
|
__result = UITextLibrary.GetString(UITextType.LocationOPC_Module1);
|
||||||
|
break;
|
||||||
|
case NomaiRemoteCameraPlatform.ID.VM_Interior:
|
||||||
|
__result = UITextLibrary.GetString(UITextType.LocationBHMoon);
|
||||||
|
break;
|
||||||
|
case NomaiRemoteCameraPlatform.ID.HGT_TLE:
|
||||||
|
__result = UITextLibrary.GetString(UITextType.LocationCT);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
__result = RemoteHandler.GetPlatformIDName(id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user