using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using Dungeonator;
using Gunfiguration;
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: AssemblyCompany("AdventurerMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AdventurerMod")]
[assembly: AssemblyTitle("AdventurerMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AdventurerMod;
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.tunombre.lostadventurer", "Lost Adventurer Mod", "1.0.0")]
public class LostAdventurerPlugin : BaseUnityPlugin
{
public const string GUID = "com.tunombre.lostadventurer";
public const string NAME = "Lost Adventurer Mod";
public const string VERSION = "1.0.0";
public const string KEY_SHOW_UI = "show_ui";
public const string KEY_SHOW_FLOOR = "show_floor";
public const string KEY_SHOW_PATCH_LOG = "show_patch_log";
public const string KEY_SHOW_BLUEPRINT = "show_blueprint";
public const string KEY_FORCE_FLOOR = "force_floor";
public static Gunfig Config;
public static string patchLog = "";
public static string blueprintLog = "";
private List<ValidTilesets> _helpedFloors = new List<ValidTilesets>();
private ValidTilesets _currentFloor;
private bool _cellGenerated;
private bool _currentFloorHelped;
private void Awake()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
ETGModConsole.Log((object)"Initialized Lost Adventurer Mod v1.0.0", false);
SetupGunfig();
new Harmony("com.tunombre.lostadventurer").PatchAll();
}
private void SetupGunfig()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
Config = Gunfig.Get(GunfigHelpers.WithColor("Lost Adventurer Mod", new Color(1f, 0.8f, 0.2f)));
Config.AddLabel(GunfigHelpers.Cyan("-- UI --"));
Config.AddToggle("show_ui", true, "Mostrar pisos ayudados", (Action<string, string>)null, (Update)1);
Config.AddToggle("show_floor", true, "Mostrar piso actual", (Action<string, string>)null, (Update)1);
Config.AddToggle("show_patch_log", true, "Mostrar patch log", (Action<string, string>)null, (Update)1);
Config.AddToggle("show_blueprint", true, "Mostrar blueprint log", (Action<string, string>)null, (Update)1);
Config.AddLabel(GunfigHelpers.Cyan("-- Forzar Aparicion --"));
Config.AddScrollBox("force_floor", new List<string> { "Ninguno", "Castle", "Gungeon", "Mines", "Catacombs", "Forge" }, "Forzar en piso", (Action<string, string>)null, new List<string> { "No forzar en ningun piso", "Forzar aparicion en Castillo", "Forzar aparicion en Gungeon", "Forzar aparicion en Minas", "Forzar aparicion en Catacumbas", "Forzar aparicion en Forja" }, (Update)0);
}
public static ValidTilesets? ForceFloorFromConfig()
{
return Config.Value("force_floor") switch
{
"Castle" => (ValidTilesets)2,
"Gungeon" => (ValidTilesets)1,
"Mines" => (ValidTilesets)16,
"Catacombs" => (ValidTilesets)32,
"Forge" => (ValidTilesets)64,
_ => null,
};
}
public static List<ValidTilesets> AllFloors()
{
return new List<ValidTilesets>
{
(ValidTilesets)2,
(ValidTilesets)1,
(ValidTilesets)16,
(ValidTilesets)32,
(ValidTilesets)64
};
}
public static List<ValidTilesets> GetFloorsHelpedList()
{
//IL_0027: 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_002f: 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_005c: Unknown result type (might be due to invalid IL or missing references)
List<ValidTilesets> list = new List<ValidTilesets>();
if (GameStatsManager.Instance == null)
{
return list;
}
foreach (ValidTilesets item in AllFloors())
{
GungeonFlags? val = FlagFromFloor(item);
if (val.HasValue && GameStatsManager.Instance.GetFlag(val.Value))
{
list.Add(item);
}
}
return list;
}
public static int GetFloorsHelped()
{
return GetFloorsHelpedList().Count;
}
public static GungeonFlags? FlagFromFloor(ValidTilesets floor)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: 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_0007: Invalid comparison between Unknown and I4
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
if ((int)floor <= 2)
{
if ((int)floor == 1)
{
return (GungeonFlags)24515;
}
if ((int)floor == 2)
{
return (GungeonFlags)24510;
}
}
else
{
if ((int)floor == 16)
{
return (GungeonFlags)24520;
}
if ((int)floor == 32)
{
return (GungeonFlags)24525;
}
if ((int)floor == 64)
{
return (GungeonFlags)24530;
}
}
return null;
}
public static string FloorName(ValidTilesets floor)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: 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_0007: Invalid comparison between Unknown and I4
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
ValidTilesets val = floor;
ValidTilesets val2 = val;
if ((int)val2 <= 2)
{
if ((int)val2 == 1)
{
return "Gungeon";
}
if ((int)val2 == 2)
{
return "Castle";
}
}
else
{
if ((int)val2 == 16)
{
return "Mines";
}
if ((int)val2 == 32)
{
return "Catacombs";
}
if ((int)val2 == 64)
{
return "Forge";
}
}
return ((object)(ValidTilesets)(ref floor)).ToString();
}
private void Update()
{
//IL_0054: 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_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)GameManager.Instance == (Object)null) && !((Object)(object)GameManager.Instance.BestGenerationDungeonPrefab == (Object)null) && GameStatsManager.Instance != null)
{
_helpedFloors = GetFloorsHelpedList();
_currentFloor = GameManager.Instance.BestGenerationDungeonPrefab.tileIndices.tilesetId;
_cellGenerated = MetaInjectionData.CellGeneratedForCurrentBlueprint;
GungeonFlags? val = FlagFromFloor(_currentFloor);
_currentFloorHelped = val.HasValue && GameStatsManager.Instance.GetFlag(val.Value);
}
}
private void OnGUI()
{
//IL_0039: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_006b: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Expected O, but got Unknown
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Expected O, but got Unknown
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Expected O, but got Unknown
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Expected O, but got Unknown
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
if (Config == null)
{
return;
}
float num = 10f;
if (Config.Enabled("show_ui"))
{
GUIStyle val = new GUIStyle(GUI.skin.label)
{
fontSize = 18,
fontStyle = (FontStyle)1
};
val.normal.textColor = Color.green;
GUIStyle val2 = val;
GUIStyle val3 = new GUIStyle(GUI.skin.label)
{
fontSize = 18,
fontStyle = (FontStyle)1
};
val3.normal.textColor = Color.red;
GUIStyle val4 = val3;
float num2 = 10f;
foreach (ValidTilesets item in AllFloors())
{
bool flag = _helpedFloors.Contains(item);
GUI.Label(new Rect(num2, num, 130f, 24f), (flag ? "✓ " : "✗ ") + FloorName(item), flag ? val2 : val4);
num2 += 140f;
}
num += 28f;
}
if (Config.Enabled("show_floor"))
{
GUIStyle val5 = new GUIStyle(GUI.skin.label)
{
fontSize = 14
};
val5.normal.textColor = Color.yellow;
GUIStyle val6 = val5;
GUI.Label(new Rect(10f, num, 900f, 22f), $"Floor: {_currentFloor} | Ayudados: {_helpedFloors.Count}/5 | CellGen: {_cellGenerated} | FloorHelped: {_currentFloorHelped}", val6);
num += 26f;
}
if (Config.Enabled("show_patch_log") && !string.IsNullOrEmpty(patchLog))
{
GUIStyle val7 = new GUIStyle(GUI.skin.label)
{
fontSize = 13
};
val7.normal.textColor = Color.cyan;
GUIStyle val8 = val7;
GUI.Label(new Rect(10f, num, 1200f, 22f), patchLog, val8);
num += 24f;
}
if (Config.Enabled("show_blueprint") && !string.IsNullOrEmpty(blueprintLog))
{
GUIStyle val9 = new GUIStyle(GUI.skin.label)
{
fontSize = 13
};
val9.normal.textColor = Color.white;
GUIStyle val10 = val9;
GUI.Label(new Rect(10f, num, 1200f, 22f), blueprintLog, val10);
}
}
}
[HarmonyPatch]
public static class ShouldDoLostAdventurerHelpPatch
{
private static MethodBase TargetMethod()
{
return typeof(LoopFlowBuilder).GetMethod("ShouldDoLostAdventurerHelp", BindingFlags.Instance | BindingFlags.NonPublic);
}
private static void Prefix(SharedInjectionData injectionData)
{
//IL_0033: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Invalid comparison between Unknown and I4
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)GameManager.Instance == (Object)null || GameStatsManager.Instance == null)
{
return;
}
ValidTilesets tilesetId = GameManager.Instance.BestGenerationDungeonPrefab.tileIndices.tilesetId;
if ((int)tilesetId != 64)
{
return;
}
string text = "Blueprint Forge: ";
if (MetaInjectionData.CurrentRunBlueprint != null && MetaInjectionData.CurrentRunBlueprint.ContainsKey((ValidTilesets)64))
{
foreach (RuntimeInjectionMetadata item in MetaInjectionData.CurrentRunBlueprint[(ValidTilesets)64])
{
text = text + "[" + ((Object)item.injectionData).name + "] ";
}
}
else
{
text += "SIN ENTRIES";
}
LostAdventurerPlugin.blueprintLog = text;
int floorsHelped = LostAdventurerPlugin.GetFloorsHelped();
bool flag = GameStatsManager.Instance.GetFlag((GungeonFlags)24530);
string text2 = "";
for (int i = 0; i < injectionData.InjectionData.Count; i++)
{
text2 += $"[{i}:{injectionData.InjectionData[i].annotation}] ";
}
ETGModConsole.Log((object)(LostAdventurerPlugin.patchLog = $"[PATCH] Floor:{tilesetId} | ConditionMet:{floorsHelped == 4 && !flag} | Annotations: {text2}"), false);
}
}
[HarmonyPatch]
public static class ProcessSingleNodeInjectionPatch
{
private static MethodBase TargetMethod()
{
return typeof(LoopFlowBuilder).GetMethod("ProcessSingleNodeInjection", BindingFlags.Instance | BindingFlags.NonPublic);
}
private static void Prefix(object __instance, ProceduralFlowModifierData currentInjectionData, BuilderFlowNode root, RuntimeInjectionFlags injectionFlags, FlowCompositeMetastructure metastructure, RuntimeInjectionMetadata optionalMetadata)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: 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_017f: Unknown result type (might be due to invalid IL or missing references)
if (currentInjectionData == null || currentInjectionData.annotation != "lost adventurer" || (Object)(object)GameManager.Instance == (Object)null || GameStatsManager.Instance == null || LostAdventurerPlugin.Config == null)
{
return;
}
ValidTilesets tilesetId = GameManager.Instance.BestGenerationDungeonPrefab.tileIndices.tilesetId;
ValidTilesets? val = LostAdventurerPlugin.ForceFloorFromConfig();
object arg = tilesetId;
object arg2;
if (!val.HasValue)
{
arg2 = "null";
}
else
{
ValidTilesets value = val.Value;
arg2 = ((object)(ValidTilesets)(ref value)).ToString();
}
ETGModConsole.Log((object)$"[PATCH] Prefix | floor:{arg} | forceFloor:{arg2} | chanceToSpawn:{currentInjectionData.chanceToSpawn}", false);
if (!val.HasValue || tilesetId != val.Value)
{
return;
}
GungeonFlags? val2 = LostAdventurerPlugin.FlagFromFloor(tilesetId);
if ((!val2.HasValue || !GameStatsManager.Instance.GetFlag(val2.Value)) && LostAdventurerPlugin.GetFloorsHelped() == 4)
{
if (optionalMetadata?.SucceededRandomizationCheckMap != null && optionalMetadata.SucceededRandomizationCheckMap.ContainsKey(currentInjectionData))
{
optionalMetadata.SucceededRandomizationCheckMap.Remove(currentInjectionData);
ETGModConsole.Log((object)"[PATCH] Cache limpiado", false);
}
currentInjectionData.chanceToSpawn = 1f;
object arg3 = tilesetId;
PrototypeDungeonRoom exactRoom = currentInjectionData.exactRoom;
ETGModConsole.Log((object)(LostAdventurerPlugin.patchLog = string.Format("[PATCH] chanceToSpawn=1 forzado | floor:{0} | room:{1}", arg3, ((exactRoom != null) ? ((Object)exactRoom).name : null) ?? "NULL")), false);
}
}
private static void Postfix(bool __result, ProceduralFlowModifierData currentInjectionData)
{
if (currentInjectionData != null && !(currentInjectionData.annotation != "lost adventurer"))
{
ETGModConsole.Log((object)(LostAdventurerPlugin.patchLog = $"[PATCH] RESULT:{__result} | chanceToSpawn:{currentInjectionData.chanceToSpawn}"), false);
}
}
}