using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BrigadeModMenu;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using StatusEffects;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(StatusEffectsMod), "Status Effects", "1.1.0", "Status Effects", null)]
[assembly: MelonGame("BoltBlasterGames", "TheSpellBrigade")]
[assembly: MelonOptionalDependencies(new string[] { "BrigadeModMenu" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("StatusEffects")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("StatusEffects")]
[assembly: AssemblyTitle("StatusEffects")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 BrigadeModMenu
{
public static class ModMenuCompat
{
public static Page Entry(this Page page, MelonPreferences_Entry entry, Func<string> label = null)
{
if (entry != null)
{
return page.Entry(entry.Raw, label ?? ((Func<string>)(() => entry.DisplayName)));
}
return page;
}
public static Page Category(this Page page, MelonPreferences_Category category)
{
if (category == null)
{
return page;
}
Menu.HideCategory(category.Identifier);
foreach (MelonPreferences_Entry e in category.Entries)
{
if (e != null && !e.IsHidden)
{
page.Entry(e.Raw, (Func<string>)(() => e.DisplayName));
}
}
return page;
}
}
}
namespace StatusEffects
{
internal static class MenuPage
{
private const string Indent = " ";
private static StatusRow _spellsRow;
private static StatusRow _wizardRow;
private static readonly HudElement SpellsElement = new HudElement
{
Name = "Status Effects: Spell Bar Badges",
Build = delegate(RectTransform parent)
{
if (!StatusEffectsMod.AboveSpells.Value)
{
return (RectTransform)null;
}
_spellsRow = new StatusRow("StatusEffectsPreview_Spells", Layer(parent), full: true);
return _spellsRow.Root;
},
Place = delegate
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
if (_spellsRow != null)
{
_spellsRow.Show(StatusEffectsMod.Samples());
_spellsRow.SetScale(1.4f * StatusEffectsMod.SpellsSize.Value);
_spellsRow.SetGap(StatusEffectsMod.SpellsSpacing.Value);
Transform parent = ((Transform)_spellsRow.Root).parent;
Vector2? val = SpellsTop((parent != null) ? ((Il2CppObjectBase)parent).TryCast<RectTransform>() : null);
_spellsRow.SetVisible(val.HasValue);
if (val.HasValue)
{
_spellsRow.Place(val.Value + new Vector2(StatusEffectsMod.SpellsOffsetX.Value, StatusEffectsMod.SpellsHeight.Value));
}
}
},
Live = () => StatusEffectsMod.LiveRow(spells: true),
GetOffset = () => new Vector2(StatusEffectsMod.SpellsOffsetX.Value, StatusEffectsMod.SpellsHeight.Value),
SetOffset = delegate(Vector2 v)
{
//IL_0005: 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)
StatusEffectsMod.SpellsOffsetX.Value = Mathf.Clamp(Mathf.Round(v.x), -4000f, 4000f);
StatusEffectsMod.SpellsHeight.Value = Mathf.Clamp(Mathf.Round(v.y), -1100f, 2100f);
},
GetSize = () => StatusEffectsMod.SpellsSize.Value,
SetSize = delegate(float s)
{
StatusEffectsMod.SpellsSize.Value = s;
},
Reset = delegate
{
StatusEffectsMod.SpellsHeight.Value = StatusEffectsMod.SpellsHeight.DefaultValue;
StatusEffectsMod.SpellsOffsetX.Value = StatusEffectsMod.SpellsOffsetX.DefaultValue;
StatusEffectsMod.SpellsSize.Value = StatusEffectsMod.SpellsSize.DefaultValue;
}
};
private static readonly HudElement WizardElement;
private const string ProjectionKey = "StatusEffects.WizardProjection";
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void Register()
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
HudEditor.Register(SpellsElement);
HudEditor.Register(WizardElement);
Menu.AddPage("StatusEffects", "Status Effects").Entry(StatusEffectsMod.Preview, () => "Preview Badges").Note((Func<string>)(() => "Shows sample badges during a mission so you can line them up. Changing any setting below also shows them for a few seconds."))
.Buttons((MenuButton[])(object)new MenuButton[1]
{
new MenuButton("Edit Position & Size", (Action)delegate
{
HudEditor.Open((StatusEffectsMod.AboveSpells.Value || !StatusEffectsMod.AboveWizard.Value) ? SpellsElement : WizardElement);
}, false)
})
.Entry(StatusEffectsMod.AboveSpells, () => "Show Spell Bar Badges")
.Entry(StatusEffectsMod.SpellsSize, () => " Size")
.Entry(StatusEffectsMod.SpellsOffsetX, () => " Move Left / Right")
.Entry(StatusEffectsMod.SpellsHeight, () => " Move Up / Down")
.Entry(StatusEffectsMod.SpellsSpacing, () => " Spacing")
.Entry(StatusEffectsMod.AboveWizard, () => "Show Wizard Badges")
.Entry(StatusEffectsMod.WizardSize, () => " Size")
.Entry(StatusEffectsMod.WizardHeight, () => " Height (Below, Over, Above)")
.Entry(StatusEffectsMod.WizardSpacing, () => " Spacing");
}
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void SaveProjection(float[] values)
{
HudEditor.Measure("StatusEffects.WizardProjection", values);
}
private static bool Projection(out Vector2 feet, out float[] heights)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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)
float[] array = StatusEffectsMod.LiveProjection() ?? HudEditor.Measured("StatusEffects.WizardProjection");
feet = default(Vector2);
heights = null;
if (array == null || array.Length != 113)
{
return false;
}
feet = new Vector2(array[0], array[1]);
heights = new float[111];
Array.Copy(array, 2, heights, 0, heights.Length);
return true;
}
private static float HeightToY(float[] heights, float height)
{
float num = Mathf.Clamp((height - -3f) / 0.1f, 0f, (float)(heights.Length - 1));
int num2 = Mathf.FloorToInt(num);
int num3 = Mathf.Min(num2 + 1, heights.Length - 1);
return Mathf.Lerp(heights[num2], heights[num3], num - (float)num2);
}
private static float YToHeight(float[] heights, float y)
{
int num = 0;
for (int i = 1; i < heights.Length; i++)
{
if (Mathf.Abs(heights[i] - y) < Mathf.Abs(heights[num] - y))
{
num = i;
}
}
return Mathf.Round((-3f + (float)num * 0.1f) * 10f) / 10f;
}
private static RectTransform Layer(RectTransform parent)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_0038: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
RectTransform obj = Ui.Rect("StatusEffectsPreview", (Transform)(object)parent);
obj.anchorMin = Vector2.zero;
obj.anchorMax = Vector2.one;
obj.pivot = new Vector2(0.5f, 0.5f);
Vector2 offsetMin = (obj.offsetMax = Vector2.zero);
obj.offsetMin = offsetMin;
return obj;
}
private static Vector2? SpellsTop(RectTransform layer)
{
//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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_0052: 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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_0077: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = HudEditor.Recorded("SpellSlotsDisplay_Panel/Layout_4Slots");
if ((Object)(object)layer == (Object)null || (Object)(object)val == (Object)null)
{
return null;
}
Il2CppStructArray<Vector3> val2 = new Il2CppStructArray<Vector3>(4L);
val.GetWorldCorners(val2);
Vector3 val3 = ((Transform)layer).InverseTransformPoint(((Il2CppArrayBase<Vector3>)(object)val2)[1]);
Vector3 val4 = ((Transform)layer).InverseTransformPoint(((Il2CppArrayBase<Vector3>)(object)val2)[2]);
return new Vector2((val3.x + val4.x) / 2f, Mathf.Max(val3.y, val4.y));
}
static MenuPage()
{
//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_0010: 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_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Expected O, but got Unknown
Vector2 feet;
float[] heights;
WizardElement = new HudElement
{
Name = "Status Effects: Wizard Badges",
Build = delegate(RectTransform parent)
{
if (!StatusEffectsMod.AboveWizard.Value)
{
return (RectTransform)null;
}
_wizardRow = new StatusRow("StatusEffectsPreview_Wizard", Layer(parent), full: false);
return _wizardRow.Root;
},
Place = delegate
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
if (_wizardRow != null)
{
_wizardRow.Show(StatusEffectsMod.Samples());
_wizardRow.SetScale(1.4f * StatusEffectsMod.WizardSize.Value);
_wizardRow.SetGap(StatusEffectsMod.WizardSpacing.Value);
bool flag = Projection(out feet, out heights);
_wizardRow.SetVisible(flag);
if (flag)
{
_wizardRow.Place(new Vector2(feet.x, HeightToY(heights, StatusEffectsMod.WizardHeight.Value)));
}
}
},
Live = () => StatusEffectsMod.LiveRow(spells: false),
GetOffset = () => (Vector2)((!Projection(out feet, out heights)) ? Vector2.zero : new Vector2(0f, HeightToY(heights, StatusEffectsMod.WizardHeight.Value))),
SetOffset = delegate(Vector2 v)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (Projection(out feet, out heights))
{
StatusEffectsMod.WizardHeight.Value = YToHeight(heights, v.y);
}
},
GetSize = () => StatusEffectsMod.WizardSize.Value,
SetSize = delegate(float s)
{
StatusEffectsMod.WizardSize.Value = s;
},
Reset = delegate
{
StatusEffectsMod.WizardHeight.Value = StatusEffectsMod.WizardHeight.DefaultValue;
StatusEffectsMod.WizardSize.Value = StatusEffectsMod.WizardSize.DefaultValue;
}
};
}
}
public class StatusEffectsMod : MelonMod
{
internal static MelonLogger.Instance Log;
internal static MelonPreferences_Entry<bool> AboveSpells;
internal static MelonPreferences_Entry<bool> AboveWizard;
internal static MelonPreferences_Entry<float> SpellsSize;
internal static MelonPreferences_Entry<float> WizardSize;
internal static MelonPreferences_Entry<float> SpellsHeight;
internal static MelonPreferences_Entry<float> SpellsOffsetX;
internal static MelonPreferences_Entry<float> WizardHeight;
internal static MelonPreferences_Entry<float> SpellsSpacing;
internal static MelonPreferences_Entry<float> WizardSpacing;
private static bool _hasMenu;
private static StatusEffectsMod _instance;
internal static MelonPreferences_Entry<bool> Preview;
private const float PreviewSeconds = 6f;
private static float _previewUntil;
internal const float BaseScale = 1.4f;
private RectTransform _container;
private Canvas _hudCanvas;
private GameObject _fallbackCanvas;
private StatusRow _spellsRow;
private StatusRow _wizardRow;
private SpellSlotsDisplay _spells;
private float _nextSpellSearch;
private float _retryAt;
private string _lastError;
private string _lastSummary = "";
internal const float ProjectionMin = -3f;
internal const float ProjectionMax = 8f;
internal const float ProjectionStep = 0.1f;
internal const int ProjectionCount = 111;
private IntPtr _measuredFor;
private float _measureAfter;
private float _stillSince;
private Vector3 _lastFeet;
private Vector3 _lastCam;
internal static RectTransform LiveRow(bool spells)
{
StatusEffectsMod instance = _instance;
if (instance == null || (Object)(object)instance._hudCanvas == (Object)null || !(spells ? AboveSpells.Value : AboveWizard.Value))
{
return null;
}
_previewUntil = Mathf.Max(_previewUntil, Time.unscaledTime + 0.3f);
instance.Tick();
return (spells ? instance._spellsRow : instance._wizardRow)?.Root;
}
internal static float[] LiveProjection()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
StatusEffectsMod instance = _instance;
PlayerMotor motor = WizardStatus.Motor;
Camera main = Camera.main;
if (instance == null || (Object)(object)motor == (Object)null || (Object)(object)main == (Object)null || (Object)(object)instance._container == (Object)null)
{
return null;
}
Canvas componentInParent = ((Component)instance._container).GetComponentInParent<Canvas>();
Canvas val = ((componentInParent != null) ? componentInParent.rootCanvas : null);
Camera uiCam = (((Object)(object)val != (Object)null && (int)val.renderMode != 0) ? val.worldCamera : null);
return instance.ComputeProjection(main, ((Component)motor).transform.position, uiCam);
}
internal static List<StatusView> Samples()
{
float t = Time.unscaledTime;
return new List<StatusView>
{
new StatusView
{
Kind = StatusKind.Frozen,
Fill = Ring(2f, 0f),
Value = "1.4s",
Stat = "Can't move"
},
new StatusView
{
Kind = StatusKind.Chilled,
Fill = Ring(4f, 1f),
Value = "45%",
Stat = "−45% move speed"
},
new StatusView
{
Kind = StatusKind.Poisoned,
Fill = Ring(3f, 0.5f),
Value = "−50%",
Stat = "Damage resistance"
},
new StatusView
{
Kind = StatusKind.Burning,
Fill = Ring(1.5f, 0.2f),
Value = "×3",
Stat = "−12 health per tick"
},
new StatusView
{
Kind = StatusKind.Healing,
Fill = Ring(5f, 2f),
Value = "+8",
Stat = "+8 health per tick"
},
new StatusView
{
Kind = StatusKind.CorruptionBuilding,
Fill = 0.6f,
Value = "60%",
Stat = "Corruption building",
Dim = true
}
};
float Ring(float period, float offset)
{
return 1f - (t + offset) % period / period;
}
}
public override void OnInitializeMelon()
{
Log = base.LoggerInstance;
_instance = this;
MelonPreferences_Category melonPreferences_Category = MelonPreferences.CreateCategory("StatusEffects", "Status Effects");
AboveSpells = melonPreferences_Category.CreateEntry("AboveSpells", default_value: true, "Show Spell Bar Badges", "Full status badges (value and what it does), starting just above your spell slots and movable anywhere");
AboveWizard = melonPreferences_Category.CreateEntry("AboveWizard", default_value: false, "Show Wizard Badges", "Compact status badges that follow your wizard, above, over or below it");
SpellsSize = melonPreferences_Category.CreateEntry("AboveSpellsSize", 1f, "Spell Bar Badges Size", "Size of the spell bar badges", is_hidden: false, dont_save_default: false, new ValueRange<float>(0.5f, 2f));
WizardSize = melonPreferences_Category.CreateEntry("AboveWizardSize", 1f, "Wizard Badges Size", "Size of the wizard badges", is_hidden: false, dont_save_default: false, new ValueRange<float>(0.5f, 2f));
SpellsOffsetX = melonPreferences_Category.CreateEntry("SpellBadgesX", 0f, "Spell Bar Badges Left / Right", "Move the spell bar badges left (negative) or right (positive) of the middle of the spell slots", is_hidden: false, dont_save_default: false, new ValueRange<float>(-4000f, 4000f));
SpellsHeight = melonPreferences_Category.CreateEntry("AboveSpellsHeight", 12f, "Spell Bar Badges Up / Down", "How far above (positive) or below (negative) the top of the spell slots the badges sit", is_hidden: false, dont_save_default: false, new ValueRange<float>(-1100f, 2100f));
WizardHeight = melonPreferences_Category.CreateEntry("AboveWizardHeight", 3.2f, "Wizard Badges Height", "Where the wizard badges float: below the feet (negative), over the wizard, or above it", is_hidden: false, dont_save_default: false, new ValueRange<float>(-3f, 8f));
SpellsSpacing = melonPreferences_Category.CreateEntry("AboveSpellsSpacing", 16f, "Spell Bar Badges Spacing", "Space between the spell bar badges", is_hidden: false, dont_save_default: false, new ValueRange<float>(0f, 80f));
WizardSpacing = melonPreferences_Category.CreateEntry("AboveWizardSpacing", 6f, "Wizard Badges Spacing", "Space between the wizard badges", is_hidden: false, dont_save_default: false, new ValueRange<float>(0f, 60f));
Preview = melonPreferences_Category.CreateEntry("Preview", default_value: false, "Preview Badges", "Show sample badges in both places so you can see your size, height and spacing (turns itself off when the game starts)");
Preview.Value = false;
MelonPreferences_Entry[] array = new MelonPreferences_Entry[9] { AboveSpells, AboveWizard, SpellsSize, WizardSize, SpellsHeight, SpellsOffsetX, WizardHeight, SpellsSpacing, WizardSpacing };
for (int i = 0; i < array.Length; i++)
{
array[i].OnEntryValueChangedUntyped.Subscribe(delegate
{
_previewUntil = Time.unscaledTime + 6f;
});
}
if (Array.Exists(AppDomain.CurrentDomain.GetAssemblies(), (Assembly a) => a.GetName().Name == "BrigadeModMenu"))
{
_hasMenu = true;
try
{
RegisterMenu();
}
catch (Exception ex)
{
Log.Warning("Mod List page: " + ex.Message);
}
}
Log.Msg("ready");
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static void RegisterMenu()
{
MenuPage.Register();
}
public override void OnUpdate()
{
if (Time.unscaledTime < _retryAt)
{
return;
}
try
{
Tick();
}
catch (Exception ex)
{
string name = ex.GetType().Name;
string? stackTrace = ex.StackTrace;
string text = name + ((stackTrace != null) ? stackTrace.Split('\n')[0] : null);
if (_lastError != text)
{
_lastError = text;
Log.Error($"status display: {ex}");
}
_retryAt = Time.unscaledTime + 2f;
SetShown(shown: false);
}
}
private void Tick()
{
//IL_00a3: 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_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
bool value = AboveSpells.Value;
bool value2 = AboveWizard.Value;
List<StatusView> list = ((value || value2) ? WizardStatus.Read() : null);
PlayerMotor motor = WizardStatus.Motor;
bool flag = list != null && (Preview.Value || Time.unscaledTime < _previewUntil);
if (flag)
{
list = Samples();
}
if (list == null || ((Object)(object)motor == (Object)null && !flag) || !EnsureLayer())
{
SetShown(shown: false);
return;
}
SetShown(shown: true);
Canvas componentInParent = ((Component)_container).GetComponentInParent<Canvas>();
Canvas val = ((componentInParent != null) ? componentInParent.rootCanvas : null);
Camera uiCam = (((Object)(object)val != (Object)null && (int)val.renderMode != 0) ? val.worldCamera : null);
if (_hasMenu && (Object)(object)motor != (Object)null && (Object)(object)_hudCanvas != (Object)null)
{
MeasureProjection(motor, uiCam);
}
bool flag2 = false;
if (value && TrySpellsTop(out var top) && ToLocal(top, uiCam, out var local))
{
_spellsRow.Place(local + new Vector2(SpellsOffsetX.Value, SpellsHeight.Value));
_spellsRow.SetScale(1.4f * SpellsSize.Value);
_spellsRow.SetGap(SpellsSpacing.Value);
flag2 = true;
}
_spellsRow.SetVisible(flag2);
if (flag2)
{
_spellsRow.Show(list);
}
bool flag3 = false;
if (value2 && (Object)(object)motor != (Object)null)
{
Camera main = Camera.main;
if ((Object)(object)main != (Object)null)
{
Vector3 val2 = main.WorldToScreenPoint(((Component)motor).transform.position + Vector3.up * WizardHeight.Value);
if (val2.z > 0f && ToLocal(new Vector2(val2.x, val2.y), uiCam, out var local2))
{
_wizardRow.Place(local2);
_wizardRow.SetScale(1.4f * WizardSize.Value);
_wizardRow.SetGap(WizardSpacing.Value);
flag3 = true;
}
}
}
_wizardRow.SetVisible(flag3);
if (flag3)
{
_wizardRow.Show(list);
}
string text = string.Join(",", list.ConvertAll((StatusView s) => s.Kind.ToString()));
if (text != _lastSummary)
{
_lastSummary = text;
if (text.Length > 0)
{
Log.Msg($"showing [{text}] — above spells: {(flag2 ? "yes" : "no")}, above wizard: {(flag3 ? "yes" : "no")}, in {(((Object)(object)_hudCanvas != (Object)null) ? ("HUD '" + ((Object)_hudCanvas).name + "'") : "own canvas")}");
}
}
}
private void MeasureProjection(PlayerMotor motor, Camera uiCam)
{
//IL_002a: 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_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_0074: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
if (((Il2CppObjectBase)motor).Pointer == _measuredFor)
{
return;
}
Camera main = Camera.main;
if ((Object)(object)main == (Object)null)
{
return;
}
Vector3 position = ((Component)motor).transform.position;
Vector3 position2 = ((Component)main).transform.position;
if (_measureAfter <= 0f)
{
_measureAfter = Time.unscaledTime + 8f;
_lastFeet = position;
_lastCam = position2;
_stillSince = Time.unscaledTime;
return;
}
Vector3 val = position - _lastFeet;
int num;
if (((Vector3)(ref val)).sqrMagnitude < 1E-06f)
{
val = position2 - _lastCam;
num = ((((Vector3)(ref val)).sqrMagnitude < 1E-06f) ? 1 : 0);
}
else
{
num = 0;
}
_lastFeet = position;
_lastCam = position2;
if (num == 0)
{
_stillSince = Time.unscaledTime;
}
if (!(Time.unscaledTime < _measureAfter) && !(Time.unscaledTime - _stillSince < 1.5f))
{
float[] array = ComputeProjection(main, position, uiCam);
if (array != null)
{
_measuredFor = ((Il2CppObjectBase)motor).Pointer;
_measureAfter = 0f;
MenuPage.SaveProjection(array);
}
}
}
private float[] ComputeProjection(Camera cam, Vector3 feet, Camera uiCam)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_002f: 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)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
float[] array = new float[113];
if (!Project(cam, feet, uiCam, out var local))
{
return null;
}
array[0] = local.x;
array[1] = local.y;
for (int i = 0; i < 111; i++)
{
if (!Project(cam, feet + Vector3.up * (-3f + (float)i * 0.1f), uiCam, out var local2))
{
return null;
}
array[2 + i] = local2.y;
}
return array;
}
private bool Project(Camera cam, Vector3 world, Camera uiCam, out Vector2 local)
{
//IL_0002: 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_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_0010: 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_0024: 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)
local = default(Vector2);
Vector3 val = cam.WorldToScreenPoint(world);
if (val.z > 0f)
{
return ToLocal(new Vector2(val.x, val.y), uiCam, out local);
}
return false;
}
private void SetShown(bool shown)
{
if ((Object)(object)_container != (Object)null && ((Component)_container).gameObject.activeSelf != shown)
{
((Component)_container).gameObject.SetActive(shown);
}
}
private bool EnsureLayer()
{
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Expected O, but got Unknown
SpellSlotsDisplay val = FindSpells();
object obj;
if (!((Object)(object)val != (Object)null))
{
obj = null;
}
else
{
Canvas componentInParent = ((Component)val).GetComponentInParent<Canvas>();
obj = ((componentInParent != null) ? componentInParent.rootCanvas : null);
}
Canvas val2 = (Canvas)obj;
if ((Object)(object)val2 != (Object)null)
{
if ((Object)(object)_container == (Object)null || (Object)(object)_hudCanvas == (Object)null || ((Il2CppObjectBase)_hudCanvas).WasCollected || ((Il2CppObjectBase)_hudCanvas).Pointer != ((Il2CppObjectBase)val2).Pointer || (Object)(object)((Transform)_container).parent == (Object)null || ((Il2CppObjectBase)((Transform)_container).parent).Pointer != ((Il2CppObjectBase)((Component)val2).transform).Pointer)
{
_hudCanvas = val2;
MoveLayerInto(((Component)val2).transform);
}
Transform val3 = ((Component)val).transform;
while ((Object)(object)val3.parent != (Object)null && ((Il2CppObjectBase)val3.parent).Pointer != ((Il2CppObjectBase)((Component)val2).transform).Pointer)
{
val3 = val3.parent;
}
int num = val3.GetSiblingIndex() + 1;
if (((Transform)_container).GetSiblingIndex() != num && num < ((Component)val2).transform.childCount + 1)
{
((Transform)_container).SetSiblingIndex(Mathf.Min(num, ((Component)val2).transform.childCount - 1));
}
return true;
}
if ((Object)(object)_fallbackCanvas == (Object)null)
{
_fallbackCanvas = new GameObject("StatusEffectsCanvas");
Object.DontDestroyOnLoad((Object)(object)_fallbackCanvas);
Canvas obj2 = _fallbackCanvas.AddComponent<Canvas>();
obj2.renderMode = (RenderMode)0;
obj2.sortingOrder = -1;
}
if ((Object)(object)_container == (Object)null || (Object)(object)((Transform)_container).parent == (Object)null || ((Il2CppObjectBase)((Transform)_container).parent).Pointer != ((Il2CppObjectBase)_fallbackCanvas.transform).Pointer)
{
_hudCanvas = null;
MoveLayerInto(_fallbackCanvas.transform);
}
_fallbackCanvas.GetComponent<Canvas>().scaleFactor = Mathf.Max(0.5f, (float)Screen.height / 1080f);
return true;
}
private void MoveLayerInto(Transform parent)
{
//IL_0062: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_container == (Object)null)
{
_container = Ui.Rect("StatusEffectsLayer", parent);
_spellsRow = new StatusRow("AboveSpells", _container, full: true);
_wizardRow = new StatusRow("AboveWizard", _container, full: false);
}
else
{
((Transform)_container).SetParent(parent, false);
}
_container.anchorMin = Vector2.zero;
_container.anchorMax = Vector2.one;
_container.pivot = new Vector2(0.5f, 0.5f);
RectTransform container = _container;
Vector2 offsetMin = (_container.offsetMax = Vector2.zero);
container.offsetMin = offsetMin;
((Transform)_container).localScale = Vector3.one;
}
private bool ToLocal(Vector2 screen, Camera uiCam, out Vector2 local)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return RectTransformUtility.ScreenPointToLocalPointInRectangle(_container, screen, uiCam, ref local);
}
private SpellSlotsDisplay FindSpells()
{
if ((Object)(object)_spells != (Object)null && !((Il2CppObjectBase)_spells).WasCollected && ((Behaviour)_spells).isActiveAndEnabled)
{
return _spells;
}
_spells = null;
if (Time.unscaledTime < _nextSpellSearch)
{
return null;
}
_nextSpellSearch = Time.unscaledTime + 1f;
foreach (SpellSlotsDisplay item in Object.FindObjectsOfType<SpellSlotsDisplay>())
{
if ((Object)(object)item != (Object)null && ((Behaviour)item).isActiveAndEnabled)
{
_spells = item;
break;
}
}
return _spells;
}
private bool TrySpellsTop(out Vector2 top)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: 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)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
top = default(Vector2);
SpellSlotsDisplay val = FindSpells();
if ((Object)(object)val == (Object)null)
{
return false;
}
RectTransform val2 = (((Object)(object)val.activeLayout != (Object)null && ((Behaviour)val.activeLayout).isActiveAndEnabled) ? ((Component)val.activeLayout).GetComponent<RectTransform>() : ((Component)val).GetComponent<RectTransform>());
if ((Object)(object)val2 == (Object)null)
{
return false;
}
Canvas componentInParent = ((Component)val2).GetComponentInParent<Canvas>();
Canvas val3 = ((componentInParent != null) ? componentInParent.rootCanvas : null);
Camera obj = (((Object)(object)val3 != (Object)null && (int)val3.renderMode != 0) ? val3.worldCamera : null);
Il2CppStructArray<Vector3> val4 = new Il2CppStructArray<Vector3>(4L);
val2.GetWorldCorners(val4);
Vector2 val5 = RectTransformUtility.WorldToScreenPoint(obj, ((Il2CppArrayBase<Vector3>)(object)val4)[1]);
Vector2 val6 = RectTransformUtility.WorldToScreenPoint(obj, ((Il2CppArrayBase<Vector3>)(object)val4)[2]);
top = new Vector2((val5.x + val6.x) / 2f, Mathf.Max(val5.y, val6.y));
return true;
}
}
internal sealed class StatusRow
{
private readonly bool _full;
private readonly RectTransform _root;
private readonly Dictionary<StatusKind, Badge> _badges = new Dictionary<StatusKind, Badge>();
private float _gap;
internal float Width
{
get
{
if (!_full)
{
return 56f;
}
return 132f;
}
}
private float Gap => _gap;
internal RectTransform Root => _root;
internal void SetGap(float gap)
{
_gap = Mathf.Max(0f, gap);
}
internal StatusRow(string name, RectTransform parent, bool full)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
_full = full;
_gap = (full ? 16f : 6f);
_root = Ui.Rect(name, (Transform)(object)parent);
RectTransform root = _root;
RectTransform root2 = _root;
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(0.5f, 0.5f);
root2.anchorMax = val;
root.anchorMin = val;
_root.pivot = new Vector2(0.5f, 0f);
_root.sizeDelta = new Vector2(10f, 10f);
}
internal void SetVisible(bool visible)
{
if (((Component)_root).gameObject.activeSelf != visible)
{
((Component)_root).gameObject.SetActive(visible);
}
}
internal void SetScale(float scale)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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)
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(scale, scale, 1f);
if (((Transform)_root).localScale != val)
{
((Transform)_root).localScale = val;
}
}
internal void Place(Vector2 bottomCentre)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
_root.anchoredPosition = bottomCentre;
}
internal void Show(List<StatusView> statuses)
{
HashSet<StatusKind> hashSet = new HashSet<StatusKind>();
foreach (StatusView status in statuses)
{
hashSet.Add(status.Kind);
}
float num = (0f - ((float)statuses.Count * Width + (float)Mathf.Max(0, statuses.Count - 1) * Gap)) / 2f + Width / 2f;
foreach (StatusView status2 in statuses)
{
if (!_badges.TryGetValue(status2.Kind, out var value))
{
value = new Badge(_root, status2.Kind, _full);
_badges[status2.Kind] = value;
value.SnapTo(num);
}
value.Update(status2, num);
num += Width + Gap;
}
foreach (var (item, badge2) in _badges)
{
if (!hashSet.Contains(item))
{
badge2.FadeOut();
}
}
}
}
internal sealed class Badge
{
private const float FadeSpeed = 8f;
private readonly RectTransform _root;
private readonly CanvasGroup _group;
private readonly Image _ring;
private readonly Image _ringBack;
private readonly Image _icon;
private readonly Image _disc;
private readonly TMP_Text _value;
private readonly TMP_Text _stat;
private readonly Color _color;
private readonly StatusKind _kind;
private float _alpha;
private bool _shown;
internal Badge(RectTransform parent, StatusKind kind, bool full)
{
//IL_0018: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: 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_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
//IL_0392: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
float num = (full ? 56f : 38f);
_color = Ui.ColorFor(kind);
_root = Ui.Rect("Status_" + kind, (Transform)(object)parent);
RectTransform root = _root;
RectTransform root2 = _root;
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(0.5f, 0f);
root2.anchorMax = val;
root.anchorMin = val;
_root.pivot = new Vector2(0.5f, 0f);
_root.sizeDelta = new Vector2(full ? 132f : 56f, full ? 112f : 62f);
_group = ((Component)_root).gameObject.AddComponent<CanvasGroup>();
_group.alpha = 0f;
_group.interactable = false;
_group.blocksRaycasts = false;
RectTransform val2 = Ui.Rect("Ring", (Transform)(object)_root);
((Vector2)(ref val))..ctor(0.5f, 1f);
val2.anchorMax = val;
val2.anchorMin = val;
val2.pivot = new Vector2(0.5f, 1f);
val2.sizeDelta = new Vector2(num, num);
val2.anchoredPosition = Vector2.zero;
_disc = Ui.Image("Disc", val2, Ui.DiscSprite(), new Color(0.05f, 0.05f, 0.08f, 0.72f), num * 0.86f);
_ringBack = Ui.Image("RingBack", val2, Ui.RingSprite(), new Color(_color.r, _color.g, _color.b, 0.25f), num);
_ring = Ui.Image("RingFill", val2, Ui.RingSprite(), _color, num);
_ring.type = (Type)3;
_ring.fillMethod = (FillMethod)4;
_ring.fillOrigin = 2;
_ring.fillClockwise = false;
_kind = kind;
Sprite val3 = Ui.IconFor(kind);
Sprite val4 = ((kind == StatusKind.Healing) ? Ui.PlusSprite() : Ui.DiscSprite());
_icon = Ui.Image("Icon", val2, val3 ?? val4, ((Object)(object)val3 != (Object)null) ? Color.white : _color, num * 0.58f);
_icon.preserveAspect = true;
float num2 = (full ? 20f : 15f);
_value = Ui.Text("Value", _root, num2, Color.white);
RectTransform rectTransform = _value.rectTransform;
((Vector2)(ref val))..ctor(0.5f, 1f);
rectTransform.anchorMax = val;
rectTransform.anchorMin = val;
rectTransform.pivot = new Vector2(0.5f, 1f);
rectTransform.sizeDelta = new Vector2(full ? 128f : 56f, num2 * 1.3f);
rectTransform.anchoredPosition = new Vector2(0f, 0f - num - 1f);
if (full)
{
_stat = Ui.Text("Stat", _root, 13f, new Color(1f, 0.82f, 0.78f, 1f));
RectTransform rectTransform2 = _stat.rectTransform;
((Vector2)(ref val))..ctor(0.5f, 1f);
rectTransform2.anchorMax = val;
rectTransform2.anchorMin = val;
rectTransform2.pivot = new Vector2(0.5f, 1f);
rectTransform2.sizeDelta = new Vector2(128f, 34f);
rectTransform2.anchoredPosition = new Vector2(0f, 0f - num - num2 * 1.3f);
_stat.textWrappingMode = (TextWrappingModes)1;
}
}
internal void SnapTo(float x)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
_root.anchoredPosition = new Vector2(x, 0f);
}
internal void Update(StatusView s, float x)
{
//IL_0030: 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_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
_shown = true;
if (!((Component)_root).gameObject.activeSelf)
{
((Component)_root).gameObject.SetActive(true);
}
Vector2 anchoredPosition = _root.anchoredPosition;
_root.anchoredPosition = new Vector2(Mathf.Lerp(anchoredPosition.x, x, 1f - Mathf.Exp(-14f * Time.unscaledDeltaTime)), 0f);
if (_kind == StatusKind.Healing && Ui.IsStandIn(_icon.sprite))
{
Sprite val = Ui.IconFor(_kind);
if ((Object)(object)val != (Object)null)
{
_icon.sprite = val;
((Graphic)_icon).color = Color.white;
}
}
_ring.fillAmount = s.Fill;
float num = (s.Dim ? 0.55f : 1f);
((Graphic)_ring).color = new Color(_color.r, _color.g, _color.b, num);
((Graphic)_icon).color = new Color(((Graphic)_icon).color.r, ((Graphic)_icon).color.g, ((Graphic)_icon).color.b, s.Dim ? 0.6f : 1f);
_value.text = s.Value;
if ((Object)(object)_stat != (Object)null)
{
_stat.text = s.Stat;
}
Fade();
}
internal void FadeOut()
{
_shown = false;
Fade();
}
private void Fade()
{
float num = (_shown ? 1f : 0f);
_alpha = Mathf.MoveTowards(_alpha, num, 8f * Time.unscaledDeltaTime);
_group.alpha = _alpha;
if (!_shown && _alpha <= 0f && ((Component)_root).gameObject.activeSelf)
{
((Component)_root).gameObject.SetActive(false);
}
}
}
internal static class Ui
{
private static Sprite _ring;
private static Sprite _disc;
private static TMP_FontAsset _font;
private static ElementIconsResource _icons;
private static ThemeResource _theme;
private static Sprite _healIcon;
private static Sprite _plus;
private static float _nextHealSearch;
private static readonly string[] HealIconNames = new string[1] { "ui_stat_icon_health_regeneration" };
internal static RectTransform Rect(string name, Transform parent)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
RectTransform obj = new GameObject(name).AddComponent<RectTransform>();
((Transform)obj).SetParent(parent, false);
return obj;
}
internal static Image Image(string name, RectTransform parent, Sprite sprite, Color color, float size)
{
//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_0022: 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_0029: 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_0050: Unknown result type (might be due to invalid IL or missing references)
RectTransform obj = Rect(name, (Transform)(object)parent);
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(0.5f, 0.5f);
obj.pivot = val;
Vector2 anchorMin = (obj.anchorMax = val);
obj.anchorMin = anchorMin;
obj.sizeDelta = new Vector2(size, size);
Image obj2 = ((Component)obj).gameObject.AddComponent<Image>();
obj2.sprite = sprite;
((Graphic)obj2).color = color;
((Graphic)obj2).raycastTarget = false;
return obj2;
}
internal static TMP_Text Text(string name, RectTransform parent, float size, Color color)
{
//IL_003c: 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)
TextMeshProUGUI val = ((Component)Rect(name, (Transform)(object)parent)).gameObject.AddComponent<TextMeshProUGUI>();
TMP_FontAsset val2 = Font();
if ((Object)(object)val2 != (Object)null)
{
((TMP_Text)val).font = val2;
((TMP_Text)val).fontSharedMaterial = ((TMP_Asset)val2).material;
}
((TMP_Text)val).fontSize = size;
((Graphic)val).color = color;
((TMP_Text)val).alignment = (TextAlignmentOptions)258;
((TMP_Text)val).textWrappingMode = (TextWrappingModes)0;
((TMP_Text)val).overflowMode = (TextOverflowModes)0;
((Graphic)val).raycastTarget = false;
((TMP_Text)val).outlineWidth = 0.25f;
((TMP_Text)val).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)220);
return (TMP_Text)(object)val;
}
private static TMP_FontAsset Font()
{
if ((Object)(object)_font != (Object)null)
{
return _font;
}
foreach (TMP_FontAsset item in Resources.FindObjectsOfTypeAll<TMP_FontAsset>())
{
if ((Object)(object)item != (Object)null && ((Object)item).name == "TitilliumWeb-Bold SDF")
{
_font = item;
break;
}
}
return _font;
}
private static ElementType ElementFor(StatusKind kind)
{
//IL_002a: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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_003d: Unknown result type (might be due to invalid IL or missing references)
switch (kind)
{
case StatusKind.Frozen:
case StatusKind.FreezeImmune:
return (ElementType)11;
case StatusKind.Chilled:
return (ElementType)10;
case StatusKind.Burning:
return (ElementType)1;
case StatusKind.Poisoned:
return (ElementType)6;
default:
return (ElementType)15;
}
}
internal static bool IsStandIn(Sprite s)
{
if ((Object)(object)s != (Object)null && (Object)(object)_plus != (Object)null)
{
return ((Il2CppObjectBase)s).Pointer == ((Il2CppObjectBase)_plus).Pointer;
}
return false;
}
internal static Sprite PlusSprite()
{
//IL_001f: 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_002c: 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_003b: Expected O, but got Unknown
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_plus != (Object)null)
{
return _plus;
}
Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false)
{
hideFlags = (HideFlags)61,
wrapMode = (TextureWrapMode)1,
filterMode = (FilterMode)1
};
Color32[] array = (Color32[])(object)new Color32[16384];
for (int i = 0; i < 128; i++)
{
for (int j = 0; j < 128; j++)
{
float u = Mathf.Abs(((float)j + 0.5f) / 128f * 2f - 1f);
float v = Mathf.Abs(((float)i + 0.5f) / 128f * 2f - 1f);
float num = Mathf.Min(RoundedBox(u, v, 0.86f, 0.27f, 0.08f), RoundedBox(u, v, 0.27f, 0.86f, 0.08f));
byte b = (byte)(Mathf.Clamp01(0.5f - num * 128f / 2f) * 255f);
array[i * 128 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
}
}
val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array));
val.Apply();
_plus = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f);
((Object)_plus).hideFlags = (HideFlags)61;
return _plus;
}
private static float RoundedBox(float u, float v, float w, float h, float r)
{
//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)
float num = u - (w - r);
float num2 = v - (h - r);
Vector2 val = new Vector2(Mathf.Max(num, 0f), Mathf.Max(num2, 0f));
return ((Vector2)(ref val)).magnitude + Mathf.Min(Mathf.Max(num, num2), 0f) - r;
}
internal static Sprite IconFor(StatusKind kind)
{
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
try
{
if (kind == StatusKind.Healing)
{
if ((Object)(object)_healIcon == (Object)null && Time.unscaledTime >= _nextHealSearch)
{
_nextHealSearch = Time.unscaledTime + 3f;
foreach (Sprite item in Resources.FindObjectsOfTypeAll<Sprite>())
{
if (!((Object)(object)item == (Object)null))
{
int num = Array.IndexOf(HealIconNames, ((Object)item).name);
if (num >= 0 && ((Object)(object)_healIcon == (Object)null || num < Array.IndexOf(HealIconNames, ((Object)_healIcon).name)))
{
_healIcon = item;
}
}
}
}
return _healIcon;
}
if ((Object)(object)_icons == (Object)null)
{
using IEnumerator<ElementIconsResource> enumerator2 = Resources.FindObjectsOfTypeAll<ElementIconsResource>().GetEnumerator();
if (enumerator2.MoveNext())
{
_icons = enumerator2.Current;
}
}
ElementIconsResource icons = _icons;
return (icons != null) ? icons.GetIconForElement(ElementFor(kind)) : null;
}
catch
{
return null;
}
}
internal static Color ColorFor(StatusKind kind)
{
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Invalid comparison between Unknown and I4
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Invalid comparison between Unknown and I4
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Invalid comparison between Unknown and I4
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Invalid comparison between Unknown and I4
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Invalid comparison between Unknown and I4
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Invalid comparison between Unknown and I4
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Invalid comparison between Unknown and I4
//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)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Invalid comparison between Unknown and I4
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: 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_00c9: Invalid comparison between Unknown and I4
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
ElementType val;
try
{
if ((Object)(object)_theme == (Object)null)
{
using IEnumerator<ThemeResource> enumerator = Resources.FindObjectsOfTypeAll<ThemeResource>().GetEnumerator();
if (enumerator.MoveNext())
{
_theme = enumerator.Current;
}
}
if ((Object)(object)_theme != (Object)null && kind == StatusKind.Healing)
{
Color healColor = _theme.HealColor;
if (healColor.a > 0.01f)
{
return new Color(healColor.r, healColor.g, healColor.b, 1f);
}
}
if (kind == StatusKind.Healing)
{
return new Color(0.35f, 1f, 0.45f);
}
Color val2;
if ((Object)(object)_theme != (Object)null)
{
val = ElementFor(kind);
if ((int)val <= 6)
{
if ((int)val != 1)
{
if ((int)val != 6)
{
goto IL_0111;
}
val2 = _theme.AcidDamageColor;
}
else
{
val2 = _theme.FireDamageColor;
}
}
else if ((int)val != 10)
{
if ((int)val != 11)
{
goto IL_0111;
}
val2 = _theme.IceDoubleDamageColor;
}
else
{
val2 = _theme.IceDamageColor;
}
goto IL_011d;
}
goto end_IL_0000;
IL_0111:
val2 = _theme.DarkDamageColor;
goto IL_011d;
IL_011d:
Color val3 = val2;
if (val3.a > 0.01f)
{
return new Color(val3.r, val3.g, val3.b, 1f);
}
end_IL_0000:;
}
catch
{
}
val = ElementFor(kind);
if ((int)val <= 6)
{
if ((int)val == 1)
{
return new Color(1f, 0.5f, 0.2f);
}
if ((int)val == 6)
{
return new Color(0.55f, 0.9f, 0.25f);
}
}
else
{
if ((int)val == 10)
{
return new Color(0.4f, 0.75f, 1f);
}
if ((int)val == 11)
{
return new Color(0.75f, 0.92f, 1f);
}
}
return new Color(0.65f, 0.45f, 1f);
}
internal static Sprite RingSprite()
{
return _ring ?? (_ring = Circle(0.78f));
}
internal static Sprite DiscSprite()
{
return _disc ?? (_disc = Circle(0f));
}
private static Sprite Circle(float inner)
{
//IL_000c: 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_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_012c: 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_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false)
{
hideFlags = (HideFlags)61,
wrapMode = (TextureWrapMode)1,
filterMode = (FilterMode)1
};
Color32[] array = (Color32[])(object)new Color32[16384];
float num = 3f / 128f;
for (int i = 0; i < 128; i++)
{
for (int j = 0; j < 128; j++)
{
float num2 = ((float)j + 0.5f) / 128f * 2f - 1f;
float num3 = ((float)i + 0.5f) / 128f * 2f - 1f;
float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3);
float num5 = Mathf.Clamp01((1f - num4) / num);
if (inner > 0f)
{
num5 *= Mathf.Clamp01((num4 - inner) / num);
}
array[i * 128 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num5 * 255f));
}
}
val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array));
val.Apply();
Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f);
((Object)obj).hideFlags = (HideFlags)61;
return obj;
}
}
internal enum StatusKind
{
Frozen,
Corrupted,
Chilled,
Poisoned,
Burning,
Healing,
CorruptionBuilding,
FreezeImmune
}
internal sealed class StatusView
{
public StatusKind Kind;
public float Fill;
public string Value;
public string Stat;
public bool Dim;
public int Order => (int)Kind;
}
internal static class WizardStatus
{
private static PlayerMotor _motor;
private static float _nextSearch;
private static readonly Dictionary<StatusKind, float> LongestLeft = new Dictionary<StatusKind, float>();
private static int _freezeAgainOffset = -1;
internal static PlayerMotor Motor => _motor;
internal static void Reset()
{
_motor = null;
LongestLeft.Clear();
}
internal static List<StatusView> Read()
{
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Invalid comparison between Unknown and I4
List<StatusView> list = new List<StatusView>();
if (!FindLocalWizard())
{
return list;
}
Transform root = ((Component)_motor).transform.root;
ElementEffectHandlers componentInChildren = ((Component)root).GetComponentInChildren<ElementEffectHandlers>(true);
PlayerHealthContainer componentInChildren2 = ((Component)root).GetComponentInChildren<PlayerHealthContainer>(true);
float time = Time.time;
HashSet<StatusKind> hashSet = new HashSet<StatusKind>();
IceEffectHandler val = ((componentInChildren != null) ? componentInChildren.iceEffectHandler : null);
FreezeStateHandler freezeStateHandler = _motor.freezeStateHandler;
float time2;
if ((((Object)(object)freezeStateHandler != (Object)null && freezeStateHandler.IsFrozen) || ((Object)(object)val != (Object)null && val.isApplyingFreeze)) && (Object)(object)val != (Object)null)
{
float num = Mathf.Max(0f, val.endFreezeTime - time);
Add(list, hashSet, StatusKind.Frozen, num, $"{num:0.0}s", "Can't move");
}
else if ((Object)(object)val != (Object)null && TryFreezeAgainTime(val, out time2) && time2 > time)
{
float left = time2 - time;
Add(list, hashSet, StatusKind.FreezeImmune, left, "Immune", "Can't be frozen", dim: true);
}
DarkEffectHandler val2 = _motor.darkEffectHandler ?? ((componentInChildren != null) ? componentInChildren.darkEffectHandler : null);
if ((Object)(object)val2 != (Object)null)
{
CorruptionCalculator calculator = val2.calculator;
if ((int)val2.CorruptionState == 1)
{
float num2 = Mathf.Max(0f, val2.maxCorruptionDuration - (time - val2.corruptionStartTime));
Add(list, hashSet, StatusKind.Corrupted, num2, $"{num2:0.0}s", "Controls reversed");
}
else if (calculator != null && calculator.CorruptionValue > 0.005f)
{
float num3 = Mathf.Clamp01(calculator.CorruptionValue);
AddMeter(list, hashSet, StatusKind.CorruptionBuilding, num3, $"{num3 * 100f:0}%", "Corruption building");
}
}
if ((Object)(object)val != (Object)null && val.isSlowedDown && val.chillFactor > 0.001f)
{
float left2 = Mathf.Max(0f, val.endSlowTime - time);
float value = val.chillFactor * 100f;
Add(list, hashSet, StatusKind.Chilled, left2, $"{value:0}%", $"−{value:0}% move speed");
}
AcidEffectHandler val3 = ((componentInChildren != null) ? componentInChildren.acidEffectHandler : null);
if ((Object)(object)val3 != (Object)null && val3.isPoisoning)
{
float num4 = 0f;
try
{
if ((Object)(object)componentInChildren2 != (Object)null)
{
num4 = 0f - ((HealthContainer)componentInChildren2).GetDamageResistanceModifier("AcidEffectHandler");
}
}
catch
{
}
float num5 = Mathf.Max(0f, val3.poisonDuration);
string value2 = ((num4 > 0.001f) ? $"−{num4 * 100f:0}%" : $"{num5:0.0}s");
Add(list, hashSet, StatusKind.Poisoned, num5, value2, "Damage resistance");
}
FireEffectHandler val4 = ((componentInChildren != null) ? componentInChildren.fireEffectHandler : null);
float num6 = 0f;
float value3 = 0f;
int num7 = 0;
if ((Object)(object)val4 != (Object)null && val4.numberOfTicks > 0)
{
float num8 = Mathf.Max(0.05f, val4.secondsBetweenTicks);
float num9 = (float)(val4.numberOfTicks - 1) * num8 + Mathf.Clamp(val4.nextTickTime - time, 0f, num8);
DamageInfo damageInfo = val4.damageInfo;
PlayerDamageInfo val5 = ((damageInfo != null) ? ((Il2CppObjectBase)damageInfo).TryCast<PlayerDamageInfo>() : null);
if (val5 != null && val5.WillHealBecauseOfVariant)
{
PlayerSpellDamageInfo obj2 = ((Il2CppObjectBase)val5).TryCast<PlayerSpellDamageInfo>();
float num10 = ((obj2 != null) ? obj2.HealingMultiplier : 1f);
num6 = num9;
num7 = val4.numberOfTicks;
value3 = val4.damagePerTick * ((num10 > 0.001f) ? num10 : 1f);
}
else
{
Add(list, hashSet, StatusKind.Burning, num9, $"×{val4.numberOfTicks}", $"−{val4.damagePerTick:0} health per tick");
}
}
try
{
HealthPickupsHealOverTime componentInChildren3 = ((Component)root).GetComponentInChildren<HealthPickupsHealOverTime>(true);
Queue<HealingInfo> val6 = ((componentInChildren3 != null) ? componentInChildren3.healingTicks : null);
if (val6 != null && val6.Count > 0)
{
float num11 = Mathf.Max(0.05f, componentInChildren3.tickInterval);
float num12 = (float)(val6.Count - 1) * num11 + Mathf.Clamp(num11 - (time - componentInChildren3.lastHealingTime), 0f, num11);
if (num12 > num6)
{
num6 = num12;
num7 = val6.Count;
HealingInfo obj3 = val6.Peek();
value3 = ((obj3 != null) ? obj3.HealingPerTick : 0f);
}
}
}
catch
{
}
if (num7 > 0)
{
Add(list, hashSet, StatusKind.Healing, num6, $"+{value3:0}", $"+{value3:0} health per tick");
}
List<StatusKind> list2 = new List<StatusKind>();
foreach (StatusKind key in LongestLeft.Keys)
{
if (!hashSet.Contains(key))
{
list2.Add(key);
}
}
foreach (StatusKind item in list2)
{
LongestLeft.Remove(item);
}
list.Sort((StatusView a, StatusView b) => a.Order.CompareTo(b.Order));
return list;
}
private static void Add(List<StatusView> list, HashSet<StatusKind> seen, StatusKind kind, float left, string value, string stat, bool dim = false)
{
seen.Add(kind);
if (!LongestLeft.TryGetValue(kind, out var value2) || left > value2 + 0.05f)
{
value2 = left;
}
LongestLeft[kind] = value2;
list.Add(new StatusView
{
Kind = kind,
Fill = ((value2 > 0.01f) ? Mathf.Clamp01(left / value2) : 0f),
Value = value,
Stat = stat,
Dim = dim
});
}
private static void AddMeter(List<StatusView> list, HashSet<StatusKind> seen, StatusKind kind, float fill, string value, string stat)
{
seen.Add(kind);
list.Add(new StatusView
{
Kind = kind,
Fill = fill,
Value = value,
Stat = stat,
Dim = true
});
}
private static bool TryFreezeAgainTime(IceEffectHandler ice, out float time)
{
time = 0f;
try
{
if (_freezeAgainOffset < 0)
{
if (!(typeof(IceEffectHandler).GetField("NativeFieldInfoPtr_canBeFrozenAgainTimeStamp", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null) is IntPtr intPtr) || intPtr == IntPtr.Zero)
{
_freezeAgainOffset = 0;
return false;
}
_freezeAgainOffset = (int)IL2CPP.il2cpp_field_get_offset(intPtr);
}
if (_freezeAgainOffset <= 0)
{
return false;
}
IntPtr intPtr2 = ((Il2CppObjectBase)ice).Pointer + _freezeAgainOffset;
if (Marshal.ReadByte(intPtr2) == 0)
{
return false;
}
time = BitConverter.Int32BitsToSingle(Marshal.ReadInt32(intPtr2 + 4));
return true;
}
catch
{
return false;
}
}
private static bool FindLocalWizard()
{
if ((Object)(object)_motor != (Object)null && !((Il2CppObjectBase)_motor).WasCollected && (Object)(object)((Component)_motor).gameObject != (Object)null && ((NetworkBehaviour)_motor).IsOwner)
{
return true;
}
_motor = null;
if (Time.unscaledTime < _nextSearch)
{
return false;
}
_nextSearch = Time.unscaledTime + 1f;
foreach (PlayerMotor item in Object.FindObjectsOfType<PlayerMotor>())
{
if ((Object)(object)item != (Object)null && ((NetworkBehaviour)item).IsOwner)
{
_motor = item;
LongestLeft.Clear();
return true;
}
}
return false;
}
}
}
namespace StatusEffects.BepInExPlugin
{
[BepInPlugin("SpellBrigade.StatusEffects", "Status Effects", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
public const string Guid = "SpellBrigade.StatusEffects";
public override void Load()
{
MelonCompat.Start<StatusEffectsMod, Runner>((BasePlugin)(object)this, "SpellBrigade.StatusEffects");
}
}
public class Runner : MonoBehaviour
{
public Runner(IntPtr ptr)
: base(ptr)
{
}
private void Update()
{
MelonCompat.Update();
}
}
}
namespace MelonLoader
{
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class MelonInfoAttribute : Attribute
{
public MelonInfoAttribute(Type type, string name, string version, string author, string downloadLink = null)
{
}
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class MelonGameAttribute : Attribute
{
public MelonGameAttribute(string developer = null, string name = null)
{
}
}
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class MelonOptionalDependenciesAttribute : Attribute
{
public MelonOptionalDependenciesAttribute(params string[] names)
{
}
}
public abstract class MelonBase
{
public MelonLogger.Instance LoggerInstance { get; internal set; }
public Harmony HarmonyInstance { get; internal set; }
public static object FindMelon(string name, string author)
{
try
{
foreach (PluginInfo value in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values)
{
if (((value != null) ? value.Metadata : null) != null && string.Equals(value.Metadata.Name, name, StringComparison.OrdinalIgnoreCase) && value.Instance != null)
{
return value;
}
}
}
catch
{
}
return null;
}
}
public abstract class MelonMod : MelonBase
{
public virtual void OnInitializeMelon()
{
}
public virtual void OnLateInitializeMelon()
{
}
public virtual void OnUpdate()
{
}
public virtual void OnLateUpdate()
{
}
public virtual void OnFixedUpdate()
{
}
public virtual void OnGUI()
{
}
public virtual void OnApplicationQuit()
{
}
public virtual void OnSceneWasLoaded(int buildIndex, string sceneName)
{
}
public virtual void OnSceneWasInitialized(int buildIndex, string sceneName)
{
}
public virtual void OnSceneWasUnloaded(int buildIndex, string sceneName)
{
}
}
public static class MelonLogger
{
public sealed class Instance
{
private readonly ManualLogSource _log;
public Instance(ManualLogSource log)
{
_log = log;
}
public void Msg(string text)
{
_log.LogInfo((object)text);
}
public void Msg(object value)
{
_log.LogInfo(value);
}
public void Msg(string format, params object[] args)
{
_log.LogInfo((object)string.Format(format, args));
}
public void Warning(string text)
{
_log.LogWarning((object)text);
}
public void Warning(object value)
{
_log.LogWarning(value);
}
public void Error(string text)
{
_log.LogError((object)text);
}
public void Error(object value)
{
_log.LogError(value);
}
public void Error(string text, Exception e)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
ManualLogSource log = _log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(1, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(e);
}
log.LogError(val);
}
}
}
public static class MelonCompat
{
internal static ConfigFile Config;
private static MelonMod _mod;
private static bool _lateInit;
public static void Start<TMod, TRunner>(BasePlugin plugin, string harmonyId) where TMod : MelonMod, new() where TRunner : MonoBehaviour
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
Config = plugin.Config;
_mod = new TMod
{
LoggerInstance = new MelonLogger.Instance(plugin.Log),
HarmonyInstance = new Harmony(harmonyId)
};
try
{
_mod.HarmonyInstance.PatchAll(typeof(TMod).Assembly);
}
catch (Exception ex)
{
ManualLogSource log = plugin.Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(17, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Harmony patches: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
log.LogError(val);
}
_mod.OnInitializeMelon();
HookScenes();
ClassInjector.RegisterTypeInIl2Cpp<TRunner>();
plugin.AddComponent<TRunner>();
}
private static void HookScenes()
{
SceneManager.sceneLoaded += DelegateSupport.ConvertDelegate<UnityAction<Scene, LoadSceneMode>>((Delegate)new Action<Scene, LoadSceneMode>(OnSceneLoaded));
SceneManager.sceneUnloaded += DelegateSupport.ConvertDelegate<UnityAction<Scene>>((Delegate)new Action<Scene>(OnSceneUnloaded));
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//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)
Guard(delegate
{
_mod.OnSceneWasLoaded(((Scene)(ref scene)).buildIndex, ((Scene)(ref scene)).name);
});
Guard(delegate
{
_mod.OnSceneWasInitialized(((Scene)(ref scene)).buildIndex, ((Scene)(ref scene)).name);
});
}
private static void OnSceneUnloaded(Scene scene)
{
//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)
Guard(delegate
{
_mod.OnSceneWasUnloaded(((Scene)(ref scene)).buildIndex, ((Scene)(ref scene)).name);
});
}
public static void Update()
{
if (_mod != null)
{
if (!_lateInit)
{
_lateInit = true;
Guard(_mod.OnLateInitializeMelon);
}
_mod.OnUpdate();
}
}
public static void LateUpdate()
{
_mod?.OnLateUpdate();
}
public static void FixedUpdate()
{
_mod?.OnFixedUpdate();
}
public static void OnGUI()
{
_mod?.OnGUI();
}
public static void Quit()
{
_mod?.OnApplicationQuit();
}
private static void Guard(Action a)
{
try
{
a();
}
catch (Exception ex)
{
_mod.LoggerInstance.Error(ex.ToString());
}
}
}
public static class MelonPreferences
{
private static readonly Dictionary<string, MelonPreferences_Category> Categories = new Dictionary<string, MelonPreferences_Category>();
public static MelonPreferences_Category CreateCategory(string identifier, string displayName = null, bool is_hidden = false, bool is_inlined = false)
{
if (!Categories.TryGetValue(identifier, out var value))
{
value = (Categories[identifier] = new MelonPreferences_Category(identifier, displayName ?? identifier)
{
IsHidden = is_hidden
});
}
return value;
}
public static MelonPreferences_Category GetCategory(string identifier)
{
if (!Categories.TryGetValue(identifier, out var value))
{
return null;
}
return value;
}
public static void Save()
{
ConfigFile config = MelonCompat.Config;
if (config != null)
{
config.Save();
}
}
}
public sealed class MelonPreferences_Category
{
public readonly List<MelonPreferences_Entry> Entries = new List<MelonPreferences_Entry>();
public string Identifier { get; }
public string DisplayName { get; }
public bool IsHidden { get; internal set; }
internal MelonPreferences_Category(string identifier, string displayName)
{
Identifier = identifier;
DisplayName = displayName;
}
public MelonPreferences_Entry<T> CreateEntry<T>(string identifier, T default_value, string display_name = null, string description = null, bool is_hidden = false, bool dont_save_default = false, ValueValidator validator = null, string oldIdentifier = null)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
{
DispName = (display_name ?? identifier),
Browsable = (!is_hidden && !IsHidden),
Order = -Entries.Count,
Category = DisplayName
};
AcceptableValueBase val = validator?.ToAcceptable(typeof(T));
ConfigEntry<T> cfg = MelonCompat.Config.Bind<T>(Identifier, identifier, default_value, new ConfigDescription(description ?? "", val, new object[1] { configurationManagerAttributes }));
MelonPreferences_Entry<T> melonPreferences_Entry = new MelonPreferences_Entry<T>(this, cfg, identifier, display_name ?? identifier, description, is_hidden);
Entries.Add(melonPreferences_Entry);
return melonPreferences_Entry;
}
public MelonPreferences_Entry GetEntry(string identifier)
{
return Entries.Find((MelonPreferences_Entry e) => e.Identifier == identifier);
}
public MelonPreferences_Entry<T> GetEntry<T>(string identifier)
{
return GetEntry(identifier) as MelonPreferences_Entry<T>;
}
public bool HasEntry(string identifier)
{
return GetEntry(identifier) != null;
}
public void SaveToFile(bool printmsg = true)
{
ConfigFile config = MelonCompat.Config;
if (config != null)
{
config.Save();
}
}
public void LoadFromFile(bool printmsg = true)
{
ConfigFile config = MelonCompat.Config;
if (config != null)
{
config.Reload();
}
}
}
public abstract class MelonPreferences_Entry
{
public readonly MelonEvent<object, object> OnEntryValueChangedUntyped = new MelonEvent<object, object>();
public MelonPreferences_Category Category { get; protected set; }
public string Identifier { get; protected set; }
public string DisplayName { get; protected set; }
public string Description { get; protected set; }
public bool IsHidden { get; protected set; }
public abstract ConfigEntryBase Raw { get; }
public abstract object BoxedValue { get; set; }
public abstract void ResetToDefault();
}
public sealed class MelonPreferences_Entry<T> : MelonPreferences_Entry
{
private readonly ConfigEntry<T> _cfg;
private T _last;
public readonly MelonEvent<T, T> OnEntryValueChanged = new MelonEvent<T, T>();
public readonly MelonEvent<T, T> OnValueChanged;
public T Value
{
get
{
return _cfg.Value;
}
set
{
_cfg.Value = value;
}
}
public T DefaultValue => (T)((ConfigEntryBase)_cfg).DefaultValue;
public override ConfigEntryBase Raw => (ConfigEntryBase)(object)_cfg;
public override object BoxedValue
{
get
{
return ((ConfigEntryBase)_cfg).BoxedValue;
}
set
{
((ConfigEntryBase)_cfg).BoxedValue = value;
}
}
internal MelonPreferences_Entry(MelonPreferences_Category category, ConfigEntry<T> cfg, string identifier, string displayName, string description, bool hidden)
{
base.Category = category;
_cfg = cfg;
base.Identifier = identifier;
base.DisplayName = displayName;
base.Description = description;
base.IsHidden = hidden;
OnValueChanged = OnEntryValueChanged;
_last = cfg.Value;
cfg.SettingChanged += OnSettingChanged;
}
private void OnSettingChanged(object sender, EventArgs e)
{
T last = _last;
_last = _cfg.Value;
if (!EqualityComparer<T>.Default.Equals(last, _last))
{
OnEntryValueChanged.Invoke(last, _last);
OnEntryValueChangedUntyped.Invoke(last, _last);
}
}
public override void ResetToDefault()
{
_cfg.Value = DefaultValue;
}
}
public sealed class MelonEvent<T1, T2>
{
private readonly List<Action<T1, T2>> _handlers = new List<Action<T1, T2>>();
public void Subscribe(Action<T1, T2> handler, int priority = 0, bool unsubscribeOnFirstInvocation = false)
{
_handlers.Add(handler);
}
public void Unsubscribe(Action<T1, T2> handler)
{
_handlers.Remove(handler);
}
internal void Invoke(T1 a, T2 b)
{
Action<T1, T2>[] array = _handlers.ToArray();
foreach (Action<T1, T2> action in array)
{
try
{
action(a, b);
}
catch (Exception ex)
{
Debug.LogError(Object.op_Implicit(ex.ToString()));
}
}
}
}
public sealed class ConfigurationManagerAttributes
{
public string DispName;
public bool? Browsable;
public int? Order;
public string Category;
}
}
namespace MelonLoader.Preferences
{
public abstract class ValueValidator
{
public abstract AcceptableValueBase ToAcceptable(Type type);
}
public sealed class ValueRange<T> : ValueValidator where T : IComparable
{
public T MinValue { get; }
public T MaxValue { get; }
public ValueRange(T min, T max)
{
MinValue = min;
MaxValue = max;
}
public override AcceptableValueBase ToAcceptable(Type type)
{
if (!(type == typeof(T)))
{
return null;
}
return (AcceptableValueBase)(object)new AcceptableValueRange<T>(MinValue, MaxValue);
}
}
}
namespace Il2CppTMPro
{
internal static class NamespaceStandIn
{
}
}
namespace Il2Cpp
{
internal static class NamespaceStandIn
{
}
}