Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TwitchChat v2.7.5
TwitchChat.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; 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 System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using MenuLib; using MenuLib.MonoBehaviors; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using TMPro; using TwitchChat.Commands.Game; using TwitchChat.Commands.Game.Commands; using TwitchChat.Commands.Game.Utils; using TwitchChat.Commands.Twitch; using TwitchChat.Commands.Twitch.ChannelPoints; using TwitchChat.Core; using TwitchChat.Core.Chat; using TwitchChat.Core.Utils; using TwitchChat.Integration; using TwitchChat.Rendering.Graphics; using TwitchChat.Rendering.UI; using TwitchChatAPI; using TwitchChatAPI.Enums; using TwitchChatAPI.Objects; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.TextCore; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("com.github.zehsteam.TwitchChatAPI")] [assembly: IgnoresAccessChecksTo("TwitchChatAPI")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TwitchChat")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Twitch chat integration for REPO Game")] [assembly: AssemblyFileVersion("2.7.5.0")] [assembly: AssemblyInformationalVersion("2.7.5+4cb76b508913e6875cb10b7c4c5acab751cc3415")] [assembly: AssemblyProduct("TwitchRepoIntegration")] [assembly: AssemblyTitle("TwitchChat")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.7.5.0")] [module: UnverifiableCode] [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; } } } public static class UniGif { public class GifTexture { public Texture2D m_texture2d; public float m_delaySec; public GifTexture(Texture2D texture2d, float delaySec) { m_texture2d = texture2d; m_delaySec = delaySec; } } private struct GifData { public byte m_sig0; public byte m_sig1; public byte m_sig2; public byte m_ver0; public byte m_ver1; public byte m_ver2; public ushort m_logicalScreenWidth; public ushort m_logicalScreenHeight; public bool m_globalColorTableFlag; public int m_colorResolution; public bool m_sortFlag; public int m_sizeOfGlobalColorTable; public byte m_bgColorIndex; public byte m_pixelAspectRatio; public List<byte[]> m_globalColorTable; public List<ImageBlock> m_imageBlockList; public List<GraphicControlExtension> m_graphicCtrlExList; public List<CommentExtension> m_commentExList; public List<PlainTextExtension> m_plainTextExList; public ApplicationExtension m_appEx; public byte m_trailer; public string signature { get { char[] value = new char[3] { (char)m_sig0, (char)m_sig1, (char)m_sig2 }; return new string(value); } } public string version { get { char[] value = new char[3] { (char)m_ver0, (char)m_ver1, (char)m_ver2 }; return new string(value); } } public void Dump() { Debug.Log((object)("GIF Type: " + signature + "-" + version)); Debug.Log((object)("Image Size: " + m_logicalScreenWidth + "x" + m_logicalScreenHeight)); Debug.Log((object)("Animation Image Count: " + m_imageBlockList.Count)); Debug.Log((object)("Animation Loop Count (0 is infinite): " + m_appEx.loopCount)); if (m_graphicCtrlExList != null && m_graphicCtrlExList.Count > 0) { StringBuilder stringBuilder = new StringBuilder("Animation Delay Time (1/100sec)"); for (int i = 0; i < m_graphicCtrlExList.Count; i++) { stringBuilder.Append(", "); stringBuilder.Append(m_graphicCtrlExList[i].m_delayTime); } Debug.Log((object)stringBuilder.ToString()); } Debug.Log((object)("Application Identifier: " + m_appEx.applicationIdentifier)); Debug.Log((object)("Application Authentication Code: " + m_appEx.applicationAuthenticationCode)); } } private struct ImageBlock { public struct ImageDataBlock { public byte m_blockSize; public byte[] m_imageData; } public byte m_imageSeparator; public ushort m_imageLeftPosition; public ushort m_imageTopPosition; public ushort m_imageWidth; public ushort m_imageHeight; public bool m_localColorTableFlag; public bool m_interlaceFlag; public bool m_sortFlag; public int m_sizeOfLocalColorTable; public List<byte[]> m_localColorTable; public byte m_lzwMinimumCodeSize; public List<ImageDataBlock> m_imageDataList; } private struct GraphicControlExtension { public byte m_extensionIntroducer; public byte m_graphicControlLabel; public byte m_blockSize; public ushort m_disposalMethod; public bool m_transparentColorFlag; public ushort m_delayTime; public byte m_transparentColorIndex; public byte m_blockTerminator; } private struct CommentExtension { public struct CommentDataBlock { public byte m_blockSize; public byte[] m_commentData; } public byte m_extensionIntroducer; public byte m_commentLabel; public List<CommentDataBlock> m_commentDataList; } private struct PlainTextExtension { public struct PlainTextDataBlock { public byte m_blockSize; public byte[] m_plainTextData; } public byte m_extensionIntroducer; public byte m_plainTextLabel; public byte m_blockSize; public List<PlainTextDataBlock> m_plainTextDataList; } private struct ApplicationExtension { public struct ApplicationDataBlock { public byte m_blockSize; public byte[] m_applicationData; } public byte m_extensionIntroducer; public byte m_extensionLabel; public byte m_blockSize; public byte m_appId1; public byte m_appId2; public byte m_appId3; public byte m_appId4; public byte m_appId5; public byte m_appId6; public byte m_appId7; public byte m_appId8; public byte m_appAuthCode1; public byte m_appAuthCode2; public byte m_appAuthCode3; public List<ApplicationDataBlock> m_appDataList; public string applicationIdentifier { get { char[] value = new char[8] { (char)m_appId1, (char)m_appId2, (char)m_appId3, (char)m_appId4, (char)m_appId5, (char)m_appId6, (char)m_appId7, (char)m_appId8 }; return new string(value); } } public string applicationAuthenticationCode { get { char[] value = new char[3] { (char)m_appAuthCode1, (char)m_appAuthCode2, (char)m_appAuthCode3 }; return new string(value); } } public int loopCount { get { if (m_appDataList == null || m_appDataList.Count < 1 || m_appDataList[0].m_applicationData.Length < 3 || m_appDataList[0].m_applicationData[0] != 1) { return 0; } return BitConverter.ToUInt16(m_appDataList[0].m_applicationData, 1); } } } private const double DecodeBudgetSeconds = 0.004; private static int s_decodeBudgetFrame = -1; private static double s_decodeBudgetStart; public static IEnumerator GetTextureListCoroutine(byte[] bytes, Action<List<GifTexture>, int, int, int> callback, FilterMode filterMode = (FilterMode)1, TextureWrapMode wrapMode = (TextureWrapMode)1, bool debugLog = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) int loopCount = -1; int width = 0; int height = 0; GifData gifData = default(GifData); if (!SetGifData(bytes, ref gifData, debugLog)) { Debug.LogWarning((object)"GIF file data set error."); callback?.Invoke(null, loopCount, width, height); yield break; } List<GifTexture> gifTexList = null; yield return DecodeTextureCoroutine(gifData, delegate(List<GifTexture> result) { gifTexList = result; }, filterMode, wrapMode); if (gifTexList == null || gifTexList.Count <= 0) { Debug.LogWarning((object)"GIF texture decode error."); callback?.Invoke(null, loopCount, width, height); yield break; } loopCount = gifData.m_appEx.loopCount; width = gifData.m_logicalScreenWidth; height = gifData.m_logicalScreenHeight; callback?.Invoke(gifTexList, loopCount, width, height); } public static IEnumerator GetFirstTextureCoroutine(byte[] bytes, Action<Texture2D> callback, FilterMode filterMode = (FilterMode)1, TextureWrapMode wrapMode = (TextureWrapMode)1, bool debugLog = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) GifData gifData = default(GifData); if (!SetGifData(bytes, ref gifData, debugLog)) { Debug.LogWarning((object)"GIF file data set error."); callback?.Invoke(null); yield break; } Texture2D texture = null; yield return DecodeFirstTextureCoroutine(gifData, delegate(Texture2D result) { texture = result; }, filterMode, wrapMode); if ((Object)(object)texture == (Object)null) { Debug.LogWarning((object)"GIF texture decode error."); callback?.Invoke(null); } else { callback?.Invoke(texture); } } private static void StartDecodeBudget() { if (s_decodeBudgetFrame != Time.frameCount) { s_decodeBudgetFrame = Time.frameCount; s_decodeBudgetStart = Time.realtimeSinceStartupAsDouble; } } private static bool IsDecodeBudgetSpent() { return Time.realtimeSinceStartupAsDouble - s_decodeBudgetStart >= 0.004; } private static IEnumerator DecodeTextureCoroutine(GifData gifData, Action<List<GifTexture>> callback, FilterMode filterMode, TextureWrapMode wrapMode) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) if (gifData.m_imageBlockList == null || gifData.m_imageBlockList.Count < 1) { yield break; } List<GifTexture> gifTexList = new List<GifTexture>(gifData.m_imageBlockList.Count); List<ushort> disposalMethodList = new List<ushort>(gifData.m_imageBlockList.Count); for (int i = 0; i < gifData.m_imageBlockList.Count; i++) { StartDecodeBudget(); GifTexture item; try { item = DecodeFrame(gifData, i, gifTexList, disposalMethodList, filterMode, wrapMode); } catch (Exception ex) { Debug.LogWarning((object)("UniGif: frame " + i + " of " + gifData.m_imageBlockList.Count + " could not be decoded, so the GIF is skipped. " + ex.GetType().Name + ": " + ex.Message)); foreach (GifTexture item2 in gifTexList) { Object.Destroy((Object)(object)item2.m_texture2d); } callback?.Invoke(null); yield break; } gifTexList.Add(item); if (IsDecodeBudgetSpent()) { yield return 0; } } foreach (GifTexture item3 in gifTexList) { StartDecodeBudget(); item3.m_texture2d.Apply(false, true); if (IsDecodeBudgetSpent()) { yield return 0; } } callback?.Invoke(gifTexList); } private static IEnumerator DecodeFirstTextureCoroutine(GifData gifData, Action<Texture2D> callback, FilterMode filterMode, TextureWrapMode wrapMode) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) if (gifData.m_imageBlockList == null || gifData.m_imageBlockList.Count < 1) { callback(null); yield break; } ImageBlock imageBlock = gifData.m_imageBlockList[0]; byte[] decodedData = GetDecodedData(imageBlock); GraphicControlExtension? graphicCtrlExt = GetGraphicCtrlExt(gifData, 0); int transparentIndex = GetTransparentIndex(graphicCtrlExt); Color32 bgColor; List<byte[]> colorTable = GetColorTableAndSetBgColor(gifData, imageBlock, transparentIndex, out bgColor); yield return 0; Texture2D tex = new Texture2D((int)gifData.m_logicalScreenWidth, (int)gifData.m_logicalScreenHeight, (TextureFormat)5, false); ((Texture)tex).filterMode = filterMode; ((Texture)tex).wrapMode = wrapMode; Color32[] array = (Color32[])(object)new Color32[((Texture)tex).width * ((Texture)tex).height]; for (int i = 0; i < array.Length; i++) { array[i] = bgColor; } tex.SetPixels32(array); tex.Apply(); yield return 0; int dataIndex = 0; int badColorIndexCount = 0; for (int num = ((Texture)tex).height - 1; num >= 0; num--) { SetTexturePixelRow(tex, num, imageBlock, decodedData, ref dataIndex, colorTable, bgColor, transparentIndex, filledTexture: true, ref badColorIndexCount); } tex.Apply(); WarnAboutBadPixels(0, decodedData.Length, dataIndex, colorTable, badColorIndexCount); yield return 0; callback(tex); } private static GifTexture DecodeFrame(GifData gifData, int imgIndex, List<GifTexture> gifTexList, List<ushort> disposalMethodList, FilterMode filterMode, TextureWrapMode wrapMode) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) ImageBlock imgBlock = gifData.m_imageBlockList[imgIndex]; byte[] decodedData = GetDecodedData(imgBlock); GraphicControlExtension? graphicCtrlExt = GetGraphicCtrlExt(gifData, imgIndex); int transparentIndex = GetTransparentIndex(graphicCtrlExt); disposalMethodList.Add(GetDisposalMethod(graphicCtrlExt)); Color32 bgColor; List<byte[]> colorTableAndSetBgColor = GetColorTableAndSetBgColor(gifData, imgBlock, transparentIndex, out bgColor); Texture2D val = null; try { val = CreateTexture2D(gifData, gifTexList, imgIndex, disposalMethodList, bgColor, filterMode, wrapMode, out var filledTexture); int dataIndex = 0; int badColorIndexCount = 0; for (int num = ((Texture)val).height - 1; num >= 0; num--) { SetTexturePixelRow(val, num, imgBlock, decodedData, ref dataIndex, colorTableAndSetBgColor, bgColor, transparentIndex, filledTexture, ref badColorIndexCount); } val.Apply(); WarnAboutBadPixels(imgIndex, decodedData.Length, dataIndex, colorTableAndSetBgColor, badColorIndexCount); return new GifTexture(val, GetDelaySec(graphicCtrlExt)); } catch { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } throw; } } private static void WarnAboutBadPixels(int imgIndex, int decodedLength, int dataIndex, List<byte[]> colorTable, int badColorIndexCount) { if (dataIndex > decodedLength) { Debug.LogWarning((object)("UniGif: frame " + imgIndex + " has " + decodedLength + " pixels of image data for " + dataIndex + " pixels. The rest use the background color.")); } if (badColorIndexCount > 0) { Debug.LogWarning((object)("UniGif: frame " + imgIndex + " has " + badColorIndexCount + " pixels whose color index is outside its color table (" + ((colorTable == null) ? "none" : (colorTable.Count + " colors")) + "). They use the background color.")); } } private static byte[] GetDecodedData(ImageBlock imgBlock) { List<byte> list = new List<byte>(); for (int i = 0; i < imgBlock.m_imageDataList.Count; i++) { for (int j = 0; j < imgBlock.m_imageDataList[i].m_imageData.Length; j++) { list.Add(imgBlock.m_imageDataList[i].m_imageData[j]); } } int needDataSize = imgBlock.m_imageHeight * imgBlock.m_imageWidth; byte[] array = DecodeGifLZW(list, imgBlock.m_lzwMinimumCodeSize, needDataSize); if (imgBlock.m_interlaceFlag) { array = SortInterlaceGifData(array, imgBlock.m_imageWidth); } return array; } private static List<byte[]> GetColorTableAndSetBgColor(GifData gifData, ImageBlock imgBlock, int transparentIndex, out Color32 bgColor) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) List<byte[]> list = (gifData.m_globalColorTableFlag ? gifData.m_globalColorTable : null); List<byte[]> list2 = ((imgBlock.m_localColorTableFlag && imgBlock.m_localColorTable != null) ? imgBlock.m_localColorTable : list); int bgColorIndex = gifData.m_bgColorIndex; byte[] array = ((list2 != null && bgColorIndex < list2.Count) ? list2[bgColorIndex] : ((list != null && bgColorIndex < list.Count) ? list[bgColorIndex] : null)); if (array != null) { bgColor = new Color32(array[0], array[1], array[2], (byte)((transparentIndex != bgColorIndex) ? 255u : 0u)); } else { bgColor = new Color32((byte)0, (byte)0, (byte)0, (byte)0); } return list2; } private static GraphicControlExtension? GetGraphicCtrlExt(GifData gifData, int imgBlockIndex) { if (gifData.m_graphicCtrlExList != null && gifData.m_graphicCtrlExList.Count > imgBlockIndex) { return gifData.m_graphicCtrlExList[imgBlockIndex]; } return null; } private static int GetTransparentIndex(GraphicControlExtension? graphicCtrlEx) { int result = -1; if (graphicCtrlEx.HasValue && graphicCtrlEx.Value.m_transparentColorFlag) { result = graphicCtrlEx.Value.m_transparentColorIndex; } return result; } private static float GetDelaySec(GraphicControlExtension? graphicCtrlEx) { float num = (graphicCtrlEx.HasValue ? ((float)(int)graphicCtrlEx.Value.m_delayTime / 100f) : (1f / 60f)); if (num <= 0f) { num = 0.1f; } return num; } private static ushort GetDisposalMethod(GraphicControlExtension? graphicCtrlEx) { if (!graphicCtrlEx.HasValue) { return 2; } return graphicCtrlEx.Value.m_disposalMethod; } private static Texture2D CreateTexture2D(GifData gifData, List<GifTexture> gifTexList, int imgIndex, List<ushort> disposalMethodList, Color32 bgColor, FilterMode filterMode, TextureWrapMode wrapMode, out bool filledTexture) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0019: 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) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) filledTexture = false; Texture2D val = new Texture2D((int)gifData.m_logicalScreenWidth, (int)gifData.m_logicalScreenHeight, (TextureFormat)5, false); ((Texture)val).filterMode = filterMode; ((Texture)val).wrapMode = wrapMode; ushort num = (ushort)((imgIndex > 0) ? disposalMethodList[imgIndex - 1] : 2); int num2 = -1; switch (num) { case 1: num2 = imgIndex - 1; break; case 2: { filledTexture = true; Color32[] array = (Color32[])(object)new Color32[((Texture)val).width * ((Texture)val).height]; for (int i = 0; i < array.Length; i++) { array[i] = bgColor; } val.SetPixels32(array); val.Apply(); break; } case 3: { for (int num3 = imgIndex - 1; num3 >= 0; num3--) { if (disposalMethodList[num3] == 0 || disposalMethodList[num3] == 1) { num2 = num3; break; } } break; } } if (num2 >= 0) { filledTexture = true; Color32[] pixels = gifTexList[num2].m_texture2d.GetPixels32(); val.SetPixels32(pixels); val.Apply(); } return val; } private static void SetTexturePixelRow(Texture2D tex, int y, ImageBlock imgBlock, byte[] decodedData, ref int dataIndex, List<byte[]> colorTable, Color32 bgColor, int transparentIndex, bool filledTexture, ref int badColorIndexCount) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) int num = ((Texture)tex).height - 1 - y; Color32 val = default(Color32); for (int i = 0; i < ((Texture)tex).width; i++) { int num2 = i; if (num < imgBlock.m_imageTopPosition || num >= imgBlock.m_imageTopPosition + imgBlock.m_imageHeight || num2 < imgBlock.m_imageLeftPosition || num2 >= imgBlock.m_imageLeftPosition + imgBlock.m_imageWidth) { if (!filledTexture) { tex.SetPixel(i, y, Color32.op_Implicit(bgColor)); } continue; } if (dataIndex >= decodedData.Length) { if (!filledTexture) { tex.SetPixel(i, y, Color32.op_Implicit(bgColor)); } dataIndex++; continue; } byte b = decodedData[dataIndex]; if (colorTable == null || colorTable.Count <= b) { badColorIndexCount++; if (!filledTexture) { tex.SetPixel(i, y, Color32.op_Implicit(bgColor)); } dataIndex++; continue; } byte[] array = colorTable[b]; byte b2 = (byte)((transparentIndex < 0 || transparentIndex != b) ? byte.MaxValue : 0); if (!filledTexture || b2 != 0) { ((Color32)(ref val))..ctor(array[0], array[1], array[2], b2); tex.SetPixel(i, y, Color32.op_Implicit(val)); } dataIndex++; } } private static byte[] DecodeGifLZW(List<byte> compData, int lzwMinimumCodeSize, int needDataSize) { int clearCode = 0; int finishCode = 0; Dictionary<int, string> dictionary = new Dictionary<int, string>(); int lzwCodeSize = 0; InitDictionary(dictionary, lzwMinimumCodeSize, out lzwCodeSize, out clearCode, out finishCode); byte[] bytes = compData.ToArray(); BitArray bitArray = new BitArray(bytes); byte[] array = new byte[needDataSize]; int num = 0; string text = null; bool flag = false; int num2 = 0; while (num2 < bitArray.Length) { if (flag) { InitDictionary(dictionary, lzwMinimumCodeSize, out lzwCodeSize, out clearCode, out finishCode); flag = false; } int numeral = bitArray.GetNumeral(num2, lzwCodeSize); string text2 = null; if (numeral == clearCode) { flag = true; num2 += lzwCodeSize; text = null; continue; } if (numeral == finishCode) { Debug.LogWarning((object)("early stop code. bitDataIndex:" + num2 + " lzwCodeSize:" + lzwCodeSize + " key:" + numeral + " dic.Count:" + dictionary.Count)); break; } if (dictionary.ContainsKey(numeral)) { text2 = dictionary[numeral]; } else { if (numeral < dictionary.Count) { Debug.LogWarning((object)("It is strange that come here. bitDataIndex:" + num2 + " lzwCodeSize:" + lzwCodeSize + " key:" + numeral + " dic.Count:" + dictionary.Count)); num2 += lzwCodeSize; continue; } if (text == null) { Debug.LogWarning((object)("It is strange that come here. bitDataIndex:" + num2 + " lzwCodeSize:" + lzwCodeSize + " key:" + numeral + " dic.Count:" + dictionary.Count)); num2 += lzwCodeSize; continue; } text2 = text + text[0]; } byte[] bytes2 = Encoding.Unicode.GetBytes(text2); for (int i = 0; i < bytes2.Length; i++) { if (num >= needDataSize) { break; } if (i % 2 == 0) { array[num] = bytes2[i]; num++; } } if (num >= needDataSize) { break; } if (text != null) { dictionary.Add(dictionary.Count, text + text2[0]); } text = text2; num2 += lzwCodeSize; if (lzwCodeSize == 3 && dictionary.Count >= 8) { lzwCodeSize = 4; } else if (lzwCodeSize == 4 && dictionary.Count >= 16) { lzwCodeSize = 5; } else if (lzwCodeSize == 5 && dictionary.Count >= 32) { lzwCodeSize = 6; } else if (lzwCodeSize == 6 && dictionary.Count >= 64) { lzwCodeSize = 7; } else if (lzwCodeSize == 7 && dictionary.Count >= 128) { lzwCodeSize = 8; } else if (lzwCodeSize == 8 && dictionary.Count >= 256) { lzwCodeSize = 9; } else if (lzwCodeSize == 9 && dictionary.Count >= 512) { lzwCodeSize = 10; } else if (lzwCodeSize == 10 && dictionary.Count >= 1024) { lzwCodeSize = 11; } else if (lzwCodeSize == 11 && dictionary.Count >= 2048) { lzwCodeSize = 12; } else if (lzwCodeSize == 12 && dictionary.Count >= 4096) { int numeral2 = bitArray.GetNumeral(num2, lzwCodeSize); if (numeral2 != clearCode) { flag = true; } } } return array; } private static void InitDictionary(Dictionary<int, string> dic, int lzwMinimumCodeSize, out int lzwCodeSize, out int clearCode, out int finishCode) { int num = (clearCode = (int)Math.Pow(2.0, lzwMinimumCodeSize)); finishCode = clearCode + 1; dic.Clear(); for (int i = 0; i < num + 2; i++) { dic.Add(i, ((char)i).ToString()); } lzwCodeSize = lzwMinimumCodeSize + 1; } private static byte[] SortInterlaceGifData(byte[] decodedData, int xNum) { int num = 0; int num2 = 0; byte[] array = new byte[decodedData.Length]; for (int i = 0; i < array.Length; i++) { if (num % 8 == 0) { array[i] = decodedData[num2]; num2++; } if (i != 0 && i % xNum == 0) { num++; } } num = 0; for (int j = 0; j < array.Length; j++) { if (num % 8 == 4) { array[j] = decodedData[num2]; num2++; } if (j != 0 && j % xNum == 0) { num++; } } num = 0; for (int k = 0; k < array.Length; k++) { if (num % 4 == 2) { array[k] = decodedData[num2]; num2++; } if (k != 0 && k % xNum == 0) { num++; } } num = 0; for (int l = 0; l < array.Length; l++) { if (num % 8 != 0 && num % 8 != 4 && num % 4 != 2) { array[l] = decodedData[num2]; num2++; } if (l != 0 && l % xNum == 0) { num++; } } return array; } private static bool SetGifData(byte[] gifBytes, ref GifData gifData, bool debugLog) { if (debugLog) { Debug.Log((object)"SetGifData Start."); } if (gifBytes == null || gifBytes.Length == 0) { Debug.LogWarning((object)"bytes is nothing."); return false; } int byteIndex = 0; bool flag; try { flag = SetGifHeader(gifBytes, ref byteIndex, ref gifData); } catch (Exception ex) { Debug.LogWarning((object)ex.Message); flag = false; } if (!flag) { Debug.LogWarning((object)"GIF header set error."); return false; } if (!SetGifBlock(gifBytes, ref byteIndex, ref gifData)) { Debug.LogWarning((object)"GIF block set error."); return false; } if (debugLog) { gifData.Dump(); Debug.Log((object)"SetGifData Finish."); } return true; } private static bool SetGifHeader(byte[] gifBytes, ref int byteIndex, ref GifData gifData) { if (gifBytes[0] != 71 || gifBytes[1] != 73 || gifBytes[2] != 70) { Debug.LogWarning((object)"This is not GIF image."); return false; } gifData.m_sig0 = gifBytes[0]; gifData.m_sig1 = gifBytes[1]; gifData.m_sig2 = gifBytes[2]; if ((gifBytes[3] != 56 || gifBytes[4] != 55 || gifBytes[5] != 97) && (gifBytes[3] != 56 || gifBytes[4] != 57 || gifBytes[5] != 97)) { Debug.LogWarning((object)"GIF version error.\nSupported only GIF87a or GIF89a."); return false; } gifData.m_ver0 = gifBytes[3]; gifData.m_ver1 = gifBytes[4]; gifData.m_ver2 = gifBytes[5]; gifData.m_logicalScreenWidth = BitConverter.ToUInt16(gifBytes, 6); gifData.m_logicalScreenHeight = BitConverter.ToUInt16(gifBytes, 8); gifData.m_globalColorTableFlag = (gifBytes[10] & 0x80) == 128; switch (gifBytes[10] & 0x70) { case 112: gifData.m_colorResolution = 8; break; case 96: gifData.m_colorResolution = 7; break; case 80: gifData.m_colorResolution = 6; break; case 64: gifData.m_colorResolution = 5; break; case 48: gifData.m_colorResolution = 4; break; case 32: gifData.m_colorResolution = 3; break; case 16: gifData.m_colorResolution = 2; break; default: gifData.m_colorResolution = 1; break; } gifData.m_sortFlag = (gifBytes[10] & 8) == 8; int num = (gifBytes[10] & 7) + 1; gifData.m_sizeOfGlobalColorTable = (int)Math.Pow(2.0, num); gifData.m_bgColorIndex = gifBytes[11]; gifData.m_pixelAspectRatio = gifBytes[12]; byteIndex = 13; if (gifData.m_globalColorTableFlag) { gifData.m_globalColorTable = new List<byte[]>(); for (int i = byteIndex; i < byteIndex + gifData.m_sizeOfGlobalColorTable * 3; i += 3) { gifData.m_globalColorTable.Add(new byte[3] { gifBytes[i], gifBytes[i + 1], gifBytes[i + 2] }); } byteIndex += gifData.m_sizeOfGlobalColorTable * 3; } return true; } private static bool SetGifBlock(byte[] gifBytes, ref int byteIndex, ref GifData gifData) { try { int num = 0; while (true) { int num2 = byteIndex; if (gifBytes[num2] == 44) { SetImageBlock(gifBytes, ref byteIndex, ref gifData); } else if (gifBytes[num2] == 33) { switch (gifBytes[num2 + 1]) { case 249: SetGraphicControlExtension(gifBytes, ref byteIndex, ref gifData); break; case 254: SetCommentExtension(gifBytes, ref byteIndex, ref gifData); break; case 1: SetPlainTextExtension(gifBytes, ref byteIndex, ref gifData); break; case byte.MaxValue: SetApplicationExtension(gifBytes, ref byteIndex, ref gifData); break; } } else if (gifBytes[num2] == 59) { break; } if (num == num2) { Debug.LogWarning((object)"Infinite loop error."); return false; } num = num2; } gifData.m_trailer = gifBytes[byteIndex]; byteIndex++; } catch (Exception ex) { Debug.LogWarning((object)ex.Message); return false; } return true; } private static void SetImageBlock(byte[] gifBytes, ref int byteIndex, ref GifData gifData) { ImageBlock item = new ImageBlock { m_imageSeparator = gifBytes[byteIndex] }; byteIndex++; item.m_imageLeftPosition = BitConverter.ToUInt16(gifBytes, byteIndex); byteIndex += 2; item.m_imageTopPosition = BitConverter.ToUInt16(gifBytes, byteIndex); byteIndex += 2; item.m_imageWidth = BitConverter.ToUInt16(gifBytes, byteIndex); byteIndex += 2; item.m_imageHeight = BitConverter.ToUInt16(gifBytes, byteIndex); byteIndex += 2; item.m_localColorTableFlag = (gifBytes[byteIndex] & 0x80) == 128; item.m_interlaceFlag = (gifBytes[byteIndex] & 0x40) == 64; item.m_sortFlag = (gifBytes[byteIndex] & 0x20) == 32; int num = (gifBytes[byteIndex] & 7) + 1; item.m_sizeOfLocalColorTable = (int)Math.Pow(2.0, num); byteIndex++; if (item.m_localColorTableFlag) { item.m_localColorTable = new List<byte[]>(); for (int i = byteIndex; i < byteIndex + item.m_sizeOfLocalColorTable * 3; i += 3) { item.m_localColorTable.Add(new byte[3] { gifBytes[i], gifBytes[i + 1], gifBytes[i + 2] }); } byteIndex += item.m_sizeOfLocalColorTable * 3; } item.m_lzwMinimumCodeSize = gifBytes[byteIndex]; byteIndex++; while (true) { byte b = gifBytes[byteIndex]; byteIndex++; if (b == 0) { break; } ImageBlock.ImageDataBlock item2 = default(ImageBlock.ImageDataBlock); item2.m_blockSize = b; item2.m_imageData = new byte[item2.m_blockSize]; for (int j = 0; j < item2.m_imageData.Length; j++) { item2.m_imageData[j] = gifBytes[byteIndex]; byteIndex++; } if (item.m_imageDataList == null) { item.m_imageDataList = new List<ImageBlock.ImageDataBlock>(); } item.m_imageDataList.Add(item2); } if (gifData.m_imageBlockList == null) { gifData.m_imageBlockList = new List<ImageBlock>(); } gifData.m_imageBlockList.Add(item); } private static void SetGraphicControlExtension(byte[] gifBytes, ref int byteIndex, ref GifData gifData) { GraphicControlExtension item = new GraphicControlExtension { m_extensionIntroducer = gifBytes[byteIndex] }; byteIndex++; item.m_graphicControlLabel = gifBytes[byteIndex]; byteIndex++; item.m_blockSize = gifBytes[byteIndex]; byteIndex++; switch (gifBytes[byteIndex] & 0x1C) { case 4: item.m_disposalMethod = 1; break; case 8: item.m_disposalMethod = 2; break; case 12: item.m_disposalMethod = 3; break; default: item.m_disposalMethod = 0; break; } item.m_transparentColorFlag = (gifBytes[byteIndex] & 1) == 1; byteIndex++; item.m_delayTime = BitConverter.ToUInt16(gifBytes, byteIndex); byteIndex += 2; item.m_transparentColorIndex = gifBytes[byteIndex]; byteIndex++; item.m_blockTerminator = gifBytes[byteIndex]; byteIndex++; if (gifData.m_graphicCtrlExList == null) { gifData.m_graphicCtrlExList = new List<GraphicControlExtension>(); } gifData.m_graphicCtrlExList.Add(item); } private static void SetCommentExtension(byte[] gifBytes, ref int byteIndex, ref GifData gifData) { CommentExtension item = new CommentExtension { m_extensionIntroducer = gifBytes[byteIndex] }; byteIndex++; item.m_commentLabel = gifBytes[byteIndex]; byteIndex++; while (true) { byte b = gifBytes[byteIndex]; byteIndex++; if (b == 0) { break; } CommentExtension.CommentDataBlock item2 = default(CommentExtension.CommentDataBlock); item2.m_blockSize = b; item2.m_commentData = new byte[item2.m_blockSize]; for (int i = 0; i < item2.m_commentData.Length; i++) { item2.m_commentData[i] = gifBytes[byteIndex]; byteIndex++; } if (item.m_commentDataList == null) { item.m_commentDataList = new List<CommentExtension.CommentDataBlock>(); } item.m_commentDataList.Add(item2); } if (gifData.m_commentExList == null) { gifData.m_commentExList = new List<CommentExtension>(); } gifData.m_commentExList.Add(item); } private static void SetPlainTextExtension(byte[] gifBytes, ref int byteIndex, ref GifData gifData) { PlainTextExtension item = new PlainTextExtension { m_extensionIntroducer = gifBytes[byteIndex] }; byteIndex++; item.m_plainTextLabel = gifBytes[byteIndex]; byteIndex++; item.m_blockSize = gifBytes[byteIndex]; byteIndex++; byteIndex += 2; byteIndex += 2; byteIndex += 2; byteIndex += 2; byteIndex++; byteIndex++; byteIndex++; byteIndex++; while (true) { byte b = gifBytes[byteIndex]; byteIndex++; if (b == 0) { break; } PlainTextExtension.PlainTextDataBlock item2 = default(PlainTextExtension.PlainTextDataBlock); item2.m_blockSize = b; item2.m_plainTextData = new byte[item2.m_blockSize]; for (int i = 0; i < item2.m_plainTextData.Length; i++) { item2.m_plainTextData[i] = gifBytes[byteIndex]; byteIndex++; } if (item.m_plainTextDataList == null) { item.m_plainTextDataList = new List<PlainTextExtension.PlainTextDataBlock>(); } item.m_plainTextDataList.Add(item2); } if (gifData.m_plainTextExList == null) { gifData.m_plainTextExList = new List<PlainTextExtension>(); } gifData.m_plainTextExList.Add(item); } private static void SetApplicationExtension(byte[] gifBytes, ref int byteIndex, ref GifData gifData) { gifData.m_appEx.m_extensionIntroducer = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_extensionLabel = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_blockSize = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_appId1 = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_appId2 = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_appId3 = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_appId4 = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_appId5 = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_appId6 = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_appId7 = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_appId8 = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_appAuthCode1 = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_appAuthCode2 = gifBytes[byteIndex]; byteIndex++; gifData.m_appEx.m_appAuthCode3 = gifBytes[byteIndex]; byteIndex++; while (true) { byte b = gifBytes[byteIndex]; byteIndex++; if (b != 0) { ApplicationExtension.ApplicationDataBlock item = default(ApplicationExtension.ApplicationDataBlock); item.m_blockSize = b; item.m_applicationData = new byte[item.m_blockSize]; for (int i = 0; i < item.m_applicationData.Length; i++) { item.m_applicationData[i] = gifBytes[byteIndex]; byteIndex++; } if (gifData.m_appEx.m_appDataList == null) { gifData.m_appEx.m_appDataList = new List<ApplicationExtension.ApplicationDataBlock>(); } gifData.m_appEx.m_appDataList.Add(item); continue; } break; } } } public static class UniGifExtension { public static int GetNumeral(this BitArray array, int startIndex, int bitLength) { BitArray bitArray = new BitArray(bitLength); for (int i = 0; i < bitLength; i++) { if (array.Length <= startIndex + i) { bitArray[i] = false; continue; } bool value = array.Get(startIndex + i); bitArray[i] = value; } return bitArray.ToNumeral(); } public static int ToNumeral(this BitArray array) { if (array == null) { Debug.LogError((object)"array is nothing."); return 0; } if (array.Length > 32) { Debug.LogError((object)"must be at most 32 bits long."); return 0; } int[] array2 = new int[1]; array.CopyTo(array2, 0); return array2[0]; } } namespace TwitchChat.Commands { internal static class CommandRateLimiter { private static readonly Dictionary<string, float> s_LastRunSeconds = new Dictionary<string, float>(); internal static bool TryConsume(string commandKey, float cooldownSeconds) { if (cooldownSeconds <= 0f || string.IsNullOrEmpty(commandKey)) { return true; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (s_LastRunSeconds.TryGetValue(commandKey, out var value) && realtimeSinceStartup - value < cooldownSeconds) { return false; } s_LastRunSeconds[commandKey] = realtimeSinceStartup; return true; } } } namespace TwitchChat.Commands.Twitch { public static class TwitchCommandProcessor { private static readonly List<ChannelPointCommand> Commands = new List<ChannelPointCommand> { new SpawnEnemy(), new ReviveRandomPlayerCommand() }; public static void ProcessCommand(TwitchChatMessage message) { bool flag = !string.IsNullOrEmpty(message.CustomRewardId); bool num; if (!flag) { if (!ConfigManager.SubscriberTTS) { goto IL_0052; } num = message.IsSubscriptionMessage; } else { num = ConfigManager.ChannelPointsTTS; } if (num) { SpeakInGame(message.UserText); } goto IL_0052; IL_0052: if (!ConfigManager.ChatCommandsEnabled || (ConfigManager.RequireChannelPoints && !flag)) { return; } ChannelPointCommand channelPointCommand = Commands.FirstOrDefault((ChannelPointCommand cmd) => cmd.CanHandle(message)); if (channelPointCommand == null) { return; } if (!CommandRateLimiter.TryConsume(channelPointCommand.CommandName, ConfigManager.TwitchCommandCooldownSeconds)) { LogManagerWrapper.LogInfo($"Command cooldown skip trace={message.TraceId} cmd={channelPointCommand.CommandName}"); return; } LogManagerWrapper.LogInfo($"Running {channelPointCommand.CommandName} trace={message.TraceId}: {message.FullText}"); try { channelPointCommand.Execute(message); } catch (Exception ex) { LogManagerWrapper.LogError("Error executing command " + channelPointCommand.CommandName + ": " + ex.Message); } } private static void SpeakInGame(string text) { if (!((Object)(object)ChatManager.instance == (Object)null) && !((Object)(object)PlayerAvatar.instance == (Object)null)) { text = ChatText.WithoutCommandPrefix(text); if (text.Length > 0) { ChatManager.instance.ForceSendMessage(text); } } } } } namespace TwitchChat.Commands.Twitch.ChannelPoints { public abstract class ChannelPointCommand : ICommand<TwitchChatMessage> { private readonly string[] _keywords; public string CommandName { get; } protected abstract bool IsEnabled { get; } protected ChannelPointCommand(string name, string[] keywords) { CommandName = name; _keywords = keywords; } public bool CanHandle(TwitchChatMessage message) { string arguments; if (IsEnabled) { return ChatKeyword.TryFind(message.FullText, (IReadOnlyCollection<string>)(object)_keywords, out arguments); } return false; } public void Execute(TwitchChatMessage message) { ChatKeyword.TryFind(message.FullText, (IReadOnlyCollection<string>)(object)_keywords, out var arguments); Execute(message, arguments); } protected abstract void Execute(TwitchChatMessage message, string arguments); } public class ReviveRandomPlayerCommand : ChannelPointCommand { protected override bool IsEnabled => ConfigManager.ReviveCommandEnabled; public ReviveRandomPlayerCommand() : base("Revive Random Player", new string[2] { "!revive", "!rez" }) { } protected override void Execute(TwitchChatMessage message, string arguments) { PlayerUtil.ReviveRandomPlayer(message.DisplayName); } } public class SpawnEnemy : ChannelPointCommand { protected override bool IsEnabled => ConfigManager.SECommandEnabled; public SpawnEnemy() : base("Spawn Enemy", new string[2] { "!se", "!spawnenemy" }) { } protected override void Execute(TwitchChatMessage message, string arguments) { if (arguments.Length == 0) { EnemyUtil.SpawnRandomEnemy(message.DisplayName); } else { EnemyUtil.SpawnEnemy(arguments, message.DisplayName); } } } } namespace TwitchChat.Commands.Game { internal static class StateUtil { internal static bool HasLocalMapToolActive() { PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerAvatarVisuals.playerAvatarRightArm.mapToolController != (Object)null) { return instance.playerAvatarVisuals.playerAvatarRightArm.mapToolController.Active; } return false; } internal static bool IsInLevel() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 if (SemiFunc.RunIsLevel() && (Object)(object)GameDirector.instance != (Object)null) { return (int)GameDirector.instance.currentState == 2; } return false; } } } namespace TwitchChat.Commands.Game.Utils { public static class EnemyUtil { private const float SpawnDelaySeconds = 3f; private static readonly Dictionary<string, string> PlayerFacingNames = new Dictionary<string, string> { ["Ceiling Eye"] = "Peeper", ["Thin Man"] = "ShadowChild", ["Gnome"] = "Gnome", ["Duck"] = "ApexPredator", ["Slow Mouth"] = "Spewer", ["Valuable Thrower"] = "Rugrat", ["Animal"] = "Animal", ["Upscream"] = "Upscream", ["Hidden"] = "Hidden", ["Tumbler"] = "Chef", ["Bowtie"] = "Bowtie", ["Floater"] = "Mentalist", ["Bang"] = "Bang", ["Head"] = "Headman", ["Robe"] = "Robe", ["Hunter"] = "Huntsman", ["Runner"] = "Reaper", ["Beamer"] = "Clown", ["Slow Walker"] = "Trudge" }; public static void SpawnRandomEnemy(string requestedBy) { if (CanSpawn()) { EnemySetup[] array = (from setup in SingleEnemies() where PlayerFacingNames.ContainsKey(GameName(setup)) select setup).ToArray(); if (array.Length == 0) { ShowError("No enemies to spawn here!"); } else { SpawnAtLocalPlayer(array[Random.Range(0, array.Length)], requestedBy); } } } public static void SpawnEnemy(string enemyName, string requestedBy) { if (CanSpawn()) { EnemySetup val = FindEnemy(enemyName); if ((Object)(object)val != (Object)null) { SpawnAtLocalPlayer(val, requestedBy); } else { ShowError("Could not find that enemy!"); } } } private static EnemySetup FindEnemy(string enemyName) { string name = RemoveSpaces(enemyName); List<EnemySetup> source = SingleEnemies().ToList(); string value; return ((IEnumerable<EnemySetup>)source).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup setup) => PlayerFacingNames.TryGetValue(GameName(setup), out value) && Matches(value, name))) ?? ((IEnumerable<EnemySetup>)source).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup setup) => !PlayerFacingNames.ContainsKey(GameName(setup)) && Matches(RemoveSpaces(GameName(setup)), name))); } private static IEnumerable<EnemySetup> SingleEnemies() { return Enemies.AllEnemies.Where((EnemySetup setup) => (Object)(object)setup != (Object)null && !((Object)setup).name.StartsWith("Enemy Group", StringComparison.Ordinal)); } private static bool CanSpawn() { if (!StateUtil.IsInLevel()) { LogManagerWrapper.LogInfo("Ignoring an enemy spawn outside of a level."); return false; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { LogManagerWrapper.LogInfo("Ignoring an enemy spawn because only the host can spawn enemies."); return false; } return true; } private static void SpawnAtLocalPlayer(EnemySetup setup, string requestedBy) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)PlayerAvatar.instance).transform.position; ((MonoBehaviour)EnemyDirector.instance).StartCoroutine(SpawnAfterDelay(setup, position)); MissionUI.instance.MissionText(requestedBy + " spawned an enemy... Run...!", Color.red, Color.red, 6f); } private static IEnumerator SpawnAfterDelay(EnemySetup setup, Vector3 position) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) yield return (object)new WaitForSeconds(3f); if (StateUtil.IsInLevel()) { Enemies.SpawnEnemy(setup, position, Quaternion.identity, false); } } private static string GameName(EnemySetup setup) { return ((Object)setup).name.Replace("Enemy - ", string.Empty); } private static bool Matches(string a, string b) { return string.Equals(a, b, StringComparison.OrdinalIgnoreCase); } private static string RemoveSpaces(string name) { return name.Replace(" ", string.Empty); } private static void ShowError(string message) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) MissionUI.instance.MissionText(message, Color.red, Color.red, 3f); } } public static class PlayerUtil { public static bool ReviveRandomPlayer(string requestedBy) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GameDirector.instance == (Object)null) { return false; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { LogManagerWrapper.LogInfo("Ignoring a revive because only the host can revive players."); return false; } List<PlayerAvatar> list = GameDirector.instance.PlayerList.Where(CanRevive).ToList(); if (list.Count == 0) { LogManagerWrapper.LogInfo("Nobody to revive."); return false; } PlayerAvatar val = list[Random.Range(0, list.Count)]; val.Revive(true); MissionUI.instance.MissionText(val.playerName + " was revived by " + requestedBy + "!", Color.green, Color.green, 3f); return true; } private static bool CanRevive(PlayerAvatar avatar) { if (avatar.deadSet) { return (Object)(object)avatar.playerDeathHead != (Object)null; } return false; } } } namespace TwitchChat.Commands.Game.Commands { public static class ChannelCommand { public static void Register() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown Commands.RegisterCommand(new ChatCommand("channel", "Switches to another Twitch channel", (Action<bool, string[]>)Execute, (Func<bool, string, string[], List<string>>)null, (Func<bool>)null, false)); } private static void Execute(bool isDebugConsole, string[] args) { if (args.Length != 0) { TwitchConnection.SwitchChannel(args[0]); } } } } namespace TwitchChat.Integration { internal sealed class ChatCanvas : MonoBehaviour { private const int SortingOrder = 100; private const float ReferenceWidth = 1920f; private const float ReferenceHeight = 1080f; private const float HudCameraDistance = 0.01f; private static ChatCanvas instance; private Canvas canvas; private RectTransform rect; private Camera hudCamera; private bool isFiltered; internal static Canvas Create() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("TwitchChatCanvas"); Canvas val2 = val.AddComponent<Canvas>(); val2.renderMode = (RenderMode)0; val2.sortingOrder = 100; CanvasScaler val3 = val.AddComponent<CanvasScaler>(); val3.uiScaleMode = (ScaleMode)1; val3.referenceResolution = new Vector2(1920f, 1080f); val3.screenMatchMode = (ScreenMatchMode)0; instance = val.AddComponent<ChatCanvas>(); Object.DontDestroyOnLoad((Object)(object)val); return val2; } internal static Vector2 MouseFraction() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) Vector2 val = Vector2.op_Implicit(Input.mousePosition); if ((Object)(object)instance == (Object)null || !instance.isFiltered || (Object)(object)RenderTextureMain.instance == (Object)null) { return new Vector2(val.x / (float)Screen.width, val.y / (float)Screen.height); } Vector3[] array = (Vector3[])(object)new Vector3[4]; ((Graphic)RenderTextureMain.instance.overlayRawImage).rectTransform.GetWorldCorners(array); return new Vector2(Mathf.InverseLerp(array[0].x, array[2].x, val.x), Mathf.InverseLerp(array[0].y, array[2].y, val.y)); } private void Awake() { canvas = ((Component)this).GetComponent<Canvas>(); rect = ((Component)this).GetComponent<RectTransform>(); } private void LateUpdate() { Camera val = ((ConfigManager.Look == ConfigManager.ChatLook.GameFilter) ? FindHudCamera() : null); if ((Object)(object)val != (Object)(object)hudCamera || (Object)(object)val != (Object)null != isFiltered) { Apply(val); } } private static Camera FindHudCamera() { if ((Object)(object)CameraOverlay.instance == (Object)null || (Object)(object)HUDCanvas.instance == (Object)null) { return null; } Camera overlayCamera = CameraOverlay.instance.overlayCamera; if (!((Object)(object)overlayCamera != (Object)null) || !((Behaviour)overlayCamera).isActiveAndEnabled) { return null; } return overlayCamera; } private void Apply(Camera camera) { hudCamera = camera; isFiltered = (Object)(object)camera != (Object)null; if (isFiltered) { AttachTo(camera); } else { canvas.renderMode = (RenderMode)0; } if ((Object)(object)Plugin.Instance != (Object)null && (Object)(object)Plugin.Instance.chatWindow != (Object)null) { Plugin.Instance.chatWindow.UpdateWindowPosition(); } } private void AttachTo(Camera camera) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) canvas.renderMode = (RenderMode)2; ((Component)this).gameObject.layer = ((Component)HUDCanvas.instance).gameObject.layer; float num = camera.orthographicSize * 2f; float num2 = num * camera.aspect / 1920f; rect.sizeDelta = new Vector2(1920f, num / num2); ((Transform)rect).localScale = new Vector3(num2, num2, num2); ((Transform)rect).SetPositionAndRotation(((Component)camera).transform.position + ((Component)camera).transform.forward * (camera.nearClipPlane + 0.01f), ((Component)camera).transform.rotation); } } internal sealed class ChatMonitor : MonoBehaviour { private sealed class ScreenLight : MonoBehaviour { private static readonly Color NeonColor = new Color(0.72f, 0.12f, 1f); private const float NeonIntensity = 3.5f; private const float NeonRange = 2.6f; private const float HumAmount = 0.08f; private const float HumSpeed = 7.5f; private Light light; private Color mapColor; private float mapIntensity; private float mapRange; private float blend; private float target; private float fadeSeconds; internal static ScreenLight Find(MapToolController tool) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Light[] componentsInChildren = ((Component)tool.displaySpringTransform).GetComponentsInChildren<Light>(true); foreach (Light val in componentsInChildren) { if (!((Object)(object)((Component)val).transform.parent != (Object)(object)tool.displaySpringTransform)) { ScreenLight screenLight = ((Component)val).GetComponent<ScreenLight>(); if ((Object)(object)screenLight == (Object)null) { screenLight = ((Component)val).gameObject.AddComponent<ScreenLight>(); screenLight.light = val; screenLight.mapColor = val.color; screenLight.mapIntensity = val.intensity; screenLight.mapRange = val.range; } return screenLight; } } return null; } internal void Set(bool chat, float seconds) { target = (chat ? 1f : 0f); fadeSeconds = seconds; if (seconds <= 0f) { blend = target; } Apply(); } private void Update() { bool flag = blend != target; if (flag) { blend = Mathf.MoveTowards(blend, target, Time.unscaledDeltaTime / fadeSeconds); } if (flag || blend > 0f) { Apply(); } } private void Apply() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.SmoothStep(0f, 1f, blend); float num2 = 1f + 0.08f * Mathf.Sin(Time.time * 7.5f); light.color = Color.Lerp(mapColor, NeonColor, num); light.intensity = Mathf.Lerp(mapIntensity, 3.5f * num2, num); light.range = Mathf.Lerp(mapRange, 2.6f, num); } } private const byte EventCode = 177; private const string EventTag = "TwitchChat.ChatMonitor"; internal const float SwitchSeconds = 0.175f; private const float MinSecondsBetweenSwitches = 0.34f; private static readonly Vector3 LabelPosition = new Vector3(0f, -0.0218f, 0.0768f); private const float LabelFontSize = 0.072f; private static readonly Color LabelColor = Color.white; private const float LabelOutlineWidth = 0.25f; private static ChatMonitor instance; private MapToolController tool; private ScreenLight toolLight; private TextMeshPro label; private bool wasActive; private bool failed; private bool chatChannel; private bool shown; private float switchTime = -1f; private float lastSwitchStart = float.NegativeInfinity; private Material chatMaterial; private ChatMonitorView view; private static Material outlinedLabelMaterial; internal static bool ShowingChat { get { if ((Object)(object)instance != (Object)null) { return instance.shown; } return false; } } internal static bool Switching { get { if ((Object)(object)instance != (Object)null) { return instance.switchTime >= 0f; } return false; } } internal static ChatMonitorView View { get { if (!((Object)(object)instance != (Object)null)) { return null; } return instance.view; } } private bool WantsChat { get { if (chatChannel) { return ConfigManager.ShowChatOnMap; } return false; } } internal static float StaticAt(float progress) { float num = Mathf.Sin(Mathf.Clamp01(progress) * MathF.PI); return num * num; } private void Awake() { instance = this; PhotonNetwork.NetworkingClient.EventReceived += OnEvent; ConfigManager.OnAnyConfigChanged += UpdateLabel; } private void OnDestroy() { PhotonNetwork.NetworkingClient.EventReceived -= OnEvent; ConfigManager.OnAnyConfigChanged -= UpdateLabel; if ((Object)(object)tool != (Object)null) { Show(chat: false); } if ((Object)(object)view != (Object)null) { Object.Destroy((Object)(object)((Component)view).gameObject); } if ((Object)(object)instance == (Object)(object)this) { instance = null; } } private void LateUpdate() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (failed) { return; } try { MapToolController val = MapToolController.instance; if ((Object)(object)val != (Object)(object)tool) { Attach(val); } if ((Object)(object)tool == (Object)null) { if ((Object)(object)view != (Object)null) { view.SetVisible(visible: false); } return; } bool activeInHierarchy = ((Component)tool.VisualTransform).gameObject.activeInHierarchy; bool flag = !Switching && Time.unscaledTime - lastSwitchStart >= 0.34f; if (activeInHierarchy && tool.Active && flag && ConfigManager.ShowChatOnMap && WasPressed(ConfigManager.ChatMonitorKey)) { chatChannel = !chatChannel; Broadcast(chatChannel); BeginSwitch(); } if (tool.Active && !wasActive && WantsChat) { Broadcast(chat: true); } wasActive = tool.Active; if (Switching) { if (activeInHierarchy && ConfigManager.ShowChatOnMap) { AdvanceSwitch(); } else { EndSwitch(); } } if (!Switching && WantsChat != shown) { Show(WantsChat); } KeepMapInStep(); view.Source = (((Object)(object)Plugin.Instance != (Object)null) ? Plugin.Instance.chatWindow : null); view.SetVisible(activeInHierarchy && (shown || Switching)); } catch (Exception ex) { failed = true; LogManagerWrapper.LogError("Chat monitor stopped: " + ex.Message + "\n" + ex.StackTrace); if ((Object)(object)tool != (Object)null) { Show(chat: false); } if ((Object)(object)label != (Object)null) { ((Component)label).gameObject.SetActive(false); } } } private void Attach(MapToolController current) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown tool = current; shown = false; switchTime = -1f; if ((Object)(object)tool == (Object)null) { return; } wasActive = tool.Active; toolLight = ScreenLight.Find(tool); if ((Object)(object)view == (Object)null) { Bounds bounds = ((Component)tool.DisplayMesh).GetComponent<MeshFilter>().sharedMesh.bounds; Vector3 size = ((Bounds)(ref bounds)).size; view = ChatMonitorView.Create(size.x / size.z); } view.MapTexture = tool.DisplayMaterial.mainTexture; if ((Object)(object)chatMaterial == (Object)null) { chatMaterial = new Material(tool.DisplayMaterial) { name = "Twitch Chat Monitor" }; chatMaterial.SetTexture("_MainTex", (Texture)(object)view.Texture); if (chatMaterial.HasProperty("_EmissionMap")) { chatMaterial.SetTexture("_EmissionMap", (Texture)(object)view.Texture); } } label = CreateLabel(((Component)tool.DisplayMesh).transform); UpdateLabel(); } private void Show(bool chat) { switchTime = -1f; shown = chat; ((Renderer)tool.DisplayMesh).sharedMaterial = (chat ? chatMaterial : tool.DisplayMaterial); if ((Object)(object)view != (Object)null) { view.ShowMap = false; view.Static = 0f; } if ((Object)(object)toolLight != (Object)null) { toolLight.Set(chat, 0f); } UpdateLabel(); } private void BeginSwitch() { switchTime = 0f; lastSwitchStart = Time.unscaledTime; ((Renderer)tool.DisplayMesh).sharedMaterial = chatMaterial; view.MapTexture = tool.DisplayMaterial.mainTexture; view.ShowMap = !shown; view.Static = 0f; if ((Object)(object)toolLight != (Object)null) { toolLight.Set(chatChannel, 0.175f); } } private void AdvanceSwitch() { switchTime += Time.unscaledDeltaTime; float num = switchTime / 0.175f; view.Static = StaticAt(num); if (num >= 0.5f && shown != chatChannel) { shown = chatChannel; view.ShowMap = !shown; UpdateLabel(); } if (num >= 1f) { EndSwitch(); } } private void EndSwitch() { Show(WantsChat); } private void KeepMapInStep() { if (!((Object)(object)Map.Instance == (Object)null)) { bool flag = (Switching ? view.ShowMap : (!shown)); if (!flag && Map.Instance.Active) { Map.Instance.ActiveSet(false); } else if (flag && tool.Active && !Map.Instance.Active) { Map.Instance.ActiveSet(true); } } } private static TextMeshPro CreateLabel(Transform screen) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Twitch Chat Key Label", new Type[1] { typeof(RectTransform) }); val.layer = ((Component)screen).gameObject.layer; val.transform.SetParent(screen, false); val.transform.localPosition = LabelPosition; val.transform.localRotation = Quaternion.LookRotation(Vector3.up, Vector3.forward); TextMeshPro val2 = val.AddComponent<TextMeshPro>(); ((TMP_Text)val2).rectTransform.sizeDelta = new Vector2(0.15f, 0.01f); ((TMP_Text)val2).fontSize = 0.072f; ((TMP_Text)val2).alignment = (TextAlignmentOptions)514; ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0; ((Graphic)val2).color = LabelColor; ((TMP_Text)val2).characterSpacing = 8f; ((TMP_Text)val2).fontStyle = (FontStyles)1; TMP_FontAsset val3 = (((Object)(object)((TMP_Text)val2).font != (Object)null) ? ((TMP_Text)val2).font : TMP_Settings.defaultFontAsset); if ((Object)(object)val3 != (Object)null) { ((TMP_Text)val2).font = val3; ((TMP_Text)val2).fontSharedMaterial = OutlinedMaterial(((TMP_Asset)val3).material); } return val2; } private static Material OutlinedMaterial(Material font) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)outlinedLabelMaterial == (Object)null) { outlinedLabelMaterial = new Material(font) { name = "Twitch Chat Key Label" }; outlinedLabelMaterial.EnableKeyword(ShaderUtilities.Keyword_Outline); outlinedLabelMaterial.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.25f); outlinedLabelMaterial.SetColor(ShaderUtilities.ID_OutlineColor, Color.black); outlinedLabelMaterial.SetFloat(ShaderUtilities.ID_FaceDilate, 0.25f); } return outlinedLabelMaterial; } private void UpdateLabel() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)label == (Object)null)) { ((Component)label).gameObject.SetActive(ConfigManager.ShowChatOnMap); ((TMP_Text)label).text = "[" + KeyName(ConfigManager.ChatMonitorKey) + "] VIEW " + (shown ? "MAP" : "CHAT"); } } private unsafe static string KeyName(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected I4, but got Unknown if ((int)key >= 48 && (int)key <= 57) { return (key - 48).ToString(); } return ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString().ToUpperInvariant(); } private static void Broadcast(bool chat) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown if (SemiFunc.IsMultiplayer() && PhotonNetwork.InRoom) { PhotonNetwork.RaiseEvent((byte)177, (object)new object[2] { "TwitchChat.ChatMonitor", chat }, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } private void OnEvent(EventData photonEvent) { if (photonEvent.Code != 177 || !(photonEvent.CustomData is object[] array) || array.Length != 2 || !(array[0] is string text) || text != "TwitchChat.ChatMonitor" || !(array[1] is bool chat)) { return; } try { MapToolController[] array2 = Object.FindObjectsByType<MapToolController>((FindObjectsSortMode)0); foreach (MapToolController val in array2) { if ((Object)(object)val != (Object)(object)tool && (Object)(object)val.photonView != (Object)null && val.photonView.OwnerActorNr == photonEvent.Sender) { ScreenLight.Find(val)?.Set(chat, 0.175f); } } } catch (Exception ex) { LogManagerWrapper.LogError($"Chat monitor event from player {photonEvent.Sender} failed: {ex.Message}"); } } private static bool WasPressed(KeyCode key) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current != null && TryGetKey(key, out var key2)) { return ((ButtonControl)current[key2]).wasPressedThisFrame; } return Input.GetKeyDown(key); } private unsafe static bool TryGetKey(KeyCode keyCode, out Key key) { string value = ((object)(*(KeyCode*)(&keyCode))/*cast due to .constrained prefix*/).ToString().Replace("Alpha", "Digit").Replace("Keypad", "Numpad") .Replace("Control", "Ctrl") .Replace("Return", "Enter"); if (Enum.TryParse<Key>(value, ignoreCase: true, out key)) { return (int)key != 0; } return false; } } public static class ConfigManager { public enum PositionPreset { TopRight, TopLeft, MiddleRight, MiddleLeft, BottomLeft, BottomRight, Manual } public enum ChatDisplay { Screen, Map, ScreenAndMap } public enum ChatLook { Sharp, GameFilter } public const float DEFAULT_FONT_SIZE = 14f; public const float DEFAULT_OPACITY = 1f; public const PositionPreset DEFAULT_POSITION_PRESET = PositionPreset.MiddleRight; public static readonly Vector2 DEFAULT_MANUAL_POSITION = new Vector2(0f, 0f); public const float DEFAULT_WIDTH = 444f; public const float DEFAULT_HEIGHT = 300f; public const float DEFAULT_BUFFER = 40f; public const bool DEFAULT_CHAT_WINDOW_VISIBLE = true; public const bool DEFAULT_SHOW_LABELS = true; public const float DEFAULT_BACKGROUND_OPACITY = 0.3f; public const float DEFAULT_MESSAGE_TTL = 0f; public const ChatLook DEFAULT_LOOK = ChatLook.Sharp; public const bool DEFAULT_ENABLE_LOGGER = false; public const bool DEFAULT_SHOW_TELEMETRY_UI = false; public const bool DEFAULT_CHANNEL_POINTS_TTS = true; public const bool DEFAULT_SUBSCRIBER_TTS = true; public const bool DEFAULT_CHATCOMMAND_ENABLED = true; public const KeyCode DEFAULT_SETTINGS_MENU_KEY = (KeyCode)292; public const KeyCode DEFAULT_MANUAL_POSITION_KEY = (KeyCode)290; public const KeyCode DEFAULT_CHAT_MONITOR_KEY = (KeyCode)99; public const ChatDisplay DEFAULT_CHAT_DISPLAY = ChatDisplay.ScreenAndMap; public const bool DEFAULT_REQUIRE_CHANNEL_POINTS = false; public const bool DEFAULT_SE_COMMAND_ENABLED = true; public const bool DEFAULT_REVIVE_COMMAND_ENABLED = true; public const float DEFAULT_TWITCH_COMMAND_COOLDOWN_SECONDS = 0f; public static readonly IReadOnlyDictionary<string, float> ttlOptions = new Dictionary<string, float> { { "Disabled", 0f }, { "5 seconds", 5f }, { "15 seconds", 15f }, { "30 seconds", 30f }, { "1 minute", 60f }, { "3 minutes", 180f } }; private static ConfigFile configFile; private static ConfigEntry<float> FontSizeConfig; private static ConfigEntry<float> OpacityConfig; private static ConfigEntry<PositionPreset> PresetConfig; private static ConfigEntry<Vector2> ManualPositionConfig; private static ConfigEntry<float> WidthConfig; private static ConfigEntry<float> HeightConfig; private static ConfigEntry<float> BufferConfig; internal static ConfigEntry<KeyCode> SettingsMenuKeyConfig; internal static ConfigEntry<KeyCode> ManualPositionKeyConfig; internal static ConfigEntry<KeyCode> ChatMonitorKeyConfig; private static ConfigEntry<ChatDisplay> ChatDisplayConfig; private static ConfigEntry<bool> ChatWindowVisibleConfig; private static ConfigEntry<bool> ShowLabelsConfig; private static ConfigEntry<float> BackgroundOpacityConfig; private static ConfigEntry<float> MessageTTLConfig; private static ConfigEntry<ChatLook> LookConfig; private static ConfigEntry<bool> EnableLoggerConfig; private static ConfigEntry<bool> ShowTelemetryUIConfig; private static ConfigEntry<bool> ChannelPointsTTSConfig; private static ConfigEntry<bool> SubscriberTTSConfig; private static ConfigEntry<bool> ChatCommandsEnabledConfig; private static ConfigEntry<bool> RequireChannelPointsConfig; private static ConfigEntry<bool> SECommandEnabledConfig; private static ConfigEntry<bool> ReviveCommandEnabledConfig; private static ConfigEntry<float> TwitchCommandCooldownConfig; private static bool isResetting; public static float FontSize { get { return FontSizeConfig?.Value ?? 14f; } set { Set(FontSizeConfig, value); } } public static float Opacity { get { return OpacityConfig?.Value ?? 1f; } set { Set(OpacityConfig, value); } } public static PositionPreset Preset { get { return PresetConfig?.Value ?? PositionPreset.MiddleRight; } set { Set(PresetConfig, value); } } public static Vector2 ManualPosition { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return ManualPositionConfig?.Value ?? DEFAULT_MANUAL_POSITION; } set { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Set<Vector2>(ManualPositionConfig, value); } } public static float Width { get { return WidthConfig?.Value ?? 444f; } set { Set(WidthConfig, value); } } public static float Height { get { return HeightConfig?.Value ?? 300f; } set { Set(HeightConfig, value); } } public static float Buffer { get { return BufferConfig?.Value ?? 40f; } set { Set(BufferConfig, value); } } public static KeyCode SettingsMenuKey { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)(((??)SettingsMenuKeyConfig?.Value) ?? 292); } set { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Set<KeyCode>(SettingsMenuKeyConfig, value); } } public static KeyCode ManualPositionKey { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)(((??)ManualPositionKeyConfig?.Value) ?? 290); } set { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Set<KeyCode>(ManualPositionKeyConfig, value); } } public static KeyCode ChatMonitorKey { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)(((??)ChatMonitorKeyConfig?.Value) ?? 99); } set { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Set<KeyCode>(ChatMonitorKeyConfig, value); } } public static ChatDisplay Display { get { return ChatDisplayConfig?.Value ?? ChatDisplay.ScreenAndMap; } set { Set(ChatDisplayConfig, value); } } public static bool ShowChatOnScreen => Display != ChatDisplay.Map; public static bool ShowChatOnMap => Display != ChatDisplay.Screen; public static bool ChatWindowVisible { get { return ChatWindowVisibleConfig?.Value ?? true; } set { Set(ChatWindowVisibleConfig, value); } } public static bool ShowLabels { get { return ShowLabelsConfig?.Value ?? true; } set { Set(ShowLabelsConfig, value); } } public static float BackgroundOpacity { get { return BackgroundOpacityConfig?.Value ?? 0.3f; } set { Set(BackgroundOpacityConfig, value); } } public static float MessageTTL { get { return MessageTTLConfig?.Value ?? 0f; } set { Set(MessageTTLConfig, value); } } public static ChatLook Look { get { return LookConfig?.Value ?? ChatLook.Sharp; } set { Set(LookConfig, value); } } public static bool EnableLogger { get { return EnableLoggerConfig?.Value ?? false; } set { Set(EnableLoggerConfig, value); } } public static bool ShowTelemetryUI { get { return ShowTelemetryUIConfig?.Value ?? false; } set { Set(ShowTelemetryUIConfig, value); } } public static bool ChannelPointsTTS { get { return ChannelPointsTTSConfig?.Value ?? true; } set { Set(ChannelPointsTTSConfig, value); } } public static bool SubscriberTTS { get { return SubscriberTTSConfig?.Value ?? true; } set { Set(SubscriberTTSConfig, value); } } public static bool ChatCommandsEnabled { get { return ChatCommandsEnabledConfig?.Value ?? true; } set { Set(ChatCommandsEnabledConfig, value); } } public static bool RequireChannelPoints { get { return RequireChannelPointsConfig?.Value ?? false; } set { Set(RequireChannelPointsConfig, value); } } public static bool SECommandEnabled { get { return SECommandEnabledConfig?.Value ?? true; } set { Set(SECommandEnabledConfig, value); } } public static bool ReviveCommandEnabled { get { return ReviveCommandEnabledConfig?.Value ?? true; } set { Set(ReviveCommandEnabledConfig, value); } } public static float TwitchCommandCooldownSeconds => TwitchCommandCooldownConfig?.Value ?? 0f; public static event Action OnAnyConfigChanged; public static event Action OnSettingsMenuKeyChanged; public static event Action OnShowLabelsChanged; public static event Action OnMessageTTLChanged; public static event Action OnShowTelemetryUIChanged; internal static void Configure(BaseUnityPlugin plugin) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Expected O, but got Unknown //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Expected O, but got Unknown configFile = plugin.Config; FontSizeConfig = Bind("General", "FontSize", 14f, "The font size for chat messages in pixels. (Range: 6-24 pixels)"); OpacityConfig = Bind("General", "Opacity", 1f, "The twitch chat opacity. (Recommended value = 0.85)"); PresetConfig = Bind("Position", "Preset", PositionPreset.MiddleRight, "The twitch chat position preset. (Recommended value = MiddleRight)"); ManualPositionConfig = Bind<Vector2>("Position", "Manual Position", DEFAULT_MANUAL_POSITION, "The position of the twitch chat as X, Y coordinates when using Manual position preset."); WidthConfig = Bind("Dimensions", "Width", 444f, "The width of the twitch chat window. (Recommended value = 444)"); HeightConfig = Bind("Dimensions", "Height", 300f, "The height of the twitch chat window. (Recommended value = 300)"); BufferConfig = Bind("Dimensions", "Buffer", 40f, "The buffer between edge of screen added to presets. (Recommended value = 40)"); SettingsMenuKeyConfig = Bind<KeyCode>("Key Bindings", "SettingsMenu", (KeyCode)292, "The key to toggle the Twitch settings menu", delegate { ConfigManager.OnSettingsMenuKeyChanged?.Invoke(); }); ManualPositionKeyConfig = Bind<KeyCode>("Key Bindings", "ManualPosition", (KeyCode)290, "The key to enable manual positioning of the chat window"); ChatMonitorKeyConfig = Bind<KeyCode>("Key Bindings", "ChatMonitor", (KeyCode)99, "Press this key while the map is up to switch its screen between the map and Twitch chat"); ChatDisplayConfig = Bind("Chat Window", "Show Chat On", ChatDisplay.ScreenAndMap, "Where Twitch chat shows: Screen is the chat window over the game, Map is the map's own screen, which the ChatMonitor key switches to while the map is up, and ScreenAndMap is both"); ChatWindowVisibleConfig = Bind("Chat Window", "Visible", defaultValue: true, "Whether the chat window is visible"); ShowLabelsConfig = Bind("Chat Window", "Show Labels", defaultValue: true, "Whether to show the channel and toggle key labels", delegate { ConfigManager.OnShowLabelsChanged?.Invoke(); }); BackgroundOpacityConfig = Bind("Chat Window", "Background Opacity", 0.3f, "The opacity of the chat window background (range: 0-1)"); MessageTTLConfig = Bind("Chat Window", "Message TTL", 0f, "The time in seconds that messages should be displayed before fading out. Set to 0 to disable message fading.", delegate { ConfigManager.OnMessageTTLChanged?.Invoke(); }); LookConfig = Bind("Chat Window", "Visual Filter", ChatLook.Sharp, "Sharp draws chat crisply over the game. GameFilter draws it through the same screen effects as the game's HUD, which blends in but softens small text."); EnableLoggerConfig = Bind("Logger", "Enable Logger", defaultValue: false, "Whether to enable logging functionality"); ShowTelemetryUIConfig = Bind("Logger", "Show Telemetry UI", defaultValue: false, "Whether to show a debug panel with the mod's connection and message state", delegate { ConfigManager.OnShowTelemetryUIChanged?.Invoke(); }); ChannelPointsTTSConfig = Bind("Twitch Connection", "Channel Points TTS", defaultValue: true, "Whether to play TTS for Channel Points messages"); SubscriberTTSConfig = Bind("Twitch Connection", "Subscriber TTS", defaultValue: true, "Whether to play TTS for messages included with a subscription"); ChatCommandsEnabledConfig = Bind("Twitch Connection", "Chat Commands", defaultValue: true, "Whether to allow chat to send in-game commands"); RequireChannelPointsConfig = Bind("Twitch Connection", "Require Channel Points", defaultValue: false, "Whether channel points are required for commands."); SECommandEnabledConfig = Bind("Commands", "SE Command Enabled", defaultValue: true, "Whether the '!se' command is enabled."); ReviveCommandEnabledConfig = Bind("Commands", "Revive Command Enabled", defaultValue: true, "Whether the '!revive' command is enabled."); TwitchCommandCooldownConfig = Bind("Commands", "Twitch Command Cooldown Seconds", 0f, new ConfigDescription("Minimum seconds between Twitch chat game commands. 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>())); ConfigDefinition val = new ConfigDefinition("Twitch Connection", "Channel"); configFile.Bind<string>(val, string.Empty, (ConfigDescription)null); if (configFile.Remove(val)) { configFile.Save(); } } private static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description, Action onChanged = null) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return Bind(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), onChanged); } private static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, ConfigDescription description, Action onChanged = null) { ConfigEntry<T> val = configFile.Bind<T>(section, key, defaultValue, description); val.SettingChanged += delegate { try { onChanged?.Invoke(); if (!isResetting) { ConfigManager.OnAnyConfigChanged?.Invoke(); } } catch (Exception ex) { LogManagerWrapper.LogError("Error in config change handler for " + key + ": " + ex.Message); } }; return val; } private static void Set<T>(ConfigEntry<T> entry, T value) { if (entry != null) { entry.Value = value; } } internal static void ResetDefaultValues() { bool saveOnConfigSet = configFile.SaveOnConfigSet; configFile.SaveOnConfigSet = false; isResetting = true; try { foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in configFile) { item.Value.BoxedValue = item.Value.DefaultValue; } } finally { isResetting = false; configFile.SaveOnConfigSet = saveOnConfigSet; configFile.Save(); } ConfigManager.OnAnyConfigChanged?.Invoke(); } } public static class LogManagerWrapper { private static ManualLogSource Logger { get; set; } internal static void Initialize(ManualLogSource logSource) { Logger = logSource; } public static void LogError(string error) { ManualLogSource logger = Logger; if (logger != null) { logger.LogError((object)error); } } public static void LogWarning(string warning) { if (ConfigManager.EnableLogger) { ManualLogSource logger = Logger; if (logger != null) { logger.LogWarning((object)warning); } } } public static void LogInfo(string info) { if (ConfigManager.EnableLogger) { ManualLogSource logger = Logger; if (logger != null) { logger.LogInfo((object)info); } } } } internal static class Mappers { public static TwitchChatMessage ToTwitchChatMessage(TwitchMessage e) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, string> tags = ((TwitchMessage)(ref e)).Tags; string body = ((TwitchMessage)(ref e)).Message ?? ""; TwitchUser user = ((TwitchMessage)(ref e)).User; return new TwitchChatMessage(tags, body, ((TwitchUser)(ref user)).Username, ((TwitchMessage)(ref e)).Channel); } public static TwitchChatMessage ToTwitchChatMessage(TwitchCheerEvent e) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, string> twitchTags = ((TwitchEvent)e).Tags.Where((KeyValuePair<string, string> tag) => !string.Equals(tag.Key, "emotes", StringComparison.OrdinalIgnoreCase)).ToDictionary((KeyValuePair<string, string> tag) => tag.Key, (KeyValuePair<string, string> tag) => tag.Value); string body = (string.IsNullOrEmpty(((TwitchEvent)e).Message) ? $"cheered {e.CheerAmount} bits!" : ((TwitchEvent)e).Message); TwitchUser user = ((TwitchEvent)e).User; return new TwitchChatMessage(twitchTags, body, ((TwitchUser)(ref user)).Username, ((TwitchEvent)e).Channel); } public static TwitchChatMessage ToTwitchChatMessage(TwitchSubEvent e) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, string> tags = ((TwitchEvent)e).Tags; string userText = ((TwitchEvent)e).Message ?? ""; TwitchUser user = ((TwitchEvent)e).User; return TwitchChatMessage.CreateNotice(tags, userText, ((TwitchUser)(ref user)).Username, ((TwitchEvent)e).Channel); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "TwitchChat"; public const string PLUGIN_NAME = "TwitchChat"; public const string PLUGIN_VERSION = "2.7.5"; } [BepInPlugin("TwitchChat", "TwitchChat", "2.7.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public ChatWindow chatWindow; private TelemetryUI telemetryUI; private Canvas overlayCanvas; internal static Plugin Instance { get; private set; } private void Awake() { try { Instance = this; ConfigManager.Configure((BaseUnityPlugin)(object)this); LogManagerWrapper.Initialize(((BaseUnityPlugin)this).Logger); ((Component)this).gameObject.transform.parent = null; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; SceneManager.sceneLoaded += OnSceneLoaded; API.OnMessage += API_OnMessageReceived; API.OnCheer += API_OnCheerReceived; API.OnSub += API_OnSubReceived; ConfigManager.OnShowTelemetryUIChanged += OnShowTelemetryUIChanged; ChannelCommand.Register(); InitializeTelemetryUI(); InitializeChatWindow(); ((Component)this).gameObject.AddComponent<ChatMonitor>(); SettingsMenu.Initialize(); ((MonoBehaviour)this).StartCoroutine(TwitchBadges.Instance.Load()); ((MonoBehaviour)this).StartCoroutine(TwitchEmojis.Instance.Load()); LogManagerWrapper.LogInfo("Twitch Chat Window initialized successfully!!"); } catch (Exception ex) { LogManagerWrapper.LogError("Error during plugin initialization: " + ex.Message + "\n" + ex.StackTrace); } } private void API_OnMessageReceived(TwitchMessage e) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { TwitchCommandProcessor.ProcessCommand(Mappers.ToTwitchChatMessage(e)); } catch (Exception ex) { LogManagerWrapper.LogError("Error processing message: " + ex.Message); } } private void API_OnCheerReceived(TwitchCheerEvent e) { ShowAndProcess(() => Mappers.ToTwitchChatMessage(e)); } private void API_OnSubReceived(TwitchSubEvent e) { ShowAndProcess(() => Mappers.ToTwitchChatMessage(e)); } private void ShowAndProcess(Func<TwitchChatMessage> createMessage) { try { TwitchChatMessage message = createMessage(); if ((Object)(object)chatWindow != (Object)null) { chatWindow.AddMessage(message); } TwitchCommandProcessor.ProcessCommand(message); } catch (Exception ex) { LogManagerWrapper.LogError("Error processing Twitch event: " + ex.Message); } } private void Update() { SettingsMenu.Update(); } private void InitializeChatWindow() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if ((Object)(object)chatWindow != (Object)null) { return; } try { if ((Object)(object)overlayCanvas == (Object)null) { overlayCanvas = ChatCanvas.Create(); } GameObject val = new GameObject("TwitchChatWindow"); val.transform.SetParent(((Component)overlayCanvas).transform, false); chatWindow = val.AddComponent<ChatWindow>(); } catch (Exception ex) { LogManagerWrapper.LogError("Error initializing chat window: " + ex.Message + "\n" + ex.StackTrace); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) LogManagerWrapper.LogInfo($"Scene changed to: {((Scene)(ref scene)).name}, Load mode: {mode}"); InitializeChatWindow(); } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; API.OnMessage -= API_OnMessageReceived; API.OnCheer -= API_OnCheerReceived; API.OnSub -= API_OnSubReceived; ConfigManager.OnShowTelemetryUIChanged -= OnShowTelemetryUIChanged; } public void OnChatWindowDestroyed() { chatWindow = null; } private void InitializeTelemetryUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown try { GameObject val = new GameObject("TelemetryUI"); val.transform.SetParent(((Component)this).gameObject.transform, false); telemetryUI = val.AddComponent<TelemetryUI>(); } catch (Exception ex) { LogManagerWrapper.LogError("Error initializing telemetry UI: " + ex.Message + "\n" + ex.StackTrace); } } private void OnShowTelemetryUIChanged() { if ((Object)(object)telemetryUI != (Object)null) { ((Component)telemetryUI).gameObject.SetActive(ConfigManager.ShowTelemetryUI); } } } internal static class TwitchConnection { public static bool IsEnabled { get { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 try { return ReadEnabled(); } catch (Exception ex) when (ex is MissingMemberException || ex is TypeLoadException) { return (int)API.ConnectionState == 2 || (int)API.ConnectionState == 1; } } } public static void SetEnabled(bool enabled) { try { if (SaveEnabled(enabled)) { return; } } catch (Exception ex) when (ex is MissingMemberException || ex is TypeLoadException) { } if (enabled) { API.Connect(); } else { API.Disconnect(); } } public static void SwitchChannel(string channel) { bool isEnabled = IsEnabled; API.Disconnect(); if (channel == API.Channel) { if (isEnabled) { API.Connect(); } return; } try { SaveChannel(channel); } catch (Exception ex) when (ex is MissingMemberException || ex is TypeLoadException) { API.Connect(channel); } } public static void ClearChannel() { bool isEnabled = IsEnabled; API.Disconnect(); try { SaveChannel(string.Empty); } catch (Exception ex) when (ex is MissingMemberException || ex is TypeLoadException) { if (isEnabled) { API.Connect(string.Empty); } } } [MethodImpl(MethodImplOptions.NoInlining)] private static void SaveChannel(string channel) { ConfigManager.TwitchChat_Channel.Value = channel; } [MethodImpl(MethodImplOptions.NoInlining)] private static bool ReadEnabled() { return ConfigManager.TwitchChat_Enabled.Value; } [MethodImpl(MethodImplOptions.NoInlining)] private static bool SaveEnabled(bool enabled) { ConfigEntry<bool> twitchChat_Enabled = ConfigManager.TwitchChat_Enabled; if (twitchChat_Enabled.Value == enabled) { return false; } twitchChat_Enabled.Value = enabled; return true; } } } namespace TwitchChat.Rendering.UI { internal static class ChatFont { private const int SamplingPointSize = 45; private const int AtlasPadding = 5; private const int AtlasSize = 1024; private static bool _waitingForGameFonts; private static bool _fallbacksAdded; public static void Initialize() { if (!_fallbacksAdded && !_waitingForGameFonts && !TryAddGameFallbacks()) { _waitingForGameFonts = true; SceneManager.sceneLoaded += OnSceneLoaded; } } public static bool CanDraw(int codePoint) { TMP_FontAsset defaultFontAsset = TMP_Settings.defaultFontAsset; bool flag = default(bool); if ((Object)(object)defaultFontAsset != (Object)null) { return TMP_FontAssetUtilities.GetCharacterFromFontAsset((uint)codePoint, defaultFontAsset, true, (FontStyles)0, (FontWeight)400, ref flag) != null; } return false; } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (TryAddGameFallbacks()) { SceneManager.sceneLoaded -= OnSceneLoaded; _waitingForGameFonts = false; } } private static bool TryAddGameFallbacks() { TMP_FontAsset chatFont = TMP_Settings.defaultFontAsset; if ((Object)(object)chatFont == (Object)null) { return false; } List<TMP_FontAsset> list = (from copy in (from font in (from font in Resources.FindObjectsOfTypeAll<TMP_FontAsset>() where (Object)(object)font != (Object)(object)chatFont && font.fallbackFontAssetTable != null select font).SelectMany((TMP_FontAsset font) => font.fallbackFontAssetTable) where (Object)(object)font != (Object)null && (Object)(object)font.sourceFontFile != (Object)null && !IsColorFont(font) select font).Distinct().Select(CopyAtFullSize) where (Object)(object)copy != (Object)null select copy).ToList(); if (list.Count == 0) { return false; } TMP_FontAsset val = chatFont; if (val.fallbackFontAssetTable == null) { List<TMP_FontAsset> list2 = (val.fallbackFontAssetTable = new List<TMP_FontAsset>()); } chatFont.fallbackFontAssetTable.AddRange(list); _fallbacksAdded = true; return true; } private static TMP_FontAsset CopyAtFullSize(TMP_FontAsset gameFont) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) TMP_FontAsset val = TMP_FontAsset.CreateFontAsset(gameFont.sourceFontFile, 45, 5, gameFont.atlasRenderMode, 1024, 1024, (AtlasPopulationMode)1, true); if ((Object)(object)val == (Object)null) { return null; } ((Object)val).name = ((Object)gameFont).name + " (chat)"; val.normalStyle = gameFont.normalStyle; ((TMP_Asset)val).material.SetFloat(ShaderUtilities.ID_WeightNormal, gameFont.normalStyle); return val; } private static bool IsColorFont(TMP_FontAsset font) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if ((int)font.atlasRenderMode != 69652) { return (int)font.atlasRenderMode == 69656; } return true; } } public class MessageUI { public GameObject container; public TextMeshProUGUI text; public Image background; public bool isVisible = true; private float messageFadeAlpha = 1f; private CanvasGroup messageCanvasGroup; public TwitchChatMessage twitchChatMessage; private TMP_SpriteAsset _messageSpecificSpriteAsset; private readonly HashSet<string> _readySprites = new HashSet<string>(StringComparer.Ordinal); private List<MessageToken> _badges = new List<MessageToken>(); private List<MessageToken> _body = new List<MessageToken>(); public DateTime timestamp => twitchChatMessage.Timestamp; public bool IsLoading { get; private set; } = true; public MessageUI(GameObject parent, TwitchChatMessage chatMessage) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references