Decompiled source of TaxmanReplacer v1.0.1

plugins/TaxmanReplacer.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
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 = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("itshollatte")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TaxmanReplacer")]
[assembly: AssemblyTitle("TaxmanReplacer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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;
		}
	}
}
namespace TaxmanReplacer
{
	[BepInPlugin("itshollatte.TaxmanReplacer", "TaxmanReplacer", "1.0.0")]
	public class TaxmanPlugin : BaseUnityPlugin
	{
		public static string ModFolderPath;

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			ModFolderPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			Harmony val = new Harmony("itshollatte.TaxmanReplacer");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogWarning((object)"TAXMAN REPLACERRUNNING");
		}
	}
	[HarmonyPatch]
	public static class TaxmanPatch
	{
		private static HashSet<Texture2D> _patchedTextures = new HashSet<Texture2D>();

		private static readonly Dictionary<string, string> _textureTargets = new Dictionary<string, string>
		{
			{ "taxman_grossup", "taxman_grossup.png" },
			{ "emojis", "emojis.png" }
		};

		[HarmonyPatch(typeof(Renderer), "get_material")]
		[HarmonyPostfix]
		public static void Postfix_Renderer(Renderer __instance)
		{
			Texture2D[] array = Resources.FindObjectsOfTypeAll<Texture2D>();
			Texture2D[] array2 = array;
			foreach (Texture2D val in array2)
			{
				if (!_textureTargets.ContainsKey(((Object)val).name) || _patchedTextures.Contains(val))
				{
					continue;
				}
				string text = _textureTargets[((Object)val).name];
				string text2 = Path.Combine(TaxmanPlugin.ModFolderPath, text);
				if (File.Exists(text2))
				{
					try
					{
						byte[] array3 = File.ReadAllBytes(text2);
						ImageConversion.LoadImage(val, array3);
						val.Apply();
						_patchedTextures.Add(val);
						Debug.LogWarning((object)("TEXTURE FOUND: " + ((Object)val).name + " replaced with " + text + "! ---"));
					}
					catch (Exception)
					{
						_patchedTextures.Add(val);
					}
				}
				else
				{
					Debug.LogError((object)("INJECTION FAILED: Could not find image at " + text2 + " ---"));
					_patchedTextures.Add(val);
				}
			}
		}
	}
}