mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
[OriginShift] Initial Fuckup
This commit is contained in:
parent
14ab184db7
commit
2375678a59
33 changed files with 2107 additions and 29 deletions
103
OriginShift/Main.cs
Normal file
103
OriginShift/Main.cs
Normal file
|
@ -0,0 +1,103 @@
|
|||
#if !UNITY_EDITOR
|
||||
using System.Globalization;
|
||||
using ABI_RC.Core.UI;
|
||||
using ABI_RC.Core.Util.AssetFiltering;
|
||||
using ABI_RC.Systems.Movement;
|
||||
using MelonLoader;
|
||||
using NAK.OriginShift.Components;
|
||||
using NAK.OriginShiftMod.Integrations;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.OriginShift;
|
||||
|
||||
// Links I looked at:
|
||||
// Controller/Event Listener Setup: https://manuel-rauber.com/2022/04/06/floating-origin-in-unity/amp/
|
||||
// Move Scene Roots: https://gist.github.com/brihernandez/9ebbaf35070181fa1ee56f9e702cc7a5
|
||||
// Looked cool but didn't really find anything to use: https://docs.coherence.io/coherence-sdk-for-unity/world-origin-shifting
|
||||
// One Day when we move to 2022: https://docs.unity3d.com/6000.0/Documentation/Manual/LightProbes-Moving.html
|
||||
|
||||
public class OriginShiftMod : MelonMod
|
||||
{
|
||||
internal static MelonLogger.Instance Logger;
|
||||
|
||||
#region Melon Mod Overrides
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
Logger = LoggerInstance;
|
||||
|
||||
ModSettings.Initialize();
|
||||
|
||||
ApplyPatches(typeof(Patches.BetterBetterCharacterControllerPatches)); // origin shift monitor
|
||||
ApplyPatches(typeof(Patches.CVRSpawnablePatches)); // components & remote spawnable pos
|
||||
|
||||
// Compatibility Mode
|
||||
ApplyPatches(typeof(Patches.PlayerSetupPatches)); // net ik, camera occlusion culling
|
||||
ApplyPatches(typeof(Patches.Comms_ClientPatches)); // voice pos
|
||||
ApplyPatches(typeof(Patches.CVRSyncHelperPatches)); // spawnable pos
|
||||
ApplyPatches(typeof(Patches.PuppetMasterPatches)); // remote player pos
|
||||
ApplyPatches(typeof(Patches.CVRObjectSyncPatches)); // remote object pos
|
||||
|
||||
ApplyPatches(typeof(Patches.DbJobsAvatarManagerPatches)); // dynamic bones
|
||||
ApplyPatches(typeof(Patches.CVRPortalManagerPatches)); // portals
|
||||
|
||||
ApplyPatches(typeof(Patches.PortableCameraPatches)); // camera occlusion culling
|
||||
ApplyPatches(typeof(Patches.PathingCameraPatches)); // camera occlusion culling
|
||||
|
||||
// add our components to the world whitelist
|
||||
WorldFilter._Base.Add(typeof(OriginShiftController)); // base component
|
||||
WorldFilter._Base.Add(typeof(OriginShiftEventReceiver)); // generic event listener
|
||||
|
||||
WorldFilter._Base.Add(typeof(OriginShiftParticleSystemReceiver)); // particle system
|
||||
WorldFilter._Base.Add(typeof(OriginShiftRigidbodyReceiver)); // rigidbody
|
||||
WorldFilter._Base.Add(typeof(OriginShiftTrailRendererReceiver)); // trail renderer
|
||||
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");
|
||||
}
|
||||
|
||||
#endregion Melon Mod Overrides
|
||||
|
||||
#region Melon Mod Utilities
|
||||
|
||||
private static void InitializeIntegration(string modName, Action integrationAction)
|
||||
{
|
||||
if (RegisteredMelons.All(it => it.Info.Name != modName))
|
||||
return;
|
||||
|
||||
Logger.Msg($"Initializing {modName} integration.");
|
||||
integrationAction.Invoke();
|
||||
}
|
||||
|
||||
private void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
HarmonyInstance.PatchAll(type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerInstance.Msg($"Failed while patching {type.Name}!");
|
||||
LoggerInstance.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Melon Mod Utilities
|
||||
}
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue