using System.Diagnostics;
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 Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Fly Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Fly Mod")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7dfa9d89-00a3-42d6-aa91-7d70ee301435")]
[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")]
[BepInPlugin("com.lamia.flymod", "FlyMod", "1.2.1")]
public class FlyMod : BaseUnityPlugin
{
internal static ConfigEntry<float> BaseForce;
internal static ConfigEntry<float> VerticalForce;
internal static ConfigEntry<float> SprintMultiplier;
internal static ConfigEntry<float> GravityPull;
internal static ConfigEntry<float> MaxClamp;
internal static ConfigEntry<KeyCode> FlyKey;
internal static ConfigEntry<bool> ToggleFly;
internal static ConfigEntry<bool> CreativeFlyMode;
internal static ManualLogSource Log;
private void Awake()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"FlyMod loaded.");
Harmony val = new Harmony("com.lamia.flymod");
val.PatchAll();
CreativeFlyMode = ((BaseUnityPlugin)this).Config.Bind<bool>("FlyMod", "CreativeFlyMode", true, "If true, flying feels more like noclipping in Garry's Mod or manuevering a 3d environment. Setting this to false makes flying feel more like a superhero or being boosted by a Jetpack.");
FlyKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("FlyMod", "FlyKey", (KeyCode)118, "Key to activate flying (default: Mouse3/Middle mouse button).");
ToggleFly = ((BaseUnityPlugin)this).Config.Bind<bool>("FlyMod", "ToggleFly", true, "If true, fly is toggled on/off with the key instead of holding.");
BaseForce = ((BaseUnityPlugin)this).Config.Bind<float>("FlyMod", "BaseForce", 800f, "Base force applied when flying forward/backward/sideways.");
VerticalForce = ((BaseUnityPlugin)this).Config.Bind<float>("FlyMod", "VerticalForce", 800f, "Force applied when flying up or down.");
SprintMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("FlyMod", "SprintMultiplier", 4f, "Multiplier when holding shift.");
MaxClamp = ((BaseUnityPlugin)this).Config.Bind<float>("FlyMod", "MaxClamp", 4000f, "Clamp for maximum fly speed in any direction.");
}
}
[HarmonyPatch(typeof(Character), "Awake")]
public static class PalThrow
{
[HarmonyPostfix]
public static void AwakePatch(Character __instance)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
if (__instance.IsLocal && (Object)((Component)__instance).GetComponent<FlyModPatch>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<FlyModPatch>();
FlyMod.Log.LogInfo((object)("FlyModPatch added to: " + ((Object)__instance).name));
}
}
}
public class FlyModPatch : MonoBehaviourPun
{
private Character character;
private CharacterMovement charMovement;
private bool flyActive = false;
private void Start()
{
character = ((Component)this).GetComponent<Character>();
charMovement = ((Component)this).GetComponent<CharacterMovement>();
}
private void Update()
{
//IL_0051: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
//IL_0428: Unknown result type (might be due to invalid IL or missing references)
//IL_042f: Unknown result type (might be due to invalid IL or missing references)
if (!character.IsLocal)
{
return;
}
if (FlyMod.ToggleFly.Value && Input.GetKeyDown(FlyMod.FlyKey.Value))
{
flyActive = !flyActive;
}
if (!Input.GetKey(FlyMod.FlyKey.Value) && !flyActive)
{
return;
}
if (FlyMod.CreativeFlyMode.Value)
{
character.data.isGrounded = true;
}
else
{
character.data.sinceGrounded = 0.5f;
}
Vector3 val = character.data.lookDirection;
if (Input.GetKey((KeyCode)119) || !FlyMod.CreativeFlyMode.Value)
{
val *= FlyMod.VerticalForce.Value;
}
else if (Input.GetKey((KeyCode)115) && FlyMod.CreativeFlyMode.Value)
{
val *= 0f - FlyMod.VerticalForce.Value;
}
Vector3 val2 = Vector3.Cross(Vector3.up, character.data.lookDirection);
Vector3 val3 = ((Vector3)(ref val2)).normalized * FlyMod.VerticalForce.Value;
if (Input.GetKey((KeyCode)100))
{
val = ((!FlyMod.CreativeFlyMode.Value) ? (val + val3 / 8f) : (val + val3));
}
if (Input.GetKey((KeyCode)97))
{
val = ((!FlyMod.CreativeFlyMode.Value) ? (val - val3 / 8f) : (val - val3));
}
if (Input.GetKey((KeyCode)32))
{
val = ((!FlyMod.CreativeFlyMode.Value) ? (val + Vector3.up * (FlyMod.VerticalForce.Value / 8f)) : (val + Vector3.up * FlyMod.VerticalForce.Value));
}
else if (Input.GetKey((KeyCode)306) && FlyMod.CreativeFlyMode.Value)
{
val += Vector3.down * FlyMod.VerticalForce.Value;
}
if (Input.GetKey((KeyCode)304))
{
character.AddStamina(charMovement.sprintStaminaUsage * Time.deltaTime);
val *= FlyMod.SprintMultiplier.Value;
}
val = ((!FlyMod.CreativeFlyMode.Value) ? (val + Vector3.up * 240f) : (val + Vector3.down * 100f));
val.x = Mathf.Clamp(val.x, 0f - FlyMod.MaxClamp.Value, FlyMod.MaxClamp.Value);
val.y = Mathf.Clamp(val.y, 0f - FlyMod.MaxClamp.Value, FlyMod.MaxClamp.Value);
val.z = Mathf.Clamp(val.z, 0f - FlyMod.MaxClamp.Value, FlyMod.MaxClamp.Value);
foreach (Bodypart part in character.refs.ragdoll.partList)
{
if (FlyMod.CreativeFlyMode.Value)
{
part.AddForce(val, (ForceMode)0);
}
else if (!((object)(BodypartType)(ref part.partType)).ToString().Contains("Leg") && !((object)(BodypartType)(ref part.partType)).ToString().Contains("Knee") && !((object)(BodypartType)(ref part.partType)).ToString().Contains("Foot"))
{
part.AddForce(val / 7f, (ForceMode)5);
}
}
}
}