Decompiled source of Valette v1.0.0

VeryVeryValet-Valette.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 System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Toyful;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("VeryVeryValet-Valette")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+948729135553c53bf0bfe1de146cf5ff496c835a")]
[assembly: AssemblyProduct("VeryVeryValet-Valette")]
[assembly: AssemblyTitle("VeryVeryValet-Valette")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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 TemplatePlugin
{
	internal static class TemplatePluginInfo
	{
		public const string PLUGIN_GUID = "very_very_valet_valette";

		public const string PLUGIN_NAME = "Valette";

		public const string GAME_NAME = "Very Very Valet";
	}
}
namespace VeryVeryValet_Valette
{
	[BepInPlugin("very_very_valet_valette", "Valette", "1.0.0")]
	public class PluginMain : BaseUnityPlugin
	{
		private struct RigColors
		{
			public Color main;

			public Color secondary;

			public Color tertiary;

			public Color clothingA;

			public Color clothingB;

			public Color clothingC;
		}

		[HarmonyPatch(typeof(ValetSelectPlayerUi))]
		private class ValetSelectPlayerUi_Patches
		{
			private static readonly Dictionary<int, bool> colorEditMode = new Dictionary<int, bool>();

			[HarmonyPatch("Update")]
			[HarmonyPrefix]
			public static bool OnUpdate(ValetSelectPlayerUi __instance)
			{
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: 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_01ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cd: Invalid comparison between Unknown and I4
				//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0247: Unknown result type (might be due to invalid IL or missing references)
				//IL_024d: Invalid comparison between Unknown and I4
				//IL_0284: Unknown result type (might be due to invalid IL or missing references)
				int playerId = __instance._playerId;
				if (playerId < 0 || !ControlsManager.instance.IsPlayerActive(playerId) || !ScreenManager.instance.isSafeToAdjust)
				{
					return false;
				}
				float num = UtilsTime.AdjustDeltaTime(Time.deltaTime, (Scales)0);
				Vector2 val = ControlsManager.instance.FilterAxisInput(num, (ControlMaps)3, __instance._playerIndex, ref __instance._axisX, ref __instance._axisY, ref __instance._axisRepeatT);
				if (!colorEditMode.ContainsKey(playerId))
				{
					colorEditMode[playerId] = false;
				}
				if (ControlsManager.instance.GetButtonDown((ControlMaps)3, (ControlActions)2, new int[1] { playerId }))
				{
					colorEditMode[playerId] = !colorEditMode[playerId];
				}
				if (colorEditMode[playerId])
				{
					PlayerReference playerReference = __instance._playerManager.GetPlayerReference(playerId);
					if (!selectedColorIndex.ContainsKey(playerId))
					{
						selectedColorIndex[playerId] = 0;
					}
					if (!editingBrightness.ContainsKey(playerId))
					{
						editingBrightness[playerId] = false;
					}
					if (ControlsManager.instance.GetButtonDown((ControlMaps)3, (ControlActions)5, new int[1] { playerId }))
					{
						selectedColorIndex[playerId] = (selectedColorIndex[playerId] + 1) % 3;
					}
					if (ControlsManager.instance.GetButtonDown((ControlMaps)3, (ControlActions)6, new int[1] { playerId }))
					{
						editingBrightness[playerId] = !editingBrightness[playerId];
					}
					HandleColorEditing(playerReference, val, selectedColorIndex[playerId], editingBrightness[playerId]);
					val = Vector2.zero;
				}
				if (val != Vector2.zero && (int)__instance._state == 1 && !__instance._isControlsActive)
				{
					__instance.CycleCharacter(val.x);
				}
				if (__instance._controlsPanel.isExpanded)
				{
					__instance._controlsPanel.UpdateInput();
				}
				if (ControlsManager.instance.GetButtonDown((ControlMaps)3, (ControlActions)1, new int[1] { playerId }))
				{
					__instance.OnCancelAction();
				}
				if (ControlsManager.instance.GetButtonDown((ControlMaps)3, (ControlActions)7, new int[1] { playerId }) && (int)__instance._state == 1)
				{
					__instance.ToggleControls(false);
				}
				if (ControlsManager.instance.GetButtonDown((ControlMaps)3, (ControlActions)0, new int[1] { playerId }))
				{
					__instance.OnConfirmAction();
				}
				if ((int)__instance._state == 0 && ControlsManager.instance.GetButton((ControlMaps)3, (ControlActions)5, new int[1] { playerId }) && ControlsManager.instance.GetButton((ControlMaps)3, (ControlActions)6, new int[1] { playerId }))
				{
					__instance.SetState((PlayerState)1);
				}
				return false;
			}

			private static void HandleColorEditing(PlayerReference player, Vector2 stick, int colorIndex, bool brightnessMode)
			{
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				CharacterRig characterRig = player.CharacterRig;
				CharacterInputRewired input = player.Input;
				if (!((Object)(object)characterRig == (Object)null) && !((Object)(object)input == (Object)null) && TryGetRigColors(characterRig, out var colors))
				{
					if (1 == 0)
					{
					}
					Color val = (Color)(colorIndex switch
					{
						1 => colors.secondary, 
						2 => colors.tertiary, 
						_ => colors.main, 
					});
					if (1 == 0)
					{
					}
					Color val2 = val;
					float num = default(float);
					float num2 = default(float);
					float num3 = default(float);
					Color.RGBToHSV(val2, ref num, ref num2, ref num3);
					num += stick.x * 2f * Time.deltaTime;
					if (brightnessMode)
					{
						num3 += stick.y * 4f * Time.deltaTime;
					}
					else
					{
						num2 += stick.y * 4f * Time.deltaTime;
					}
					num = Mathf.Repeat(num, 1f);
					num2 = Mathf.Clamp01(num2);
					num3 = Mathf.Clamp01(num3);
					Color val3 = Color.HSVToRGB(num, num2, num3);
					switch (colorIndex)
					{
					case 1:
						colors.secondary = val3;
						break;
					case 2:
						colors.tertiary = val3;
						break;
					default:
						colors.main = val3;
						break;
					}
					ApplyRigColors(characterRig, colors);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerMgr))]
		private static class PlayerColorPatch
		{
			[HarmonyPatch("SetPlayerColor")]
			[HarmonyPrefix]
			private static bool OnSetPlayerColor(PlayerMgr __instance, int playerID)
			{
				return false;
			}
		}

		public const string GameName = "Very Very Valet";

		private const string Version = "1.0.0";

		private readonly Harmony _harmony = new Harmony("very_very_valet_valette");

		public static ManualLogSource? logger;

		private static readonly Dictionary<int, int> selectedColorIndex = new Dictionary<int, int>();

		private static readonly Dictionary<int, bool> editingBrightness = new Dictionary<int, bool>();

		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			_harmony.PatchAll();
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			SceneManager.sceneLoaded += delegate
			{
			};
		}

		private static bool TryGetRigColors(CharacterRig rig, out RigColors colors)
		{
			colors = default(RigColors);
			if (!rig.GetColors(ref colors.main, ref colors.secondary, ref colors.tertiary, ref colors.clothingA, ref colors.clothingB, ref colors.clothingC))
			{
				return false;
			}
			return true;
		}

		private static void ApplyRigColors(CharacterRig rig, RigColors c)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			rig.SetColors(c.main, c.secondary, c.tertiary, c.clothingA, c.clothingB, c.clothingC, Random.ColorHSV());
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}