Decompiled source of PepeTheTaxman v1.0.2

PepeTheTaxman.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("emojisandrenamepep")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("emojisandrenamepep")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f132c140-c0f2-4fbe-96f4-1e2d3081b7a4")]
[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 PepeTaxman;

[BepInPlugin("rebecca.repo.pepetaxman", "Pepe Taxman Combined", "1.1.0")]
public class PepeTaxmanPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "rebecca.repo.pepetaxman";

	public const string PluginName = "Pepe Taxman Combined";

	public const string PluginVersion = "1.1.0";

	public const string NewTaxmanName = "\n\n<color=#4d0000><b>FROGMAN:</b></color>\n";

	internal static byte[] PngBytes;

	internal static bool RuntimeStarted;

	private void Awake()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		string path = Path.Combine(Paths.PluginPath, "PepeTheTaxman", "emojis.png");
		if (File.Exists(path))
		{
			try
			{
				PngBytes = File.ReadAllBytes(path);
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to read emojis.png: {arg}");
			}
		}
		new Harmony("rebecca.repo.pepetaxman").PatchAll();
		UpdateTaxmanNames();
		if (PngBytes != null && !RuntimeStarted)
		{
			RuntimeStarted = true;
			GameObject val = new GameObject("PepeTaxman_Runtime")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)val);
			val.AddComponent<PepeTaxmanTextureRuntime>();
		}
	}

	private void UpdateTaxmanNames()
	{
		try
		{
			Type type = AccessTools.TypeByName("TruckScreenText");
			if (type == null)
			{
				return;
			}
			FieldInfo fieldInfo = AccessTools.Field(type, "nicknameTaxman");
			if (!(fieldInfo == null))
			{
				Object[] array = Resources.FindObjectsOfTypeAll(type);
				foreach (Object obj in array)
				{
					fieldInfo.SetValue(obj, "\n\n<color=#4d0000><b>FROGMAN:</b></color>\n");
				}
			}
		}
		catch
		{
		}
	}
}
[HarmonyPatch]
internal static class TruckScreenTextPatch
{
	private static MethodBase TargetMethod()
	{
		Type type = AccessTools.TypeByName("TruckScreenText");
		return AccessTools.Method(type, "Awake", (Type[])null, (Type[])null) ?? AccessTools.Method(type, "Start", (Type[])null, (Type[])null);
	}

	private static void Postfix(object __instance)
	{
		if (__instance != null)
		{
			AccessTools.Field(__instance.GetType(), "nicknameTaxman")?.SetValue(__instance, "\n\n<color=#4d0000><b>FROGMAN:</b></color>\n");
		}
	}
}
internal sealed class PepeTaxmanTextureRuntime : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <EnforceLoop>d__8 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public PepeTaxmanTextureRuntime <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <EnforceLoop>d__8(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			int num = <>1__state;
			PepeTaxmanTextureRuntime pepeTaxmanTextureRuntime = <>4__this;
			if (num != 0)
			{
				if (num != 1)
				{
					return false;
				}
				<>1__state = -1;
			}
			else
			{
				<>1__state = -1;
			}
			pepeTaxmanTextureRuntime.ApplyReplacements();
			<>2__current = (object)new WaitForSeconds(2f);
			<>1__state = 1;
			return true;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private const int CellSize = 64;

	private const int TaxmanTileCol = 6;

	private const int TaxmanTileRow = 4;

	private static readonly string[] TargetTextureNames = new string[3] { "emojis", "emojis extraction point", "taxman_grossup" };

	private Texture2D _sheetReplacement;

	private Texture2D _taxmanReplacement64;

	private void Awake()
	{
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		InitializeTextures();
		SceneManager.sceneLoaded += delegate
		{
			((MonoBehaviour)this).StopAllCoroutines();
		};
		SceneManager.sceneLoaded += delegate
		{
			((MonoBehaviour)this).StartCoroutine(EnforceLoop());
		};
		((MonoBehaviour)this).StartCoroutine(EnforceLoop());
	}

	private void InitializeTextures()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		if (!((Object)(object)_sheetReplacement != (Object)null) && PepeTaxmanPlugin.PngBytes != null)
		{
			_sheetReplacement = new Texture2D(2, 2, (TextureFormat)4, false, false);
			if (ImageConversion.LoadImage(_sheetReplacement, PepeTaxmanPlugin.PngBytes))
			{
				((Object)_sheetReplacement).name = "emojis_modded_sheet";
				((Texture)_sheetReplacement).filterMode = (FilterMode)0;
				int num = 384;
				int num2 = ((Texture)_sheetReplacement).height - 320;
				_taxmanReplacement64 = new Texture2D(64, 64, (TextureFormat)4, false, false);
				_taxmanReplacement64.SetPixels(_sheetReplacement.GetPixels(num, num2, 64, 64));
				_taxmanReplacement64.Apply(false, false);
				((Object)_taxmanReplacement64).name = "taxman_grossup_modded";
				((Texture)_taxmanReplacement64).filterMode = (FilterMode)0;
			}
		}
	}

	[IteratorStateMachine(typeof(<EnforceLoop>d__8))]
	private IEnumerator EnforceLoop()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <EnforceLoop>d__8(0)
		{
			<>4__this = this
		};
	}

	private void ApplyReplacements()
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Invalid comparison between Unknown and I4
		if ((Object)(object)_sheetReplacement == (Object)null)
		{
			return;
		}
		Material[] array = Resources.FindObjectsOfTypeAll<Material>();
		foreach (Material val in array)
		{
			if ((Object)(object)val == (Object)null || (Object)(object)val.shader == (Object)null)
			{
				continue;
			}
			for (int j = 0; j < val.shader.GetPropertyCount(); j++)
			{
				if ((int)val.shader.GetPropertyType(j) != 4)
				{
					continue;
				}
				string propertyName = val.shader.GetPropertyName(j);
				Texture currentTex = val.GetTexture(propertyName);
				if ((Object)(object)currentTex == (Object)null || !TargetTextureNames.Any((string name) => string.Equals(((Object)currentTex).name, name, StringComparison.OrdinalIgnoreCase)))
				{
					continue;
				}
				if (((Object)currentTex).name.Equals("taxman_grossup", StringComparison.OrdinalIgnoreCase))
				{
					if ((Object)(object)currentTex != (Object)(object)_taxmanReplacement64)
					{
						val.SetTexture(propertyName, (Texture)(object)_taxmanReplacement64);
					}
				}
				else if ((Object)(object)currentTex != (Object)(object)_sheetReplacement)
				{
					val.SetTexture(propertyName, (Texture)(object)_sheetReplacement);
				}
			}
		}
	}
}