Decompiled source of Scrollmotes v1.0.0

BepInEx/plugins/Scrollmotes.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Mirror;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("KRW's Emote Scroller")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("KRW's Emote Scroller")]
[assembly: AssemblyTitle("KRW's Emote Scroller")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace KRWEmoteScroller;

[BepInPlugin("mods.krwclassic.zortemotescroller", "KRW's Zort Emote Scroller", "1.0.0")]
public class KRWEmoteScrollerPlugin : BaseUnityPlugin
{
	private static Harmony _harmony;

	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		_harmony = new Harmony("mods.krwclassic.zortemotescroller");
		_harmony.PatchAll(typeof(EmoteScrollPatch));
	}
}
[HarmonyPatch(typeof(PlayerController), "Update")]
internal static class EmoteScrollPatch
{
	private static int _scrollEmoteIndex;

	private static Transform[] _emoteSlots;

	internal static int SelectedEmoteIndex => _scrollEmoteIndex;

	private static void Prefix(PlayerController __instance)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		if (!((NetworkBehaviour)__instance).isLocalPlayer)
		{
			return;
		}
		if (Input.GetButton("Emote"))
		{
			float y = Input.mouseScrollDelta.y;
			if (y != 0f)
			{
				int num = PlayerAnimator.HASH_ANIM_EMOTES.Length;
				if (num > 0 && __instance.Data.isGrounded)
				{
					int num2 = ((!(y > 0f)) ? 1 : (-1));
					_scrollEmoteIndex = (_scrollEmoteIndex + num2) % num;
					if (_scrollEmoteIndex < 0)
					{
						_scrollEmoteIndex += num;
					}
					UpdateEmoteSelectionUI(_scrollEmoteIndex);
				}
			}
		}
		if (Input.GetButtonUp("Emote") && __instance.Data.isGrounded)
		{
			typeof(PlayerController).GetMethod("PlayEmoteCmd", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[1] { typeof(int) }, null)?.Invoke(__instance, new object[1] { _scrollEmoteIndex });
		}
	}

	private static void UpdateEmoteSelectionUI(int selectedIndex)
	{
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		if (_emoteSlots == null || _emoteSlots.Length != 4)
		{
			_emoteSlots = (Transform[])(object)new Transform[4];
			for (int i = 0; i < 4; i++)
			{
				GameObject val = GameObject.Find($"InGameUICanvas/EmotesParent/Emotes/EmoteSloteUI_{i + 1}");
				if ((Object)(object)val != (Object)null)
				{
					_emoteSlots[i] = val.transform;
				}
			}
		}
		for (int j = 0; j < 4; j++)
		{
			if ((Object)(object)_emoteSlots[j] != (Object)null)
			{
				float num = ((j == selectedIndex) ? 1.35f : 1f);
				_emoteSlots[j].localScale = new Vector3(num, num, num);
			}
		}
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "mods.krwclassic.zortemotescroller";

	public const string PLUGIN_NAME = "KRW's Zort Emote Scroller";

	public const string PLUGIN_VERSION = "1.0.0";
}