Decompiled source of BlindedByBlood v1.0.0

BlindedByBloodPlugin/ultrakillTestMod.dll

Decompiled 3 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Fields;
using UnityEngine;
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: AssemblyTitle("ultrakillTestMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ultrakillTestMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("73a06801-ef9b-4d8f-bac4-69c106cdeb93")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ultrakillTestMod
{
	[BepInPlugin("com.michi.ultrakillTestMod", "ultrakillTestMod", "1.0.0")]
	public class ultrakillTestModPlugin : BaseUnityPlugin
	{
		private PluginConfigurator config;

		public static bool enabledMod;

		private Material unlitMaterial;

		private Material litMaterial;

		public static Material lamat;

		public static Color matColor;

		public static bool includeEnemies;

		private bool includeMap;

		private const string MyGUID = "com.michi.ultrakillTestMod";

		private const string PluginName = "ultrakillTestMod";

		private const string VersionString = "1.0.0";

		private static readonly Harmony Harmony = new Harmony("com.michi.ultrakillTestMod");

		public static ManualLogSource Log = new ManualLogSource("ultrakillTestMod");

		public void Start()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00d7: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Expected O, but got Unknown
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			config = PluginConfigurator.Create("Blinded By Blood", "com.michi.ultrakillTestMod");
			BoolField val = new BoolField(config.rootPanel, "enabled", "field.standardenabled", true, true);
			ColorField val2 = new ColorField(config.rootPanel, "color", "field.colormaterial", Color.white, true);
			BoolField val3 = new BoolField(config.rootPanel, "include enemies", "field.includeenemies", true, true);
			BoolField val4 = new BoolField(config.rootPanel, "include map", "field.includemap", true, true);
			BoolField val5 = new BoolField(config.rootPanel, "use Lit shader", "field.uselitshader", false, true);
			includeMap = val4.value;
			includeEnemies = val3.value;
			enabledMod = val.value;
			matColor = val2.value;
			val4.onValueChange += new BoolValueChangeEventDelegate(IncludeMapField_onValueChange);
			val.onValueChange += new BoolValueChangeEventDelegate(Field_onValueChange);
			val2.onValueChange += new ColorValueChangeEventDelegate(ColorField_onValueChange);
			val3.onValueChange += new BoolValueChangeEventDelegate(IncludeEnemiesField_onValueChange);
			ref Material reference = ref unlitMaterial;
			Object obj = AssetBundle.LoadFromStream(executingAssembly.GetManifestResourceStream("ultrakillTestMod.bundles.unlit")).LoadAllAssets()[0];
			reference = (Material)(object)((obj is Material) ? obj : null);
			litMaterial = new Material(unlitMaterial);
			litMaterial.shader = Shader.Find("Standard");
			ChangeMaterialAccordingly(val5.value);
			val5.onValueChange += new BoolValueChangeEventDelegate(UseStandardShader_onValueChange);
		}

		private void ChangeMaterialAccordingly(bool data)
		{
			if (!data)
			{
				lamat = unlitMaterial;
			}
			else
			{
				lamat = litMaterial;
			}
		}

		private void UseStandardShader_onValueChange(BoolValueChangeEvent data)
		{
			ChangeMaterialAccordingly(data.value);
		}

		private void IncludeMapField_onValueChange(BoolValueChangeEvent data)
		{
			includeMap = data.value;
		}

		private void IncludeEnemiesField_onValueChange(BoolValueChangeEvent data)
		{
			includeEnemies = data.value;
		}

		private void ColorField_onValueChange(ColorValueChangeEvent data)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			matColor = data.value;
		}

		private void Field_onValueChange(BoolValueChangeEvent data)
		{
			enabledMod = data.value;
		}

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: ultrakillTestMod, VersionString: 1.0.0 is loading...");
			Harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: ultrakillTestMod, VersionString: 1.0.0 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
			SceneManager.sceneLoaded += SceneManager_sceneLoaded;
		}

		private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
		{
			RemoveMats();
		}

		private void RemoveMats()
		{
			if (!enabledMod)
			{
				return;
			}
			Renderer[] array = Resources.FindObjectsOfTypeAll<Renderer>();
			Renderer[] array2 = array;
			foreach (Renderer val in array2)
			{
				if (CheckIfValid(((Component)val).gameObject))
				{
					if (((Object)((Component)val).gameObject).name == "Virtual Camera")
					{
						((Component)val).gameObject.SetActive(false);
					}
					Material[] array3 = (Material[])(object)new Material[val.materials.Length];
					for (int j = 0; j < array3.Length; j++)
					{
						array3[j] = lamat;
					}
					val.materials = array3;
					val.material = lamat;
				}
			}
		}

		private bool CheckIfValid(GameObject lobject)
		{
			bool flag = lobject.layer == 1;
			if (lobject.tag == "Enemy" || lobject.layer == 9)
			{
				if (!includeEnemies)
				{
					return false;
				}
				return true;
			}
			if (Object.op_Implicit((Object)(object)lobject.GetComponent<ParticleSystem>()))
			{
				return false;
			}
			if (!includeMap)
			{
				return false;
			}
			return lobject.layer != 19 && !flag && lobject.tag != "Coin";
		}
	}
}
namespace ultrakillTestMod.Utils
{
	internal static class ModUtils
	{
		public static Transform GetPlayerTransform()
		{
			return null;
		}
	}
}
namespace ultrakillTestMod.Patches
{
	[HarmonyPatch(typeof(EnemySimplifier))]
	internal class PlayerPatches
	{
		[HarmonyPatch("ChangeMaterialNew")]
		private static bool Prefix(MaterialState stateToTarget, Material newMaterial)
		{
			if (!ultrakillTestModPlugin.enabledMod)
			{
				return true;
			}
			if (!ultrakillTestModPlugin.includeEnemies)
			{
				return true;
			}
			newMaterial = ultrakillTestModPlugin.lamat;
			return false;
		}
	}
}
namespace ultrakillTestMod.MonoBehaviours
{
	internal class ultrakillTestModComponent : MonoBehaviour
	{
		public void Awake()
		{
		}

		public void Start()
		{
		}

		public void Update()
		{
		}

		public void LateUpdate()
		{
		}
	}
}