mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
[RelativeSync] Fixed buncha stuff, cleanup
This commit is contained in:
parent
b97265ef37
commit
b786ecd51c
11 changed files with 429 additions and 231 deletions
|
@ -2,10 +2,12 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Core.Networking.Jobs;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Systems.Movement;
|
||||
using ABI.CCK.Components;
|
||||
using HarmonyLib;
|
||||
using NAK.RelativeSync.Components;
|
||||
using NAK.RelativeSync.Networking;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.RelativeSync.Patches;
|
||||
|
||||
|
@ -58,4 +60,52 @@ internal static class NetworkRootDataUpdatePatches
|
|||
{
|
||||
ModNetwork.SendRelativeSyncUpdate(); // Send the relative sync update after the network root data update
|
||||
}
|
||||
}
|
||||
|
||||
internal static class CVRSpawnablePatches
|
||||
{
|
||||
internal static bool UseHack;
|
||||
|
||||
private static bool _canUpdate;
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(CVRSpawnable), nameof(CVRSpawnable.Update))]
|
||||
private static bool Prefix_CVRSpawnable_Update()
|
||||
=> !UseHack || _canUpdate;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRSpawnable), nameof(CVRSpawnable.FixedUpdate))]
|
||||
private static void Postfix_CVRSpawnable_FixedUpdate(ref CVRSpawnable __instance)
|
||||
{
|
||||
if (!UseHack) return;
|
||||
|
||||
_canUpdate = true;
|
||||
__instance.Update();
|
||||
_canUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal static class BetterBetterCharacterControllerPatches
|
||||
{
|
||||
private static bool _noInterpolation;
|
||||
internal static bool NoInterpolation
|
||||
{
|
||||
get => _noInterpolation;
|
||||
set
|
||||
{
|
||||
_noInterpolation = value;
|
||||
if (_rigidbody == null) return;
|
||||
_rigidbody.interpolation = value ? RigidbodyInterpolation.None : RigidbodyInterpolation.Interpolate;
|
||||
}
|
||||
}
|
||||
|
||||
private static Rigidbody _rigidbody;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(BetterBetterCharacterController), nameof(BetterBetterCharacterController.Start))]
|
||||
private static void Postfix_BetterBetterCharacterController_Update(ref BetterBetterCharacterController __instance)
|
||||
{
|
||||
_rigidbody = __instance.GetComponent<Rigidbody>();
|
||||
NoInterpolation = _noInterpolation; // get initial value as patch runs later than settings init
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue