using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AnimatedName;
using AnimatedName.Utilities;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using LabFusion.Player;
using LabFusion.Preferences.Client;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyProduct("Animated Name")]
[assembly: AssemblyCopyright("Camobiwon")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: MelonInfo(typeof(Core), "Animated Name", "1.1.0", "Camobiwon", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "LabFusion" })]
[assembly: MelonColor(255, 0, 255, 255)]
[assembly: MelonAuthorColor(255, 0, 100, 255)]
[assembly: RequiresPreviewFeatures]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace AnimatedName
{
public static class BuildInfo
{
public const string Name = "Animated Name";
public const string Author = "Camobiwon";
public const string Version = "1.1.0";
public const string Company = "Camobiwon";
public const string DownloadLink = null;
}
public class Core : MelonMod
{
internal static Core Instance;
internal static MelonPreferences_Category PrefsCategory { get; private set; }
public static Page RootPage { get; private set; }
public static event Action Update;
private Core()
{
Instance = this;
}
public override void OnInitializeMelon()
{
PrefsCategory = MelonPreferences.CreateCategory("Animated Name");
Mod.Initialize();
SavePrefences();
}
public override void OnUpdate()
{
Extensions.InvokeActionSafe(Core.Update);
}
internal static void SavePrefences()
{
PrefsCategory.SaveToFile(false);
}
public static void Log(object message)
{
((MelonBase)Instance).LoggerInstance.Msg(message?.ToString() ?? "null");
}
public static void Log(object message, ConsoleColor color)
{
((MelonBase)Instance).LoggerInstance.Msg(color, message?.ToString() ?? "null");
}
public static void Warn(object message)
{
((MelonBase)Instance).LoggerInstance.Warning(message?.ToString() ?? "null");
}
public static void Error(object message)
{
((MelonBase)Instance).LoggerInstance.Error(message?.ToString() ?? "null");
}
[Conditional("DEBUG")]
internal static void DebugLog(object message)
{
Log(message);
}
[Conditional("DEBUG")]
internal static void DebugWarn(object message)
{
Warn(message);
}
[Conditional("DEBUG")]
internal static void DebugError(object message)
{
Error(message);
}
}
public class Mod
{
public static MelonPreferences_Entry<bool> animationEnabled;
public static MelonPreferences_Entry<float> animationTimer;
public static MelonPreferences_Entry<string[]> animationElements;
private static int animationIndex;
private static float timer;
private static Element previewElement;
private static Element[] menuNameElements;
public static Page Page { get; set; }
public static void Initialize()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
Core.Update += Update;
Page = Page.Root.CreatePage("Animated Name", Color.cyan, 0, true);
animationElements = Core.PrefsCategory.CreateEntry<string[]>("Animated Name Elements", new string[3] { "Your", "Name", "Here" }, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
SetElements(animationElements.Value.Length);
}
private static void BuildMenu()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
previewElement = (Element)(object)Page.CreateFunction("Preview\n" + ClientSettings.Nickname.Value, Color.white, (Action)null);
Page.CreateBoolPref("Animate", Color.white, ref animationEnabled, delegate(bool x)
{
if (x)
{
timer = 0f;
animationIndex = 0;
SetNametag(animationElements.Value[animationIndex]);
}
else
{
SetNametag(ClientSettings.Nickname.Value);
}
}, "Animated Name Enabled");
Page.CreateFloatPref("Timer (s)", Color.white, ref animationTimer, 0.025f, 0.1f, 5f, null, "Animated Name Timer", 0.2f);
NameGenerator.Initialize(Page);
Page.CreateFunction("Paste (CB)", Color.white, (Action)delegate
{
Menu.DisplayDialog("Paste Elements", "This will overwrite all existing elements and paste from the clipboard separated by new lines. Continue?", (Texture2D)null, (Action)delegate
{
if (Clipboard.ContainsText())
{
string[] array = Clipboard.GetText().Split(new string[3] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
SetElements(array.Length);
for (int j = 0; j < array.Length; j++)
{
SetElement(j, array[j]);
}
Core.SavePrefences();
}
}, (Action)null);
});
Page.CreateInt("Elements (CB)", Color.white, animationElements.Value.Length, 1, 1, 1000, (Action<int>)SetElements);
for (int i = 0; i < animationElements.Value.Length; i++)
{
int value = i;
menuNameElements[value] = (Element)(object)Page.CreateFunction($"{value}: {animationElements.Value[value]}", Color.white, (Action)delegate
{
if (Clipboard.ContainsText())
{
SetElement(value, Clipboard.GetText());
Core.SavePrefences();
}
});
}
}
internal static void Update()
{
if (animationEnabled.Value)
{
timer += Time.unscaledDeltaTime;
if (timer > animationTimer.Value)
{
animationIndex = (animationIndex + 1) % animationElements.Value.Length;
SetNametag(animationElements.Value[animationIndex]);
timer = 0f;
}
}
}
private static void SetNametag(string name)
{
PlayerId localId = PlayerIdManager.LocalId;
if (localId != null)
{
localId.Metadata.TrySetMetadata("Nickname", name);
}
previewElement.ElementName = "Preview\n" + name;
}
private static void SetElement(int index, string text)
{
animationElements.Value[index] = text;
menuNameElements[index].ElementName = $"{index}: {animationElements.Value[index]}";
}
private static void SetElements(int elements)
{
string[] array = new string[elements];
for (int i = 0; i < array.Length; i++)
{
if (i < animationElements.Value.Length)
{
array[i] = animationElements.Value[i];
}
if (array[i] == null)
{
array[i] = "Name";
}
}
animationElements.Value = array;
Page.RemoveAll();
Element[] array2 = (Element[])(object)new FunctionElement[elements];
menuNameElements = array2;
BuildMenu();
Menu.OpenPage(Page);
}
}
internal class NameGenerator
{
private enum Direction
{
LeftToRight,
RightToLeft
}
private static string name = string.Empty;
private static Direction direction = Direction.RightToLeft;
internal static void Initialize(Page page)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
Page val = page.CreatePage("Name Generator (CB)", Color.white, 0, true);
StringElement nameElement = null;
nameElement = val.CreateString("Name", Color.white, string.Empty, (Action<string>)delegate(string x)
{
name = x;
nameElement.Value = x;
});
val.CreateEnum("Direction", Color.white, (Enum)direction, (Action<Enum>)delegate(Enum x)
{
direction = (Direction)(object)x;
});
val.CreateFunction("<color=#FF0000>S<color=#FF5A00>c<color=#FFB400>r<color=#EFFF00>o<color=#95FF00>l<color=#3BFF00>l<color=#00FF1E>i<color=#00FF78>n<color=#00FFD2>g <color=#0077FF>R<color=#001DFF>a<color=#3C00FF>i<color=#9500FF>n<color=#F000FF>b<color=#FF00B3>o<color=#FF0059>w</color>", Color.white, (Action)delegate
{
//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_0047: Unknown result type (might be due to invalid IL or missing references)
string[] array = new string[name.Length];
float num = 1f / (float)name.Length;
for (int i = 0; i < name.Length; i++)
{
Color color = Color.HSVToRGB((float)i * num % 1f, 1f, 1f);
array[i] = "<color=#" + ToHtmlStringRGB(color) + ">";
}
Clipboard.SetText(GenerateScrollingName(array));
Notifications.Notify(Notifications.Copied);
});
}
private static string GenerateScrollingName(string[] colorTags)
{
string text = string.Empty;
for (int i = 0; i < colorTags.Length; i++)
{
string text2 = string.Empty;
for (int j = 0; j < colorTags.Length; j++)
{
text2 += $"{colorTags[Mod(j + i * ((direction == Direction.RightToLeft) ? 1 : (-1)), colorTags.Length)]}{name[j]}";
}
text = text + text2 + "</color>";
if (i < name.Length - 1)
{
text += "\n";
}
}
return text;
}
private static int Mod(int num, int mod)
{
return (num % mod + mod) % mod;
}
public static string ToHtmlStringRGB(Color color)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
Color32 val = default(Color32);
((Color32)(ref val))..ctor((byte)Mathf.Clamp(Mathf.RoundToInt(color.r * 255f), 0, 255), (byte)Mathf.Clamp(Mathf.RoundToInt(color.g * 255f), 0, 255), (byte)Mathf.Clamp(Mathf.RoundToInt(color.b * 255f), 0, 255), (byte)1);
return $"{val.r:X2}{val.g:X2}{val.b:X2}";
}
}
}
namespace AnimatedName.Utilities
{
public class Clipboard
{
internal static void SetText(string text)
{
GUIUtility.systemCopyBuffer = text;
}
internal static bool ContainsText()
{
return !string.IsNullOrEmpty(GUIUtility.systemCopyBuffer);
}
internal static string GetText()
{
return GUIUtility.systemCopyBuffer;
}
}
public static class MenuHelper
{
internal static IntElement CreateIntPref(this Page page, string name, Color color, ref MelonPreferences_Entry<int> value, int increment, int minValue, int maxValue, Action<int> callback = null, string prefName = null, int prefDefaultValue = 0)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return page.CreateIntPref(name, color, ref value, Core.PrefsCategory, increment, minValue, maxValue, callback, prefName, prefDefaultValue);
}
internal static FloatElement CreateFloatPref(this Page page, string name, Color color, ref MelonPreferences_Entry<float> value, float increment, float minValue, float maxValue, Action<float> callback = null, string prefName = null, float prefDefaultValue = 0f)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return page.CreateFloatPref(name, color, ref value, Core.PrefsCategory, increment, minValue, maxValue, callback, prefName, prefDefaultValue);
}
internal static BoolElement CreateBoolPref(this Page page, string name, Color color, ref MelonPreferences_Entry<bool> value, Action<bool> callback = null, string prefName = null, bool prefDefaultValue = false)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return page.CreateBoolPref(name, color, ref value, Core.PrefsCategory, callback, prefName, prefDefaultValue);
}
internal static EnumElement CreateEnumPref<T>(this Page page, string name, Color color, ref MelonPreferences_Entry<T> value, Action<Enum> callback = null, string prefName = null, Enum prefDefaultValue = null) where T : Enum
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return page.CreateEnumPref(name, color, ref value, Core.PrefsCategory, callback, prefName, prefDefaultValue);
}
internal static StringElement CreateStringPref(this Page page, string name, Color color, ref MelonPreferences_Entry<string> value, Action<string> callback = null, string prefName = null, string prefDefaultValue = null)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return page.CreateStringPref(name, color, ref value, Core.PrefsCategory, callback, prefName, prefDefaultValue);
}
public static IntElement CreateIntPref(this Page page, string name, Color color, ref MelonPreferences_Entry<int> value, MelonPreferences_Category prefCategory, int increment, int minValue, int maxValue, Action<int> callback = null, string prefName = null, int prefDefaultValue = 0)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
if (prefName == null)
{
prefName = name;
}
if (!prefCategory.HasEntry(prefName))
{
value = prefCategory.CreateEntry<int>(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
MelonPreferences_Entry<int> val = value;
return page.CreateInt(name, color, val.Value, increment, minValue, maxValue, (Action<int>)delegate(int x)
{
val.Value = x;
prefCategory.SaveToFile(false);
Action<int> action = callback;
if (action != null)
{
Extensions.InvokeActionSafe<int>(action, x);
}
});
}
public static FloatElement CreateFloatPref(this Page page, string name, Color color, ref MelonPreferences_Entry<float> value, MelonPreferences_Category prefCategory, float increment, float minValue, float maxValue, Action<float> callback = null, string prefName = null, float prefDefaultValue = 0f)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
if (prefName == null)
{
prefName = name;
}
if (!prefCategory.HasEntry(prefName))
{
value = prefCategory.CreateEntry<float>(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
MelonPreferences_Entry<float> val = value;
return page.CreateFloat(name, color, val.Value, increment, minValue, maxValue, (Action<float>)delegate(float x)
{
val.Value = x;
prefCategory.SaveToFile(false);
Action<float> action = callback;
if (action != null)
{
Extensions.InvokeActionSafe<float>(action, x);
}
});
}
public static BoolElement CreateBoolPref(this Page page, string name, Color color, ref MelonPreferences_Entry<bool> value, MelonPreferences_Category prefCategory, Action<bool> callback = null, string prefName = null, bool prefDefaultValue = false)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
if (prefName == null)
{
prefName = name;
}
if (!prefCategory.HasEntry(prefName))
{
value = prefCategory.CreateEntry<bool>(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
MelonPreferences_Entry<bool> val = value;
return page.CreateBool(name, color, val.Value, (Action<bool>)delegate(bool x)
{
val.Value = x;
prefCategory.SaveToFile(false);
Action<bool> action = callback;
if (action != null)
{
Extensions.InvokeActionSafe<bool>(action, x);
}
});
}
public static EnumElement CreateEnumPref<T>(this Page page, string name, Color color, ref MelonPreferences_Entry<T> value, MelonPreferences_Category prefCategory, Action<Enum> callback = null, string prefName = null, Enum prefDefaultValue = null) where T : Enum
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if (prefName == null)
{
prefName = name;
}
if (!prefCategory.HasEntry(prefName))
{
value = prefCategory.CreateEntry<T>(prefName, (T)prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
MelonPreferences_Entry<T> val = value;
return page.CreateEnum(name, color, (Enum)val.Value, (Action<Enum>)delegate(Enum x)
{
val.Value = (T)x;
prefCategory.SaveToFile(false);
Action<Enum> action = callback;
if (action != null)
{
Extensions.InvokeActionSafe<Enum>(action, x);
}
});
}
public static StringElement CreateStringPref(this Page page, string name, Color color, ref MelonPreferences_Entry<string> value, MelonPreferences_Category prefCategory, Action<string> callback = null, string prefName = null, string prefDefaultValue = null)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
if (prefName == null)
{
prefName = name;
}
if (!prefCategory.HasEntry(prefName))
{
value = prefCategory.CreateEntry<string>(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
MelonPreferences_Entry<string> val = value;
StringElement obj = page.CreateString(name, color, val.Value, (Action<string>)delegate(string x)
{
val.Value = x;
prefCategory.SaveToFile(false);
Action<string> action = callback;
if (action != null)
{
Extensions.InvokeActionSafe<string>(action, x);
}
});
obj.Value = value.Value;
return obj;
}
}
public static class Notifications
{
public static readonly Notification Copied = new Notification
{
Message = NotificationText.op_Implicit("Copied to clipboard!"),
Type = (NotificationType)3
};
public static readonly Notification NotInServer = new Notification
{
Message = NotificationText.op_Implicit("You are not in a server."),
Type = (NotificationType)2
};
public static void Notify(Notification notification)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
NotifyInternal(notification.Message.Text, null, notification.Type, notification.PopupLength);
}
public static void Notify(string message, string title = null, float duration = 2f)
{
NotifyInternal(message, title, (NotificationType)0, duration);
}
public static void NotifyWarning(string message, string title = null, float duration = 2f)
{
NotifyInternal(message, title, (NotificationType)1, duration);
}
public static void NotifyError(string message, string title = null, float duration = 2f)
{
NotifyInternal(message, title, (NotificationType)2, duration);
}
public static void NotifySuccess(string message, string title = null, float duration = 2f)
{
NotifyInternal(message, title, (NotificationType)3, duration);
}
private static void NotifyInternal(string message, string title, NotificationType type, float duration)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
if (title == null)
{
title = "Animated Name";
}
Notifier.Send(new Notification
{
Title = NotificationText.op_Implicit(title),
Message = NotificationText.op_Implicit(message),
Type = type,
ShowTitleOnPopup = true,
PopupLength = duration
});
}
}
}