using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using HarmonyLib; using RocketLib.Collections; using UnityEngine; using UnityModManagerNet; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("OnlyPockettedSpecialAmmo")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OnlyPockettedSpecialAmmo")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("c5c10f8b-5ece-40ed-8ef2-56472c25fb57")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")] namespace OnlyPockettedSpecialAmmo; internal static class Main { public static ModEntry mod; public static bool enabled; public static Settings settings; private static List pockettedList = PockettedSpecial.SpecialAmmo.ToList(); private static bool Load(ModEntry modEntry) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown modEntry.OnToggle = OnToggle; modEntry.OnGUI = OnGUI; modEntry.OnSaveGUI = OnSaveGUI; settings = ModSettings.Load(modEntry); mod = modEntry; Harmony val = new Harmony(modEntry.Info.Id); try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); val.PatchAll(executingAssembly); } catch (Exception ex) { mod.Logger.Log("Failed to Patch Harmony !\n" + ex.ToString()); } return true; } private static void OnGUI(ModEntry modEntry) { settings.infinity = GUILayout.Toggle(settings.infinity, "Infinity mode", (GUILayoutOption[])(object)new GUILayoutOption[0]); } private static bool OnToggle(ModEntry modEntry, bool value) { enabled = value; return true; } internal static void Log(object str) { mod.Logger.Log(str.ToString()); } private static void OnSaveGUI(ModEntry modEntry) { ((ModSettings)settings).Save(modEntry); } internal static PockettedSpecialAmmoType GetRandomPockettedSpecialAmmo() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return IEnumerableExtensions.RandomElement((IEnumerable)pockettedList); } } public class Settings : ModSettings { public bool infinity; public override void Save(ModEntry modEntry) { ModSettings.Save(this, modEntry); } } [HarmonyPatch(typeof(BroBase), "Start")] internal class SetSpecialAmmo_Patch { private static void Postfix(BroBase __instance) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!Main.enabled) { return; } try { ((TestVanDammeAnim)__instance).SpecialAmmo = 0; ((TestVanDammeAnim)__instance).originalSpecialAmmo = 0; HarmonyExtensions.SetFieldValue((object)__instance, "_specialAmmo", 0); ((TestVanDammeAnim)__instance).PickupPockettableAmmo(Main.GetRandomPockettedSpecialAmmo()); } catch (Exception ex) { Main.Log("Failed to assign Pocketted special ammo !\n" + ex); } } } [HarmonyPatch(typeof(TestVanDammeAnim), "ResetSpecialAmmo")] internal class AddPockettedSpecialOnAmmoCrate_Patch { private static void Postfix(TestVanDammeAnim __instance) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!Main.enabled) { return; } try { if (Main.settings.infinity) { __instance.PickupPockettableAmmo(Main.GetRandomPockettedSpecialAmmo()); } } catch (Exception ex) { Main.Log("Failed to add special ammo on reset !\n" + ex); } } } [HarmonyPatch(typeof(TheBrolander), "ResetSpecialAmmo")] internal class AddPockettedSpecialOnAmmoCrateFor_TheBrolander_Patch { private static void Postfix(TheBrolander __instance) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!Main.enabled) { return; } try { if (Main.settings.infinity) { ((TestVanDammeAnim)__instance).PickupPockettableAmmo(Main.GetRandomPockettedSpecialAmmo()); } } catch (Exception ex) { Main.Log("Failed to add special ammo on reset for The Brolander !\n" + ex); } } } [HarmonyPatch(typeof(TheBrolander), "Start")] internal class SetSpecialAmmoFor_TheBrolander_Patch { private static void Postfix(TheBrolander __instance) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!Main.enabled) { return; } try { __instance.maxSpecialAmmo = 0; ((TestVanDammeAnim)__instance).SpecialAmmo = 0; ((TestVanDammeAnim)__instance).originalSpecialAmmo = 0; HarmonyExtensions.SetFieldValue((object)__instance, "_specialAmmo", 0); ((TestVanDammeAnim)__instance).PickupPockettableAmmo(Main.GetRandomPockettedSpecialAmmo()); } catch (Exception ex) { Main.Log("Failed to assign Pocketted special ammo for The Brolander !\n" + ex); } } }