using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using Agents; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using GameData; using Gear; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppSystem.Collections.Generic; using Player; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("TacticalReload")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TacticalReload")] [assembly: AssemblyTitle("TacticalReload")] [assembly: AssemblyVersion("1.0.0.0")] namespace TacticalReload; internal static class Exclusions { private const string TAG = "[TacticalReload] "; private const bool ExcludeShotguns = true; private const bool ExcludeRevolvers = true; private const bool ExcludeSentries = true; private const string ExtraExcluded = ""; public static bool IsExcluded(BulletWeapon weapon, string publicName, out string reason) { reason = null; bool flag = true; bool flag2 = true; bool flag3 = true; string text = ""; bool flag4 = !string.IsNullOrWhiteSpace(text); if (!flag && !flag2 && !flag3 && !flag4) { return false; } if (flag && ((Object)(object)((Il2CppObjectBase)weapon).TryCast() != (Object)null || HasPellets(weapon))) { reason = "霰弹枪"; return true; } string text2 = CollectNames(weapon, publicName); if (flag && text2.IndexOf("shotgun", StringComparison.OrdinalIgnoreCase) >= 0) { reason = "霰弹枪(按名字)"; return true; } if (flag2 && text2.IndexOf("revolver", StringComparison.OrdinalIgnoreCase) >= 0) { reason = "左轮"; return true; } if (flag3 && text2.IndexOf("sentry", StringComparison.OrdinalIgnoreCase) >= 0) { reason = "炮台"; return true; } if (flag4) { string[] array = text.Split(','); for (int i = 0; i < array.Length; i++) { string text3 = array[i].Trim(); if (text3.Length > 0 && text2.IndexOf(text3, StringComparison.OrdinalIgnoreCase) >= 0) { reason = "排除名单:" + text3; return true; } } } return false; } private static bool HasPellets(BulletWeapon weapon) { ArchetypeDataBlock archetypeData = ((ItemEquippable)weapon).ArchetypeData; if (archetypeData != null) { return archetypeData.ShotgunBulletCount > 0; } return false; } private static string CollectNames(BulletWeapon weapon, string publicName) { StringBuilder stringBuilder = new StringBuilder(160); stringBuilder.Append(publicName ?? "").Append('|'); try { ItemDataBlock itemDataBlock = ((Item)weapon).ItemDataBlock; if (itemDataBlock != null) { stringBuilder.Append(itemDataBlock.publicName).Append('|'); } ArchetypeDataBlock archetypeData = ((ItemEquippable)weapon).ArchetypeData; if (archetypeData != null) { stringBuilder.Append(((GameDataBlockBase)(object)archetypeData).name).Append('|'); } GearPartHolder gearPartHolder = ((ItemEquippable)weapon).GearPartHolder; if ((Object)(object)gearPartHolder != (Object)null) { GearFrontPartDataBlock frontData = gearPartHolder.FrontData; if (frontData != null) { stringBuilder.Append(((GameDataBlockBase)(object)frontData).name).Append('|'); } GearStockPartDataBlock stockData = gearPartHolder.StockData; if (stockData != null) { stringBuilder.Append(((GameDataBlockBase)(object)stockData).name).Append('|'); } } } catch (Exception e) { Plugin.HookError("读取武器名字", e); } return stringBuilder.ToString(); } } [HarmonyPatch(typeof(ItemEquippable), "TryTriggerReloadAnimationSequence")] internal static class Patch_TryTrigger { [HarmonyPrefix] private static void Prefix(ItemEquippable __instance) { try { ReloadTracker.OnReloadRequested(__instance); } catch (Exception e) { Plugin.HookError("换弹开始判定", e); } } [HarmonyPostfix] private static void Postfix(ItemEquippable __instance, bool __result) { try { ReloadTracker.OnReloadTriggered(__instance, __result); } catch (Exception e) { Plugin.HookError("换弹开始确认", e); } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class Patch_ReloadTime { [HarmonyPostfix] private static void Postfix(BulletWeapon __instance, ref float __result) { try { __result = ReloadTracker.ScaleReloadTime(((Il2CppObjectBase)__instance).Pointer, __result); } catch (Exception e) { Plugin.HookError("换弹时长", e); } } } [HarmonyPatch(typeof(ItemEquippable), "DoItemAnimationSequence")] internal static class Patch_Sequence { [HarmonyPrefix] private static void Prefix(ItemEquippable __instance, List sequence, ref float timeScale) { try { ReloadTracker.OnSequenceStarting(__instance, sequence, ref timeScale); } catch (Exception e) { Plugin.HookError("换弹序列", e); } } } [HarmonyPatch(typeof(BulletWeapon), "ClipIsFull")] internal static class Patch_ClipFull { [HarmonyPostfix] private static void Postfix(BulletWeapon __instance, ref bool __result) { try { __result = ReloadTracker.IsClipFull(__instance, __result); } catch (Exception e) { Plugin.HookError("+1(ClipIsFull)", e); } } } [HarmonyPatch(typeof(PlayerAmmoStorage), "GetClipBulletsFromPack")] internal static class Patch_ClipFromPack { [HarmonyPriority(600)] [HarmonyPrefix] private static void Prefix(PlayerAmmoStorage __instance, ref int currentClip, AmmoType ammoType, out bool __state) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) __state = false; ReloadTracker.EnterRefill(); try { __state = ReloadTracker.BeforeClipFromPack(__instance, ref currentClip, ammoType); } catch (Exception e) { Plugin.HookError("+1(GetClipBulletsFromPack 前缀)", e); } } [HarmonyPriority(600)] [HarmonyPostfix] private static void Postfix(PlayerAmmoStorage __instance, AmmoType ammoType, int currentClip, ref int __result, bool __state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) try { ReloadTracker.AfterClipFromPack(__instance, ammoType, currentClip, ref __result, __state); } catch (Exception e) { Plugin.HookError("+1(GetClipBulletsFromPack 后缀)", e); } } [HarmonyFinalizer] private static void Finalizer() { try { ReloadTracker.LeaveRefill(); } catch (Exception e) { Plugin.HookError("+1(GetClipBulletsFromPack 收尾)", e); } } } [HarmonyPatch(typeof(BulletWeapon), "GetCurrentClipRel")] internal static class Patch_ClipRel { [HarmonyPostfix] private static void Postfix(BulletWeapon __instance, ref float __result) { try { ReloadTracker.ClampClipRel(ref __result); } catch (Exception e) { Plugin.HookError("+1(GetCurrentClipRel)", e); } } } [BepInPlugin("TacticalReload", "TacticalReload", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { public const string GUID = "TacticalReload"; public const string VERSION = "1.0.0"; public const string TAG = "[TacticalReload] "; public const string RealisticReloadGuid = "RealisticReloadV2.GUID"; internal static bool RealisticReloadLoaded; internal const float TimeMult = 0.9f; internal static ManualLogSource L; internal static ConfigEntry Debug; internal static bool PlusOneAvailable; private const int MaxHookErrors = 30; private static int _hookErrors; private static bool _shutDown; private static Harmony _harmony; internal static bool PlusOneActive { get { if (PlusOneAvailable) { return !Dead; } return false; } } internal static bool Dead { get; private set; } public override void Load() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown L = ((BasePlugin)this).Log; Debug = ((BasePlugin)this).Config.Bind("9-Debug", "LogReloads", false, "每次换弹在 BepInEx 的 LogOutput.log 里打印一行判定和结果。"); _harmony = new Harmony("TacticalReload"); if (ApplyPatches(_harmony)) { RealisticReloadLoaded = IsPluginLoaded("RealisticReloadV2.GUID"); ((BasePlugin)this).AddComponent(); L.LogInfo((object)("[TacticalReload] v1.0.0 已载入。战术换弹耗时 x" + 0.9f.ToString("0.##") + ",+1 开(那一发从备弹扣,弹匣满也能再补一发),排除:霰弹枪、左轮、炮台。")); if (RealisticReloadLoaded) { L.LogInfo((object)"[TacticalReload] 检测到 RealisticReload。战斗中它丢弃弹匣时,加速照常生效,膛内那一发照常保留(不扣备弹)。"); } } } private static bool IsPluginLoaded(string guid) { try { return IL2CPPChainloader.Instance != null && ((BaseChainloader)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey(guid); } catch (Exception ex) { L.LogWarning((object)("[TacticalReload] 查询插件 " + guid + " 是否加载时出错(按未加载处理):" + ex.Message)); return false; } } private static bool ApplyPatches(Harmony harmony) { if (!Apply(harmony, typeof(Patch_TryTrigger)) || !Apply(harmony, typeof(Patch_ReloadTime))) { harmony.UnpatchSelf(); return false; } PlusOneAvailable = true; PlusOneAvailable &= Apply(harmony, typeof(Patch_ClipFromPack)); PlusOneAvailable &= Apply(harmony, typeof(Patch_ClipFull)); PlusOneAvailable &= Apply(harmony, typeof(Patch_ClipRel)); if (!PlusOneAvailable) { L.LogWarning((object)"[TacticalReload] +1 相关的补丁没有全部挂上,本次运行关闭 +1,只保留变速。"); } Apply(harmony, typeof(Patch_Sequence)); return true; } private static bool Apply(Harmony harmony, Type patchClass) { try { harmony.PatchAll(patchClass); return true; } catch (Exception ex) { L.LogError((object)("[TacticalReload] 补丁 " + patchClass.Name + " 挂载失败:" + ex.Message)); return false; } } internal static void HookError(string where, Exception e) { _hookErrors++; if (_hookErrors >= 30) { if (!Dead) { Dead = true; L.LogError((object)("[TacticalReload] 钩子反复出错(已达 " + _hookErrors + " 次),自动停用。最后一次:" + where + " " + e)); } } else if (_hookErrors <= 5 || _hookErrors % 10 == 0) { L.LogWarning((object)("[TacticalReload] " + where + " 出错(第 " + _hookErrors + " 次):" + e.Message)); } } internal static void ShutDown() { if (_shutDown) { return; } _shutDown = true; try { _harmony.UnpatchSelf(); } catch (Exception ex) { L.LogError((object)("[TacticalReload] 卸载补丁失败:" + ex.Message)); } } } public static class ReloadRules { public static bool HasChamberedRound(int clip) { return clip > 0; } public static int MaxFireable(int cap) { return cap + 1; } public static bool IsFull(int clip, int cap) { return clip >= cap + 1; } public static bool IsTacticalReload(int clip) { return clip > 0; } public static bool ClipIsFull(bool active, bool localOwner, bool excluded, int clip, int cap, bool vanillaFull) { if (!active || !localOwner || excluded || cap < 1) { return vanillaFull; } return IsFull(clip, cap); } public static bool PlanRefill(bool active, bool nested, bool localStorage, bool excluded, int incomingClip, int weaponClip, out int argument) { argument = incomingClip; if (!active || nested || !localStorage || excluded) { return false; } if (incomingClip <= 0 || incomingClip != weaponClip) { return false; } argument = weaponClip - 1; return true; } public static int RefillResult(int vanillaResult, bool hidden) { if (!hidden) { return vanillaResult; } return vanillaResult + 1; } public static float ScaleReloadTime(float reloadTime, float mult) { if (!(mult > 0f)) { return reloadTime; } return reloadTime * mult; } public static float ClampClipRel(float rel, bool active) { if (!active || !(rel > 1f)) { return rel; } return 1f; } } internal sealed class TrackedReload { public BulletWeapon Weapon; public IntPtr Ptr; public string Name = ""; public int ClipAtStart; public int BaseMax; public int ReserveAtStart; public bool Tactical; public bool SequenceSeen; public string SpeedSource = ""; public string PartName = ""; public string SequenceInfo = ""; public float StartTime; } internal static class ReloadTracker { private const string TAG = "[TacticalReload] "; private static TrackedReload _current; private static int _refillDepth; private static string _refillName = ""; private static int _clipBefore; private static int _reserveBefore = -1; public static void EnterRefill() { _refillDepth++; } public static void LeaveRefill() { if (_refillDepth > 0) { _refillDepth--; } } public static void OnReloadRequested(ItemEquippable item) { if (Plugin.Dead) { _current = null; return; } BulletWeapon val = ((Il2CppObjectBase)item).TryCast(); if ((Object)(object)val == (Object)null) { return; } PlayerAgent owner = ((Item)val).Owner; if ((Object)(object)owner == (Object)null || !((Agent)owner).IsLocallyOwned || ((ItemEquippable)val).IsReloading) { return; } IntPtr pointer = ((Il2CppObjectBase)val).Pointer; _current = null; string publicName = ((Item)val).PublicName; if (Exclusions.IsExcluded(val, publicName, out var reason)) { if (Plugin.Debug.Value) { Plugin.L.LogInfo((object)("[TacticalReload] 不处理(" + reason + "):" + publicName)); } return; } int currentClip = ((ItemEquippable)val).GetCurrentClip(); _current = new TrackedReload { Weapon = val, Ptr = pointer, Name = publicName, ClipAtStart = currentClip, BaseMax = ((ItemEquippable)val).GetMaxClip(), ReserveAtStart = ReserveOf(val), Tactical = ReloadRules.IsTacticalReload(currentClip), PartName = GetPartName(val), StartTime = Time.time }; } public static void OnReloadTriggered(ItemEquippable item, bool started) { TrackedReload current = _current; if (current == null || current.Ptr != ((Il2CppObjectBase)item).Pointer) { return; } if (started) { current.StartTime = Time.time; if (Plugin.Debug.Value) { string text = "[TacticalReload] " + (current.Tactical ? "战术换弹开始:" : "空仓换弹(走原版):") + current.Name + " 弹匣 " + current.ClipAtStart + "/" + current.BaseMax + " 备弹 " + current.ReserveAtStart + " 部件=" + current.PartName; if (current.Tactical && current.SequenceInfo.Length > 0) { text = text + " " + current.SequenceInfo; } Plugin.L.LogInfo((object)text); } } else if (!item.IsReloading) { _current = null; } } public static float ScaleReloadTime(IntPtr ptr, float reloadTime) { TrackedReload current = _current; if (current == null || !current.Tactical || current.Ptr != ptr) { return reloadTime; } return ReloadRules.ScaleReloadTime(reloadTime, 0.9f); } public static void OnSequenceStarting(ItemEquippable item, List sequence, ref float timeScale) { TrackedReload current = _current; if (current == null || !current.Tactical || current.SequenceSeen || current.Ptr != ((Il2CppObjectBase)item).Pointer) { return; } current.SequenceSeen = true; BulletWeapon weapon = current.Weapon; float num = 0.9f; float num2 = 0f; int num3 = 0; if (sequence != null) { num3 = sequence.Count; for (int i = 0; i < num3; i++) { WeaponAnimSequenceItem val = sequence[i]; if (val != null && val.TriggerTime > num2) { num2 = val.TriggerTime; } } } float reloadTime = ((ItemEquippable)weapon).ReloadTime; string text; if (num2 <= 0f || reloadTime <= 0f || num <= 0f) { text = "无法判定"; } else { float num4 = reloadTime / num2; float b = num4 / num; if (Near(timeScale, num4)) { text = "ReloadTime"; } else if (Near(timeScale, b)) { timeScale = ReloadRules.ScaleReloadTime(timeScale, num); text = "timeScale(后备)"; } else { text = "未知公式-未加速"; } } current.SpeedSource = text; current.SequenceInfo = "事件=" + num3 + " 末事件=" + num2.ToString("0.###") + " ReloadTime=" + reloadTime.ToString("0.###") + " timeScale=" + timeScale.ToString("0.###") + " 是换弹序列=" + IsReloadSequence(item, sequence) + " 加速来源=" + text; if (num > 0f) { current.SequenceInfo = current.SequenceInfo + " 原版耗时=" + (reloadTime / num).ToString("0.##"); } } private static string GetPartName(BulletWeapon weapon) { try { GearPartHolder gearPartHolder = ((ItemEquippable)weapon).GearPartHolder; if ((Object)(object)gearPartHolder == (Object)null) { return ""; } GearFrontPartDataBlock frontData = gearPartHolder.FrontData; if (frontData != null) { List reloadSequence = frontData.ReloadSequence; if (reloadSequence != null && reloadSequence.Count > 0) { return ((GameDataBlockBase)(object)frontData).name ?? ""; } } GearStockPartDataBlock stockData = gearPartHolder.StockData; return (stockData != null) ? (((GameDataBlockBase)(object)stockData).name ?? "") : ""; } catch (Exception e) { Plugin.HookError("读取部件名", e); return ""; } } private static bool Near(float a, float b) { return Math.Abs(a - b) <= 0.01f * Math.Max(1f, Math.Abs(b)); } private static bool IsReloadSequence(ItemEquippable item, List sequence) { if (sequence == null) { return false; } GearPartHolder gearPartHolder = item.GearPartHolder; if ((Object)(object)gearPartHolder == (Object)null) { return false; } List val = null; GearFrontPartDataBlock frontData = gearPartHolder.FrontData; if (frontData != null) { List reloadSequence = frontData.ReloadSequence; if (reloadSequence != null && reloadSequence.Count > 0) { val = reloadSequence; } } if (val == null) { GearStockPartDataBlock stockData = gearPartHolder.StockData; if (stockData != null) { val = stockData.ReloadSequence; } } if (val != null) { return ((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)sequence).Pointer; } return false; } public static bool IsClipFull(BulletWeapon weapon, bool vanillaFull) { if (!Plugin.PlusOneActive) { return vanillaFull; } PlayerAgent owner = ((Item)weapon).Owner; if ((Object)(object)owner == (Object)null || !((Agent)owner).IsLocallyOwned) { return vanillaFull; } int clipSize = ((ItemEquippable)weapon).ClipSize; int currentClip = ((ItemEquippable)weapon).GetCurrentClip(); if (clipSize < 1 || currentClip < clipSize) { return vanillaFull; } bool excluded = IsExcluded(weapon); return ReloadRules.ClipIsFull(active: true, localOwner: true, excluded, currentClip, clipSize, vanillaFull); } public static void ClampClipRel(ref float rel) { rel = ReloadRules.ClampClipRel(rel, Plugin.PlusOneActive); } public static bool BeforeClipFromPack(PlayerAmmoStorage storage, ref int currentClip, AmmoType ammoType) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) bool plusOneActive = Plugin.PlusOneActive; int refillDepth = _refillDepth; bool flag = IsLocalStorage(storage); BulletWeapon val = (flag ? FindWieldedBulletWeapon() : null); int num = (((Object)(object)val != (Object)null && ((ItemEquippable)val).AmmoType == ammoType) ? ((ItemEquippable)val).GetCurrentClip() : int.MinValue); bool excluded = (Object)(object)val != (Object)null && currentClip > 0 && currentClip == num && IsExcluded(val); int argument; bool flag2 = ReloadRules.PlanRefill(plusOneActive, refillDepth > 1, flag, excluded, currentClip, num, out argument); if (refillDepth > 1) { return false; } _refillName = ""; _reserveBefore = -1; if (!flag2) { return false; } currentClip = argument; _refillName = ((Item)val).PublicName ?? ""; _clipBefore = num; _reserveBefore = ReserveOf(storage, ammoType); if (Plugin.Debug.Value) { Plugin.L.LogInfo((object)("[TacticalReload] 补弹:" + _refillName + " 传给游戏 " + argument + "(弹匣实际 " + num + "),让原版连膛内那一发一起补;备弹 " + _reserveBefore)); } return true; } public static void AfterClipFromPack(PlayerAmmoStorage storage, AmmoType ammoType, int currentClip, ref int result, bool hidden) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) int num = result; result = ReloadRules.RefillResult(result, hidden); if (hidden && Plugin.Debug.Value) { int num2 = ReserveOf(storage, ammoType); bool flag = currentClip == 0 && _clipBefore > 0; if (_reserveBefore < 0) { Plugin.L.LogInfo((object)("[TacticalReload] 补弹结果:" + _refillName + " 原版算出 " + num + ",膛内那一发加回 → " + result + (flag ? "(弹匣被别的 MOD 丢弃后装填,膛内那一发保留)" : ""))); return; } int num3 = _clipBefore + _reserveBefore; int num4 = result + num2; int num5 = (flag ? (num3 - (_clipBefore - 1)) : num3); string text = ((num4 == num5) ? "" : (" [注意:总弹药 " + num3 + " -> " + num4 + ",预期 " + num5 + "]")); Plugin.L.LogInfo((object)("[TacticalReload] 补弹结果:" + _refillName + " 原版算出 " + num + ",膛内那一发加回 → " + result + ";备弹 " + _reserveBefore + " -> " + num2 + (flag ? "(弹匣被别的 MOD 丢弃后装填,膛内那一发保留)" : "") + text)); } } private static bool IsLocalStorage(PlayerAmmoStorage storage) { if (storage == null) { return false; } PlayerBackpack localBackpack = PlayerBackpackManager.LocalBackpack; if (localBackpack == null) { return false; } PlayerAmmoStorage ammoStorage = localBackpack.AmmoStorage; if (ammoStorage != null) { return ((Il2CppObjectBase)ammoStorage).Pointer == ((Il2CppObjectBase)storage).Pointer; } return false; } private static BulletWeapon FindWieldedBulletWeapon() { PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent(); if ((Object)(object)localPlayerAgent == (Object)null) { return null; } PlayerInventoryBase inventory = localPlayerAgent.Inventory; if ((Object)(object)inventory == (Object)null) { return null; } ItemEquippable wieldedItem = inventory.WieldedItem; if ((Object)(object)wieldedItem == (Object)null || (Object)(object)wieldedItem == (Object)null) { return null; } BulletWeapon val = ((Il2CppObjectBase)wieldedItem).TryCast(); if (!((Object)(object)val != (Object)null) || !((Object)(object)val != (Object)null)) { return null; } return val; } private static bool IsExcluded(BulletWeapon weapon) { string reason; return Exclusions.IsExcluded(weapon, ((Item)weapon).PublicName, out reason); } public static void Tick() { _refillDepth = 0; if (Plugin.Dead) { _current = null; Plugin.ShutDown(); return; } TrackedReload current = _current; if (current != null) { BulletWeapon weapon = current.Weapon; if ((Object)(object)weapon == (Object)null) { Finish("武器已销毁"); } else if (!((ItemEquippable)weapon).m_isWielded) { Finish("已切走"); } else if (!((ItemEquippable)weapon).IsReloading) { Finish("完成"); } } } private static void Finish(string reason) { TrackedReload current = _current; if (current != null) { _current = null; if (Plugin.Debug.Value) { BulletWeapon weapon = current.Weapon; bool num = (Object)(object)weapon != (Object)null; string text = (num ? ((ItemEquippable)weapon).GetCurrentClip().ToString() : "?"); string text2 = (num ? ReserveOf(weapon).ToString() : "?"); Plugin.L.LogInfo((object)("[TacticalReload] 换弹结束(" + reason + "):" + current.Name + " 耗时=" + (Time.time - current.StartTime).ToString("0.00") + "s 弹匣=" + text + "/" + current.BaseMax + " 备弹=" + current.ReserveAtStart + " -> " + text2 + " 加速来源=" + (current.Tactical ? current.SpeedSource : "无(空仓)"))); } } } private static int ReserveOf(BulletWeapon weapon) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) PlayerBackpack localBackpack = PlayerBackpackManager.LocalBackpack; PlayerAmmoStorage val = ((localBackpack != null) ? localBackpack.AmmoStorage : null); if (val == null) { return -1; } return ReserveOf(val, ((ItemEquippable)weapon).AmmoType); } private static int ReserveOf(PlayerAmmoStorage storage, AmmoType ammoType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) InventorySlotAmmo inventorySlotAmmo = storage.GetInventorySlotAmmo(ammoType); if (inventorySlotAmmo == null) { return -1; } return inventorySlotAmmo.BulletsInPack; } } public sealed class ReloadWatcher : MonoBehaviour { private void Update() { try { ReloadTracker.Tick(); } catch (Exception e) { Plugin.HookError("换弹结束检测", e); } if (Plugin.Dead) { ((Behaviour)this).enabled = false; } } }