Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Ammo Tin v1.1.0
AmmoTin.dll
Decompiled 2 years agousing System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LethalCompanyAmmoTin")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LethalCompanyAmmoTin")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("85d63194-36a9-4b57-9db1-9b88fba8b04e")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace LethalCompanyAmmoTin; [BepInPlugin("htd.lethalcompany.ammotin", "Ammo Tin", "1.0.0.0")] public class ModAmmoTinMain : BaseUnityPlugin { [HarmonyPatch(typeof(ShotgunItem), "ReloadedGun")] private static class ShotgunItemReloadedGunPatches { private static void Postfix(ShotgunItem __instance, ref bool __result) { if (__result) { return; } for (int i = 0; i < ((GrabbableObject)__instance).playerHeldBy.ItemSlots.Length; i++) { if ((Object)(object)((GrabbableObject)__instance).playerHeldBy.ItemSlots[i] != (Object)null && ((GrabbableObject)__instance).playerHeldBy.ItemSlots[i].itemProperties.itemName == "Ammo Tin" && ((GrabbableObject)__instance).playerHeldBy.ItemSlots[i].insertedBattery.charge >= shotgunDrainCost) { Battery insertedBattery = ((GrabbableObject)__instance).playerHeldBy.ItemSlots[i].insertedBattery; insertedBattery.charge -= shotgunDrainCost; __result = true; __instance.ammoSlotToUse = 100; break; } } } } [HarmonyPatch(typeof(PlayerControllerB), "DestroyItemInSlot")] private static class PlayerControllerBDestroyItemInSlotPatches { private static bool Prefix(PlayerControllerB __instance, ref int itemSlot) { if (itemSlot == 100) { if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (Object)(object)NetworkManager.Singleton == (Object)null || NetworkManager.Singleton.ShutdownInProgress) { return true; } return false; } return true; } } public const string Version = "1.0.0.0"; public const string ModName = "Ammo Tin"; public const string GUID = "htd.lethalcompany.ammotin"; private Harmony _Harmony = new Harmony("htd.lethalcompany.ammotin"); public static ManualLogSource Log; public static AssetBundle AmmoTinAssets; public static int maxShotgunReloads = 8; public static float shotgunDrainCost = 1f / (float)maxShotgunReloads; private void Awake() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); AmmoTinAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "ammotin")); if ((Object)(object)AmmoTinAssets == (Object)null) { Log.LogError((object)"Failed to load custom assets."); return; } Item val = AmmoTinAssets.LoadAsset<Item>("Assets/Prefab/AmmoTin.asset"); Item val2 = AmmoTinAssets.LoadAsset<Item>("Assets/Prefab/AmmoTinScrap.asset"); NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab); bool value = ((BaseUnityPlugin)this).Config.Bind<bool>("2-Scrap", "Allow Ammo Tin to be Scrap", false, "Setting this to true will add it to scrap lists for all moons.").Value; int value2 = ((BaseUnityPlugin)this).Config.Bind<int>("2-Scrap", "Ammo Tin Default Rarity", 5, "What Weighted Value does this have.").Value; int value3 = ((BaseUnityPlugin)this).Config.Bind<int>("2-Scrap", "Ammo Tin Min", 65, "Min Scrap value.").Value; int value4 = ((BaseUnityPlugin)this).Config.Bind<int>("2-Scrap", "Ammo Tin Max", 215, "Max Scrap value.").Value; int value5 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin Experimentation Rarity", -1, "What Weighted Value does this have for Moon Experimentation If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; int value6 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin Assurance Rarity", -1, "What Weighted Value does this have for Moon Assurance If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; int value7 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin Vow Rarity", -1, "What Weighted Value does this have for Moon Vow If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; int value8 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin Offense Rarity", -1, "What Weighted Value does this have for Moon Offense If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; int value9 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin March Rarity", -1, "What Weighted Value does this have for Moon March If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; int value10 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin Adamance Rarity", -1, "What Weighted Value does this have for Moon Adamance If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; int value11 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin Rend Rarity", -1, "What Weighted Value does this have for Moon Rend If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; int value12 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin Dine Rarity", -1, "What Weighted Value does this have for Moon Dine If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; int value13 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin Titan Rarity", -1, "What Weighted Value does this have for Moon Titan If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; int value14 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin Embrion Rarity", -1, "What Weighted Value does this have for Moon Embrion If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; int value15 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin Artifice Rarity", -1, "What Weighted Value does this have for Moon Artifice If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; int value16 = ((BaseUnityPlugin)this).Config.Bind<int>("3-Moon Rarity", "Ammo Tin Modded Moons Rarity", -1, "What Weighted Value does this have for Modded Moons If set to -1 defualt is used, if set to 0 it won't spawn here.").Value; if (value) { val2.minValue = value3; val2.maxValue = value4; if (value5 != 0) { Items.RegisterScrap(val2, (value5 < 0) ? value2 : value5, (LevelTypes)4); } if (value6 != 0) { Items.RegisterScrap(val2, (value6 < 0) ? value2 : value6, (LevelTypes)8); } if (value7 != 0) { Items.RegisterScrap(val2, (value7 < 0) ? value2 : value7, (LevelTypes)16); } if (value8 != 0) { Items.RegisterScrap(val2, (value8 < 0) ? value2 : value8, (LevelTypes)32); } if (value9 != 0) { Items.RegisterScrap(val2, (value9 < 0) ? value2 : value9, (LevelTypes)64); } if (value10 != 0) { Items.RegisterScrap(val2, (value10 < 0) ? value2 : value10, (LevelTypes)2048); } if (value11 != 0) { Items.RegisterScrap(val2, (value11 < 0) ? value2 : value11, (LevelTypes)128); } if (value12 != 0) { Items.RegisterScrap(val2, (value12 < 0) ? value2 : value12, (LevelTypes)256); } if (value13 != 0) { Items.RegisterScrap(val2, (value13 < 0) ? value2 : value13, (LevelTypes)512); } if (value14 != 0) { Items.RegisterScrap(val2, (value14 < 0) ? value2 : value14, (LevelTypes)8192); } if (value15 != 0) { Items.RegisterScrap(val2, (value15 < 0) ? value2 : value15, (LevelTypes)4096); } if (value16 != 0) { Items.RegisterScrap(val2, (value16 < 0) ? value2 : value16, (LevelTypes)1024); } } bool value17 = ((BaseUnityPlugin)this).Config.Bind<bool>("1-Shop", "Ammo Tin In Shop", true, "Is it possible to buy the Ammo Tin from the shop.").Value; int value18 = ((BaseUnityPlugin)this).Config.Bind<int>("1-Shop", "Ammo Tin Price", 600, "Price of the Ammo Tin in the shop.").Value; int num = value18; if (value17) { TerminalNode val3 = AmmoTinAssets.LoadAsset<TerminalNode>("Assets/Terminal/WI.asset"); Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val3, num); } maxShotgunReloads = ((BaseUnityPlugin)this).Config.Bind<int>("0-Reloads", "Total Shotgun Reloads from Full Ammo Tin", 8, "If an Ammo Tin is full, this is the possible amount of reloads you can get.").Value; shotgunDrainCost = 1f / (float)maxShotgunReloads; _Harmony.PatchAll(); ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; } }