Decompiled source of Sash Colour Changer v1.0.1

SashColourChanger.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
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: AssemblyCompany("SashColourChanger")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("SashColourChanger")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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;
		}
	}
}
namespace SashColourChanger
{
	[BepInPlugin("SashColourChanger", "My first plugin", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private int currentIndex = 0;

		private MethodInfo getCustomizationDataMethod;

		private MethodInfo setCustomizationDataMethod;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin SashColourChanger is loaded!");
			Type typeFromHandle = typeof(CharacterCustomization);
			getCustomizationDataMethod = typeFromHandle.GetMethod("GetCustomizationData", BindingFlags.Static | BindingFlags.NonPublic);
			setCustomizationDataMethod = typeFromHandle.GetMethod("SetCustomizationData", BindingFlags.Static | BindingFlags.NonPublic);
			if (getCustomizationDataMethod == null || setCustomizationDataMethod == null)
			{
				Logger.LogError((object)"Borked");
			}
		}

		private void Update()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			if (Input.GetKeyDown((KeyCode)110))
			{
				Player localPlayer = PhotonNetwork.LocalPlayer;
				if (localPlayer == null)
				{
					Logger.LogError((object)"No local player found :( ");
					return;
				}
				if (getCustomizationDataMethod == null || setCustomizationDataMethod == null)
				{
					Logger.LogError((object)"Customization methods not found :(");
					return;
				}
				CharacterCustomizationData val = (CharacterCustomizationData)getCustomizationDataMethod.Invoke(null, new object[1] { localPlayer });
				val.currentSash = currentIndex;
				setCustomizationDataMethod.Invoke(null, new object[2] { val, localPlayer });
				Logger.LogInfo((object)$"Sash color changed to index {currentIndex}");
				currentIndex = (currentIndex + 1) % 9;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SashColourChanger";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}