using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using GTFO.API; using GTFO.API.Utilities; using GameData; using Gear; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Microsoft.CodeAnalysis; using Player; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("BurstActionBuffer")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e461e4ac20919ad180b3a1b095be23fa2d9aa4dc")] [assembly: AssemblyProduct("BurstActionBuffer")] [assembly: AssemblyTitle("BurstActionBuffer")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace BurstActionBuffer { public sealed class BufferHandler : MonoBehaviour { private enum BufferAction { None, Reload, Swap, Push } private static InventorySlot _bufferSwapSlot; private static BufferAction _bufferAction; private static float _bufferTime; private PlayerAgent? _owner; private BWA_Burst? _bwa; private static readonly Dictionary SwapActions = new Dictionary { { (InputAction)23, (InventorySlot)1 }, { (InputAction)24, (InventorySlot)2 }, { (InputAction)25, (InventorySlot)3 }, { (InputAction)26, (InventorySlot)10 }, { (InputAction)28, (InventorySlot)5 }, { (InputAction)29, (InventorySlot)11 }, { (InputAction)27, (InventorySlot)4 } }; public static BufferHandler Instance { get; private set; } = null; public BufferHandler(IntPtr ptr) : base(ptr) { } private void Awake() { Instance = this; ((Behaviour)this).enabled = false; } public void OnBurstStart(BWA_Burst bwa) { if (!((Object)(object)((BulletWeaponArchetype)bwa).m_owner == (Object)null)) { _bwa = bwa; _owner = ((BulletWeaponArchetype)bwa).m_owner; ((Behaviour)this).enabled = true; } } public void OnBurstEnd() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) AttemptBufferedAction(); ((Behaviour)this).enabled = false; _bwa = null; _owner = null; _bufferAction = BufferAction.None; _bufferSwapSlot = (InventorySlot)0; _bufferTime = 0f; } private void Update() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_owner == (Object)null) { OnBurstEnd(); return; } if (InputMapper.GetButtonDown.Invoke((InputAction)11, _owner.InputFilter)) { _bufferAction = BufferAction.Reload; _bufferTime = Clock.Time; } foreach (KeyValuePair swapAction in SwapActions) { if (InputMapper.GetButtonDown.Invoke(swapAction.Key, _owner.InputFilter)) { _bufferSwapSlot = swapAction.Value; _bufferAction = BufferAction.Swap; _bufferTime = Clock.Time; } } if (InputMapper.GetButtonDown.Invoke((InputAction)12, _owner.InputFilter)) { _bufferAction = BufferAction.Push; _bufferTime = Clock.Time; } } private void AttemptBufferedAction() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Invalid comparison between Unknown and I4 //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_owner == (Object)null || Clock.Time - _bufferTime > Configuration.BufferTime) { return; } FirstPersonItemHolder fPItemHolder = _owner.FPItemHolder; if ((Object)(object)fPItemHolder.WieldedItem != (Object)(object)((BulletWeaponArchetype)_bwa).m_weapon) { return; } PlayerInventoryBase inventory = _owner.Inventory; switch (_bufferAction) { case BufferAction.Reload: if (!fPItemHolder.ItemIsBusy && inventory.CanReloadCurrent()) { inventory.TriggerReload(); } break; case BufferAction.Swap: if ((int)inventory.WieldedSlot != 8 && inventory.WieldedSlot != _bufferSwapSlot) { _owner.Sync.WantsToWieldSlot(_bufferSwapSlot, false); } break; case BufferAction.Push: fPItemHolder.MeleeAttackShortcut(); break; } } } [HarmonyPatch] internal static class BurstPatches { private static ArchetypeDataBlock? _cachedArch; [HarmonyPatch(typeof(PLOC_Stand), "Update")] [HarmonyPrefix] private static void Pre_Update(PLOC_Stand __instance, out bool __state) { __state = false; if (_cachedArch != null && ((PLOC_Base)__instance).m_owner.Locomotion.HasNonForwardInput()) { __state = true; _cachedArch.FireMode = (eWeaponFireMode)0; } } [HarmonyPatch(typeof(PLOC_Stand), "Update")] [HarmonyPostfix] private static void Post_Update(bool __state) { if (__state) { _cachedArch.FireMode = (eWeaponFireMode)1; } } [HarmonyPatch(typeof(BWA_Burst), "OnStartFiring")] [HarmonyPostfix] private static void Post_StartBurstFire(BWA_Burst __instance) { _cachedArch = ((BulletWeaponArchetype)__instance).m_archetypeData; BufferHandler.Instance.OnBurstStart(__instance); } [HarmonyPatch(typeof(BWA_Burst), "OnStopFiring")] [HarmonyPostfix] private static void Post_EndBurstFire() { _cachedArch = null; BufferHandler.Instance.OnBurstEnd(); } } internal static class Configuration { private static ConfigEntry _bufferTime; public static float BufferTime => _bufferTime.Value; internal static void Init() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown ConfigFile config = new ConfigFile(Path.Combine(Paths.ConfigPath, "BurstActionBuffer.cfg"), true); _bufferTime = config.Bind("Base Settings", "Buffer Time", 0.5f, "Maximum allowed time between buffering an action and finishing the burst."); LiveEdit.CreateListener(Paths.ConfigPath, "BurstActionBuffer.cfg", false).FileChanged += (LiveEditEventHandler)delegate { config.Reload(); }; } } internal static class DinoLogger { private static ManualLogSource logger = Logger.CreateLogSource("BurstActionBuffer"); public static void Log(string format, params object[] args) { Log(string.Format(format, args)); } public static void Log(string str) { if (logger != null) { logger.Log((LogLevel)8, (object)str); } } public static void Warning(string format, params object[] args) { Warning(string.Format(format, args)); } public static void Warning(string str) { if (logger != null) { logger.Log((LogLevel)4, (object)str); } } public static void Error(string format, params object[] args) { Error(string.Format(format, args)); } public static void Error(string str) { if (logger != null) { logger.Log((LogLevel)2, (object)str); } } public static void Debug(string format, params object[] args) { Debug(string.Format(format, args)); } public static void Debug(string str) { if (logger != null) { logger.Log((LogLevel)32, (object)str); } } } [BepInPlugin("Dinorush.BurstActionBuffer", "BurstActionBuffer", "1.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal sealed class EntryPoint : BasePlugin { public const string MODNAME = "BurstActionBuffer"; public override void Load() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Configuration.Init(); new Harmony("BurstActionBuffer").PatchAll(); AssetAPI.OnStartupAssetsLoaded += delegate { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown ClassInjector.RegisterTypeInIl2Cpp(); GameObject val = new GameObject("BurstActionBuffer"); Object.DontDestroyOnLoad((Object)val); val.AddComponent(); }; ((BasePlugin)this).Log.LogMessage((object)"Loaded BurstActionBuffer"); } } }