using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreShipUpgrades.Misc.Upgrades;
using MoreShipUpgrades.Misc.Util;
using MoreShipUpgrades.UpgradeComponents.TierUpgrades.Items.Shotgun;
using PiggyVarietyMod.Patches;
using SleightOfHandPiggyVarietyPatch.NetcodePatcher;
using SleightOfHandPiggyVarietyPatch.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
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;
}
}
}
namespace SleightOfHandPiggyVarietyPatch
{
[BepInPlugin("com.github.WhiteSpike.SleightOfHandPiggyVarietyPatch", "Sleight Of Hand Piggy Variety Patch", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static readonly Harmony harmony = new Harmony("com.github.WhiteSpike.SleightOfHandPiggyVarietyPatch");
internal static readonly ManualLogSource mls = Logger.CreateLogSource("Sleight Of Hand Piggy Variety Patch");
private void Awake()
{
harmony.PatchAll(typeof(M4ItemPatcher));
mls.LogInfo((object)"Patched the rifle succesfully");
harmony.PatchAll(typeof(RevolverItemPatcher));
mls.LogInfo((object)"Patched the revolver successfully");
mls.LogInfo((object)"Sleight Of Hand Piggy Variety Patch 1.0.0 has been loaded successfully.");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "SleightOfHandPiggyVarietyPatch";
public const string PLUGIN_NAME = "SleightOfHandPiggyVarietyPatch";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace SleightOfHandPiggyVarietyPatch.Patches
{
[HarmonyPatch(typeof(M4Item))]
internal static class M4ItemPatcher
{
[HarmonyPatch("ReloadGunAnimation")]
[HarmonyPrefix]
private static void ReloadGunAnimationPrefix(M4Item __instance)
{
if (BaseUpgrade.GetActiveUpgrade("Sleight of Hand"))
{
Animator playerBodyAnimator = ((GrabbableObject)__instance).playerHeldBy.playerBodyAnimator;
playerBodyAnimator.speed *= 2f + SleightOfHand.ComputeSleightOfHandSpeedBoost();
Animator gunAnimator = __instance.gunAnimator;
gunAnimator.speed *= 2f + SleightOfHand.ComputeSleightOfHandSpeedBoost();
((MonoBehaviour)__instance).StartCoroutine(__instance.waitToEndReloadAnimation());
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> ReloadGunAnimationTranspiler(IEnumerable<CodeInstruction> instructions)
{
MethodInfo method = typeof(SleightOfHand).GetMethod("GetSleightOfHandSpeedBoost");
List<CodeInstruction> result = new List<CodeInstruction>(instructions);
int num = 0;
Tools.FindFloat(ref num, ref result, 2f, method, false, false, false, false, false, false, "Couldn't find the first WaitForSecond value");
Tools.FindFloat(ref num, ref result, 0.55f, method, false, false, false, false, false, false, "Couldn't find the second WaitForSecond value");
return result;
}
private static IEnumerator waitToEndReloadAnimation(this M4Item gun)
{
yield return (object)new WaitForSeconds(1f);
yield return (object)new WaitWhile((Func<bool>)(() => gun.isReloading));
Animator playerBodyAnimator = ((GrabbableObject)gun).playerHeldBy.playerBodyAnimator;
playerBodyAnimator.speed /= 2f + SleightOfHand.ComputeSleightOfHandSpeedBoost();
Animator gunAnimator = gun.gunAnimator;
gunAnimator.speed /= 2f + SleightOfHand.ComputeSleightOfHandSpeedBoost();
}
}
[HarmonyPatch(typeof(RevolverItem))]
internal static class RevolverItemPatcher
{
[HarmonyPatch("ReloadGunAnimation")]
[HarmonyPrefix]
private static void ReloadGunAnimationPrefix(RevolverItem __instance)
{
if (BaseUpgrade.GetActiveUpgrade("Sleight of Hand"))
{
Animator playerBodyAnimator = ((GrabbableObject)__instance).playerHeldBy.playerBodyAnimator;
playerBodyAnimator.speed *= 2f + SleightOfHand.ComputeSleightOfHandSpeedBoost();
Animator gunAnimator = __instance.gunAnimator;
gunAnimator.speed *= 2f + SleightOfHand.ComputeSleightOfHandSpeedBoost();
((MonoBehaviour)__instance).StartCoroutine(__instance.waitToEndReloadAnimation());
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> ReloadGunAnimationTranspiler(IEnumerable<CodeInstruction> instructions)
{
MethodInfo method = typeof(SleightOfHand).GetMethod("GetSleightOfHandSpeedBoost");
List<CodeInstruction> result = new List<CodeInstruction>(instructions);
int num = 0;
Tools.FindFloat(ref num, ref result, 0.05f, method, false, false, false, false, false, false, "Couldn't find the first WaitForSecond value");
Tools.FindFloat(ref num, ref result, 0.75f, method, false, false, false, false, false, false, "Couldn't find the second WaitForSecond value");
Tools.FindFloat(ref num, ref result, 0.1f, method, false, false, false, false, false, false, "Couldn't find the second WaitForSecond value");
Tools.FindFloat(ref num, ref result, 1f, method, false, false, false, false, false, false, "Couldn't find the second WaitForSecond value");
return result;
}
private static IEnumerator waitToEndReloadAnimation(this RevolverItem gun)
{
yield return (object)new WaitForSeconds(0.5f);
yield return (object)new WaitWhile((Func<bool>)(() => gun.isReloading));
Animator playerBodyAnimator = ((GrabbableObject)gun).playerHeldBy.playerBodyAnimator;
playerBodyAnimator.speed /= 2f + SleightOfHand.ComputeSleightOfHandSpeedBoost();
Animator gunAnimator = gun.gunAnimator;
gunAnimator.speed /= 2f + SleightOfHand.ComputeSleightOfHandSpeedBoost();
}
}
}
namespace SleightOfHandPiggyVarietyPatch.Misc
{
internal static class Metadata
{
public const string GUID = "com.github.WhiteSpike.SleightOfHandPiggyVarietyPatch";
public const string NAME = "Sleight Of Hand Piggy Variety Patch";
public const string VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace SleightOfHandPiggyVarietyPatch.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}