RUMBLE does not support other mod managers. If you want to use a manager, you must use the RUMBLE Mod Manager, a manager specifically designed for this game.
Decompiled source of NameBending v2.0.0
Mods/NameBending.dll
Decompiled 21 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.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<FrameData> ConvertGifToList(byte[] bytes) { List<FrameData> list = new List<FrameData>(); 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<Color32>.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<Player>)(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<byte[]> list = new List<byte[]>(); 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<byte> list = new List<byte>(); 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<BentImage> BentImages = new List<BentImage>(); 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<PlayerNameTag>(); 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<TextMeshPro>(); 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.<<CheckPlayerProps>g___|0>d))] IEnumerator _() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass37_0.<<CheckPlayerProps>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<TextMeshPro>(); 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<Variation>(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<Variation>(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<Renderer>().material = val2; if (IsScreenSpace) { val.layer = LayerMask.NameToLayer("UI"); } BentImage bentImage = val.AddComponent<BentImage>(); 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<TextMeshProUGUI>(); TextMeshPro component2 = ((Component)this).gameObject.GetComponent<TextMeshPro>(); 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<TextMeshProUGUI>(); TextMeshPro component2 = ((Component)this).gameObject.GetComponent<TextMeshPro>(); 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<BentImage> list = new List<BentImage>(); if ((Object)(object)this == (Object)null || (Object)(object)((Component)this).gameObject == (Object)null) { return; } BentImage[] array = Il2CppArrayBase<BentImage>.op_Implicit(((Component)this).GetComponentsInChildren<BentImage>()); 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<TypedField> typedFields = variation.TypedFields; string text2 = string.Empty; List<FieldInstance> list = new List<FieldInstance>(); 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 <SetTextureWhenAvailable>d__12 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int index; public BentImage <>4__this; private int <tries>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SetTextureWhenAvailable>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; <tries>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 (<tries>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 (<tries>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<Renderer>(); 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(<SetTextureWhenAvailable>d__12))] public IEnumerator SetTextureWhenAvailable(int index) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SetTextureWhenAvailable>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<bool> NameplatePreview; public static MelonPreferences_Entry<string> RefreshHotkey; public static MelonPreferences_Category Cat_SimpleConfig; public static MelonPreferences_Entry<bool> EnableSimpleConfig; public static MelonPreferences_Entry<string> SimpleNameBend; public static MelonPreferences_Entry<string> SimpleTitleBend; public static MelonPreferences_Entry<string> SimpleAltText; public static MelonPreferences_Category Cat_Toggles; public static MelonPreferences_Entry<bool> DisableMod; public static MelonPreferences_Entry<bool> MatchInfoPlates; public static MelonPreferences_Entry<bool> MyAltName; public static MelonPreferences_Entry<bool> MyBentName; public static MelonPreferences_Entry<bool> OtherBentNames; public static MelonPreferences_Entry<bool> MyBentTitle; public static MelonPreferences_Entry<bool> OtherBentTitles; public static MelonPreferences_Entry<bool> Animations; public static MelonPreferences_Entry<bool> Images; public static MelonPreferences_Category Cat_Advanced; public static MelonPreferences_Entry<int> TruncationLength; public static MelonPreferences_Entry<int> FieldDepthLimit; public static MelonPreferences_Entry<int> ForceVariationAt; public static MelonPreferences_Entry<float> MipmapBias; public static MelonPreferences_Entry<bool> SaveNamesToFiles; public static MelonPreferences_Entry<bool> TrustAllImages; public static MelonPreferences_Entry<bool> 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<bool>("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<string>("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<bool>("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. <noparse><#F00></noparse>\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<string>("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<string>("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<string>("SimpleAltText", "", "Alt Text", $"When set, your name will appear like this to others who <b>do not</b> 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<bool>("DisableMod", false, "Disable Mod", "Turn off all name bending", false, false, (ValueValidator)null, (string)null); MatchInfoPlates = Cat_Toggles.CreateEntry<bool>("MatchInfoPlates", true, "MatchInfo Plates", "Show nameplates on the MatchInfo mod board", false, false, (ValueValidator)null, (string)null); MyAltName = Cat_Toggles.CreateEntry<bool>("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<bool>("MyBentName", true, "My Bent Name", "Show your custom name to other people", false, false, (ValueValidator)null, (string)null); OtherBentNames = Cat_Toggles.CreateEntry<bool>("OtherBentNames", true, "Other Bent Names", "Show other people's custom names", false, false, (ValueValidator)null, (string)null); MyBentTitle = Cat_Toggles.CreateEntry<bool>("MyBentTitle", true, "My Bent Title", "Show your custom title to other people", false, false, (ValueValidator)null, (string)null); OtherBentTitles = Cat_Toggles.CreateEntry<bool>("OtherBentTitles", true, "Other Bent Titles", "Show other people's custom titles", false, false, (ValueValidator)null, (string)null); Animations = Cat_Toggles.CreateEntry<bool>("Animations", true, "Animations", "Show animations in custom names and titles", false, false, (ValueValidator)null, (string)null); Images = Cat_Toggles.CreateEntry<bool>("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<int>("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<int>("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<int>("ForceVariationAt", -1, "ForceVariationAt", "Always pick the variation at this index\n-1 to disable", false, false, (ValueValidator)null, (string)null); MipmapBias = Cat_Advanced.CreateEntry<float>("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<bool>("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<bool>("TrustAllImages", false, "<#F00><b>TRUST ALL IMAGES", "<b><#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<bool>("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<KeyCode>(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<NameBend>()) { if (!((Object)(object)componentsInChild != (Object)null) || componentsInChild.IsScreenSpace) { continue; } foreach (BentImage bentImage in componentsInChild.BentImages) { bentImage.SetOpacity(alpha); } } } } [CompilerGenerated] private sealed class <<OnSceneWasLoaded>g___|61_0>d : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Core <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <<OnSceneWasLoaded>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 <<OnSceneWasUnloaded>g__listenForLandButton|59_0>d : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string landType; public Core <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <<OnSceneWasUnloaded>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<InteractionButton>().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 <AddLocalProp>d__72 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string type; public string text; public Core <>4__this; private Player <local>5__1; private int <tries>5__2; private Hashtable <prop>5__3; private string <strToSend>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AddLocalProp>d__72(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <local>5__1 = null; <prop>5__3 = null; <strToSend>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) { <strToSend>5__4 = "NameBending." + type.Substring(0, 1) + "|" + text; Instance.EventRaised = true; <strToSend>5__4 = null; } <local>5__1 = null; <tries>5__2 = 0; break; case 1: <>1__state = -1; <tries>5__2++; break; } while (<local>5__1 == null) { if (<tries>5__2 > 300) { ((MelonBase)<>4__this).LoggerInstance.Error("Failed to get local Photon player"); return false; } PlayerManager instance = Singleton<PlayerManager>.Instance; <local>5__1 = HelperFunctions.FindPhotonPlayerFromRumblePlayer((instance != null) ? instance.LocalPlayer : null); if (<local>5__1 == null) { <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 1; return true; } } <prop>5__3 = new Hashtable(); <prop>5__3[Object.op_Implicit("NameBending." + type)] = Object.op_Implicit(text); <local>5__1.SetCustomProperties(<prop>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 <AddLocalProp>d__73 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string type; public Variation variation; public Core <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AddLocalProp>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 <ApplyComponentsToPlate>d__55 : IEnumerator<object>, 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 <nameTag>5__2; private IEnumerator<TextMeshPro> <>s__3; private TextMeshPro <tmp>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ApplyComponentsToPlate>d__55(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <nameTag>5__2 = null; <>s__3 = null; <tmp>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; <nameTag>5__2 = <>8__1.plate.GetComponent<PlayerNameTag>(); <nameTag>5__2.RefreshNameTag(); <>s__3 = <>8__1.plate.GetComponentsInChildren<TextMeshPro>().GetEnumerator(); try { while (<>s__3.MoveNext()) { <tmp>5__4 = <>s__3.Current; ((TMP_Text)<tmp>5__4).fontStyle = (FontStyles)0; ((TMP_Text)<tmp>5__4).characterSpacing = 0f; <tmp>5__4 = null; } } finally { if (<>s__3 != null) { <>s__3.Dispose(); } } <>s__3 = null; MelonCoroutines.Start(<>8__1.<ApplyComponentsToPlate>g__applyWhenAble|0(DesignationType.Name)); MelonCoroutines.Start(<>8__1.<ApplyComponentsToPlate>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 <OnLandEntered>d__60 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Core <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OnLandEntered>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<PlayerController, string> DesignationsHashes = new Dictionary<PlayerController, string>(); public List<NameBend> NameBends = new List<NameBend>(); public List<BentImage> BentImages = new List<BentImage>(); 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<TMP_FontAsset> CachedFontAssets = new List<TMP_FontAsset>(); public Shader CachedImageShader; public List<FrameData> CachedLoadingFrames; public Texture2D CachedCensoredTexture; public Texture2D CachedLoadingTexture; public Texture2D CachedFailedTexture; public Dictionary<string, List<FrameData>> CachedImages = new Dictionary<string, List<FrameData>>(); public GameObject PlatePreviewCanvas; public static bool IsInMatch => CurrentScene.StartsWith("Map") && ((Il2CppArrayBase<Player>)(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(<ApplyComponentsToPlate>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 <ApplyComponentsToPlate>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<PlayerManager>.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(<<OnSceneWasUnloaded>g__listenForLandButton|59_0>d))] IEnumerator listenForLandButton(string landType) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <<OnSceneWasUnloaded>g__listenForLandButton|59_0>d(0) { <>4__this = this, landType = landType }; } } [IteratorStateMachine(typeof(<OnLandEntered>d__60))] private IEnumerator OnLandEntered() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OnLandEntered>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<PlayerManager>.Instance.LocalPlayer, isPlayer: false, isLocal: true, isUI: false)); } if (buildIndex >= 3) { MelonCoroutines.Start(MatchInfoBoard.SetUpMatchInfoDelayed(1f)); } if (globalInit) { MelonCoroutines.Start(_()); } [IteratorStateMachine(typeof(<<OnSceneWasLoaded>g___|61_0>d))] IEnumerator _() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <<OnSceneWasLoaded>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<PlayerManager>.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<PlayerManager>.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<Root>(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<TMP_FontAsset> list = new List<TMP_FontAsset>(); try { foreach (string item in new List<string> { "Arial", "ChineseRocks", "ComicSans", "Crumble", "GoodDogPlain", "Impact", "Minecraft", "Roboto", "SGA", "TimesNewRoman", "Tumble", "TokiPona", "Avasinistral", "Wingdings", "Papyrus", "Cascadia", "Hollywood", "HighwayGothic" }) { Font val = AssetBundles.LoadA