using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using Utils;
[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("LiquidStainRemover")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+24e0ad7dbe6ac7269d55ac45fb77da9887694899")]
[assembly: AssemblyProduct("LiquidStainRemover")]
[assembly: AssemblyTitle("LiquidStainRemover")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
internal class <Module>
{
static <Module>()
{
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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]
[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;
}
}
}
[BepInPlugin("flowerwater.liquidStainRemover", "LiquidStain Remover", "1.2.2")]
public class LiquidStainRemoverPlugin : BaseUnityPlugin
{
public const string ModGuid = "flowerwater.liquidStainRemover";
public const string ModName = "LiquidStain Remover";
public const string ModVersion = "1.2.2";
public static ConfigEntry<bool> disableLogoChanges;
public static byte[] logo;
public static Sprite logo2;
private void Awake()
{
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
disableLogoChanges = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Disable Logo Changes", true, "Prevents the Logo from being changed aswell. (Technically this pulls a random image from the Folder™\ufe0f and uses that for the logo so this can be used to have random logos if you want to.)");
ToolModules.InitHooks();
string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Folder");
int num = Random.Range(0, Directory.GetFiles(path).Length);
int num2 = 0;
string[] files = Directory.GetFiles(path);
foreach (string path2 in files)
{
if (num2 == num)
{
logo = File.ReadAllBytes(path2);
}
num2++;
}
Texture2D val = LoadTexture(logo, 545, 249);
logo2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(272.5f, 124.5f), 100f, 1u, (SpriteMeshType)1, new Vector4(0f, 0f, 0f, 0f), true);
}
public static Texture2D LoadTexture(byte[] bytes, int width, int height)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Texture2D val = new Texture2D(width, height, (TextureFormat)5, false, false);
ImageConversion.LoadImage(val, bytes);
((Texture)val).filterMode = (FilterMode)0;
return val;
}
}
[DefaultExecutionOrder(-1)]
internal static class ToolModules
{
private static Hook? menuManagerUpdateHook;
private static Hook? menuManagerStartHook;
private static Hook? menuManagerEnableUIHook;
private static Hook? menuManagerDisableUIHook;
private static Transform? loadingScreenImageTransform;
private static Transform? headerImageTransform;
private static Transform? loadingImageTransform;
private static Transform? menuContainerTransform;
private static Transform? versionNumTransform;
private static Sprite OriginalLogo;
private static Behaviour[] misBehaviors = (Behaviour[])(object)new Behaviour[0];
private static RectTransform? creditsContentTransform;
private static RectTransform? creditsTextTransform;
private static bool inCredits;
private static float creditsOffset = 0f;
public static void InitHooks()
{
menuManagerUpdateHook = HookUtils.NewHook<MenuManager>("Update", typeof(ToolModules), "OnMenuManagerUpdate");
menuManagerStartHook = HookUtils.NewHook<MenuManager>("Start", typeof(ToolModules), "OnMenuManagerStart");
menuManagerEnableUIHook = HookUtils.NewHook<MenuManager>("EnableUIPanel", typeof(ToolModules), "OnMenuManagerEnableUIPanel");
menuManagerDisableUIHook = HookUtils.NewHook<MenuManager>("DisableUIPanel", typeof(ToolModules), "OnMenuManagerDisableUIPanel");
}
private static void OnMenuManagerUpdate(Action<MenuManager> orig, MenuManager self)
{
//IL_0586: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Expected O, but got Unknown
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
//IL_03fa: Expected O, but got Unknown
//IL_041d: Unknown result type (might be due to invalid IL or missing references)
//IL_0434: Unknown result type (might be due to invalid IL or missing references)
//IL_044b: Unknown result type (might be due to invalid IL or missing references)
//IL_0466: Unknown result type (might be due to invalid IL or missing references)
//IL_0487: Unknown result type (might be due to invalid IL or missing references)
//IL_0494: Unknown result type (might be due to invalid IL or missing references)
//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0503: Unknown result type (might be due to invalid IL or missing references)
//IL_0508: Unknown result type (might be due to invalid IL or missing references)
//IL_050f: Unknown result type (might be due to invalid IL or missing references)
//IL_0516: Unknown result type (might be due to invalid IL or missing references)
//IL_0520: Unknown result type (might be due to invalid IL or missing references)
Behaviour[] array = misBehaviors;
foreach (Behaviour val in array)
{
val.enabled = true;
}
orig(self);
Behaviour[] array2 = misBehaviors;
foreach (Behaviour val2 in array2)
{
val2.enabled = false;
}
try
{
if (loadingScreenImageTransform != null)
{
Graphic[] componentsInChildren = ((Component)loadingScreenImageTransform).GetComponentsInChildren<Graphic>();
foreach (Graphic val3 in componentsInChildren)
{
if (!((Object)(object)((Component)val3).transform == (Object)(object)loadingScreenImageTransform))
{
((Behaviour)val3).enabled = false;
}
}
}
if (headerImageTransform != null && menuContainerTransform != null)
{
Graphic[] componentsInChildren2 = ((Component)headerImageTransform).GetComponentsInChildren<Graphic>();
foreach (Graphic val4 in componentsInChildren2)
{
if ((Object)(object)((Component)val4).transform == (Object)(object)headerImageTransform)
{
continue;
}
if (creditsContentTransform != null && creditsTextTransform != null && inCredits)
{
if ((Object)(object)((Component)val4).transform.parent == (Object)(object)headerImageTransform)
{
float num = creditsTextTransform.sizeDelta.y / 2f - 50f + creditsOffset;
GameObject val5 = new GameObject("CreditsHolder");
RectTransform val6 = val5.AddComponent<RectTransform>();
((Transform)val6).SetParent((Transform)(object)creditsContentTransform, false);
val6.anchorMin = new Vector2(0f, 0.5f);
val6.anchorMax = new Vector2(1f, 0.5f);
val6.pivot = new Vector2(0.5f, 0.5f);
val6.sizeDelta = new Vector2(val6.sizeDelta.x, 75f);
val6.anchoredPosition = new Vector2(0f, 0f - (num + 10f));
RectTransform component = ((Component)val4).GetComponent<RectTransform>();
((Transform)component).SetParent((Transform)(object)val6, false);
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.pivot = new Vector2(0.5f, 0.5f);
((Transform)component).localPosition = Vector3.zero;
((Transform)component).localScale = Vector3.one;
component.sizeDelta = Vector2.zero;
Image val7 = (Image)(object)((val4 is Image) ? val4 : null);
if (val7 != null)
{
val7.preserveAspect = true;
}
Rect rect = component.rect;
float num2 = ((Rect)(ref rect)).height + 10f;
creditsOffset += num2;
Vector2 sizeDelta = creditsContentTransform.sizeDelta;
creditsContentTransform.sizeDelta = new Vector2(sizeDelta.x, sizeDelta.y + num2);
}
((Behaviour)val4).enabled = true;
}
else
{
((Behaviour)val4).enabled = false;
}
}
bool flag = false;
for (int m = 0; m < menuContainerTransform.childCount; m++)
{
Transform child = menuContainerTransform.GetChild(m);
if (((Object)child).name == "CreditsPanel")
{
flag = true;
}
else if (flag)
{
IEnumerable<Component> source = from item in ((Component)child).GetComponents<Component>()
where ((object)item).GetType().ToString() == "UnityEngine.RectTransform" || ((object)item).GetType().ToString() == "UnityEngine.CanvasRenderer" || ((object)item).GetType().ToString() == "TMPro.TextMeshProUGUI"
select item;
if (source.Count() == 3 && creditsContentTransform != null && creditsTextTransform != null)
{
float num3 = creditsTextTransform.sizeDelta.y / 2f - 50f + creditsOffset;
GameObject val8 = new GameObject("CreditsHolder");
RectTransform val9 = val8.AddComponent<RectTransform>();
((Transform)val9).SetParent((Transform)(object)creditsContentTransform, false);
val9.anchorMin = new Vector2(0f, 0.5f);
val9.anchorMax = new Vector2(1f, 0.5f);
val9.pivot = new Vector2(0.5f, 0.5f);
val9.anchoredPosition = new Vector2(0f, 0f - (num3 + 10f));
RectTransform component2 = ((Component)child).GetComponent<RectTransform>();
((Transform)component2).SetParent((Transform)(object)val9, false);
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.pivot = new Vector2(0.5f, 0.5f);
((Transform)component2).localPosition = Vector3.zero;
((Transform)component2).eulerAngles = Vector3.zero;
TextMeshProUGUI component3 = ((Component)child).GetComponent<TextMeshProUGUI>();
((TMP_Text)component3).horizontalAlignment = (HorizontalAlignmentOptions)2;
float num4 = ((TMP_Text)component3).preferredHeight + 40f;
creditsOffset += num4;
Vector2 sizeDelta2 = creditsContentTransform.sizeDelta;
creditsContentTransform.sizeDelta = new Vector2(sizeDelta2.x, sizeDelta2.y + num4);
}
}
}
}
if (LiquidStainRemoverPlugin.disableLogoChanges.Value)
{
try
{
((Component)headerImageTransform).GetComponent<Image>().overrideSprite = LiquidStainRemoverPlugin.logo2;
headerImageTransform.position = new Vector3(1092.367f, 643.2534f, -35.065f);
}
catch (Exception)
{
}
try
{
((Component)loadingImageTransform).GetComponent<Image>().sprite = LiquidStainRemoverPlugin.logo2;
return;
}
catch (Exception)
{
throw;
}
}
}
catch (Exception)
{
}
}
private static void OnMenuManagerStart(Action<MenuManager> orig, MenuManager self)
{
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected O, but got Unknown
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
try
{
loadingScreenImageTransform = null;
headerImageTransform = null;
loadingImageTransform = null;
menuContainerTransform = null;
creditsContentTransform = null;
creditsTextTransform = null;
versionNumTransform = null;
creditsOffset = 0f;
if (creditsContentTransform == null || creditsTextTransform == null)
{
creditsContentTransform = ((Component)((Component)self).transform.parent.Find("MenuContainer/CreditsPanel/Panel/Scroll View/Viewport/Content")).GetComponent<RectTransform>();
creditsTextTransform = ((Component)((Transform)creditsContentTransform).Find("CreditsText")).GetComponent<RectTransform>();
}
if (menuContainerTransform == null)
{
menuContainerTransform = ((Component)self).transform.parent.Find("MenuContainer");
}
versionNumTransform = menuContainerTransform.Find("VersionNum");
if (versionNumTransform != null)
{
float num = creditsTextTransform.sizeDelta.y / 2f - 50f + creditsOffset;
GameObject val = new GameObject("CreditsHolder");
RectTransform val2 = val.AddComponent<RectTransform>();
((Transform)val2).SetParent((Transform)(object)creditsContentTransform, false);
val2.anchorMin = new Vector2(0f, 0.5f);
val2.anchorMax = new Vector2(1f, 0.5f);
val2.pivot = new Vector2(0.5f, 0.5f);
val2.anchoredPosition = new Vector2(0f, 0f - (num + 10f));
TextMeshProUGUI val3 = ((Component)val2).gameObject.AddComponent<TextMeshProUGUI>();
TextMeshProUGUI component = ((Component)versionNumTransform).GetComponent<TextMeshProUGUI>();
((TMP_Text)val3).horizontalAlignment = (HorizontalAlignmentOptions)2;
((TMP_Text)val3).fontMaterial = ((TMP_Text)component).fontMaterial;
((TMP_Text)val3).fontStyle = ((TMP_Text)component).fontStyle;
((TMP_Text)val3).fontSize = ((TMP_Text)component).fontSize;
((TMP_Text)val3).text = ((TMP_Text)component).text;
((TMP_Text)val3).font = ((TMP_Text)component).font;
((Graphic)val3).color = ((Graphic)component).color;
((TMP_Text)val3).alignment = ((TMP_Text)component).alignment;
((TMP_Text)val3).enableAutoSizing = ((TMP_Text)component).enableAutoSizing;
((TMP_Text)component).text = ((TMP_Text)component).text.Split('\n', ' ')[0] ?? "";
float num2 = ((TMP_Text)val3).preferredHeight + 100f;
creditsOffset += num2;
Vector2 sizeDelta = creditsContentTransform.sizeDelta;
creditsContentTransform.sizeDelta = new Vector2(sizeDelta.x, sizeDelta.y + num2);
}
if (loadingScreenImageTransform == null)
{
Transform val4 = ((Component)self).transform.parent.Find("MenuContainer/LoadingScreen");
for (int i = 0; i < val4.childCount; i++)
{
Transform child = val4.GetChild(i);
Component[] components = ((Component)child).GetComponents<Component>();
if (components.Length == 3)
{
IEnumerable<Component> source = components.Where((Component item) => ((object)item).GetType().ToString() == "UnityEngine.RectTransform" || ((object)item).GetType().ToString() == "UnityEngine.CanvasRenderer" || ((object)item).GetType().ToString() == "UnityEngine.UI.Image");
if (source.Count() == 3)
{
loadingScreenImageTransform = child;
break;
}
}
}
}
if (headerImageTransform == null)
{
headerImageTransform = ((Component)self).transform.parent.Find("MenuContainer/MainButtons");
RectTransform[] componentsInChildren = ((Component)headerImageTransform).GetComponentsInChildren<RectTransform>();
foreach (RectTransform val5 in componentsInChildren)
{
if (((Component)val5).GetComponents<Component>().Length == 3 && (Object)(object)((Component)val5).gameObject != (Object)(object)((Component)headerImageTransform).gameObject && Object.op_Implicit((Object)(object)((Component)val5).GetComponent<RectTransform>()) && Object.op_Implicit((Object)(object)((Component)val5).GetComponent<CanvasRenderer>()) && Object.op_Implicit((Object)(object)((Component)val5).GetComponent<Image>()))
{
headerImageTransform = ((Component)val5).gameObject.transform;
break;
}
}
}
if (loadingImageTransform == null)
{
loadingImageTransform = ((Component)self).transform.parent.Find("MenuContainer/LoadingScreen/Image");
}
}
catch
{
}
orig(self);
misBehaviors = (from item in ((Component)self).GetComponents<Component>()
where ((object)item).GetType().ToString() != "UnityEngine.Transform" && ((object)item).GetType().ToString() != "MenuManager" && ((object)item).GetType().ToString() != "UnityEngine.AudioSource" && ((object)item).GetType().ToString() != "LCSoundTool.AudioSourceExtension"
select item).OfType<Behaviour>().ToArray();
Behaviour[] array = misBehaviors;
foreach (Behaviour val6 in array)
{
val6.enabled = false;
}
}
private static void OnMenuManagerEnableUIPanel(Action<MenuManager, GameObject> orig, MenuManager self, GameObject panel)
{
if (((Object)panel).name == "CreditsPanel")
{
inCredits = true;
}
orig(self, panel);
}
private static void OnMenuManagerDisableUIPanel(Action<MenuManager, GameObject> orig, MenuManager self, GameObject panel)
{
if (((Object)panel).name == "CreditsPanel")
{
inCredits = false;
}
orig(self, panel);
}
}
namespace Utils
{
internal static class HookUtils
{
private const BindingFlags DefaultFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
private const BindingFlags StaticFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
public static Hook NewHook<TTarget, TDest>(string targetMethodName, string destMethodName, TDest instance)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
MethodInfo method = typeof(TTarget).GetMethod(targetMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
MethodInfo method2 = typeof(TDest).GetMethod(destMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
return new Hook((MethodBase)method, method2, (object)instance);
}
public static Hook NewHook<TTarget>(string targetMethodName, MethodInfo destMethod)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
MethodInfo method = typeof(TTarget).GetMethod(targetMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
return new Hook((MethodBase)method, destMethod);
}
public static Hook NewHook<TTarget>(string targetMethodName, Type destType, string destMethodName)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
MethodInfo method = typeof(TTarget).GetMethod(targetMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
MethodInfo method2 = destType.GetMethod(destMethodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
return new Hook((MethodBase)method, method2);
}
public static ILHook NewILHook<TTarget>(string targetMethodName, Manipulator manipulator)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
MethodInfo method = typeof(TTarget).GetMethod(targetMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
return new ILHook((MethodBase)method, manipulator);
}
}
}