using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FlyMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("DESKTOP-")]
[assembly: AssemblyProduct("FlyMod")]
[assembly: AssemblyCopyright("Copyright © DESKTOP- 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("11fc7f41-185a-4476-822d-665d4c5c4065")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FlyMod;
[BepInPlugin("FlyMod", "Fly Mod", "1.0.7")]
public class FlyModPlugin : BaseUnityPlugin
{
internal static ConfigEntry<float> ConfigFlySpeed;
internal static ConfigEntry<float> ConfigAcceleration;
private void Awake()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
ConfigFlySpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Fly Settings", "FlySpeed", 100f, "Your flying speed");
ConfigAcceleration = ((BaseUnityPlugin)this).Config.Bind<float>("Fly Settings", "Acceleration", 300f, "Your acceleration speed, when you run, obviously..");
Harmony val = new Harmony("com.mathis.flymod");
val.PatchAll(Assembly.GetExecutingAssembly());
((BaseUnityPlugin)this).Logger.LogInfo((object)"[FlyMod] Patch Harmony applied.");
GameObject val2 = new GameObject("FlyModUI");
Object.DontDestroyOnLoad((Object)(object)val2);
FlyModUI.Instance = val2.AddComponent<FlyModUI>();
}
}
public class FlyModUI : MonoBehaviour
{
public static FlyModUI Instance;
public bool IsVisible = false;
private float lastChangeTime = -10f;
private string status = "Deactivated";
private float speed = 0f;
private float accel = 0f;
public void ShowStatus(bool flyActive, float flySpeed, float acceleration)
{
status = (flyActive ? "Activated" : "Deactivated");
speed = flySpeed;
accel = acceleration;
IsVisible = true;
lastChangeTime = Time.time;
}
private void OnGUI()
{
//IL_0037: 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_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
if (IsVisible)
{
if (Time.time - lastChangeTime > 3f)
{
IsVisible = false;
return;
}
GUI.color = Color.white;
GUI.backgroundColor = new Color(0f, 0f, 0f, 0.6f);
GUIStyle val = new GUIStyle(GUI.skin.box);
val.fontSize = 16;
val.alignment = (TextAnchor)0;
GUILayout.BeginArea(new Rect(10f, 10f, 250f, 80f), GUI.skin.box);
GUILayout.Label("Fly Mode: " + status, val, Array.Empty<GUILayoutOption>());
GUILayout.Label($"Speed: {speed}", val, Array.Empty<GUILayoutOption>());
GUILayout.EndArea();
}
}
}
[HarmonyPatch(typeof(CharacterMovement), "Update")]
public class FlyPatch
{
private static bool isFlying = false;
private static Vector3 flyVelocity = Vector3.zero;
private static void Postfix(CharacterMovement __instance)
{
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
//IL_03de: Unknown result type (might be due to invalid IL or missing references)
//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_0403: Unknown result type (might be due to invalid IL or missing references)
//IL_0408: Unknown result type (might be due to invalid IL or missing references)
//IL_040d: Unknown result type (might be due to invalid IL or missing references)
//IL_0420: Unknown result type (might be due to invalid IL or missing references)
//IL_0422: Unknown result type (might be due to invalid IL or missing references)
//IL_0427: Unknown result type (might be due to invalid IL or missing references)
//IL_042c: Unknown result type (might be due to invalid IL or missing references)
//IL_0475: Unknown result type (might be due to invalid IL or missing references)
//IL_047c: Unknown result type (might be due to invalid IL or missing references)
//IL_0483: Unknown result type (might be due to invalid IL or missing references)
//IL_0490: Unknown result type (might be due to invalid IL or missing references)
//IL_0495: Unknown result type (might be due to invalid IL or missing references)
//IL_044e: Unknown result type (might be due to invalid IL or missing references)
//IL_0450: Unknown result type (might be due to invalid IL or missing references)
//IL_0455: Unknown result type (might be due to invalid IL or missing references)
//IL_045a: Unknown result type (might be due to invalid IL or missing references)
//IL_04df: Unknown result type (might be due to invalid IL or missing references)
Character value = Traverse.Create((object)__instance).Field("character").GetValue<Character>();
if (!value.IsLocal || (Object)(object)value.refs?.ragdoll == (Object)null)
{
return;
}
if (Input.GetKeyDown((KeyCode)283) || (Gamepad.current != null && Gamepad.current.leftShoulder.wasPressedThisFrame))
{
FlyModPlugin.ConfigFlySpeed.Value = ((FlyModPlugin.ConfigFlySpeed.Value <= 15f) ? 5f : (FlyModPlugin.ConfigFlySpeed.Value - 15f));
FlyModPlugin.ConfigAcceleration.Value = ((FlyModPlugin.ConfigAcceleration.Value <= 15f) ? 5f : (FlyModPlugin.ConfigAcceleration.Value - 15f));
Debug.Log((object)$"[FlyMod] FlySpeed reduced : {FlyModPlugin.ConfigFlySpeed.Value} and acceleration : {FlyModPlugin.ConfigAcceleration.Value}");
FlyModUI.Instance?.ShowStatus(isFlying, FlyModPlugin.ConfigFlySpeed.Value, FlyModPlugin.ConfigAcceleration.Value);
}
if (Input.GetKeyDown((KeyCode)284) || (Gamepad.current != null && Gamepad.current.rightShoulder.wasPressedThisFrame))
{
ConfigEntry<float> configFlySpeed = FlyModPlugin.ConfigFlySpeed;
configFlySpeed.Value += 15f;
ConfigEntry<float> configAcceleration = FlyModPlugin.ConfigAcceleration;
configAcceleration.Value += 15f;
Debug.Log((object)$"[FlyMod] FlySpeed increased : {FlyModPlugin.ConfigFlySpeed.Value} and acceleration : {FlyModPlugin.ConfigAcceleration.Value}");
FlyModUI.Instance?.ShowStatus(isFlying, FlyModPlugin.ConfigFlySpeed.Value, FlyModPlugin.ConfigAcceleration.Value);
}
if (Input.GetKeyDown((KeyCode)285))
{
FlyModPlugin.ConfigFlySpeed.Value = 100f;
FlyModPlugin.ConfigAcceleration.Value = 300f;
Debug.Log((object)"[FlyMod] FlySpeed and Acceleration reset to default.");
FlyModUI.Instance?.ShowStatus(isFlying, FlyModPlugin.ConfigFlySpeed.Value, FlyModPlugin.ConfigAcceleration.Value);
}
if (Input.GetKeyDown((KeyCode)287) || (Gamepad.current != null && Gamepad.current.selectButton.wasPressedThisFrame))
{
isFlying = !isFlying;
flyVelocity = Vector3.zero;
foreach (Bodypart part in value.refs.ragdoll.partList)
{
if ((Object)(object)((part != null) ? part.Rig : null) != (Object)null)
{
part.Rig.useGravity = !isFlying;
}
}
Debug.Log((object)("[FlyMod] Status " + (isFlying ? "activated" : "deactivated")));
FlyModUI.Instance?.ShowStatus(isFlying, FlyModPlugin.ConfigFlySpeed.Value, FlyModPlugin.ConfigAcceleration.Value);
}
if (!isFlying)
{
return;
}
value.data.isGrounded = true;
value.data.sinceGrounded = 0f;
value.data.sinceJump = 0f;
Vector3 val = Vector2.op_Implicit(value.input.movementInput);
Vector3 normalized = ((Vector3)(ref value.data.lookDirection_Flat)).normalized;
Vector3 val2 = Vector3.Cross(Vector3.up, normalized);
Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
Vector3 val3 = normalized * val.y + normalized2 * val.x;
if (value.input.jumpIsPressed)
{
val3 += Vector3.up;
}
if (value.input.crouchIsPressed)
{
val3 += Vector3.down;
}
if (Gamepad.current != null && Gamepad.current.buttonEast.isPressed)
{
val3 += Vector3.down;
}
float value2 = FlyModPlugin.ConfigFlySpeed.Value;
float value3 = FlyModPlugin.ConfigAcceleration.Value;
flyVelocity = Vector3.Lerp(flyVelocity, ((Vector3)(ref val3)).normalized * value2, Time.deltaTime * value3);
foreach (Bodypart part2 in value.refs.ragdoll.partList)
{
if ((Object)(object)((part2 != null) ? part2.Rig : null) != (Object)null)
{
part2.Rig.linearVelocity = flyVelocity;
}
}
}
}