Decompiled source of UltimateMovement v1.0.3

BepInEx/plugins/UltimateMovement.dll

Decompiled 11 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Movement;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("UltimateMovement")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0+873ff3fae4fe7f4415f75c3331915ef3d1a2134f")]
[assembly: AssemblyProduct("UltimateMovement")]
[assembly: AssemblyTitle("UltimateMovement")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("sparroh.ultimatemovement", "UltimateMovement", "1.0.3")]
public class FreeFireMod : BaseUnityPlugin
{
	public enum GunType
	{
		Unknown,
		Cycler,
		Jackrabbit,
		SwarmLauncher,
		DMLR,
		PlateLauncher,
		LeadFlinger,
		Gunship,
		Trident,
		Globbler,
		Carver,
		Shocklance
	}

	public struct GunModData
	{
		public int CanFireWhileSprinting { get; set; }

		public int CanFireWhileSliding { get; set; }

		public int CanAimWhileSliding { get; set; }

		public int CanAimWhileReloading { get; set; }

		public int CanAimWhileSprinting { get; set; }
	}

	public const string PluginGUID = "sparroh.ultimatemovement";

	public const string PluginName = "UltimateMovement";

	public const string PluginVersion = "1.0.3";

	private Harmony harmony;

	public static readonly Dictionary<GunType, GunModData> GunMods = new Dictionary<GunType, GunModData>
	{
		{
			GunType.Cycler,
			new GunModData
			{
				CanFireWhileSprinting = 1,
				CanFireWhileSliding = 1,
				CanAimWhileSliding = 1,
				CanAimWhileReloading = 1,
				CanAimWhileSprinting = 1
			}
		},
		{
			GunType.Jackrabbit,
			new GunModData
			{
				CanFireWhileSprinting = 1,
				CanFireWhileSliding = 1,
				CanAimWhileSliding = 1,
				CanAimWhileReloading = 1,
				CanAimWhileSprinting = 1
			}
		},
		{
			GunType.SwarmLauncher,
			new GunModData
			{
				CanFireWhileSprinting = 1,
				CanFireWhileSliding = 1,
				CanAimWhileSliding = 1,
				CanAimWhileReloading = 1,
				CanAimWhileSprinting = 1
			}
		},
		{
			GunType.DMLR,
			new GunModData
			{
				CanFireWhileSprinting = 1,
				CanFireWhileSliding = 1,
				CanAimWhileSliding = 1,
				CanAimWhileReloading = 1,
				CanAimWhileSprinting = 1
			}
		},
		{
			GunType.PlateLauncher,
			new GunModData
			{
				CanFireWhileSprinting = 1,
				CanFireWhileSliding = 1,
				CanAimWhileSliding = 1,
				CanAimWhileReloading = 1,
				CanAimWhileSprinting = 1
			}
		},
		{
			GunType.LeadFlinger,
			new GunModData
			{
				CanFireWhileSprinting = 1,
				CanFireWhileSliding = 1,
				CanAimWhileSliding = 1,
				CanAimWhileReloading = 1,
				CanAimWhileSprinting = 1
			}
		},
		{
			GunType.Gunship,
			new GunModData
			{
				CanFireWhileSprinting = 1,
				CanFireWhileSliding = 1,
				CanAimWhileSliding = 1,
				CanAimWhileReloading = 1,
				CanAimWhileSprinting = 1
			}
		},
		{
			GunType.Trident,
			new GunModData
			{
				CanFireWhileSprinting = 1,
				CanFireWhileSliding = 1,
				CanAimWhileSliding = 1,
				CanAimWhileReloading = 1,
				CanAimWhileSprinting = 1
			}
		},
		{
			GunType.Globbler,
			new GunModData
			{
				CanFireWhileSprinting = 1,
				CanFireWhileSliding = 1,
				CanAimWhileSliding = 1,
				CanAimWhileReloading = 1,
				CanAimWhileSprinting = 1
			}
		},
		{
			GunType.Carver,
			new GunModData
			{
				CanFireWhileSprinting = 1,
				CanFireWhileSliding = 1,
				CanAimWhileSliding = 1,
				CanAimWhileReloading = 1,
				CanAimWhileSprinting = 1
			}
		},
		{
			GunType.Shocklance,
			new GunModData
			{
				CanFireWhileSprinting = 1,
				CanFireWhileSliding = 1,
				CanAimWhileSliding = 1,
				CanAimWhileReloading = 1,
				CanAimWhileSprinting = 1
			}
		}
	};

	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Expected O, but got Unknown
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Expected O, but got Unknown
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Expected O, but got Unknown
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Expected O, but got Unknown
		Harmony val = new Harmony("sparroh.ultimatemovement");
		MethodInfo methodInfo = AccessTools.Method(typeof(Gun), "Setup", new Type[3]
		{
			typeof(Player),
			typeof(PlayerAnimation),
			typeof(IGear)
		}, (Type[])null);
		if (methodInfo == null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Could not find Gun.Setup method!");
			return;
		}
		HarmonyMethod val2 = new HarmonyMethod(typeof(Patches), "ModifyWeaponPrefix", (Type[])null);
		val.Patch((MethodBase)methodInfo, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo2 = AccessTools.Method(typeof(Gun), "OnStartAim", (Type[])null, (Type[])null);
		if (methodInfo2 == null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Could not find Gun.OnStartAim method!");
			return;
		}
		HarmonyMethod val3 = new HarmonyMethod(typeof(Patches), "OnStartAimPrefix", (Type[])null);
		HarmonyMethod val4 = new HarmonyMethod(typeof(Patches), "OnStartAimPostfix", (Type[])null);
		val.Patch((MethodBase)methodInfo2, val3, val4, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo3 = AccessTools.Method(typeof(Gun), "CanAim", (Type[])null, (Type[])null);
		if (methodInfo3 == null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Could not find Gun.CanAim method!");
			return;
		}
		HarmonyMethod val5 = new HarmonyMethod(typeof(Patches), "CanAimPrefix", (Type[])null);
		val.Patch((MethodBase)methodInfo3, val5, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo4 = AccessTools.PropertyGetter(typeof(Player), "EnableWallrun");
		if (!(methodInfo4 == null))
		{
			HarmonyMethod val6 = new HarmonyMethod(typeof(Patches), "EnableWallrunGetPrefix", (Type[])null);
			val.Patch((MethodBase)methodInfo4, val6, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"UltimateMovement loaded successfully.");
		}
	}
}
public class ModGunData : MonoBehaviour
{
	public int CanAimWhileSprinting { get; set; }

	public bool WasSprinting { get; set; }
}
internal static class Patches
{
	private static readonly FieldInfo lockSprintingField = AccessTools.Field(typeof(Gun), "lockSprinting");

	public static void ModifyWeaponPrefix(Gun __instance, IGear prefab)
	{
		FreeFireMod.GunType gunType = DetermineGunType(__instance);
		if (gunType != 0)
		{
			ModGunData modGunData = ((Component)__instance).gameObject.AddComponent<ModGunData>();
			ModifyGunBaseStats(prefab, gunType, modGunData);
		}
	}

	private static FreeFireMod.GunType DetermineGunType(Gun gun)
	{
		string text = ((Object)((Component)gun).gameObject).name.ToUpperInvariant();
		if (text.Contains("SMG") && gun is CartridgeSMG)
		{
			return FreeFireMod.GunType.Cycler;
		}
		if (text.Contains("BOUNCE SHOTGUN") && gun is BounceShotgun)
		{
			return FreeFireMod.GunType.Jackrabbit;
		}
		if (text.Contains("SWARM GUN") && gun is SwarmGun)
		{
			return FreeFireMod.GunType.SwarmLauncher;
		}
		if (text.Contains("SCOUT") && gun is ScoutLaserRifle)
		{
			return FreeFireMod.GunType.DMLR;
		}
		if (text.Contains("PLATE LAUNCHER") && gun is PlateLauncher)
		{
			return FreeFireMod.GunType.PlateLauncher;
		}
		if (text.Contains("FAST SHOTGUN") && gun is FastReloadShotgun)
		{
			return FreeFireMod.GunType.LeadFlinger;
		}
		if (text.Contains("MINI CANNON") && gun is MiniCannon)
		{
			return FreeFireMod.GunType.Gunship;
		}
		if (text.Contains("WIDE GUN") && gun is WideGun)
		{
			return FreeFireMod.GunType.Trident;
		}
		if (text.Contains("GLOBBLER") && gun is Globbler)
		{
			return FreeFireMod.GunType.Globbler;
		}
		if (text.Contains("THE CARVER") && gun is TheCarver)
		{
			return FreeFireMod.GunType.Carver;
		}
		if (text.Contains("SHOCKLANCE") && gun is Shocklance)
		{
			return FreeFireMod.GunType.Shocklance;
		}
		return FreeFireMod.GunType.Unknown;
	}

	private static void ModifyGunBaseStats(IGear prefab, FreeFireMod.GunType gunType, ModGunData modGunData)
	{
		//IL_0032: 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_0056: Unknown result type (might be due to invalid IL or missing references)
		if (prefab == null)
		{
			return;
		}
		Gun val = (Gun)(object)((prefab is Gun) ? prefab : null);
		if (val != null)
		{
			ref GunData gunData = ref val.GunData;
			if (FreeFireMod.GunMods.TryGetValue(gunType, out var value))
			{
				gunData.fireConstraints.canFireWhileSprinting = (ActionFireMode)value.CanFireWhileSprinting;
				gunData.fireConstraints.canFireWhileSliding = (ActionFireMode)value.CanFireWhileSliding;
				gunData.fireConstraints.canAimWhileSliding = (ActionFireMode)value.CanAimWhileSliding;
				gunData.fireConstraints.canAimWhileReloading = value.CanAimWhileReloading != 0;
				modGunData.CanAimWhileSprinting = value.CanAimWhileSprinting;
				bool flag = value.CanAimWhileSprinting != 1;
				lockSprintingField.SetValue(val, flag);
			}
		}
	}

	public static bool OnStartAimPrefix(Gun __instance)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		ModGunData component = ((Component)__instance).gameObject.GetComponent<ModGunData>();
		if ((Object)(object)component != (Object)null && component.CanAimWhileSprinting == 1)
		{
			Player val = (Player)AccessTools.Field(typeof(Gun), "player").GetValue(__instance);
			if ((Object)(object)val != (Object)null)
			{
				PropertyInfo propertyInfo = AccessTools.Property(typeof(Player), "IsSprinting");
				if (propertyInfo != null)
				{
					component.WasSprinting = (bool)propertyInfo.GetValue(val);
				}
			}
		}
		return true;
	}

	public static void OnStartAimPostfix(Gun __instance)
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Expected O, but got Unknown
		ModGunData component = ((Component)__instance).gameObject.GetComponent<ModGunData>();
		if (!((Object)(object)component != (Object)null) || component.CanAimWhileSprinting != 1 || !component.WasSprinting)
		{
			return;
		}
		Player val = (Player)AccessTools.Field(typeof(Gun), "player").GetValue(__instance);
		if ((Object)(object)val != (Object)null)
		{
			MethodInfo methodInfo = AccessTools.Method(typeof(Player), "ResumeSprint", (Type[])null, (Type[])null);
			if (methodInfo != null)
			{
				methodInfo.Invoke(val, null);
			}
		}
		component.WasSprinting = false;
	}

	public static bool CanAimPrefix(Gun __instance, ref bool __result)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		ModGunData component = ((Component)__instance).gameObject.GetComponent<ModGunData>();
		if ((Object)(object)component != (Object)null && component.CanAimWhileSprinting == 1)
		{
			Player val = (Player)AccessTools.Field(typeof(Gun), "player").GetValue(__instance);
			if ((Object)(object)val != (Object)null)
			{
				PropertyInfo propertyInfo = AccessTools.Property(typeof(Player), "IsSprinting");
				if (propertyInfo != null && (bool)propertyInfo.GetValue(val))
				{
					FieldInfo fieldInfo = AccessTools.Field(typeof(Gun), "isAimInputHeld");
					if (fieldInfo != null && (bool)fieldInfo.GetValue(__instance))
					{
						__result = true;
						return false;
					}
				}
			}
		}
		return true;
	}

	public static bool EnableWallrunGetPrefix(Player __instance, ref bool __result)
	{
		if (!((NetworkBehaviour)__instance).IsLocalPlayer)
		{
			return true;
		}
		__result = true;
		return false;
	}
}
[CompilerGenerated]
[ExcludeFromCodeCoverage]
internal static class GitVersionInformation
{
	public const string AssemblySemFileVer = "0.0.1.0";

	public const string AssemblySemVer = "0.0.1.0";

	public const string BranchName = "master";

	public const string BuildMetaData = "";

	public const string CommitDate = "2025-10-17";

	public const string CommitsSinceVersionSource = "1";

	public const string EscapedBranchName = "master";

	public const string FullBuildMetaData = "Branch.master.Sha.873ff3fae4fe7f4415f75c3331915ef3d1a2134f";

	public const string FullSemVer = "0.0.1-1";

	public const string InformationalVersion = "0.0.1-1+Branch.master.Sha.873ff3fae4fe7f4415f75c3331915ef3d1a2134f";

	public const string Major = "0";

	public const string MajorMinorPatch = "0.0.1";

	public const string Minor = "0";

	public const string Patch = "1";

	public const string PreReleaseLabel = "";

	public const string PreReleaseLabelWithDash = "";

	public const string PreReleaseNumber = "1";

	public const string PreReleaseTag = "1";

	public const string PreReleaseTagWithDash = "-1";

	public const string SemVer = "0.0.1-1";

	public const string Sha = "873ff3fae4fe7f4415f75c3331915ef3d1a2134f";

	public const string ShortSha = "873ff3f";

	public const string UncommittedChanges = "12";

	public const string VersionSourceSha = "";

	public const string WeightedPreReleaseNumber = "55001";
}
namespace UltimateMovement
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "UltimateMovement";

		public const string PLUGIN_NAME = "UltimateMovement";

		public const string PLUGIN_VERSION = "0.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}