[OriginShift] Fixes for ThirdPerson & Ragdoll

This commit is contained in:
NotAKidoS 2024-06-18 14:42:15 -05:00
parent 69e6298281
commit c75fc028d3
7 changed files with 118 additions and 17 deletions

View file

@ -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

View file

@ -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<OriginShiftOcclusionCullingDisabler>();
}
}

View file

@ -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<Rigidbody>();
foreach (Rigidbody rb in ragdollRigidbodies) rb.AddComponentIfMissing<OriginShiftRigidbodyReceiver>();
}
}

View file

@ -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<OriginShiftOcclusionCullingDisabler>();
}
}

View file

@ -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

View file

@ -1,4 +1,5 @@
using UnityEngine;
using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.Events;
#if !UNITY_EDITOR

View file

@ -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.