Decompiled source of BadToTheBone v1.0.1

bitmotte.BadToTheBone.dll

Decompiled a day 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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Fields;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.SceneManagement;

[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("bitmotte.BadToTheBone")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BadToTheBone")]
[assembly: AssemblyTitle("bitmotte.BadToTheBone")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 BadToTheBone
{
	public class Bad : MonoBehaviour
	{
		private GameObject bad;

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			AssetBundle val = BundleTool.Load("bad.bundle");
			bad = (GameObject)val.LoadAsset("Assets/BadCanvas.prefab");
			Check();
			val.Unload(false);
		}

		private void Check()
		{
			((MonoBehaviour)this).Invoke("Check", Configurator.interval.value);
			float num = Random.Range(0f, Configurator.rarity.value);
			if (num <= 1f)
			{
				Plugin.Logger.LogInfo((object)"WOAH what was that ? !");
				Object.Instantiate<GameObject>(bad);
			}
		}
	}
	public static class Configurator
	{
		public static FloatSliderField rarity;

		public static FloatSliderField interval;

		public static PluginConfigurator CreateConfigurator()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			PluginConfigurator val = PluginConfigurator.Create("BadToTheBone", "bitmotte.BadToTheBone");
			rarity = new FloatSliderField(val.rootPanel, "Rarity (1 in X)", "rarity", new Tuple<float, float>(1f, 10000f), 5000f);
			interval = new FloatSliderField(val.rootPanel, "Time between checks (Seconds)", "interval", new Tuple<float, float>(0.01f, 60f), 1f);
			return val;
		}
	}
	[BepInPlugin("bitmotte.BadToTheBone", "BadToTheBone", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static PluginConfigurator config;

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin bitmotte.BadToTheBone is loaded!");
			Harmony val = new Harmony("bitmotte.BadToTheBone");
			val.PatchAll();
			config = Configurator.CreateConfigurator();
			SceneManager.sceneLoaded += SceneUtility.OnSceneLoad;
		}
	}
	public static class BundleTool
	{
		public static AssetBundle Load(string fileName)
		{
			return AssetBundle.LoadFromMemory(EmbeddedAccess.AccessFile(fileName));
		}
	}
	public static class EmbeddedAccess
	{
		public static byte[] AccessFile(string fileName)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			byte[] array;
			using (Stream stream = executingAssembly.GetManifestResourceStream("BadToTheBone.resources." + fileName))
			{
				if (stream == null)
				{
					return null;
				}
				array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
			}
			return array;
		}
	}
	public static class SceneUtility
	{
		public static string sceneName;

		public static void OnSceneLoad(Scene scene, LoadSceneMode mode)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			sceneName = ((Scene)(ref scene)).name;
			GameObject val = new GameObject("Boner");
			val.AddComponent<Bad>();
		}
	}
	public static class SetupResource
	{
		public static GameObject FixShader(GameObject gameObject)
		{
			//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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			Shader shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Environment/Metal/Pattern 1/Metal Pattern 1 8.mat").WaitForCompletion().shader;
			SkinnedMeshRenderer[] componentsInChildren = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val in componentsInChildren)
			{
				Material[] materials = ((Renderer)val).materials;
				foreach (Material val2 in materials)
				{
					if (((Object)val2.shader).name == "ULTRAKILL/Master")
					{
						val2.shader = shader;
					}
					if (((Object)val2.shader).name == "Hidden/InternalErrorShader")
					{
						val2.shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Dev/FadeToWhite.mat").WaitForCompletion().shader;
					}
				}
			}
			MeshRenderer[] componentsInChildren2 = gameObject.GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val3 in componentsInChildren2)
			{
				Material[] materials2 = ((Renderer)val3).materials;
				foreach (Material val4 in materials2)
				{
					val4.shader = shader;
				}
			}
			ParticleSystem[] componentsInChildren3 = gameObject.GetComponentsInChildren<ParticleSystem>();
			foreach (ParticleSystem val5 in componentsInChildren3)
			{
				Renderer[] componentsInChildren4 = ((Component)val5).gameObject.GetComponentsInChildren<Renderer>();
				foreach (Renderer val6 in componentsInChildren4)
				{
					Material[] materials3 = val6.materials;
					foreach (Material val7 in materials3)
					{
						val7.shader = shader;
					}
				}
			}
			EnemySimplifier[] componentsInChildren5 = gameObject.GetComponentsInChildren<EnemySimplifier>();
			foreach (EnemySimplifier val8 in componentsInChildren5)
			{
				val8.simplifiedMaterial.shader = shader;
				val8.enragedSimplifiedMaterial.shader = shader;
				if (((Object)val8.enragedMaterial.shader).name == "Hidden/InternalErrorShader" || ((Object)val8.enragedMaterial.shader).name == "Sprites/Default")
				{
					val8.enragedMaterial.shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Dev/FadeToWhite.mat").WaitForCompletion().shader;
				}
				else
				{
					val8.enragedMaterial.shader = shader;
				}
				val8.enemyColorType = (EnemyType)0;
			}
			return gameObject;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "bitmotte.BadToTheBone";

		public const string PLUGIN_NAME = "BadToTheBone";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}