Please disclose if any significant portion of your mod was created 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 RebalancedMineshaft v0.3.0
RebalancedMineshaft.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using DunGen; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RebalancedMineshaft")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Rebalances the Mineshaft interior to be more akin to how Factory and Mansion are balanced.")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: AssemblyInformationalVersion("0.3.0+ac4863b37322bd8dde851043a97fd3c1aa2a50dc")] [assembly: AssemblyProduct("RebalancedMineshaft")] [assembly: AssemblyTitle("RebalancedMineshaft")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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 RebalancedMineshaft { internal class RebalancedMineshaftConfig { internal static ConfigEntry<bool> extraScrapSpawn; internal static ConfigEntry<bool> increasedManeaterChance; internal static void Bind(ConfigFile config) { extraScrapSpawn = config.Bind<bool>("Mineshaft", "Spawn 6 extra scrap", true, "Should Mineshaft give 6 extra scrap?"); increasedManeaterChance = config.Bind<bool>("Mineshaft", "Increased Maneater spawn", true, "Should Maneaters have more commonality (1.7x spawn chance) on Mineshaft?\n\n"); } } [BepInPlugin("RebalancedMineshaft", "RebalancedMineshaft", "0.3.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("RebalancedMineshaft"); public static Plugin Instance; private void Awake() { if (Instance == null) { Instance = this; } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RebalancedMineshaft is loaded!"); RebalancedMineshaftConfig.Bind(((BaseUnityPlugin)this).Config); Assets.LoadAssets(); harmony.PatchAll(typeof(MineshaftPatch)); } public static void Log(string msg) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg); } public static void LogDebug(string msg) { ((BaseUnityPlugin)Instance).Logger.LogDebug((object)msg); } public static void LogWarning(string msg) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)msg); } public static void LogError(string msg) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)msg); } } internal static class Assets { internal static AssetBundle assetBundle; internal static Mesh waterTileCollision; internal static void LoadAssets() { try { assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "rebalancedmineshaft")); waterTileCollision = assetBundle.LoadAsset<Mesh>("WaterTileCollision"); assetBundle.Unload(false); } catch (Exception ex) { Plugin.LogError(ex.Message + " - Failed to load mod assets!"); } } } public class MineshaftPatch { private class Functions { internal static GameObject CreateItemSpawn(Transform transform, Vector3 localPosition, string spawn, int range, bool copy) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown GameObject val = new GameObject { name = "AddedItemSpawn_" + spawn }; val.transform.SetParent(transform); val.transform.localPosition = localPosition; RandomScrapSpawn obj = val.AddComponent<RandomScrapSpawn>(); obj.spawnableItems = GetItemGroupFromString(spawn); obj.itemSpawnRange = range; obj.spawnedItemsCopyPosition = copy; return val; } internal static GameObject ConvertToRandomSpawn(Transform transform, float mainWeight, float branchWeight) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown GameObject val = new GameObject(); ((Object)val).name = "AddedRandomSpawn_" + ((Object)transform).name; val.transform.SetParent(transform.parent); transform.SetParent(val.transform); LocalPropSet obj = val.AddComponent<LocalPropSet>(); GameObjectChance val2 = new GameObjectChance(); val2.Value = ((Component)transform).gameObject; val2.MainPathWeight = mainWeight; val2.BranchPathWeight = branchWeight; obj.Props.Weights.Add(val2); obj.PropCount.Min = 0; obj.PropCount.Max = 1; return val; } internal static ItemGroup GetItemGroupFromString(string str) { ItemGroup[] array = Resources.FindObjectsOfTypeAll<ItemGroup>(); foreach (ItemGroup val in array) { if (((Object)val).name == str) { return val; } } return null; } } [HarmonyPatch(typeof(Dungeon), "PreGenerateDungeon")] [HarmonyPostfix] private static void PreGenerateDungeonPostfix(Dungeon __instance) { if (((Object)__instance.DungeonFlow).name == "Level3Flow") { Plugin.LogDebug(((Object)__instance.DungeonFlow).name + " detected, changing generation size."); __instance.DungeonFlow.Length.Min = 12; __instance.DungeonFlow.Length.Max = 14; __instance.DungeonFlow.Lines[0].Length = 0.35f; __instance.DungeonFlow.Lines[1].Position = 0.35f; __instance.DungeonFlow.Lines[1].Length = 0.3f; __instance.DungeonFlow.Lines[2].Position = 0.65f; __instance.DungeonFlow.Lines[2].Length = 0.35f; } } [HarmonyPatch(typeof(Dungeon), "PostGenerateDungeon")] [HarmonyPostfix] private static void PostGenerateDungeonPostfix(Dungeon __instance) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) if (((Object)__instance.DungeonFlow).name != "Level3Flow") { return; } foreach (Tile allTile in __instance.AllTiles) { string name = ((Object)allTile).name; if (!(name == "CaveSmallIntersectTile(Clone)")) { if (name == "CaveCrampedIntersectTile(Clone)") { Transform obj = ((Component)allTile).transform.Find("GeneralScrapSpawn"); Transform val = ((obj != null) ? ((Component)obj).transform : null); if ((Object)(object)val != (Object)null) { Plugin.LogDebug("Converting to random spawn at " + val.position.x + ", " + val.position.y + ", " + val.position.z); Functions.ConvertToRandomSpawn(val, 0.3f, 0.5f); } } } else { Transform obj2 = ((Component)allTile).transform.Find("GeneralScrapSpawn"); Transform val = ((obj2 != null) ? ((Component)obj2).transform : null); if ((Object)(object)val != (Object)null) { Plugin.LogDebug("Converting to random spawn at " + val.position.x + ", " + val.position.y + ", " + val.position.z); Functions.ConvertToRandomSpawn(val, 0.3f, 0.5f); } } } } [HarmonyPatch(typeof(DungeonGenerator), "ProcessGlobalProps")] [HarmonyPostfix] private static void ProcessGlobalPropsPostfix(DungeonGenerator __instance) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) if (((Object)__instance.DungeonFlow).name != "Level3Flow") { return; } foreach (Tile allTile in __instance.CurrentDungeon.AllTiles) { switch (((Object)allTile).name) { case "TunnelSplit(Clone)": { Transform obj5 = ((Component)allTile).transform.Find("SouthWallProps/Shelf1 (14)"); Transform val2 = ((obj5 != null) ? ((Component)obj5).transform : null); if ((Object)(object)val2 != (Object)null) { Plugin.LogDebug("Found a shelf at " + val2.position.x + ", " + val2.position.y + ", " + val2.position.z); Functions.CreateItemSpawn(val2, new Vector3(-7.68f, -6.6f, 1.79f), "SmallItems", 15, copy: true); } Transform obj6 = ((Component)allTile).transform.Find("Props/PropSet2/WoodPalletPile2x"); val2 = ((obj6 != null) ? ((Component)obj6).transform : null); if ((Object)(object)val2 != (Object)null) { Plugin.LogDebug("Found a pallet at " + val2.position.x + ", " + val2.position.y + ", " + val2.position.z); Functions.CreateItemSpawn(val2, new Vector3(0.3f, 0.04f, 2.54f), "TabletopItems", 3, copy: false); } Transform obj7 = ((Component)allTile).transform.Find("Props/PropSet2/Minecart (1)"); val2 = ((obj7 != null) ? ((Component)obj7).transform : null); if ((Object)(object)val2 != (Object)null) { Plugin.LogDebug("Found a minecart at " + val2.position.x + ", " + val2.position.y + ", " + val2.position.z); GameObject obj8 = Functions.CreateItemSpawn(val2, new Vector3(-0.74f, 1.22f, 4.11f), "SmallItems", 1, copy: false); Transform val3 = ((obj8 != null) ? obj8.transform : null); if ((Object)(object)val3 != (Object)null) { Functions.ConvertToRandomSpawn(val3, 0.25f, 0.8f); } } break; } case "TunnelSplitEndTile(Clone)": { Transform obj4 = ((Component)allTile).transform.Find("SouthWallProps/Shelf1 (14)"); Transform val2 = ((obj4 != null) ? ((Component)obj4).transform : null); if ((Object)(object)val2 != (Object)null) { Plugin.LogDebug("Found a shelf at " + val2.position.x + ", " + val2.position.y + ", " + val2.position.z); Functions.CreateItemSpawn(val2, new Vector3(-7.68f, -6.6f, 1.79f), "SmallItems", 15, copy: true); } break; } case "CaveCrampedIntersectTile(Clone)": { Transform obj9 = ((Component)allTile).transform.Find("TablePropSpawn"); GameObject val = ((obj9 != null) ? ((Component)obj9).gameObject : null); if ((Object)(object)val != (Object)null) { Plugin.LogDebug("Destroying table prop spawn at " + val.transform.position.x + ", " + val.transform.position.y + ", " + val.transform.position.z); Object.Destroy((Object)(object)val); } break; } case "CaveWaterTile(Clone)": { Transform obj = ((Component)allTile).transform.Find("MapHazardSpawnType1"); GameObject val = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)val != (Object)null) { Plugin.LogDebug("Destroying hazard spawn at " + val.transform.position.x + ", " + val.transform.position.y + ", " + val.transform.position.z); Object.Destroy((Object)(object)val); } Transform obj2 = ((Component)allTile).transform.Find("WaterTileMesh"); object obj3; if (obj2 == null) { obj3 = null; } else { MeshCollider component = ((Component)obj2).gameObject.GetComponent<MeshCollider>(); obj3 = ((component != null) ? component.sharedMesh : null); } if ((Object)obj3 != (Object)null) { Plugin.LogDebug("Changing collision on water tile at " + ((Component)allTile).transform.position.x + ", " + ((Component)allTile).transform.position.y + ", " + ((Component)allTile).transform.position.z); _ = Assets.waterTileCollision; } break; } } } } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void ChangeManeaterData(StartOfRound __instance) { EnemyType[] array = Resources.FindObjectsOfTypeAll<EnemyType>(); foreach (EnemyType val in array) { if (((Object)val).name == "CaveDweller") { val.increasedChanceInterior = (RebalancedMineshaftConfig.increasedManeaterChance.Value ? 4 : (-1)); break; } } } [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ChangeMineshaftAmount(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(RoundManager), "currentDungeonType"), (string)null) }).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_6, (object)null, (string)null) }).SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MineshaftPatch), "ShouldSpawnAdditionalScrap", (Type[])null, (Type[])null))) .InstructionEnumeration(); } public static int ShouldSpawnAdditionalScrap() { if (!RebalancedMineshaftConfig.extraScrapSpawn.Value) { return 0; } return 6; } } public static class PluginInfo { public const string PLUGIN_GUID = "RebalancedMineshaft"; public const string PLUGIN_NAME = "RebalancedMineshaft"; public const string PLUGIN_VERSION = "0.3.0"; } }