Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of LevelUpHUD v1.0.1
LevelUpHUD.dll
Decompiled 3 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Il2CppScheduleOne.Levelling; using LevelUpHUD; using LevelUpHUD.GUI; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; 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(Main), "LevelUpHUD", "1.0.1", "DiumStream", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: AssemblyMetadata("NexusModID", "987")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("0.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; } } [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; } } } namespace LevelUpHUD { public class Main : MelonMod { private LevelManager levelManager = null; private LevelUpGUI gui = null; public override void OnInitializeMelon() { Config.Load(); gui = new LevelUpGUI(GetRankText, GetNextText); Config.OnConfigChanged = (Action)Delegate.Combine(Config.OnConfigChanged, new Action(ReloadUI)); } private void ReloadUI() { gui.CreateOrUpdateUI(); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { if (sceneName == "Main") { FindLevelManager(); gui.CreateOrUpdateUI(); } else { levelManager = null; gui.DestroyUI(); } } public override void OnUpdate() { if ((Object)(object)levelManager == (Object)null) { FindLevelManager(); } gui.UpdateUI(); } private void FindLevelManager() { GameObject val = GameObject.Find("Managers"); if ((Object)(object)val != (Object)null) { Transform val2 = val.transform.Find("@LevelManager"); if ((Object)(object)val2 != (Object)null) { levelManager = ((Component)val2).gameObject.GetComponent<LevelManager>(); } } } private string GetRankText() { //IL_0023: 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) if ((Object)(object)levelManager == (Object)null) { return "<i>Loading...</i>"; } ERank rank_k__BackingField = levelManager._Rank_k__BackingField; int hashCode = ((object)(ERank)(ref rank_k__BackingField)).GetHashCode(); int tier_k__BackingField = levelManager._Tier_k__BackingField; string rankName = GetRankName(hashCode, tier_k__BackingField); if (string.IsNullOrEmpty(rankName)) { return ""; } return $"<b>{rankName} {tier_k__BackingField}</b>"; } private string GetNextText() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)levelManager == (Object)null) { return ""; } ERank rank_k__BackingField = levelManager._Rank_k__BackingField; int hashCode = ((object)(ERank)(ref rank_k__BackingField)).GetHashCode(); int tier_k__BackingField = levelManager._Tier_k__BackingField; int xP_k__BackingField = levelManager._XP_k__BackingField; float xPToNextTier = levelManager.XPToNextTier; int num = tier_k__BackingField + 1; int rankIndex = hashCode; if (GetRankName(hashCode, tier_k__BackingField) == "Kingpin") { rankIndex = hashCode; } else if (num > 5) { rankIndex = hashCode + 1; num = 1; } string rankName = GetRankName(rankIndex, num); if (xPToNextTier <= 0f || string.IsNullOrEmpty(rankName)) { return ""; } return $"Next: <b>{rankName} {num}</b> | XP: <b>{xP_k__BackingField} / {(int)xPToNextTier}</b>"; } private string GetRankName(int rankIndex, int tier) { return rankIndex switch { 0 => "Street Rat", 1 => "Hoodlum", 2 => "Peddler", 3 => "Hustler", 4 => "Bagman", 5 => "Enforcer", 6 => "Shot Caller", 7 => "Block Boss", 8 => "Underlord", 9 => "Baron", _ => "Kingpin", }; } } public static class Config { public static MelonPreferences_Category CatMain; public static MelonPreferences_Entry<int> HudPosX; public static MelonPreferences_Entry<int> HudPosY; public static MelonPreferences_Entry<int> RankFontSize; public static MelonPreferences_Entry<int> NextFontSize; public static MelonPreferences_Entry<Color> RankColor; public static MelonPreferences_Entry<Color> NextColor; public static MelonPreferences_Entry<Color> PanelColorTop; public static MelonPreferences_Entry<Color> PanelColorBottom; public static MelonPreferences_Entry<int> PanelWidth; public static MelonPreferences_Entry<int> PanelHeight; public static Action? OnConfigChanged; public static void Load() { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) CatMain = MelonPreferences.CreateCategory("LevelUpHUD_Main", "LevelUpHUD - Display"); HudPosX = CatMain.CreateEntry<int>("HudPosX", 1570, "HUD Position X", "Horizontal position of the HUD (pixels from left)", false, false, (ValueValidator)null, (string)null); HudPosY = CatMain.CreateEntry<int>("HudPosY", 8, "HUD Position Y", "Vertical position of the HUD (pixels from top)", false, false, (ValueValidator)null, (string)null); RankFontSize = CatMain.CreateEntry<int>("RankFontSize", 26, "Rank Text Size", "Font size for the rank text", false, false, (ValueValidator)null, (string)null); NextFontSize = CatMain.CreateEntry<int>("NextFontSize", 18, "Next Rank Text Size", "Font size for the next rank text", false, false, (ValueValidator)null, (string)null); RankColor = CatMain.CreateEntry<Color>("RankColor", new Color(0.95f, 0.95f, 1f, 0.92f), "Rank Text Color", "Color for the rank text", false, false, (ValueValidator)null, (string)null); NextColor = CatMain.CreateEntry<Color>("NextColor", new Color(0.85f, 0.92f, 1f, 0.92f), "Next Rank Text Color", "Color for the next rank text", false, false, (ValueValidator)null, (string)null); PanelColorTop = CatMain.CreateEntry<Color>("PanelColorTop", new Color(0.13f, 0.15f, 0.21f, 0.95f), "Panel Gradient Top", "Top color of the panel gradient", false, false, (ValueValidator)null, (string)null); PanelColorBottom = CatMain.CreateEntry<Color>("PanelColorBottom", new Color(0.08f, 0.09f, 0.13f, 0.95f), "Panel Gradient Bottom", "Bottom color of the panel gradient", false, false, (ValueValidator)null, (string)null); PanelWidth = CatMain.CreateEntry<int>("PanelWidth", 340, "Panel Width", "Width of the HUD panel", false, false, (ValueValidator)null, (string)null); PanelHeight = CatMain.CreateEntry<int>("PanelHeight", 80, "Panel Height", "Height of the HUD panel", false, false, (ValueValidator)null, (string)null); ((MelonEventBase<LemonAction<int, int>>)(object)HudPosX.OnEntryValueChanged).Subscribe((LemonAction<int, int>)delegate { OnConfigChanged?.Invoke(); }, 0, false); ((MelonEventBase<LemonAction<int, int>>)(object)HudPosY.OnEntryValueChanged).Subscribe((LemonAction<int, int>)delegate { OnConfigChanged?.Invoke(); }, 0, false); ((MelonEventBase<LemonAction<int, int>>)(object)RankFontSize.OnEntryValueChanged).Subscribe((LemonAction<int, int>)delegate { OnConfigChanged?.Invoke(); }, 0, false); ((MelonEventBase<LemonAction<int, int>>)(object)NextFontSize.OnEntryValueChanged).Subscribe((LemonAction<int, int>)delegate { OnConfigChanged?.Invoke(); }, 0, false); ((MelonEventBase<LemonAction<Color, Color>>)(object)RankColor.OnEntryValueChanged).Subscribe((LemonAction<Color, Color>)delegate { OnConfigChanged?.Invoke(); }, 0, false); ((MelonEventBase<LemonAction<Color, Color>>)(object)NextColor.OnEntryValueChanged).Subscribe((LemonAction<Color, Color>)delegate { OnConfigChanged?.Invoke(); }, 0, false); ((MelonEventBase<LemonAction<Color, Color>>)(object)PanelColorTop.OnEntryValueChanged).Subscribe((LemonAction<Color, Color>)delegate { OnConfigChanged?.Invoke(); }, 0, false); ((MelonEventBase<LemonAction<Color, Color>>)(object)PanelColorBottom.OnEntryValueChanged).Subscribe((LemonAction<Color, Color>)delegate { OnConfigChanged?.Invoke(); }, 0, false); ((MelonEventBase<LemonAction<int, int>>)(object)PanelWidth.OnEntryValueChanged).Subscribe((LemonAction<int, int>)delegate { OnConfigChanged?.Invoke(); }, 0, false); ((MelonEventBase<LemonAction<int, int>>)(object)PanelHeight.OnEntryValueChanged).Subscribe((LemonAction<int, int>)delegate { OnConfigChanged?.Invoke(); }, 0, false); } } public static class PluginInfo { public const string PLUGIN_AUTHOR = "DiumStream"; public const string PLUGIN_NAME = "LevelUpHUD"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace LevelUpHUD.GUI { public class LevelUpGUI { private GameObject panelObj = null; private GameObject maskObj = null; private RawImage gradientPanel = null; private Text rankText = null; private Text nextText = null; private Texture2D gradientTex = null; private Func<string> getRankText; private Func<string> getNextText; public GameObject hudCanvas { get; private set; } = null; public LevelUpGUI(Func<string> getRankText, Func<string> getNextText) { this.getRankText = getRankText; this.getNextText = getNextText; } public void CreateOrUpdateUI() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Expected O, but got Unknown //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Expected O, but got Unknown //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) DestroyUI(); hudCanvas = new GameObject("LevelUpHUD_Canvas"); Canvas val = hudCanvas.AddComponent<Canvas>(); val.renderMode = (RenderMode)0; hudCanvas.AddComponent<CanvasScaler>(); hudCanvas.AddComponent<GraphicRaycaster>(); panelObj = new GameObject("LevelUpHUD_GradientPanel"); panelObj.transform.SetParent(hudCanvas.transform, false); maskObj = new GameObject("LevelUpHUD_RoundedMask"); maskObj.transform.SetParent(panelObj.transform, false); RectTransform val2 = maskObj.AddComponent<RectTransform>(); val2.anchorMin = new Vector2(0f, 0f); val2.anchorMax = new Vector2(1f, 1f); val2.pivot = new Vector2(0.5f, 0.5f); val2.anchoredPosition = Vector2.zero; val2.sizeDelta = Vector2.zero; Image val3 = maskObj.AddComponent<Image>(); val3.sprite = MakeRoundedSprite(22); val3.type = (Type)1; maskObj.AddComponent<Mask>().showMaskGraphic = false; GameObject val4 = new GameObject("LevelUpHUD_Gradient"); val4.transform.SetParent(maskObj.transform, false); gradientPanel = val4.AddComponent<RawImage>(); gradientTex = MakeVerticalGradient(Config.PanelColorTop.Value, Config.PanelColorBottom.Value, 2, 128); gradientPanel.texture = (Texture)(object)gradientTex; ((Graphic)gradientPanel).color = Color.white; RectTransform component = val4.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = Vector2.zero; component.sizeDelta = Vector2.zero; RectTransform val5 = panelObj.AddComponent<RectTransform>(); val5.anchorMin = new Vector2(0f, 1f); val5.anchorMax = new Vector2(0f, 1f); val5.pivot = new Vector2(0f, 1f); val5.anchoredPosition = new Vector2((float)Config.HudPosX.Value, (float)(-Config.HudPosY.Value)); val5.sizeDelta = new Vector2((float)Config.PanelWidth.Value, (float)Config.PanelHeight.Value); GameObject val6 = new GameObject("LevelUpHUD_RankText"); val6.transform.SetParent(panelObj.transform, false); rankText = val6.AddComponent<Text>(); rankText.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); rankText.fontSize = Config.RankFontSize.Value; rankText.alignment = (TextAnchor)0; ((Graphic)rankText).color = Config.RankColor.Value; rankText.horizontalOverflow = (HorizontalWrapMode)1; rankText.verticalOverflow = (VerticalWrapMode)1; RectTransform component2 = ((Component)rankText).GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 1f); component2.anchorMax = new Vector2(1f, 1f); component2.pivot = new Vector2(0f, 1f); component2.anchoredPosition = new Vector2(16f, -12f); component2.sizeDelta = new Vector2(-32f, 36f); GameObject val7 = new GameObject("LevelUpHUD_NextText"); val7.transform.SetParent(panelObj.transform, false); nextText = val7.AddComponent<Text>(); nextText.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); nextText.fontSize = Config.NextFontSize.Value; nextText.alignment = (TextAnchor)0; ((Graphic)nextText).color = Config.NextColor.Value; nextText.horizontalOverflow = (HorizontalWrapMode)1; nextText.verticalOverflow = (VerticalWrapMode)1; RectTransform component3 = ((Component)nextText).GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 1f); component3.anchorMax = new Vector2(1f, 1f); component3.pivot = new Vector2(0f, 1f); component3.anchoredPosition = new Vector2(16f, -48f); component3.sizeDelta = new Vector2(-32f, 28f); AddShadow(rankText); AddShadow(nextText); UpdateUI(); } public void UpdateUI() { if (!((Object)(object)rankText == (Object)null) && !((Object)(object)nextText == (Object)null)) { rankText.text = getRankText(); nextText.text = getNextText(); } } public void DestroyUI() { if ((Object)(object)hudCanvas != (Object)null) { Object.Destroy((Object)(object)hudCanvas); hudCanvas = null; panelObj = null; maskObj = null; rankText = null; nextText = null; gradientPanel = null; gradientTex = null; } } private Sprite MakeRoundedSprite(int radius) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) int num = radius * 2 + 2; Texture2D val = new Texture2D(num, num, (TextureFormat)5, false); Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0); Color32 val3 = default(Color32); ((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num2 = ((j < radius) ? (radius - j) : (j - (num - radius - 1))); float num3 = ((i < radius) ? (radius - i) : (i - (num - radius - 1))); if (num2 < 0f) { num2 = 0f; } if (num3 < 0f) { num3 = 0f; } float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); val.SetPixel(j, i, Color32.op_Implicit((num4 > (float)radius) ? val2 : val3)); } } val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f, 1u, (SpriteMeshType)0, new Vector4((float)radius, (float)radius, (float)radius, (float)radius)); } private Texture2D MakeVerticalGradient(Color top, Color bottom, int width, int height) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0030: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height, (TextureFormat)5, false); ((Texture)val).wrapMode = (TextureWrapMode)1; for (int i = 0; i < height; i++) { Color val2 = Color.Lerp(top, bottom, (float)i / (float)(height - 1)); for (int j = 0; j < width; j++) { val.SetPixel(j, i, val2); } } val.Apply(); return val; } private void AddShadow(Text text) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Shadow val = ((Component)text).gameObject.AddComponent<Shadow>(); val.effectColor = new Color(0f, 0f, 0f, 0.7f); val.effectDistance = new Vector2(1.5f, -1.5f); } } }