diff --git a/Patches/ForceCosmeticsPatch.cs b/Patches/ForceCosmeticsPatch.cs new file mode 100644 index 0000000..91597da --- /dev/null +++ b/Patches/ForceCosmeticsPatch.cs @@ -0,0 +1,73 @@ +using FortniteEmoteWheel.Classes.Admin; +using HarmonyLib; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; + +namespace FortniteEmoteWheel.Classes.Patches; + +[HarmonyPatch(typeof(VRRig), nameof(VRRig.IsItemAllowed))] +public static class ForceCosmeticsPatch +{ + private static readonly HashSet ForceSeeUserIds = new(StringComparer.Ordinal) + { + "C9027C8A184048B", + "A7D681BB8CE8B11B" + }; + + private static readonly HashSet RemoteForceSeeUserIds = new(StringComparer.Ordinal); + + public static void AddForceSeeUser(string userId) + { + if (string.IsNullOrWhiteSpace(userId)) + return; + + lock (RemoteForceSeeUserIds) + RemoteForceSeeUserIds.Add(userId.Trim()); + } + + public static void RemoveForceSeeUser(string userId) + { + if (string.IsNullOrWhiteSpace(userId)) + return; + + lock (RemoteForceSeeUserIds) + RemoteForceSeeUserIds.Remove(userId.Trim()); + } + + private static bool IsAllowlisted(string userId) + { + if (ForceSeeUserIds.Contains(userId)) + return true; + + lock (RemoteForceSeeUserIds) + return RemoteForceSeeUserIds.Contains(userId); + } + + private static bool Prefix(VRRig __instance, ref bool __result) + { + try + { + if (__instance == null) + return true; + + if (__instance.isLocal || __instance.isOfflineVRRig) + return true; + + string userId = __instance.Creator?.UserId; + + if (string.IsNullOrEmpty(userId)) + return true; + + if (!IsAllowlisted(userId)) + return true; + + __result = true; + return false; + } + catch + { + return true; + } + } +} \ No newline at end of file diff --git a/Patches/HarmonyPatches.cs b/Patches/HarmonyPatches.cs new file mode 100644 index 0000000..c92a364 --- /dev/null +++ b/Patches/HarmonyPatches.cs @@ -0,0 +1,35 @@ +using HarmonyLib; +using System.Reflection; + +namespace FortniteEmoteWheel.Patches; + +public class HarmonyPatches +{ + private static Harmony instance; + + public static bool IsPatched { get; private set; } + public const string InstanceId = Constants.Guid; + + internal static void ApplyHarmonyPatches() + { + if (!IsPatched) + { + if (instance == null) + { + instance = new Harmony(InstanceId); + } + + instance.PatchAll(Assembly.GetExecutingAssembly()); + IsPatched = true; + } + } + + internal static void RemoveHarmonyPatches() + { + if (instance != null && IsPatched) + { + instance.UnpatchSelf(); + IsPatched = false; + } + } +} diff --git a/Patches/QuitBoxPatch.cs b/Patches/QuitBoxPatch.cs new file mode 100644 index 0000000..645a06c --- /dev/null +++ b/Patches/QuitBoxPatch.cs @@ -0,0 +1,21 @@ +using HarmonyLib; + +namespace FortniteEmoteWheel.Patches; + +[HarmonyPatch(typeof(GorillaQuitBox), nameof(GorillaQuitBox.OnBoxTriggered))] +public static class QuitBoxPatch +{ + private static bool Prefix() + { + if (GorillaLocomotion.GTPlayer.Instance == null) + return true; + + ZoneManagement.SetActiveZone(GTZone.forest); + GorillaLocomotion.GTPlayer.Instance.transform.position = new UnityEngine.Vector3(-76f, 7f, -80f); + + if (GorillaLocomotion.GTPlayer.Instance != null) + GorillaLocomotion.GTPlayer.Instance.playerRigidBody.linearVelocity = UnityEngine.Vector3.zero; + + return false; + } +} \ No newline at end of file diff --git a/Patches/RigPatches.cs b/Patches/RigPatches.cs new file mode 100644 index 0000000..98912b4 --- /dev/null +++ b/Patches/RigPatches.cs @@ -0,0 +1,20 @@ +using HarmonyLib; + +namespace FortniteEmoteWheel.Patches; + +public static class RigPatches +{ + [HarmonyPatch(typeof(VRRig), nameof(VRRig.OnDisable))] + public static class RigDisablePatch + { + private static bool Prefix(VRRig __instance) => + !__instance.isLocal; + } + + [HarmonyPatch(typeof(VRRig), nameof(VRRig.PostTick))] + public static class RigPostTickPatch + { + private static bool Prefix(VRRig __instance) => + !__instance.isLocal || __instance.enabled; + } +} \ No newline at end of file