using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Web; using HarmonyLib; using Il2CppExitGames.Client.Photon; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppPhoton.Pun; using Il2CppPhoton.Realtime; using Il2CppRUMBLE.Economy; using Il2CppRUMBLE.Environment.MatchFlow; using Il2CppRUMBLE.Interactions.InteractionBase; using Il2CppRUMBLE.Managers; using Il2CppRUMBLE.Players; using Il2CppRUMBLE.Players.Subsystems; using Il2CppRUMBLE.Slabs; using Il2CppRUMBLE.Utilities; using Il2CppSystem; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using NameBending; using Newtonsoft.Json; using RumbleModdingAPI.RMAPI; using ThreeDISevenZeroR.UnityGifDecoder; using ThreeDISevenZeroR.UnityGifDecoder.Decode; using ThreeDISevenZeroR.UnityGifDecoder.Model; using ThreeDISevenZeroR.UnityGifDecoder.Utils; using UIFramework; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(Core), "NameBending", "2.0.0", "TacoSlayer36", null)] [assembly: MelonGame("Buckethead Entertainment", "RUMBLE")] [assembly: MelonColor(255, 255, 248, 231)] [assembly: MelonAuthorColor(255, 255, 248, 231)] [assembly: MelonAdditionalDependencies(new string[] { "UIFramework" })] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("NameBending")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c50a573436c558ae0beca3bdb5a3b049ab09300c")] [assembly: AssemblyProduct("NameBending")] [assembly: AssemblyTitle("NameBending")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } } public static class HelperFunctions { public static string ToHtmlStringRGB(this Color color) { //IL_0001: 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) //IL_003b: Unknown result type (might be due to invalid IL or missing references) int value = Mathf.Clamp(Mathf.RoundToInt(color.r * 255f), 0, 255); int value2 = Mathf.Clamp(Mathf.RoundToInt(color.g * 255f), 0, 255); int value3 = Mathf.Clamp(Mathf.RoundToInt(color.b * 255f), 0, 255); return $"#{value:X2}{value2:X2}{value3:X2}"; } public static bool IsGif(byte[] bytes) { if (bytes == null || bytes.Length < 6) { return false; } return bytes[0] == 71 && bytes[1] == 73 && bytes[2] == 70 && bytes[3] == 56 && (bytes[4] == 55 || bytes[4] == 57) && bytes[5] == 97; } public static List ConvertGifToList(byte[] bytes) { List list = new List(); GifStream gifStream = new GifStream(bytes); int num = 0; while (gifStream.HasMoreData) { FrameData frameData = ReadNextGifFrame(gifStream); if (frameData != null && (Object)(object)frameData.Texture != (Object)null) { frameData.Index = num++; list.Add(frameData); } } return list; } private static FrameData ReadNextGifFrame(GifStream gifStream) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown GifStream.Token currentToken = gifStream.CurrentToken; GifStream.Token token = currentToken; if (token == GifStream.Token.Image) { GifImage gifImage = gifStream.ReadImage(); Texture2D val = new Texture2D(gifStream.Header.width, gifStream.Header.height, (TextureFormat)5, false); ((Texture)val).mipMapBias = Config.MipmapBias.Value; val.SetPixels32(Il2CppStructArray.op_Implicit(gifImage.colors)); val.Apply(); float num = gifImage.SafeDelaySeconds; if (num < 0.001f) { num = 0.001f; } return new FrameData(val, num); } gifStream.SkipToken(); return null; } public static string SanitizeString(string Input) { string pattern = "<[^>]*>"; return Regex.Replace(Input, pattern, string.Empty); } public static string RemoveInPlaceCharArray(string input) { int length = input.Length; char[] array = input.ToCharArray(); int length2 = 0; for (int i = 0; i < length; i++) { char c = array[i]; switch (c) { case '\t': case '\n': case '\v': case '\f': case '\r': case ' ': case '\u0085': case '\u00a0': case '\u1680': case '\u2000': case '\u2001': case '\u2002': case '\u2003': case '\u2004': case '\u2005': case '\u2006': case '\u2007': case '\u2008': case '\u2009': case '\u200a': case '\u2028': case '\u2029': case '\u202f': case '\u205f': case '\u3000': continue; } array[length2++] = c; } return new string(array, 0, length2); } public static int LevenshteinDistance(string source, string target) { if (string.IsNullOrEmpty(source)) { return (!string.IsNullOrEmpty(target)) ? target.Length : 0; } if (string.IsNullOrEmpty(target)) { return source.Length; } int length = source.Length; int length2 = target.Length; int[,] array = new int[length + 1, length2 + 1]; int num = 0; while (num <= length) { array[num, 0] = num++; } int num2 = 0; while (num2 <= length2) { array[0, num2] = num2++; } for (int i = 1; i <= length; i++) { for (int j = 1; j <= length2; j++) { int num3 = ((target[j - 1] != source[i - 1]) ? 1 : 0); array[i, j] = Math.Min(Math.Min(array[i - 1, j] + 1, array[i, j - 1] + 1), array[i - 1, j - 1] + num3); } } return array[length, length2]; } public static Player FindPhotonPlayerFromRumblePlayer(Player player) { if (player == null) { return null; } foreach (Player item in (Il2CppArrayBase)(object)PhotonNetwork.PlayerList) { short? obj; if (player == null) { obj = null; } else { PlayerData data = player.Data; if (data == null) { obj = null; } else { GeneralData generalData = data.GeneralData; obj = ((generalData != null) ? new short?(generalData.actorNo) : null); } } if (obj == item.ActorNumber) { return item; } } return null; } } namespace ThreeDISevenZeroR.UnityGifDecoder { public class GifBitBlockReader { private Stream stream; private int currentByte; private int currentBitPosition; private int currentBufferPosition; private int currentBufferSize; private bool endReached; private readonly byte[] buffer; public GifBitBlockReader() { buffer = new byte[256]; } public GifBitBlockReader(Stream stream) : this() { SetStream(stream); } public void SetStream(Stream stream) { this.stream = stream; } public void StartNewReading() { currentByte = 0; currentBitPosition = 8; ReadNextBlock(); } public void FinishReading() { while (!endReached) { ReadNextBlock(); } } public int ReadBits(int count) { int num = 0; int num2 = count; int num3 = 0; int num4 = 8 - currentBitPosition; while (num2 > 0) { if (currentBitPosition >= 8) { currentBitPosition = 0; num4 = 8; if (endReached) { currentByte = 0; } else { currentByte = buffer[currentBufferPosition++]; if (currentBufferPosition == currentBufferSize) { ReadNextBlock(); } } } byte b = (byte)((1 << num2) - 1 << currentBitPosition); int num5 = ((num4 < num2) ? num4 : num2); num += (b & currentByte) >> currentBitPosition << num3; currentBitPosition += num5; num2 -= num5; num3 += num5; } return num; } private void ReadNextBlock() { currentBufferSize = stream.ReadByte8(); currentBufferPosition = 0; endReached = currentBufferSize == 0; if (!endReached) { stream.Read(buffer, 0, currentBufferSize); } } } public class GifCanvas { private Color32[] canvasColors; private Color32[] revertDisposalBuffer; private int canvasWidth; private int canvasHeight; private bool canvasIsEmpty; private Color32[] framePalette; private GifDisposalMethod frameDisposalMethod; private int frameCanvasPosition; private int frameCanvasRowEndPosition; private int frameTransparentColorIndex; private int frameRowCurrent; private int frameX; private int frameY; private int frameWidth; private int frameHeight; private int[] frameRowStart; private int[] frameRowEnd; public Color32[] Colors => canvasColors; public bool FlipVertically { get; set; } = true; public Color32 BackgroundColor { get; set; } public GifCanvas() { canvasIsEmpty = true; } public GifCanvas(int width, int height) : this() { SetSize(width, height); } public void SetSize(int width, int height) { if (width != canvasWidth || height != canvasHeight) { int num = width * height; canvasColors = (Color32[])(object)new Color32[num]; frameRowStart = new int[height]; frameRowEnd = new int[height]; revertDisposalBuffer = null; canvasWidth = width; canvasHeight = height; } Reset(); } public void Reset() { //IL_004c: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) frameDisposalMethod = GifDisposalMethod.Keep; frameX = 0; frameY = 0; frameWidth = canvasWidth; frameHeight = canvasHeight; if (!canvasIsEmpty) { FillWithColor(0, 0, canvasWidth, canvasHeight, new Color32(BackgroundColor.r, BackgroundColor.g, BackgroundColor.b, (byte)0)); canvasIsEmpty = true; } } public void BeginNewFrame(int x, int y, int width, int height, Color32[] palette, int transparentColorIndex, bool isInterlaced, GifDisposalMethod disposalMethod) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0051: Unknown result type (might be due to invalid IL or missing references) switch (frameDisposalMethod) { case GifDisposalMethod.ClearToBackgroundColor: FillWithColor(frameX, frameY, frameWidth, frameHeight, new Color32(BackgroundColor.r, BackgroundColor.g, BackgroundColor.b, (byte)0)); break; case GifDisposalMethod.Revert: if (disposalMethod != 0) { Array.Copy(revertDisposalBuffer, 0, canvasColors, 0, revertDisposalBuffer.Length); } break; } if (disposalMethod == GifDisposalMethod.Revert) { if (revertDisposalBuffer == null) { revertDisposalBuffer = (Color32[])(object)new Color32[canvasColors.Length]; } Array.Copy(canvasColors, 0, revertDisposalBuffer, 0, revertDisposalBuffer.Length); } framePalette = palette; frameDisposalMethod = disposalMethod; canvasIsEmpty = false; frameWidth = width; frameHeight = height; frameX = x; frameY = y; frameCanvasPosition = 0; frameRowCurrent = -1; frameCanvasRowEndPosition = -1; frameTransparentColorIndex = transparentColorIndex; RouteFrameDrawing(x, y, width, height, isInterlaced); } public void OutputPixel(int color) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (frameCanvasPosition >= frameCanvasRowEndPosition) { frameRowCurrent++; frameCanvasPosition = frameRowStart[frameRowCurrent]; frameCanvasRowEndPosition = frameRowEnd[frameRowCurrent]; } if (color != frameTransparentColorIndex) { canvasColors[frameCanvasPosition] = framePalette[color]; } frameCanvasPosition++; } public void FillWithColor(int x, int y, int width, int height, Color32 color) { //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_00b1: 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) if (width == canvasWidth && height == canvasHeight) { for (int num = canvasColors.Length - 1; num >= 0; num--) { canvasColors[num] = color; } return; } int num2; int num3; if (FlipVertically) { num2 = (canvasHeight - y) * canvasWidth + x; num3 = num2 - canvasWidth * height; } else { num3 = y * canvasWidth + x; num2 = num3 + height * canvasWidth; } for (int i = num3; i < num2; i += canvasWidth) { int num4 = i + width; for (int j = i; j < num4; j++) { canvasColors[j] = color; } } } private void RouteFrameDrawing(int x, int y, int width, int height, bool deinterlace) { int currentRow = 0; if (deinterlace) { for (int i = 0; i < height; i += 8) { ScheduleRowIndex(i); } for (int j = 4; j < height; j += 8) { ScheduleRowIndex(j); } for (int k = 2; k < height; k += 4) { ScheduleRowIndex(k); } for (int l = 1; l < height; l += 2) { ScheduleRowIndex(l); } } else { for (int m = 0; m < height; m++) { ScheduleRowIndex(m); } } void ScheduleRowIndex(int row) { int num = (FlipVertically ? ((canvasHeight - 1 - (y + row)) * canvasWidth + x) : ((y + row) * canvasWidth + x)); frameRowStart[currentRow] = num; frameRowEnd[currentRow] = num + width; currentRow++; } } } public class GifStream : IDisposable { public enum Token { Header, Palette, GraphicsControl, ImageDescriptor, Image, Comment, PlainText, NetscapeExtension, ApplicationExtension, EndOfFile } private Stream currentStream; private long headerStartPosition; private long firstFrameStartPosition; private GifHeader header; private GifGraphicControl graphicControl; private GifImageDescriptor imageDescriptor; private GifCanvas canvas; private GifLzwDictionary lzwDictionary; private GifBitBlockReader blockReader; private Color32[] globalColorTable; private Color32[] localColorTable; private readonly byte[] headerBuffer; private readonly byte[] colorTableBuffer; private readonly byte[] extensionApplicationBuffer; private bool nextPaletteIsGlobal; private const int ExtensionBlock = 33; private const int ImageDescriptorBlock = 44; private const int EndOfFile = 59; private const int PlainTextLabel = 1; private const int GraphicControlLabel = 249; private const int commentLabel = 254; private const int applicationExtensionLabel = 255; public bool FlipVertically { get { return canvas.FlipVertically; } set { canvas.FlipVertically = value; } } public bool DrawPlainTextBackground { get; set; } public GifHeader Header => header; public bool HasMoreData => CurrentToken != Token.EndOfFile; public Token CurrentToken { get; private set; } public Stream BaseStream { get { return currentStream; } set { SetStream(value); } } public GifStream() { lzwDictionary = new GifLzwDictionary(); canvas = new GifCanvas(); blockReader = new GifBitBlockReader(); globalColorTable = (Color32[])(object)new Color32[256]; localColorTable = (Color32[])(object)new Color32[256]; headerBuffer = new byte[6]; extensionApplicationBuffer = new byte[11]; colorTableBuffer = new byte[768]; } public GifStream(Stream stream) : this() { SetStream(stream); } public GifStream(byte[] gifBytes) : this(new MemoryStream(gifBytes)) { } public GifStream(string path) : this(File.OpenRead(path)) { } public void SetStream(Stream stream, bool disposePrevious = false) { if (disposePrevious) { currentStream?.Dispose(); } header = default(GifHeader); imageDescriptor = default(GifImageDescriptor); graphicControl = default(GifGraphicControl); currentStream = stream; CurrentToken = Token.Header; blockReader.SetStream(stream); } public void Dispose() { currentStream?.Dispose(); } public void SkipToken() { switch (CurrentToken) { case Token.Header: ReadHeader(); break; case Token.Palette: ReadPalette(); break; case Token.GraphicsControl: ReadGraphicsControl(); break; case Token.ImageDescriptor: ReadImageDescriptor(); break; case Token.Image: ReadImage(); break; case Token.Comment: SkipComment(); break; case Token.PlainText: SkipPlainText(); break; case Token.NetscapeExtension: SkipNetscapeExtension(); break; case Token.ApplicationExtension: SkipApplicationExtension(); break; default: throw new InvalidOperationException($"Cannot skip token {CurrentToken}"); } } public void Reset(bool skipHeader = true, bool resetCanvas = true) { long num = ((skipHeader && firstFrameStartPosition != -1) ? firstFrameStartPosition : headerStartPosition); if (currentStream.Position != num) { currentStream.Position = num; } SetCurrentToken(Token.Header); if (resetCanvas) { canvas.Reset(); } } public GifHeader ReadHeader() { AssertToken(Token.Header); headerStartPosition = currentStream.Position; firstFrameStartPosition = -1L; currentStream.Read(headerBuffer, 0, headerBuffer.Length); if (BitUtils.CheckString(headerBuffer, "GIF87a")) { header.version = GifVersion.Gif87a; } else { if (!BitUtils.CheckString(headerBuffer, "GIF89a")) { throw new ArgumentException("Invalid or corrupted Gif file"); } header.version = GifVersion.Gif89a; } header.width = currentStream.ReadInt16LittleEndian(); header.height = currentStream.ReadInt16LittleEndian(); byte b = currentStream.ReadByte8(); header.globalColorTableSize = BitUtils.GetColorTableSize(b.GetBitsFromByte(0, 3)); header.sortColors = b.GetBitFromByte(3); header.colorResolution = b.GetBitsFromByte(4, 3); header.hasGlobalColorTable = b.GetBitFromByte(7); header.transparentColorIndex = currentStream.ReadByte8(); header.pixelAspectRatio = currentStream.ReadByte8(); canvas.SetSize(header.width, header.height); if (header.hasGlobalColorTable) { SetCurrentToken(Token.Palette); nextPaletteIsGlobal = true; } else { DetermineNextToken(); } return header; } public GifPalette ReadPalette() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) AssertToken(Token.Palette); int num = (nextPaletteIsGlobal ? header.globalColorTableSize : imageDescriptor.localColorTableSize); Color32[] array = (nextPaletteIsGlobal ? globalColorTable : localColorTable); currentStream.Read(colorTableBuffer, 0, num * 3); int num2 = 0; for (int i = 0; i < num; i++) { array[i] = new Color32(colorTableBuffer[num2++], colorTableBuffer[num2++], colorTableBuffer[num2++], byte.MaxValue); } if (nextPaletteIsGlobal) { firstFrameStartPosition = currentStream.Position; DetermineNextToken(); } else { SetCurrentToken(Token.Image); } GifPalette result = default(GifPalette); result.palette = array; result.size = num; result.isGlobal = nextPaletteIsGlobal; return result; } public GifGraphicControl ReadGraphicsControl() { AssertToken(Token.GraphicsControl); currentStream.AssertByte(4); byte b = currentStream.ReadByte8(); int bitsFromByte = b.GetBitsFromByte(2, 3); graphicControl.hasTransparency = b.GetBitFromByte(0); graphicControl.userInput = b.GetBitFromByte(1); graphicControl.delayTime = currentStream.ReadInt16LittleEndian(); graphicControl.transparentColorIndex = currentStream.ReadByte8(); if (!graphicControl.hasTransparency) { graphicControl.transparentColorIndex = -1; } switch (bitsFromByte) { case 0: case 1: graphicControl.disposalMethod = GifDisposalMethod.Keep; break; case 2: graphicControl.disposalMethod = GifDisposalMethod.ClearToBackgroundColor; break; case 3: graphicControl.disposalMethod = GifDisposalMethod.Revert; break; default: throw new ArgumentException($"Invalid disposal method type: {bitsFromByte}"); } currentStream.AssertByte(0); DetermineNextToken(); return graphicControl; } public GifImageDescriptor ReadImageDescriptor() { AssertToken(Token.ImageDescriptor); imageDescriptor.left = currentStream.ReadInt16LittleEndian(); imageDescriptor.top = currentStream.ReadInt16LittleEndian(); imageDescriptor.width = currentStream.ReadInt16LittleEndian(); imageDescriptor.height = currentStream.ReadInt16LittleEndian(); byte b = currentStream.ReadByte8(); imageDescriptor.localColorTableSize = BitUtils.GetColorTableSize(b.GetBitsFromByte(0, 3)); imageDescriptor.isInterlaced = b.GetBitFromByte(6); imageDescriptor.hasLocalColorTable = b.GetBitFromByte(7); if (imageDescriptor.hasLocalColorTable) { nextPaletteIsGlobal = false; SetCurrentToken(Token.Palette); } else { SetCurrentToken(Token.Image); } return imageDescriptor; } public GifImage ReadImage() { AssertToken(Token.Image); Color32[] colorTable = (imageDescriptor.hasLocalColorTable ? localColorTable : globalColorTable); byte b = currentStream.ReadByte8(); if (b == 0 || b > 8) { throw new ArgumentException("Invalid lzw min code size"); } DecodeLzwImageToCanvas(b, imageDescriptor.left, imageDescriptor.top, imageDescriptor.width, imageDescriptor.height, colorTable, graphicControl.transparentColorIndex, imageDescriptor.isInterlaced, graphicControl.disposalMethod); DetermineNextToken(); return new GifImage { colors = canvas.Colors, userInput = graphicControl.userInput, delay = graphicControl.delayTime }; } public string ReadComment() { AssertToken(Token.Comment); string @string = Encoding.ASCII.GetString(BitUtils.ReadGifBlocks(currentStream)); DetermineNextToken(); return @string; } public void SkipComment() { SkipBlock(Token.Comment); } public GifPlainText ReadPlainText() { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) AssertToken(Token.PlainText); currentStream.AssertByte(12); GifPlainText gifPlainText = default(GifPlainText); gifPlainText.left = currentStream.ReadInt16LittleEndian(); gifPlainText.top = currentStream.ReadInt16LittleEndian(); gifPlainText.width = currentStream.ReadInt16LittleEndian(); gifPlainText.height = currentStream.ReadInt16LittleEndian(); gifPlainText.charWidth = currentStream.ReadByte8(); gifPlainText.charHeight = currentStream.ReadByte8(); gifPlainText.foregroundColor = globalColorTable[currentStream.ReadByte8()]; gifPlainText.backgroundColor = globalColorTable[currentStream.ReadByte8()]; gifPlainText.text = Encoding.ASCII.GetString(BitUtils.ReadGifBlocks(currentStream)); gifPlainText.colors = canvas.Colors; if (DrawPlainTextBackground) { FillPlainTextBackground(gifPlainText); } DetermineNextToken(); return gifPlainText; } public void SkipPlainText() { if (DrawPlainTextBackground) { ReadPlainText(); } else { SkipBlock(Token.PlainText); } } public GifNetscapeExtension ReadNetscapeExtension() { AssertToken(Token.NetscapeExtension); bool hasBufferSize = false; bool hasLoopCount = false; int loopCount = 0; int bufferSize = 0; while (true) { byte b = currentStream.ReadByte8(); if (b == 0) { break; } switch (currentStream.ReadByte8()) { case 1: hasLoopCount = true; loopCount = currentStream.ReadInt16LittleEndian(); break; case 2: hasBufferSize = true; bufferSize = currentStream.ReadInt32LittleEndian(); break; default: currentStream.Seek(b - 1, SeekOrigin.Current); break; } } DetermineNextToken(); GifNetscapeExtension result = default(GifNetscapeExtension); result.hasLoopCount = hasLoopCount; result.hasBufferSize = hasBufferSize; result.loopCount = loopCount; result.bufferSize = bufferSize; return result; } public void SkipNetscapeExtension() { SkipBlock(Token.NetscapeExtension); } public GifApplicationExtension ReadApplicationExtension() { AssertToken(Token.ApplicationExtension); List list = new List(); string @string = Encoding.ASCII.GetString(extensionApplicationBuffer, 0, 8); string string2 = Encoding.ASCII.GetString(extensionApplicationBuffer, 8, 3); while (true) { byte b = currentStream.ReadByte8(); if (b == 0) { break; } byte[] array = new byte[b]; currentStream.Read(array, 0, b); list.Add(array); } DetermineNextToken(); return new GifApplicationExtension { applicationIdentifier = @string, applicationAuthCode = string2, applicationData = list.ToArray() }; } public void SkipApplicationExtension() { SkipBlock(Token.ApplicationExtension); } private void DecodeLzwImageToCanvas(int lzwMinCodeSize, int x, int y, int width, int height, Color32[] colorTable, int transparentColorIndex, bool isInterlaced, GifDisposalMethod disposalMethod) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (header.hasGlobalColorTable) { canvas.BackgroundColor = globalColorTable[header.transparentColorIndex]; } canvas.BeginNewFrame(x, y, width, height, colorTable, transparentColorIndex, isInterlaced, disposalMethod); lzwDictionary.InitWithWordSize(lzwMinCodeSize); blockReader.StartNewReading(); lzwDictionary.DecodeStream(blockReader, canvas); blockReader.FinishReading(); } private Token DetermineNextToken() { while (true) { byte b = currentStream.ReadByte8(); switch (b) { case 33: switch (currentStream.ReadByte8()) { case 254: return SetCurrentToken(Token.Comment); case 1: return SetCurrentToken(Token.PlainText); case 249: return SetCurrentToken(Token.GraphicsControl); case byte.MaxValue: { currentStream.AssertByte(11); currentStream.Read(extensionApplicationBuffer, 0, 11); Token currentToken = (BitUtils.CheckString(extensionApplicationBuffer, "NETSCAPE2.0") ? Token.NetscapeExtension : Token.ApplicationExtension); return SetCurrentToken(currentToken); } } break; case 44: return SetCurrentToken(Token.ImageDescriptor); case 59: return SetCurrentToken(Token.EndOfFile); default: throw new ArgumentException($"Unknown block type {b}"); } BitUtils.SkipGifBlocks(currentStream); } } private Token SetCurrentToken(Token token) { CurrentToken = token; return token; } private void FillPlainTextBackground(GifPlainText text) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) canvas.BeginNewFrame(text.left, text.top, text.width, text.height, globalColorTable, graphicControl.transparentColorIndex, imageDescriptor.isInterlaced, graphicControl.disposalMethod); canvas.FillWithColor(text.left, text.top, text.width, text.height, text.backgroundColor); } private void AssertToken(Token token) { if (CurrentToken != token) { throw new InvalidOperationException($"Cannot invoke this method while current token is \"{CurrentToken}\", method should be called when token is {token}"); } } private void SkipBlock(Token token) { AssertToken(token); BitUtils.SkipGifBlocks(currentStream); DetermineNextToken(); } } } namespace ThreeDISevenZeroR.UnityGifDecoder.Utils { public static class BitUtils { public static bool CheckString(byte[] array, string s) { for (int i = 0; i < array.Length; i++) { if (array[i] != s[i]) { return false; } } return true; } public static int ReadInt16LittleEndian(this Stream reader) { byte b = reader.ReadByte8(); byte b2 = reader.ReadByte8(); return (b2 << 8) + b; } public static int ReadInt32LittleEndian(this Stream reader) { byte b = reader.ReadByte8(); byte b2 = reader.ReadByte8(); byte b3 = reader.ReadByte8(); byte b4 = reader.ReadByte8(); return (b4 << 24) + (b3 << 16) + (b2 << 8) + b; } public static byte ReadByte8(this Stream reader) { int num = reader.ReadByte(); if (num == -1) { throw new EndOfStreamException(); } return (byte)num; } public static void AssertByte(this Stream reader, int expectedValue) { byte b = reader.ReadByte8(); if (b != expectedValue) { throw new ArgumentException($"Invalid byte, expected {expectedValue}, got {b}"); } } public static int GetColorTableSize(int data) { return 1 << data + 1; } public static int GetBitsFromByte(this byte b, int offset, int count) { int num = 0; for (int i = 0; i < count; i++) { num += (b.GetBitFromByte(offset + i) ? 1 : 0) << i; } return num; } public static bool GetBitFromByte(this byte b, int offset) { return (b & (1 << offset)) != 0; } public static byte[] ReadGifBlocks(Stream reader) { List list = new List(); while (true) { byte b = reader.ReadByte8(); if (b == 0) { break; } byte[] array = new byte[b]; reader.Read(array, 0, array.Length); list.AddRange(array); } return list.ToArray(); } public static void SkipGifBlocks(Stream reader) { while (true) { byte b = reader.ReadByte8(); if (b == 0) { break; } reader.Seek(b, SeekOrigin.Current); } } } } namespace ThreeDISevenZeroR.UnityGifDecoder.Model { public class GifApplicationExtension { public string applicationIdentifier; public string applicationAuthCode; public byte[][] applicationData; } public enum GifDisposalMethod { Keep, ClearToBackgroundColor, Revert } public struct GifGraphicControl { public bool userInput; public GifDisposalMethod disposalMethod; public int delayTime; public bool hasTransparency; public int transparentColorIndex; } public struct GifHeader { public GifVersion version; public int width; public int height; public bool hasGlobalColorTable; public int globalColorTableSize; public int transparentColorIndex; public bool sortColors; public int colorResolution; public int pixelAspectRatio; } public class GifImage { public bool userInput; public Color32[] colors; public int delay; public int DelayMs => delay * 10; public float SafeDelayMs => (delay > 1) ? DelayMs : 100; public float DelaySeconds => (float)delay / 100f; public float SafeDelaySeconds => SafeDelayMs / 1000f; } public struct GifImageDescriptor { public int left; public int top; public int width; public int height; public bool isInterlaced; public bool hasLocalColorTable; public int localColorTableSize; } public struct GifNetscapeExtension { public bool hasLoopCount; public bool hasBufferSize; public int loopCount; public int bufferSize; } public struct GifPalette { public Color32[] palette; public int size; public bool isGlobal; } public struct GifPlainText { public int left; public int top; public int width; public int height; public int charWidth; public int charHeight; public Color32 backgroundColor; public Color32 foregroundColor; public string text; public Color32[] colors; } public enum GifVersion { Gif89a, Gif87a } } namespace ThreeDISevenZeroR.UnityGifDecoder.Decode { public class GifLzwDictionary { private readonly int[] dictionaryEntryOffsets; private readonly int[] dictionaryEntrySizes; private byte[] dictionaryHeap; private int dictionarySize; private int dictionaryHeapPosition; private int initialDictionarySize; private int initialLzwCodeSize; private int initialDictionaryHeapPosition; private int nextLzwCodeGrowth; private int currentMinLzwCodeSize; private int codeSize; private int clearCodeId; private int stopCodeId; private int lastCodeId; private bool isFull; public GifLzwDictionary() { dictionaryEntryOffsets = new int[4096]; dictionaryEntrySizes = new int[4096]; dictionaryHeap = new byte[32768]; } public void InitWithWordSize(int minLzwCodeSize) { if (currentMinLzwCodeSize != minLzwCodeSize) { currentMinLzwCodeSize = minLzwCodeSize; dictionaryHeapPosition = 0; dictionarySize = 0; int num = 1 << minLzwCodeSize; for (int i = 0; i < num; i++) { dictionaryEntryOffsets[i] = dictionaryHeapPosition; dictionaryEntrySizes[i] = 1; dictionaryHeap[dictionaryHeapPosition++] = (byte)i; } initialDictionarySize = num + 2; initialLzwCodeSize = minLzwCodeSize + 1; initialDictionaryHeapPosition = dictionaryHeapPosition; clearCodeId = num; stopCodeId = num + 1; } Clear(); } public void Clear() { codeSize = initialLzwCodeSize; dictionarySize = initialDictionarySize; dictionaryHeapPosition = initialDictionaryHeapPosition; nextLzwCodeGrowth = 1 << codeSize; isFull = false; lastCodeId = -1; } public void DecodeStream(GifBitBlockReader reader, GifCanvas c) { while (true) { int num = reader.ReadBits(codeSize); if (num == clearCodeId) { Clear(); continue; } if (num == stopCodeId) { break; } if (num < dictionarySize) { if (lastCodeId >= 0) { CreateNewCode(lastCodeId, num); } lastCodeId = num; } else { lastCodeId = CreateNewCode(lastCodeId, lastCodeId); } int num2 = dictionaryEntryOffsets[lastCodeId]; int num3 = dictionaryEntrySizes[lastCodeId]; int num4 = num2 + num3; for (int i = num2; i < num4; i++) { c.OutputPixel(dictionaryHeap[i]); } } } public int CreateNewCode(int baseEntry, int deriveEntry) { if (isFull) { return -1; } int num = dictionaryEntryOffsets[baseEntry]; int num2 = dictionaryEntrySizes[baseEntry]; int num3 = dictionaryHeapPosition; int num4 = num2 + 1; int num5 = num3 + num4; if (dictionaryHeap.Length < num5) { Array.Resize(ref dictionaryHeap, Math.Max(dictionaryHeap.Length * 2, num5)); } if (num2 < 12) { int num6 = num + num2; for (int i = num; i < num6; i++) { dictionaryHeap[dictionaryHeapPosition++] = dictionaryHeap[i]; } } else { Buffer.BlockCopy(dictionaryHeap, num, dictionaryHeap, dictionaryHeapPosition, num2); dictionaryHeapPosition += num2; } dictionaryHeap[dictionaryHeapPosition++] = ((deriveEntry < initialDictionarySize) ? ((byte)deriveEntry) : dictionaryHeap[dictionaryEntryOffsets[deriveEntry]]); int num7 = dictionarySize++; dictionaryEntryOffsets[num7] = num3; dictionaryEntrySizes[num7] = num4; if (dictionarySize >= nextLzwCodeGrowth) { codeSize++; nextLzwCodeGrowth = ((codeSize == 12) ? int.MaxValue : (1 << codeSize)); } if (dictionarySize >= 4096) { isFull = true; } return num7; } } } namespace NameBending { [RegisterTypeInIl2Cpp] public class NameBend : MonoBehaviour { [CompilerGenerated] private sealed class <>c__DisplayClass37_0 { public NameBend <>4__this; public string hash; } public Variation Variation; public List BentImages = new List(); public Player Owner; public string PhotonEventString = null; public bool IsLocal = false; public bool IsPlayer = true; public bool IsScreenSpace = true; private PlayerNameTag _parentTag; public Core.DesignationType DesignationType = Core.DesignationType.Name; public string unbentText = ""; private float _timer = 0f; public float AnimationProgress = 0f; private int steps = 0; private Player photonOwner => HelperFunctions.FindPhotonPlayerFromRumblePlayer(Owner); public PlayerNameTag ParentTag { get { if ((Object)(object)_parentTag != (Object)null) { return _parentTag; } _parentTag = ((Component)this).GetComponentInParent(); return _parentTag; } } public bool IsRemote => !IsLocal && !IsScreenSpace; private string typeString => (DesignationType == Core.DesignationType.Name) ? "Name" : "Title"; public float Timer { get { if (Config.Animations.Value) { return _timer; } return 0f; } set { _timer = value; } } private float frameDurationInSeconds => (float)Variation.FrameDuration / 1000f; public int FrameIndex { get { if (Config.Animations.Value) { return (int)Math.Truncate(AnimationProgress); } return 0; } } public float FrameProgress { get { if (Config.Animations.Value) { return AnimationProgress - (float)FrameIndex; } return 0f; } } public float LoopProgress { get { if (Config.Animations.Value) { return AnimationProgress / ((float)Variation.FindTotalFrameCount() * frameDurationInSeconds); } return 0f; } } public int LoopCount { get { if (Config.Animations.Value) { return (int)(Timer / ((float)Variation.FindTotalFrameCount() * frameDurationInSeconds)); } return 0; } } private void Start() { if (!IsRemote) { Core.Instance.OnUpdateDesignations += OnUpdateDesignations; } OnUpdateDesignations(); if (Variation != null) { TextMeshPro component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null) { ((TMP_Text)component).fontStyle = (FontStyles)0; ((TMP_Text)component).characterSpacing = 0f; } } } private void OnDestroy() { Core.Instance.NameBends.Remove(this); Core.Instance.OnUpdateDesignations -= OnUpdateDesignations; } private void FixedUpdate() { CheckPlayerProps(); Timer += Time.fixedDeltaTime; if (Variation != null) { Render(); } } private void CheckPlayerProps() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 <>c__DisplayClass37_0 CS$<>8__locals0 = new <>c__DisplayClass37_0(); CS$<>8__locals0.<>4__this = this; if (!PhotonNetwork.InRoom) { return; } Player owner = Owner; if (owner != null) { PlayerController controller = owner.Controller; if ((int)((controller != null) ? new ControllerType?(controller.controllerType) : null).GetValueOrDefault() == 1) { return; } } if (photonOwner != null) { Object obj = photonOwner.CustomProperties[Object.op_Implicit("NameBending.HashCode")]; CS$<>8__locals0.hash = ((obj != null) ? obj.ToString() : null) ?? ""; string text = "-"; if (Core.Instance.DesignationsHashes.ContainsKey(Owner.Controller)) { text = Core.Instance.DesignationsHashes[Owner.Controller]; } if (text != CS$<>8__locals0.hash || !string.IsNullOrEmpty(PhotonEventString)) { MelonCoroutines.Start(_()); OnUpdateDesignations(); } } [IteratorStateMachine(typeof(<>c__DisplayClass37_0.<g___|0>d))] IEnumerator _() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass37_0.<g___|0>d(0) { <>4__this = CS$<>8__locals0 }; } } public void OnUpdateDesignations() { if ((Object)(object)this == (Object)null) { return; } ResetAll(); if (Config.DisableMod.Value) { return; } Variation = null; FetchVariation(); if (!IsRemote && DesignationType == Core.DesignationType.Name && (!Config.MyBentName.Value || Config.DisableMod.Value)) { Variation = null; } if (IsRemote && DesignationType == Core.DesignationType.Name && (!Config.OtherBentNames.Value || Config.DisableMod.Value)) { Variation = null; } if (!IsRemote && DesignationType == Core.DesignationType.Title && (!Config.MyBentTitle.Value || Config.DisableMod.Value)) { Variation = null; } if (IsRemote && DesignationType == Core.DesignationType.Title && (!Config.OtherBentTitles.Value || Config.DisableMod.Value)) { Variation = null; } if (Variation != null) { ApplyImages(); Timer = 0f; TextMeshPro component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null && Variation != null) { ((TMP_Text)component).enableAutoSizing = Variation.AutoScaling; ((TMP_Text)component).fontStyle = (FontStyles)0; ((TMP_Text)component).characterSpacing = 0f; } } } public void FetchVariation() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 if (Core.IsInMatch) { Player owner = Owner; if (owner != null) { PlayerController controller = owner.Controller; if ((int)((controller != null) ? new ControllerType?(controller.ControllerType) : null).GetValueOrDefault() == 1) { goto IL_00a1; } } if (DesignationType == Core.DesignationType.Name && Core.OpponentPhotonName != null) { PhotonEventString = Core.OpponentPhotonName; Core.OpponentPhotonName = null; } else if (DesignationType == Core.DesignationType.Title && Core.OpponentPhotonTitle != null) { PhotonEventString = Core.OpponentPhotonTitle; Core.OpponentPhotonTitle = null; } } goto IL_00a1; IL_00a1: if (!string.IsNullOrEmpty(PhotonEventString)) { Variation = JsonConvert.DeserializeObject(PhotonEventString); PhotonEventString = null; } else if (!IsRemote) { if (DesignationType == Core.DesignationType.Name) { Variation = Core.Instance.ActiveNameVariation; } if (DesignationType == Core.DesignationType.Title) { Variation = Core.Instance.ActiveTitleVariation; } if (Variation == null) { SetText(unbentText); } } else if (photonOwner != null) { Object val = photonOwner.CustomProperties[Object.op_Implicit("NameBending." + typeString)]; string text = null; if (val != null) { text = val.ToString(); if (text == null || text == "None") { SetText(unbentText); Variation = null; return; } Variation = JsonConvert.DeserializeObject(text); } } if (Variation != null) { Variation.OwnerComponent = this; Variation.Owner = Owner; Variation.DesignationType = DesignationType.ToString(); if (Variation.EnableFields && !Variation.FieldInstancesFound) { Variation.FindAllFieldInstances(); } Variation.DownloadAllImages(); if (Config.SaveNamesToFiles.Value && !Variation.ProhibitSaving) { saveVariation(Variation); } } } public void ReapplyImages() { ResetImages(); ApplyImages(); } public void ApplyImages() { if (Variation?.Images != null && Variation.Images.Count > 0) { foreach (ImageInfo image in Variation.Images) { CreateImageObject(image, Variation); } } foreach (BentImage bentImage in BentImages) { bentImage.RestartFrames(); } } private void CreateImageObject(ImageInfo imageInfo, Variation containerVariation) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown if (!((Object)(object)this == (Object)null) && !((Object)(object)((Component)this).transform == (Object)null) && !Config.DisableMod.Value && Config.Images.Value) { GameObject val = GameObject.CreatePrimitive((PrimitiveType)4); ((Object)val).name = "BentImagePlane"; val.transform.SetParent(((Component)this).transform, false); float num = (float)(containerVariation.GetImageInfoIndex(imageInfo) + 1) * -0.0015f; if (imageInfo.ZDepth.HasValue) { num = imageInfo.ZDepth.Value * -0.0015f; } val.transform.localPosition = new Vector3(imageInfo.XOffset / 100f, imageInfo.YOffset / 100f, num); val.transform.localScale = new Vector3(imageInfo.Width / 1000f, 1f, imageInfo.Height / 1000f); Transform transform = val.transform; transform.localRotation *= Quaternion.Euler(90f, 180f, 0f); Material val2 = new Material(Core.Instance.CachedImageShader); val2.mainTexture = (Texture)(object)Core.Instance.CachedLoadingTexture; val.GetComponent().material = val2; if (IsScreenSpace) { val.layer = LayerMask.NameToLayer("UI"); } BentImage bentImage = val.AddComponent(); bentImage.ImageInfo = imageInfo; bentImage.ParentComponent = this; BentImages.Add(bentImage); Core.Instance.BentImages.Add(bentImage); } } private void saveVariation(Variation variation) { if (variation != null) { string serializedJsonIndented = variation.SerializedJsonIndented; string text = Path.Combine(Core.UserDataPath, "saved_names"); string jsonPropertiesHashCode = variation.GetJsonPropertiesHashCode(); string value = HelperFunctions.SanitizeString(variation.Owner.Data.GeneralData.PublicUsername); string playFabMasterId = variation.Owner.Data.GeneralData.PlayFabMasterId; string path = Path.Combine(text, $"{value}, {playFabMasterId} - {variation.DesignationType} {jsonPropertiesHashCode}.json"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } File.WriteAllText(path, serializedJsonIndented); } } public void Render() { bool flag = !string.IsNullOrEmpty(Config.SimpleNameBend.Value); bool flag2 = !string.IsNullOrEmpty(Config.SimpleTitleBend.Value); if (Config.EnableSimpleConfig.Value) { if (DesignationType == Core.DesignationType.Name && flag) { SetText(truncateText(Config.SimpleNameBend.Value)); return; } if (DesignationType == Core.DesignationType.Title && flag2) { SetText(truncateText(Config.SimpleTitleBend.Value)); return; } } if (frameDurationInSeconds > 0f) { if (Variation.LoopFrames) { AnimationProgress = Timer / frameDurationInSeconds % (float)Variation.FindTotalFrameCount(); } else { AnimationProgress = Math.Min(Timer / frameDurationInSeconds, Variation.FindLargestModifier()); } } else { AnimationProgress = 0f; } try { int num = Variation.FindPrevModifierOfType("frame", FrameIndex); if (Variation.Frames.ContainsKey(num)) { string text = Variation.Frames[num]; if (Variation.EnableFields) { text = ProcessFields(num, Variation); } SetText(truncateText(text)); } } catch { } try { int num2 = Variation.FindPrevModifierOfType("font", FrameIndex); if (num2 == -1) { SetFont(getFontFromName("GoodDogPlain")); } if (Variation.Fonts != null && Variation.Fonts.ContainsKey(num2)) { SetFont(Variation.Fonts[num2]); } } catch { } try { int key = Variation.FindPrevModifierOfType("depth", FrameIndex); if (Variation.Depths != null && Variation.Depths.ContainsKey(key)) { string s = Variation.Depths[key]; float num3 = 0f; num3 = ((!Variation.Interpolation) ? float.Parse(s) : Mathf.Lerp(float.Parse(s), float.Parse(Variation.Depths[Variation.FindNextModifierOfType("depth", FrameIndex)]), FrameProgress)); SetDepth(num3); } } catch { } } public void SetText(string text) { if (string.IsNullOrEmpty(text)) { return; } TextMeshProUGUI component = ((Component)this).gameObject.GetComponent(); TextMeshPro component2 = ((Component)this).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { if (string.IsNullOrEmpty(unbentText)) { unbentText = ((TMP_Text)component).text; } ((TMP_Text)component).text = text; } else if ((Object)(object)component2 != (Object)null) { if (string.IsNullOrEmpty(unbentText)) { unbentText = ((TMP_Text)component2).text; } ((TMP_Text)component2).text = text; } } public void SetFont(TMP_FontAsset font) { if (!((Object)(object)this == (Object)null) && !((Object)(object)((Component)this).gameObject == (Object)null)) { TextMeshProUGUI component = ((Component)this).gameObject.GetComponent(); TextMeshPro component2 = ((Component)this).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { ((TMP_Text)component).font = font; } else if ((Object)(object)component2 != (Object)null) { ((TMP_Text)component2).font = font; } } } public void SetFont(string fontName) { TMP_FontAsset fontFromName = getFontFromName(fontName); if ((Object)(object)fontFromName != (Object)null) { SetFont(fontFromName); } } private string truncateText(string text) { if (Config.TruncationLength.Value <= 0) { return text; } return text.Substring(0, Config.TruncationLength.Value); } public void SetDepth(float depth) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.localPosition = new Vector3(((Component)this).transform.localPosition.x, ((Component)this).transform.localPosition.y, depth / 10f); } public void ResetText() { SetText(unbentText); } public void ResetFont() { SetFont("GoodDogPlain"); } public void ResetImages() { List list = new List(); if ((Object)(object)this == (Object)null || (Object)(object)((Component)this).gameObject == (Object)null) { return; } BentImage[] array = Il2CppArrayBase.op_Implicit(((Component)this).GetComponentsInChildren()); if (BentImages.Count == 0 && array.Length != 0) { BentImages.AddRange(array); } foreach (BentImage bentImage in BentImages) { bentImage.Reset(); list.Add(bentImage); } foreach (BentImage item in list) { BentImages.Remove(item); } } public void ResetAll() { Variation = null; ResetText(); ResetFont(); ResetImages(); } public static string ProcessFields(int frameIndex, Variation variation) { string text = variation.Frames[frameIndex]; List typedFields = variation.TypedFields; string text2 = string.Empty; List list = new List(); foreach (TypedField item in typedFields) { foreach (FieldInstance instance in item.Instances) { if (instance.FrameIndex == frameIndex) { list.Add(instance); } } } int num = 0; if (list.Count > 0) { for (int i = 0; i < list.Count; i++) { FieldInstance fieldInstance = list[i]; TypedField ownerField = fieldInstance.OwnerField; string valueAsStringAt = ownerField.GetValueAsStringAt(fieldInstance, entry: true); if (num > text.Length) { break; } text2 += text.Substring(num, fieldInstance.StartPos - num); if (!ownerField.IsReferential && !ownerField.IsFactory) { if (!fieldInstance.IsSetter) { ownerField.SetValueUntyped(valueAsStringAt); } else { ownerField.SetValueUntyped(fieldInstance.SetTo); } } text2 += valueAsStringAt; num = fieldInstance.StartPos + fieldInstance.TotalLength; } if (num <= text.Length) { text2 += text.Substring(num); } return text2; } return text; } private TMP_FontAsset getFontFromName(string font) { foreach (TMP_FontAsset cachedFontAsset in Core.Instance.CachedFontAssets) { if (((Object)cachedFontAsset).name == font) { return cachedFontAsset; } } return null; } } [RegisterTypeInIl2Cpp] public class BentImage : MonoBehaviour { [CompilerGenerated] private sealed class d__12 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int index; public BentImage <>4__this; private int 5__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = 0; goto IL_007a; case 1: <>1__state = -1; goto IL_007a; case 2: { <>1__state = -1; break; } IL_007a: if (!<>4__this.ImageInfo.TextureDownloaded) { if (5__1++ >= 500) { return false; } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } break; } if ((Object)(object)<>4__this.material == (Object)null) { if (5__1++ >= 500) { return false; } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; } if (!<>4__this.ImageInfo.IsGIF) { <>4__this.material.mainTexture = (Texture)(object)<>4__this.ImageInfo.Texture; } else { <>4__this.material.mainTexture = (Texture)(object)<>4__this.ImageInfo.Frames[index].Texture; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public ImageInfo ImageInfo; public NameBend ParentComponent; public object SetTextureRoutine; public bool IsReset = false; private float timer = 0f; private int currentFrameIndex = 0; private Material material { get { if ((Object)(object)this != (Object)null && (Object)(object)((Component)this).gameObject != (Object)null) { Renderer componentInChildren = ((Component)this).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { return componentInChildren.material; } } return null; } } private void OnDestroy() { Core.Instance.BentImages.Remove(this); } public void Update() { if (Config.DisableMod.Value || !Config.Images.Value) { return; } ImageInfo imageInfo = ImageInfo; if (!imageInfo.TextureDownloaded) { imageInfo = ImageInfo.GetLoadingGif(); } if (!imageInfo.IsGIF) { return; } timer += Time.deltaTime; if (timer > imageInfo.GifDuration) { timer = 0f; currentFrameIndex = 0; } for (int i = currentFrameIndex; i < imageInfo.Frames.Count; i++) { FrameData frameData = imageInfo.Frames[i]; if (frameData.GetTimestamp() < timer && frameData.Index > currentFrameIndex) { currentFrameIndex = frameData.Index; material.mainTexture = (Texture)(object)imageInfo.Frames[currentFrameIndex].Texture; break; } } } public void Reset() { if (SetTextureRoutine != null) { MelonCoroutines.Stop(SetTextureRoutine); } IsReset = true; try { Object.Destroy((Object)(object)((Component)this).gameObject); } catch { } } public void RestartFrames() { SetTextureRoutine = MelonCoroutines.Start(SetTextureWhenAvailable(0)); timer = 0f; } [IteratorStateMachine(typeof(d__12))] public IEnumerator SetTextureWhenAvailable(int index) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { <>4__this = this, index = index }; } public void Censor() { ImageInfo.UndownloadImage(); ImageInfo.Censored = true; ImageInfo.ForceUncensor = false; ImageInfo.Texture = Core.Instance.CachedCensoredTexture; ImageInfo.TextureDownloaded = true; RestartFrames(); } public void CensorIfNeeded() { if (ImageInfo.Censored && !ImageInfo.ForceUncensor) { ImageInfo.UndownloadImage(); ImageInfo.Texture = Core.Instance.CachedCensoredTexture; ImageInfo.TextureDownloaded = true; RestartFrames(); } } public void Uncensor() { ImageInfo.UndownloadImage(); ImageInfo.Censored = false; ImageInfo.ForceUncensor = true; if (ImageInfo.DownloadCoroutine != null) { MelonCoroutines.Stop(ImageInfo.DownloadCoroutine); } ImageInfo.DownloadCoroutine = MelonCoroutines.Start(ImageInfo.DownloadImage()); RestartFrames(); } public void UncensorIfNeeded() { if (!ImageInfo.Censored || ImageInfo.ForceUncensor) { ImageInfo.UndownloadImage(); ImageInfo.Censored = false; if (ImageInfo.DownloadCoroutine != null) { MelonCoroutines.Stop(ImageInfo.DownloadCoroutine); } ImageInfo.DownloadCoroutine = MelonCoroutines.Start(ImageInfo.DownloadImage()); RestartFrames(); } } public void SetMipmapBias(float bias) { foreach (FrameData frame in ImageInfo.Frames) { ((Texture)frame.Texture).mipMapBias = bias; } } public void SetOpacity(float opacity) { material.SetFloat("_Opacity", opacity); } } public static class Config { public static KeyCode _refreshHotkeyCode = (KeyCode)0; public static bool prevDisableMod = false; public static bool prevBentName = false; public static bool prevBentTitle = false; public static bool prevImages = false; public static int prevForceVariation = -1; public static bool prevTrustAll = false; public static ModelMod Me; public static MelonPreferences_Category Cat_NamePlate; public static MelonPreferences_Entry NameplatePreview; public static MelonPreferences_Entry RefreshHotkey; public static MelonPreferences_Category Cat_SimpleConfig; public static MelonPreferences_Entry EnableSimpleConfig; public static MelonPreferences_Entry SimpleNameBend; public static MelonPreferences_Entry SimpleTitleBend; public static MelonPreferences_Entry SimpleAltText; public static MelonPreferences_Category Cat_Toggles; public static MelonPreferences_Entry DisableMod; public static MelonPreferences_Entry MatchInfoPlates; public static MelonPreferences_Entry MyAltName; public static MelonPreferences_Entry MyBentName; public static MelonPreferences_Entry OtherBentNames; public static MelonPreferences_Entry MyBentTitle; public static MelonPreferences_Entry OtherBentTitles; public static MelonPreferences_Entry Animations; public static MelonPreferences_Entry Images; public static MelonPreferences_Category Cat_Advanced; public static MelonPreferences_Entry TruncationLength; public static MelonPreferences_Entry FieldDepthLimit; public static MelonPreferences_Entry ForceVariationAt; public static MelonPreferences_Entry MipmapBias; public static MelonPreferences_Entry SaveNamesToFiles; public static MelonPreferences_Entry TrustAllImages; public static MelonPreferences_Entry Disclaimer; public static string ConfigFilePath => Path.Combine(Core.UserDataPath, "UIConfig.cfg"); public static KeyCode RefreshHotkeyCode { get { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(RefreshHotkey.Value)) { if ((int)_refreshHotkeyCode == 0) { _refreshHotkeyCode = parseKey(RefreshHotkey.Value); } return _refreshHotkeyCode; } return (KeyCode)0; } } public static void SetUpUI() { Cat_NamePlate = MelonPreferences.CreateCategory("NamePlate", "Name Plate"); Cat_NamePlate.SetFilePath(ConfigFilePath); NameplatePreview = Cat_NamePlate.CreateEntry("NameplatePreview", false, "Nameplate Preview", "Show a preview of your nameplate on the screen", false, false, (ValueValidator)null, (string)null); UI.CreateButtonEntry(Cat_NamePlate, "Refresh", "Refresh Designations", "Update your name and title for everyone", (Action)Core.Instance.UpdateDesignations); RefreshHotkey = Cat_NamePlate.CreateEntry("RefreshHotkey", "N", "Refresh Hotkey", "Keyboard button to refresh with\nLeave empty to disable", false, false, (ValueValidator)null, (string)null); Cat_SimpleConfig = MelonPreferences.CreateCategory("SimpleConfig", "Simple Config"); Cat_SimpleConfig.SetFilePath(ConfigFilePath); EnableSimpleConfig = Cat_SimpleConfig.CreateEntry("EnableSimpleConfig", true, "Enable Simple Config", "Enable a simple way to set name, title, and alt text\nSupports Unity rich text tags, such as colors, e.g. <#F00>\nAdvanced features such as animations and images will require configuring the .json files in UserData/NameBending", false, false, (ValueValidator)null, (string)null); SimpleNameBend = Cat_SimpleConfig.CreateEntry("SimpleNameBend", "", "Custom Bent Name", "When set, your name will appear like this to others who have the mod\nAdvanced features such as animations and images will require configuring the .json files in UserData/NameBending", false, false, (ValueValidator)null, (string)null); SimpleTitleBend = Cat_SimpleConfig.CreateEntry("SimpleTitleBend", "", "Custom Bent Title", "When set, your title will appear like this to others who have the mod", false, false, (ValueValidator)null, (string)null); SimpleAltText = Cat_SimpleConfig.CreateEntry("SimpleAltText", "", "Alt Text", $"When set, your name will appear like this to others who do not have the mod\nLimited to {71} characters", false, false, (ValueValidator)null, (string)null); Cat_Toggles = MelonPreferences.CreateCategory("Toggles", "Toggles"); Cat_Toggles.SetFilePath(ConfigFilePath); DisableMod = Cat_Toggles.CreateEntry("DisableMod", false, "Disable Mod", "Turn off all name bending", false, false, (ValueValidator)null, (string)null); MatchInfoPlates = Cat_Toggles.CreateEntry("MatchInfoPlates", true, "MatchInfo Plates", "Show nameplates on the MatchInfo mod board", false, false, (ValueValidator)null, (string)null); MyAltName = Cat_Toggles.CreateEntry("MyAltName", true, "My Alt Name", "Enable the name that shows to people who don't have the mod", false, false, (ValueValidator)null, (string)null); MyBentName = Cat_Toggles.CreateEntry("MyBentName", true, "My Bent Name", "Show your custom name to other people", false, false, (ValueValidator)null, (string)null); OtherBentNames = Cat_Toggles.CreateEntry("OtherBentNames", true, "Other Bent Names", "Show other people's custom names", false, false, (ValueValidator)null, (string)null); MyBentTitle = Cat_Toggles.CreateEntry("MyBentTitle", true, "My Bent Title", "Show your custom title to other people", false, false, (ValueValidator)null, (string)null); OtherBentTitles = Cat_Toggles.CreateEntry("OtherBentTitles", true, "Other Bent Titles", "Show other people's custom titles", false, false, (ValueValidator)null, (string)null); Animations = Cat_Toggles.CreateEntry("Animations", true, "Animations", "Show animations in custom names and titles", false, false, (ValueValidator)null, (string)null); Images = Cat_Toggles.CreateEntry("Images", true, "Images", "Enable all nameplate images", false, false, (ValueValidator)null, (string)null); Cat_Advanced = MelonPreferences.CreateCategory("Advanced", "Advanced"); Cat_Advanced.SetFilePath(ConfigFilePath); TruncationLength = Cat_Advanced.CreateEntry("TruncationLength", -1, "Truncation Length", "The number of characters to truncate names to\nSet to -1 to disable", false, false, (ValueValidator)null, (string)null); FieldDepthLimit = Cat_Advanced.CreateEntry("FieldDepthLimit", 10, "Field Depth Limit", "The amount of times fields are allowed to process other fields within themselves", false, false, (ValueValidator)null, (string)null); ForceVariationAt = Cat_Advanced.CreateEntry("ForceVariationAt", -1, "ForceVariationAt", "Always pick the variation at this index\n-1 to disable", false, false, (ValueValidator)null, (string)null); MipmapBias = Cat_Advanced.CreateEntry("MipmapBias", -0.5f, "Mipmap Bias", "The mipmap bias of images on nameplates\nLower numbers make clearer images\n(usually between -2.0 and 2.0)", false, false, (ValueValidator)null, (string)null); SaveNamesToFiles = Cat_Advanced.CreateEntry("SaveNamesToFiles", false, "Save Names to Files", "Save every name and title you come across to files in\nUserdata/NameBending/saved_names", false, false, (ValueValidator)null, (string)null); TrustAllImages = Cat_Advanced.CreateEntry("TrustAllImages", false, "<#F00>TRUST ALL IMAGES", "<#F00>Disable moderation features by automatically trusting images that have not been manually approved by moderators\nRequires accepting the disclaimer below", false, false, (ValueValidator)null, (string)null); Disclaimer = Cat_Advanced.CreateEntry("Disclaimer", false, "Accept Disclaimer", "I understand that by disabling moderation features, other users can subject me to any image on the internet. These images may be graphic, NSFW, offensive, triggering to photosensitivity, or otherwise unwanted.", false, false, (ValueValidator)null, (string)null); UI.CreateButtonEntry(Cat_Advanced, "Clear", "Clear Image Cache", "Remove any stored data about existing and previous nameplate images", (Action)Core.ClearImageCache); Me = UI.Register((MelonBase)(object)Core.Instance, (MelonPreferences_Category[])(object)new MelonPreferences_Category[4] { Cat_NamePlate, Cat_SimpleConfig, Cat_Toggles, Cat_Advanced }); ((ModelModItem)Me).OnModSaved += OnPrefsSaved; } public static void OnPrefsSaved() { //IL_038f: Unknown result type (might be due to invalid IL or missing references) MatchInfoBoard.SetMatchInfo(MatchInfoPlates.Value); Core.Instance.SetPlatePreview(NameplatePreview.Value); if (DisableMod.Value) { foreach (NameBend nameBend in Core.Instance.NameBends) { nameBend.ResetAll(); } } if (!MyBentName.Value || DisableMod.Value) { foreach (NameBend nameBend2 in Core.Instance.NameBends) { if (!((Object)(object)nameBend2 == (Object)null) && nameBend2.DesignationType == Core.DesignationType.Name && nameBend2.IsLocal) { nameBend2.ResetAll(); } } } if (!MyBentName.Value || DisableMod.Value) { foreach (NameBend nameBend3 in Core.Instance.NameBends) { if (!((Object)(object)nameBend3 == (Object)null) && nameBend3.DesignationType == Core.DesignationType.Name && !nameBend3.IsLocal) { nameBend3.ResetAll(); } } } if (!MyBentName.Value || DisableMod.Value) { foreach (NameBend nameBend4 in Core.Instance.NameBends) { if (!((Object)(object)nameBend4 == (Object)null) && nameBend4.DesignationType == Core.DesignationType.Title && nameBend4.IsLocal) { nameBend4.ResetAll(); } } } if (!MyBentName.Value || DisableMod.Value) { foreach (NameBend nameBend5 in Core.Instance.NameBends) { if (!((Object)(object)nameBend5 == (Object)null) && nameBend5.DesignationType == Core.DesignationType.Title && !nameBend5.IsLocal) { nameBend5.ResetAll(); } } } if (EnableSimpleConfig.Value && SimpleAltText.Value.Length > 71) { Debug.Error($"Alt text cannot be more than {71} characters"); } if (!Images.Value || DisableMod.Value) { foreach (BentImage bentImage in Core.Instance.BentImages) { if (!((Object)(object)bentImage == (Object)null)) { bentImage.ImageInfo.UndownloadImage(); bentImage.Reset(); } } } _refreshHotkeyCode = (KeyCode)0; if (ForceVariationAt.Value != prevForceVariation) { Core.Instance.UpdateDesignations(); } prevForceVariation = ForceVariationAt.Value; foreach (BentImage bentImage2 in Core.Instance.BentImages) { if (!((Object)(object)bentImage2 == (Object)null)) { bentImage2.SetMipmapBias(MipmapBias.Value); } } if (prevTrustAll != (TrustAllImages.Value && Disclaimer.Value)) { Core.ClearImageCache(); } prevTrustAll = TrustAllImages.Value && Disclaimer.Value; if (TrustAllImages.Value && Disclaimer.Value) { foreach (BentImage bentImage3 in Core.Instance.BentImages) { if (!((Object)(object)bentImage3 == (Object)null)) { bentImage3.Uncensor(); } } } else { foreach (BentImage bentImage4 in Core.Instance.BentImages) { if (!((Object)(object)bentImage4 == (Object)null)) { bentImage4.CensorIfNeeded(); } } } if ((!prevDisableMod || DisableMod.Value) && (prevBentName || !MyBentName.Value) && (prevBentTitle || !MyBentTitle.Value) && (prevImages || !Images.Value)) { return; } foreach (NameBend nameBend6 in Core.Instance.NameBends) { nameBend6.OnUpdateDesignations(); } } private static KeyCode parseKey(string key) { //IL_0015: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (Enum.TryParse(key, ignoreCase: true, out KeyCode result)) { return result; } return (KeyCode)0; } } public static class BuildInfo { public const string Name = "NameBending"; public const string Author = "TacoSlayer36"; public const string Version = "2.0.0"; public const string Description = "Change your name and title to anything you like"; } public class Core : MelonMod { public enum DesignationType { Name, Title } [HarmonyPatch(typeof(PlayerController), "Initialize", new Type[] { typeof(Player) })] public static class playerspawn { private static void Postfix(ref PlayerController __instance, ref Player player) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 bool isLocal = (int)player.Controller.controllerType == 1; Instance.ApplyComponentsToPlate(player, isPlayer: true, isLocal, isUI: false); } } [HarmonyPatch(typeof(PlayerNameTag), "ChangeOpacity", new Type[] { typeof(float) })] public static class nametagopacity { private static void Postfix(ref PlayerNameTag __instance, ref float alpha) { foreach (NameBend componentsInChild in ((Component)__instance).GetComponentsInChildren()) { if (!((Object)(object)componentsInChild != (Object)null) || componentsInChild.IsScreenSpace) { continue; } foreach (BentImage bentImage in componentsInChild.BentImages) { bentImage.SetOpacity(alpha); } } } } [CompilerGenerated] private sealed class <g___|61_0>d : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Core <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <g___|61_0>d(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this.readDesignationFiles(); <>4__this.UpdateDesignations(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <g__listenForLandButton|59_0>d : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string landType; public Core <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <g__listenForLandButton|59_0>d(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(3f); <>1__state = 1; return true; case 1: { <>1__state = -1; GameObject obj = GameObject.Find(landType); if (obj != null) { obj.GetComponentInChildren().onPressed.AddListener(UnityAction.op_Implicit((Action)delegate { MelonCoroutines.Start(<>4__this.OnLandEntered()); })); } return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <>c__DisplayClass55_0 { public bool isLocal; public Player player; public GameObject plate; public bool isPlayer; public bool isUI; } [CompilerGenerated] private sealed class <>c__DisplayClass77_0 { public Core <>4__this; public bool enabled; } [CompilerGenerated] private sealed class d__72 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string type; public string text; public Core <>4__this; private Player 5__1; private int 5__2; private Hashtable 5__3; private string 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__72(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!PhotonNetwork.InRoom) { return false; } if (!Instance.EventRaised && IsInMatch) { 5__4 = "NameBending." + type.Substring(0, 1) + "|" + text; Instance.EventRaised = true; 5__4 = null; } 5__1 = null; 5__2 = 0; break; case 1: <>1__state = -1; 5__2++; break; } while (5__1 == null) { if (5__2 > 300) { ((MelonBase)<>4__this).LoggerInstance.Error("Failed to get local Photon player"); return false; } PlayerManager instance = Singleton.Instance; 5__1 = HelperFunctions.FindPhotonPlayerFromRumblePlayer((instance != null) ? instance.LocalPlayer : null); if (5__1 == null) { <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 1; return true; } } 5__3 = new Hashtable(); 5__3[Object.op_Implicit("NameBending." + type)] = Object.op_Implicit(text); 5__1.SetCustomProperties(5__3, (Hashtable)null, (WebFlags)null); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__73 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string type; public Variation variation; public Core <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__73(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; MelonCoroutines.Start(<>4__this.AddLocalProp(type, variation?.SerializedJson ?? "None")); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__55 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GameObject plate; public Player player; public bool isPlayer; public bool isLocal; public bool isUI; public Core <>4__this; private <>c__DisplayClass55_0 <>8__1; private PlayerNameTag 5__2; private IEnumerator <>s__3; private TextMeshPro 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__55(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; <>s__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; <>8__1 = new <>c__DisplayClass55_0(); <>8__1.isLocal = isLocal; <>8__1.player = player; <>8__1.plate = plate; <>8__1.isPlayer = isPlayer; <>8__1.isUI = isUI; 5__2 = <>8__1.plate.GetComponent(); 5__2.RefreshNameTag(); <>s__3 = <>8__1.plate.GetComponentsInChildren().GetEnumerator(); try { while (<>s__3.MoveNext()) { 5__4 = <>s__3.Current; ((TMP_Text)5__4).fontStyle = (FontStyles)0; ((TMP_Text)5__4).characterSpacing = 0f; 5__4 = null; } } finally { if (<>s__3 != null) { <>s__3.Dispose(); } } <>s__3 = null; MelonCoroutines.Start(<>8__1.g__applyWhenAble|0(DesignationType.Name)); MelonCoroutines.Start(<>8__1.g__applyWhenAble|0(DesignationType.Title)); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__60 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Core <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__60(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1.5f); <>1__state = 1; return true; case 1: { <>1__state = -1; GameObject modParent = <>4__this.ModParent; if (modParent != null) { modParent.SetActive(true); } return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static Core Instance; private bool globalInit = false; public static string CurrentScene = "Loader"; public const byte EventNumber = 31; public bool EventRaised = false; public static string OpponentPhotonName = null; public static string OpponentPhotonTitle = null; public GameObject ModParent; public GameObject localNameplateImageObject; public GameObject LocalNameplateClone; public RawImage LocalRawNameplateImage; public GameObject CanvasObject; public static readonly HttpClient _http = new HttpClient(); public const int AltTextCharLimit = 71; private string nameConfigFileName = "CustomBentName"; private string titleConfigFileName = "CustomBentTitle"; public bool HasNameConfigFile = false; public bool HasTitleConfigFile = false; public const int FloatingPointPrecision = 5; public const string FieldPattern = "{([\\da-zA-Z_\\-|.#]+)(=[^}]+)?}"; public Root NameRoot = null; public Root TitleRoot = null; public Variation ActiveNameVariation = null; public Variation ActiveTitleVariation = null; private int nameVariationIndex = 0; private int titleVariationIndex = 0; public Dictionary DesignationsHashes = new Dictionary(); public List NameBends = new List(); public List BentImages = new List(); private bool shownNoNameFileWarning = false; private bool shownNoTitleFileWarning = false; private bool shownNameTemplateWarning = false; private bool shownTitleTemplateWarning = false; private bool shownLowFrameDurationWarning = false; private long lastDesignationUpdate = 0L; public List CachedFontAssets = new List(); public Shader CachedImageShader; public List CachedLoadingFrames; public Texture2D CachedCensoredTexture; public Texture2D CachedLoadingTexture; public Texture2D CachedFailedTexture; public Dictionary> CachedImages = new Dictionary>(); public GameObject PlatePreviewCanvas; public static bool IsInMatch => CurrentScene.StartsWith("Map") && ((Il2CppArrayBase)(object)PhotonNetwork.PlayerList).Count == 2; public static string UserDataPath => Path.Combine("UserData", "NameBending"); public string MyDesignationsHash { get { string s = ActiveNameVariation?.GetJsonPropertiesHashCode() + ActiveTitleVariation?.GetJsonPropertiesHashCode(); byte[] bytes = Encoding.UTF8.GetBytes(s); byte[] inArray = SHA256.HashData(bytes); return Convert.ToHexString(inArray).Substring(0, 9); } } public event Action OnUpdateDesignations; [IteratorStateMachine(typeof(d__55))] public IEnumerator ApplyComponentsToPlate(GameObject plate, Player player, bool isPlayer, bool isLocal, bool isUI) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__55(0) { <>4__this = this, plate = plate, player = player, isPlayer = isPlayer, isLocal = isLocal, isUI = isUI }; } public void ApplyComponentsToPlate(Player player, bool isPlayer, bool isLocal, bool isUI) { GameObject gameObject = ((Component)player.Controller.PlayerNameTag).gameObject; MelonCoroutines.Start(ApplyComponentsToPlate(gameObject, player, isPlayer, isLocal, isUI)); } public Variation PickVariation(Root root, DesignationType designationType) { if (root == null) { return null; } Variation variation = null; if (root.DoRandomVariations) { Random random = new Random(); double num = root.Variations.Sum((Variation v) => v.GetWeightFromString()); double num2 = random.NextDouble() * num; double num3 = 0.0; Variation variation2 = null; foreach (Variation variation3 in root.Variations) { num3 += variation3.GetWeightFromString(); if (num2 <= num3) { variation2 = variation3; break; } } variation = variation2; } else { if (designationType == DesignationType.Name) { variation = root.Variations[nameVariationIndex = (nameVariationIndex + 1) % root.Variations.Count]; } if (designationType == DesignationType.Title) { variation = root.Variations[titleVariationIndex = (titleVariationIndex + 1) % root.Variations.Count]; } } if (Config.ForceVariationAt.Value >= 0 && Config.ForceVariationAt.Value < root.Variations.Count) { variation = root.Variations[Config.ForceVariationAt.Value]; } if (variation == null) { return null; } variation.DesignationType = ((designationType == DesignationType.Name) ? "Name" : "Title"); variation.Owner = Singleton.Instance.LocalPlayer; return variation; } public override void OnLateInitializeMelon() { Instance = this; Config.SetUpUI(); loadFonts(); loadShader(); readDesignationFiles(); } public override void OnSceneWasUnloaded(int buildIndex, string sceneName) { EventRaised = false; OpponentPhotonName = null; OpponentPhotonTitle = null; Object.Destroy((Object)(object)MatchInfoBoard.PlateClone1); Object.Destroy((Object)(object)MatchInfoBoard.PlateClone2); MelonCoroutines.Start(listenForLandButton("FlatLand")); MelonCoroutines.Start(listenForLandButton("VoidLand")); [IteratorStateMachine(typeof(<g__listenForLandButton|59_0>d))] IEnumerator listenForLandButton(string landType) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <g__listenForLandButton|59_0>d(0) { <>4__this = this, landType = landType }; } } [IteratorStateMachine(typeof(d__60))] private IEnumerator OnLandEntered() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__60(0) { <>4__this = this }; } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { CurrentScene = sceneName; if (sceneName == "Gym") { if (!globalInit) { globalInit = true; Config.OnPrefsSaved(); MelonCoroutines.Start(MatchInfoBoard.FindMatchInfoBoard()); } GameObject gameObject = NameTag.GetGameObject(); MelonCoroutines.Start(ApplyComponentsToPlate(gameObject, Singleton.Instance.LocalPlayer, isPlayer: false, isLocal: true, isUI: false)); } if (buildIndex >= 3) { MelonCoroutines.Start(MatchInfoBoard.SetUpMatchInfoDelayed(1f)); } if (globalInit) { MelonCoroutines.Start(_()); } [IteratorStateMachine(typeof(<g___|61_0>d))] IEnumerator _() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <g___|61_0>d(0) { <>4__this = this }; } } public override void OnUpdate() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (globalInit && Input.GetKeyDown(Config.RefreshHotkeyCode)) { readDesignationFiles(); UpdateDesignations(); } } public void UpdateDesignations() { long num = 3000 - (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - lastDesignationUpdate); if (num > 0 && PhotonNetwork.InRoom) { Debug.Error("Please wait " + Mathf.Round((float)(num / 1000)).ToString("0") + " seconds before updating your name again"); return; } if (globalInit) { string message = "Updating your name and title..."; if (Instance.HasNameConfigFile && !Instance.HasTitleConfigFile) { message = "Updating your name..."; } if (!Instance.HasNameConfigFile && Instance.HasTitleConfigFile) { message = "Updating your title..."; } if (!Instance.HasNameConfigFile && !Instance.HasTitleConfigFile) { message = "Nothing to update"; } Debug.Log(message); } if (NameRoot != null && Config.MyBentName.Value && !Config.DisableMod.Value) { ActiveNameVariation = PickVariation(NameRoot, DesignationType.Name); } else { ActiveNameVariation = null; } if (TitleRoot != null && Config.MyBentTitle.Value && !Config.DisableMod.Value) { ActiveTitleVariation = PickVariation(TitleRoot, DesignationType.Title); } else { ActiveTitleVariation = null; } if (ActiveTitleVariation != null) { ActiveTitleVariation.MarkTitleCounterfeit(); } string text = Singleton.Instance.LocalPlayer.Data.GeneralData.PublicUsername; if (Config.EnableSimpleConfig.Value && !string.IsNullOrEmpty(Config.SimpleAltText.Value)) { text = Config.SimpleAltText.Value; } else if (ActiveNameVariation != null) { text = ActiveNameVariation.AltText; } if (Config.MyAltName.Value && !string.IsNullOrWhiteSpace(text) && text.Length <= 71) { Singleton.Instance.LocalPlayer.Data.GeneralData.PublicUsername = text; } if (text.Length > 71) { Debug.Error($"Alt text cannot be more than {71} characters"); } if (PhotonNetwork.InRoom) { MelonCoroutines.Start(AddLocalProp("Name", GetVariationString(ActiveNameVariation))); MelonCoroutines.Start(AddLocalProp("Title", GetVariationString(ActiveTitleVariation))); MelonCoroutines.Start(AddLocalProp("HashCode", MyDesignationsHash)); } lastDesignationUpdate = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); this.OnUpdateDesignations?.Invoke(); } public string GetVariationString(Variation variation) { if (variation == null) { return "None"; } if (variation.DesignationType == "Name" && Config.EnableSimpleConfig.Value && !string.IsNullOrEmpty(Config.SimpleNameBend.Value)) { return "{\"frames\":{\"0\":\"" + Config.SimpleNameBend.Value + "\"}}"; } if (variation.DesignationType == "Title" && Config.EnableSimpleConfig.Value && !string.IsNullOrEmpty(Config.SimpleTitleBend.Value)) { return "{\"frames\":{\"0\":\"" + Config.SimpleTitleBend.Value + "\"}}"; } return variation.SerializedJson; } public string GetVariationHash(Variation variation) { if (variation == null) { return ""; } if (variation.DesignationType == "Name" && Config.EnableSimpleConfig.Value && !string.IsNullOrEmpty(Config.SimpleNameBend.Value)) { byte[] bytes = Encoding.UTF8.GetBytes(Config.SimpleNameBend.Value); byte[] inArray = SHA256.HashData(bytes); return Convert.ToHexString(inArray).Substring(0, 9); } if (variation.DesignationType == "Title" && Config.EnableSimpleConfig.Value && !string.IsNullOrEmpty(Config.SimpleTitleBend.Value)) { byte[] bytes2 = Encoding.UTF8.GetBytes(Config.SimpleTitleBend.Value); byte[] inArray2 = SHA256.HashData(bytes2); return Convert.ToHexString(inArray2).Substring(0, 9); } return variation.GetJsonPropertiesHashCode(); } public static void ClearImageCache() { Instance.CachedImages.Clear(); Debug.Log("Cleared image cache"); } private void readDesignationFiles() { readDesignationFile(DesignationType.Name); readDesignationFile(DesignationType.Title); } private void readDesignationFile(DesignationType type) { //IL_00a3: Expected O, but got Unknown //IL_0113: Expected O, but got Unknown string empty = string.Empty; switch (type) { case DesignationType.Name: empty = nameConfigFileName; break; case DesignationType.Title: empty = titleConfigFileName; break; } string text = Path.Combine(UserDataPath, empty); string path = text + ".json"; string path2 = text + "TEMPLATE.json"; if (File.Exists(path)) { switch (type) { case DesignationType.Name: HasNameConfigFile = true; try { NameRoot = deserializeFile(DesignationType.Name); if (NameRoot != null) { NameRoot.Type = DesignationType.Name; } } catch (JsonException val3) { JsonException val4 = val3; ((MelonBase)this).LoggerInstance.Error(((Exception)(object)val4).Message); ((MelonBase)this).LoggerInstance.Error("Make sure your JSON is formatted correctly"); } break; case DesignationType.Title: HasTitleConfigFile = true; try { TitleRoot = deserializeFile(DesignationType.Title); if (TitleRoot != null) { TitleRoot.Type = DesignationType.Title; } } catch (JsonException val) { JsonException val2 = val; ((MelonBase)this).LoggerInstance.Error(((Exception)(object)val2).Message); ((MelonBase)this).LoggerInstance.Error("Make sure your JSON is formatted correctly"); } catch (FileNotFoundException) { ((MelonBase)this).LoggerInstance.Error("Bent title config file not found"); } break; } } else { switch (type) { case DesignationType.Name: HasNameConfigFile = false; if (!shownNoNameFileWarning) { Debug.Log("No bent name file found; name will not be bent"); NameRoot = null; } break; case DesignationType.Title: HasTitleConfigFile = false; if (!shownNoTitleFileWarning) { Debug.Log("No bent title file found; title will not be bent"); TitleRoot = null; } break; } } if (File.Exists(path2)) { if (type == DesignationType.Name && !shownNameTemplateWarning && NameRoot == null) { shownNameTemplateWarning = true; ((MelonBase)this).LoggerInstance.Warning("TEMPLATE file detected for bent name"); } else if (type == DesignationType.Title && !shownTitleTemplateWarning && TitleRoot == null) { shownTitleTemplateWarning = true; ((MelonBase)this).LoggerInstance.Warning("TEMPLATE file detected for bent title"); } if (shownNameTemplateWarning || shownTitleTemplateWarning) { ((MelonBase)this).LoggerInstance.Warning("Don't forget to remove TEMPLATE from your config files"); } } } private Root deserializeFile(DesignationType type) { //IL_00c0: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) string text = ((type == DesignationType.Name) ? "Name" : "Title"); if (type == DesignationType.Name && !HasNameConfigFile) { return null; } if (type == DesignationType.Title && !HasTitleConfigFile) { return null; } Root root = new Root(); string text2 = string.Empty; switch (type) { case DesignationType.Name: text2 = File.ReadAllText(Path.Combine(UserDataPath, nameConfigFileName + ".json")); break; case DesignationType.Title: text2 = File.ReadAllText(Path.Combine(UserDataPath, titleConfigFileName + ".json")); break; } try { root = JsonConvert.DeserializeObject(text2); } catch (JsonException val) { JsonException val2 = val; throw new JsonException("Error deserializing bent " + text + " config file: " + ((Exception)(object)val2).Message); } if (!shownLowFrameDurationWarning) { foreach (Variation variation in root.Variations) { if (variation.FrameDuration > 0 && variation.FrameDuration < 20) { ((MelonBase)this).LoggerInstance.Warning($"Frame duration ({variation.FrameDuration} in {text} config) is lower than 20ms; some frames may be skipped"); shownLowFrameDurationWarning = true; } } } return root; } private void loadFonts() { if (CachedFontAssets.Count > 0) { return; } List list = new List(); try { foreach (string item in new List { "Arial", "ChineseRocks", "ComicSans", "Crumble", "GoodDogPlain", "Impact", "Minecraft", "Roboto", "SGA", "TimesNewRoman", "Tumble", "TokiPona", "Avasinistral", "Wingdings", "Papyrus", "Cascadia", "Hollywood", "HighwayGothic" }) { Font val = AssetBundles.LoadAssetFromStream((MelonMod)(object)this, "NameBending.assets.namebending", item); TMP_FontAsset val2 = TMP_FontAsset.CreateFontAsset(val); ((Object)val2).hideFlags = (HideFlags)61; ((Object)val2).name = item; list.Add(val2); } CachedFontAssets = list; } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error("Error loading fonts: " + ex.Message); } try { CachedLoadingTexture = AssetBundles.LoadAssetFromStream((MelonMod)(object)this, "NameBending.assets.namebending", "LoadingTexture"); CachedCensoredTexture = AssetBundles.LoadAssetFromStream((MelonMod)(object)this, "NameBending.assets.namebending", "CensoredTexture"); CachedFailedTexture = AssetBundles.LoadAssetFromStream((MelonMod)(object)this, "NameBending.assets.namebending", "FailedTexture"); CachedLoadingFrames = HelperFunctions.ConvertGifToList(Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)AssetBundles.LoadAssetFromStream((MelonMod)(object)this, "NameBending.assets.namebending", "LoadingGif").bytes)); ((Object)CachedLoadingTexture).hideFlags = (HideFlags)61; ((Object)CachedCensoredTexture).hideFlags = (HideFlags)61; ((Object)CachedFailedTexture).hideFlags = (HideFlags)61; foreach (FrameData cachedLoadingFrame in CachedLoadingFrames) { ((Object)cachedLoadingFrame.Texture).hideFlags = (HideFlags)61; cachedLoadingFrame.HolderList = CachedLoadingFrames; } } catch (Exception ex2) { ((MelonBase)this).LoggerInstance.Error("Error loading built-in textures: " + ex2.Message); } CachedFontAssets = list; } private void loadShader() { Shader val = AssetBundles.LoadAssetFromStream((MelonMod)(object)this, "NameBending.assets.namebending", "SimpleRGBA"); ((Object)val).hideFlags = (HideFlags)61; CachedImageShader = val; } [IteratorStateMachine(typeof(d__72))] public IEnumerator AddLocalProp(string type, string text) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__72(0) { <>4__this = this, type = type, text = text }; } [IteratorStateMachine(typeof(d__73))] public IEnumerator AddLocalProp(string type, Variation variation) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__73(0) { <>4__this = this, type = type, variation = variation }; } public void EventReceived(EventData photonEvent) { if (photonEvent.Code == 31 && photonEvent.CustomData.ToString().StartsWith("NameBending.")) { string text = photonEvent.CustomData.ToString().Substring(12, 1); string text2 = photonEvent.CustomData.ToString().Substring(14); if (text == "N") { OpponentPhotonName = text2; } else if (text == "T") { OpponentPhotonTitle = text2; } } } public void CreatePlatePreview() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0082: 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) //IL_00bd: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0303: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ModParent == (Object)null) { ModParent = new GameObject("NameBending"); } CanvasObject = new GameObject("NameplateCanvas"); CanvasObject.transform.SetParent(ModParent.transform); Canvas val = CanvasObject.AddComponent(); val.renderMode = (RenderMode)0; CanvasScaler val2 = CanvasObject.AddComponent(); val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); val2.screenMatchMode = (ScreenMatchMode)0; val2.matchWidthOrHeight = 0.5f; CanvasObject.AddComponent(); localNameplateImageObject = new GameObject("LocalNameplateImage"); localNameplateImageObject.transform.SetParent(CanvasObject.transform, false); RawImage val3 = localNameplateImageObject.AddComponent(); float num = (float)Mathf.Min(Screen.width, Screen.height) / 1.5f; RectTransform component = localNameplateImageObject.GetComponent(); component.anchorMin = new Vector2(1f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(1f, 1f); component.anchoredPosition = new Vector2(-10f, 200f); component.sizeDelta = new Vector2(num, num); GameObject val4 = new GameObject("LocalNameplateCamera"); val4.transform.SetParent(ModParent.transform); Camera val5 = val4.AddComponent(); val5.clearFlags = (CameraClearFlags)2; val5.backgroundColor = new Color(0f, 0f, 0f, 0f); val5.cullingMask = LayerMask.GetMask(new string[1] { "UI" }); RenderTexture val6 = new RenderTexture(900, 900, 16); val6.Create(); val5.targetTexture = val6; val5.orthographic = false; ((Component)val5).transform.position = new Vector3(0f, -1000f, 1f); ((Component)val5).transform.rotation = Quaternion.Euler(0f, 180f, 0f); LocalRawNameplateImage = localNameplateImageObject.GetComponent(); LocalRawNameplateImage.texture = (Texture)(object)val6; if ((Object)(object)LocalNameplateClone == (Object)null) { GameObject gameObject = ((Component)((Component)Singleton.Instance.LocalPlayer.Controller).transform.Find("NameTag")).gameObject; LocalNameplateClone = CloneNameplate(gameObject, isUI: true); LocalNameplateClone.transform.SetParent(ModParent.transform); LocalNameplateClone.active = true; LocalNameplateClone.transform.position = new Vector3(0f, -1000f, 0f); } } public GameObject CloneNameplate(GameObject nameplate, bool isUI = false) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Invalid comparison between Unknown and I4 GameObject val = Object.Instantiate(nameplate); val.SetActive(true); PlayerNameTag component = val.GetComponent(); if ((Object)(object)((PlayerControllerSubsystem)component).parentController == (Object)null) { ((PlayerControllerSubsystem)component).parentController = nameplate.GetComponentInParent(); } if ((Object)(object)((PlayerControllerSubsystem)component).parentController == (Object)null) { ((PlayerControllerSubsystem)component).parentController = ((Component)component.followTarget).GetComponentInParent(); } if ((Object)(object)((PlayerControllerSubsystem)component).parentController == (Object)null) { ((PlayerControllerSubsystem)component).parentController = Singleton.Instance.LocalPlayer.Controller; } PlayerController parentController = ((PlayerControllerSubsystem)component).parentController; bool isLocal = (int)parentController.controllerType == 1; component.followTarget = null; component.ChangeOpacity(1f); component.RefreshNameTag(); foreach (NameBend componentsInChild in val.GetComponentsInChildren()) { componentsInChild.ResetAll(); Object.DestroyImmediate((Object)(object)componentsInChild); } MelonCoroutines.Start(Instance.ApplyComponentsToPlate(val, parentController.assignedPlayer, isPlayer: false, isLocal, isUI)); if (isUI) { foreach (Transform componentsInChild2 in val.GetComponentsInChildren()) { ((Component)componentsInChild2).gameObject.layer = LayerMask.NameToLayer("UI"); } } return val; } public void SetPlatePreview(bool enabled) { <>c__DisplayClass77_0 CS$<>8__locals0 = new <>c__DisplayClass77_0(); CS$<>8__locals0.<>4__this = this; CS$<>8__locals0.enabled = enabled; if (globalInit) { if (Config.DisableMod.Value) { CS$<>8__locals0.enabled = false; } MelonCoroutines.Start(_()); } [IteratorStateMachine(typeof(<>c__DisplayClass77_0.<g___|0>d))] IEnumerator _() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass77_0.<g___|0>d(0) { <>4__this = CS$<>8__locals0 }; } } } internal static class Debug { public static bool debugMode = false; private static string lastDiffLogMessage = string.Empty; internal static void DiffLog(string message, bool debugOnly = true, int logLevel = 0) { if (message != lastDiffLogMessage) { lastDiffLogMessage = message; Log("DIFFLOG: " + message, debugOnly, logLevel); } } internal static void Log(string message, bool debugOnly = false, int logLevel = 0) { if (!(!debugMode && debugOnly)) { switch (logLevel) { case 1: Melon.Logger.Warning(message); break; case 2: Melon.Logger.Error(message); break; default: Melon.Logger.Msg(message); break; } } } internal static void Deb(string message) { Log(message, debugOnly: true); } internal static void Msg(string message) { Log(message); } internal static void Warning(string message) { Log(message, debugOnly: false, 1); } internal static void Error(string message) { Log(message, debugOnly: false, 2); } } public class TypedField { public enum FieldType { Boolean, Number, String, Color, Referential } public enum FormatType { None, SigFigs, Round, Hex } public NameBend OwnerComponent; public static ReadOnlyCollection FactoryFields = new List { "RANDOM", "INSTANCE_RANDOM", "FRAME_PROGRESS", "LOOP_PROGRESS", "FRAME", "TIMER" }.AsReadOnly(); public string Identifier; public int DefinitionIndex = 0; public int InstanceIndexTracker = 0; public FieldType CurrentFieldType; public FormatType CurrentFormatType; public bool BooleanValue; public float NumberValue; public string StringValue; public Color ColorValue; public int SigFigs = 2; public int Round = 1; public int HexDigits = 0; private float lastOutput; public List Instances = new List(); public bool IsReferential = false; public List> InternalFieldRefs = new List>(); public static int DepthTicker = 0; public Variation Variation => OwnerComponent.Variation; public bool IsFactory { get { string stringValue = StringValue; object obj; if (stringValue == null) { obj = null; } else { string[] array = stringValue.Split('|'); obj = ((array != null) ? array[0] : null); } if (obj == null) { obj = string.Empty; } string text = (string)obj; if (text != null) { return FactoryFields.Contains(text) || text.Contains("RANDOM"); } return false; } } public FieldInstance FindNeighborInstance(FieldInstance fieldInstance, bool onlySetters = true, bool findPrevious = false, bool loop = false) { return FindNeighborInstance(fieldInstance.FrameIndex, fieldInstance.StartPos, onlySetters, findPrevious, loop); } public FieldInstance FindNeighborInstance(int frameIndex, int startPos, bool onlySetters = true, bool findPrevious = false, bool loop = false) { if (Instances == null || Instances.Count == 0) { return null; } List list = (from i in Instances orderby i.FrameIndex, i.StartPos select i).ToList(); if (onlySetters) { list = list.Where((FieldInstance i) => i.IsSetter).ToList(); if (list.Count == 0) { return null; } } if (!findPrevious) { foreach (FieldInstance item in list) { if (item.FrameIndex > frameIndex) { return item; } } return loop ? list.First() : null; } for (int num = list.Count - 1; num >= 0; num--) { FieldInstance fieldInstance = list[num]; if (fieldInstance.FrameIndex <= frameIndex) { return fieldInstance; } } return loop ? list.Last() : null; } public FieldInstance FindInstanceAt(int frameIndex, int startPos, bool onlySetters = true) { foreach (FieldInstance instance in Instances) { if (!onlySetters && instance.FrameIndex == frameIndex && instance.StartPos == startPos) { return instance; } if (onlySetters && instance.SetTo != null && instance.FrameIndex == frameIndex && instance.StartPos == startPos) { return instance; } } return null; } public void SetValue(bool booleanValue) { if (CurrentFieldType != 0) { Debug.Log("Failed to set field value for " + Identifier + ": field does not hold booleans"); } else { BooleanValue = booleanValue; } } public void SetValue(float numberValue) { if (CurrentFieldType != FieldType.Number) { Debug.Log("Failed to set field value for " + Identifier + ": field does not hold numbers"); } else { NumberValue = numberValue; } } public void SetValue(string stringValue) { if (CurrentFieldType != FieldType.String) { Debug.Log("Failed to set field value for " + Identifier + ": field does not hold strings"); return; } StringValue = stringValue; IsReferential = FindInternalRefs(); } public void SetValue(Color colorValue) { //IL_007c: 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) if (CurrentFieldType != FieldType.Color) { Debug.Log($"Failed to set field value for {Identifier} ({CurrentFieldType.ToString()}): field does not hold colors"); } else { ColorValue = colorValue; } } public void SetValueUntyped(string value) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) float result; int result2; Color value2 = default(Color); if (value == "true") { SetValue(booleanValue: true); } else if (value == "false") { SetValue(booleanValue: false); } else if (float.TryParse(value, out result)) { SetValue(result); } else if (CurrentFormatType == FormatType.Hex && int.TryParse(value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result2)) { SetValue((float)result2); } else if (ColorUtility.TryParseHtmlString(value, ref value2)) { SetValue(value2); } else { SetValue(value); } } public static string LerpValueUntyped(string a, string b, float t, TypedField ownerField) { //IL_00b3: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) int result3; int result4; if (ownerField.HexDigits <= 0) { if (float.TryParse(a, out var result) && float.TryParse(b, out var result2)) { float input = Mathf.Lerp(result, result2, t); return ownerField.ProcessFormatting(input); } } else if (int.TryParse(a, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result3) && int.TryParse(b, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result4)) { float input2 = Mathf.Lerp((float)result3, (float)result4, t); return ownerField.ProcessFormatting(input2); } Color val = default(Color); Color val2 = default(Color); if (ColorUtility.TryParseHtmlString(a, ref val) && ColorUtility.TryParseHtmlString(b, ref val2)) { Color color = Color.Lerp(val, val2, t); return color.ToHtmlStringRGB(); } return a; } public string GetValueAsString(bool entry, int instanceIndex, int frameIndex = -1) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (frameIndex == -1) { frameIndex = OwnerComponent.FrameIndex; } if (!IsFactory) { return CurrentFieldType switch { FieldType.Boolean => BooleanValue.ToString(), FieldType.Number => ProcessFormatting(NumberValue), FieldType.Color => ColorValue.ToHtmlStringRGB(), _ => ProcessInternalRefs(StringValue, entry, instanceIndex), }; } string[] array = ProcessInternalRefs(StringValue, entry, instanceIndex).Split('|'); string text = array[0]; float num = lastOutput; bool flag = false; bool flag2 = false; if (text.Contains("RANDOM")) { int num2 = HashCode.Combine(OwnerComponent.Timer); if (text.Contains("FRAME")) { num2 = HashCode.Combine(OwnerComponent.LoopCount, frameIndex); } if (text.Contains("INSTANCE")) { num2 = HashCode.Combine(num2, instanceIndex); } Random random = new Random(num2); num = (float)random.NextDouble(); flag = true; } if (text == "FRAME_PROGRESS") { num = OwnerComponent.FrameProgress; flag = true; } if (text == "LOOP_PROGRESS") { num = OwnerComponent.LoopProgress; flag = true; } if (text == "FRAME") { num = OwnerComponent.FrameIndex; flag2 = true; } if (text == "TIMER") { num = OwnerComponent.Timer; flag2 = true; } if (flag) { float result2; float result3; if (array.Length == 2) { if (float.TryParse(array[1], out var result)) { num += result; } } else if (array.Length > 2 && float.TryParse(array[1], out result2) && float.TryParse(array[2], out result3)) { num = Mathf.Lerp(result2, result3, num); } } if (flag2) { if (array.Length > 2 && float.TryParse(array[2], out var result4)) { num *= result4; } if (array.Length > 1 && float.TryParse(array[1], out var result5)) { num += result5; } } lastOutput = num; return ProcessFormatting(num); } public string ProcessFormatting(float input) { if (CurrentFormatType == FormatType.Hex) { string text = ((int)input).ToString("X"); if (HexDigits > 0) { text = ((text.Length > HexDigits) ? new string('F', HexDigits) : text.PadLeft(HexDigits, '0')); } return text; } if (CurrentFormatType == FormatType.SigFigs) { return input.ToString("n" + SigFigs); } if (CurrentFormatType == FormatType.Round) { if (Round > 0) { return (Mathf.Round(input / (float)Round) * (float)Round).ToString("n0"); } CurrentFormatType = FormatType.None; } return input.ToString("n" + 5); } public bool FindInternalRefs() { InternalFieldRefs.Clear(); if (CurrentFieldType != FieldType.String) { return false; } MatchCollection matchCollection = Regex.Matches(StringValue, "{([\\da-zA-Z_\\-|.#]+)(=[^}]+)?}"); foreach (Match item in matchCollection) { string value = item.Groups[1].Value; foreach (TypedField typedField in Variation.TypedFields) { if (value == typedField.Identifier) { InternalFieldRefs.Add(new Tuple(typedField.Identifier, item.Index)); } } } return InternalFieldRefs.Count > 0; } public string ProcessInternalRefs(string input, bool entry, int instanceIndex) { if (entry) { DepthTicker = 0; } DepthTicker++; string text = string.Empty; int num = 0; if (InternalFieldRefs.Count > 0) { for (int i = 0; i < InternalFieldRefs.Count; i++) { Tuple tuple = InternalFieldRefs[i]; string text2 = string.Empty; if (DepthTicker < Config.FieldDepthLimit.Value) { TypedField typedField = Variation.FindField(tuple.Item1); text2 = typedField.GetValueAsStringAt(OwnerComponent.FrameIndex, tuple.Item2, entry: false, instanceIndex); } if (num > input.Length) { break; } text += input.Substring(num, tuple.Item2 - num); text += text2; num = tuple.Item2 + (tuple.Item1.Length + 2); } if (num <= input.Length) { text += input.Substring(num); } return text; } return input; } public string GetValueAsStringAt(FieldInstance fieldInstance, bool entry) { return GetValueAsStringAt(fieldInstance.FrameIndex, fieldInstance.StartPos, entry, fieldInstance.DefinitionIndex); } public string GetValueAsStringAt(int frameIndex, int startPos, bool entry, int instanceIndex = -1) { FieldInstance fieldInstance = FindInstanceAt(frameIndex, startPos); if (fieldInstance != null && OwnerComponent.FrameProgress == 0f) { return fieldInstance.SetTo; } FieldInstance fieldInstance2 = FindNeighborInstance(frameIndex, startPos, onlySetters: true, findPrevious: false, Variation.LoopInterpolation); FieldInstance fieldInstance3 = FindNeighborInstance(frameIndex, startPos, onlySetters: true, findPrevious: true, Variation.LoopInterpolation); if (Variation.Interpolation && fieldInstance2 != null && fieldInstance3 != null) { string setTo = fieldInstance2.SetTo; string setTo2 = fieldInstance3.SetTo; bool flag = fieldInstance2.FrameIndex <= fieldInstance3.FrameIndex; bool flag2 = Variation.OwnerComponent.FrameIndex < fieldInstance3.FrameIndex; int count = Variation.Frames.Count; int num = (flag ? (count - fieldInstance3.FrameIndex + fieldInstance2.FrameIndex) : (fieldInstance2.FrameIndex - fieldInstance3.FrameIndex)); float num2 = num * Variation.FrameDuration; int num3 = (flag2 ? (count - fieldInstance3.FrameIndex + Variation.OwnerComponent.FrameIndex) : (Variation.OwnerComponent.FrameIndex - fieldInstance3.FrameIndex)); float num4 = (float)(num3 * Variation.FrameDuration) + Variation.OwnerComponent.FrameProgress * (float)Variation.FrameDuration; float t = num4 / num2; return LerpValueUntyped(setTo2, setTo, t, fieldInstance2.OwnerField); } if ((!Variation.Interpolation || (Variation.Interpolation && fieldInstance2 == null)) && fieldInstance3 != null) { return fieldInstance3.SetTo; } if (instanceIndex == -1) { instanceIndex = fieldInstance?.DefinitionIndex ?? 0; } return GetValueAsString(entry, instanceIndex); } public TypedField(bool booleanValue) { CurrentFieldType = FieldType.Boolean; BooleanValue = booleanValue; } public TypedField(float numberValue) { CurrentFieldType = FieldType.Number; NumberValue = numberValue; } public TypedField(string stringValue) { CurrentFieldType = FieldType.String; StringValue = stringValue; } public TypedField(Color colorValue) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) CurrentFieldType = FieldType.Color; ColorValue = colorValue; } } public class FieldInstance { public TypedField OwnerField; public int DefinitionIndex = 0; public int FrameIndex = 0; public int StartPos = 0; public int TotalLength = 0; private string _setTo = null; public string SetTo { get { if (_setTo == null && OwnerField.IsFactory) { return OwnerField.GetValueAsString(entry: true, DefinitionIndex, FrameIndex); } return _setTo; } set { _setTo = value; } } public bool IsSetter => !OwnerField.IsFactory && !OwnerField.IsReferential && _setTo != null; public FieldInstance(TypedField ownerField, int frameIndex, int startPos, int totalLength) { OwnerField = ownerField; FrameIndex = frameIndex; StartPos = startPos; TotalLength = totalLength; DefinitionIndex = ownerField.DefinitionIndex++; } } public static class LinkVerifier { private const string PublicKeyPem = "-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEyDokFop6UARvf5kc4AoF4hVcI75P3eKv/wE9IlFZUcIksso7FBXJgn+vHlHgax3ABkDaf9JFl++kbIVCstE8PA==-----END PUBLIC KEY-----"; public static bool IsApprovedLink(string url, string token) { if (Config.Disclaimer.Value && Config.TrustAllImages.Value) { return true; } try { using ECDsa eCDsa = ECDsa.Create(); eCDsa.ImportFromPem("-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEyDokFop6UARvf5kc4AoF4hVcI75P3eKv/wE9IlFZUcIksso7FBXJgn+vHlHgax3ABkDaf9JFl++kbIVCstE8PA==-----END PUBLIC KEY-----"); byte[] bytes = Encoding.UTF8.GetBytes(url); byte[] signature = Convert.FromBase64String(token); return eCDsa.VerifyData(bytes, signature, HashAlgorithmName.SHA256); } catch { return false; } } public static async Task<(bool approved, byte[]? imageBytes)> VerifyAndFetch(string proxyUrl, string token, HttpClient http) { try { if (!IsApprovedLink(proxyUrl, token)) { return (false, null); } Uri uri = new Uri(proxyUrl); NameValueCollection qs = HttpUtility.ParseQueryString(uri.Query); string expectedChecksum = qs["cs"]; if (string.IsNullOrEmpty(expectedChecksum)) { return (false, null); } string base64 = uri.Segments.Last().Replace('-', '+').Replace('_', '/'); string originalUrl = Encoding.UTF8.GetString(Convert.FromBase64String(base64)); byte[] imageBytes = await http.GetByteArrayAsync(originalUrl); string actualChecksum = Convert.ToHexString(SHA256.HashData(imageBytes)).ToLowerInvariant(); if (actualChecksum != expectedChecksum) { return (false, null); } return (true, imageBytes); } catch { return (false, null); } } } public static class MatchInfoBoard { [HarmonyPatch(typeof(SlabOwnership), "SetOwnership", new Type[] { typeof(Pedestal) })] public static class slabpatch { private static void Postfix() { GameObject plateClone = PlateClone1; if (plateClone != null) { PlayerNameTag componentInChildren = plateClone.GetComponentInChildren(); if (componentInChildren != null) { componentInChildren.UpdatePlayerBPText(); } } GameObject plateClone2 = PlateClone2; if (plateClone2 != null) { PlayerNameTag componentInChildren2 = plateClone2.GetComponentInChildren(); if (componentInChildren2 != null) { componentInChildren2.UpdatePlayerBPText(); } } } } [CompilerGenerated] private sealed class d__10 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private GameObject[] 5__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(5f); <>1__state = 1; return true; case 1: <>1__state = -1; try { 5__1 = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType(true)); matchInfoBoard = ((IEnumerable)5__1).FirstOrDefault((Func)((GameObject go) => ((Object)go).name == "MatchInfoMod")); if ((Object)(object)matchInfoBoard == (Object)null) { return false; } Transform obj = matchInfoBoard.transform.Find("Player1Name"); matchInfoPlayer1Name = ((obj != null) ? ((Component)obj).gameObject : null); Transform obj2 = matchInfoBoard.transform.Find("Player2Name"); matchInfoPlayer2Name = ((obj2 != null) ? ((Component)obj2).gameObject : null); Transform obj3 = matchInfoBoard.transform.Find("Player1BP"); matchInfoPlayer1BP = ((obj3 != null) ? ((Component)obj3).gameObject : null); Transform obj4 = matchInfoBoard.transform.Find("Player2BP"); matchInfoPlayer2BP = ((obj4 != null) ? ((Component)obj4).gameObject : null); HasMatchInfo = true; 5__1 = null; } catch { HasMatchInfo = false; } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__11 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; SetUpMatchInfo(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static GameObject matchInfoBoard; private static GameObject matchInfoPlayer1Name; private static GameObject matchInfoPlayer2Name; private static GameObject matchInfoPlayer1BP; private static GameObject matchInfoPlayer2BP; private static GameObject player1TagClone; private static GameObject player2TagClone; public static bool HasMatchInfo; public static GameObject PlateClone1; public static GameObject PlateClone2; [IteratorStateMachine(typeof(d__10))] public static IEnumerator FindMatchInfoBoard() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0); } [IteratorStateMachine(typeof(d__11))] public static IEnumerator SetUpMatchInfoDelayed(float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__11(0) { delay = delay }; } public static void SetUpMatchInfo() { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) if (Singleton.Instance.AllPlayers.Count >= 2 && HasMatchInfo) { Player obj = Singleton.Instance.AllPlayers[0]; PlayerController val = ((obj != null) ? obj.Controller : null); Player obj2 = Singleton.Instance.AllPlayers[1]; PlayerController val2 = ((obj2 != null) ? obj2.Controller : null); PlateClone1 = Core.Instance.CloneNameplate(((Component)((Component)val).transform.Find("NameTag")).gameObject); PlateClone2 = Core.Instance.CloneNameplate(((Component)((Component)val2).transform.Find("NameTag")).gameObject); PlateClone1.SetActive(true); PlateClone2.SetActive(true); PlateClone1.transform.SetParent(matchInfoBoard.transform); PlateClone1.transform.rotation = matchInfoPlayer2Name.transform.rotation * Quaternion.Euler(0f, 180f, 0f); PlateClone1.transform.localPosition = new Vector3(1.37f, 0.78f, 0f); PlateClone1.transform.localScale = Vector3.one * 2.22f; PlateClone2.transform.SetParent(matchInfoBoard.transform); PlateClone2.transform.rotation = matchInfoPlayer2Name.transform.rotation * Quaternion.Euler(0f, 180f, 0f); PlateClone2.transform.localPosition = new Vector3(-1.37f, 0.78f, 0f); PlateClone2.transform.localScale = Vector3.one * 2.22f; matchInfoPlayer1Name.SetActive(false); matchInfoPlayer2Name.SetActive(false); matchInfoPlayer1BP.SetActive(false); matchInfoPlayer2BP.SetActive(false); } } public static void ResetMatchInfo() { Object.Destroy((Object)(object)PlateClone1); Object.Destroy((Object)(object)PlateClone2); if ((Object)(object)matchInfoBoard == (Object)null) { FindMatchInfoBoard(); } if ((Object)(object)matchInfoBoard != (Object)null) { matchInfoPlayer1Name.SetActive(true); matchInfoPlayer2Name.SetActive(true); matchInfoPlayer1BP.SetActive(true); matchInfoPlayer2BP.SetActive(true); } } public static void SetMatchInfo(bool enabled) { if (!enabled) { ResetMatchInfo(); return; } if ((Object)(object)matchInfoBoard == (Object)null) { FindMatchInfoBoard(); } if ((Object)(object)PlateClone1 == (Object)null || (Object)(object)PlateClone2 == (Object)null) { ResetMatchInfo(); SetUpMatchInfo(); } } } public class Root { [JsonProperty("doRandomVariations")] public bool DoRandomVariations = false; [JsonProperty("variations")] public List Variations; public Core.DesignationType Type; } [Serializable] public class Variation { [JsonIgnore] public NameBend OwnerComponent; [JsonProperty("designationType")] public string DesignationType = "UNKNOWN"; [JsonProperty("weight")] public string Weight = "1"; [JsonProperty("prohibitSaving")] public bool ProhibitSaving = false; [JsonProperty("altText")] public string AltText = ""; [JsonProperty("frameDuration")] public int FrameDuration = 0; [JsonProperty("loopFrames")] public bool LoopFrames = true; [JsonProperty("interpolation")] public bool Interpolation = false; [JsonProperty("loopInterpolation")] public bool LoopInterpolation = true; [JsonProperty("enableFields")] public bool EnableFields = true; [JsonProperty("autoScaling")] public bool AutoScaling = true; [JsonProperty("fields")] private Dictionary fields; [JsonIgnore] public bool FieldInstancesFound = false; [JsonIgnore] private List _typedFields; [JsonProperty("frames")] public Dictionary Frames; [JsonProperty("fonts")] public Dictionary Fonts; [JsonProperty("depths")] public Dictionary Depths; [JsonProperty("images")] public List Images; [JsonIgnore] public Player Owner; [JsonProperty("ownerID")] public string OwnerID => (Owner != null) ? Owner.Data.GeneralData.PlayFabMasterId : "UNKNOWN"; [JsonProperty("ownerAltText")] public string OwnerAltText => (Owner != null) ? Owner.Data.GeneralData.PublicUsername : "UNKNOWN"; [JsonIgnore] public List TypedFields { get { if (_typedFields == null) { GenerateTypedFields(); } return _typedFields; } } [JsonIgnore] public string SerializedJson => JsonConvert.SerializeObject((object)this, (Formatting)0); [JsonIgnore] public string SerializedJsonIndented => JsonConvert.SerializeObject((object)this, (Formatting)1); public void GenerateTypedFields() { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (fields == null) { _typedFields = list; return; } int num = 0; Color colorValue = default(Color); foreach (KeyValuePair field in fields) { string[] array = field.Key.Split('|'); float result; TypedField typedField = ((field.Value == "true") ? new TypedField(booleanValue: true) : ((field.Value == "false") ? new TypedField(booleanValue: false) : (float.TryParse(field.Value, out result) ? new TypedField(result) : ((!ColorUtility.TryParseHtmlString(field.Value, ref colorValue)) ? new TypedField(field.Value) : new TypedField(colorValue))))); typedField.Identifier = array[0]; if (array.Length > 1) { string text = array[1]; if (text == "#") { typedField.CurrentFormatType = TypedField.FormatType.Hex; if (array.Length >= 3 && int.TryParse(array[2], out var result2)) { typedField.HexDigits = result2; } } else if (Regex.IsMatch(text, "\\.0*")) { typedField.CurrentFormatType = TypedField.FormatType.SigFigs; int sigFigs = text.Count((char s) => s == '0'); typedField.SigFigs = sigFigs; } else if (Regex.IsMatch(text, "\\d+")) { typedField.CurrentFormatType = TypedField.FormatType.Round; if (int.TryParse(text, out var result3)) { typedField.Round = result3; } else { typedField.CurrentFormatType = TypedField.FormatType.None; } } } else { typedField.CurrentFormatType = TypedField.FormatType.None; } typedField.OwnerComponent = OwnerComponent; typedField.DefinitionIndex = num; num++; list.Add(typedField); } _typedFields = list; foreach (TypedField typedField2 in _typedFields) { typedField2.IsReferential = typedField2.FindInternalRefs(); } } public void FindAllFieldInstances() { foreach (int key in Frames.Keys) { string input = Frames[key]; MatchCollection matchCollection = Regex.Matches(input, "{([\\da-zA-Z_\\-|.#]+)(=[^}]+)?}"); foreach (Match item in matchCollection) { string value = item.Groups[1].Value; foreach (TypedField typedField in TypedFields) { if (!(value == typedField.Identifier)) { continue; } FieldInstance fieldInstance = new FieldInstance(typedField, key, item.Groups[1].Index - 1, item.Length); fieldInstance.DefinitionIndex = ++typedField.InstanceIndexTracker; if (item.Groups.Count > 2) { string value2 = item.Groups[2].Value; if (value2.Length > 0 && value2.StartsWith('=')) { fieldInstance.SetTo = value2.Substring(1); } } typedField.Instances.Add(fieldInstance); } } } FieldInstancesFound = true; } public TypedField FindField(string identifier) { foreach (TypedField typedField in TypedFields) { if (typedField.Identifier == identifier) { return typedField; } } return null; } public int FindLargestModifier() { int num = 0; Dictionary fonts = Fonts; if (fonts != null && fonts.Count > 0) { foreach (int key in Fonts.Keys) { if (key > num) { num = key; } } } foreach (int key2 in Frames.Keys) { if (key2 > num) { num = key2; } } return num; } public int FindSmallestModifier() { int num = 0; Dictionary fonts = Fonts; if (fonts != null && fonts.Count > 0) { foreach (int key in Fonts.Keys) { if (key < num) { num = key; } } } foreach (int key2 in Frames.Keys) { if (key2 < num) { num = key2; } } return num; } public int FindTotalFrameCount() { return FindLargestModifier() - FindSmallestModifier() + 1; } public int FindPrevModifierOfType(string type, int index) { return FindPrevModifierOfType(type, index, LoopFrames); } public int FindNextModifierOfType(string type, int index) { return FindNextModifierOfType(type, index, LoopFrames); } public int FindPrevModifierOfType(string type, int index, bool isLoop) { Dictionary dictionary; switch (type) { case "frame": dictionary = Frames; break; case "font": dictionary = Fonts; break; case "depth": dictionary = Depths; break; default: return -1; } if (dictionary == null) { return -1; } int num = 0; int num2 = FindTotalFrameCount(); do { if (dictionary.ContainsKey(index)) { return index; } index--; if (index < FindSmallestModifier()) { if (!isLoop) { throw new Exception("No previous modifier found"); } index = FindLargestModifier(); } num++; } while (num <= num2); throw new Exception("No previous modifier found"); } public int FindNextModifierOfType(string type, int index, bool isLoop) { Dictionary dictionary; switch (type) { case "frame": dictionary = Frames; break; case "font": dictionary = Fonts; break; case "depth": dictionary = Depths; break; default: return -1; } if (dictionary == null) { return -1; } int num = 0; int num2 = FindTotalFrameCount(); index++; while (!dictionary.ContainsKey(index)) { index++; if (index > FindLargestModifier()) { if (!isLoop) { throw new Exception("No next modifier found"); } index = FindSmallestModifier(); } num++; if (num > num2) { throw new Exception("No next modifier found"); } } return index; } public void DownloadAllImages() { if (Images == null) { return; } foreach (ImageInfo image in Images) { image.DoLooping = LoopFrames; if (image.DownloadCoroutine != null) { MelonCoroutines.Stop(image.DownloadCoroutine); } image.DownloadCoroutine = MelonCoroutines.Start(image.DownloadImage()); } } public void MarkTitleCounterfeit() { if (DesignationType != "Title") { return; } List list = ((IEnumerable)Singleton.Instance.GetCatalogItemsWithTags((ItemTag)4096)).Where((CatalogItem i) => (int)Singleton.Instance.GetUnlockStatus(i) != 2).ToList(); foreach (KeyValuePair frame in Frames) { string text = HelperFunctions.SanitizeString(HelperFunctions.RemoveInPlaceCharArray(frame.Value)).ToLower(); if (text.Length >= 26) { continue; } foreach (CatalogItem item in list) { bool flag = false; string text2 = item.Title.Split('.')[3]; if (text == text2.ToLower()) { flag = true; } else if (HelperFunctions.LevenshteinDistance(text, text2.ToLower()) < 3) { flag = true; } if (flag) { Frames[frame.Key] += "<#F00>COUNTERFEIT"; Debug.Warning($"Counterfeit detected\nYour title: {frame.Value}\nat frame: {frame.Key}\nhas been marked as counterfeit due to being too similar to a base game title you do not own: {text2}"); } } } } public string GetJsonPropertiesHashCode() { string s = DesignationType + OwnerID + OwnerAltText + Weight + ProhibitSaving + AltText + FrameDuration + LoopFrames + Interpolation + LoopInterpolation + EnableFields + AutoScaling + getFramesString() + getFontsString() + getImagesString(); byte[] bytes = Encoding.UTF8.GetBytes(s); byte[] inArray = SHA256.HashData(bytes); return Convert.ToHexString(inArray).Substring(0, 9); string getFontsString() { string text3 = ""; if (Fonts == null) { return ""; } foreach (KeyValuePair font in Fonts) { text3 += font.Key; text3 += font.Value; } return text3; } string getFramesString() { string text4 = ""; if (Frames == null) { return ""; } foreach (KeyValuePair frame in Frames) { text4 += frame.Key; text4 += frame.Value; } return text4; } string getImagesString() { string text = ""; if (Images == null) { return ""; } foreach (ImageInfo image in Images) { text += image.Link; text += image.Token; text += image.XOffset; text += image.YOffset; text += image.Width; text += image.Height; string text2 = text; float? zDepth = image.ZDepth; text = text2 + zDepth; } return text; } } public double GetWeightFromString() { if (Weight == "") { return 1.0; } if (Weight.ToLower() == "host") { if (PhotonNetwork.InRoom) { return PhotonNetwork.IsMasterClient ? 1 : 0; } return 1.0; } if (Weight.ToLower() == "client") { if (PhotonNetwork.InRoom) { return (!PhotonNetwork.IsMasterClient) ? 1 : 0; } return 0.0; } try { return double.Parse(Weight); } catch { } return 1.0; } public int GetImageInfoIndex(ImageInfo imageInfo) { for (int i = 0; i < Images.Count; i++) { if (Images[i] == imageInfo) { return i; } } return 0; } } [Serializable] public class ImageInfo { [CompilerGenerated] private sealed class d__26 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ImageInfo <>4__this; private Task<(bool approved, byte[]? imageBytes)> 5__1; private bool 5__2; private byte[] 5__3; private List.Enumerator <>s__4; private FrameData 5__5; private Texture2D 5__6; private List 5__7; private List.Enumerator <>s__8; private FrameData 5__9; private List 5__10; private List.Enumerator <>s__11; private FrameData 5__12; private FrameData 5__13; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__26(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__3 = null; <>s__4 = default(List.Enumerator); 5__5 = null; 5__6 = null; 5__7 = null; <>s__8 = default(List.Enumerator); 5__9 = null; 5__10 = null; <>s__11 = default(List.Enumerator); 5__12 = null; 5__13 = null; <>1__state = -2; } private bool MoveNext() { //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; } else { <>1__state = -1; <>4__this.UndownloadImage(); if (Config.DisableMod.Value) { return false; } if (!Config.Images.Value) { return false; } if (Core.Instance.CachedImages.ContainsKey(<>4__this.Link)) { <>4__this.TextureDownloaded = true; 5__10 = Core.Instance.CachedImages[<>4__this.Link]; <>4__this.Frames.Clear(); <>s__11 = 5__10.GetEnumerator(); try { while (<>s__11.MoveNext()) { 5__12 = <>s__11.Current; 5__13 = new FrameData(5__12); if ((Object)(object)5__13.Texture == (Object)null) { 5__13.Texture = new Texture2D(2, 2, (TextureFormat)4, true); } ImageConversion.LoadImage(5__13.Texture, Il2CppStructArray.op_Implicit(5__12.CachedBytes)); <>4__this.Frames.Add(5__13); 5__13 = null; 5__12 = null; } } finally { ((IDisposable)<>s__11).Dispose(); } <>s__11 = default(List.Enumerator); 5__10 = null; goto IL_0526; } 5__1 = LinkVerifier.VerifyAndFetch(<>4__this.Link, <>4__this.Token, Core._http); } if (!5__1.IsCompleted) { <>2__current = null; <>1__state = 1; return true; } 5__2 = 5__1.IsCompletedSuccessfully && 5__1.Result.approved; 5__3 = (5__1.IsCompletedSuccessfully ? 5__1.Result.imageBytes : null); if (!5__2 && !<>4__this.ForceUncensor) { <>4__this.Frames.Add(new FrameData(Core.Instance.CachedCensoredTexture, <>4__this.Frames, dontCache: true)); <>4__this.TextureDownloaded = true; <>4__this.Censored = true; return false; } <>4__this.Censored = false; if (HelperFunctions.IsGif(5__3)) { <>4__this.Frames.AddRange(HelperFunctions.ConvertGifToList(5__3)); <>s__4 = <>4__this.Frames.GetEnumerator(); try { while (<>s__4.MoveNext()) { 5__5 = <>s__4.Current; 5__5.HolderList = <>4__this.Frames; 5__5 = null; } } finally { ((IDisposable)<>s__4).Dispose(); } <>s__4 = default(List.Enumerator); } else { 5__6 = new Texture2D(2, 2, (TextureFormat)4, true); ((Object)5__6).name = <>4__this.Link; ((Texture)5__6).mipMapBias = Config.MipmapBias.Value; if (!ImageConversion.LoadImage(5__6, Il2CppStructArray.op_Implicit(5__3))) { <>4__this.Frames.Add(new FrameData(Core.Instance.CachedFailedTexture, <>4__this.Frames, dontCache: true)); <>4__this.TextureDownloaded = true; return false; } <>4__this.Frames.Add(new FrameData(5__6, <>4__this.Frames)); 5__6 = null; } <>4__this.TextureDownloaded = true; if (!Core.Instance.CachedImages.ContainsKey(<>4__this.Link) && <>4__this.Frames.Count > 0) { 5__7 = new List(); <>s__8 = <>4__this.Frames.GetEnumerator(); try { while (<>s__8.MoveNext()) { 5__9 = <>s__8.Current; 5__7.Add(new FrameData(5__9)); 5__9 = null; } } finally { ((IDisposable)<>s__8).Dispose(); } <>s__8 = default(List.Enumerator); Core.Instance.CachedImages[<>4__this.Link] = 5__7; 5__7 = null; } 5__1 = null; 5__3 = null; goto IL_0526; IL_0526: return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [JsonProperty("link")] public string Link; [JsonProperty("token")] public string Token; [JsonProperty("x")] public float XOffset = 0f; [JsonProperty("y")] public float YOffset = 0f; [JsonProperty("h")] private float? _height = null; [JsonProperty("w")] private float? _width = null; [JsonProperty("z")] public float? ZDepth = null; [JsonIgnore] public List Frames = new List(); [JsonIgnore] public bool DoLooping = true; [JsonIgnore] public bool Censored = true; [JsonIgnore] public bool ForceUncensor = false; [JsonIgnore] public bool TextureDownloaded = false; [JsonIgnore] public object DownloadCoroutine; [JsonIgnore] public float GifDuration => Frames.Last().GetTimestamp() + Frames.Last().Delay; [JsonIgnore] public Texture2D Texture { get { if (Frames.Count == 0) { return Texture2D.whiteTexture; } return Frames[0]?.Texture ?? Texture2D.whiteTexture; } set { Frames.Clear(); Frames.Add(new FrameData(value, Frames, !TextureDownloaded || Censored)); } } [JsonIgnore] public bool IsGIF => Frames.Count > 1; [JsonIgnore] private float aspectRatio { get { if ((Object)(object)Texture == (Object)null) { return 0f; } if (((Texture)Texture).height == 0 || ((Texture)Texture).width == 0) { return 0f; } return ((Texture)Texture).height / ((Texture)Texture).width; } } [JsonIgnore] public float Width { get { if (_width.HasValue) { return _width.Value; } if (_height.HasValue) { return _height.Value / aspectRatio; } return 100f; } } [JsonIgnore] public float Height { get { if (_height.HasValue) { return _height.Value; } if (_width.HasValue) { return _width.Value * aspectRatio; } return 100f; } } [IteratorStateMachine(typeof(d__26))] public IEnumerator DownloadImage() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__26(0) { <>4__this = this }; } public void UndownloadImage() { Frames.Clear(); TextureDownloaded = false; } public ImageInfo GetLoadingGif() { return new ImageInfo { Link = Link, XOffset = XOffset, YOffset = YOffset, _height = Height, _width = Width, TextureDownloaded = true, DoLooping = true, Frames = Core.Instance.CachedLoadingFrames }; } } public class FrameData { public Texture2D Texture; public byte[] CachedBytes; public bool Censcored = false; public int Index = 0; public float Delay = 0.001f; public List HolderList; public float GetTimestamp() { if (HolderList == null) { return 0f; } float num = 0f; for (int i = 0; i < Index; i++) { num += HolderList[i].Delay; } return num; } public FrameData(Texture2D texture, List holderList, bool dontCache = false) { Texture = texture; HolderList = holderList; if (!dontCache) { CachedBytes = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)ImageConversion.EncodeToPNG(texture)); } } public FrameData(Texture2D texture, float delay, bool dontCache = false) { Texture = texture; Delay = delay; if (!dontCache) { CachedBytes = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)ImageConversion.EncodeToPNG(texture)); } } public FrameData(FrameData frameData) { Texture = frameData.Texture; CachedBytes = frameData.CachedBytes; Index = frameData.Index; Delay = frameData.Delay; HolderList = frameData.HolderList; } } }