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;
using System.Security.Permissions;
using AtlyssEmotes;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using Nessie.ATLYSS.EasySettings;
using UnityEngine;
using UnityEngine.Events;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AtlyssEmotes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AtlyssEmotes")]
[assembly: AssemblyTitle("AtlyssEmotes")]
[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;
}
}
}
[CreateAssetMenu(fileName = "EmoteWheelEmotes", menuName = "ScriptableObjects/Custom/EmoteWheelEmotes", order = 1)]
public class EmoteWheelEmotes : ScriptableObject
{
public List<ScriptableEmote> list;
}
public static class EmoteWheelSettings
{
[CompilerGenerated]
private static class <>O
{
public static UnityAction <0>__AddSettings;
public static UnityAction <1>__Apply;
}
private static ConfigFile saveFile;
public static ConfigEntry<KeyCode> EmoteWheelKey { get; private set; }
public static ConfigEntry<bool> Mouth { get; private set; }
public static void Awake()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
Plugin.Logger.LogInfo((object)"Initializing Settings");
saveFile = ((BaseUnityPlugin)Plugin.plugin).Config;
InitConfiguration();
UnityEvent onInitialized = Settings.OnInitialized;
object obj = <>O.<0>__AddSettings;
if (obj == null)
{
UnityAction val = AddSettings;
<>O.<0>__AddSettings = val;
obj = (object)val;
}
onInitialized.AddListener((UnityAction)obj);
UnityEvent onApplySettings = Settings.OnApplySettings;
object obj2 = <>O.<1>__Apply;
if (obj2 == null)
{
UnityAction val2 = Apply;
<>O.<1>__Apply = val2;
obj2 = (object)val2;
}
onApplySettings.AddListener((UnityAction)obj2);
}
private static void Apply()
{
saveFile.Save();
if ((Object)(object)Plugin.Mouth != (Object)null)
{
Plugin.Mouth.SetActive(Mouth.Value);
}
}
private static void InitConfiguration()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
ConfigDefinition val = new ConfigDefinition("Keys", "EmoteWheel");
ConfigDescription val2 = new ConfigDescription("Key to pull up the Emote Wheel.", (AcceptableValueBase)null, Array.Empty<object>());
EmoteWheelKey = saveFile.Bind<KeyCode>(val, (KeyCode)93, val2);
ConfigDefinition val3 = new ConfigDefinition("Toggles", "EmoteWheel");
ConfigDescription val4 = new ConfigDescription("Toggles Live Mouth Reaction", (AcceptableValueBase)null, Array.Empty<object>());
Mouth = saveFile.Bind<bool>(val3, false, val4);
}
private static void AddSettings()
{
SettingsTab modTab = Settings.ModTab;
modTab.AddHeader("Emote Wheel");
modTab.AddKeyButton("Emote Wheel Key", EmoteWheelKey);
modTab.AddToggle("Live Mouth Reaction", Mouth);
}
}
public class MouthReaction : MonoBehaviour
{
private Image image;
private float currentTimer;
private const float timermin = 120f;
private const float timermax = 240f;
private const float disappeartimermin = 2f;
private const float disappeartimermax = 10f;
private void Start()
{
image = ((Component)this).GetComponent<Image>();
((Behaviour)image).enabled = false;
currentTimer = Random.Range(120f, 240f);
}
private void Update()
{
if (currentTimer <= 0f)
{
((Behaviour)image).enabled = !((Behaviour)image).enabled;
if (((Behaviour)image).enabled)
{
currentTimer = Random.Range(2f, 10f);
}
else
{
currentTimer = Random.Range(120f, 240f);
}
}
else
{
currentTimer -= Time.deltaTime;
}
}
}
[CreateAssetMenu(fileName = "Emote", menuName = "ScriptableObjects/Custom/Emote", order = 1)]
public class ScriptableEmote : ScriptableObject
{
public Sprite icon;
public string emoteString;
}
public class WheelBehavior : MonoBehaviour
{
[HarmonyPatch]
private class Patches
{
[HarmonyPatch(typeof(PlayerCombat), "<Init_Attack>g__AbleToInitAttack|102_0")]
[HarmonyPostfix]
private static void PatchCanAttack(ref bool __result)
{
if ((Object)(object)instance != (Object)null && instance.active)
{
__result = false;
}
}
}
public static WheelBehavior instance;
[Header("Emote Icons")]
public Image[] EmoteBackgrounds;
public Image[] EmoteIcons;
public EmoteWheelEmotes Emotes;
public Sprite EmoteUnselected;
public Sprite EmoteSelected;
public float WheelRadius;
public float LerpSpeed;
[SerializeField]
private bool InUnityEdtior;
private Vector2 centeredMousePosition;
private float mouseAngle;
private float openProgress;
private int selectedIndex;
private bool active;
private Canvas canvas;
private ChatBehaviour chat;
private void Start()
{
canvas = ((Component)this).GetComponent<Canvas>();
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
if (!InUnityEdtior)
{
chat = ChatBehaviour._current;
}
}
private void Update()
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
if (active)
{
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
CameraFunction._current._unlockedCamera = true;
InGameUI._current._escapeMenuElement.isEnabled = false;
openProgress = Mathf.Lerp(openProgress, 1f, 1f - Mathf.Pow(1f - 1f / LerpSpeed, Time.deltaTime));
centeredMousePosition = Vector2.op_Implicit(Input.mousePosition - new Vector3((float)(Screen.width / 2), (float)(Screen.height / 2)));
mouseAngle = MathF.PI * 2f / 3f - Mathf.Atan2(centeredMousePosition.y, centeredMousePosition.x);
float num = mouseAngle / (MathF.PI * 2f) * 6f;
if (num < 0f)
{
num += 6f;
}
selectedIndex = Mathf.FloorToInt(num);
if (Input.GetMouseButtonUp(0))
{
Plugin.Logger.LogInfo((object)EmoteWheelSettings.Mouth.Value);
active = false;
PlayEmote(selectedIndex);
CameraFunction._current._unlockedCamera = false;
}
}
else
{
openProgress = Mathf.Lerp(openProgress, 0f, 1f - Mathf.Pow(1f - 1f / LerpSpeed, Time.deltaTime));
}
if (InUnityEdtior)
{
if (Input.GetKeyDown((KeyCode)93))
{
active = !active;
}
}
else
{
if ((!ChatBehaviour._current._focusedInChat && Input.GetKeyDown(EmoteWheelSettings.EmoteWheelKey.Value)) || (active && Input.GetKeyDown((KeyCode)27)))
{
active = !active;
if (!active)
{
CameraFunction._current._unlockedCamera = false;
}
}
if (SettingsManager._current._isOpen || DialogManager._current._isDialogEnabled || TabMenu._current._isOpen || InGameUI._current._escapeMenuElement.isEnabled)
{
active = false;
}
}
if (openProgress > 0.1f)
{
((Behaviour)canvas).enabled = true;
}
else
{
((Behaviour)canvas).enabled = false;
}
for (int i = 0; i < EmoteBackgrounds.Length; i++)
{
((Component)EmoteBackgrounds[i]).gameObject.SetActive(openProgress > 0.1f);
if (i == selectedIndex)
{
EmoteBackgrounds[i].sprite = EmoteSelected;
}
else
{
EmoteBackgrounds[i].sprite = EmoteUnselected;
}
((Component)EmoteBackgrounds[i]).transform.localPosition = Vector2.op_Implicit(new Vector2(openProgress * WheelRadius * Mathf.Sin((float)i * MathF.PI / 3f), openProgress * WheelRadius * Mathf.Cos((float)i * MathF.PI / 3f)));
if (active)
{
EmoteIcons[i].sprite = Emotes.list[i].icon;
}
}
}
private void PlayEmote(int index)
{
if (InUnityEdtior)
{
Debug.Log((object)Emotes.list[index].emoteString);
}
else
{
chat.Cmd_SendChatMessage(Emotes.list[index].emoteString, (ChatChannel)1);
}
}
}
namespace AtlyssEmotes
{
public static class AssetHandler
{
public static Dictionary<string, AssetBundle> bundles = new Dictionary<string, AssetBundle>();
public static void GetAssetBundle(string bundlename)
{
Plugin.Logger.LogInfo((object)("Loading bundle: " + bundlename));
AssetBundle value = AssetBundle.LoadFromFile(Path.Combine(Utilities.path, bundlename));
bundles.Add(bundlename, value);
Plugin.Logger.LogInfo((object)("Bundle " + bundlename + " Loaded!"));
Plugin.Logger.LogInfo((object)((Object)bundles[bundlename]).name);
}
public static void GetAssetBundles()
{
GetAssetBundle("emotewheel");
}
public static T FetchFromBundle<T>(string bundle, string key) where T : Object
{
return bundles[bundle].LoadAsset<T>(key);
}
}
[BepInPlugin("com.snivyxxy.plugins.atlyssemotes", "Atlyss Emotes", "1.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("ATLYSS.exe")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch]
private static class GetPlayer
{
[HarmonyPatch(typeof(Player), "OnGameConditionChange")]
[HarmonyPostfix]
private static void getPlayer(ref Player __instance, GameCondition _newCondition)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)__instance._currentGameCondition == 1 && ((NetworkBehaviour)__instance).isLocalPlayer)
{
Logger.LogInfo((object)"Getting Player...");
if ((Object)(object)player == (Object)null)
{
Logger.LogInfo((object)"Loading Assets...");
player = __instance;
GameObject val = AssetHandler.FetchFromBundle<GameObject>("emotewheel", "LiveMouthReaction");
GameObject val2 = AssetHandler.FetchFromBundle<GameObject>("emotewheel", "EmoteWheel");
Mouth = Object.Instantiate<GameObject>(val, ((Component)player).gameObject.transform.Find("_Canvas_DynamicPlayerUI"));
Mouth.SetActive(EmoteWheelSettings.Mouth.Value);
Object.Instantiate<GameObject>(val2, ((Component)player).gameObject.transform);
Logger.LogInfo((object)"Assets Loaded!");
}
if ((Object)(object)player != (Object)null)
{
Logger.LogInfo((object)("Player " + ((Object)((Component)__instance).gameObject).name + " got!"));
}
else
{
Logger.LogError((object)"Player wasn't got because it was null ;-;");
}
}
}
}
public static ManualLogSource Logger;
private static Player player;
public static GameObject Mouth;
public static Plugin plugin { get; private set; }
private void Awake()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin AtlyssEmotes is loaded!");
plugin = this;
new Harmony("AtlyssEmotes").PatchAll();
EmoteWheelSettings.Awake();
Harmony val = new Harmony("AtlyssEmotes");
val.PatchAll();
AssetHandler.GetAssetBundles();
}
}
public static class Utilities
{
public static string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "AtlyssEmotes";
public const string PLUGIN_NAME = "AtlyssEmotes";
public const string PLUGIN_VERSION = "1.0.0";
}
}