using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("ImGogole")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+28906c51394ffff726c4bb8da0cdba07ec3a4e6e")]
[assembly: AssemblyProduct("SomeEmotesREPO")]
[assembly: AssemblyTitle("SomeEmotesREPO")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.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.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;
}
}
[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;
}
}
}
[Serializable]
public class Preferences
{
public List<string> farovites = new List<string>();
public KeyCode panelKey = (KeyCode)112;
}
namespace SomeEmotesREPO
{
[HarmonyPatch(typeof(PlayerAvatar))]
internal class AddEmoteSystemPatch
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(PlayerAvatar __instance)
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
if (GameManager.Multiplayer())
{
if (Object.op_Implicit((Object)(object)GameManager.instance) && GameManager.instance.connectRandom)
{
SomeEmotesREPO.Logger.LogWarning((object)"CAUTION ! You are using a mod in a public lobby, people who doesn't have the mod and yourself can have some errors due to compatibility.");
}
EmoteSystem emoteSystem = ((Component)__instance).GetComponent<EmoteSystem>();
if (!Object.op_Implicit((Object)(object)emoteSystem))
{
emoteSystem = ((Component)__instance).gameObject.AddComponent<EmoteSystem>();
}
emoteSystem.SetPlayerAvatar(__instance);
if (__instance.photonView.IsMine)
{
SomeEmotesREPO.Logger.LogInfo((object)$"EmoteSystem has been added to the player. Press [{EmoteLoader.PanelKey}] to see the Emote Panel.");
}
}
else
{
SomeEmotesREPO.Logger.LogInfo((object)"Not in a multiplayer game : ignored.");
}
}
}
[HarmonyPatch(typeof(GameDirector))]
internal class AddPatchGameDirector
{
[HarmonyPrefix]
[HarmonyPatch("DeathStart")]
private static void DeathStart_Prefix()
{
if (EmoteSystem.Ready && EmoteSystem.Instance.IsEmoting)
{
EmoteSystem.Instance.StopEmote();
}
}
}
[HarmonyPatch(typeof(PlayerExpression))]
internal class AddPatchPlayerExpression
{
[HarmonyPrefix]
[HarmonyPatch("DoExpression")]
private static bool DoExpression_Prefix()
{
return !BlockBecauseEmoteIsPlaying();
}
[HarmonyPrefix]
[HarmonyPatch("ToggleExpression")]
private static bool ToggleExpression_Prefix()
{
return !BlockBecauseEmoteIsPlaying();
}
private static bool BlockBecauseEmoteIsPlaying()
{
return EmoteSystem.Ready && EmoteSystem.Instance.IsEmoting;
}
}
public static class EmoteBundleLoader
{
private static AssetBundle emoteBundle;
public static AssetBundle Load(string path)
{
if ((Object)(object)emoteBundle == (Object)null)
{
emoteBundle = AssetBundle.LoadFromFile(path);
if ((Object)(object)emoteBundle == (Object)null)
{
SomeEmotesREPO.Logger.LogError((object)"EmoteBundle is not found");
}
}
return emoteBundle;
}
public static void Unload()
{
if ((Object)(object)emoteBundle != (Object)null)
{
emoteBundle.Unload(true);
emoteBundle = null;
}
}
public static T LoadAsset<T>(string name) where T : Object
{
if ((Object)(object)emoteBundle == (Object)null)
{
return default(T);
}
name = name.ToLower();
string[] allAssetNames = emoteBundle.GetAllAssetNames();
string[] array = allAssetNames;
foreach (string text in array)
{
if (text.ToLower().EndsWith(name))
{
return emoteBundle.LoadAsset<T>(text);
}
}
return default(T);
}
public static List<string> GetAllAnimNames()
{
List<string> list = new List<string>();
string[] allAssetNames = emoteBundle.GetAllAssetNames();
foreach (string text in allAssetNames)
{
if (text.EndsWith(".anim"))
{
list.Add(text);
}
}
return list;
}
}
public class EmoteLauncher : MonoBehaviour
{
public Animator animator;
public EmoteSystem emoteSystem;
public List<string> emoteNames = new List<string>();
private Dictionary<string, AnimationClip> animationDict = new Dictionary<string, AnimationClip>();
private AnimatorOverrideController overrideController;
private string overrideKeyName = "Placeholder";
private float initialRot;
private Transform targetPlayer;
private GameObject visuals;
private GameObject spotlight;
public SkinnedMeshRenderer leg_R;
public SkinnedMeshRenderer leg_L;
public SkinnedMeshRenderer body_bot;
public SkinnedMeshRenderer body_top_sphere;
public SkinnedMeshRenderer arm_L;
public SkinnedMeshRenderer arm_R;
public SkinnedMeshRenderer health_LED;
public SkinnedMeshRenderer health_frame;
public SkinnedMeshRenderer health_shadow;
public SkinnedMeshRenderer head_bot_sphere;
public SkinnedMeshRenderer head_bot_flat;
public SkinnedMeshRenderer head_top;
public SkinnedMeshRenderer eye_L;
public SkinnedMeshRenderer iris_L;
public SkinnedMeshRenderer eye_R;
public SkinnedMeshRenderer iris_R;
public List<string> EmoteNames => emoteNames;
public void AddEntry(string name, AnimationClip clip)
{
animationDict.Add(name, clip);
}
public void Init(Transform target)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
targetPlayer = target;
visuals = ((Component)((Component)this).transform.GetChild(0)).gameObject;
spotlight = ((Component)((Component)this).transform.GetChild(1)).gameObject;
animator = ((Component)this).GetComponentInChildren<Animator>();
overrideController = new AnimatorOverrideController(animator.runtimeAnimatorController);
animator.runtimeAnimatorController = (RuntimeAnimatorController)(object)overrideController;
foreach (KeyValuePair<string, AnimationClip> item in animationDict)
{
emoteNames.Add(item.Key);
}
InitBones();
InitLight();
visuals.SetActive(false);
spotlight.SetActive(false);
}
private void Update()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)targetPlayer))
{
((Component)this).transform.position = targetPlayer.position;
}
}
private void LateUpdate()
{
//IL_002d: 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_004d: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)emoteSystem) && emoteSystem.IsEmoting)
{
((Component)this).transform.eulerAngles = new Vector3(((Component)this).transform.eulerAngles.x, initialRot, ((Component)this).transform.eulerAngles.z);
}
}
public void SetFavorites(List<string> favs)
{
if (favs != null && favs.Count != 0)
{
List<string> list = favs.Where(emoteNames.Contains).Distinct().ToList();
if (list.Count != 0)
{
emoteNames.RemoveAll(list.Contains);
emoteNames.InsertRange(0, list);
EmoteLoader.Instance.emotesName = new List<string>(emoteNames);
int count = Math.Min(8, emoteNames.Count);
List<string> favorites = emoteNames.Take(count).ToList();
EmoteLoader.Instance.SetFavorites(favorites);
}
}
}
public void SetRotation(float _initialRot)
{
initialRot = _initialRot;
}
public bool Animate(string emoteName)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (!animationDict.TryGetValue(emoteName, out AnimationClip value))
{
return false;
}
((Component)animator).transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
visuals.SetActive(true);
spotlight.SetActive(true);
overrideController[overrideKeyName] = value;
animator.ResetTrigger("StopEmote");
animator.SetTrigger("TriggerEmote");
return true;
}
public void StopEmote()
{
visuals.SetActive(false);
spotlight.SetActive(false);
animator.SetTrigger("StopEmote");
}
private void InitLight()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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)
Light val = spotlight.AddComponent<Light>();
((Component)val).transform.localPosition = Vector3.up * 2.5f;
((Component)val).transform.localEulerAngles = -Vector3.left * 90f;
val.type = (LightType)0;
val.innerSpotAngle = 35f;
val.spotAngle = 40f;
val.color = new Color(1f, 0.97f, 0.84f);
val.intensity = 1.75f;
val.bounceIntensity = 1f;
val.range = 5f;
val.shadows = (LightShadows)0;
val.cullingMask = -1;
}
private void InitBones()
{
leg_R = ((Component)FindDeepChild(((Component)this).transform, "leg_R_0")).GetComponent<SkinnedMeshRenderer>();
leg_L = ((Component)FindDeepChild(((Component)this).transform, "leg_L_0")).GetComponent<SkinnedMeshRenderer>();
body_bot = ((Component)FindDeepChild(((Component)this).transform, "body_bot_0")).GetComponent<SkinnedMeshRenderer>();
body_top_sphere = ((Component)FindDeepChild(((Component)this).transform, "body_top_sphere_0")).GetComponent<SkinnedMeshRenderer>();
arm_L = ((Component)FindDeepChild(((Component)this).transform, "arm_L_0")).GetComponent<SkinnedMeshRenderer>();
arm_R = ((Component)FindDeepChild(((Component)this).transform, "arm_R_0")).GetComponent<SkinnedMeshRenderer>();
health_LED = ((Component)FindDeepChild(((Component)this).transform, "health_LED_0")).GetComponent<SkinnedMeshRenderer>();
health_frame = ((Component)FindDeepChild(((Component)this).transform, "health_frame_0")).GetComponent<SkinnedMeshRenderer>();
health_shadow = ((Component)FindDeepChild(((Component)this).transform, "health_shadow_0")).GetComponent<SkinnedMeshRenderer>();
head_bot_sphere = ((Component)FindDeepChild(((Component)this).transform, "head_bot_sphere_0")).GetComponent<SkinnedMeshRenderer>();
head_bot_flat = ((Component)FindDeepChild(((Component)this).transform, "head_bot_flat_0")).GetComponent<SkinnedMeshRenderer>();
head_top = ((Component)FindDeepChild(((Component)this).transform, "head_top_0")).GetComponent<SkinnedMeshRenderer>();
eye_L = ((Component)FindDeepChild(((Component)this).transform, "eye_L_0")).GetComponent<SkinnedMeshRenderer>();
iris_L = ((Component)FindDeepChild(((Component)this).transform, "iris_L_0")).GetComponent<SkinnedMeshRenderer>();
eye_R = ((Component)FindDeepChild(((Component)this).transform, "eye_R_0")).GetComponent<SkinnedMeshRenderer>();
iris_R = ((Component)FindDeepChild(((Component)this).transform, "iris_R_0")).GetComponent<SkinnedMeshRenderer>();
}
public void InitTexturesFrom(GameObject initial)
{
if ((Object)(object)leg_R != (Object)null)
{
((Renderer)leg_R).materials = GetMaterialsFromBone(initial, "mesh_leg_r");
}
if ((Object)(object)leg_L != (Object)null)
{
((Renderer)leg_L).materials = GetMaterialsFromBone(initial, "mesh_leg_l");
}
if ((Object)(object)body_bot != (Object)null)
{
((Renderer)body_bot).materials = GetMaterialsFromBone(initial, "mesh_body_bot");
}
if ((Object)(object)body_top_sphere != (Object)null)
{
((Renderer)body_top_sphere).materials = GetMaterialsFromBone(initial, "mesh_body_top_sphere");
}
if ((Object)(object)arm_L != (Object)null)
{
((Renderer)arm_L).materials = GetMaterialsFromBone(initial, "mesh_arm_l");
}
if ((Object)(object)arm_R != (Object)null)
{
((Renderer)arm_R).materials = GetMaterialsFromBone(initial, "mesh_arm_r");
}
if ((Object)(object)health_LED != (Object)null)
{
((Renderer)health_LED).materials = GetMaterialsFromBone(initial, "mesh_health");
}
if ((Object)(object)health_frame != (Object)null)
{
((Renderer)health_frame).materials = GetMaterialsFromBone(initial, "mesh_health frame");
}
if ((Object)(object)health_shadow != (Object)null)
{
((Renderer)health_shadow).materials = GetMaterialsFromBone(initial, "mesh_health shadow");
}
if ((Object)(object)head_bot_sphere != (Object)null)
{
((Renderer)head_bot_sphere).materials = GetMaterialsFromBone(initial, "mesh_head_bot_sphere");
}
if ((Object)(object)head_bot_flat != (Object)null)
{
((Renderer)head_bot_flat).materials = GetMaterialsFromBone(initial, "mesh_head_bot_flat");
}
if ((Object)(object)head_top != (Object)null)
{
((Renderer)head_top).materials = GetMaterialsFromBone(initial, "mesh_head_top");
}
if ((Object)(object)eye_L != (Object)null)
{
((Renderer)eye_L).materials = GetMaterialsFromBone(initial, "mesh_eye_l");
}
if ((Object)(object)iris_L != (Object)null)
{
((Renderer)iris_L).materials = GetMaterialsFromBone(initial, "mesh_pupil_l");
}
if ((Object)(object)eye_R != (Object)null)
{
((Renderer)eye_R).materials = GetMaterialsFromBone(initial, "mesh_eye_r");
}
if ((Object)(object)iris_R != (Object)null)
{
((Renderer)iris_R).materials = GetMaterialsFromBone(initial, "mesh_pupil_r");
}
}
private Material[] GetMaterialsFromBone(GameObject initial, string name)
{
Transform val = FindDeepChild(initial.transform, name);
if ((Object)(object)val != (Object)null)
{
return ((Renderer)((Component)val).GetComponent<MeshRenderer>()).materials;
}
return null;
}
private Transform FindDeepChild(Transform parent, string childName)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
foreach (Transform item in parent)
{
Transform val = item;
if (((Object)val).name.ToLower() == childName.ToLower())
{
return val;
}
Transform val2 = FindDeepChild(val, childName);
if ((Object)(object)val2 != (Object)null)
{
return val2;
}
}
return null;
}
}
public class EmoteLoader : MonoBehaviour
{
private AssetBundle assetBundle;
private static EmoteLoader instance;
public List<string> emotesName = new List<string>();
private Preferences emotesPreferences;
public static EmoteLoader Instance => instance;
public static KeyCode PanelKey => (KeyCode)((!((Object)(object)instance != (Object)null) || instance.emotesPreferences == null) ? 112 : ((int)instance.emotesPreferences.panelKey));
public int TotalPages => Mathf.CeilToInt((float)(emotesName.Count / 8));
private void Awake()
{
instance = this;
}
private void Start()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string path = Path.Combine(directoryName, "emotes.bundle");
assetBundle = EmoteBundleLoader.Load(path);
string path2 = Path.Combine(directoryName, "preferences.json");
try
{
string text = File.ReadAllText(path2);
emotesPreferences = JsonUtility.FromJson<Preferences>(text);
}
catch
{
SomeEmotesREPO.Logger.LogInfo((object)"No preferences file found, creating one.");
emotesPreferences = new Preferences();
SavePreferences();
}
}
public static Font GetFont()
{
return instance.assetBundle.LoadAllAssets<Font>().First((Font f) => ((Object)f).name.ToLower().Contains("teko-regular"));
}
public void SavePreferences()
{
string path = Path.Combine(Paths.PluginPath, "ImGogole-SomeEmotesREPO", "preferences.json");
string contents = JsonUtility.ToJson((object)emotesPreferences);
File.WriteAllText(path, contents);
}
public void SetFavorites(List<string> favs)
{
emotesPreferences.farovites = favs;
SavePreferences();
}
public EmoteLauncher LoadEmote(PlayerAvatar playerAvatar)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)assetBundle == (Object)null)
{
SomeEmotesREPO.Logger.LogError((object)"Unable to load emotes.bundle");
return null;
}
emotesName.Clear();
GameObject val = EmoteBundleLoader.LoadAsset<GameObject>("emote.prefab");
if ((Object)(object)val == (Object)null)
{
SomeEmotesREPO.Logger.LogError((object)"Prefab emote not found");
return null;
}
GameObject val2 = Object.Instantiate<GameObject>(val, Vector3.zero, Quaternion.identity);
EmoteLauncher emoteLauncher = val2.AddComponent<EmoteLauncher>();
List<string> allAnimNames = EmoteBundleLoader.GetAllAnimNames();
foreach (string item in allAnimNames)
{
string text = ExtractElement(item);
if (!string.IsNullOrWhiteSpace(text))
{
emoteLauncher.AddEntry(text, EmoteBundleLoader.LoadAsset<AnimationClip>(item));
emotesName.Add(text);
}
}
emoteLauncher.Init(((Component)playerAvatar).transform);
emoteLauncher.SetFavorites(emotesPreferences.farovites);
emoteLauncher.InitTexturesFrom(((Component)((Component)playerAvatar).transform.parent).gameObject);
return emoteLauncher;
}
public static string ExtractElement(string path)
{
if (string.IsNullOrWhiteSpace(path))
{
return string.Empty;
}
string text = path.Trim();
int num = text.LastIndexOf('/');
if (num >= 0)
{
text = text.Substring(num + 1);
}
if (text.EndsWith(".anim", StringComparison.OrdinalIgnoreCase))
{
text = text.Substring(0, text.Length - ".anim".Length);
}
return text;
}
}
public class EmoteSelectionManager : MonoBehaviour
{
private static EmoteSelectionManager instance;
private bool visible = false;
private int currentPage = 0;
private List<string> lines = new List<string>();
private List<string> emotesToPlay = new List<string>();
public const int emotePerPages = 8;
public const int LineHeigth = 30;
public const string delimiter = "-----------------------------";
public GUIStyle style;
public List<string> Lines => lines;
public List<string> EmotesToPlay => emotesToPlay;
public bool Visible => visible;
public static EmoteSelectionManager Instance => instance;
private void Awake()
{
instance = this;
SomeEmotesREPO.Logger.LogInfo((object)"EmoteSelectionManager ready.");
}
public void SetVisible(bool isVisible)
{
visible = isVisible;
if (visible)
{
OpenPanel(0);
}
}
public void OpenPanel(int page)
{
currentPage = page;
UpdateLines();
}
private void Update()
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
if (ChatManager.instance.chatActive || !Visible)
{
return;
}
if (currentPage > 0 && Input.GetKeyDown((KeyCode)276))
{
OpenPanel(currentPage - 1);
}
if (currentPage < EmoteLoader.Instance.TotalPages && Input.GetKeyDown((KeyCode)275))
{
OpenPanel(currentPage + 1);
}
for (int i = 0; i < emotesToPlay.Count; i++)
{
KeyCode val = (KeyCode)(49 + i);
KeyCode val2 = (KeyCode)(257 + i);
bool flag = Input.GetKeyDown(val) || Input.GetKeyDown(val2);
bool flag2 = Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307) || Input.GetKey((KeyCode)313);
if (flag)
{
if (flag2)
{
EmoteSystem.Instance.SetFavorite(emotesToPlay[i]);
UpdateLines();
}
else
{
EmoteSystem.Instance.PlayEmote(emotesToPlay[i]);
}
}
}
}
private void UpdateLines()
{
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
lines.Clear();
emotesToPlay.Clear();
List<string> list = EmoteSystem.Instance.FetchEmotes(currentPage * 8, 8);
if (currentPage == 0)
{
lines.Add("Favorite emotes");
lines.Add("-----------------------------");
if (list.Count > 0)
{
for (int i = 0; i < list.Count; i++)
{
lines.Add($"[{i + 1}] {list[i]}");
emotesToPlay.Add(list[i]);
}
}
else
{
lines.Add("No emote yet");
}
lines.Add("-----------------------------");
lines.Add("Press [->] for next page");
}
else
{
lines.Add($"Page {currentPage + 1}/{EmoteLoader.Instance.TotalPages + 1}");
lines.Add("-----------------------------");
for (int j = 0; j < list.Count; j++)
{
lines.Add($"[{j + 1}] {list[j]}");
emotesToPlay.Add(list[j]);
}
lines.Add("-----------------------------");
if (EmoteLoader.Instance.TotalPages > currentPage)
{
lines.Add("Press [->] for next page");
}
lines.Add("Press [<-] for previous page");
}
if (list.Count > 0)
{
lines.Add("Press [Num] to emote");
lines.Add("Press [Alt + Num] to add to favorite");
}
lines.Add($"Press [{EmoteLoader.PanelKey}] to quit");
}
private void OnGUI()
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
if (!EmoteSystem.Ready || !Visible || Lines.Count == 0)
{
return;
}
if (style == null)
{
style = GUI.skin.GetStyle("label");
style.fontSize = 22;
style.font = EmoteLoader.GetFont();
style.richText = true;
}
float num = (float)Screen.height - 8f - (float)(Lines.Count * 30);
foreach (string line in Lines)
{
GUI.Label(new Rect(8f, num, (float)Screen.width - 16f, 30f), line, style);
num += 30f;
}
}
}
public class EmoteSystem : MonoBehaviourPun
{
private bool isEmoting = false;
private int emoteId = -1;
private float emoteTime = 0f;
private float initialRot = 0f;
private bool ready = false;
private Transform camTransform;
private PlayerAvatar playerAvatar;
private PlayerAvatarVisuals playerVisuals;
private static float initalCamOffset = 3.25f;
private static float camOffset = initalCamOffset;
private static EmoteSystem instance;
private EmoteLauncher emoteLauncher;
private Animator animator;
public static bool Ready
{
get
{
if (!Object.op_Implicit((Object)(object)instance))
{
return false;
}
return instance.ready;
}
}
public bool IsEmoting
{
get
{
return isEmoting;
}
set
{
isEmoting = value;
if (isEmoting)
{
emoteTime = 0f;
}
}
}
public static EmoteSystem Instance => instance;
private PhotonView PV => playerVisuals.playerAvatar.photonView;
private void Awake()
{
ready = false;
if ((Object)(object)Camera.main != (Object)null)
{
camTransform = ((Component)Camera.main).transform;
}
}
public List<string> FetchEmotes(int startIndex, int count)
{
return emoteLauncher.EmoteNames.Skip(Math.Max(startIndex, 0)).Take(Math.Max(count, 0)).ToList();
}
public void SetFavorite(string fav)
{
SetFavorites(new List<string> { fav });
}
public void SetFavorites(List<string> favs)
{
emoteLauncher.SetFavorites(favs);
}
public void SetPlayerAvatar(PlayerAvatar pa)
{
playerAvatar = pa;
((MonoBehaviour)this).StartCoroutine(SetVisuals());
}
private IEnumerator SetVisuals()
{
yield return (object)new WaitForSeconds(0.75f);
if ((Object)(object)playerAvatar != (Object)null)
{
playerVisuals = playerAvatar.playerAvatarVisuals;
if ((Object)(object)playerVisuals == (Object)null)
{
playerVisuals = ((Component)((Component)playerAvatar).transform.parent).GetComponentInChildren<PlayerAvatarVisuals>();
animator = ((Component)playerVisuals).GetComponentInChildren<Animator>();
}
}
if (PV.IsMine)
{
instance = this;
}
if (GameManager.Multiplayer())
{
emoteLauncher = EmoteLoader.Instance.LoadEmote(playerAvatar);
emoteLauncher.emoteSystem = this;
}
ready = true;
}
public void PlayEmote(string emoteId)
{
if (PV.IsMine)
{
EmoteSelectionManager.Instance.SetVisible(isVisible: false);
IsEmoting = true;
((MonoBehaviourPun)this).photonView.RPC("RPC_PlayEmote", (RpcTarget)0, new object[2] { emoteId, initialRot });
}
}
public void StopEmote()
{
if (PV.IsMine)
{
EmoteSelectionManager.Instance.SetVisible(isVisible: false);
IsEmoting = false;
((MonoBehaviourPun)this).photonView.RPC("RPC_StopEmote", (RpcTarget)0, Array.Empty<object>());
}
}
[PunRPC]
private void RPC_PlayEmote(string emoteId, float _initialRot)
{
IsEmoting = true;
emoteLauncher.SetRotation(_initialRot);
emoteLauncher.Animate(emoteId);
SomeEmotesREPO.Logger.LogInfo((object)("[" + ((MonoBehaviourPun)this).photonView.Owner.NickName + "] played emote " + emoteId + "."));
}
[PunRPC]
private void RPC_StopEmote()
{
IsEmoting = false;
emoteLauncher.StopEmote();
}
private void Update()
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
if (!ready)
{
return;
}
if (IsEmoting)
{
emoteTime += Time.deltaTime;
if (IsPlayerTakeControlBack())
{
IsEmoting = false;
StopEmote();
}
}
if (PV.IsMine && Object.op_Implicit((Object)(object)camTransform))
{
if (isEmoting)
{
camTransform.localPosition = new Vector3(0f, 0f, 0f - camOffset);
}
else
{
camTransform.localPosition = Vector3.zero;
}
float y = Input.mouseScrollDelta.y;
if (y != 0f)
{
camOffset -= y * Time.deltaTime * 20f;
camOffset = Mathf.Clamp(camOffset, 0.5f, 4f);
}
}
if (Object.op_Implicit((Object)(object)playerVisuals))
{
if (PV.IsMine && !playerAvatar.deadSet && Input.GetKeyDown(EmoteLoader.PanelKey) && !ChatManager.instance.chatActive)
{
EmoteSelectionManager.Instance.SetVisible(!EmoteSelectionManager.Instance.Visible);
}
if (!PV.IsMine)
{
((Behaviour)animator).enabled = !IsEmoting;
playerVisuals.meshParent.SetActive(!IsEmoting);
}
else
{
initialRot = ((Component)playerAvatar).transform.eulerAngles.y;
}
}
}
public bool IsPlayerTakeControlBack()
{
//IL_001c: 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)
if (!PV.IsMine)
{
return false;
}
Vector2 movement = InputManager.instance.GetMovement();
if (((Vector2)(ref movement)).sqrMagnitude > 0.01f)
{
return true;
}
if (InputManager.instance.KeyDown((InputKey)1) || InputManager.instance.KeyDown((InputKey)2) || InputManager.instance.KeyDown((InputKey)15) || InputManager.instance.KeyDown((InputKey)12) || InputManager.instance.KeyDown((InputKey)14))
{
return true;
}
return false;
}
public void OnDestroy()
{
if ((Object)(object)emoteLauncher != (Object)null)
{
Object.Destroy((Object)(object)((Component)emoteLauncher).gameObject);
}
}
}
[HarmonyPatch(typeof(FlashlightController))]
internal class FlashlightControllerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Update")]
private static bool Update_Prefix(FlashlightController __instance)
{
EmoteSystem component = ((Component)__instance.PlayerAvatar).GetComponent<EmoteSystem>();
if ((Object)(object)component == (Object)null)
{
return true;
}
if (component.IsEmoting)
{
((Renderer)__instance.mesh).enabled = false;
((Behaviour)__instance.spotlight).enabled = false;
__instance.halo.enabled = false;
__instance.LightActive = false;
return false;
}
return true;
}
}
public static class HierarchyLogger
{
public static void LogFullHierarchy(GameObject go)
{
Transform val = go.transform;
while ((Object)(object)val.parent != (Object)null)
{
val = val.parent;
}
StringBuilder stringBuilder = new StringBuilder();
BuildHierarchyString(val, 0, stringBuilder, go.transform);
SomeEmotesREPO.Logger.LogInfo((object)stringBuilder.ToString());
}
private static void BuildHierarchyString(Transform t, int indent, StringBuilder sb, Transform initial)
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
sb.Append(' ', indent * 2);
string text = (((Object)(object)t == (Object)(object)initial) ? " [INITIAL GAME OBJECT]" : "");
Component[] components = ((Component)t).GetComponents<Component>();
string text2 = string.Join(", ", from c in components
where !(c is Transform)
select ((object)c).GetType().Name);
if (!string.IsNullOrEmpty(text2))
{
text2 = " [" + text2 + "]";
}
sb.AppendLine("- " + ((Object)t).name + text + text2);
foreach (Transform item in t)
{
Transform t2 = item;
BuildHierarchyString(t2, indent + 1, sb, initial);
}
}
}
[HarmonyPatch(typeof(PlayerAvatarVisuals), "Update")]
internal static class PlayerAvatarVisualsUpdatePatch
{
private static bool Prefix(PlayerAvatarVisuals __instance)
{
if ((Object)(object)__instance.playerAvatar != (Object)null && __instance.playerAvatar.photonView.IsMine && (Object)(object)EmoteSystem.Instance != (Object)null && EmoteSystem.Instance.IsEmoting)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(PlayerAvatarVisuals), "Revive")]
internal static class PlayerAvatarVisualsRevivePatch
{
private static void Prefix(PlayerAvatarVisuals __instance)
{
EmoteSystem.Instance.StopEmote();
}
}
[HarmonyPatch(typeof(PlayerNameChecker))]
internal class PlayerNameCheckerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Update")]
public static void Update_Prefix(PlayerNameChecker __instance)
{
if (Object.op_Implicit((Object)(object)EmoteSystem.Instance) && EmoteSystem.Instance.IsEmoting)
{
__instance.checkTimer = 0.25f;
}
}
}
[BepInPlugin("ImGogole.SomeEmotesREPO", "SomeEmotesREPO", "1.0.4")]
public class SomeEmotesREPO : BaseUnityPlugin
{
internal static SomeEmotesREPO Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
if (!Object.op_Implicit((Object)(object)((Component)this).GetComponent<EmoteSelectionManager>()))
{
((Component)this).gameObject.AddComponent<EmoteSelectionManager>();
}
if (!Object.op_Implicit((Object)(object)((Component)this).GetComponent<EmoteLoader>()))
{
((Component)this).gameObject.AddComponent<EmoteLoader>();
}
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
}
namespace SomeEmotesREPO.Utils
{
public static class ChatReflection
{
private static readonly FieldRef<ChatManager, bool> _chatActiveGetter = AccessTools.FieldRefAccess<ChatManager, bool>("chatActive");
public static bool IsChatActive()
{
if ((Object)(object)ChatManager.instance == (Object)null)
{
return false;
}
return _chatActiveGetter.Invoke(ChatManager.instance);
}
}
}