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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RelicsBeforeRun")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RelicsBeforeRun")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8a1a804a-aa20-4af7-8d8b-ee03c513a9c3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MagicraftGameMod_01
{
[BepInPlugin("com.sybaritte.RelicsBeforeRun", "RelicsBeforeRun", "1.0.0")]
public class ModeBase : BaseUnityPlugin
{
private const string MyGUID = "com.sybaritte.RelicsBeforeRun";
private const string PluginName = "RelicsBeforeRun";
private const string VersionString = "1.0.0";
private static readonly Harmony Harmony = new Harmony("com.sybaritte.RelicsBeforeRun");
public static ManualLogSource Log = new ManualLogSource("RelicsBeforeRun");
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: RelicsBeforeRun, VersionString: 1.0.0 is loading...");
Harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: RelicsBeforeRun, VersionString: 1.0.0 is loaded.");
Log = ((BaseUnityPlugin)this).Logger;
}
}
}
namespace MagicraftGameMod_01.Utils
{
internal static class ModUtils
{
}
}
namespace MagicraftGameMod_01.Patches
{
[HarmonyPatch(typeof(PlayerItemController))]
internal class PlayerItemControllerPatches
{
private static bool _isRunStarted = false;
private static List<int> _relicIds = new List<int>();
private static readonly List<int> _relicIdsToCheck = new List<int> { 936, 931, 932, 933, 934, 935, 937, 38 };
[HarmonyPatch("RelicAdd")]
[HarmonyPostfix]
public static void RelicAdd_Postfix(int id, bool addGallery, bool fromLoadSave)
{
if (!_isRunStarted && !_relicIdsToCheck.Contains(id))
{
_relicIds.Add(id);
ModeBase.Log.LogInfo((object)$"Relic Add. ID:{id}. Relics count: {_relicIds.Count}");
}
}
[HarmonyPatch(typeof(BattleMgr))]
[HarmonyPatch("Start_Normal")]
[HarmonyPostfix]
public static void StartRun_Postfix()
{
ModeBase.Log.LogInfo((object)"Start new run");
_isRunStarted = true;
string text = "";
PlayerItemController val = Object.FindObjectOfType<PlayerItemController>();
if ((Object)(object)val == (Object)null)
{
ModeBase.Log.LogError((object)"PlayerItemController instance not found!");
return;
}
foreach (int relicId in _relicIds)
{
text += $" {relicId}";
MethodInfo methodInfo = AccessTools.Method(typeof(PlayerItemController), "RelicAdd", (Type[])null, (Type[])null);
if (methodInfo != null)
{
methodInfo.Invoke(val, new object[3] { relicId, false, false });
}
}
ModeBase.Log.LogInfo((object)("Added Relics IDs: " + text));
_relicIds.Clear();
}
[HarmonyPatch(typeof(CampMgr))]
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartCamp_Postfix()
{
ModeBase.Log.LogInfo((object)"Start camp");
_isRunStarted = false;
_relicIds.Clear();
}
[HarmonyPatch(typeof(UITraining))]
[HarmonyPatch("_Recover")]
[HarmonyPostfix]
public static void TrainingRecover_Postfix()
{
_relicIds.Clear();
ModeBase.Log.LogInfo((object)$"Relics cleared. Relics count: {_relicIds.Count}");
}
}
}
namespace MagicraftGameMod_01.MonoBehaviours
{
internal class MagicraftGameMod_01Component : MonoBehaviour
{
public void Awake()
{
}
public void Start()
{
}
public void Update()
{
}
public void LateUpdate()
{
}
}
}