using System;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyCompany("BackFlipPercent")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8d6f9c6c24d8c662ad0f79d92f11836a7529cbe8")]
[assembly: AssemblyProduct("BackFlip%")]
[assembly: AssemblyTitle("BackFlipPercent")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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;
}
}
}
namespace BackFlipPercent
{
[BepInPlugin("YonDev.BackFlipPercent", "BackFlip%", "1.0.0")]
public class BackFlipPercent : BaseUnityPlugin
{
private static class BackFlipPatch
{
[HarmonyPatch(typeof(CharacterAnimations), "PlayEmote")]
[HarmonyPrefix]
private static bool Prefix(CharacterAnimations __instance, string emoteName)
{
if (emoteName != "A_Scout_Emote_BackFlip")
{
return true;
}
if (!enableFlipPatch.Value)
{
return true;
}
Character value = Traverse.Create((object)__instance).Field<Character>("character").Value;
value.refs.view.RPC("RPCA_PlayRemove", (RpcTarget)0, new object[2]
{
emoteName,
GetSucceeded()
});
return false;
}
}
internal static ManualLogSource Logger;
public static ConfigEntry<bool> enableFlipPatch;
public static ConfigEntry<float> SuccessChance;
public static ConfigEntry<KeyCode> BackFlipKey;
public static ConfigEntry<bool> UseRPC;
private static readonly MethodInfo playEmoteMethod = AccessTools.Method(typeof(CharacterAnimations), "PlayEmote", (Type[])null, (Type[])null);
private void Awake()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Expected O, but got Unknown
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin BackFlipPercent is loaded!");
enableFlipPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("hi Mordz", "Enable", true, new ConfigDescription("Enable or disable the backflip patch", (AcceptableValueBase)null, Array.Empty<object>()));
SuccessChance = ((BaseUnityPlugin)this).Config.Bind<float>("hi Mordz", "Backflip Success", 50f, new ConfigDescription("Probability of backflip succeeding (0 - 100)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
BackFlipKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("hi Mordz", "Backflip Key", (KeyCode)116, new ConfigDescription("Key to perform a backflip", (AcceptableValueBase)null, Array.Empty<object>()));
UseRPC = ((BaseUnityPlugin)this).Config.Bind<bool>("hi Mordz", "Use RPC Directly for Backflip", false, new ConfigDescription("Use animation method instead of RPC ", (AcceptableValueBase)null, Array.Empty<object>()));
Harmony val = new Harmony("BackFlipPercent");
val.PatchAll(typeof(BackFlipPatch));
}
private void Update()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)GUIManager.instance != (Object)null && GUIManager.instance.windowBlockingInput)
{
return;
}
CharacterAnimations val = Character.localCharacter?.refs?.animations;
if (!((Object)(object)val == (Object)null) && enableFlipPatch.Value && Input.GetKeyDown(BackFlipKey.Value))
{
Character localCharacter = Character.localCharacter;
if (UseRPC.Value)
{
localCharacter.refs.view.RPC("RPCA_PlayRemove", (RpcTarget)0, new object[2]
{
"A_Scout_Emote_BackFlip",
GetSucceeded()
});
}
else if (playEmoteMethod != null)
{
playEmoteMethod.Invoke(val, new object[1] { "A_Scout_Emote_BackFlip" });
}
}
}
private static bool GetSucceeded()
{
bool flag = Random.value * 100f > SuccessChance.Value;
Logger.LogInfo((object)string.Format("Backflip {0} with chance {1}%", (!flag) ? "succeeded" : "failed", SuccessChance.Value));
return flag;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "BackFlipPercent";
public const string PLUGIN_NAME = "BackFlip%";
public const string PLUGIN_VERSION = "1.0.0";
}
}