using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RelicsBeforeRun")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RelicsBeforeRun")]
[assembly: AssemblyTitle("RelicsBeforeRun")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MagicraftGameMod_01
{
[BepInPlugin("com.sybaritte.GrabYaRelics", "GrabYaRelics", "2.0.0")]
public class ModeBase : BasePlugin
{
private static readonly Harmony Harmony = new Harmony("com.sybaritte.RelicsBeforeRun");
internal static ManualLogSource Log;
public override void Load()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
Log.LogInfo((object)"PluginName: RelicsBeforeRun, VersionString: 2.0.0 is loading...");
ClassInjector.RegisterTypeInIl2Cpp<RelicsQueueUI>();
GameObject val = new GameObject("RelicsQueueUI");
val.AddComponent<RelicsQueueUI>();
Object.DontDestroyOnLoad((Object)(object)val);
Harmony.PatchAll();
Log.LogInfo((object)"PluginName: RelicsBeforeRun, VersionString: 2.0.0 is loaded.");
}
}
internal static class RelicState
{
internal const int MaxRelics = 3;
internal static bool IsInGame = false;
internal static bool IsRunStarted = false;
internal static PlayerItemController CachedController = null;
internal static readonly Dictionary<int, int> QueuedRelics = new Dictionary<int, int>();
internal static readonly HashSet<int> IgnoredIds = new HashSet<int> { 936, 931, 932, 933, 934, 935, 937, 38 };
internal static int TotalQueued
{
get
{
int num = 0;
foreach (int value in QueuedRelics.Values)
{
num += value;
}
return num;
}
}
}
internal class RelicsQueueUI : MonoBehaviour
{
private static GUIStyle _boxStyle;
private static GUIStyle _headerStyle;
private static GUIStyle _entryStyle;
private static bool _stylesInit;
public RelicsQueueUI(IntPtr ptr)
: base(ptr)
{
}
private void InitStyles()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_002b: 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_004e: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_006f: 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_0091: Expected O, but got Unknown
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
_boxStyle = new GUIStyle();
_boxStyle.normal.background = MakeTex(1, 1, new Color(0f, 0f, 0f, 0.65f));
_boxStyle.padding = new RectOffset(8, 8, 6, 6);
_headerStyle = new GUIStyle();
_headerStyle.fontStyle = (FontStyle)1;
_headerStyle.normal.textColor = Color.white;
_headerStyle.fontSize = 13;
_entryStyle = new GUIStyle();
_entryStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
_entryStyle.fontSize = 12;
_stylesInit = true;
}
private static Texture2D MakeTex(int width, int height, Color col)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(width, height);
Il2CppStructArray<Color> pixels = val.GetPixels();
for (int i = 0; i < ((Il2CppArrayBase<Color>)(object)pixels).Length; i++)
{
((Il2CppArrayBase<Color>)(object)pixels)[i] = col;
}
val.SetPixels(pixels);
val.Apply();
return val;
}
private void OnGUI()
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
if (!RelicState.IsInGame || RelicState.IsRunStarted)
{
return;
}
if (!_stylesInit)
{
InitStyles();
}
int totalQueued = RelicState.TotalQueued;
int count = RelicState.QueuedRelics.Count;
float num = 36 + count * 22 + 10;
float num2 = 240f;
Rect val = default(Rect);
((Rect)(ref val))..ctor(1468f, 8f, num2, num);
GUI.Box(val, GUIContent.none, _boxStyle);
GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 8f, ((Rect)(ref val)).y + 6f, ((Rect)(ref val)).width - 16f, ((Rect)(ref val)).height - 8f));
GUILayout.Label($"Queued Relics {totalQueued} / {3}", _headerStyle, Array.Empty<GUILayoutOption>());
if (count == 0)
{
GUILayout.Label(" No relics queued", _entryStyle, Array.Empty<GUILayoutOption>());
}
else
{
foreach (KeyValuePair<int, int> queuedRelic in RelicState.QueuedRelics)
{
string relicName = GetRelicName(queuedRelic.Key);
string text = ((queuedRelic.Value > 1) ? $" x{queuedRelic.Value}" : "");
GUILayout.Label(" • " + relicName + text, _entryStyle, Array.Empty<GUILayoutOption>());
}
}
GUILayout.EndArea();
}
private static string GetRelicName(int id)
{
try
{
Dictionary<int, RelicConfig> dic = RelicConfig.dic;
if (dic != null && dic.ContainsKey(id))
{
return dic[id].GetName(true);
}
}
catch
{
}
return $"Relic {id}";
}
}
}
namespace MagicraftGameMod_01.Patches
{
[HarmonyPatch(typeof(PlayerItemController), "Awake")]
internal class Patch_PlayerItemController_Awake
{
private static void Postfix(PlayerItemController __instance)
{
RelicState.CachedController = __instance;
ModeBase.Log.LogInfo((object)"PlayerItemController cached.");
}
}
[HarmonyPatch(typeof(PlayerItemController), "RelicAdd")]
internal class Patch_PlayerItemController_RelicAdd
{
private static void Postfix(int id)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
if (RelicState.IsRunStarted || RelicState.IgnoredIds.Contains(id))
{
return;
}
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val;
if (RelicState.TotalQueued >= 3)
{
ManualLogSource log = ModeBase.Log;
val = new BepInExInfoLogInterpolatedStringHandler(37, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Relic queue full (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(3);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(3);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("). ID:");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(id);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" not queued.");
}
log.LogInfo(val);
return;
}
if (RelicState.QueuedRelics.ContainsKey(id))
{
RelicState.QueuedRelics[id]++;
}
else
{
RelicState.QueuedRelics[id] = 1;
}
ManualLogSource log2 = ModeBase.Log;
val = new BepInExInfoLogInterpolatedStringHandler(29, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Relic queued. ID:");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(id);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" x");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(RelicState.QueuedRelics[id]);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Total: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(RelicState.TotalQueued);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(3);
}
log2.LogInfo(val);
}
}
[HarmonyPatch(typeof(BattleMgr), "Start_Normal")]
internal class Patch_BattleMgr_StartNormal
{
private static void Postfix()
{
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Expected O, but got Unknown
ModeBase.Log.LogInfo((object)"Run started — applying queued relics.");
RelicState.IsRunStarted = true;
if ((Object)(object)RelicState.CachedController == (Object)null)
{
ModeBase.Log.LogError((object)"PlayerItemController not cached — queued relics could not be applied.");
return;
}
string text = "";
foreach (KeyValuePair<int, int> queuedRelic in RelicState.QueuedRelics)
{
for (int i = 0; i < queuedRelic.Value; i++)
{
RelicState.CachedController.RelicAdd(queuedRelic.Key, true, false);
}
text += $" {queuedRelic.Key}x{queuedRelic.Value}";
}
ManualLogSource log = ModeBase.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(8, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Applied:");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
}
log.LogInfo(val);
RelicState.QueuedRelics.Clear();
}
}
[HarmonyPatch(typeof(CampMgr), "Start")]
internal class Patch_CampMgr_Start
{
private static void Postfix()
{
ModeBase.Log.LogInfo((object)"Returned to camp — resetting run state.");
RelicState.IsInGame = true;
RelicState.IsRunStarted = false;
RelicState.QueuedRelics.Clear();
}
}
[HarmonyPatch(typeof(CampMgr), "OnDestroy")]
internal class Patch_CampMgr_OnDestroy
{
private static void Postfix()
{
ModeBase.Log.LogInfo((object)"Camp destroyed.");
RelicState.IsInGame = false;
RelicState.CachedController = null;
}
}
[HarmonyPatch(typeof(MainMenuMgr), "Start")]
internal class Patch_MainMenuMgr_Start
{
private static void Postfix()
{
ModeBase.Log.LogInfo((object)"Main menu loaded — clearing all state.");
RelicState.IsInGame = false;
RelicState.IsRunStarted = false;
RelicState.CachedController = null;
RelicState.QueuedRelics.Clear();
}
}
[HarmonyPatch(typeof(UITraining), "_Recover")]
internal class Patch_UITraining_Recover
{
private static void Postfix()
{
RelicState.QueuedRelics.Clear();
ModeBase.Log.LogInfo((object)"Training reset — relic queue cleared.");
}
}
}