using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using EmotesAPI;
using HG.Reflection;
using On.RoR2.UI;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CustomEmotesAdvancedPicker")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomEmotesAdvancedPicker")]
[assembly: AssemblyTitle("CustomEmotesAdvancedPicker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CustomEmotesAdvancedPicker;
[Serializable]
[BepInPlugin("com.brynzananas.customemotesadvancedpicker", "Custom Emotes Advanced Picker", "1.1.0")]
[BepInDependency("com.bepis.r2api", "5.0.10")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Main : BaseUnityPlugin
{
public class NewPicker : MonoBehaviour
{
private TextMeshProUGUI currentEmoteText;
private ScrollRect scrollRect;
private void OnEnable()
{
BoneMapper localMapper = CustomEmotesAPI.localMapper;
currentEmoteText = ((Component)((Component)this).transform.Find("balls/text")).GetComponent<TextMeshProUGUI>();
((TMP_Text)currentEmoteText).text = "Current Emote: \n" + localMapper.currentClipName;
scrollRect = ((Component)((Component)this).transform.Find("Panel")).GetComponent<ScrollRect>();
scrollRect.scrollSensitivity = Sensivity.Value;
}
private void OnDisable()
{
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
if (HoldAndRelease.Value)
{
if (Object.op_Implicit((Object)(object)selected))
{
try
{
CustomEmotesAPI.PlayAnimation(((Object)selected).name, -2);
}
catch
{
}
}
else if (!continueEmote)
{
try
{
CustomEmotesAPI.PlayAnimation("none", -2);
}
catch
{
}
}
}
if (Object.op_Implicit((Object)(object)selected))
{
((Graphic)selected.GetComponent<Image>()).color = inactiveColor;
}
((Graphic)((Component)((Component)this).transform.Find("balls")).GetComponent<Image>()).color = inactiveColor;
continueEmote = false;
}
private void Update()
{
BoneMapper localMapper = CustomEmotesAPI.localMapper;
((TMP_Text)currentEmoteText).text = "Current Emote: \n" + localMapper.currentClipName;
if (!Input.GetKey((KeyCode)337))
{
}
}
}
public class EmoteClick : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler
{
private string text;
private Image image;
public void OnPointerClick(PointerEventData eventData)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
if ((int)eventData.button == 0)
{
try
{
CustomEmotesAPI.PlayAnimation(text, -2);
}
catch
{
}
trueHud.SetActive(false);
ToggleCursor();
}
}
public void OnPointerEnter(PointerEventData eventData)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
selected = ((Component)this).gameObject;
((Graphic)image).color = activeColor;
}
public void OnPointerExit(PointerEventData eventData)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
selected = null;
((Graphic)image).color = inactiveColor;
}
private void Start()
{
text = ((TMP_Text)((Component)((Component)this).transform.Find("EmoteName")).GetComponent<TextMeshProUGUI>()).text;
image = ((Component)this).GetComponent<Image>();
}
private void Update()
{
}
}
public class ContinueEmote : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler
{
private Image image;
private void Start()
{
image = ((Component)this).GetComponent<Image>();
}
public void OnPointerEnter(PointerEventData eventData)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
continueEmote = true;
((Graphic)image).color = activeColor;
}
public void OnPointerExit(PointerEventData eventData)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
continueEmote = false;
((Graphic)image).color = inactiveColor;
}
public void OnPointerClick(PointerEventData eventData)
{
CustomEmotesAPI.PlayAnimation("none", -2);
trueHud.SetActive(false);
ToggleCursor();
}
}
public const string ModGuid = "com.brynzananas.customemotesadvancedpicker";
public const string ModName = "Custom Emotes Advanced Picker";
public const string ModVer = "1.1.0";
public static AssetBundle UnityAssets;
public GameObject HudObject;
public GameObject EmoteObject;
public static Vector3 mousePosition;
public static GameObject selected;
public static Sprite inactiveSprite;
public static Sprite activeSprite;
public static Color activeColor = new Color(1f, 0.8f, 0f);
public static Color inactiveColor = Color.white;
public static bool continueEmote = false;
public static ConfigEntry<KeyboardShortcut> NewEmoteMenu;
public static ConfigEntry<bool> HoldAndRelease;
public static ConfigEntry<float> Sensivity;
public static GameObject trueHud;
private HUD MenuHud = null;
public static PluginInfo PInfo { get; private set; }
public void Awake()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Expected O, but got Unknown
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Expected O, but got Unknown
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Expected O, but got Unknown
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Expected O, but got Unknown
NewEmoteMenu = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "New Emote Picker", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), "Displays the new emote picker");
HoldAndRelease = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hold And Release", false, "Pick emote by holding and releasing the button");
Sensivity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Scroll Sensivity", 48f, "Control scroll sensivity");
PInfo = ((BaseUnityPlugin)this).Info;
UnityAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(PInfo.Location), "assetbundles", "customemotesadvancedpicker"));
HudObject = UnityAssets.LoadAsset<GameObject>("Assets/CustomEmotes/EmotePicker.prefab");
EmoteObject = UnityAssets.LoadAsset<GameObject>("Assets/CustomEmotes/Emote.prefab");
activeSprite = UnityAssets.LoadAsset<Sprite>("Assets/Noita/HUD/full_inventory_box_highlight.png");
inactiveSprite = UnityAssets.LoadAsset<Sprite>("Assets/Noita/HUD/full_inventory_box.png");
HudObject.AddComponent<NewPicker>();
EmoteObject.AddComponent<EmoteClick>();
((Component)HudObject.transform.Find("balls")).gameObject.AddComponent<ContinueEmote>();
HUD.Awake += new hook_Awake(AwakeMyHud);
ModSettingsManager.AddOption((BaseOption)new KeyBindOption(NewEmoteMenu));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(HoldAndRelease));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(Sensivity));
ModSettingsManager.SetModIcon(UnityAssets.LoadAsset<Sprite>("Assets/CustomEmotes/menu-icon.png"));
}
public void Update()
{
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (PauseManager.isPaused || !Object.op_Implicit((Object)(object)Run.instance))
{
return;
}
int cursorOpenerCount = MPEventSystemManager.primaryEventSystem.cursorOpenerCount;
KeyboardShortcut value;
if (HoldAndRelease.Value)
{
value = NewEmoteMenu.Value;
if (Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
{
if (!trueHud.activeSelf)
{
trueHud.SetActive(true);
if (cursorOpenerCount <= 0)
{
ToggleCursor();
}
}
}
else if (trueHud.activeSelf)
{
trueHud.SetActive(false);
if (cursorOpenerCount > 0)
{
ToggleCursor();
}
}
}
else
{
value = NewEmoteMenu.Value;
if (Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
{
if (trueHud.activeSelf)
{
trueHud.SetActive(false);
if (cursorOpenerCount > 0)
{
ToggleCursor();
}
}
else
{
trueHud.SetActive(true);
if (cursorOpenerCount <= 0)
{
ToggleCursor();
}
}
}
}
if (Input.GetKeyDown((KeyCode)27) && trueHud.activeSelf)
{
trueHud.SetActive(false);
if (cursorOpenerCount > 0)
{
ToggleCursor();
}
}
}
public static int ToggleCursor()
{
MPEventSystem primaryEventSystem = MPEventSystemManager.primaryEventSystem;
primaryEventSystem.cursorOpenerCount = ((primaryEventSystem.cursorOpenerCount <= 0) ? 1 : 0);
primaryEventSystem.cursorOpenerForGamepadCount = ((primaryEventSystem.cursorOpenerForGamepadCount <= 0) ? 1 : 0);
return primaryEventSystem.cursorOpenerCount;
}
public static void SaveCursorPosition()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
mousePosition = Input.mousePosition;
}
private void AwakeMyHud(orig_Awake orig, HUD self)
{
orig.Invoke(self);
if (Object.op_Implicit((Object)(object)trueHud))
{
return;
}
MenuHud = self;
GameObject val = Object.Instantiate<GameObject>(HudObject);
List<string> list = new List<string>();
foreach (KeyValuePair<string, CustomAnimationClip> animClip in BoneMapper.animClips)
{
list.Add(animClip.Key);
}
list.Sort();
foreach (string item in list)
{
Debug.Log((object)("Emote: " + item));
GameObject val2 = Object.Instantiate<GameObject>(EmoteObject);
((Object)val2).name = item;
((TMP_Text)((Component)val2.transform.Find("EmoteName")).GetComponent<TextMeshProUGUI>()).text = item;
val2.transform.SetParent(val.transform.Find("Panel/scroll"));
}
val.SetActive(false);
trueHud = val;
Object.DontDestroyOnLoad((Object)(object)trueHud);
}
}