using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Obeliskial_Essentials;
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("TheChosenOnes")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TheChosenOnes")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ed3050ba-b23a-4aa5-a306-bd1a8508543d")]
[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 TheChosenOnes;
public class GameConfig
{
public const string DefaultLootId = "thechosenshop";
public bool IsModEnabled => EnabledEntry?.Value ?? true;
public string InitialLootId => InitialLootIdEntry?.Value ?? "thechosenshop";
private ConfigEntry<string> InitialLootIdEntry { get; set; } = null;
private ConfigEntry<bool> EnabledEntry { get; set; } = null;
public GameConfig(ConfigEntry<string> initialLootIdEntry, ConfigEntry<bool> enabledEntry)
{
InitialLootIdEntry = initialLootIdEntry;
EnabledEntry = enabledEntry;
}
public GameConfig(ConfigFile config)
{
EnabledEntry = config.Bind<bool>("General", "EnableMod", true, "Enable or disable the mod");
InitialLootIdEntry = config.Bind<string>("General", "InitialLootIdx", "thechosenshop", "The loot list ID to have displayed once the game starts");
}
}
public class HaveInitialEquipmentsGivenUseCase : IUseCase
{
private bool equipsWereGiven = false;
public void DoIt()
{
if (GameProvider.Config.IsModEnabled && !((Object)(object)MapManager.Instance == (Object)null) && !((Object)(object)AtOManager.Instance == (Object)null))
{
if (AtOManager.Instance.currentMapNode != "sen_0")
{
GameProvider.Log.LogInfo((object)"reset initial equips for next gameplay");
equipsWereGiven = false;
}
else if (!equipsWereGiven)
{
equipsWereGiven = true;
GameProvider.Log.LogInfo((object)("current node = " + AtOManager.Instance.currentMapNode));
GameProvider.Log.LogInfo((object)("initial loot list = " + GameProvider.Config.InitialLootId));
GameProvider.Log.LogInfo((object)"offering initial loot");
AtOManager.Instance.DoLoot(GameProvider.Config.InitialLootId);
}
}
}
}
public interface IUseCase
{
void DoIt();
}
public static class GameProvider
{
public static ManualLogSource Log { get; set; }
public static GameConfig Config { get; set; }
}
[BepInPlugin("scotilen.thechosenones", "TheChosenOnes", "1.0.0")]
public class TheChosenOnesPlugin : BaseUnityPlugin
{
private static bool legendaryGiven;
public static ManualLogSource Log;
private void Awake()
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
GameProvider.Config = new GameConfig(((BaseUnityPlugin)this).Config);
GameProvider.Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"TheChosenOnes loaded");
Essentials.RegisterMod("TheChosenOnes", "Scotilen", "TheChosenOnes", "1.0.0", 20251216, "https://github.com/miguelcjalmeida/TheChosenOnes", (string[])null, "TheChosenOnes", 100, (string[])null, "", true);
new Harmony("scotilen.thechosenones").PatchAll();
}
}
[HarmonyPatch(typeof(MapManager), "Start")]
public static class MapManagerStartPatch
{
private static IUseCase useCase = new HaveInitialEquipmentsGivenUseCase();
public static void Postfix()
{
useCase.DoIt();
}
}