Decompiled source of Joe Joblin Bracken v1.2.0

BepInEx/plugins/BrackenRandomizer.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.IO;
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 HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("BrackenRandomizer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BrackenRandomizer")]
[assembly: AssemblyTitle("BrackenRandomizer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BrackenRandomizer
{
	public class configValues
	{
		public static int value0;

		public static int value1;

		public static int value2;

		public static int value3;

		public static int value4;

		public static int value5;

		public static int value6;

		public static int defaultRarity;

		public static int hutchersonRarity;

		public static int dekuRarity;

		public static int gokuRarity;

		public static int mondayRarity;

		public static int bttbRarity;

		public static int pipeRarity;
	}
	[BepInPlugin("BrackenRandomizer", "BrackenRandomizer", "1.2.2")]
	public class Plugin : BaseUnityPlugin
	{
		public Harmony harmonymain;

		public static AssetBundle LoadedBundle;

		public static ConfigEntry<int> defaultBrackenRarity;

		public static ConfigEntry<int> joshHutchersonRarity;

		public static ConfigEntry<int> dekuRarity;

		public static ConfigEntry<int> gokuRarity;

		public static ConfigEntry<int> mondayRarity;

		public static ConfigEntry<int> badToTheBoneRarity;

		public static ConfigEntry<int> metalPipeRarity;

		public static ConfigEntry<bool> shouldDefaultBrackenSpawn;

		public static ConfigEntry<bool> shouldJoshHutchersonSpawn;

		public static ConfigEntry<bool> shouldDekuSpawn;

		public static ConfigEntry<bool> shouldGokuSpawn;

		public static ConfigEntry<bool> shouldMondaySpawn;

		public static ConfigEntry<bool> shouldBadToTheBoneSpawn;

		public static ConfigEntry<bool> shouldMetalPipeSpawn;

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			harmonymain = new Harmony("BrackenRandomizer");
			harmonymain.PatchAll();
			shouldDefaultBrackenSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Variations.Toggles", "shouldDefaultBrackenSpawn?", true, (ConfigDescription)null);
			shouldJoshHutchersonSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Variations.Toggles", "shouldJoshHutchersonSpawn?", true, (ConfigDescription)null);
			shouldDekuSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Variations.Toggles", "shouldDekuSpawn?", true, (ConfigDescription)null);
			shouldGokuSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Variations.Toggles", "shouldGokuSpawn?", true, (ConfigDescription)null);
			shouldMondaySpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Variations.Toggles", "shouldMondayLeftMeBrokenSpawn?", true, (ConfigDescription)null);
			shouldBadToTheBoneSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Variations.Toggles", "shouldBadToTheBoneSpawn?", true, (ConfigDescription)null);
			shouldMetalPipeSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Variations.Toggles", "shouldMetalPipeSpawn?", true, (ConfigDescription)null);
			defaultBrackenRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Variations", "NormalBrackenRarity", 25, "Standard Bracken Spawnrate, all Variation values should add up to 100");
			joshHutchersonRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Variations", "JoshHutchersonRarity", 20, "Josh Hutcherson Variation Spawnrate, all Variation values should add up to 100");
			dekuRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Variations", "DekuRarity", 15, "Deku Variation Spawnrate (Default 25), all values should add up to 100");
			gokuRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Variations", "GokuRarity", 15, "Goku Variation Spawnrate, all Variation values should add up to 100");
			mondayRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Variations", "MondayLeftMeBrokenRarity", 10, "Monday left me Broken Variation Spawnrate, all Variation values should add up to 100");
			badToTheBoneRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Variations", "BadToTheBoneRarity", 10, "Bad to the Bone Variation Spawnrate, all Variation values should add up to 100");
			metalPipeRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Variations", "MetalPipeRarity", 5, "Metal Pipe Variation Spawnrate, all Variation values should add up to 100");
			configValues.defaultRarity = (configValues.hutchersonRarity = (configValues.dekuRarity = (configValues.gokuRarity = (configValues.mondayRarity = (configValues.bttbRarity = (configValues.pipeRarity = 0))))));
			if (shouldDefaultBrackenSpawn.Value)
			{
				configValues.defaultRarity = defaultBrackenRarity.Value;
			}
			if (shouldJoshHutchersonSpawn.Value)
			{
				configValues.hutchersonRarity = joshHutchersonRarity.Value;
			}
			if (shouldDekuSpawn.Value)
			{
				configValues.dekuRarity = dekuRarity.Value;
			}
			if (shouldGokuSpawn.Value)
			{
				configValues.gokuRarity = gokuRarity.Value;
			}
			if (shouldMondaySpawn.Value)
			{
				configValues.mondayRarity = mondayRarity.Value;
			}
			if (shouldBadToTheBoneSpawn.Value)
			{
				configValues.bttbRarity = badToTheBoneRarity.Value;
			}
			if (shouldMetalPipeSpawn.Value)
			{
				configValues.pipeRarity = metalPipeRarity.Value;
			}
			configValues.value0 = configValues.defaultRarity;
			configValues.value1 = configValues.value0 + configValues.hutchersonRarity;
			configValues.value2 = configValues.value1 + configValues.dekuRarity;
			configValues.value3 = configValues.value2 + configValues.gokuRarity;
			configValues.value4 = configValues.value3 + configValues.mondayRarity;
			configValues.value5 = configValues.value4 + configValues.bttbRarity;
			configValues.value6 = configValues.value5 + configValues.pipeRarity;
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "brackenrandomizer");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load BrackenRandomizer AssetBundle! (Bundle should be located in the same folder as mod!)");
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded BrackenRandomizer AssetBundle!");
			LoadedBundle = val;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"BrackenRandomizer loaded.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Config Info: {defaultBrackenRarity.Value}% {shouldDefaultBrackenSpawn.Value}, {joshHutchersonRarity.Value}% {shouldJoshHutchersonSpawn.Value}, {dekuRarity.Value}% {shouldDekuSpawn.Value}, {gokuRarity.Value}% {shouldGokuSpawn.Value}, {mondayRarity.Value}% {shouldMondaySpawn.Value}, {badToTheBoneRarity.Value}% {shouldBadToTheBoneSpawn.Value}, {metalPipeRarity.Value}% {shouldMetalPipeSpawn.Value}");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Config Values: {configValues.value0}, {configValues.value1}, {configValues.value2}, {configValues.value3}, {configValues.value4}, {configValues.value5}, {configValues.value6}");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BrackenRandomizer";

		public const string PLUGIN_NAME = "BrackenRandomizer";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace BrackenRandomizer.Patches
{
	[HarmonyPatch]
	internal class EnemyTypes
	{
		[HarmonyPatch(typeof(FlowermanAI), "Start")]
		[HarmonyPostfix]
		public static void SummonRBracken(FlowermanAI __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Expected O, but got Unknown
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource val = new ManualLogSource("BrackenRandomizer");
			Logger.Sources.Add((ILogSource)(object)val);
			string text = "null";
			string text2 = "null";
			string text3 = "null";
			string text4 = "null";
			string text5 = "null";
			string arg = "null";
			int num = -1;
			val.LogInfo((object)"Rolling...");
			int num2 = new Random().Next(1, configValues.value6);
			val.LogInfo((object)$"Rolled {num2}!");
			int num3 = num2;
			int num4 = num3;
			if (num4 < configValues.value0 && num4 >= 0)
			{
				val.LogInfo((object)$"Summoned Normal Bracken at {configValues.defaultRarity} chance");
				return;
			}
			int num5 = num4;
			if (num5 < configValues.value1 + configValues.defaultRarity && num5 >= configValues.value0)
			{
				text = "assets/hutcherson/whistlefull.mp3";
				text2 = "assets/hutcherson/whistle.mp3";
				text5 = "assets/hutcherson/JoshHutcherson.prefab";
				arg = "Josh Hutcherson";
				num = configValues.hutchersonRarity;
			}
			else
			{
				int num6 = num4;
				if (num6 < configValues.value2 + configValues.defaultRarity && num6 >= configValues.value1)
				{
					text = "assets/deku/deku_chase_alt.mp3";
					text2 = "assets/deku/deku_necksnap.mp3";
					text3 = "assets/deku/deku_growl.mp3";
					text5 = "assets/deku/Deku.prefab";
					arg = "Deku";
					num = configValues.dekuRarity;
				}
				else
				{
					int num7 = num4;
					if (num7 < configValues.value3 && num7 >= configValues.value2)
					{
						text = "assets/goku/ultra.mp3";
						text2 = "assets/goku/mods.mp3";
						text5 = "assets/goku/Gok.prefab";
						arg = "Goku";
						num = configValues.gokuRarity;
					}
					else
					{
						int num8 = num4;
						if (num8 < configValues.value4 && num8 >= configValues.value3)
						{
							text = "assets/mond/monday.mp3";
							text2 = "assets/mond/monday.mp3";
							text5 = "assets/mond/Monday.prefab";
							arg = "Monday left me Broken";
							num = configValues.mondayRarity;
						}
						else
						{
							int num9 = num4;
							if (num9 < configValues.value5 && num9 >= configValues.value4)
							{
								text = "assets/bttb/bttb_full.mp3";
								text2 = "assets/bttb/bttb.mp3";
								text3 = "assets/bttb/bttb.mp3";
								text5 = "assets/bttb/BadToTheBone.prefab";
								arg = "Bone to the Bone";
								num = configValues.bttbRarity;
							}
							else
							{
								int num10 = num4;
								if (num10 < configValues.value6 && num10 >= configValues.value5)
								{
									text = "assets/pipe/pipe_full.mp3";
									text2 = "assets/pipe/pipe.mp3";
									text5 = "assets/pipe//Pipe.prefab";
									arg = "Metal Pipe";
									num = configValues.pipeRarity;
								}
							}
						}
					}
				}
			}
			PlayAudioAnimationEvent component = ((Component)((Component)__instance).gameObject.transform.Find("FlowermanModel").Find("AnimContainer")).GetComponent<PlayAudioAnimationEvent>();
			Object.Destroy((Object)((Component)((Component)__instance).gameObject.transform.Find("FlowermanModel").Find("LOD1")).gameObject.GetComponent<SkinnedMeshRenderer>());
			__instance.creatureAngerVoice.clip = Plugin.LoadedBundle.LoadAsset<AudioClip>(text ?? "");
			__instance.crackNeckSFX = Plugin.LoadedBundle.LoadAsset<AudioClip>(text2 ?? "");
			__instance.crackNeckAudio.clip = Plugin.LoadedBundle.LoadAsset<AudioClip>(text2 ?? "");
			if (text3 != "null")
			{
				component.audioClip = Plugin.LoadedBundle.LoadAsset<AudioClip>(text3 ?? "");
			}
			GameObject val2 = Object.Instantiate<GameObject>(Plugin.LoadedBundle.LoadAsset<GameObject>(text5 ?? ""), ((Component)__instance).gameObject.transform);
			val2.transform.localPosition = new Vector3(0f, 1.5f, 0f);
			val.LogInfo((object)$"Summoned {arg} at {num} chance");
		}
	}
}