diff --git a/NewHorizons/OtherMods/CommonCameraUtility/CommonCameraHandler.cs b/NewHorizons/OtherMods/CommonCameraUtility/CommonCameraHandler.cs new file mode 100644 index 00000000..e344a57f --- /dev/null +++ b/NewHorizons/OtherMods/CommonCameraUtility/CommonCameraHandler.cs @@ -0,0 +1,27 @@ +using NewHorizons.OtherMods.MenuFramework; +using Logger = NewHorizons.Utility.Logger; + +namespace NewHorizons.OtherMods.CommonCameraUtility +{ + public static class CommonCameraHandler + { + private static ICommonCameraAPI _cameraAPI; + + static CommonCameraHandler() + { + _cameraAPI = Main.Instance.ModHelper.Interaction.TryGetModApi("xen.CommonCameraUtility"); + } + + public static void RegisterCustomCamera(OWCamera camera) + { + if (_cameraAPI != null) + { + _cameraAPI.RegisterCustomCamera(camera); + } + else + { + Logger.LogError("Tried to register custom camera but Common Camera Utility was missing."); + } + } + } +} diff --git a/NewHorizons/OtherMods/CommonCameraUtility/ICommonCameraAPI.cs b/NewHorizons/OtherMods/CommonCameraUtility/ICommonCameraAPI.cs new file mode 100644 index 00000000..bd49375b --- /dev/null +++ b/NewHorizons/OtherMods/CommonCameraUtility/ICommonCameraAPI.cs @@ -0,0 +1,13 @@ +using UnityEngine; +using UnityEngine.Events; + +namespace NewHorizons.OtherMods.CommonCameraUtility +{ + public interface ICommonCameraAPI + { + void RegisterCustomCamera(OWCamera OWCamera); + (OWCamera, Camera) CreateCustomCamera(string name); + UnityEvent EquipTool(); + UnityEvent UnequipTool(); + } +} diff --git a/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs new file mode 100644 index 00000000..29719c0e --- /dev/null +++ b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs @@ -0,0 +1,24 @@ +using HarmonyLib; +using NewHorizons.OtherMods.CommonCameraUtility; +using UnityEngine; + +namespace NewHorizons.Patches.CameraPatches +{ + [HarmonyPatch] + public static class NomaiRemoteCameraPatches + { + [HarmonyPostfix] + [HarmonyPatch(typeof(NomaiRemoteCamera), nameof(NomaiRemoteCamera.Awake))] + public static void NomaiRemoteCamera_Awake(NomaiRemoteCamera __instance) + { + // Ensures that if the player is visible from the remote camera they look normal + CommonCameraHandler.RegisterCustomCamera(__instance._camera); + + // These layers were left on because it doesnt come up in base game (Dreamworld is inactive, player is far away) + __instance._camera.mainCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("DreamSimulation")); + __instance._camera.mainCamera.cullingMask &= ~(1 <