diff --git a/NAK_CVR_Mods.sln b/NAK_CVR_Mods.sln index c05398b..927e66a 100644 --- a/NAK_CVR_Mods.sln +++ b/NAK_CVR_Mods.sln @@ -61,6 +61,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AASDefaultProfileFix", "AAS EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OriginShift", "OriginShift\OriginShift.csproj", "{F381F604-9C16-4870-AD49-4BD7CA3F36DC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScrollFlight", "ScrollFlight\ScrollFlight.csproj", "{1B5D7DCB-01A4-4988-8B25-211948AEED76}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -183,6 +185,10 @@ Global {F381F604-9C16-4870-AD49-4BD7CA3F36DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {F381F604-9C16-4870-AD49-4BD7CA3F36DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {F381F604-9C16-4870-AD49-4BD7CA3F36DC}.Release|Any CPU.Build.0 = Release|Any CPU + {1B5D7DCB-01A4-4988-8B25-211948AEED76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1B5D7DCB-01A4-4988-8B25-211948AEED76}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1B5D7DCB-01A4-4988-8B25-211948AEED76}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1B5D7DCB-01A4-4988-8B25-211948AEED76}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/OriginShift/CompatibilityFixes/ThirdPersonCompatibilityFix.cs b/OriginShift/CompatibilityFixes/ThirdPersonCompatibilityFix.cs new file mode 100644 index 0000000..ad902f7 --- /dev/null +++ b/OriginShift/CompatibilityFixes/ThirdPersonCompatibilityFix.cs @@ -0,0 +1,17 @@ +using ABI_RC.Core.Base; +using NAK.OriginShift; +using NAK.OriginShift.Hacks; +using UnityEngine; + +namespace OriginShift.ModCompatibility; + +public static class ThirdPersonCompatibility +{ + internal static void Fix() + { + GameObject thirdPersonCameraObj = GameObject.Find("_PLAYERLOCAL/[CameraRigDesktop]/Camera/ThirdPersonCameraObj"); + if (thirdPersonCameraObj == null) return; + OriginShiftMod.Logger.Msg("Found ThirdPerson, fixing compatibility..."); + thirdPersonCameraObj.AddComponentIfMissing(); + } +} \ No newline at end of file diff --git a/OriginShift/Integrations/Ragdoll/RagdollAddon.cs b/OriginShift/Integrations/Ragdoll/RagdollAddon.cs new file mode 100644 index 0000000..4ec0726 --- /dev/null +++ b/OriginShift/Integrations/Ragdoll/RagdollAddon.cs @@ -0,0 +1,37 @@ +using System.Collections; +using ABI_RC.Core.Base; +using ABI_RC.Core.Player; +using HarmonyLib; +using MelonLoader; +using NAK.OriginShift; +using NAK.OriginShift.Components; +using UnityEngine; + +namespace OriginShift.Integrations; + +public static class RagdollAddon +{ + public static void Initialize() + { + OriginShiftMod.HarmonyInst.Patch( + AccessTools.Method(typeof(PlayerSetup), nameof(PlayerSetup.SetupAvatar)), + postfix: new HarmonyMethod(typeof(RagdollAddon), nameof(OnPostPlayerSetupSetupAvatar)) + ); + } + + private static void OnPostPlayerSetupSetupAvatar() + { + OriginShiftMod.Logger.Msg("Found Ragdoll, fixing compatibility..."); + MelonCoroutines.Start(FixRagdollCompatibility()); + } + + private static IEnumerator FixRagdollCompatibility() + { + yield return null; // wait a frame for the avatar to be setup + GameObject ragdollObj = GameObject.Find("_PLAYERLOCAL/[PlayerAvatarPuppet]"); + + // get all rigidbodies in the ragdoll + var ragdollRigidbodies = ragdollObj.GetComponentsInChildren(); + foreach (Rigidbody rb in ragdollRigidbodies) rb.AddComponentIfMissing(); + } +} \ No newline at end of file diff --git a/OriginShift/Integrations/ThirdPerson/ThirdPersonAddon.cs b/OriginShift/Integrations/ThirdPerson/ThirdPersonAddon.cs new file mode 100644 index 0000000..baf92ee --- /dev/null +++ b/OriginShift/Integrations/ThirdPerson/ThirdPersonAddon.cs @@ -0,0 +1,36 @@ +using System.Collections; +using ABI_RC.Core.Base; +using ABI_RC.Core.Player; +using MelonLoader; +using NAK.OriginShift; +using NAK.OriginShift.Hacks; +using UnityEngine; +using AccessTools = HarmonyLib.AccessTools; +using HarmonyMethod = HarmonyLib.HarmonyMethod; + +namespace OriginShift.Integrations; + +public static class ThirdPersonAddon +{ + public static void Initialize() + { + OriginShiftMod.HarmonyInst.Patch( + AccessTools.Method(typeof(PlayerSetup), nameof(PlayerSetup.Start)), + postfix: new HarmonyMethod(typeof(ThirdPersonAddon), nameof(OnPostPlayerSetupStart)) + ); + } + + private static void OnPostPlayerSetupStart() + { + OriginShiftMod.Logger.Msg("Found ThirdPerson, fixing compatibility..."); + MelonCoroutines.Start(FixThirdPersonCompatibility()); + } + + private static IEnumerator FixThirdPersonCompatibility() + { + yield return null; // wait a frame for the camera to be setup + GameObject thirdPersonCameraObj = GameObject.Find("_PLAYERLOCAL/[CameraRigDesktop]/Camera/ThirdPersonCameraObj"); + thirdPersonCameraObj.AddComponentIfMissing(); + } +} + diff --git a/OriginShift/Main.cs b/OriginShift/Main.cs index 0724c39..4222cc4 100644 --- a/OriginShift/Main.cs +++ b/OriginShift/Main.cs @@ -6,6 +6,7 @@ using ABI_RC.Systems.Movement; using MelonLoader; using NAK.OriginShift.Components; using NAK.OriginShiftMod.Integrations; +using OriginShift.Integrations; using UnityEngine; namespace NAK.OriginShift; @@ -19,12 +20,14 @@ namespace NAK.OriginShift; public class OriginShiftMod : MelonMod { internal static MelonLogger.Instance Logger; + internal static HarmonyLib.Harmony HarmonyInst; #region Melon Mod Overrides public override void OnInitializeMelon() { Logger = LoggerInstance; + HarmonyInst = HarmonyInstance; ModSettings.Initialize(); @@ -54,22 +57,8 @@ public class OriginShiftMod : MelonMod WorldFilter._Base.Add(typeof(OriginShiftTransformReceiver)); // transform InitializeIntegration("BTKUILib", BtkUiAddon.Initialize); - } - - public override void OnUpdate() - { - if (BetterBetterCharacterController.Instance == null - || !BetterBetterCharacterController.Instance.IsFlying() - || Input.GetKey(KeyCode.Mouse2) - || Cursor.lockState != CursorLockMode.Locked) - return; - - BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier = Math.Max(0f, - BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier + Input.mouseScrollDelta.y); - if (Input.mouseScrollDelta.y != 0f) - CohtmlHud.Instance.ViewDropTextImmediate("(Local) ScrollFlight", - BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier.ToString(CultureInfo - .InvariantCulture), "Speed multiplier"); + InitializeIntegration("ThirdPerson", ThirdPersonAddon.Initialize); + InitializeIntegration("PlayerRagdollMod", RagdollAddon.Initialize); } #endregion Melon Mod Overrides diff --git a/OriginShift/OriginShift/Components/Receivers/OriginShiftEventReceiver.cs b/OriginShift/OriginShift/Components/Receivers/OriginShiftEventReceiver.cs index ee7b81b..fd329bf 100644 --- a/OriginShift/OriginShift/Components/Receivers/OriginShiftEventReceiver.cs +++ b/OriginShift/OriginShift/Components/Receivers/OriginShiftEventReceiver.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using JetBrains.Annotations; +using UnityEngine; using UnityEngine.Events; #if !UNITY_EDITOR diff --git a/OriginShift/README.md b/OriginShift/README.md index 395a707..6fee919 100644 --- a/OriginShift/README.md +++ b/OriginShift/README.md @@ -2,6 +2,21 @@ Experimental mod that allows world origin to be shifted to prevent floating point precision issues. +## Compromises +- Steam Audio data cannot be shifted. +- NavMesh data cannot be shifted. +- Light Probe data cannot be shifted (until [unity 2022](https://docs.unity3d.com/2022.3/Documentation/Manual/LightProbes-Moving.html)). +- Occlusion Culling data cannot be shifted. + - When using "Forced" mode, occlusion culling is disabled. + +## Known Issues +- Player position on a Movement Parent may slightly drift when passing a chunk boundary if being moved by a Force Applicator. +- Mod Network is not yet implemented, so Compatibility Mode is required to play with others. +- Portable Camera drone mode is not yet offset by the world origin shift. + +## Mod Incompatibilities +- PlayerRagdollMod will freak out when you ragdoll between chunk boundaries. + --- Here is the block of text where I tell you this mod is not affiliated with or endorsed by ABI.