using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("EmoteWheelPage")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EmoteWheelPage")]
[assembly: AssemblyTitle("EmoteWheelPage")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 EmoteWheelPage
{
[BepInPlugin("xtyob.emotewheelpage", "EmoteWheelPage", "1.0.0")]
public sealed class Plugin : BaseUnityPlugin
{
public const string Guid = "xtyob.emotewheelpage";
public const string Name = "EmoteWheelPage";
public const string Version = "1.0.0";
internal static ConfigEntry<int> DefaultPage;
internal static ConfigEntry<bool> EveryOpen;
private void Awake()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
DefaultPage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "DefaultPage", 2, new ConfigDescription("Page the emote wheel opens on (1 = the game's first page).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
EveryOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ResetEveryOpen", true, "true = always open on DefaultPage. false = only the first time; afterwards the wheel remembers the last page you used (vanilla behaviour).");
new Harmony("xtyob.emotewheelpage").PatchAll(typeof(Plugin).Assembly);
((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded. Emote wheel opens on page {2}.", "EmoteWheelPage", "1.0.0", DefaultPage.Value));
}
}
[HarmonyPatch(typeof(EmoteWheel), "OnEnable")]
internal static class EmoteWheel_OnEnable
{
private static readonly FieldRef<EmoteWheel, int> Page = AccessTools.FieldRefAccess<EmoteWheel, int>("page");
private static readonly HashSet<EmoteWheel> Initialised = new HashSet<EmoteWheel>();
private static void Prefix(EmoteWheel __instance)
{
Initialised.RemoveWhere((EmoteWheel w) => !Object.op_Implicit((Object)(object)w));
if (Plugin.EveryOpen.Value || Initialised.Add(__instance))
{
Initialised.Add(__instance);
int num = ((__instance.pages < 1) ? 1 : __instance.pages);
int num2 = ((__instance.slices != null && __instance.slices.Length != 0) ? __instance.slices.Length : 8);
int val = ((__instance.data != null) ? (__instance.data.Length / num2) : num);
int num3 = Math.Max(0, Math.Min(num, val) - 1);
int num4 = Plugin.DefaultPage.Value - 1;
Page.Invoke(__instance) = ((num4 >= 0) ? ((num4 > num3) ? num3 : num4) : 0);
}
}
}
}