Decompiled source of CosmeticToggler v1.0.1

CosmeticToggler.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using CosmeticToggler;
using GorillaNetworking;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "CosmeticToggler", "1.0.1", "Lapis", null)]
[assembly: MelonGame("Another Axiom", "Gorilla Tag")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CosmeticToggler")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+939eb20452440222852951a8b53d49f8fb023307")]
[assembly: AssemblyProduct("CosmeticToggler")]
[assembly: AssemblyTitle("CosmeticToggler")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace CosmeticToggler
{
	internal class Constants
	{
		public const string Version = "1.0.0";

		public const string ModName = "CosmeticToggler";

		public const string ModAuthor = "Lapis";
	}
	public class Mod : MelonMod
	{
		public static Mod instance;

		private bool windowOpen = true;

		private Rect windowRect = new Rect(10f, 10f, 300f, 400f);

		private Vector2 scrollPosition = Vector2.zero;

		private string selectedCosmeticName = "";

		private bool selectedCosmeticActive;

		private List<CosmeticItem> cosmeticsList = new List<CosmeticItem>();

		public override void OnInitializeMelon()
		{
			instance = this;
			MelonLogger.Msg("CosmeticToggler v1.0.0 has loaded!");
		}

		public void AddUpdateCosmeticsSubscriptionIHateThisLmaoPleaseHelpMe()
		{
			CosmeticsController val = CosmeticsController.instance;
			((CosmeticsController)val).OnCosmeticsUpdated = (Action)Delegate.Combine(((CosmeticsController)val).OnCosmeticsUpdated, new Action(UpdateCosmetics));
		}

		public void UpdateCosmetics()
		{
			if ((Object)(object)CosmeticsController.instance != (Object)null && ((CosmeticsController)CosmeticsController.instance).unlockedCosmetics != null)
			{
				cosmeticsList.Clear();
				cosmeticsList.AddRange(((CosmeticsController)CosmeticsController.instance).unlockedCosmetics);
				MelonLogger.Msg($"Loaded {cosmeticsList.Count} cosmetics");
			}
		}

		public override void OnGUI()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			windowRect = GUILayout.Window(0, windowRect, new WindowFunction(DrawWindow), "Cosmetic Toggler", Array.Empty<GUILayoutOption>());
		}

		private void DrawWindow(int windowID)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Available Cosmetics", GUI.skin.box, Array.Empty<GUILayoutOption>());
			scrollPosition = GUILayout.BeginScrollView(scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(250f) });
			foreach (CosmeticItem cosmetics in cosmeticsList)
			{
				string overrideDisplayName = cosmetics.overrideDisplayName;
				if (GUILayout.Button(overrideDisplayName, (selectedCosmeticName == overrideDisplayName) ? GUI.skin.box : GUI.skin.button, Array.Empty<GUILayoutOption>()))
				{
					selectedCosmeticName = overrideDisplayName;
					MelonLogger.Msg("selected cosmetic: " + overrideDisplayName);
				}
			}
			GUILayout.EndScrollView();
			GUILayout.Space(10f);
			GUILayout.Label("Selected: " + (string.IsNullOrEmpty(selectedCosmeticName) ? "None" : selectedCosmeticName), GUI.skin.box, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Toggle " + (string.IsNullOrEmpty(selectedCosmeticName) ? "Cosmetic" : selectedCosmeticName) + " " + (selectedCosmeticActive ? "OFF" : "ON"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				if (!string.IsNullOrEmpty(selectedCosmeticName))
				{
					selectedCosmeticActive = !selectedCosmeticActive;
					MelonLogger.Msg($"Cosmetic '{selectedCosmeticName}' toggled to: {selectedCosmeticActive}");
					CosmeticItem? cosmeticByName = GetCosmeticByName(selectedCosmeticName);
					if (cosmeticByName.HasValue)
					{
						CosmeticItem value = cosmeticByName.Value;
						if (selectedCosmeticActive)
						{
							((CosmeticsController)CosmeticsController.instance).ApplyCosmeticItemToSet(((CosmeticsController)CosmeticsController.instance).currentWornSet, value, false, true);
						}
						else
						{
							((CosmeticsController)CosmeticsController.instance).RemoveCosmeticItemFromSet(((CosmeticsController)CosmeticsController.instance).currentWornSet, value.displayName, true);
						}
						((CosmeticsController)CosmeticsController.instance).UpdateWornCosmetics(true);
					}
					else
					{
						MelonLogger.Msg("Could not find cosmetic item: " + selectedCosmeticName);
					}
				}
				else
				{
					MelonLogger.Msg("No cosmetic selected, ignoring");
				}
			}
			GUILayout.EndVertical();
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
		}

		private CosmeticItem? GetCosmeticByName(string displayName)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			foreach (CosmeticItem cosmetics in cosmeticsList)
			{
				if (cosmetics.overrideDisplayName == displayName)
				{
					return cosmetics;
				}
			}
			return null;
		}
	}
}
namespace CosmeticToggler.Patches
{
	public class CosmeticsControllerPatch
	{
		[HarmonyPatch(typeof(CosmeticsController), "Awake")]
		public class OnCosmeticsUpdatedPatch
		{
			public static void Postfix()
			{
				Mod.instance.AddUpdateCosmeticsSubscriptionIHateThisLmaoPleaseHelpMe();
			}
		}
	}
}