using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Text.RegularExpressions;
using Il2CppExitGames.Client.Photon;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppPhoton.Pun;
using Il2CppPhoton.Realtime;
using Il2CppRUMBLE.Economy;
using Il2CppRUMBLE.Players;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using MelonLoader;
using Microsoft.CodeAnalysis;
using NameBending;
using Newtonsoft.Json;
using RumbleModUI;
using RumbleModdingAPI;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyDescription("Change your name and title to anything you like")]
[assembly: AssemblyCopyright("Created by TacoSlayer36")]
[assembly: AssemblyTrademark(null)]
[assembly: MelonInfo(typeof(NBClass), "NameBending", "1.1.0", "TacoSlayer36", null)]
[assembly: MelonColor]
[assembly: MelonGame(null, null)]
[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")]
[assembly: AssemblyProduct("NameBending")]
[assembly: AssemblyTitle("NameBending")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
public static class StringExt
{
public static string Truncate(this string value, int maxLength)
{
if (maxLength > 0)
{
if (string.IsNullOrEmpty(value))
{
return value;
}
return (value.Length <= maxLength) ? value : value.Substring(0, maxLength);
}
if (maxLength == 0)
{
return "";
}
return value;
}
}
namespace NameBending
{
public static class BuildInfo
{
public const string ModName = "NameBending";
public const string ModVersion = "1.1.0";
public const string Description = "Change your name and title to anything you like";
public const string Author = "TacoSlayer36";
public const string Company = "";
}
public class Variation
{
[JsonProperty("altText")]
public string AltText;
[JsonProperty("frameDuration")]
public int FrameDuration;
[JsonProperty("frames")]
public Dictionary<int, string> Frames;
[JsonProperty("fonts")]
public Dictionary<int, string> Fonts;
}
public class Root
{
[JsonProperty("doRandomVariations")]
public bool DoRandomVariations { get; set; }
[JsonProperty("variations")]
public List<Variation> Variations { get; set; }
}
public class Chunk
{
public int Index { get; set; }
public string Id { get; set; }
public string Data { get; set; }
public int SetSize { get; set; }
}
public class JSON
{
public Variation Variation { get; set; }
public string ID { get; set; }
}
public class NBClass : MelonMod
{
private Mod Mod = new Mod();
private bool showOtherNames = true;
private bool showMyName = true;
private bool showMyAlt = true;
private bool showOtherTitles = true;
private bool showMyTitle = true;
private bool showAnimations = true;
private bool showMatchInfoTags = true;
private int truncationLength = -1;
private int playerCount = 1;
private string sceneName = "Loader";
private int currentNameVariationIndex = 0;
private int currentTitleVariationIndex = 0;
private float timer = 0f;
private const byte nameEventNumber = 30;
private const byte titleEventNumber = 31;
private bool eventInit = false;
private List<Player> playerList;
private List<Player> lastPlayerList;
private List<JSON> allNameJsons = new List<JSON>();
private List<JSON> allTitleJsons = new List<JSON>();
private List<string> chunkyNameJsons = new List<string>();
private List<string> chunkyTitleJsons = new List<string>();
private Regex indexPattern = new Regex("^.{4}§");
private Regex idPattern = new Regex("§[A-Z\\d]+$");
private Regex idPatternFirstChunk = new Regex("}[A-Z\\d]+$");
private static RaiseEventOptions eventOptions = new RaiseEventOptions
{
Receivers = (ReceiverGroup)0
};
private float updateNameCooldown = 0f;
private List<TMP_FontAsset> cachedFontAssets;
private bool hasMatchInfo = false;
private GameObject player1TagClone = null;
private GameObject player2TagClone = null;
public override void OnLateInitializeMelon()
{
((MelonBase)this).OnLateInitializeMelon();
UI.instance.UI_Initialized += OnUIInit;
LoadFonts();
hasMatchInfo = Mods.findOwnMod("MatchInfo", "2.1.2", false);
}
public void OnUIInit()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Expected O, but got Unknown
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Expected O, but got Unknown
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Expected O, but got Unknown
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Expected O, but got Unknown
Mod.ModName = "NameBending";
Mod.ModVersion = "1.1.0";
Mod.SetFolder("NameBending");
Mod.AddDescription("Description", "", "Change your name and title to anything you like", new Tags
{
IsSummary = true
});
Mod.AddToList("Others' Custom Names", true, 0, "See others' custom bent names", new Tags());
Mod.AddToList("My Custom Name", true, 0, "See your custom bent name", new Tags());
Mod.AddToList("My Alt Name", true, 0, "Others will see the name specified under \"altText\" in the settings file when they don't have the mod", new Tags());
Mod.AddToList("Others' Custom Titles", true, 0, "See others' custom bent titles", new Tags());
Mod.AddToList("My Custom Title", true, 0, "Others will see your custom bent title", new Tags());
Mod.AddToList("Animations", true, 0, "Name and title animations will be visible", new Tags());
Mod.AddToList("MatchInfo Tags", true, 0, "Fully customized name tags will show up on the MatchInfo sign", new Tags());
Mod.AddToList("Truncation Length", -1, "Max number of characters to show on names and titles (set to -1 to disable)", new Tags());
Mod.GetFromFile();
Mod.ModSaved += Save;
UI.instance.AddMod(Mod);
MelonLogger.Msg("Added Mod: NameBending");
}
public void Save()
{
showOtherNames = (bool)Mod.Settings[1].SavedValue;
showMyName = (bool)Mod.Settings[2].SavedValue;
showMyAlt = (bool)Mod.Settings[3].SavedValue;
showOtherTitles = (bool)Mod.Settings[4].SavedValue;
showMyTitle = (bool)Mod.Settings[5].SavedValue;
showAnimations = (bool)Mod.Settings[6].SavedValue;
showMatchInfoTags = (bool)Mod.Settings[7].SavedValue;
truncationLength = (int)Mod.Settings[8].SavedValue;
}
public override void OnUpdate()
{
if (updateNameCooldown > 0f)
{
updateNameCooldown -= Time.deltaTime;
}
if (Input.GetKeyDown((KeyCode)110) && sceneName != "Loader")
{
if (updateNameCooldown <= 0f)
{
purgeNonexistentPlayerJsons(allNameJsons, Managers.GetPlayerManager().LocalPlayer);
purgeNonexistentPlayerJsons(allTitleJsons, Managers.GetPlayerManager().LocalPlayer);
updateNameCooldown = 3f;
determineSituation();
}
else
{
MelonLogger.Error("Please wait to update name again");
}
}
}
public override void OnFixedUpdate()
{
if (showAnimations)
{
timer += Time.deltaTime;
}
if (!eventInit)
{
return;
}
insertChunkies();
if (sceneName != "Gym" && sceneName != "Loader")
{
if (Managers.GetPlayerManager().AllPlayers.Count > playerCount)
{
playerList = Managers.GetPlayerManager().AllPlayers;
AnalyzeAndRaise("Name");
AnalyzeAndRaise("Title");
timer = 0f;
}
if (Managers.GetPlayerManager().AllPlayers.Count < playerCount)
{
playerList = Managers.GetPlayerManager().AllPlayers;
List<Player> val = new List<Player>();
if (lastPlayerList != null)
{
Enumerator<Player> enumerator = lastPlayerList.GetEnumerator();
while (enumerator.MoveNext())
{
Player current = enumerator.Current;
if (!playerList.Contains(current))
{
val.Add(current);
}
}
}
Enumerator<Player> enumerator2 = val.GetEnumerator();
while (enumerator2.MoveNext())
{
Player current2 = enumerator2.Current;
purgeNonexistentPlayerJsons(allNameJsons, current2);
purgeNonexistentPlayerJsons(allTitleJsons, current2);
}
}
lastPlayerList = new List<Player>();
if (playerList != null)
{
Enumerator<Player> enumerator3 = playerList.GetEnumerator();
while (enumerator3.MoveNext())
{
Player current3 = enumerator3.Current;
lastPlayerList.Add(current3);
}
}
}
playerCount = Managers.GetPlayerManager().AllPlayers.Count;
if (showOtherNames && allNameJsons != null && allNameJsons.Any())
{
finalize("Name");
}
if (showOtherTitles && allTitleJsons != null && allTitleJsons.Any())
{
finalize("Title");
}
}
private void insertChunkies()
{
if (chunkyNameJsons != null && chunkyNameJsons.Any())
{
string text = dechunkify(chunkyNameJsons);
if (text != null)
{
string text2 = findID(text);
string text3 = text.Substring(0, text.Length - text2.Length);
if (text3.EndsWith('§'))
{
text3 = text3.Substring(0, text3.Length - 1);
}
Variation variation = JsonConvert.DeserializeObject<Variation>(text3);
JSON item = new JSON
{
Variation = variation,
ID = text2
};
List<JSON> list = new List<JSON>();
foreach (JSON allNameJson in allNameJsons)
{
if (allNameJson.ID == text2)
{
list.Add(allNameJson);
}
}
foreach (JSON item3 in list)
{
allNameJsons.Remove(item3);
}
allNameJsons.Add(item);
}
}
if (chunkyTitleJsons == null || !chunkyTitleJsons.Any())
{
return;
}
string text4 = dechunkify(chunkyTitleJsons);
if (text4 == null)
{
return;
}
string text5 = findID(text4);
string text6 = text4.Substring(0, text4.Length - text5.Length);
if (text6.EndsWith('§'))
{
text6 = text6.Substring(0, text6.Length - 1);
}
Variation variation2 = JsonConvert.DeserializeObject<Variation>(text6);
JSON item2 = new JSON
{
Variation = variation2,
ID = text5
};
if (variation2.Frames != null)
{
foreach (int item4 in variation2.Frames.Keys.ToList())
{
if (variation2.Frames[item4].Length <= 80)
{
variation2.Frames[item4] = markCounterfeit(variation2.Frames[item4]);
}
}
}
List<JSON> list2 = new List<JSON>();
foreach (JSON allTitleJson in allTitleJsons)
{
if (allTitleJson.ID == text5)
{
list2.Add(allTitleJson);
}
}
foreach (JSON item5 in list2)
{
allTitleJsons.Remove(item5);
}
allTitleJsons.Add(item2);
}
private string findID(string str)
{
Match match = idPattern.Match(str);
if (match.Success)
{
return match.Value.Substring(1);
}
match = idPatternFirstChunk.Match(str);
if (match.Success)
{
return match.Value.Substring(1);
}
return null;
}
private void finalize(string tagType)
{
List<JSON> list = new List<JSON>();
List<JSON> list2 = new List<JSON>();
if (!(sceneName != "Loader"))
{
return;
}
if (tagType == "Name")
{
list2 = allNameJsons;
}
if (tagType == "Title")
{
list2 = allTitleJsons;
}
foreach (JSON item in list2)
{
try
{
if (item.Variation.Frames != null)
{
changeTagText(item.Variation, item.ID, tagType);
}
}
catch
{
list.Add(item);
}
foreach (JSON item2 in list)
{
list2.Remove(item2);
}
}
}
private void purgeNonexistentPlayerJsons(List<JSON> purgeInJsons, Player player)
{
List<JSON> list = new List<JSON>();
foreach (JSON purgeInJson in purgeInJsons)
{
if (purgeInJson.ID == player.Data.GeneralData.PlayFabMasterId)
{
list.Add(purgeInJson);
}
}
foreach (JSON item in list)
{
purgeInJsons.Remove(item);
}
}
public override void OnSceneWasLoaded(int buildIndex, string name)
{
sceneName = name;
allNameJsons.Clear();
allTitleJsons.Clear();
determineSituation();
insertChunkies();
if (hasMatchInfo && sceneName.Contains("Map"))
{
MelonCoroutines.Start(reactivateMatchInfo());
if (showMatchInfoTags)
{
MelonCoroutines.Start(setUpMatchInfo());
}
}
}
private IEnumerator reactivateMatchInfo()
{
yield return (object)new WaitForSeconds(1f);
GameObject sign = GameObject.Find("MatchInfoMod");
((Component)sign.transform.Find("Player1Name")).gameObject.active = true;
((Component)sign.transform.Find("Player2Name")).gameObject.active = true;
((Component)sign.transform.Find("Player1BP")).gameObject.active = true;
((Component)sign.transform.Find("Player2BP")).gameObject.active = true;
}
private void determineSituation()
{
if (sceneName == "Gym" && !eventInit)
{
MelonCoroutines.Start(WaitThenAddEvent());
eventInit = true;
}
if (sceneName != "Loader")
{
AnalyzeAndRaise("Name");
AnalyzeAndRaise("Title");
}
}
private void AnalyzeAndRaise(string tagType)
{
if ((tagType == "Name" && !showMyName) || (tagType == "Title" && !showMyTitle))
{
return;
}
string empty = string.Empty;
try
{
empty = File.ReadAllText("UserData/NameBending/customBent" + tagType + ".json");
}
catch
{
MelonLogger.Error("Could not find custom name file at \"UserData/NameBending/customBent" + tagType + ".json\"");
return;
}
string playFabMasterId = Managers.GetPlayerManager().LocalPlayer.Data.GeneralData.PlayFabMasterId;
Root root = new Root();
try
{
root = JsonConvert.DeserializeObject<Root>(empty);
}
catch
{
MelonLogger.Error("Failed to deserialize JSON. Make sure it is formatted correctly");
return;
}
string text = "";
int index = 0;
if (root.DoRandomVariations)
{
index = Random.Range(0, root.Variations.Count);
}
else if (tagType == "Name")
{
index = currentNameVariationIndex;
currentNameVariationIndex = (currentNameVariationIndex + 1) % root.Variations.Count;
}
else if (tagType == "Title")
{
index = currentTitleVariationIndex;
currentTitleVariationIndex = (currentTitleVariationIndex + 1) % root.Variations.Count;
}
if (tagType == "Name" && showMyAlt && root.Variations[index].AltText.Length > 0 && root.Variations[index].AltText.Length <= 32)
{
Managers.GetPlayerManager().LocalPlayer.Data.GeneralData.PublicUsername = root.Variations[index].AltText;
}
if (tagType == "Title")
{
foreach (int item in root.Variations[index].Frames.Keys.ToList())
{
if (root.Variations[index].Frames[item].Length <= 80)
{
root.Variations[index].Frames[item] = markCounterfeit(root.Variations[index].Frames[item]);
}
}
}
text = JsonConvert.SerializeObject((object)root.Variations[index], (Formatting)1);
if (sceneName == "Gym" || sceneName.Contains("Map"))
{
List<string> list = chunkify(text, 19900);
if (list != null && list.Any())
{
for (int i = 0; i < list.Count; i++)
{
string text2 = list[i] + "§" + playFabMasterId;
text2 = i.ToString("D2") + list.Count.ToString("D2") + "§" + text2;
if (tagType == "Name")
{
chunkyNameJsons.Add(text2);
}
else
{
chunkyTitleJsons.Add(text2);
}
}
}
else
{
MelonLogger.Error($"Max variation character count exceeded in customBent{tagType}.json ({text.Length} > 500000)");
}
}
else
{
MelonCoroutines.Start(WaitThenRaise(text, playFabMasterId, tagType));
}
}
private IEnumerator WaitThenRaise(string justVariationJson, string myInternalID, string tagType)
{
yield return (object)new WaitForSeconds(2f);
List<string> chunkyJson = chunkify(justVariationJson, 19900);
if (chunkyJson?.Any() ?? false)
{
for (int i = 0; i < chunkyJson.Count; i++)
{
string strToSend = chunkyJson[i];
strToSend = ((chunkyJson.Count != 1) ? string.Concat(str3: strToSend + "§" + myInternalID, str0: i.ToString("D2"), str1: chunkyJson.Count.ToString("D2"), str2: "§") : (strToSend + myInternalID));
byte eventNumber = 30;
if (tagType == "Title")
{
eventNumber = 31;
}
PhotonNetwork.RaiseEvent(eventNumber, Object.op_Implicit(strToSend), eventOptions, SendOptions.SendReliable);
}
}
else
{
MelonLogger.Error($"Max variation character count exceeded in customBent{tagType}.json ({justVariationJson.Length} > 500000)");
}
}
private List<string> chunkify(string str, int chunkSize)
{
List<string> list = new List<string>();
if (str.Length > 500000)
{
return null;
}
for (int i = 0; i < str.Length; i += chunkSize)
{
if (i + chunkSize > str.Length)
{
list.Add(str.Substring(i));
}
else
{
list.Add(str.Substring(i, chunkSize));
}
}
return list;
}
private IEnumerator WaitThenAddEvent()
{
yield return (object)new WaitForSeconds(2f);
LoadBalancingClient networkingClient = PhotonNetwork.NetworkingClient;
networkingClient.EventReceived += Action<EventData>.op_Implicit((Action<EventData>)OnEvent);
}
private IEnumerator setUpMatchInfo()
{
yield return (object)new WaitForSeconds(6.5f);
Player player1 = null;
Player player2 = null;
try
{
player1 = Managers.GetPlayerManager().AllPlayers[1];
}
catch
{
}
try
{
player2 = Managers.GetPlayerManager().AllPlayers[0];
}
catch
{
}
if (player1 != null)
{
GameObject player1Tag = ((Component)((Component)player1.Controller).transform.GetChild(9)).gameObject;
if ((Object)(object)player1Tag != (Object)null)
{
player1TagClone = Object.Instantiate<GameObject>(player1Tag);
player1TagClone.active = true;
player1TagClone.GetComponent<PlayerNameTag>().FadePlayerNameTag(true);
((TMP_Text)((Component)player1TagClone.transform.GetChild(0)).GetComponent<TextMeshPro>()).text = ((TMP_Text)((Component)player1Tag.transform.GetChild(0)).GetComponent<TextMeshPro>()).text;
((TMP_Text)((Component)player1TagClone.transform.GetChild(3)).GetComponent<TextMeshPro>()).text = ((TMP_Text)((Component)player1Tag.transform.GetChild(3)).GetComponent<TextMeshPro>()).text;
}
}
if (player2 != null)
{
GameObject player2Tag = ((Component)((Component)player2.Controller).transform.GetChild(8)).gameObject;
if ((Object)(object)player2Tag != (Object)null)
{
player2Tag.GetComponent<PlayerNameTag>().UpdatePlayerBPText();
player2Tag.GetComponent<PlayerNameTag>().UpdatePlayerNameTagColor();
player2Tag.GetComponent<PlayerNameTag>().UpdatePlayerRankIcon();
player2Tag.GetComponent<PlayerNameTag>().UpdatePlayerTitleText();
player2Tag.GetComponent<PlayerNameTag>().UpdatePlayerNameText();
player2TagClone = Object.Instantiate<GameObject>(player2Tag);
player2TagClone.active = true;
player2TagClone.GetComponent<PlayerNameTag>().FadePlayerNameTag(true);
((TMP_Text)((Component)player2TagClone.transform.GetChild(0)).GetComponent<TextMeshPro>()).text = ((TMP_Text)((Component)player2Tag.transform.GetChild(0)).GetComponent<TextMeshPro>()).text;
((TMP_Text)((Component)player2TagClone.transform.GetChild(3)).GetComponent<TextMeshPro>()).text = ((TMP_Text)((Component)player2Tag.transform.GetChild(3)).GetComponent<TextMeshPro>()).text;
}
}
if (sceneName == "Map0")
{
if ((Object)(object)player1TagClone != (Object)null)
{
player1TagClone.transform.position = new Vector3(-2.51f, 0.27f, 20f);
}
if ((Object)(object)player2TagClone != (Object)null)
{
player2TagClone.transform.position = new Vector3(0.51f, 0.27f, 20f);
}
}
if (sceneName == "Map1")
{
if ((Object)(object)player1TagClone != (Object)null)
{
player1TagClone.transform.position = new Vector3(-1.51f, 6.02f, 11f);
}
if ((Object)(object)player2TagClone != (Object)null)
{
player2TagClone.transform.position = new Vector3(1.51f, 6.02f, 11f);
}
}
if ((Object)(object)player1TagClone != (Object)null)
{
player1TagClone.transform.localScale = new Vector3(2.5f, 2.5f, 2.5f);
player1TagClone.transform.rotation = Quaternion.Euler(0f, 180f, 0f);
}
if ((Object)(object)player2TagClone != (Object)null)
{
player2TagClone.transform.localScale = new Vector3(2.5f, 2.5f, 2.5f);
player2TagClone.transform.rotation = Quaternion.Euler(0f, 180f, 0f);
}
GameObject sign = GameObject.Find("MatchInfoMod");
sign.transform.position = new Vector3(sign.transform.position.x, sign.transform.position.y, sign.transform.position.z - 0.5f);
((Component)sign.transform.Find("Player1Name")).gameObject.active = false;
((Component)sign.transform.Find("Player2Name")).gameObject.active = false;
((Component)sign.transform.Find("Player1BP")).gameObject.active = false;
((Component)sign.transform.Find("Player2BP")).gameObject.active = false;
}
public void OnEvent(EventData photonEvent)
{
if (photonEvent.Code == 30)
{
chunkyNameJsons.Add(photonEvent.CustomData.ToString());
}
if (photonEvent.Code == 31)
{
chunkyTitleJsons.Add(photonEvent.CustomData.ToString());
}
}
private int FindLastFrame(Dictionary<int, string> frames)
{
int num = 0;
foreach (KeyValuePair<int, string> frame in frames)
{
if (frame.Key > num)
{
num = frame.Key;
}
}
if (num > 0)
{
return num;
}
return 1;
}
private void changeTagText(Variation currentVariation, string id, string tagType)
{
try
{
Enumerator<Player> enumerator = Managers.GetPlayerManager().AllPlayers.GetEnumerator();
while (enumerator.MoveNext())
{
Player current = enumerator.Current;
float num = (float)currentVariation.FrameDuration / 1000f;
TMP_FontAsset fontToApply = null;
int num2 = FindLastFrame(currentVariation.Frames);
if (currentVariation.Fonts != null && FindLastFrame(currentVariation.Fonts) > num2)
{
num2 = FindLastFrame(currentVariation.Fonts);
}
int key = (int)(timer / num) % (num2 + 1);
string value = null;
string value2 = null;
currentVariation.Frames.TryGetValue(key, out value);
if (currentVariation.Fonts != null)
{
currentVariation.Fonts.TryGetValue(key, out value2);
}
else
{
value2 = "GoodDogPlain";
}
if (value == null && value2 == null)
{
continue;
}
if (cachedFontAssets != null && value2 != null)
{
foreach (TMP_FontAsset cachedFontAsset in cachedFontAssets)
{
if (((Object)cachedFontAsset).name == value2)
{
fontToApply = cachedFontAsset;
}
}
}
if (current.Data.GeneralData.PlayFabMasterId == id && sceneName != "Gym")
{
TextMeshPro textComponent = null;
if (current != Managers.GetPlayerManager().localPlayer)
{
try
{
if (tagType == "Name")
{
textComponent = ((Component)((Component)current.Controller).gameObject.transform.Find("NameTag").Find("PlayerNameText")).GetComponent<TextMeshPro>();
}
if (tagType == "Title")
{
textComponent = ((Component)((Component)current.Controller).gameObject.transform.Find("NameTag").Find("Player Title Text")).GetComponent<TextMeshPro>();
}
}
catch
{
}
updateTextComponent(textComponent, value, fontToApply);
if (hasMatchInfo && sceneName.Contains("Map"))
{
try
{
if (tagType == "Name")
{
textComponent = ((Component)player1TagClone.transform.Find("PlayerNameText")).GetComponent<TextMeshPro>();
}
if (tagType == "Title")
{
textComponent = ((Component)player1TagClone.transform.Find("Player Title Text")).GetComponent<TextMeshPro>();
}
}
catch
{
}
updateTextComponent(textComponent, value, fontToApply);
}
}
else if (hasMatchInfo && sceneName.Contains("Map"))
{
try
{
if (tagType == "Name")
{
textComponent = ((Component)player2TagClone.transform.Find("PlayerNameText")).GetComponent<TextMeshPro>();
}
if (tagType == "Title")
{
textComponent = ((Component)player2TagClone.transform.Find("Player Title Text")).GetComponent<TextMeshPro>();
}
}
catch
{
}
updateTextComponent(textComponent, value, fontToApply);
}
}
if (sceneName == "Gym")
{
TextMeshPro textComponent2 = null;
if (tagType == "Name")
{
textComponent2 = GameObject.Find("--------------SCENE--------------/Gym_Production/Dressing Room/Preview Player Controller/NameTag/PlayerNameText").GetComponent<TextMeshPro>();
}
if (tagType == "Title")
{
textComponent2 = GameObject.Find("--------------SCENE--------------/Gym_Production/Dressing Room/Preview Player Controller/NameTag/Player Title Text").GetComponent<TextMeshPro>();
}
updateTextComponent(textComponent2, value, fontToApply);
}
}
}
catch
{
}
}
private void updateTextComponent(TextMeshPro textComponent, string value, TMP_FontAsset fontToApply)
{
if ((Object)(object)textComponent != (Object)null)
{
if (value != null && ((TMP_Text)textComponent).text != value.Truncate(truncationLength))
{
((TMP_Text)textComponent).text = value.Truncate(truncationLength);
}
if ((Object)(object)fontToApply != (Object)null && (Object)(object)((TMP_Text)textComponent).font != (Object)(object)fontToApply)
{
((TMP_Text)textComponent).font = fontToApply;
}
}
}
private 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);
}
private 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];
}
private string markCounterfeit(string value)
{
string text = value;
CatalogHandler component = ((Component)Singleton<CatalogHandler>.Instance).GetComponent<CatalogHandler>();
Il2CppReferenceArray<CatalogItem> catalogItemsWithTags = component.GetCatalogItemsWithTags((ItemTag)4096);
foreach (CatalogItem item in (Il2CppArrayBase<CatalogItem>)(object)catalogItemsWithTags)
{
string source = ("Item.Part.Title." + removeInPlaceCharArray(value) + ".Name").ToLower();
string target = item.Title.ToLower();
if (levenshteinDistance(source, target) <= 2)
{
text += "<pos=0><#F00>COUNTERFEIT";
break;
}
}
return text;
}
private string dechunkify(List<string> list)
{
string str = list[0];
string text = findID(str);
List<Chunk> list2 = new List<Chunk>();
List<string> list3 = new List<string>();
HashSet<int> hashSet = new HashSet<int>();
int num = -1;
for (int i = 0; i < list.Count && i <= 26; i++)
{
string text2 = findID(list[i]);
if (!(text == text2))
{
continue;
}
int num2 = 0;
int num3 = 1;
string text3 = list[i].Substring(0, list[i].Length - text2.Length);
if (text3.EndsWith('§'))
{
text3 = text3.Substring(0, text3.Length - 1);
}
if (indexPattern.Match(list[i]).Success)
{
num2 = int.Parse(list[i].Substring(0, 2));
num3 = int.Parse(list[i].Substring(2, 2));
text3 = list[i].Substring(5, list[i].Length - 5 - text2.Length);
if (text3.EndsWith('§'))
{
text3 = text3.Substring(0, text3.Length - 1);
}
}
if (num == -1)
{
num = num3;
}
if (!hashSet.Contains(num2))
{
list2.Add(new Chunk
{
Index = num2,
Id = text2,
Data = text3,
SetSize = num3
});
hashSet.Add(num2);
list3.Add(list[i]);
}
}
if (list2.Count != num)
{
return "{\"frameDuration\":600,\"frames\":{\"0\":\"<align=left>Loading Name.\",\"1\":\"<align=left>Loading Name..\",\"2\":\"<align=left>Loading Name...\"},\"fonts\":{\"0\":\"Arial\"}}" + text;
}
foreach (string item in list3)
{
list.Remove(item);
}
string text4 = string.Empty;
foreach (Chunk item2 in list2.OrderBy((Chunk c) => c.Index).ToList())
{
text4 += item2.Data;
}
return text4 + text;
}
private List<TMP_FontAsset> LoadFonts()
{
if (cachedFontAssets != null)
{
return cachedFontAssets;
}
List<TMP_FontAsset> list = new List<TMP_FontAsset>();
try
{
using (Stream stream = ((MelonBase)this).MelonAssembly.Assembly.GetManifestResourceStream("NameBending.AssetBundles.fonts"))
{
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
Il2CppAssetBundle val = Il2CppAssetBundleManager.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(array));
List<Font> list2 = new List<Font>();
list2.Add(Object.Instantiate<Font>(val.LoadAsset<Font>("Arial.otf")));
list2.Add(Object.Instantiate<Font>(val.LoadAsset<Font>("ChineseRocks.otf")));
list2.Add(Object.Instantiate<Font>(val.LoadAsset<Font>("ComicSans.otf")));
list2.Add(Object.Instantiate<Font>(val.LoadAsset<Font>("Crumble.otf")));
list2.Add(Object.Instantiate<Font>(val.LoadAsset<Font>("GoodDogPlain.otf")));
list2.Add(Object.Instantiate<Font>(val.LoadAsset<Font>("Impact.otf")));
list2.Add(Object.Instantiate<Font>(val.LoadAsset<Font>("Minecraft.otf")));
list2.Add(Object.Instantiate<Font>(val.LoadAsset<Font>("Roboto.otf")));
list2.Add(Object.Instantiate<Font>(val.LoadAsset<Font>("SGA.otf")));
list2.Add(Object.Instantiate<Font>(val.LoadAsset<Font>("TimesNewRoman.otf")));
list2.Add(Object.Instantiate<Font>(val.LoadAsset<Font>("Tumble.otf")));
foreach (Font item in list2)
{
TMP_FontAsset val2 = TMP_FontAsset.CreateFontAsset(item);
((Object)val2).hideFlags = (HideFlags)61;
list.Add(val2);
}
((Object)list[0]).name = "Arial";
((Object)list[1]).name = "ChineseRocks";
((Object)list[2]).name = "ComicSans";
((Object)list[3]).name = "Crumble";
((Object)list[4]).name = "GoodDogPlain";
((Object)list[5]).name = "Impact";
((Object)list[6]).name = "Minecraft";
((Object)list[7]).name = "Roboto";
((Object)list[8]).name = "SGA";
((Object)list[9]).name = "TimesNewRoman";
((Object)list[10]).name = "Tumble";
}
cachedFontAssets = list;
}
catch (Exception ex)
{
MelonLogger.Error("Error loading fonts: " + ex.Message);
}
return list;
}
}
}