using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComputerysModdingUtilities;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: StraftatMod(false)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AboubiAcrobatics")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A mod for Straftat that allows you to flip in midair")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("kestrel.straftat.aboubiacrobatics")]
[assembly: AssemblyTitle("AboubiAcrobatics")]
[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 AboubiAcrobatics
{
[BepInPlugin("kestrel.straftat.aboubiacrobatics", "AboubiAcrobatics", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(FirstPersonController))]
private static class FirstPersonControllerPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void Awake()
{
InitAutocorrectTimer();
}
[HarmonyPatch("HandleMouseLook")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> ReplaceClamp(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Mathf), "Clamp", new Type[3]
{
typeof(float),
typeof(float),
typeof(float)
}, (Type[])null), (string)null)
}).Set(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "ClampInjected", (Type[])null, (Type[])null)).InstructionEnumeration();
}
}
internal static ManualLogSource Logger;
public static readonly string loadBearingColonThree = ":3";
private static ConfigEntry<float> autocorrectDuration;
private static ConfigEntry<float> fullAutocorrectThreshold;
private static ConfigEntry<bool> performFullAutocorrects;
private static float m_autocorrectTimer;
private static float m_initialRotation;
private static float m_targetRotation;
private static float m_inAirTime;
public static Plugin Instance { get; private set; }
private void Awake()
{
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
if (loadBearingColonThree != ":3")
{
Application.Quit();
}
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
autocorrectDuration = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Autocorrect duration", 0.15f, "The duration of the automatic flip back to the normal rotation limit upon hitting the ground, in seconds.");
performFullAutocorrects = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Perform full autocorrects", true, "Whether you should be corrected back to looking straight forwards instead of up or down after a given amount of time in the air.");
fullAutocorrectThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Full autocorrect threshold", 0.5f, "The amount of time spent in the air after which full autocorrects will be performed, in seconds.");
((BaseUnityPlugin)this).Config.SettingChanged += delegate
{
InitAutocorrectTimer();
};
new Harmony("kestrel.straftat.aboubiacrobatics").PatchAll();
Logger.LogInfo((object)"Hiiiiiiiiiiii :3");
}
private static void InitAutocorrectTimer()
{
m_autocorrectTimer = autocorrectDuration.Value;
}
private static float ClampInjected(float value, float min, float max)
{
value %= 360f;
value = (value + 360f) % 360f;
if (value > 180f)
{
value -= 360f;
}
FirstPersonController localPlayer = Settings.Instance.localPlayer;
bool num = localPlayer == null || localPlayer.characterController.isGrounded;
if (m_autocorrectTimer < autocorrectDuration.Value)
{
m_autocorrectTimer += Time.deltaTime;
value = Mathf.SmoothStep(m_initialRotation, m_targetRotation, m_autocorrectTimer / autocorrectDuration.Value);
}
if (num && m_autocorrectTimer >= autocorrectDuration.Value && (value < min || value > max))
{
if (m_inAirTime > 0f)
{
m_autocorrectTimer = -1E-45f;
m_initialRotation = value;
m_targetRotation = ((m_inAirTime >= fullAutocorrectThreshold.Value && performFullAutocorrects.Value) ? 0f : Mathf.Clamp(value, min, max));
}
else
{
value = Mathf.Clamp(value, min, max);
}
}
if (!num)
{
m_inAirTime += Time.deltaTime;
}
else
{
m_inAirTime = 0f;
}
return value;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "kestrel.straftat.aboubiacrobatics";
public const string PLUGIN_NAME = "AboubiAcrobatics";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}