using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using HarmonyLib;
using Il2Cpp;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using StatEditor;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(StatEditorMod), "StatEditor", "1.0.0", "1Zoker", null)]
[assembly: MelonGame(null, "The Spell Brigade")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace StatEditor;
internal class Row
{
public StatType Type;
public Stat Stat;
public string Key;
public string Label;
public string Display = "";
public int Order;
public float Step = 1f;
public float Max = 100f;
public float Cap = float.NaN;
public float Applied;
public float Target;
public float ChangedAt = -1f;
public MelonPreferences_Entry<float> Entry;
}
public class StatEditorMod : MelonMod
{
internal static Instance Log;
internal static MelonPreferences_Category Cat;
internal static MelonPreferences_Entry<bool> Enabled;
internal static MelonPreferences_Entry<float> XpMultiplier;
internal static MelonPreferences_Entry<float> GoldMultiplier;
internal static MelonPreferences_Entry<bool> KeepBonuses;
internal static MelonPreferences_Entry<string> FontName;
internal static readonly List<PlayerStats> Pending = new List<PlayerStats>();
internal static PlayerStats Local;
internal static readonly List<Row> Rows = new List<Row>();
private static readonly List<Row> MainRows = new List<Row>();
private static readonly List<Row> ExtraRows = new List<Row>();
private static bool xpHookOk;
private static bool goldHookOk;
private static bool statHookOk;
private static bool menuOpen;
private static bool prefsDirty;
private static bool savedCursorVisible;
private static CursorLockMode savedCursorLock;
private static float nextRefresh;
private static int tab;
private const float MultMin = 1f;
private const float MultMax = 10f;
private const float MultStep = 0.5f;
private static readonly KeyValuePair<StatType, string>[] MainStats = new KeyValuePair<StatType, string>[13]
{
new KeyValuePair<StatType, string>((StatType)8, "MAX HEALTH"),
new KeyValuePair<StatType, string>((StatType)16, "HEALTH REGENERATION"),
new KeyValuePair<StatType, string>((StatType)14, "ARMOR"),
new KeyValuePair<StatType, string>((StatType)15, "DODGE"),
new KeyValuePair<StatType, string>((StatType)7, "MOVE SPEED"),
new KeyValuePair<StatType, string>((StatType)0, "DAMAGE"),
new KeyValuePair<StatType, string>((StatType)6, "SPELL SIZE"),
new KeyValuePair<StatType, string>((StatType)2, "CAST SPEED"),
new KeyValuePair<StatType, string>((StatType)12, "CRITICAL CHANCE"),
new KeyValuePair<StatType, string>((StatType)13, "CRITICAL DAMAGE"),
new KeyValuePair<StatType, string>((StatType)11, "MANA PULL"),
new KeyValuePair<StatType, string>((StatType)10, "MANA GAIN"),
new KeyValuePair<StatType, string>((StatType)9, "LUCK")
};
private static readonly StatType[] ExtraOrder;
private const float PanelX = 30f;
private const float PanelY = 30f;
private const float PanelW = 760f;
private const float Pad = 26f;
private const float ColValue = 270f;
private const float ColValueW = 96f;
private const float ColStep = 392f;
private const float ColBonus = 646f;
private static int ExtraRank(Row r)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
int num = Array.IndexOf(ExtraOrder, r.Type);
if (num < 0)
{
return 1000 + r.Label.Length;
}
return num;
}
public override void OnInitializeMelon()
{
Log = ((MelonBase)this).LoggerInstance;
Cat = MelonPreferences.CreateCategory("StatEditor");
Enabled = Cat.CreateEntry<bool>("Enabled", true, (string)null, "Master switch for the whole mod.", false, false, (ValueValidator)null, (string)null);
XpMultiplier = Cat.CreateEntry<float>("XpMultiplier", 1f, (string)null, "Run XP multiplier. 1.0 = vanilla. Solo or host only.", false, false, (ValueValidator)null, (string)null);
GoldMultiplier = Cat.CreateEntry<float>("GoldMultiplier", 1f, (string)null, "End-of-run gold multiplier. 1.0 = vanilla.", false, false, (ValueValidator)null, (string)null);
KeepBonuses = Cat.CreateEntry<bool>("KeepBonusesBetweenRuns", false, (string)null, "true = stat bonuses set in the menu are re-applied at the start of every run. false = every run starts with no bonuses.", false, false, (ValueValidator)null, (string)null);
FontName = Cat.CreateEntry<string>("FontName", "", (string)null, "Menu font. Empty = Noto Sans SC ExtraBold (or another game font if that is missing), 'default' = plain built-in font. F9 in the menu cycles through the choices.", false, false, (ValueValidator)null, (string)null);
xpHookOk = Patch("XP", typeof(PartyLevelManager), "TryAddExperience", "XpPrefix", null);
goldHookOk = Patch("Gold", typeof(RunGoldCalculator), "Calculate", null, "GoldPostfix");
statHookOk = Patch("Stats", typeof(PlayerStats), "Awake", null, "PlayerStatsAwakePostfix");
Log.Msg("Loaded. Press F8 in game to open the menu.");
}
private bool Patch(string label, Type type, string method, string prefix, string postfix)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
try
{
MethodInfo methodInfo = AccessTools.Method(type, method, (Type[])null, (Type[])null);
if (methodInfo == null)
{
throw new Exception("method " + type.Name + "." + method + " not found");
}
((MelonBase)this).HarmonyInstance.Patch((MethodBase)methodInfo, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(Hooks), prefix, (Type[])null), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(Hooks), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
return true;
}
catch (Exception ex)
{
Log.Error(label + " hook failed: " + ex);
return false;
}
}
public override void OnUpdate()
{
try
{
Keyboard current = Keyboard.current;
if (current != null)
{
if (((ButtonControl)current.f8Key).wasPressedThisFrame)
{
ToggleMenu();
}
if (menuOpen && ((ButtonControl)current.f9Key).wasPressedThisFrame)
{
Ui.NextFont();
}
}
}
catch (Exception)
{
}
Ui.PollMouse();
if (menuOpen)
{
try
{
Cursor.visible = true;
Cursor.lockState = (CursorLockMode)0;
}
catch (Exception)
{
}
Ui.UpdateBlocker(show: true);
}
if (!Enabled.Value)
{
return;
}
for (int num = Pending.Count - 1; num >= 0; num--)
{
try
{
PlayerStats val = Pending[num];
if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).WasCollected)
{
Pending.RemoveAt(num);
}
else if (((NetworkBehaviour)val).IsSpawned)
{
Pending.RemoveAt(num);
if (((NetworkBehaviour)val).IsOwner)
{
Local = val;
ClearRows();
}
}
}
catch (Exception ex3)
{
Pending.RemoveAt(num);
Log.Warning("Could not check a player: " + ex3.Message);
}
}
if (!HasRun())
{
if (Rows.Count > 0)
{
ClearRows();
}
return;
}
float unscaledTime = Time.unscaledTime;
if (unscaledTime >= nextRefresh)
{
nextRefresh = unscaledTime + 0.25f;
if (Rows.Count == 0)
{
BuildRows();
}
if (menuOpen)
{
RefreshDisplay();
}
}
for (int i = 0; i < Rows.Count; i++)
{
Row row = Rows[i];
if (row.ChangedAt >= 0f && unscaledTime - row.ChangedAt > 0.2f)
{
row.ChangedAt = -1f;
SetBonus(row, row.Target);
}
}
}
private static void ClearRows()
{
Rows.Clear();
MainRows.Clear();
ExtraRows.Clear();
}
private static bool HasRun()
{
try
{
return (Object)(object)Local != (Object)null && !((Il2CppObjectBase)Local).WasCollected && ((NetworkBehaviour)Local).IsSpawned;
}
catch (Exception)
{
return false;
}
}
private void ToggleMenu()
{
//IL_0043: 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_0023: Unknown result type (might be due to invalid IL or missing references)
menuOpen = !menuOpen;
try
{
if (menuOpen)
{
savedCursorVisible = Cursor.visible;
savedCursorLock = Cursor.lockState;
nextRefresh = 0f;
Ui.OnOpen();
return;
}
Cursor.visible = savedCursorVisible;
Cursor.lockState = savedCursorLock;
Ui.UpdateBlocker(show: false);
Ui.OnClose();
if (prefsDirty)
{
MelonPreferences.Save();
prefsDirty = false;
}
}
catch (Exception)
{
}
}
private static string Pretty(string camel)
{
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < camel.Length; i++)
{
char c = camel[i];
if (i > 0 && char.IsUpper(c) && (char.IsLower(camel[i - 1]) || (i + 1 < camel.Length && char.IsLower(camel[i + 1]))))
{
stringBuilder.Append(' ');
}
stringBuilder.Append(char.ToUpperInvariant(c));
}
return stringBuilder.ToString();
}
private static void BuildRows()
{
//IL_0036: 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_0081: 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)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
try
{
List<Stat> playerStats = Local.GetPlayerStats();
if (playerStats == null)
{
return;
}
for (int i = 0; i < playerStats.Count; i++)
{
Stat val = playerStats[i];
if (val == null)
{
continue;
}
Row row = new Row
{
Stat = val,
Type = val.StatType,
Order = -1
};
row.Key = ((object)Unsafe.As<StatType, StatType>(ref row.Type)/*cast due to .constrained prefix*/).ToString();
row.Label = Pretty(row.Key);
for (int j = 0; j < MainStats.Length; j++)
{
if (MainStats[j].Key == row.Type)
{
row.Order = j;
row.Label = MainStats[j].Value;
}
}
Configure(row);
try
{
Log.Msg(" " + row.Key + ": " + ((object)val.StatCalculationType/*cast due to .constrained prefix*/).ToString() + ", base " + val.BaseValue + ", now " + val.GetValue() + ", step " + row.Step + ", max bonus " + row.Max + (float.IsNaN(row.Cap) ? "" : (", cap " + row.Cap)));
}
catch (Exception)
{
}
row.Entry = Cat.GetEntry<float>(row.Key) ?? Cat.CreateEntry<float>(row.Key, 0f, (string)null, "Bonus added to " + row.Key + " at the start of each run. 0 = off.", false, false, (ValueValidator)null, (string)null);
Rows.Add(row);
if (row.Order >= 0)
{
MainRows.Add(row);
}
else
{
ExtraRows.Add(row);
}
}
MainRows.Sort((Row a, Row b) => a.Order.CompareTo(b.Order));
ExtraRows.Sort((Row a, Row b) => ExtraRank(a).CompareTo(ExtraRank(b)));
for (int num = 0; num < Rows.Count; num++)
{
Row row2 = Rows[num];
if (KeepBonuses.Value)
{
if (row2.Entry.Value > 0f)
{
SetBonus(row2, row2.Entry.Value);
}
}
else if (row2.Entry.Value != 0f)
{
row2.Entry.Value = 0f;
prefsDirty = true;
}
row2.Target = row2.Applied;
if (row2.Applied > row2.Max)
{
row2.Max = row2.Applied;
}
}
RefreshDisplay();
Log.Msg("Run started: " + Rows.Count + " stats found.");
}
catch (Exception ex2)
{
Log.Warning("Could not read stats: " + ex2.Message);
}
}
private static void Configure(Row row)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected I4, but got Unknown
StatType type = row.Type;
switch ((int)type)
{
case 8:
Limits(row, 10f, 10000f);
break;
case 16:
Limits(row, 1f, 500f);
break;
case 14:
Limits(row, 1f, 500f);
break;
case 15:
Limits(row, 1f, 100f, 100f);
break;
case 7:
Limits(row, 5f, 200f);
break;
case 0:
Limits(row, 1f, 100f);
break;
case 6:
Limits(row, 1f, 100f);
break;
case 2:
Limits(row, 1f, 100f);
break;
case 12:
Limits(row, 1f, 100f, 100f);
break;
case 13:
Limits(row, 5f, 500f);
break;
case 11:
Limits(row, 10f, 1000f);
break;
case 10:
Limits(row, 10f, 1000f);
break;
case 9:
Limits(row, 1f, 100f, 100f);
break;
case 17:
case 19:
case 20:
case 39:
case 40:
Limits(row, 1f, 20f);
break;
case 37:
Limits(row, 1f, 50f);
break;
case 18:
case 36:
Limits(row, 10f, 1000f);
break;
case 24:
case 25:
case 27:
case 30:
case 33:
Limits(row, 50f, 5000f);
break;
default:
Limits(row, 1f, 100f);
break;
}
}
private static void Limits(Row row, float step, float max, float cap = float.NaN)
{
row.Step = step;
row.Max = max;
row.Cap = cap;
}
internal static float Snap(float value, float step)
{
return (float)Math.Round(Math.Round(value / step) * (double)step, 4);
}
private static void SetBonus(Row row, float target)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
if (!HasRun())
{
return;
}
try
{
target = Snap(Math.Max(0f, target), row.Step);
float num = target - row.Applied;
if (Math.Abs(num) < 0.0001f)
{
return;
}
float characterValue = Local.GetCharacterValue(row.Type);
Local.AddCharacterImprovement(row.Type, num, (StatModifiersType)0);
row.Applied = target;
if (!float.IsNaN(row.Cap) && num > 0f)
{
int num2 = 0;
while (row.Applied > 0f && num2++ < 500 && Local.GetCharacterValue(row.Type) > row.Cap + 0.001f)
{
float num3 = Math.Min(row.Step, row.Applied);
Local.AddCharacterImprovement(row.Type, 0f - num3, (StatModifiersType)0);
row.Applied = Snap(row.Applied - num3, row.Step);
}
}
row.Target = row.Applied;
float num4 = (KeepBonuses.Value ? row.Applied : 0f);
if (row.Entry.Value != num4)
{
row.Entry.Value = num4;
prefsDirty = true;
}
Log.Msg(row.Key + " bonus " + row.Applied + ": " + characterValue + " -> " + Local.GetCharacterValue(row.Type));
}
catch (Exception ex)
{
row.Target = row.Applied;
Log.Warning(row.Key + " could not be changed: " + ex.Message);
}
}
private static void RefreshDisplay()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < Rows.Count; i++)
{
Row row = Rows[i];
try
{
string text = null;
try
{
text = row.Stat.ToCachedStat().DisplayText;
}
catch (Exception)
{
}
if (string.IsNullOrEmpty(text))
{
text = Local.GetCharacterValue(row.Type).ToString("0.##");
}
row.Display = text;
}
catch (Exception)
{
row.Display = "?";
}
}
}
public override void OnGUI()
{
if (!menuOpen)
{
return;
}
try
{
DrawMenu();
}
catch (Exception ex)
{
menuOpen = false;
Ui.UpdateBlocker(show: false);
Log.Error("Menu error, closing it: " + ex);
}
}
private static void DrawMenu()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0675: Unknown result type (might be due to invalid IL or missing references)
//IL_06bf: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: 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_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_074a: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
//IL_0361: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
//IL_057f: Unknown result type (might be due to invalid IL or missing references)
//IL_0584: Unknown result type (might be due to invalid IL or missing references)
//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
//IL_041d: Unknown result type (might be due to invalid IL or missing references)
//IL_042e: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Unknown result type (might be due to invalid IL or missing references)
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_046b: Expected I4, but got Unknown
//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
//IL_052f: Unknown result type (might be due to invalid IL or missing references)
//IL_0546: Unknown result type (might be due to invalid IL or missing references)
//IL_053f: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Max(0.6f, (float)Screen.height / 1080f);
Matrix4x4 matrix = GUI.matrix;
GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
GUI.depth = -1000;
Ui.Begin();
bool flag = HasRun();
List<Row> list = ((tab == 0) ? MainRows : ExtraRows);
int num2 = (flag ? list.Count : 0);
float num3 = 30f;
float num4 = (float)Screen.height / num - 60f;
if (num2 > 0 && 372f + (float)num2 * num3 > num4)
{
num3 = Mathf.Max(22f, (num4 - 372f) / (float)num2);
}
float num5 = 30f;
float num6 = 30f;
float num7 = 760f;
float num8 = 372f + (float)Mathf.Max(1, num2) * num3;
float num9 = num5 + 26f;
float num10 = num7 - 52f;
Ui.Panel = new Rect(num5, num6, num7, num8);
Ui.Scale = num;
Ui.Frame(Ui.Panel);
Ui.Text(new Rect(num9, num6 + 18f, 400f, 40f), "STAT EDITOR", Ui.Title, Color.white);
Ui.Text(new Rect(num5 + num7 - 26f - 260f, num6 + 16f, 260f, 20f), "F8 CLOSE", Ui.SmallRight, Ui.Dim);
Ui.Text(new Rect(num5 + num7 - 26f - 260f, num6 + 36f, 260f, 20f), "F9 FONT: " + Ui.FontLabel, Ui.SmallRight, Ui.Dim);
float num11 = num6 + 70f;
Ui.Fill(new Rect(num9, num11, num10, 2f), Ui.Line);
num11 += 14f;
bool flag2 = Ui.Check(new Rect(num9, num11, 260f, 24f), "MOD ENABLED", Enabled.Value);
if (flag2 != Enabled.Value)
{
Enabled.Value = flag2;
prefsDirty = true;
}
num11 += 34f;
MultiplierRow(1, num5, num11, "XP MULTIPLIER", XpMultiplier, xpHookOk);
num11 += 32f;
MultiplierRow(2, num5, num11, "GOLD MULTIPLIER", GoldMultiplier, goldHookOk);
num11 += 42f;
float num12 = num10 / 2f - 4f;
if (Ui.Tab(new Rect(num9, num11, num12, 34f), "YOUR STATS", tab == 0))
{
tab = 0;
}
if (Ui.Tab(new Rect(num9 + num12 + 8f, num11, num12, 34f), "ADDITIONAL MODIFIERS", tab == 1))
{
tab = 1;
}
num11 += 34f;
Ui.Fill(new Rect(num9, num11, num10, 2f), Ui.Accent);
num11 += 12f;
if (!statHookOk)
{
Ui.Text(new Rect(num9, num11, num10, num3), "STAT EDITING IS UNAVAILABLE (SEE MELONLOADER/LATEST.LOG)", Ui.Label, Ui.Dim);
num11 += num3;
}
else if (!flag || num2 == 0)
{
Ui.Text(new Rect(num9, num11, num10, num3), "START A RUN TO SEE AND CHANGE YOUR STATS", Ui.Label, Ui.Dim);
num11 += num3;
}
else
{
Rect r = default(Rect);
for (int i = 0; i < list.Count; i++)
{
Row row = list[i];
((Rect)(ref r))..ctor(num9 - 8f, num11, num10 + 16f, num3);
if (((Rect)(ref r)).Contains(Ui.MousePos))
{
Ui.Fill(r, Ui.Hover);
}
float num13 = num11 + (num3 - 24f) / 2f;
Ui.Text(new Rect(num9, num13, 244f, 24f), row.Label, Ui.Label, Color.white);
Ui.Text(new Rect(num5 + 270f, num13, 96f, 24f), row.Display, Ui.Value, Color.white);
float num14 = Ui.Stepper(100 + row.Type, num5 + 392f, num13, row.Target, 0f, row.Max, row.Step);
if (Math.Abs(num14 - row.Target) > 0.0001f)
{
row.Target = num14;
row.ChangedAt = Time.unscaledTime;
}
bool flag3 = row.Target > 0f;
string text = (flag3 ? ("+" + row.Target.ToString((row.Step < 1f) ? "0.00" : "0")) : "+0");
if (!float.IsNaN(row.Cap))
{
text = text + " CAP " + row.Cap.ToString("0");
}
Ui.Text(new Rect(num5 + 646f, num13, num7 - 646f - 26f, 24f), text, Ui.Label, flag3 ? Ui.Accent : Ui.Dim);
num11 += num3;
}
}
num11 += 12f;
Ui.Fill(new Rect(num9, num11, num10, 2f), Ui.Line);
num11 += 14f;
if (Ui.Button(new Rect(num9, num11, 230f, 32f), "RESET STAT BONUSES"))
{
for (int j = 0; j < Rows.Count; j++)
{
Rows[j].Target = 0f;
Rows[j].ChangedAt = 0f;
}
string[] names = Enum.GetNames(typeof(StatType));
foreach (string text2 in names)
{
try
{
MelonPreferences_Entry<float> entry = Cat.GetEntry<float>(text2);
if (entry != null && entry.Value != 0f)
{
entry.Value = 0f;
prefsDirty = true;
}
}
catch (Exception)
{
}
}
}
if (Ui.Button(new Rect(num9 + 242f, num11, 230f, 32f), "RESET MULTIPLIERS"))
{
XpMultiplier.Value = 1f;
GoldMultiplier.Value = 1f;
prefsDirty = true;
}
num11 += 44f;
bool flag4 = Ui.Check(new Rect(num9, num11, num10, 24f), "KEEP STAT BONUSES BETWEEN RUNS", KeepBonuses.Value);
if (flag4 != KeepBonuses.Value)
{
KeepBonuses.Value = flag4;
prefsDirty = true;
for (int l = 0; l < Rows.Count; l++)
{
Rows[l].Entry.Value = (flag4 ? Rows[l].Applied : 0f);
}
}
Ui.End();
GUI.matrix = matrix;
}
private static void MultiplierRow(int id, float x, float y, string name, MelonPreferences_Entry<float> entry, bool hookOk)
{
//IL_0012: 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_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
Ui.Text(new Rect(x + 26f, y, 244f, 24f), name, Ui.Label, Color.white);
if (!hookOk)
{
Ui.Text(new Rect(x + 270f, y, 420f, 24f), "UNAVAILABLE (SEE LATEST.LOG)", Ui.Label, Ui.Dim);
return;
}
float num = Mathf.Clamp(Snap(entry.Value, 0.5f), 1f, 10f);
float num2 = Ui.Stepper(id, x + 392f, y, num, 1f, 10f, 0.5f);
if (Math.Abs(num2 - num) > 0.0001f)
{
entry.Value = num2;
prefsDirty = true;
}
Ui.Text(new Rect(x + 270f, y, 96f, 24f), "x" + entry.Value.ToString("0.0"), Ui.Value, (entry.Value > 1f) ? Ui.Accent : Color.white);
}
public override void OnApplicationQuit()
{
try
{
if (prefsDirty)
{
MelonPreferences.Save();
}
}
catch (Exception)
{
}
}
static StatEditorMod()
{
StatType[] array = new StatType[23];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
ExtraOrder = (StatType[])(object)array;
}
}
internal static class Ui
{
internal static readonly Color Back = new Color(0.086f, 0.082f, 0.106f, 0.97f);
internal static readonly Color FrameOuter = new Color(0.6f, 0.57f, 0.72f, 1f);
internal static readonly Color FrameInner = new Color(0.27f, 0.25f, 0.36f, 1f);
internal static readonly Color Line = new Color(0.25f, 0.23f, 0.33f, 1f);
internal static readonly Color Accent = new Color(0.74f, 0.66f, 1f, 1f);
internal static readonly Color Dim = new Color(0.62f, 0.6f, 0.72f, 1f);
internal static readonly Color Hover = new Color(1f, 1f, 1f, 0.05f);
internal static readonly Color Track = new Color(0.22f, 0.2f, 0.3f, 1f);
internal static readonly Color ButtonBack = new Color(0.17f, 0.16f, 0.23f, 1f);
internal static readonly Color ButtonHover = new Color(0.3f, 0.27f, 0.42f, 1f);
internal static GUIStyle Title;
internal static GUIStyle Label;
internal static GUIStyle Value;
internal static GUIStyle Center;
internal static GUIStyle SmallRight;
internal static Rect Panel;
internal static float Scale = 1f;
internal static Vector2 MousePos;
internal static string FontLabel = "DEFAULT";
private static Texture2D whiteTex;
private static GUIStyle solid;
private static bool click;
private static int activeSlider = -1;
private static bool sawPressed;
private static int evDown;
private static int evUp;
private static int evDrag;
private static int pollPressed;
private static int pollErrors;
private static readonly List<Font> fonts = new List<Font>();
private static int fontIndex = -1;
private static bool fontsLoaded;
private static GameObject blockerRoot;
private static RectTransform blockerRect;
private static bool blockerFailed;
internal static void OnOpen()
{
evDown = (evUp = (evDrag = (pollPressed = (pollErrors = 0))));
activeSlider = -1;
if (!fontsLoaded)
{
LoadFonts();
}
}
internal static void OnClose()
{
activeSlider = -1;
StatEditorMod.Log.Msg("Menu input: " + evDown + " down, " + evUp + " up, " + evDrag + " drag events; button seen held on " + pollPressed + " frames, " + pollErrors + " read errors.");
}
internal static void PollMouse()
{
if (activeSlider == -1)
{
return;
}
try
{
Mouse current = Mouse.current;
if (current != null)
{
if (current.leftButton.isPressed)
{
sawPressed = true;
pollPressed++;
}
else if (sawPressed)
{
activeSlider = -1;
sawPressed = false;
}
}
}
catch (Exception)
{
pollErrors++;
}
}
internal static void Begin()
{
//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_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Invalid comparison between Unknown and I4
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Invalid comparison between Unknown and I4
EnsureStyles();
click = false;
Event current = Event.current;
if (current != null)
{
MousePos = current.mousePosition;
EventType type = current.type;
if ((int)type == 0 && current.button == 0)
{
evDown++;
activeSlider = -1;
click = true;
}
else if ((int)type == 1)
{
evUp++;
activeSlider = -1;
}
else if ((int)type == 3)
{
evDrag++;
}
}
}
internal static void End()
{
//IL_002c: 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_0015: Unknown result type (might be due to invalid IL or missing references)
try
{
Event current = Event.current;
if (current != null && click && ((Rect)(ref Panel)).Contains(MousePos))
{
current.Use();
}
}
catch (Exception)
{
}
GUI.color = Color.white;
GUI.contentColor = Color.white;
}
private static bool Clicked(Rect r)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (click)
{
return ((Rect)(ref r)).Contains(MousePos);
}
return false;
}
private static void EnsureStyles()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0033: 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)
//IL_0051: Expected O, but got Unknown
if (solid == null || (Object)(object)whiteTex == (Object)null)
{
whiteTex = new Texture2D(1, 1);
((Object)whiteTex).hideFlags = (HideFlags)61;
whiteTex.SetPixel(0, 0, Color.white);
whiteTex.Apply();
solid = new GUIStyle();
solid.normal.background = whiteTex;
}
if (Title == null)
{
Title = Make(30, (TextAnchor)3);
Label = Make(16, (TextAnchor)3);
Value = Make(16, (TextAnchor)5);
Center = Make(16, (TextAnchor)4);
SmallRight = Make(12, (TextAnchor)5);
ApplyFont();
}
}
private static GUIStyle Make(int size, TextAnchor anchor)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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_0021: 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_0032: Expected O, but got Unknown
GUIStyle val = new GUIStyle
{
fontSize = size,
fontStyle = (FontStyle)1,
alignment = anchor,
clipping = (TextClipping)0
};
val.normal.textColor = Color.white;
return val;
}
internal static void Fill(Rect r, Color c)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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)
GUI.color = c;
GUI.Box(r, "", solid);
GUI.color = Color.white;
}
internal static void Outline(Rect r, Color c, float t)
{
//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_0041: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, t), c);
Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + ((Rect)(ref r)).height - t, ((Rect)(ref r)).width, t), c);
Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + t, t, ((Rect)(ref r)).height - 2f * t), c);
Fill(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - t, ((Rect)(ref r)).y + t, t, ((Rect)(ref r)).height - 2f * t), c);
}
internal static void Text(Rect r, string text, GUIStyle style, Color c)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
GUI.contentColor = c;
GUI.Label(r, text, style);
GUI.contentColor = Color.white;
}
internal static void Frame(Rect r)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_0054: Unknown result type (might be due to invalid IL or missing references)
Fill(r, Back);
Outline(r, FrameOuter, 4f);
Outline(new Rect(((Rect)(ref r)).x + 8f, ((Rect)(ref r)).y + 8f, ((Rect)(ref r)).width - 16f, ((Rect)(ref r)).height - 16f), FrameInner, 1f);
Corner(((Rect)(ref r)).x - 4f, ((Rect)(ref r)).y - 4f, 16f);
Corner(((Rect)(ref r)).x + ((Rect)(ref r)).width - 16f + 4f, ((Rect)(ref r)).y - 4f, 16f);
Corner(((Rect)(ref r)).x - 4f, ((Rect)(ref r)).y + ((Rect)(ref r)).height - 16f + 4f, 16f);
Corner(((Rect)(ref r)).x + ((Rect)(ref r)).width - 16f + 4f, ((Rect)(ref r)).y + ((Rect)(ref r)).height - 16f + 4f, 16f);
}
private static void Corner(float x, float y, float s)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: 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)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
Fill(new Rect(x, y, s, s), FrameOuter);
Fill(new Rect(x + 3f, y + 3f, s - 6f, s - 6f), Back);
Fill(new Rect(x + 6f, y + 6f, s - 12f, s - 12f), Accent);
}
internal static bool Button(Rect r, string text)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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_0011: 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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_0043: 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)
bool flag = ((Rect)(ref r)).Contains(MousePos);
Fill(r, flag ? ButtonHover : ButtonBack);
Outline(r, flag ? Accent : FrameInner, 2f);
Text(r, text, Center, Color.white);
return Clicked(r);
}
internal static bool Tab(Rect r, string text, bool selected)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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_002c: 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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_0047: Unknown result type (might be due to invalid IL or missing references)
bool flag = ((Rect)(ref r)).Contains(MousePos);
Fill(r, selected ? Accent : (flag ? ButtonHover : ButtonBack));
Text(r, text, Center, selected ? Back : Color.white);
return Clicked(r);
}
internal static bool Check(Rect r, string text, bool value)
{
//IL_0033: 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)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_00c1: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
Rect r2 = default(Rect);
((Rect)(ref r2))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y + (((Rect)(ref r)).height - 20f) / 2f, 20f, 20f);
Fill(r2, ButtonBack);
Outline(r2, ((Rect)(ref r)).Contains(MousePos) ? Accent : FrameOuter, 2f);
if (value)
{
Fill(new Rect(((Rect)(ref r2)).x + 5f, ((Rect)(ref r2)).y + 5f, 10f, 10f), Accent);
}
Text(new Rect(((Rect)(ref r)).x + 30f, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 30f, ((Rect)(ref r)).height), text, Label, Color.white);
if (!Clicked(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, Mathf.Min(((Rect)(ref r)).width, 420f), ((Rect)(ref r)).height)))
{
return value;
}
return !value;
}
private static float Slider(int id, Rect r, float value, float min, float max)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
Rect r2 = default(Rect);
((Rect)(ref r2))..ctor(((Rect)(ref r)).x - 8f, ((Rect)(ref r)).y - 4f, ((Rect)(ref r)).width + 16f, ((Rect)(ref r)).height + 8f);
if (Clicked(r2))
{
activeSlider = id;
sawPressed = false;
}
if (activeSlider == id)
{
float num = Mathf.Clamp01((MousePos.x - ((Rect)(ref r)).x) / ((Rect)(ref r)).width);
value = min + num * (max - min);
}
float num2 = ((max > min) ? Mathf.Clamp01((value - min) / (max - min)) : 0f);
float num3 = ((Rect)(ref r)).y + ((Rect)(ref r)).height / 2f;
bool flag = activeSlider == id || ((Rect)(ref r2)).Contains(MousePos);
Fill(new Rect(((Rect)(ref r)).x, num3 - 3f, ((Rect)(ref r)).width, 6f), Track);
Fill(new Rect(((Rect)(ref r)).x, num3 - 3f, ((Rect)(ref r)).width * num2, 6f), Accent);
float num4 = ((Rect)(ref r)).x + ((Rect)(ref r)).width * num2;
Fill(new Rect(num4 - 6f, num3 - 10f, 12f, 20f), flag ? Color.white : FrameOuter);
Fill(new Rect(num4 - 2f, num3 - 6f, 4f, 12f), Back);
return value;
}
internal static float Stepper(int id, float x, float y, float value, float min, float max, float step)
{
//IL_000c: 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_005f: Unknown result type (might be due to invalid IL or missing references)
if (Button(new Rect(x, y, 26f, 24f), "-"))
{
value -= step;
}
value = Slider(id, new Rect(x + 40f, y + 2f, 160f, 20f), value, min, max);
if (Button(new Rect(x + 214f, y, 26f, 24f), "+"))
{
value += step;
}
return Mathf.Clamp(StatEditorMod.Snap(value, step), min, max);
}
private static void LoadFonts()
{
fontsLoaded = true;
try
{
Il2CppReferenceArray<Object> val = Resources.FindObjectsOfTypeAll(Il2CppType.Of<Font>());
List<string> list = new List<string>();
for (int i = 0; i < ((Il2CppArrayBase<Object>)(object)val).Length; i++)
{
Font val2 = ((((Il2CppArrayBase<Object>)(object)val)[i] == (Object)null) ? null : ((Il2CppObjectBase)((Il2CppArrayBase<Object>)(object)val)[i]).TryCast<Font>());
if ((Object)(object)val2 == (Object)null)
{
continue;
}
bool flag = false;
try
{
flag = val2.dynamic;
}
catch (Exception)
{
}
list.Add(((Object)val2).name + (flag ? "" : " (fixed size, skipped)"));
if (!flag)
{
continue;
}
bool flag2 = false;
for (int j = 0; j < fonts.Count; j++)
{
if (((Object)fonts[j]).name == ((Object)val2).name)
{
flag2 = true;
}
}
if (!flag2)
{
fonts.Add(val2);
}
}
StatEditorMod.Log.Msg("Fonts found: " + ((list.Count == 0) ? "none" : string.Join(", ", list)));
string text = StatEditorMod.FontName.Value ?? "";
fontIndex = -1;
if (text != "default")
{
for (int k = 0; k < fonts.Count; k++)
{
if (fontIndex != -1)
{
break;
}
if (((Object)fonts[k]).name == text)
{
fontIndex = k;
}
}
for (int l = 0; l < fonts.Count; l++)
{
if (fontIndex != -1)
{
break;
}
if (!(text == ""))
{
break;
}
string text2 = ((Object)fonts[l]).name.Replace("-", "").Replace(" ", "").Replace("_", "")
.ToLowerInvariant();
if (text2.Contains("notosanssc") && text2.Contains("extrabold"))
{
fontIndex = l;
}
}
for (int m = 0; m < fonts.Count; m++)
{
if (fontIndex != -1)
{
break;
}
if (!(text == ""))
{
break;
}
string name = ((Object)fonts[m]).name;
if (name.IndexOf("Arial", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("Legacy", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("Liberation", StringComparison.OrdinalIgnoreCase) < 0)
{
fontIndex = m;
}
}
}
ApplyFont();
}
catch (Exception ex2)
{
StatEditorMod.Log.Warning("Could not look up game fonts: " + ex2.Message);
}
}
internal static void NextFont()
{
if (!fontsLoaded)
{
LoadFonts();
}
fontIndex++;
if (fontIndex >= fonts.Count)
{
fontIndex = -1;
}
ApplyFont();
StatEditorMod.FontName.Value = ((fontIndex == -1) ? "default" : ((Object)fonts[fontIndex]).name);
MelonPreferences.Save();
}
private static void ApplyFont()
{
try
{
Font val = ((fontIndex >= 0 && fontIndex < fonts.Count) ? fonts[fontIndex] : null);
if ((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).WasCollected)
{
val = null;
}
FontLabel = (((Object)(object)val == (Object)null) ? "DEFAULT" : ((Object)val).name.ToUpperInvariant());
if (Title != null)
{
Title.font = val;
Label.font = val;
Value.font = val;
Center.font = val;
SmallRight.font = val;
}
}
catch (Exception)
{
}
}
internal static void UpdateBlocker(bool show)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
if (blockerFailed)
{
return;
}
try
{
if ((Object)(object)blockerRoot == (Object)null || ((Il2CppObjectBase)blockerRoot).WasCollected)
{
if (!show)
{
return;
}
blockerRoot = new GameObject("StatEditorClickBlocker");
Object.DontDestroyOnLoad((Object)(object)blockerRoot);
Canvas obj = blockerRoot.AddComponent<Canvas>();
obj.renderMode = (RenderMode)0;
obj.sortingOrder = 32000;
blockerRoot.AddComponent<GraphicRaycaster>();
GameObject val = new GameObject("Area");
val.transform.SetParent(blockerRoot.transform, false);
Image obj2 = val.AddComponent<Image>();
((Graphic)obj2).color = new Color(0f, 0f, 0f, 0f);
((Graphic)obj2).raycastTarget = true;
blockerRect = val.GetComponent<RectTransform>();
}
if (blockerRoot.activeSelf != show)
{
blockerRoot.SetActive(show);
}
if (show && !((Object)(object)blockerRect == (Object)null) && !(((Rect)(ref Panel)).width <= 0f))
{
float num = Screen.width;
float num2 = Screen.height;
float num3 = (((Rect)(ref Panel)).x - 8f) * Scale / num;
float num4 = (((Rect)(ref Panel)).x + ((Rect)(ref Panel)).width + 8f) * Scale / num;
float num5 = 1f - (((Rect)(ref Panel)).y - 8f) * Scale / num2;
float num6 = 1f - (((Rect)(ref Panel)).y + ((Rect)(ref Panel)).height + 8f) * Scale / num2;
blockerRect.anchorMin = new Vector2(Mathf.Clamp01(num3), Mathf.Clamp01(num6));
blockerRect.anchorMax = new Vector2(Mathf.Clamp01(num4), Mathf.Clamp01(num5));
blockerRect.offsetMin = Vector2.zero;
blockerRect.offsetMax = Vector2.zero;
}
}
catch (Exception ex)
{
blockerFailed = true;
StatEditorMod.Log.Warning("Click blocker unavailable, clicks may reach the game behind the menu: " + ex.Message);
}
}
}
internal static class Hooks
{
public static void PlayerStatsAwakePostfix(PlayerStats __instance)
{
StatEditorMod.Pending.Add(__instance);
}
public static void XpPrefix(ref float experience)
{
if (StatEditorMod.Enabled.Value && experience > 0f)
{
experience *= StatEditorMod.XpMultiplier.Value;
}
}
public static void GoldPostfix(EarnedGold __result)
{
try
{
if (__result != null && StatEditorMod.Enabled.Value)
{
float value = StatEditorMod.GoldMultiplier.Value;
if (!(value <= 0f) && !(Math.Abs(value - 1f) < 0.0001f))
{
__result._BaseGold_k__BackingField = Scale(__result._BaseGold_k__BackingField, value);
__result._BonusGoldFromFinalUpgrade_k__BackingField = Scale(__result._BonusGoldFromFinalUpgrade_k__BackingField, value);
__result._BonusGoldFromGoldGainStat_k__BackingField = Scale(__result._BonusGoldFromGoldGainStat_k__BackingField, value);
__result._BonusGoldFromCurses_k__BackingField = Scale(__result._BonusGoldFromCurses_k__BackingField, value);
__result._BonusGoldFromDifficulty_k__BackingField = Scale(__result._BonusGoldFromDifficulty_k__BackingField, value);
__result._BonusGoldFromUnusedCharacter_k__BackingField = Scale(__result._BonusGoldFromUnusedCharacter_k__BackingField, value);
}
}
}
catch (Exception ex)
{
StatEditorMod.Log.Warning("Gold multiplier failed: " + ex.Message);
}
}
private static int Scale(int gold, float m)
{
return (int)Math.Round((double)gold * (double)m);
}
}