Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FreeFly v1.0.0
Landoria.FreeFly.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Landoria.SharedLib; using Splatform; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Landoria.FreeFly")] [assembly: AssemblyDescription("Adds a client-side free-camera shortcut within a limited range.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Landoria")] [assembly: AssemblyProduct("Landoria.FreeFly")] [assembly: AssemblyCopyright("Copyright © 2026 End3rbyte")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("037059B7-0C09-4B60-A05B-62627829B3D8")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")] [assembly: AssemblyVersion("1.0.0.25986")] namespace Landoria.FreeFly { internal static class FreeFlyCommands { internal static void Register() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0030: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) new ConsoleCommand("ffsmooth", "[0-1] sets native free-camera smoothing.", new ConsoleEventFailable(SetSmoothness), false, false, false, false, false, false, new ConsoleOptionsFetcher(SmoothnessOptions), false, false, false); } private static object SetSmoothness(ConsoleEventArgs args) { if (args.Length != 2 || !float.TryParse(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || result < 0f || result > 1f) { return "Use ffsmooth followed by a value from 0 to 1."; } GameCamera.instance.SetFreeFlySmoothness(result); return true; } private static List<string> SmoothnessOptions() { return new List<string> { "0", "0.25", "0.5", "0.75", "1" }; } } internal static class FreeFlyController { internal const float DefaultSmoothness = 0.25f; internal const float MaximumDistance = 50f; internal const float MaximumSpeed = 10f; private const float MinimumSpeed = 2f; private const float DefaultSpeed = 4f; private const float SpeedTransitionSmoothTime = 0.35f; internal const float CollisionRadius = 1f; internal const float CollisionClearance = 0.05f; private const float InitialForwardDistance = 3f; private const float InitialHeight = 1f; private const float InitialSearchStep = 15f; private const int InitialSearchPositions = 24; private static bool smoothnessInitialized; private static float speedTransitionVelocity; internal static float ClampSpeed(float speed) { return Mathf.Clamp(speed, 2f, 10f); } internal static void SetDefaultSpeed(ref float speed) { speed = 4f; speedTransitionVelocity = 0f; } internal static void UpdateSpeed(ref float speed, float deltaTime) { float num = ((ZInput.GetKey((KeyCode)304, true) || ZInput.GetKey((KeyCode)303, true)) ? 10f : 4f); speed = Mathf.SmoothDamp(speed, num, ref speedTransitionVelocity, 0.35f, float.PositiveInfinity, deltaTime); } internal static void ClampFrameMovement(GameCamera camera, Vector3 origin, float deltaTime) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)camera).transform.position - origin; float num = 10f * deltaTime; if (((Vector3)(ref val)).sqrMagnitude > num * num) { ((Component)camera).transform.position = origin + ((Vector3)(ref val)).normalized * num; } } internal static void ClampToCollision(GameCamera camera, Vector3 origin) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)camera).transform.position - origin; float magnitude = ((Vector3)(ref val)).magnitude; RaycastHit val2 = default(RaycastHit); if (!(magnitude <= 0.001f) && Physics.SphereCast(origin, 1f, val / magnitude, ref val2, magnitude, LayerMask.op_Implicit(camera.m_blockCameraMask), (QueryTriggerInteraction)1)) { float num = Mathf.Max(0f, ((RaycastHit)(ref val2)).distance - 0.05f); ((Component)camera).transform.position = origin + ((Vector3)(ref val)).normalized * num; } } internal static void Toggle() { if (!((Object)(object)GameCamera.instance == (Object)null)) { if (GameCamera.InFreeFly()) { FreeFlyTransitionController.StartExiting(GameCamera.instance); } else { GameCamera.instance.ToggleFreeFly(); } } } internal static void InitializeActivation(GameCamera camera) { if (!smoothnessInitialized) { camera.SetFreeFlySmoothness(0.25f); smoothnessInitialized = true; } PositionInFrontOfPlayer(camera); } internal static void Reset() { smoothnessInitialized = false; speedTransitionVelocity = 0f; } internal static void SynchronizeRotation(Vector3 direction, ref float yaw, ref float pitch) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) yaw = Mathf.Atan2(direction.x, direction.z) * 57.29578f; pitch = (0f - Mathf.Asin(Mathf.Clamp(direction.y, -1f, 1f))) * 57.29578f; } private static void PositionInFrontOfPlayer(GameCamera camera) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer)) { Vector3 position = ((Character)localPlayer).m_eye.position; if (TryFindInitialPosition(camera, position, ((Component)localPlayer).transform.forward, out var position2)) { ((Component)camera).transform.position = position2; } Vector3 val = position - ((Component)camera).transform.position; if (((Vector3)(ref val)).sqrMagnitude > Mathf.Epsilon) { ((Component)camera).transform.rotation = Quaternion.LookRotation(val, Vector3.up); } } } private static bool TryFindInitialPosition(GameCamera camera, Vector3 origin, Vector3 forward, out Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) RaycastHit val4 = default(RaycastHit); for (int i = 0; i < 24; i++) { Vector3 val = Quaternion.AngleAxis((float)i * 15f, Vector3.up) * forward * 3f; Vector3 val2 = origin + val + Vector3.up * 1f; Vector3 val3 = val2 - origin; if (!Physics.SphereCast(origin, 1f, ((Vector3)(ref val3)).normalized, ref val4, ((Vector3)(ref val3)).magnitude, LayerMask.op_Implicit(camera.m_blockCameraMask), (QueryTriggerInteraction)1) && !Physics.CheckSphere(val2, 1f, LayerMask.op_Implicit(camera.m_blockCameraMask), (QueryTriggerInteraction)1)) { position = val2; return true; } } position = ((Component)camera).transform.position; return false; } internal static void Disable() { if (Object.op_Implicit((Object)(object)GameCamera.instance) && GameCamera.InFreeFly()) { FreeFlyTransitionController.StartExiting(GameCamera.instance); } } internal static void CompleteDisable() { if (Object.op_Implicit((Object)(object)GameCamera.instance) && GameCamera.InFreeFly()) { GameCamera.instance.ToggleFreeFly(); } } internal static void ClampToPlayer(GameCamera camera) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (GameCamera.InFreeFly() && !((Object)(object)localPlayer == (Object)null)) { Vector3 val = ((Component)camera).transform.position - ((Component)localPlayer).transform.position; if (((Vector3)(ref val)).sqrMagnitude > 2500f) { ((Component)camera).transform.position = ((Component)localPlayer).transform.position + ((Vector3)(ref val)).normalized * 50f; } } } } internal static class FreeFlyInterfaceController { private static bool wasFreeFlyActive; private static bool previousHiddenState; private static bool stateCaptured; internal static void Update() { bool num = GameCamera.InFreeFly(); if (num) { CaptureState(); if (Object.op_Implicit((Object)(object)Hud.instance)) { Hud.instance.m_userHidden = true; } } else if (wasFreeFlyActive) { Restore(); } wasFreeFlyActive = num; } private static void CaptureState() { if (!stateCaptured && Object.op_Implicit((Object)(object)Hud.instance)) { previousHiddenState = Hud.IsUserHidden(); stateCaptured = true; } } internal static void Restore() { if (stateCaptured && Object.op_Implicit((Object)(object)Hud.instance)) { Hud.instance.m_userHidden = previousHiddenState; } stateCaptured = false; wasFreeFlyActive = false; } } [HarmonyPatch(typeof(GameCamera), "ToggleFreeFly")] internal static class FreeFlyInitializationPatch { private static void Postfix(GameCamera __instance, ref float ___m_freeFlySpeed, ref float ___m_freeFlyYaw, ref float ___m_freeFlyPitch, ref Quaternion ___m_freeFlyRef, ref Vector3 ___m_freeFlySavedVel, ref Transform ___m_freeFlyTarget, ref Transform ___m_freeFlyLockon, ref Vector3 ___m_freeFlyVel) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (GameCamera.InFreeFly()) { Vector3 position = ((Component)__instance).transform.position; Quaternion rotation = ((Component)__instance).transform.rotation; FreeFlyController.SetDefaultSpeed(ref ___m_freeFlySpeed); FreeFlyController.InitializeActivation(__instance); FreeFlyController.SynchronizeRotation(((Component)__instance).transform.forward, ref ___m_freeFlyYaw, ref ___m_freeFlyPitch); ___m_freeFlyRef = Quaternion.identity; ___m_freeFlySavedVel = Vector3.zero; ___m_freeFlyTarget = null; ___m_freeFlyLockon = null; ___m_freeFlyVel = Vector3.zero; FreeFlyTransitionController.StartEntering(__instance, position, rotation); } } } [HarmonyPatch(typeof(Menu), "Update")] internal static class FreeFlyEscapeMenuPatch { private static void Postfix() { FreeFlyShortcut.CloseSuppressedMenu(); } } [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] internal static class FreeFlyMouseWheelPatch { private static bool Prefix(ref float __result) { if (!GameCamera.InFreeFly()) { return true; } __result = 0f; return false; } } [HarmonyPatch(typeof(GameCamera), "UpdateFreeFly")] internal static class FreeFlyMovementPatch { private static void Prefix(GameCamera __instance, float dt, ref float ___m_freeFlySpeed, out Vector3 __state) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) FreeFlyController.UpdateSpeed(ref ___m_freeFlySpeed, dt); __state = ((Component)__instance).transform.position; } private static void Postfix(GameCamera __instance, float dt, ref float ___m_freeFlySpeed, Vector3 __state) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) ___m_freeFlySpeed = FreeFlyController.ClampSpeed(___m_freeFlySpeed); FreeFlyController.ClampFrameMovement(__instance, __state, dt); FreeFlyController.ClampToCollision(__instance, __state); FreeFlyController.ClampToPlayer(__instance); FreeFlyTransitionController.ApplyEntering(__instance, dt); FreeFlyTransitionController.ApplyExiting(__instance, dt); } } [BepInPlugin("Landoria.FreeFly", "Landoria.FreeFly", "1.0.0")] public sealed class FreeFlyPlugin : LandoriaPlugin { internal const string PluginGuid = "Landoria.FreeFly"; internal const string PluginName = "Landoria.FreeFly"; internal const string PluginVersion = "1.0.0"; private static ModLog ModLogger { get; set; } private void Awake() { ModLogger = InitializePlugin("Landoria.FreeFly"); FreeFlyPreference.Initialize(((BaseUnityPlugin)this).Config); FreeFlyCommands.Register(); ModLogger.LogInfo("Landoria.FreeFly 1.0.0 is loaded."); } private void Update() { FreeFlyShortcut.Update(); FreeFlyInterfaceController.Update(); } private void OnDestroy() { FreeFlyController.CompleteDisable(); FreeFlyController.Reset(); FreeFlyInterfaceController.Restore(); ModLogger?.LogInfo("Landoria.FreeFly 1.0.0 is unloaded."); ShutdownPlugin(); ModLogger = null; } } internal static class FreeFlyPreference { private static ConfigEntry<KeyboardShortcut> toggleShortcut; internal static KeyboardShortcut ToggleShortcut => toggleShortcut.Value; internal static void Initialize(ConfigFile config) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) toggleShortcut = config.Bind<KeyboardShortcut>("Controls", "ToggleShortcut", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Shortcut used to enable or disable free fly.\n\nExamples: Mouse2 for the middle mouse button.\n\nMouse3/Mouse4 for the Forward/Back side button.\n\nSpace + LeftControl for Left Ctrl + Space.\n\nhttps://docs.unity3d.com/ScriptReference/KeyCode.html"); } } internal static class FreeFlyShortcut { private static bool suppressEscapeMenu; internal static void Update() { if (GameCamera.InFreeFly() && ZInput.GetKeyDown((KeyCode)27, true)) { FreeFlyController.Disable(); suppressEscapeMenu = true; if (Menu.IsActive()) { Menu.instance.Hide(); } } else if (CanToggle() && IsToggleShortcutDown()) { FreeFlyController.Toggle(); } } internal static void CloseSuppressedMenu() { if (suppressEscapeMenu) { if (Object.op_Implicit((Object)(object)Menu.instance)) { Menu.instance.Hide(); } suppressEscapeMenu = false; } } private static bool CanToggle() { Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer) && !((Character)localPlayer).IsDead() && !((Character)localPlayer).InCutscene() && Object.op_Implicit((Object)(object)GameCamera.instance) && !Console.IsVisible() && !Menu.IsVisible() && !InventoryGui.IsVisible() && !StoreGui.IsVisible() && !Minimap.IsOpen() && !Hud.IsPieceSelectionVisible() && !Hud.InRadial()) { if (!((Object)(object)Chat.instance == (Object)null)) { return !Chat.instance.HasFocus(); } return true; } return false; } private static bool IsToggleShortcutDown() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut toggleShortcut = FreeFlyPreference.ToggleShortcut; if ((int)((KeyboardShortcut)(ref toggleShortcut)).MainKey == 0 || !ZInput.GetKeyDown(((KeyboardShortcut)(ref toggleShortcut)).MainKey, true)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref toggleShortcut)).Modifiers) { if (!ZInput.GetKey(modifier, true)) { return false; } } return true; } } internal static class FreeFlyTransitionController { private const float EnterDuration = 1f; private const float ExitDuration = 3f; private const float InitialTurnDuration = 1.5f; private const float FinalTurnDuration = 1f; private static Vector3 startPosition; private static Quaternion startRotation; private static Vector3 returnPosition; private static Quaternion returnRotation; private static Vector3 targetPosition; private static Quaternion targetRotation; private static Vector3 exitLookTarget; private static float elapsed; private static bool entering; private static bool exiting; internal static void StartEntering(GameCamera camera, Vector3 position, Quaternion rotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) startPosition = position; startRotation = rotation; returnPosition = position; returnRotation = rotation; targetPosition = ((Component)camera).transform.position; targetRotation = ((Component)camera).transform.rotation; elapsed = 0f; entering = true; exiting = false; ((Component)camera).transform.SetPositionAndRotation(position, rotation); } internal static void StartExiting(GameCamera camera) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (!exiting) { startPosition = ((Component)camera).transform.position; startRotation = ((Component)camera).transform.rotation; targetPosition = returnPosition; targetRotation = returnRotation; Player localPlayer = Player.m_localPlayer; exitLookTarget = (Object.op_Implicit((Object)(object)localPlayer) ? ((Character)localPlayer).m_eye.position : (((Component)camera).transform.position + ((Component)camera).transform.forward)); elapsed = 0f; entering = false; exiting = true; } } internal static void ApplyEntering(GameCamera camera, float deltaTime) { if (entering) { ApplyEnteringTransform(camera, deltaTime); entering = elapsed < 1f; } } internal static void ApplyExiting(GameCamera camera, float deltaTime) { if (exiting) { elapsed += deltaTime; ApplyExitTransform(camera, Mathf.Min(elapsed, 3f)); exiting = elapsed < 3f; if (!exiting) { FreeFlyController.CompleteDisable(); } } } private static void ApplyEnteringTransform(GameCamera camera, float deltaTime) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) elapsed += deltaTime; float num = Ease(Mathf.Clamp01(elapsed / 1f)); ((Component)camera).transform.SetPositionAndRotation(Vector3.Lerp(startPosition, targetPosition, num), Quaternion.Slerp(startRotation, targetRotation, num)); } private static void ApplyExitTransform(GameCamera camera, float time) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) float progress = time / 3f; Vector3 val = Vector3.Lerp(startPosition, targetPosition, Ease(progress)); Quaternion val2 = LookAt(val, startRotation); float num = Ease(Mathf.Clamp01(time / 1.5f)); Quaternion val3 = Quaternion.Slerp(startRotation, val2, num); float num2 = 2f; float num3 = Ease(Mathf.Clamp01((time - num2) / 1f)); ((Component)camera).transform.SetPositionAndRotation(val, Quaternion.Slerp(val3, targetRotation, num3)); } private static Quaternion LookAt(Vector3 position, Quaternion fallback) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = exitLookTarget - position; if (!(((Vector3)(ref val)).sqrMagnitude > Mathf.Epsilon)) { return fallback; } return Quaternion.LookRotation(val, Vector3.up); } private static float Ease(float progress) { return progress * progress * progress * (progress * (progress * 6f - 15f) + 10f); } } } namespace Landoria.SharedLib { public abstract class LandoriaPlugin : BaseUnityPlugin { private Harmony _harmony; private bool _patchesApplied; protected ModLog InitializePlugin(string pluginGuid) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown ModLog modLog = new ModLog(((BaseUnityPlugin)this).Logger); Version version = ((object)this).GetType().Assembly.GetName().Version; modLog.LogInfo($"AssemblyVersion: {version}."); EnsureSharedPatches(modLog); _harmony = new Harmony(pluginGuid); PatchOwnNamespace(modLog); return modLog; } protected ModLog InitializePlugin(string pluginGuid, Type[] patchTypes) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown ModLog modLog = new ModLog(((BaseUnityPlugin)this).Logger); Version version = ((object)this).GetType().Assembly.GetName().Version; modLog.LogInfo($"AssemblyVersion: {version}."); EnsureSharedPatches(modLog); _harmony = new Harmony(pluginGuid); foreach (Type type in patchTypes) { _harmony.CreateClassProcessor(type).Patch(); modLog.LogInfo("Server patch: " + type.Name); } _patchesApplied = true; return modLog; } private static void EnsureSharedPatches(ModLog log) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) lock (AppDomain.CurrentDomain) { if (AppDomain.CurrentDomain.GetData("Landoria.SharedLib.ConnectionFailureMenuPatch.v1") == null) { new Harmony("Landoria.SharedLib").CreateClassProcessor(typeof(ConnectionFailureMenuPatch)).Patch(); AppDomain.CurrentDomain.SetData("Landoria.SharedLib.ConnectionFailureMenuPatch.v1", true); log.LogDebug("Shared connection failure menu patch was applied."); } } } protected void PatchOwnNamespace(ModLog log) { if (_patchesApplied) { log.LogDebug("Harmony patches are already active; skipping registration."); return; } string text = ((object)this).GetType().Namespace; Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { if (type.Namespace == text) { _harmony.CreateClassProcessor(type).Patch(); } } _patchesApplied = true; log.LogDebug("Harmony patches were applied for the plugin namespace."); } protected void ShutdownPlugin() { if (_patchesApplied) { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _patchesApplied = false; } } } public static class ConnectionFailureMessages { private const string StateKey = "Landoria.SharedLib.ConnectionFailureMessages.v1"; private static readonly ManualLogSource Log = Logger.CreateLogSource("Landoria.ConnectionFailureMessages"); public static void Push(string source, string message) { Push(source, message, (string)null); } public static void Push(string source, string userMessage, string systemMessage) { Push(source, userMessage, systemMessage, null); } public static void Push(string source, string userMessage, Exception exception) { Push(source, userMessage, exception?.Message, exception); } public static void Push(string source, string userMessage, string systemMessage, Exception exception) { string text = DisplayMessage(userMessage, systemMessage ?? exception?.Message); if (string.IsNullOrWhiteSpace(source) || text == null) { return; } bool flag = false; lock (AppDomain.CurrentDomain) { Stack<Tuple<string, string, string>> messages = GetMessages(); Tuple<string, string, string> item = Tuple.Create(source, text, systemMessage); if (!messages.Contains(item)) { messages.Push(item); flag = true; } } if (flag) { LogQueued(source, text, systemMessage, exception); } } public static void Clear(string source) { if (string.IsNullOrWhiteSpace(source)) { return; } lock (AppDomain.CurrentDomain) { Stack<Tuple<string, string, string>> messages = GetMessages(); Stack<Tuple<string, string, string>> stack = new Stack<Tuple<string, string, string>>(); while (messages.Count > 0) { Tuple<string, string, string> tuple = messages.Pop(); if (tuple.Item1 != source) { stack.Push(tuple); } } while (stack.Count > 0) { messages.Push(stack.Pop()); } } } internal static bool TryPopAll(out string message) { lock (AppDomain.CurrentDomain) { Stack<Tuple<string, string, string>> messages = GetMessages(); if (messages.Count > 0) { List<string> list = new List<string>(); while (messages.Count > 0) { list.Add(messages.Pop().Item2); } message = string.Join("\n", list); return true; } } message = null; return false; } private static Stack<Tuple<string, string, string>> GetMessages() { if (AppDomain.CurrentDomain.GetData("Landoria.SharedLib.ConnectionFailureMessages.v1") is Stack<Tuple<string, string, string>> result) { return result; } Stack<Tuple<string, string, string>> stack = new Stack<Tuple<string, string, string>>(); AppDomain.CurrentDomain.SetData("Landoria.SharedLib.ConnectionFailureMessages.v1", stack); return stack; } private static string DisplayMessage(string userMessage, string systemMessage) { if (!string.IsNullOrWhiteSpace(userMessage)) { return userMessage; } if (!string.IsNullOrWhiteSpace(systemMessage)) { return systemMessage; } return null; } private static void LogQueued(string source, string userMessage, string systemMessage, Exception exception) { string text = exception?.ToString() ?? Environment.StackTrace; if (string.IsNullOrWhiteSpace(systemMessage) || systemMessage == userMessage) { Log.LogWarning((object)("Queued connection failure message from " + source + ": " + userMessage + "\nDiagnostic stack:\n" + text)); } else { Log.LogWarning((object)("Queued connection failure message from " + source + ": userMessage=" + userMessage + "; systemMessage=" + systemMessage + "\nDiagnostic stack:\n" + text)); } } } [HarmonyPatch] internal static class ConnectionFailureMenuPatch { [HarmonyPostfix] [HarmonyPatch(typeof(FejdStartup), "ShowConnectError")] private static void ShowConnectError(TMP_Text ___m_connectionFailedError) { if (ConnectionFailureMessages.TryPopAll(out var message)) { ___m_connectionFailedError.text = message; } } [HarmonyPostfix] [HarmonyPatch(typeof(FejdStartup), "Start")] private static void Start(GameObject ___m_connectionFailedPanel, TMP_Text ___m_connectionFailedError) { ShowNext(___m_connectionFailedPanel, ___m_connectionFailedError); } [HarmonyPostfix] [HarmonyPatch(typeof(FejdStartup), "OnConnectionFailedOk")] private static void OnConnectionFailedOk(GameObject ___m_connectionFailedPanel, TMP_Text ___m_connectionFailedError) { ShowNext(___m_connectionFailedPanel, ___m_connectionFailedError); } private static void ShowNext(GameObject panel, TMP_Text text) { if (ConnectionFailureMessages.TryPopAll(out var message)) { text.text = message; panel.SetActive(true); } } } public sealed class ModLog { private readonly ManualLogSource _logger; public ModLog(ManualLogSource logger) { _logger = logger; } public void LogFatal(object message) { Write((LogLevel)1, message); } public void LogError(object message) { Write((LogLevel)2, message); } public void LogWarning(object message) { Write((LogLevel)4, message); } public void LogMessage(object message) { Write((LogLevel)8, message); } public void LogInfo(object message) { Write((LogLevel)16, message); } public void LogDebug(object message) { Write((LogLevel)32, message); } public void Log(LogLevel level, object message) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Write(level, message); } private void Write(LogLevel level, object message) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) string arg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); _logger.Log(level, (object)$"[{arg}] {message}"); } } public static class PlatformPlayerIdentity { public unsafe static string Resolve(PlayerInfo player) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) string text = ((object)(*(PlatformUserID*)(&player.m_userInfo.m_id))/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrWhiteSpace(text)) { return text; } ZNetPeer obj = FindPeer(player); if (obj == null) { return null; } ISocket socket = obj.m_socket; if (socket == null) { return null; } return socket.GetHostName(); } public static ZNetPeer FindPeer(PlayerInfo player) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || ((ZDOID)(ref player.m_characterID)).IsNone()) { return null; } return ((IEnumerable<ZNetPeer>)ZNet.instance.GetPeers()).FirstOrDefault((Func<ZNetPeer, bool>)((ZNetPeer peer) => peer != null && ((ZDOID)(ref peer.m_characterID)).Equals(player.m_characterID))); } } public static class ServerRole { public static bool IsDedicatedServer { get { if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { return ZNet.instance.IsDedicated(); } return false; } } } }