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 ChainsawBasher v1.1.0
plugins/ChainsawBasher/ChainsawBasher.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ChainsawBasher.Configs; using ChainsawBasher.NetcodePatcher; using ChainsawBasher.Patches; using ChainsawBasher.Util.Extensions; using ChainsawBasher.Weapons; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ChainsawBasher")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("ChainsawBasher for Lethal Company.")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("ChainsawBasher")] [assembly: AssemblyTitle("ChainsawBasher")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } 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 ChainsawBasher { [BepInPlugin("ChainsawBasher", "ChainsawBasher", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("ChainsawBasher"); internal static ManualLogSource Logger; public static ChainsawBasherConfig ModConfig { get; private set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; ModConfig = new ChainsawBasherConfig(((BaseUnityPlugin)this).Config); Assets.PopulateAssets(); Item val = Assets.MainAssetBundle.LoadAsset<Item>("ChainsawBasherObj"); Utilities.FixMixerGroups(val.spawnPrefab); NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); TerminalNode terminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("cbTerminalNode"); RegisterShopItemWithConfig(ModConfig.ConfigChainsawBasherEnabled.Value, ModConfig.ConfigChainsawBasherScrapEnabled.Value, val, terminalNode, ModConfig.ConfigChainsawBasherCost.Value, ModConfig.ConfigChainsawBasherScrapSpawnWeights.Value); InitializeNetworkBehaviours(); _harmony.PatchAll(typeof(ShovelPatch)); Logger.LogInfo((object)"Plugin ChainsawBasher is loaded!"); } private static void RegisterScrapWithConfig(bool enabled, string configMoonRarity, Item scrap) { if (enabled) { var (dictionary, dictionary2) = ConfigParsing(configMoonRarity); Items.RegisterScrap(scrap, dictionary, dictionary2); } else { Items.RegisterScrap(scrap, 0, (LevelTypes)(-1)); } } private static void RegisterShopItemWithConfig(bool enabledShopItem, bool enabledScrap, Item item, TerminalNode terminalNode, int itemCost, string configMoonRarity) { if (enabledShopItem) { Items.RegisterShopItem(item, (TerminalNode)null, (TerminalNode)null, terminalNode, itemCost); } if (enabledScrap) { RegisterScrapWithConfig(enabled: true, configMoonRarity, item); } } private static (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ConfigParsing(string configMoonRarity) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>(); Dictionary<string, int> dictionary2 = new Dictionary<string, int>(); foreach (string item in from s in configMoonRarity.Split(',') select s.Trim()) { string[] array = item.Split(':'); if (array.Length != 2) { continue; } string text = array[0]; if (int.TryParse(array[1], out var result)) { if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2)) { dictionary[result2] = result; Logger.LogInfo((object)$"Registered spawn rate for level type {result2} to {result}"); } else { dictionary2[text] = result; Logger.LogInfo((object)$"Registered spawn rate for custom level type {text} to {result}"); } } } return (dictionary, dictionary2); } private void InitializeNetworkBehaviours() { IEnumerable<Type> enumerable; try { enumerable = Assembly.GetExecutingAssembly().GetTypes(); } catch (ReflectionTypeLoadException ex) { enumerable = ex.Types.Where((Type t) => t != null); } foreach (Type item in enumerable) { MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array = methods; foreach (MethodInfo methodInfo in array) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } } public static class Assets { public static AssetBundle MainAssetBundle; public static void PopulateAssets() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); MainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "chainsawbasherassets")); if ((Object)(object)MainAssetBundle == (Object)null) { Plugin.Logger.LogError((object)"Failed to load custom assets."); } } } public static class PluginInfo { public const string PLUGIN_GUID = "ChainsawBasher"; public const string PLUGIN_NAME = "ChainsawBasher"; public const string PLUGIN_VERSION = "1.1.0"; } } namespace ChainsawBasher.Util.Extensions { public static class ShovelExtensions { public static int CriticalHit(int force, Random random, int critChance) { if (random.Next(0, 100) < Math.Clamp(critChance, 0, 99)) { Plugin.Logger.LogInfo((object)"Critical Hit!"); return force * 2; } return force; } } } namespace ChainsawBasher.Patches { [HarmonyPatch(typeof(Shovel))] internal static class ShovelPatch { public static Random random; [HarmonyPatch("HitShovel")] [HarmonyPrefix] public static void CritHitShovelPre(Shovel __instance) { if (random == null) { if ((Object)(object)StartOfRound.Instance != (Object)null) { random = new Random(StartOfRound.Instance.randomMapSeed + 85); } else { random = new Random(69); } } if (__instance is ChainsawBasherWeapon chainsawBasherWeapon) { chainsawBasherWeapon.defaultForce = ((Shovel)chainsawBasherWeapon).shovelHitForce; if (chainsawBasherWeapon.critPossible && Plugin.ModConfig.ConfigAllowCrits.Value) { ((Shovel)chainsawBasherWeapon).shovelHitForce = ShovelExtensions.CriticalHit(((Shovel)chainsawBasherWeapon).shovelHitForce, random, chainsawBasherWeapon.critChance); } } } [HarmonyPatch("HitShovel")] [HarmonyPostfix] public static void CritHitShovelPost(Shovel __instance) { if (__instance is ChainsawBasherWeapon chainsawBasherWeapon) { ((Shovel)chainsawBasherWeapon).shovelHitForce = chainsawBasherWeapon.defaultForce; } } } } namespace ChainsawBasher.Configs { public class ChainsawBasherConfig { public ConfigEntry<bool> ConfigAllowCrits { get; private set; } public ConfigEntry<int> ConfigCritChance { get; private set; } public ConfigEntry<bool> ConfigChainsawBasherEnabled { get; private set; } public ConfigEntry<int> ConfigChainsawBasherCost { get; private set; } public ConfigEntry<bool> ConfigChainsawBasherScrapEnabled { get; private set; } public ConfigEntry<string> ConfigChainsawBasherScrapSpawnWeights { get; private set; } public ChainsawBasherConfig(ConfigFile configFile) { ConfigAllowCrits = configFile.Bind<bool>("ChainsawBatcher Options", "ChainsawBatcher | Crits", true, "Enables/Disables crits in the game for the Chainsaw Basher."); ConfigCritChance = configFile.Bind<int>("ChainsawBatcher Options", "ChainsawBatcher | Crits Chance", 25, "Chance of crits in the game for the Chainsaw Basher."); ConfigChainsawBasherEnabled = configFile.Bind<bool>("ChainsawBasher Options", "Chainsaw Basher | Enabled", true, "Enables/Disables the Chainsaw Basher from the shop."); ConfigChainsawBasherCost = configFile.Bind<int>("ChainsawBasher Options", "Chainsaw Basher | Cost", 300, "Cost of Chainsaw Basher."); ConfigChainsawBasherScrapEnabled = configFile.Bind<bool>("ChainsawBasher Options", "Chainsaw Basher Scrap | Enabled", false, "Enables/Disables the Chainsaw Basher from showing up in facility."); ConfigChainsawBasherScrapSpawnWeights = configFile.Bind<string>("ChainsawBasher Options", "Chainsaw Basher Scrap | Spawn Weights", "Modded:50,Vanilla:50", "Spawn Weight of the Chainsaw Basher in moons."); ClearUnusedEntries(configFile); } private void ClearUnusedEntries(ConfigFile configFile) { PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null); dictionary.Clear(); configFile.Save(); } } } namespace ChainsawBasher.Weapons { public class ChainsawBasherWeapon : Shovel { internal int defaultForce; internal bool critPossible = Plugin.ModConfig.ConfigAllowCrits.Value; internal int critChance = Plugin.ModConfig.ConfigCritChance.Value; protected override void __initializeVariables() { ((Shovel)this).__initializeVariables(); } protected internal override string __getTypeName() { return "ChainsawBasherWeapon"; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace ChainsawBasher.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }