Decompiled source of LinguiniKill v1.0.0

plugins/LinguiniKill/bitmotte.LinguiniKill.dll

Decompiled 4 hours 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 LinguiniKill;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;

[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.LinguiniKill")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("LinguiniKill")]
[assembly: AssemblyTitle("bitmotte.LinguiniKill")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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;
		}
	}
}
public class Ensure : MonoBehaviour
{
	public Texture2D tex;

	private void Awake()
	{
		((MonoBehaviour)this).Invoke("Mostlys", 1f);
	}

	private void Mostlys()
	{
		((Component)this).gameObject.GetComponent<Renderer>().material.mainTexture = (Texture)(object)tex;
	}
}
public static class ImageLoader
{
	public static Texture2D LoadPNG(string filePath)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		Texture2D val = null;
		if (File.Exists(filePath))
		{
			byte[] array = File.ReadAllBytes(filePath);
			Plugin.Logger.LogInfo((object)"YES");
			val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, array);
			((Texture)val).filterMode = (FilterMode)0;
		}
		Plugin.Logger.LogInfo((object)val);
		return val;
	}
}
namespace LinguiniKill
{
	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("LinguiniKill.resources." + fileName))
			{
				if (stream == null)
				{
					return null;
				}
				array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
			}
			return array;
		}
	}
	[HarmonyPatch(typeof(EnemyIdentifier), "Awake")]
	public static class patcg
	{
		private static void Postfix(EnemyIdentifier __instance)
		{
			Renderer[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Texture2D mainTexture = ImageLoader.LoadPNG(Assembly.GetExecutingAssembly().Location.Replace("bitmotte.LinguiniKill.dll", "oce.jpg") ?? "");
				val.material.mainTexture = (Texture)(object)mainTexture;
			}
		}
	}
	[BepInPlugin("bitmotte.LinguiniKill", "LinguiniKill", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		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.LinguiniKill is loaded!");
			Harmony val = new Harmony("bitmotte.LinguiniKill");
			val.PatchAll();
			SceneManager.sceneLoaded += OnSceneLoad;
		}

		private void OnSceneLoad(Scene scene, LoadSceneMode mode)
		{
			//IL_020d: 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)
			GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
			Renderer[] array = Array.Empty<Renderer>();
			Image[] array2 = Array.Empty<Image>();
			Texture2D val = ImageLoader.LoadPNG(Assembly.GetExecutingAssembly().Location.Replace("bitmotte.LinguiniKill.dll", "oce.jpg") ?? "");
			GameObject[] array3 = rootGameObjects;
			foreach (GameObject val2 in array3)
			{
				Renderer[] array4 = array;
				Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>();
				int num = 0;
				Renderer[] array5 = (Renderer[])(object)new Renderer[array4.Length + componentsInChildren.Length];
				ReadOnlySpan<Renderer> readOnlySpan = new ReadOnlySpan<Renderer>(array4);
				readOnlySpan.CopyTo(new Span<Renderer>(array5).Slice(num, readOnlySpan.Length));
				num += readOnlySpan.Length;
				ReadOnlySpan<Renderer> readOnlySpan2 = new ReadOnlySpan<Renderer>(componentsInChildren);
				readOnlySpan2.CopyTo(new Span<Renderer>(array5).Slice(num, readOnlySpan2.Length));
				num += readOnlySpan2.Length;
				array = array5;
				Image[] array6 = array2;
				Image[] componentsInChildren2 = val2.GetComponentsInChildren<Image>();
				num = 0;
				Image[] array7 = (Image[])(object)new Image[array6.Length + componentsInChildren2.Length];
				ReadOnlySpan<Image> readOnlySpan3 = new ReadOnlySpan<Image>(array6);
				readOnlySpan3.CopyTo(new Span<Image>(array7).Slice(num, readOnlySpan3.Length));
				num += readOnlySpan3.Length;
				ReadOnlySpan<Image> readOnlySpan4 = new ReadOnlySpan<Image>(componentsInChildren2);
				readOnlySpan4.CopyTo(new Span<Image>(array7).Slice(num, readOnlySpan4.Length));
				num += readOnlySpan4.Length;
				array2 = array7;
			}
			Renderer[] array8 = array;
			foreach (Renderer val3 in array8)
			{
				if (((Object)((Component)val3).gameObject).name != "Quad")
				{
					val3.material.mainTexture = (Texture)(object)val;
					Ensure ensure = ((Component)val3).gameObject.AddComponent<Ensure>();
					ensure.tex = val;
				}
			}
			Image[] array9 = array2;
			foreach (Image val4 in array9)
			{
				val4.sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			}
		}
	}
	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)
			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;
				}
			}
			return gameObject;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "bitmotte.LinguiniKill";

		public const string PLUGIN_NAME = "LinguiniKill";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}