using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ShotgunJump")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ShotgunJump")] [assembly: AssemblyTitle("ShotgunJump")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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; } } } namespace ShotgunJump { public enum BoostMode { Absolute, Multiplier } [BepInPlugin("howtofish.shotgunrocketjump", "ShotgunJump", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "howtofish.shotgunrocketjump"; public const string Name = "ShotgunJump"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry Enabled; internal static ConfigEntry Mode; internal static ConfigEntry AbsoluteForce; internal static ConfigEntry Multiplier; internal static ConfigEntry AllWeapons; internal static ConfigEntry NameFilter; internal static ConfigEntry LogWeaponNames; private void Awake() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind("1. General", "Enabled", true, "Master switch. Turn off to restore vanilla recoil knockback without uninstalling."); NameFilter = ((BaseUnityPlugin)this).Config.Bind("1. General", "WeaponNameFilter", "shotgun", "Only weapons whose prefab name contains this text get boosted. Case-insensitive.\nIf the shotgun isn't reacting, turn on LogWeaponNames and check the console for its real name."); AllWeapons = ((BaseUnityPlugin)this).Config.Bind("1. General", "AffectAllWeapons", false, "Ignore WeaponNameFilter and boost every gun in the game."); Mode = ((BaseUnityPlugin)this).Config.Bind("2. Force", "Mode", BoostMode.Absolute, "Absolute = use AbsoluteForce as the knockback value.\nMultiplier = multiply the weapon's own vanilla value by Multiplier."); AbsoluteForce = ((BaseUnityPlugin)this).Config.Bind("2. Force", "AbsoluteForce", 20, new ConfigDescription("THIS IS THE ONE YOU WANT. How hard the shot throws you, in metres per second, straight backwards from where your camera is pointing.\nVanilla is a low single-digit number. ~12 is a hop, ~20 is a proper rocket jump, ~35 is silly.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); Multiplier = ((BaseUnityPlugin)this).Config.Bind("2. Force", "Multiplier", 8f, new ConfigDescription("Only used when Mode = Multiplier. Scales the weapon's vanilla knockback.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 50f), Array.Empty())); LogWeaponNames = ((BaseUnityPlugin)this).Config.Bind("3. Debug", "LogWeaponNames", true, "Log each weapon's prefab name and its vanilla knockback value the first time you fire it.\nUse this once to find the shotgun's exact name, then turn it off."); new Harmony("howtofish.shotgunrocketjump").PatchAll(); Log.LogInfo((object)string.Format("{0} v{1} loaded. Mode={2}, AbsoluteForce={3}, filter='{4}'", "ShotgunJump", "1.0.0", Mode.Value, AbsoluteForce.Value, NameFilter.Value)); } } [HarmonyPatch(typeof(Weapon), "Shoot")] internal static class WeaponShootPatch { private static readonly FieldRef RecoilKnockback = AccessTools.FieldRefAccess("_recoilKnockback"); private static readonly ConditionalWeakTable> VanillaForce = new ConditionalWeakTable>(); [HarmonyPrefix] private static void Prefix(Weapon __instance) { if ((Object)(object)__instance == (Object)null) { return; } if (!VanillaForce.TryGetValue(__instance, out var value)) { value = new StrongBox(RecoilKnockback.Invoke(__instance)); VanillaForce.Add(__instance, value); if (Plugin.LogWeaponNames.Value) { Plugin.Log.LogInfo((object)$"Fired weapon '{((Object)__instance).name}' | vanilla _recoilKnockback = {value.Value}"); } } int value2 = value.Value; int num = value2; if (Plugin.Enabled.Value && Matches(__instance)) { num = ((Plugin.Mode.Value == BoostMode.Absolute) ? Plugin.AbsoluteForce.Value : Mathf.RoundToInt((float)value2 * Plugin.Multiplier.Value)); } if (RecoilKnockback.Invoke(__instance) != num) { RecoilKnockback.Invoke(__instance) = num; } } private static bool Matches(Weapon weapon) { if (Plugin.AllWeapons.Value) { return true; } string value = Plugin.NameFilter.Value; if (string.IsNullOrEmpty(value)) { return false; } return ((Object)weapon).name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0; } } }