Decompiled source of Once More Into The Breach v1.31.0

MakingAnItem.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using Alexandria.Assetbundle;
using Alexandria.BreakableAPI;
using Alexandria.CharacterAPI;
using Alexandria.ChestAPI;
using Alexandria.DungeonAPI;
using Alexandria.EnemyAPI;
using Alexandria.ItemAPI;
using Alexandria.Misc;
using Alexandria.NPCAPI;
using Alexandria.TranslationAPI;
using Alexandria.VisualAPI;
using BepInEx;
using BepInEx.Bootstrap;
using Brave.BulletScript;
using Dungeonator;
using FullSerializer;
using Gunfiguration;
using Gungeon;
using GungeonAPI;
using HarmonyLib;
using HutongGames.PlayMaker;
using InControl;
using MonoMod.RuntimeDetour;
using Pathfinding;
using SaveAPI;
using UnityEngine;
using UnityEngine.Rendering;
using tk2dRuntime.TileMap;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NevernamedsItems")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NevernamedsItems")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d851ff74-c4b3-47c1-9ecc-ad359ebf9b93")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public class EnemyGuidDatabase
{
	public static Dictionary<string, string> Entries { get; set; } = new Dictionary<string, string>
	{
		{ "bullet_kin", "01972dee89fc4404a5c408d50007dad5" },
		{ "ak47_bullet_kin", "db35531e66ce41cbb81d507a34366dfe" },
		{ "bandana_bullet_kin", "88b6b6a93d4b4234a67844ef4728382c" },
		{ "veteran_bullet_kin", "70216cae6c1346309d86d4a0b4603045" },
		{ "treadnaughts_bullet_kin", "df7fb62405dc4697b7721862c7b6b3cd" },
		{ "minelet", "3cadf10c489b461f9fb8814abc1a09c1" },
		{ "cardinal", "8bb5578fba374e8aae8e10b754e61d62" },
		{ "shroomer", "e5cffcfabfae489da61062ea20539887" },
		{ "ashen_bullet_kin", "1a78cfb776f54641b832e92c44021cf2" },
		{ "mutant_bullet_kin", "d4a9836f8ab14f3fadd0f597438b1f1f" },
		{ "fallen_bullet_kin", "5f3abc2d561b4b9c9e72b879c6f10c7e" },
		{ "hooded_bullet", "844657ad68894a4facb1b8e1aef1abf9" },
		{ "office_bullet_kin", "906d71ccc1934c02a6f4ff2e9c07c9ec" },
		{ "office_bullette_kin", "9eba44a0ea6c4ea386ff02286dd0e6bd" },
		{ "brollet", "05cb719e0178478685dc610f8b3e8bfc" },
		{ "western_bullet_kin", "5861e5a077244905a8c25c2b7b4d6ebb" },
		{ "pirate_bullet_kin", "6f818f482a5c47fd8f38cce101f6566c" },
		{ "armored_bullet_kin", "39e6f47a16ab4c86bec4b12984aece4c" },
		{ "key_bullet_kin", "699cd24270af4cd183d671090d8323a1" },
		{ "chance_bullet_kin", "a446c626b56d4166915a4e29869737fd" },
		{ "hollowpoint", "4db03291a12144d69fe940d5a01de376" },
		{ "spectre", "56f5a0f2c1fc4bc78875aea617ee31ac" },
		{ "skullet", "336190e29e8a4f75ab7486595b700d4a" },
		{ "skullmet", "95ec774b5a75467a9ab05fa230c0c143" },
		{ "gummy", "5288e86d20184fa69c91ceb642d31474" },
		{ "spent", "249db525a9464e5282d02162c88e0357" },
		{ "gummy_spent", "e21ac9492110493baef6df02a2682a0d" },
		{ "red_shotgun_kin", "128db2f0781141bcb505d8f00f9e4d47" },
		{ "blue_shotgun_kin", "b54d89f9e802455cbb2b8a96a31e8259" },
		{ "veteran_shotgun_kin", "2752019b770f473193b08b4005dc781f" },
		{ "mutant_shotgun_kin", "7f665bd7151347e298e4d366f8818284" },
		{ "executioner", "b1770e0f1c744d9d887cc16122882b4f" },
		{ "ashen_shotgun_kin", "1bd8e49f93614e76b140077ff2e33f2b" },
		{ "shotgrub", "044a9f39712f456597b9762893fbc19c" },
		{ "creech", "37340393f97f41b2822bc02d14654172" },
		{ "western_shotgun_kin", "ddf12a4881eb43cfba04f36dd6377abb" },
		{ "pirate_shotgun_kin", "86dfc13486ee4f559189de53cfb84107" },
		{ "blobulon", "0239c0680f9f467dbe5c4aab7dd1eca6" },
		{ "blobuloid", "042edb1dfb614dc385d5ad1b010f2ee3" },
		{ "blobulin", "42be66373a3d4d89b91a35c9ff8adfec" },
		{ "poisbulon", "e61cab252cfb435db9172adc96ded75f" },
		{ "poisbuloid", "fe3fe59d867347839824d5d9ae87f244" },
		{ "poisbulin", "b8103805af174924b578c98e95313074" },
		{ "blizzbulon", "022d7c822bc146b58fe3b0287568aaa2" },
		{ "leadbulon", "ccf6d241dad64d989cbcaca2a8477f01" },
		{ "bloodbulon", "062b9b64371e46e195de17b6f10e47c8" },
		{ "poopulon", "116d09c26e624bca8cca09fc69c714b3" },
		{ "cubulon", "864ea5a6a9324efc95a0dd2407f42810" },
		{ "cubulead", "0b547ac6b6fc4d68876a241a88f5ca6a" },
		{ "chancebulon", "1bc2a07ef87741be90c37096910843ab" },
		{ "skusket", "af84951206324e349e1f13f9b7b60c1a" },
		{ "black_skusket", "1cec0cdf383e42b19920787798353e46" },
		{ "skusket_head", "c2f902b7cbe745efb3db4399927eab34" },
		{ "shelleton", "21dd14e5ca2a4a388adab5b11b69a1e1" },
		{ "revolvenant", "d5a7b95774cd41f080e517bea07bf495" },
		{ "gunreaper", "88f037c3f93b4362a040a87b30770407" },
		{ "bullat", "2feb50a6a40f4f50982e89fd276f6f15" },
		{ "shotgat", "2d4f8b5404614e7d8b235006acde427a" },
		{ "grenat", "b4666cb6ef4f4b038ba8924fd8adf38f" },
		{ "spirat", "7ec3e8146f634c559a7d58b19191cd43" },
		{ "king_bullat", "1a4872dafdb34fd29fe8ac90bd2cea67" },
		{ "gargoyle", "981d358ffc69419bac918ca1bdf0c7f7" },
		{ "apprentice_gunjurer", "206405acad4d4c33aac6717d184dc8d4" },
		{ "gunjurer", "c4fba8def15e47b297865b18e36cbef8" },
		{ "high_gunjurer", "9b2cf2949a894599917d4d391a0b7394" },
		{ "lore_gunjurer", "56fb939a434140308b8f257f0f447829" },
		{ "bookllet", "c0ff3744760c4a2eb0bb52ac162056e6" },
		{ "blue_bookllet", "6f22935656c54ccfb89fca30ad663a64" },
		{ "green_bookllet", "a400523e535f41ac80a43ff6b06dc0bf" },
		{ "necronomicon", "216fd3dfb9da439d9bd7ba53e1c76462" },
		{ "tablet_bookllett", "78e0951b097b46d89356f004dda27c42" },
		{ "mountain_cube", "f155fd2759764f4a9217db29dd21b7eb" },
		{ "lead_cube", "33b212b856b74ff09252bf4f2e8b8c57" },
		{ "flesh_cube", "3f2026dc3712490289c4658a2ba4a24b" },
		{ "brown_chest_mimic", "2ebf8ef6728648089babb507dec4edb7" },
		{ "blue_chest_mimic", "d8d651e3484f471ba8a2daa4bf535ce6" },
		{ "green_chest_mimic", "abfb454340294a0992f4173d6e5898a8" },
		{ "red_chest_mimic", "d8fd592b184b4ac9a3be217bc70912a2" },
		{ "black_chest_mimic", "6450d20137994881aff0ddd13e3d40c8" },
		{ "rat_chest_mimic", "ac9d345575444c9a8d11b799e8719be0" },
		{ "pedestal_mimic", "796a7ed4ad804984859088fc91672c7f" },
		{ "wall_mimic", "479556d05c7c44f3b6abb3b2067fc778" },
		{ "gun_nut", "ec8ea75b557d4e7b8ceeaacdf6f8238c" },
		{ "chain_gunner", "463d16121f884984abe759de38418e48" },
		{ "spectral_gun_nut", "383175a55879441d90933b5c4e60cf6f" },
		{ "det", "ac986dabc5a24adab11d48a4bccf4cb1" },
		{ "x_det", "48d74b9c65f44b888a94f9e093554977" },
		{ "diagonal_x_det", "c5a0fd2774b64287bf11127ca59dd8b4" },
		{ "vertical_det", "b67ffe82c66742d1985e5888fd8e6a03" },
		{ "diagonal_det", "d9632631a18849539333a92332895ebd" },
		{ "horizontal_det", "1898f6fe1ee0408e886aaf05c23cc216" },
		{ "vertical_x_det", "abd816b0bcbf4035b95837ca931169df" },
		{ "horizontal_x_det", "07d06d2b23cc48fe9f95454c839cb361" },
		{ "gunsinger", "cf2b7021eac44e3f95af07db9a7c442c" },
		{ "aged_gunsinger", "c50a862d19fc4d30baeba54795e8cb93" },
		{ "ammomancer", "b1540990a4f1480bbcb3bea70d67f60d" },
		{ "jammomancer", "8b4a938cdbc64e64822e841e482ba3d2" },
		{ "jamerlengo", "ba657723b2904aa79f9e51bce7d23872" },
		{ "gun_cultist", "57255ed50ee24794b7aac1ac3cfb8a95" },
		{ "gat", "9b4fb8a2a60a457f90dcf285d34143ac" },
		{ "grey_cylinder", "d4f4405e0ff34ab483966fd177f2ece3" },
		{ "red_cylinder", "534f1159e7cf4f6aa00aeea92459065e" },
		{ "bullet_mech", "2b6854c0849b4b8fb98eb15519d7db1c" },
		{ "grenade_kin", "4d37ce3d666b4ddda8039929225b7ede" },
		{ "dynamite_kin", "c0260c286c8d4538a697c5bf24976ccf" },
		{ "bombshee", "19b420dec96d4e9ea4aebc3398c0ba7a" },
		{ "m80_kin", "5f15093e6f684f4fb09d3e7e697216b4" },
		{ "rubber_kin", "6b7ef9e5d05b4f96b04f05ef4a0d1b18" },
		{ "tazie", "98fdf153a4dd4d51bf0bafe43f3c77ff" },
		{ "sniper_shell", "31a3ea0c54a745e182e22ea54844a82d" },
		{ "professional", "c5b11bfc065d417b9c4d03a5e385fe2c" },
		{ "muzzle_wisp", "ffdc8680bdaa487f8f31995539f74265" },
		{ "muzzle_flare", "d8a445ea4d944cc1b55a40f22821ae69" },
		{ "wizbang", "43426a2e39584871b287ac31df04b544" },
		{ "coaler", "9d50684ce2c044e880878e86dbada919" },
		{ "fungun", "f905765488874846b7ff257ff81d6d0c" },
		{ "bullet_shark", "72d2f44431da43b8a3bae7d8a114a46d" },
		{ "arrow_head", "05891b158cd542b1a5f3df30fb67a7ff" },
		{ "pot_fairy", "c182a5cb704d460d9d099a47af49c913" },
		{ "musketball", "226fd90be3a64958a5b13cb0a4f43e97" },
		{ "western_cactus", "3b0bd258b4c9432db3339665cc61c356" },
		{ "candle_kin", "37de0df92697431baa47894a075ba7e9" },
		{ "gigi", "ed37fa13e0fa4fcf8239643957c51293" },
		{ "misfire_beast", "45192ff6d6cb43ed8f1a874ab6bef316" },
		{ "phaser_spider", "98ca70157c364750a60f5e0084f9d3e2" },
		{ "gunzookie", "6e972cd3b11e4b429b888b488e308551" },
		{ "gunzockie", "8a9e9bedac014a829a48735da6daf3da" },
		{ "chameleon", "80ab6cd15bfc46668a8844b2975c6c26" },
		{ "bird_parrot", "4b21a913e8c54056bc05cafecf9da880" },
		{ "western_snake", "e861e59012954ab2b9b6977da85cb83c" },
		{ "kalibullet", "ff4f54ce606e4604bf8d467c1279be3e" },
		{ "kbullet", "f020570a42164e2699dcf57cac8a495c" },
		{ "blue_fish_bullet_kin", "06f5623a351c4f28bc8c6cda56004b80" },
		{ "green_fish_bullet_kin", "143be8c9bbb84e3fb3ab98bcd4cf5e5b" },
		{ "tarnisher", "475c20c1fd474dfbad54954e7cba29c1" },
		{ "agonizer", "3f6d6b0c4a7c4690807435c7b37c35a5" },
		{ "lead_maiden", "cd4a4b7f612a4ba9a720b9f97c52f38c" },
		{ "grip_master", "22fc2c2c45fb47cf9fb5f7b043a70122" },
		{ "shambling_round", "98ea2fe181ab4323ab6e9981955a9bca" },
		{ "great_bullet_shark", "b70cbd875fea498aa7fd14b970248920" },
		{ "killithid", "3e98ccecf7334ff2800188c417e67c15" },
		{ "spogre", "eed5addcc15148179f300cc0d9ee7f94" },
		{ "fridge_maiden", "9215d1a221904c7386b481a171e52859" },
		{ "titan_bullet_kin", "c4cf0620f71c4678bb8d77929fd4feff" },
		{ "titan_bullet_kin_boss", "1f290ea06a4c416cabc52d6b3cf47266" },
		{ "titaness_bullet_kin_boss", "df4e9fedb8764b5a876517431ca67b86" },
		{ "beadie", "7b0b1b6d9ce7405b86b75ce648025dd6" },
		{ "tombstoner", "cf27dd464a504a428d87a8b2560ad40a" },
		{ "ammoconda_ball", "f38686671d524feda75261e469f30e0b" },
		{ "summoned_treadnaughts_bullet_kin", "47bdfec22e8e4568a619130a267eab5b" },
		{ "mine_flayers_bell", "78a8ee40dff2477e9c2134f6990ef297" },
		{ "mine_flayers_claymore", "566ecca5f3b04945ac6ce1f26dedbf4f" },
		{ "candle_guy", "eeb33c3a5a8e4eaaaaf39a743e8767bc" },
		{ "bullet_kings_toadie", "b5e699a0abb94666bda567ab23bd91c4" },
		{ "bullet_kings_toadie_revenge", "d4dd2b2bbda64cc9bcec534b4e920518" },
		{ "old_kings_toadie", "02a14dec58ab45fb8aacde7aacd25b01" },
		{ "fusebot", "4538456236f64ea79f483784370bc62f" },
		{ "mouser", "be0683affb0e41bbb699cb7125fdded6" },
		{ "draguns_knife", "78eca975263d4482a4bfa4c07b32e252" },
		{ "dragun_knife_advanced", "2e6223e42e574775b56c6349921f42cb" },
		{ "marines_past_imp", "a9cc6a4e9b3d46ea871e70a03c9f77d4" },
		{ "convicts_past_soldier", "556e9f2a10f9411cb9dbfd61e0e0f1e1" },
		{ "robots_past_terminator", "12a054b8a6e549dcac58a82b89e319e5" },
		{ "blockner", "bb73eeeb9e584fbeaf35877ec176de28" },
		{ "blockner_rematch", "edc61b105ddd4ce18302b82efdc47178" },
		{ "fuselier", "39de9bd6a863451a97906d949c103538" },
		{ "shadow_agunim", "db97e486ef02425280129e1e27c33118" },
		{ "gatling_gull", "ec6b674e0acd4553b47ee94493d66422" },
		{ "bullet_king", "ffca09398635467da3b1f4a54bcfda80" },
		{ "blobulord", "1b5810fafbec445d89921a4efb4e42b7" },
		{ "beholster", "4b992de5b4274168a8878ef9bf7ea36b" },
		{ "gorgun", "c367f00240a64d5d9f3c26484dc35833" },
		{ "ammoconda", "da797878d215453abba824ff902e21b4" },
		{ "old_king", "5729c8b5ffa7415bb3d01205663a33ef" },
		{ "treadnaught", "fa76c8cfdf1c4a88b55173666b4bc7fb" },
		{ "mine_flayer", "8b0dd96e2fe74ec7bebc1bc689c0008a" },
		{ "cannonbalrog", "5e0af7f7d9de4755a68d2fd3bbc15df4" },
		{ "door_lord", "9189f46c47564ed588b9108965f975c9" },
		{ "helicopter_agunim", "41ee1c8538e8474a82a74c4aff99c712" },
		{ "dragun", "465da2bb086a4a88a803f79fe3a27677" },
		{ "dragun_advanced", "05b8afe0b6cc4fffa9dc6036fa24c8ec" },
		{ "lich", "cd88c3ce60c442e9aa5b3904d31652bc" },
		{ "megalich", "68a238ed6a82467ea85474c595c49c6e" },
		{ "infinilich", "7c5d5f09911e49b78ae644d2b50ff3bf" },
		{ "chicken", "76bc43539fc24648bff4568c75c686d1" },
		{ "poopulons_corn", "0ff278534abb4fbaaa65d3f638003648" },
		{ "snake", "1386da0f42fb4bcabc5be8feb16a7c38" },
		{ "tiny_blobulord", "d1c9781fdac54d9e8498ed89210a0238" },
		{ "robots_past_critter_1", "95ea1a31fc9e4415a5f271b9aedf9b15" },
		{ "robots_past_critter_2", "42432592685e47c9941e339879379d3a" },
		{ "robots_past_critter_3", "4254a93fc3c84c0dbe0a8f0dddf48a5a" },
		{ "rat", "6ad1cafc268f4214a101dca7af61bc91" },
		{ "rat_candle", "14ea47ff46b54bb4a98f91ffcffb656d" },
		{ "dragun_egg_slimeguy", "8b43a5c59b854eb780f9ab669ec26b7a" },
		{ "portable_turret", "998807b57e454f00a63d67883fcf90d6" },
		{ "friendly_gatling_gull", "538669d3b2cd4edca2e3699812bcf2b6" },
		{ "cop", "705e9081261446039e1ed9ff16905d04" },
		{ "cucco", "7bd9c670f35b4b8d84280f52a5cc47f6" },
		{ "super_space_turtle_dummy", "cc9c41aa8c194e17b44ac45f993dd212" },
		{ "cop_android", "640238ba85dd4e94b3d6f68888e6ecb8" }
	};

}
public class ModdedGUIDDatabase
{
	public static Dictionary<string, string> ExpandTheGungeonGUIDs { get; set; } = new Dictionary<string, string>
	{
		{ "bootleg_bullat", "7ef020b9-11fb-4a24-a818-60581e6d3105" },
		{ "bootleg_bullet_kin", "a52cfba8-f141-4a98-9022-48816201f834" },
		{ "bootleg_bandana_bullet_kin", "7093253e-a118-4813-8feb-703a1ad31665" },
		{ "bootleg_red_shotgun_kin", "01e4e238-89bb-4b30-b93a-ae17dc19e748" },
		{ "bootleg_blue_shotgun_kin", "f7c0b0ab-3d80-4855-9fd6-38861af1147a" },
		{ "grenade_rat", "1a1dc5ed-92a6-4bd1-bbee-098991e7d2d4" },
		{ "cronenberg", "0a2433d6e0784eefb28762c5c127d0b3" },
		{ "agressive_cronenberg", "6d2d7a845e464d3ca453fe1fff5fed84" },
		{ "parasitic_abomination", "acd8d483f24e4c43b964fa4e54068cf1" },
		{ "com4nd0_boss", "0a406e36-80eb-43b8-8ad0-c56232f9496e" },
		{ "explodey_boy", "27638478e52e4785925b578b52bf79d3" }
	};


	public static Dictionary<string, string> FrostAndGunfireGUIDs { get; set; } = new Dictionary<string, string>
	{
		{ "cannon_kin", "cannon" },
		{ "suppressor", "silencer" },
		{ "skell", "shellet" },
		{ "salamander", "salamander" },
		{ "mushboom", "mini mushboom" },
		{ "roomimic", "Room Mimic" },
		{ "ophaim", "ophaim" },
		{ "firefly", "firefly" },
		{ "spitfire", "spitfire" },
		{ "gunzooka", "spitter" },
		{ "humphrey", "humphrey" },
		{ "milton", "milton" }
	};


	public static Dictionary<string, string> PlanetsideOfGunymedeGUIDs { get; set; } = new Dictionary<string, string>
	{
		{ "fodder", "fodder_enemy" },
		{ "skullvenant", "skullvenant" },
		{ "wailer", "wailer" },
		{ "arch_gunjurer", "arch_gunjurer" },
		{ "cursebulon", "cursebulon" },
		{ "glockulus", "glockulus" },
		{ "barretina", "barretina" },
		{ "shellrax", "Shellrax" },
		{ "bullet_banker", "Bullet_Banker" },
		{ "jammed_guardian", "jammed_guardian" },
		{ "deturret_left", "deturretleft_enemy" },
		{ "deturret_right", "deturret_enemy" },
		{ "an3s_bullet", "an3s_bullet" },
		{ "apache_bullet", "apache_bullet" },
		{ "blazey_bullet", "blazey_bullet" },
		{ "bleak_bullet", "bleak_bullet" },
		{ "bot_bullet", "bot_bullet" },
		{ "bunny_bullet", "bunny_bullet" },
		{ "cel_bullet", "cel_bullet" },
		{ "glaurung_bullet", "glaurung_bullet" },
		{ "hunter_bullet", "hunter_bullet" },
		{ "king_bullet", "king_bullet" },
		{ "kyle_bullet", "kyle_bullet" },
		{ "neighborino_bullet", "neighborino_bullet" },
		{ "nevernamed_bullet", "nevernamed_bullet" },
		{ "panda_bullet", "panda_bullet" },
		{ "retrash_bullet", "retrash_bullet" },
		{ "skilotar_bullet", "skilotar_bullet" },
		{ "spapi_bullet", "spapi_bullet" },
		{ "spcreat_bullet", "spcreat_bullet" },
		{ "wow_bullet", "wow_bullet" }
	};

}
namespace GungeonAPI
{
	public static class ResourceExtractor
	{
		private static string spritesDirectory = Path.Combine(ETGMod.ResourcesDirectory, "sprites");

		public static List<Texture2D> GetTexturesFromDirectory(string directoryPath)
		{
			if (!Directory.Exists(directoryPath))
			{
				Tools.PrintError(directoryPath + " not found.");
				return null;
			}
			List<Texture2D> list = new List<Texture2D>();
			string[] files = Directory.GetFiles(directoryPath);
			foreach (string text in files)
			{
				if (text.EndsWith(".png"))
				{
					Texture2D item = BytesToTexture(File.ReadAllBytes(text), Path.GetFileName(text).Replace(".png", ""));
					list.Add(item);
				}
			}
			return list;
		}

		public static Texture2D GetTextureFromFile(string fileName, string extension = ".png")
		{
			fileName = fileName.Replace(extension, "");
			string text = Path.Combine(spritesDirectory, fileName + extension);
			if (!File.Exists(text))
			{
				Tools.PrintError(text + " not found.");
				return null;
			}
			return BytesToTexture(File.ReadAllBytes(text), fileName);
		}

		public static List<string> GetCollectionFiles()
		{
			List<string> list = new List<string>();
			string[] files = Directory.GetFiles(spritesDirectory);
			foreach (string text in files)
			{
				if (text.EndsWith(".png"))
				{
					list.Add(Path.GetFileName(text).Replace(".png", ""));
				}
			}
			return list;
		}

		public static Texture2D BytesToTexture(byte[] bytes, string resourceName)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			ImageConversion.LoadImage(val, bytes);
			((Texture)val).filterMode = (FilterMode)0;
			((Object)val).name = resourceName;
			return val;
		}

		public static string[] GetLinesFromEmbeddedResource(string filePath)
		{
			string text = BytesToString(ExtractEmbeddedResource(filePath));
			return text.Split(new char[1] { '\n' });
		}

		public static string[] GetLinesFromFile(string filePath)
		{
			string text = BytesToString(File.ReadAllBytes(filePath));
			return text.Split(new char[1] { '\n' });
		}

		public static string BytesToString(byte[] bytes)
		{
			return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
		}

		public static List<string> GetResourceFolders()
		{
			List<string> list = new List<string>();
			string path = Path.Combine(ETGMod.ResourcesDirectory, "sprites");
			if (Directory.Exists(path))
			{
				string[] directories = Directory.GetDirectories(path);
				foreach (string path2 in directories)
				{
					list.Add(Path.GetFileName(path2));
				}
			}
			return list;
		}

		public static byte[] ExtractEmbeddedResource(string filePath)
		{
			filePath = filePath.Replace("/", ".");
			filePath = filePath.Replace("\\", ".");
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			using Stream stream = callingAssembly.GetManifestResourceStream(filePath);
			if (stream == null)
			{
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			return array;
		}

		public static Texture2D GetTextureFromResource(string resourceName)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			byte[] array = ExtractEmbeddedResource(resourceName);
			if (array == null)
			{
				Tools.PrintError("No bytes found in " + resourceName);
				return null;
			}
			Texture2D val = new Texture2D(1, 1, (TextureFormat)20, false);
			ImageConversion.LoadImage(val, array);
			((Texture)val).filterMode = (FilterMode)0;
			string text = resourceName.Substring(0, resourceName.LastIndexOf('.'));
			if (text.LastIndexOf('.') >= 0)
			{
				text = text.Substring(text.LastIndexOf('.') + 1);
			}
			((Object)val).name = text;
			return val;
		}

		public static string[] GetResourceNames()
		{
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			string[] manifestResourceNames = callingAssembly.GetManifestResourceNames();
			if (manifestResourceNames == null)
			{
				ETGModConsole.Log((object)"No manifest resources found.", false);
				return null;
			}
			return manifestResourceNames;
		}
	}
	public static class StaticReferences
	{
		public static Dictionary<string, AssetBundle> AssetBundles;

		public static Dictionary<string, GenericRoomTable> RoomTables;

		public static SharedInjectionData subShopTable;

		public static Dictionary<string, string> roomTableMap = new Dictionary<string, string>
		{
			{ "castle", "Castle_RoomTable" },
			{ "gungeon", "Gungeon_RoomTable" },
			{ "mines", "Mines_RoomTable" },
			{ "catacombs", "Catacomb_RoomTable" },
			{ "forge", "Forge_RoomTable" },
			{ "sewer", "Sewer_RoomTable" },
			{ "cathedral", "Cathedral_RoomTable" },
			{ "bullethell", "BulletHell_RoomTable" }
		};

		public static Dictionary<string, string> specialRoomTableMap = new Dictionary<string, string>
		{
			{ "special", "basic special rooms (shrines, etc)" },
			{ "shop", "Shop Room Table" },
			{ "secret", "secret_room_table_01" }
		};

		public static Dictionary<string, string> BossRoomGrabage = new Dictionary<string, string>
		{
			{ "gull", "bosstable_01_gatlinggull" },
			{ "triggertwins", "bosstable_01_bulletbros" },
			{ "bulletking", "bosstable_01_bulletking" },
			{ "blobby", "bosstable_01a_blobulord" },
			{ "gorgun", "bosstable_02_meduzi" },
			{ "beholster", "bosstable_02_beholster" },
			{ "ammoconda", "bosstable_02_bashellisk" },
			{ "oldking", "bosstable_04_oldking" },
			{ "tank", "bosstable_03_tank" },
			{ "cannonballrog", "bosstable_03_powderskull" },
			{ "flayer", "bosstable_03_mineflayer" },
			{ "priest", "bosstable_02a_highpriest" },
			{ "pillars", "bosstable_04_statues" },
			{ "monger", "bosstable_04_demonwall" },
			{ "doorlord", "bosstable_xx_bossdoormimic" }
		};

		public static Dictionary<string, string> MiniBossRoomPools = new Dictionary<string, string>
		{
			{ "blockner", "BlocknerMiniboss_Table_01" },
			{ "shadeagunim", "PhantomAgunim_Table_01" }
		};

		public static string[] assetBundleNames = new string[3] { "shared_auto_001", "shared_auto_002", "brave_resources_001" };

		public static string[] dungeonPrefabNames = new string[8] { "base_gungeon", "base_castle", "base_mines", "base_catacombs", "base_forge", "base_sewer", "base_cathedral", "base_bullethell" };

		public static void Init()
		{
			AssetBundles = new Dictionary<string, AssetBundle>();
			string[] array = assetBundleNames;
			foreach (string text in array)
			{
				try
				{
					AssetBundle val = ResourceManager.LoadAssetBundle(text);
					if ((Object)(object)val == (Object)null)
					{
						Tools.PrintError("Failed to load asset bundle: " + text);
					}
					else
					{
						AssetBundles.Add(text, ResourceManager.LoadAssetBundle(text));
					}
				}
				catch (Exception e)
				{
					Tools.PrintError("Failed to load asset bundle: " + text);
					Tools.PrintException(e);
				}
			}
			RoomTables = new Dictionary<string, GenericRoomTable>();
			foreach (KeyValuePair<string, string> item in roomTableMap)
			{
				try
				{
					GenericRoomTable fallbackRoomTable = DungeonDatabase.GetOrLoadByName("base_" + item.Key).PatternSettings.flows[0].fallbackRoomTable;
					RoomTables.Add(item.Key, fallbackRoomTable);
				}
				catch (Exception e2)
				{
					Tools.PrintError("Failed to load room table: " + item.Key + ":" + item.Value);
					Tools.PrintException(e2);
				}
			}
			foreach (KeyValuePair<string, string> item2 in specialRoomTableMap)
			{
				try
				{
					GenericRoomTable asset = StaticReferences.GetAsset<GenericRoomTable>(item2.Value);
					RoomTables.Add(item2.Key, asset);
				}
				catch (Exception e3)
				{
					Tools.PrintError("Failed to load special room table: " + item2.Key + ":" + item2.Value);
					Tools.PrintException(e3);
				}
			}
			foreach (KeyValuePair<string, string> item3 in BossRoomGrabage)
			{
				try
				{
					GenericRoomTable asset2 = StaticReferences.GetAsset<GenericRoomTable>(item3.Value);
					RoomTables.Add(item3.Key, asset2);
				}
				catch (Exception e4)
				{
					Tools.PrintError("Failed to load special room table: " + item3.Key + ":" + item3.Value);
					Tools.PrintException(e4);
				}
			}
			foreach (KeyValuePair<string, string> miniBossRoomPool in MiniBossRoomPools)
			{
				try
				{
					GenericRoomTable asset3 = StaticReferences.GetAsset<GenericRoomTable>(miniBossRoomPool.Value);
					RoomTables.Add(miniBossRoomPool.Key, asset3);
				}
				catch (Exception e5)
				{
					Tools.PrintError("Failed to load special room table: " + miniBossRoomPool.Key + ":" + miniBossRoomPool.Value);
					Tools.PrintException(e5);
				}
			}
			subShopTable = AssetBundles["shared_auto_001"].LoadAsset<SharedInjectionData>("_global injected subshop table");
			Tools.Print("Static references initialized.");
		}

		public static GenericRoomTable GetRoomTable(ValidTilesets tileset)
		{
			//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_0008: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			if ((int)tileset <= 16)
			{
				switch (tileset - 1)
				{
				default:
					if ((int)tileset != 8)
					{
						if ((int)tileset != 16)
						{
							break;
						}
						return RoomTables["mines"];
					}
					return RoomTables["cathedral"];
				case 1:
					return RoomTables["castle"];
				case 0:
					return RoomTables["gungeon"];
				case 3:
					return RoomTables["sewer"];
				case 2:
					break;
				}
			}
			else if ((int)tileset <= 64)
			{
				if ((int)tileset == 32)
				{
					return RoomTables["catacombs"];
				}
				if ((int)tileset == 64)
				{
					return RoomTables["forge"];
				}
			}
			else
			{
				if ((int)tileset == 128)
				{
					return RoomTables["bullethell"];
				}
				if ((int)tileset == 32768)
				{
					ETGModConsole.Log((object)"CANNOT ADD TO RAT FLOOR. DEFAULTING TO GUNGEON PROPER", false);
					return RoomTables["gungeon"];
				}
			}
			return RoomTables["gungeon"];
		}

		public static T GetAsset<T>(string assetName) where T : Object
		{
			T val = default(T);
			foreach (AssetBundle value in AssetBundles.Values)
			{
				val = value.LoadAsset<T>(assetName);
				if ((Object)(object)val != (Object)null)
				{
					break;
				}
			}
			return val;
		}
	}
	public static class TextureStitcher
	{
		public static readonly int padding = 1;

		public static Rect AddFaceCardToAtlas(Texture2D tex, Texture2D atlas, int index, Rect bounds)
		{
			//IL_004c: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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)
			int num = (int)(((Rect)(ref bounds)).width / 34f);
			int num2 = (int)(((Rect)(ref bounds)).height / 34f);
			int num3 = index % num;
			int num4 = index / num;
			if (num3 >= num || num4 >= num2)
			{
				Tools.PrintError("Not enough room left on the Facecard Atlas for this facecard!");
				return Rect.zero;
			}
			int num5 = (int)((Rect)(ref bounds)).x + num3 * 34;
			int num6 = (int)((Rect)(ref bounds)).y + num4 * 34;
			for (int i = 0; i < ((Texture)tex).width; i++)
			{
				for (int j = 0; j < ((Texture)tex).height; j++)
				{
					atlas.SetPixel(i + num5, j + num6, tex.GetPixel(i, j));
				}
			}
			atlas.Apply(false, false);
			return new Rect((float)num5 / (float)((Texture)atlas).width, (float)num6 / (float)((Texture)atlas).height, 34f / (float)((Texture)atlas).width, 34f / (float)((Texture)atlas).height);
		}

		public static Rect ReplaceFaceCardInAtlas(Texture2D tex, Texture2D atlas, Rect region)
		{
			//IL_00ab: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			int num = (int)Mathf.Round((float)((Texture)atlas).width * ((Rect)(ref region)).x);
			int num2 = (int)Mathf.Round((float)((Texture)atlas).width * ((Rect)(ref region)).y);
			for (int i = 0; i < ((Texture)tex).width; i++)
			{
				for (int j = 0; j < ((Texture)tex).height; j++)
				{
					atlas.SetPixel(i + num, j + num2, tex.GetPixel(i, j));
				}
			}
			atlas.Apply(false, false);
			return new Rect((float)num / (float)((Texture)atlas).width, (float)num2 / (float)((Texture)atlas).height, 34f / (float)((Texture)atlas).width, 34f / (float)((Texture)atlas).height);
		}

		public static Texture2D CropWhiteSpace(this Texture2D orig)
		{
			//IL_0002: 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)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			Rect trimmedBounds = orig.GetTrimmedBounds();
			Texture2D val = new Texture2D((int)((Rect)(ref trimmedBounds)).width, (int)((Rect)(ref trimmedBounds)).height);
			((Object)val).name = ((Object)orig).name;
			for (int i = (int)((Rect)(ref trimmedBounds)).x; (float)i < ((Rect)(ref trimmedBounds)).x + ((Rect)(ref trimmedBounds)).width; i++)
			{
				for (int j = (int)((Rect)(ref trimmedBounds)).y; (float)j < ((Rect)(ref trimmedBounds)).y + ((Rect)(ref trimmedBounds)).height; j++)
				{
					val.SetPixel(i - (int)((Rect)(ref trimmedBounds)).x, j - (int)((Rect)(ref trimmedBounds)).y, orig.GetPixel(i, j));
				}
			}
			val.Apply(false, false);
			return val;
		}

		public static Rect GetTrimmedBounds(this Texture2D t)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			int num = ((Texture)t).width;
			int num2 = ((Texture)t).height;
			int num3 = 0;
			int num4 = 0;
			for (int i = 0; i < ((Texture)t).width; i++)
			{
				for (int j = 0; j < ((Texture)t).height; j++)
				{
					if (t.GetPixel(i, j) != Color.clear)
					{
						if (i < num)
						{
							num = i;
						}
						if (j < num2)
						{
							num2 = j;
						}
						if (i > num3)
						{
							num3 = i;
						}
						if (j > num4)
						{
							num4 = j;
						}
					}
				}
			}
			return new Rect((float)num, (float)num2, (float)(num3 - num + 1), (float)(num4 - num2 + 1));
		}

		public static Texture2D AddMargin(this Texture2D texture)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(((Texture)texture).width + 2 * padding, ((Texture)texture).height + 2 * padding);
			((Object)val).name = ((Object)texture).name;
			((Texture)val).filterMode = ((Texture)texture).filterMode;
			for (int i = 0; i < ((Texture)val).width; i++)
			{
				for (int j = 0; j < ((Texture)val).height; j++)
				{
					val.SetPixel(i, j, Color.clear);
				}
			}
			for (int k = 0; k < ((Texture)texture).width; k++)
			{
				for (int l = 0; l < ((Texture)texture).height; l++)
				{
					val.SetPixel(k + padding, l + padding, texture.GetPixel(k, l));
				}
			}
			val.Apply(false, false);
			return val;
		}

		public static Texture2D GetReadable(this Texture2D texture)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture temporary = RenderTexture.GetTemporary(((Texture)texture).width, ((Texture)texture).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1);
			Graphics.Blit((Texture)(object)texture, temporary);
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = temporary;
			Texture2D val = new Texture2D(((Texture)texture).width, ((Texture)texture).height);
			val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0);
			val.Apply();
			RenderTexture.active = active;
			return val;
		}

		public static Texture2D Rotated(this Texture2D texture, bool clockwise = false)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			Color32[] pixels = texture.GetPixels32();
			Color32[] array = (Color32[])(object)new Color32[pixels.Length];
			int width = ((Texture)texture).width;
			int height = ((Texture)texture).height;
			for (int i = 0; i < height; i++)
			{
				for (int j = 0; j < width; j++)
				{
					int num = (j + 1) * height - i - 1;
					int num2 = (clockwise ? (pixels.Length - 1 - (i * width + j)) : (i * width + j));
					array[num] = pixels[num2];
				}
			}
			Texture2D val = new Texture2D(height, width);
			val.SetPixels32(array);
			val.Apply();
			return val;
		}

		public static Texture2D Flipped(this Texture2D texture, bool horizontal = true)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			int width = ((Texture)texture).width;
			int height = ((Texture)texture).height;
			Texture2D val = new Texture2D(width, height);
			for (int i = 0; i < width; i++)
			{
				for (int j = 0; j < height; j++)
				{
					val.SetPixel(i, j, texture.GetPixel(width - i - 1, j));
				}
			}
			val.Apply();
			return val;
		}
	}
	public static class Tools
	{
		public static bool verbose = false;

		private static string defaultLog = Path.Combine(ETGMod.ResourcesDirectory, "customCharacterLog.txt");

		public static string modID = "NN";

		private static Dictionary<string, float> timers = new Dictionary<string, float>();

		public static void Init()
		{
			if (File.Exists(defaultLog))
			{
				File.Delete(defaultLog);
			}
		}

		public static void Print<T>(T obj, string color = "FFFFFF", bool force = false)
		{
			if (verbose || force)
			{
				string[] array = obj.ToString().Split(new char[1] { '\n' });
				string[] array2 = array;
				foreach (string text in array2)
				{
					LogToConsole("<color=#" + color + ">[" + modID + "] " + text + "</color>");
				}
			}
			Log(obj.ToString());
		}

		public static void PrintRaw<T>(T obj, bool force = false)
		{
			if (verbose || force)
			{
				LogToConsole(obj.ToString());
			}
			Log(obj.ToString());
		}

		public static void PrintError<T>(T obj, string color = "FF0000")
		{
			string[] array = obj.ToString().Split(new char[1] { '\n' });
			string[] array2 = array;
			foreach (string text in array2)
			{
				LogToConsole("<color=#" + color + ">[" + modID + "] " + text + "</color>");
			}
			Log(obj.ToString());
		}

		public static void PrintException(Exception e, string color = "FF0000")
		{
			string text = e.Message + "\n" + e.StackTrace;
			string[] array = text.Split(new char[1] { '\n' });
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				LogToConsole("<color=#" + color + ">[" + modID + "] " + text2 + "</color>");
			}
			Log(e.Message);
			Log("\t" + e.StackTrace);
		}

		public static void Log<T>(T obj)
		{
			using StreamWriter streamWriter = new StreamWriter(Path.Combine(ETGMod.ResourcesDirectory, defaultLog), append: true);
			streamWriter.WriteLine(obj.ToString());
		}

		public static void Log<T>(T obj, string fileName)
		{
			if (verbose)
			{
				using (StreamWriter streamWriter = new StreamWriter(Path.Combine(ETGMod.ResourcesDirectory, fileName), append: true))
				{
					streamWriter.WriteLine(obj.ToString());
				}
			}
		}

		public static void LogToConsole(string message)
		{
			message.Replace("\t", "    ");
			ETGModConsole.Log((object)message, false);
		}

		private static void BreakdownComponentsInternal(this GameObject obj, int lvl = 0)
		{
			string text = "";
			for (int i = 0; i < lvl; i++)
			{
				text += "\t";
			}
			Log(text + ((Object)obj).name + "...");
			Component[] components = obj.GetComponents<Component>();
			foreach (Component val in components)
			{
				string text2 = text;
				string text3 = "    -";
				Log(text2 + text3 + ((object)val).GetType());
			}
			Transform[] componentsInChildren = obj.GetComponentsInChildren<Transform>();
			foreach (Transform val2 in componentsInChildren)
			{
				if ((Object)(object)val2 != (Object)(object)obj.transform)
				{
					((Component)val2).gameObject.BreakdownComponentsInternal(lvl + 1);
				}
			}
		}

		public static void BreakdownComponents(this GameObject obj)
		{
			obj.BreakdownComponentsInternal();
		}

		public static void ExportTexture(Texture texture, string folder = "")
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			string text = Path.Combine(ETGMod.ResourcesDirectory, folder);
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			File.WriteAllBytes(Path.Combine(text, ((Object)texture).name + DateTime.Now.Ticks + ".png"), ImageConversion.EncodeToPNG((Texture2D)texture));
		}

		public static T GetEnumValue<T>(string val) where T : Enum
		{
			return (T)Enum.Parse(typeof(T), val.ToUpper());
		}

		public static void LogPropertiesAndFields<T>(T obj, string header = "")
		{
			Log(header);
			Log("=======================");
			if (obj == null)
			{
				Log("LogPropertiesAndFields: Null object");
				return;
			}
			Type type = obj.GetType();
			Log($"Type: {type}");
			PropertyInfo[] properties = type.GetProperties();
			Log($"{typeof(T)} Properties: ");
			PropertyInfo[] array = properties;
			foreach (PropertyInfo propertyInfo in array)
			{
				try
				{
					object value = propertyInfo.GetValue(obj, null);
					string text = value.ToString();
					if ((object)obj?.GetType().GetGenericTypeDefinition() == typeof(List<>))
					{
						List<object> list = value as List<object>;
						text = $"List[{list.Count}]";
						foreach (object item in list)
						{
							text = text + "\n\t\t" + item.ToString();
						}
					}
					Log("\t" + propertyInfo.Name + ": " + text);
				}
				catch
				{
				}
			}
			Log($"{typeof(T)} Fields: ");
			FieldInfo[] fields = type.GetFields();
			FieldInfo[] array2 = fields;
			foreach (FieldInfo fieldInfo in array2)
			{
				Log($"\t{fieldInfo.Name}: {fieldInfo.GetValue(obj)}");
			}
		}

		public static void StartTimer(string name)
		{
			string key = name.ToLower();
			if (timers.ContainsKey(key))
			{
				PrintError("Timer " + name + " already exists.");
			}
			else
			{
				timers.Add(key, Time.realtimeSinceStartup);
			}
		}

		public static void StopTimerAndReport(string name)
		{
			string key = name.ToLower();
			if (!timers.ContainsKey(key))
			{
				PrintError("Could not stop timer " + name + ", no such timer exists");
				return;
			}
			float num = timers[key];
			int num2 = (int)((Time.realtimeSinceStartup - num) * 1000f);
			timers.Remove(key);
			Print(name + " finished in " + num2 + "ms");
		}
	}
}
namespace SaveAPI
{
	[fsObject]
	public class AdvancedGameStats
	{
		[fsProperty]
		private Dictionary<CustomTrackedStats, float> stats;

		[fsProperty]
		private Dictionary<CustomTrackedMaximums, float> maxima;

		[fsProperty]
		public HashSet<CustomCharacterSpecificGungeonFlags> m_flags;

		public AdvancedGameStats()
		{
			m_flags = new HashSet<CustomCharacterSpecificGungeonFlags>();
			stats = new Dictionary<CustomTrackedStats, float>(new CustomTrackedStatsComparer());
			maxima = new Dictionary<CustomTrackedMaximums, float>(new CustomTrackedMaximumsComparer());
		}

		public float GetStatValue(CustomTrackedStats statToCheck)
		{
			if (!stats.ContainsKey(statToCheck))
			{
				return 0f;
			}
			return stats[statToCheck];
		}

		public float GetMaximumValue(CustomTrackedMaximums maxToCheck)
		{
			if (!maxima.ContainsKey(maxToCheck))
			{
				return 0f;
			}
			return maxima[maxToCheck];
		}

		public bool GetFlag(CustomCharacterSpecificGungeonFlags flag)
		{
			if (flag == CustomCharacterSpecificGungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to get a NONE character-specific save flag!");
				return false;
			}
			return m_flags.Contains(flag);
		}

		public void SetStat(CustomTrackedStats stat, float val)
		{
			if (stats.ContainsKey(stat))
			{
				stats[stat] = val;
			}
			else
			{
				stats.Add(stat, val);
			}
		}

		public void SetMax(CustomTrackedMaximums max, float val)
		{
			if (maxima.ContainsKey(max))
			{
				maxima[max] = Mathf.Max(maxima[max], val);
			}
			else
			{
				maxima.Add(max, val);
			}
		}

		public void SetFlag(CustomCharacterSpecificGungeonFlags flag, bool value)
		{
			if (flag == CustomCharacterSpecificGungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to set a NONE character-specific save flag!");
			}
			else if (value)
			{
				m_flags.Add(flag);
			}
			else
			{
				m_flags.Remove(flag);
			}
		}

		public void IncrementStat(CustomTrackedStats stat, float val)
		{
			if (stats.ContainsKey(stat))
			{
				stats[stat] += val;
			}
			else
			{
				stats.Add(stat, val);
			}
		}

		public void AddStats(AdvancedGameStats otherStats)
		{
			foreach (KeyValuePair<CustomTrackedStats, float> stat in otherStats.stats)
			{
				IncrementStat(stat.Key, stat.Value);
			}
			foreach (KeyValuePair<CustomTrackedMaximums, float> item in otherStats.maxima)
			{
				SetMax(item.Key, item.Value);
			}
			foreach (CustomCharacterSpecificGungeonFlags flag in otherStats.m_flags)
			{
				m_flags.Add(flag);
			}
		}

		public void ClearAllState()
		{
			List<CustomTrackedStats> list = new List<CustomTrackedStats>();
			foreach (KeyValuePair<CustomTrackedStats, float> stat in stats)
			{
				list.Add(stat.Key);
			}
			foreach (CustomTrackedStats item in list)
			{
				stats[item] = 0f;
			}
			List<CustomTrackedMaximums> list2 = new List<CustomTrackedMaximums>();
			foreach (KeyValuePair<CustomTrackedMaximums, float> item2 in maxima)
			{
				list2.Add(item2.Key);
			}
			foreach (CustomTrackedMaximums item3 in list2)
			{
				maxima[item3] = 0f;
			}
		}
	}
	[fsObject]
	internal class AdvancedGameStatsManager
	{
		private static AdvancedGameStatsManager m_instance;

		[fsProperty]
		public HashSet<CustomDungeonFlags> m_flags;

		[fsProperty]
		public string midGameSaveGuid;

		[fsProperty]
		public Dictionary<PlayableCharacters, AdvancedGameStats> m_characterStats;

		private AdvancedGameStats m_sessionStats;

		private AdvancedGameStats m_savedSessionStats;

		private PlayableCharacters m_sessionCharacter;

		private int m_numCharacters;

		[fsIgnore]
		public int cachedHuntIndex;

		[fsIgnore]
		public SaveSlot cachedSaveSlot;

		[fsProperty]
		public int BeggarRepeatTarget;

		[fsProperty]
		public int BeggarRepeatCurrent;

		[fsIgnore]
		public bool IsInSession => m_sessionStats != null;

		public static bool HasInstance => m_instance != null;

		public static AdvancedGameStatsManager Instance => m_instance;

		public AdvancedGameStatsManager()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			m_flags = new HashSet<CustomDungeonFlags>(new CustomDungeonFlagsComparer());
			m_characterStats = new Dictionary<PlayableCharacters, AdvancedGameStats>((IEqualityComparer<PlayableCharacters>?)new PlayableCharactersComparer());
			m_numCharacters = -1;
			cachedHuntIndex = -1;
		}

		public static void Unload()
		{
			m_instance = null;
		}

		public void SetCharacterSpecificFlag(PlayableCharacters character, CustomCharacterSpecificGungeonFlags flag, bool value)
		{
			//IL_001d: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if (flag == CustomCharacterSpecificGungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to set a NONE character-specific save flag!");
				return;
			}
			if (!m_characterStats.ContainsKey(character))
			{
				m_characterStats.Add(character, new AdvancedGameStats());
			}
			if (m_sessionStats != null && m_sessionCharacter == character)
			{
				m_sessionStats.SetFlag(flag, value);
			}
			else
			{
				m_characterStats[character].SetFlag(flag, value);
			}
		}

		public void SetStat(CustomTrackedStats stat, float value)
		{
			if (!float.IsNaN(value) && !float.IsInfinity(value) && m_sessionStats != null)
			{
				m_sessionStats.SetStat(stat, value);
			}
		}

		public void UpdateMaximum(CustomTrackedMaximums maximum, float val)
		{
			if (!float.IsNaN(val) && !float.IsInfinity(val) && m_sessionStats != null)
			{
				m_sessionStats.SetMax(maximum, val);
			}
		}

		public bool GetCharacterSpecificFlag(CustomCharacterSpecificGungeonFlags flag)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return GetCharacterSpecificFlag(m_sessionCharacter, flag);
		}

		public bool GetCharacterSpecificFlag(PlayableCharacters character, CustomCharacterSpecificGungeonFlags flag)
		{
			//IL_0022: 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)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (flag == CustomCharacterSpecificGungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to get a NONE character-specific save flag!");
				return false;
			}
			if (m_sessionStats != null && m_sessionCharacter == character)
			{
				if (m_sessionStats.GetFlag(flag))
				{
					return true;
				}
				if (m_savedSessionStats.GetFlag(flag))
				{
					return true;
				}
			}
			AdvancedGameStats value;
			return m_characterStats.TryGetValue(character, out value) && value.GetFlag(flag);
		}

		public static void DoMidgameSave()
		{
			string text = Guid.NewGuid().ToString();
			AdvancedMidGameSaveData advancedMidGameSaveData = new AdvancedMidGameSaveData(text);
			SaveManager.Save<AdvancedMidGameSaveData>(advancedMidGameSaveData, SaveAPIManager.AdvancedMidGameSave, GameStatsManager.Instance.PlaytimeMin, 0u, (SaveSlot?)null);
			Instance.midGameSaveGuid = text;
			Save();
		}

		public void RegisterStatChange(CustomTrackedStats stat, float value)
		{
			if (m_sessionStats == null)
			{
				Debug.LogError((object)"No session stats active and we're registering a stat change!");
			}
			else if (!float.IsNaN(value) && !float.IsInfinity(value) && !(Mathf.Abs(value) > 10000f))
			{
				m_sessionStats.IncrementStat(stat, value);
			}
		}

		public static void InvalidateMidgameSave(bool saveStats)
		{
			AdvancedMidGameSaveData midgameSave = null;
			if (VerifyAndLoadMidgameSave(out midgameSave, checkValidity: false))
			{
				midgameSave.Invalidate();
				SaveManager.Save<AdvancedMidGameSaveData>(midgameSave, SaveAPIManager.AdvancedMidGameSave, GameStatsManager.Instance.PlaytimeMin, 0u, (SaveSlot?)null);
				GameStatsManager.Instance.midGameSaveGuid = midgameSave.midGameSaveGuid;
				if (saveStats)
				{
					GameStatsManager.Save();
				}
			}
		}

		public static void RevalidateMidgameSave(bool saveStats)
		{
			AdvancedMidGameSaveData midgameSave = null;
			if (VerifyAndLoadMidgameSave(out midgameSave, checkValidity: false))
			{
				midgameSave.Revalidate();
				SaveManager.Save<AdvancedMidGameSaveData>(midgameSave, SaveAPIManager.AdvancedMidGameSave, GameStatsManager.Instance.PlaytimeMin, 0u, (SaveSlot?)null);
				GameStatsManager.Instance.midGameSaveGuid = midgameSave.midGameSaveGuid;
				if (saveStats)
				{
					GameStatsManager.Save();
				}
			}
		}

		public static bool VerifyAndLoadMidgameSave(out AdvancedMidGameSaveData midgameSave, bool checkValidity = true)
		{
			if (!SaveManager.Load<AdvancedMidGameSaveData>(SaveAPIManager.AdvancedGameSave, ref midgameSave, true, 0u, (Func<string, uint, string>)null, (SaveSlot?)null))
			{
				Debug.LogError((object)"No mid game save found");
				return false;
			}
			if (midgameSave == null)
			{
				Debug.LogError((object)"Failed to load mid game save (0)");
				return false;
			}
			if (checkValidity && !midgameSave.IsValid())
			{
				return false;
			}
			if (GameStatsManager.Instance.midGameSaveGuid == null || GameStatsManager.Instance.midGameSaveGuid != midgameSave.midGameSaveGuid)
			{
				Debug.LogError((object)"Failed to load mid game save (1)");
				return false;
			}
			return true;
		}

		public void ClearAllStatsGlobal()
		{
			m_sessionStats.ClearAllState();
			m_savedSessionStats.ClearAllState();
			if (m_numCharacters <= 0)
			{
				m_numCharacters = Enum.GetValues(typeof(PlayableCharacters)).Length;
			}
			for (int i = 0; i < m_numCharacters; i++)
			{
				if (m_characterStats.TryGetValue((PlayableCharacters)i, out var value))
				{
					value.ClearAllState();
				}
			}
		}

		public void ClearStatValueGlobal(CustomTrackedStats stat)
		{
			m_sessionStats.SetStat(stat, 0f);
			m_savedSessionStats.SetStat(stat, 0f);
			if (m_numCharacters <= 0)
			{
				m_numCharacters = Enum.GetValues(typeof(PlayableCharacters)).Length;
			}
			for (int i = 0; i < m_numCharacters; i++)
			{
				if (m_characterStats.TryGetValue((PlayableCharacters)i, out var value))
				{
					value.SetStat(stat, 0f);
				}
			}
		}

		private PlayableCharacters GetCurrentCharacter()
		{
			//IL_000b: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			return GameManager.Instance.PrimaryPlayer.characterIdentity;
		}

		public float GetPlayerMaximum(CustomTrackedMaximums maximum)
		{
			if (m_numCharacters <= 0)
			{
				m_numCharacters = Enum.GetValues(typeof(PlayableCharacters)).Length;
			}
			float num = 0f;
			if (m_sessionStats != null)
			{
				num = Mathf.Max(new float[3]
				{
					num,
					m_sessionStats.GetMaximumValue(maximum),
					m_savedSessionStats.GetMaximumValue(maximum)
				});
			}
			for (int i = 0; i < m_numCharacters; i++)
			{
				if (m_characterStats.TryGetValue((PlayableCharacters)i, out var value))
				{
					num = Mathf.Max(num, value.GetMaximumValue(maximum));
				}
			}
			return num;
		}

		public float GetPlayerStatValue(CustomTrackedStats stat)
		{
			if (m_numCharacters <= 0)
			{
				m_numCharacters = Enum.GetValues(typeof(PlayableCharacters)).Length;
			}
			float num = 0f;
			if (m_sessionStats != null)
			{
				num += m_sessionStats.GetStatValue(stat);
			}
			for (int i = 0; i < m_numCharacters; i++)
			{
				if (m_characterStats.TryGetValue((PlayableCharacters)i, out var value))
				{
					num += value.GetStatValue(stat);
				}
			}
			return num;
		}

		public void SetCharacterSpecificFlag(CustomCharacterSpecificGungeonFlags flag, bool value)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			SetCharacterSpecificFlag(m_sessionCharacter, flag, value);
		}

		public float GetSessionStatValue(CustomTrackedStats stat)
		{
			return m_sessionStats.GetStatValue(stat) + m_savedSessionStats.GetStatValue(stat);
		}

		public float GetCharacterStatValue(CustomTrackedStats stat)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return GetCharacterStatValue(GetCurrentCharacter(), stat);
		}

		public AdvancedGameStats MoveSessionStatsToSavedSessionStats()
		{
			//IL_0028: 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)
			if (!IsInSession)
			{
				return null;
			}
			if (m_sessionStats != null)
			{
				if (m_characterStats.ContainsKey(m_sessionCharacter))
				{
					m_characterStats[m_sessionCharacter].AddStats(m_sessionStats);
				}
				m_savedSessionStats.AddStats(m_sessionStats);
				m_sessionStats.ClearAllState();
			}
			return m_savedSessionStats;
		}

		public float GetCharacterStatValue(PlayableCharacters character, CustomTrackedStats stat)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			float num = 0f;
			if (m_sessionCharacter == character)
			{
				num += m_sessionStats.GetStatValue(stat);
			}
			if (m_characterStats.ContainsKey(character))
			{
				num += m_characterStats[character].GetStatValue(stat);
			}
			return num;
		}

		public void BeginNewSession(PlayerController player)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_006e: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_00ae: 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)
			if (m_characterStats == null)
			{
				m_characterStats = new Dictionary<PlayableCharacters, AdvancedGameStats>((IEqualityComparer<PlayableCharacters>?)new PlayableCharactersComparer());
			}
			if (IsInSession)
			{
				m_sessionCharacter = player.characterIdentity;
				if (!m_characterStats.ContainsKey(player.characterIdentity))
				{
					m_characterStats.Add(player.characterIdentity, new AdvancedGameStats());
				}
				return;
			}
			m_sessionCharacter = player.characterIdentity;
			m_sessionStats = new AdvancedGameStats();
			m_savedSessionStats = new AdvancedGameStats();
			if (!m_characterStats.ContainsKey(player.characterIdentity))
			{
				m_characterStats.Add(player.characterIdentity, new AdvancedGameStats());
			}
		}

		public void EndSession(bool recordSessionStats)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (IsInSession && m_sessionStats != null)
			{
				if (recordSessionStats && m_characterStats.ContainsKey(m_sessionCharacter))
				{
					m_characterStats[m_sessionCharacter].AddStats(m_sessionStats);
				}
				m_sessionStats = null;
				m_savedSessionStats = null;
			}
		}

		public static void Load()
		{
			//IL_0029: 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_007a: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			SaveManager.Init();
			bool flag = false;
			SaveSlot? val = null;
			int num = -1;
			if (m_instance != null)
			{
				flag = true;
				val = m_instance.cachedSaveSlot;
				num = m_instance.cachedHuntIndex;
			}
			if (!SaveManager.Load<AdvancedGameStatsManager>(SaveAPIManager.AdvancedGameSave, ref m_instance, true, 0u, (Func<string, uint, string>)null, (SaveSlot?)null))
			{
				m_instance = new AdvancedGameStatsManager();
			}
			m_instance.cachedSaveSlot = SaveManager.CurrentSaveSlot;
			if (flag && val.HasValue && m_instance.cachedSaveSlot == val.Value)
			{
				m_instance.cachedHuntIndex = num;
			}
			else
			{
				m_instance.cachedHuntIndex = -1;
			}
		}

		public static void DANGEROUS_ResetAllStats()
		{
			m_instance = new AdvancedGameStatsManager();
			SaveManager.DeleteAllBackups(SaveAPIManager.AdvancedGameSave, (SaveSlot?)null);
		}

		public bool GetFlag(CustomDungeonFlags flag)
		{
			if (flag == CustomDungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to get a NONE save flag!");
				return false;
			}
			return m_flags.Contains(flag);
		}

		public void SetFlag(CustomDungeonFlags flag, bool value)
		{
			if (flag == CustomDungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to set a NONE save flag!");
			}
			else if (value)
			{
				m_flags.Add(flag);
			}
			else
			{
				m_flags.Remove(flag);
			}
		}

		public static bool Save()
		{
			bool result = false;
			try
			{
				result = SaveManager.Save<AdvancedGameStatsManager>(m_instance, SaveAPIManager.AdvancedGameSave, GameStatsManager.Instance.PlaytimeMin, 0u, (SaveSlot?)null);
			}
			catch (Exception ex)
			{
				Debug.LogErrorFormat("SAVE FAILED: {0}", new object[1] { ex });
			}
			return result;
		}

		public void AssignMidGameSavedSessionStats(AdvancedGameStats source)
		{
			if (IsInSession && m_savedSessionStats != null)
			{
				m_savedSessionStats.AddStats(source);
			}
		}
	}
	public class AdvancedMidGameSaveData
	{
		[fsProperty]
		public AdvancedGameStats PriorSessionStats;

		[fsProperty]
		public string midGameSaveGuid;

		[fsProperty]
		public bool invalidated;

		public AdvancedMidGameSaveData(string midGameSaveGuid)
		{
			this.midGameSaveGuid = midGameSaveGuid;
			PriorSessionStats = AdvancedGameStatsManager.Instance.MoveSessionStatsToSavedSessionStats();
		}

		public bool IsValid()
		{
			return !invalidated;
		}

		public void Invalidate()
		{
			invalidated = true;
		}

		public void Revalidate()
		{
			invalidated = false;
		}

		public void LoadDataFromMidGameSave()
		{
			AdvancedGameStatsManager.Instance.AssignMidGameSavedSessionStats(PriorSessionStats);
		}
	}
	public static class BreachShopTool
	{
		public class DoubleMetaShopTier
		{
			private MetaShopTier m_topTier;

			private MetaShopTier m_bottomTier;

			public DoubleMetaShopTier(MetaShopTier topTier, MetaShopTier bottomTier)
			{
				m_topTier = topTier;
				m_bottomTier = bottomTier;
			}

			public DoubleMetaShopTier(DoubleMetaShopTier other)
			{
				m_topTier = other.m_topTier;
				m_bottomTier = other.m_bottomTier;
			}

			public MetaShopTier GetTopTier()
			{
				return m_topTier;
			}

			public MetaShopTier GetBottomTier()
			{
				return m_topTier;
			}

			public List<MetaShopTier> GetTierList()
			{
				return new List<MetaShopTier> { m_topTier, m_bottomTier };
			}
		}

		public static MetaShopController BaseMetaShopController;

		public static GenericLootTable TrorcMetaShopItems;

		public static GenericLootTable GooptonMetaShopItems;

		public static GenericLootTable DougMetaShopItems;

		private static FieldInfo ItemControllersInfo = typeof(ShopController).GetField("m_itemControllers", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo BaseItemControllersInfo = typeof(BaseShopController).GetField("m_itemControllers", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Hook pickupObjectEncounterableHook;

		private static Hook baseShopSetupHook;

		private static Hook metaShopSetupHook;

		private static Hook metaShopCurrentTierHook;

		private static Hook metaShopProximateTierHook;

		public static Dictionary<WeightedGameObjectCollection, List<WeightedGameObject>> baseShopAddedItems;

		public static List<MetaShopTier> metaShopAddedTiers;

		private static bool m_loaded;

		public static void DoSetup()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			if (!m_loaded)
			{
				BaseMetaShopController = SaveTools.LoadAssetFromAnywhere<GameObject>("Foyer_MetaShop").GetComponent<MetaShopController>();
				TrorcMetaShopItems = SaveTools.LoadAssetFromAnywhere<GenericLootTable>("Shop_Truck_Meta");
				GooptonMetaShopItems = SaveTools.LoadAssetFromAnywhere<GenericLootTable>("Shop_Goop_Meta");
				DougMetaShopItems = SaveTools.LoadAssetFromAnywhere<GenericLootTable>("Shop_Beetle_Meta");
				pickupObjectEncounterableHook = new Hook((MethodBase)typeof(PickupObject).GetMethod("HandleEncounterable", BindingFlags.Instance | BindingFlags.NonPublic), typeof(BreachShopTool).GetMethod("HandleEncounterableHook"));
				baseShopSetupHook = new Hook((MethodBase)typeof(BaseShopController).GetMethod("DoSetup", BindingFlags.Instance | BindingFlags.NonPublic), typeof(BreachShopTool).GetMethod("BaseShopSetupHook"));
				metaShopSetupHook = new Hook((MethodBase)typeof(MetaShopController).GetMethod("DoSetup", BindingFlags.Instance | BindingFlags.NonPublic), typeof(BreachShopTool).GetMethod("MetaSetupHook"));
				metaShopCurrentTierHook = new Hook((MethodBase)typeof(MetaShopController).GetMethod("GetCurrentTier", BindingFlags.Instance | BindingFlags.NonPublic), typeof(BreachShopTool).GetMethod("MetaShopCurrentTierHook"));
				metaShopProximateTierHook = new Hook((MethodBase)typeof(MetaShopController).GetMethod("GetProximateTier", BindingFlags.Instance | BindingFlags.NonPublic), typeof(BreachShopTool).GetMethod("MetaShopProximateTierHook"));
				m_loaded = true;
			}
		}

		public static void Unload()
		{
			if (!m_loaded)
			{
				return;
			}
			if (baseShopAddedItems != null)
			{
				for (int i = 0; i < baseShopAddedItems.Keys.Count; i++)
				{
					WeightedGameObjectCollection val = baseShopAddedItems.Keys.ToList()[i];
					if (val == null || baseShopAddedItems[val] == null)
					{
						continue;
					}
					for (int j = 0; j < baseShopAddedItems[val].Count; j++)
					{
						WeightedGameObject val2 = baseShopAddedItems[val][j];
						if (val2 != null && val.elements.Contains(val2))
						{
							val.elements.Remove(val2);
						}
					}
				}
				baseShopAddedItems.Clear();
				baseShopAddedItems = null;
			}
			if (metaShopAddedTiers != null)
			{
				for (int k = 0; k < metaShopAddedTiers.Count; k++)
				{
					MetaShopTier val3 = metaShopAddedTiers[k];
					if (val3 != null && BaseMetaShopController.metaShopTiers.Contains(val3))
					{
						BaseMetaShopController.metaShopTiers.Remove(val3);
					}
				}
				metaShopAddedTiers.Clear();
				metaShopAddedTiers = null;
			}
			BaseMetaShopController = null;
			TrorcMetaShopItems = null;
			GooptonMetaShopItems = null;
			DougMetaShopItems = null;
			Hook obj = pickupObjectEncounterableHook;
			if (obj != null)
			{
				obj.Dispose();
			}
			Hook obj2 = baseShopSetupHook;
			if (obj2 != null)
			{
				obj2.Dispose();
			}
			Hook obj3 = metaShopSetupHook;
			if (obj3 != null)
			{
				obj3.Dispose();
			}
			Hook obj4 = metaShopCurrentTierHook;
			if (obj4 != null)
			{
				obj4.Dispose();
			}
			Hook obj5 = metaShopProximateTierHook;
			if (obj5 != null)
			{
				obj5.Dispose();
			}
			m_loaded = false;
		}

		public static void HandleEncounterableHook(Action<PickupObject, PlayerController> orig, PickupObject po, PlayerController player)
		{
			orig(po, player);
			if ((Object)(object)po != (Object)null && (Object)(object)((Component)po).GetComponent<SpecialPickupObject>() != (Object)null && ((Component)po).GetComponent<SpecialPickupObject>().CustomSaveFlagToSetOnAcquisition != 0)
			{
				AdvancedGameStatsManager.Instance.SetFlag(((Component)po).GetComponent<SpecialPickupObject>().CustomSaveFlagToSetOnAcquisition, value: true);
			}
		}

		public static void BaseShopSetupHook(Action<BaseShopController> orig, BaseShopController self)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			orig(self);
			if ((int)self.baseShopType != 6 || !((Object)(object)self.ExampleBlueprintPrefab != (Object)null))
			{
				return;
			}
			List<ShopItemController> list = (List<ShopItemController>)BaseItemControllersInfo.GetValue(self);
			if (list == null)
			{
				return;
			}
			foreach (ShopItemController item in list)
			{
				if (!((Object)(object)item != (Object)null) || !((Object)(object)item.item != (Object)null) || !((Object)(object)((BraveBehaviour)item.item).encounterTrackable != (Object)null) || ((BraveBehaviour)item.item).encounterTrackable.journalData == null)
				{
					continue;
				}
				PickupObject blueprintUnlockedItem = GetBlueprintUnlockedItem(((BraveBehaviour)item.item).encounterTrackable);
				if (!((Object)(object)blueprintUnlockedItem != (Object)null) || !((Object)(object)((BraveBehaviour)blueprintUnlockedItem).encounterTrackable != (Object)null) || ((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites == null)
				{
					continue;
				}
				CustomDungeonFlags customDungeonFlags = CustomDungeonFlags.NONE;
				for (int i = 0; i < ((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites.Length; i++)
				{
					if (((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites[i] is CustomDungeonPrerequisite && (((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites[i] as CustomDungeonPrerequisite).advancedPrerequisiteType == CustomDungeonPrerequisite.AdvancedPrerequisiteType.CUSTOM_FLAG)
					{
						customDungeonFlags = (((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites[i] as CustomDungeonPrerequisite).customFlagToCheck;
					}
				}
				if (customDungeonFlags != 0)
				{
					((Component)item.item).gameObject.AddComponent<SpecialPickupObject>().CustomSaveFlagToSetOnAcquisition = customDungeonFlags;
				}
			}
		}

		public static void MetaSetupHook(Action<MetaShopController> orig, MetaShopController meta)
		{
			orig(meta);
			List<ShopItemController> list = (List<ShopItemController>)ItemControllersInfo.GetValue(meta);
			if (list == null)
			{
				return;
			}
			foreach (ShopItemController item in list)
			{
				if (!((Object)(object)item != (Object)null) || !((Object)(object)item.item != (Object)null) || !((Object)(object)((BraveBehaviour)item.item).encounterTrackable != (Object)null) || ((BraveBehaviour)item.item).encounterTrackable.journalData == null)
				{
					continue;
				}
				PickupObject blueprintUnlockedItem = GetBlueprintUnlockedItem(((BraveBehaviour)item.item).encounterTrackable);
				if (!((Object)(object)blueprintUnlockedItem != (Object)null) || !((Object)(object)((BraveBehaviour)blueprintUnlockedItem).encounterTrackable != (Object)null) || ((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites == null)
				{
					continue;
				}
				CustomDungeonFlags customFlagFromTargetItem = GetCustomFlagFromTargetItem(blueprintUnlockedItem.PickupObjectId);
				if (customFlagFromTargetItem != 0)
				{
					((Component)item.item).gameObject.AddComponent<SpecialPickupObject>().CustomSaveFlagToSetOnAcquisition = customFlagFromTargetItem;
					if (AdvancedGameStatsManager.Instance.GetFlag(customFlagFromTargetItem))
					{
						item.ForceOutOfStock();
					}
				}
			}
		}

		private static bool GetMetaItemUnlockedAdvanced(int pickupObjectId)
		{
			CustomDungeonFlags customFlagFromTargetItem = GetCustomFlagFromTargetItem(pickupObjectId);
			if (customFlagFromTargetItem == CustomDungeonFlags.NONE)
			{
				return true;
			}
			return AdvancedGameStatsManager.Instance.GetFlag(customFlagFromTargetItem);
		}

		public static MetaShopTier MetaShopCurrentTierHook(Func<MetaShopController, MetaShopTier> orig, MetaShopController self)
		{
			MetaShopTier val = null;
			for (int i = 0; i < self.metaShopTiers.Count; i++)
			{
				if (!GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId1) || !GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId2) || !GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId3))
				{
					val = self.metaShopTiers[i];
					break;
				}
			}
			List<MetaShopTier> metaShopTiers = self.metaShopTiers;
			List<MetaShopTier> list = new List<MetaShopTier>();
			for (int j = 0; j < metaShopTiers.Count; j++)
			{
				if (metaShopTiers[j] != null && (!ItemConditionsFulfilled(metaShopTiers[j].itemId1) || !ItemConditionsFulfilled(metaShopTiers[j].itemId2) || !ItemConditionsFulfilled(metaShopTiers[j].itemId3) || j == metaShopTiers.Count - 1))
				{
					list.Add(metaShopTiers[j]);
				}
			}
			self.metaShopTiers = list;
			MetaShopTier val2 = orig(self);
			self.metaShopTiers = metaShopTiers;
			if (val == null)
			{
				return val2;
			}
			if (val2 == null)
			{
				return val;
			}
			return (self.metaShopTiers.IndexOf(val) < self.metaShopTiers.IndexOf(val2)) ? val : val2;
		}

		public static MetaShopTier MetaShopProximateTierHook(Func<MetaShopController, MetaShopTier> orig, MetaShopController self)
		{
			MetaShopTier val = null;
			for (int i = 0; i < self.metaShopTiers.Count - 1; i++)
			{
				if (!GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId1) || !GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId2) || !GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId3))
				{
					val = self.metaShopTiers[i + 1];
					break;
				}
			}
			List<MetaShopTier> metaShopTiers = self.metaShopTiers;
			List<MetaShopTier> list = new List<MetaShopTier>();
			for (int j = 0; j < metaShopTiers.Count; j++)
			{
				if (metaShopTiers[j] != null && (!ItemConditionsFulfilled(metaShopTiers[j].itemId1) || !ItemConditionsFulfilled(metaShopTiers[j].itemId2) || !ItemConditionsFulfilled(metaShopTiers[j].itemId3)))
				{
					list.Add(metaShopTiers[j]);
				}
			}
			self.metaShopTiers = list;
			MetaShopTier val2 = orig(self);
			self.metaShopTiers = metaShopTiers;
			if (val == null)
			{
				return val2;
			}
			if (val2 == null)
			{
				return val;
			}
			return (self.metaShopTiers.IndexOf(val) < self.metaShopTiers.IndexOf(val2)) ? val : val2;
		}

		public static CustomDungeonFlags GetCustomFlagFromTargetItem(int shopItemId)
		{
			CustomDungeonFlags result = CustomDungeonFlags.NONE;
			PickupObject byId = PickupObjectDatabase.GetById(shopItemId);
			for (int i = 0; i < ((BraveBehaviour)byId).encounterTrackable.prerequisites.Length; i++)
			{
				if (((BraveBehaviour)byId).encounterTrackable.prerequisites[i] is CustomDungeonPrerequisite && (((BraveBehaviour)byId).encounterTrackable.prerequisites[i] as CustomDungeonPrerequisite).advancedPrerequisiteType == CustomDungeonPrerequisite.AdvancedPrerequisiteType.CUSTOM_FLAG)
				{
					result = (((BraveBehaviour)byId).encounterTrackable.prerequisites[i] as CustomDungeonPrerequisite).customFlagToCheck;
				}
			}
			return result;
		}

		public static GungeonFlags GetFlagFromTargetItem(int shopItemId)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0058: 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_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_005d: Unknown result type (might be due to invalid IL or missing references)
			GungeonFlags result = (GungeonFlags)0;
			PickupObject byId = PickupObjectDatabase.GetById(shopItemId);
			for (int i = 0; i < ((BraveBehaviour)byId).encounterTrackable.prerequisites.Length; i++)
			{
				if ((int)((BraveBehaviour)byId).encounterTrackable.prerequisites[i].prerequisiteType == 4)
				{
					result = ((BraveBehaviour)byId).encounterTrackable.prerequisites[i].saveFlagToCheck;
				}
			}
			return result;
		}

		public static bool ItemConditionsFulfilled(int shopItemId)
		{
			return (Object)(object)PickupObjectDatabase.GetById(shopItemId) != (Object)null && PickupObjectDatabase.GetById(shopItemId).PrerequisitesMet();
		}

		public static PickupObject GetBlueprintUnlockedItem(EncounterTrackable blueprintTrackable)
		{
			for (int i = 0; i < ((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).Objects.Count; i++)
			{
				PickupObject val = ((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).Objects[i];
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				EncounterTrackable encounterTrackable = ((BraveBehaviour)val).encounterTrackable;
				if (!Object.op_Implicit((Object)(object)encounterTrackable))
				{
					continue;
				}
				string primaryDisplayName = encounterTrackable.journalData.PrimaryDisplayName;
				if (!primaryDisplayName.Equals(blueprintTrackable.journalData.PrimaryDisplayName, StringComparison.OrdinalIgnoreCase))
				{
					continue;
				}
				string notificationPanelDescription = encounterTrackable.journalData.NotificationPanelDescription;
				if (!notificationPanelDescription.Equals(blueprintTrackable.journalData.NotificationPanelDescription, StringComparison.OrdinalIgnoreCase))
				{
					continue;
				}
				string ammonomiconFullEntry = encounterTrackable.journalData.AmmonomiconFullEntry;
				if (ammonomiconFullEntry.Equals(blueprintTrackable.journalData.AmmonomiconFullEntry, StringComparison.OrdinalIgnoreCase))
				{
					string ammonomiconSprite = encounterTrackable.journalData.AmmonomiconSprite;
					if (ammonomiconSprite.Equals(blueprintTrackable.journalData.AmmonomiconSprite, StringComparison.OrdinalIgnoreCase))
					{
						return val;
					}
				}
			}
			return null;
		}

		public static WeightedGameObject AddItemToTrorcMetaShop(this PickupObject po, int cost, int? index = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if ((Object)(object)TrorcMetaShopItems == (Object)null)
			{
				DoSetup();
			}
			WeightedGameObject val = new WeightedGameObject();
			val.rawGameObject = null;
			val.pickupId = po.PickupObjectId;
			val.weight = cost;
			val.forceDuplicatesPossible = false;
			val.additionalPrerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
			WeightedGameObject val2 = val;
			if (!index.HasValue)
			{
				TrorcMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else if (index.Value < 0)
			{
				TrorcMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else
			{
				TrorcMetaShopItems.defaultItemDrops.elements.InsertOrAdd(index.Value, val2);
			}
			RegisterBaseShopControllerAddedItem(val2, TrorcMetaShopItems.defaultItemDrops);
			return val2;
		}

		public static WeightedGameObject AddItemToGooptonMetaShop(this PickupObject po, int cost, int? index = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if ((Object)(object)GooptonMetaShopItems == (Object)null)
			{
				DoSetup();
			}
			WeightedGameObject val = new WeightedGameObject();
			val.rawGameObject = null;
			val.pickupId = po.PickupObjectId;
			val.weight = cost;
			val.forceDuplicatesPossible = false;
			val.additionalPrerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
			WeightedGameObject val2 = val;
			if (!index.HasValue)
			{
				GooptonMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else if (index.Value < 0)
			{
				TrorcMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else
			{
				GooptonMetaShopItems.defaultItemDrops.elements.InsertOrAdd(index.Value, val2);
			}
			RegisterBaseShopControllerAddedItem(val2, GooptonMetaShopItems.defaultItemDrops);
			return val2;
		}

		public static WeightedGameObject AddItemToDougMetaShop(this PickupObject po, int cost, int? index = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if ((Object)(object)DougMetaShopItems == (Object)null)
			{
				DoSetup();
			}
			WeightedGameObject val = new WeightedGameObject();
			val.rawGameObject = null;
			val.pickupId = po.PickupObjectId;
			val.weight = cost;
			val.forceDuplicatesPossible = false;
			val.additionalPrerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
			WeightedGameObject val2 = val;
			if (!index.HasValue)
			{
				DougMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else if (index.Value < 0)
			{
				DougMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else
			{
				DougMetaShopItems.defaultItemDrops.elements.InsertOrAdd(index.Value, val2);
			}
			RegisterBaseShopControllerAddedItem(val2, DougMetaShopItems.defaultItemDrops);
			return val2;
		}

		private static void RegisterBaseShopControllerAddedItem(WeightedGameObject obj, WeightedGameObjectCollection collection)
		{
			if (baseShopAddedItems == null)
			{
				baseShopAddedItems = new Dictionary<WeightedGameObjectCollection, List<WeightedGameObject>>();
			}
			if (!baseShopAddedItems.ContainsKey(collection))
			{
				baseShopAddedItems.Add(collection, new List<WeightedGameObject>());
			}
			if (baseShopAddedItems[collection] == null)
			{
				baseShopAddedItems[collection] = new List<WeightedGameObject>();
			}
			baseShopAddedItems[collection].Add(obj);
		}

		public static List<MetaShopTier> AddBaseMetaShopDoubleTier(int topLeftItemId, int topLeftItemPrice, int topMiddleItemId, int topMiddleItemPrice, int topRightItemId, int topRightItemPrice, int bottomLeftItemId, int bottomLeftItemPrice, int bottomMiddleItemId, int bottomMiddleItemPrice, int bottomRightItemId, int bottomRightItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005e: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_007a: Expected O, but got Unknown
			return AddBaseMetaShopDoubleTier(new DoubleMetaShopTier(new MetaShopTier
			{
				itemId1 = topLeftItemId,
				overrideItem1Cost = topLeftItemPrice,
				itemId2 = topMiddleItemId,
				overrideItem2Cost = topMiddleItemPrice,
				itemId3 = topRightItemId,
				overrideItem3Cost = topRightItemPrice,
				overrideTierCost = topLeftItemId
			}, new MetaShopTier
			{
				itemId1 = bottomLeftItemId,
				overrideItem1Cost = bottomLeftItemPrice,
				itemId2 = bottomMiddleItemId,
				overrideItem2Cost = bottomMiddleItemPrice,
				itemId3 = bottomRightItemId,
				overrideItem3Cost = bottomRightItemPrice,
				overrideTierCost = topLeftItemId
			}), index);
		}

		public static List<MetaShopTier> AddBaseMetaShopDoubleTier(int topLeftItemId, int topLeftItemPrice, int topMiddleItemId, int topMiddleItemPrice, int topRightItemId, int topRightItemPrice, int bottomLeftItemId, int bottomLeftItemPrice, int bottomMiddleItemId, int bottomMiddleItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0078: Expected O, but got Unknown
			//IL_0078: Expected O, but got Unknown
			return AddBaseMetaShopDoubleTier(new DoubleMetaShopTier(new MetaShopTier
			{
				itemId1 = topLeftItemId,
				overrideItem1Cost = topLeftItemPrice,
				itemId2 = topMiddleItemId,
				overrideItem2Cost = topMiddleItemPrice,
				itemId3 = topRightItemId,
				overrideItem3Cost = topRightItemPrice,
				overrideTierCost = topLeftItemId
			}, new MetaShopTier
			{
				itemId1 = bottomLeftItemId,
				overrideItem1Cost = bottomLeftItemPrice,
				itemId2 = bottomMiddleItemId,
				overrideItem2Cost = bottomMiddleItemPrice,
				itemId3 = -1,
				overrideItem3Cost = -1,
				overrideTierCost = topLeftItemId
			}), index);
		}

		public static List<MetaShopTier> AddBaseMetaShopDoubleTier(int topLeftItemId, int topLeftItemPrice, int topMiddleItemId, int topMiddleItemPrice, int topRightItemId, int topRightItemPrice, int bottomLeftItemId, int bottomLeftItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005c: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0076: Expected O, but got Unknown
			return AddBaseMetaShopDoubleTier(new DoubleMetaShopTier(new MetaShopTier
			{
				itemId1 = topLeftItemId,
				overrideItem1Cost = topLeftItemPrice,
				itemId2 = topMiddleItemId,
				overrideItem2Cost = topMiddleItemPrice,
				itemId3 = topRightItemId,
				overrideItem3Cost = topRightItemPrice,
				overrideTierCost = topLeftItemId
			}, new MetaShopTier
			{
				itemId1 = bottomLeftItemId,
				overrideItem1Cost = bottomLeftItemPrice,
				itemId2 = -1,
				overrideItem2Cost = -1,
				itemId3 = -1,
				overrideItem3Cost = -1,
				overrideTierCost = topLeftItemId
			}), index);
		}

		public static MetaShopTier AddBaseMetaShopTier(int leftItemId, int leftItemPrice, int middleItemId, int middleItemPrice, int rightItemId, int rightItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			return AddBaseMetaShopTier(new MetaShopTier
			{
				itemId1 = leftItemId,
				overrideItem1Cost = leftItemPrice,
				itemId2 = middleItemId,
				overrideItem2Cost = middleItemPrice,
				itemId3 = rightItemId,
				overrideItem3Cost = rightItemPrice,
				overrideTierCost = leftItemPrice
			}, index);
		}

		public static MetaShopTier AddBaseMetaShopTier(int leftItemId, int leftItemPrice, int middleItemId, int middleItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0029: 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_003e: Expected O, but got Unknown
			return AddBaseMetaShopTier(new MetaShopTier
			{
				itemId1 = leftItemId,
				overrideItem1Cost = leftItemPrice,
				itemId2 = middleItemId,
				overrideItem2Cost = middleItemPrice,
				itemId3 = -1,
				overrideItem3Cost = -1,
				overrideTierCost = leftItemPrice
			}, index);
		}

		public static MetaShopTier AddBaseMetaShopTier(int leftItemId, int leftItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0029: 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_003d: Expected O, but got Unknown
			return AddBaseMetaShopTier(new MetaShopTier
			{
				itemId1 = leftItemId,
				overrideItem1Cost = leftItemPrice,
				itemId2 = -1,
				overrideItem2Cost = -1,
				itemId3 = -1,
				overrideItem3Cost = -1,
				overrideTierCost = leftItemPrice
			}, index);
		}

		public static List<MetaShopTier> AddBaseMetaShopDoubleTier(DoubleMetaShopTier tier, int? index = null)
		{
			return new List<MetaShopTier>
			{
				AddBaseMetaShopTier(tier.GetBottomTier(), index),
				AddBaseMetaShopTier(tier.GetTopTier(), index)
			};
		}

		public static MetaShopTier AddBaseMetaShopTier(MetaShopTier tier, int? index = null)
		{
			if ((Object)(object)BaseMetaShopController == (Object)null)
			{
				DoSetup();
			}
			if (!index.HasValue)
			{
				BaseMetaShopController.metaShopTiers.Add(tier);
			}
			else if (index.Value < 0)
			{
				BaseMetaShopController.metaShopTiers.Add(tier);
			}
			else
			{
				BaseMetaShopController.metaShopTiers.InsertOrAdd(index.Value, tier);
			}
			if (metaShopAddedTiers == null)
			{
				metaShopAddedTiers = new List<MetaShopTier>();
			}
			metaShopAddedTiers.Add(tier);
			ReloadInstanceMetaShopTiers();
			return tier;
		}

		public static void ReloadInstanceMetaShopTiers()
		{
			MetaShopController[] array = Object.FindObjectsOfType<MetaShopController>();
			foreach (MetaShopController val in array)
			{
				val.metaShopTiers = SaveTools.CloneList(BaseMetaShopController.metaShopTiers);
			}
		}
	}
	public class CustomDungeonPrerequisite : DungeonPrerequisite
	{
		public enum AdvancedPrerequisiteType
		{
			NONE,
			CUSTOM_FLAG,
			CUSTOM_STAT_COMPARISION,
			CUSTOM_MAXIMUM_COMPARISON,
			NUMBER_PASTS_COMPLETED_BETTER,
			ENCOUNTER_OR_CUSTOM_FLAG
		}

		public AdvancedPrerequisiteType advancedPrerequisiteType;

		public CustomDungeonFlags customFlagToCheck;

		public bool requireCustomFlag;

		public Type requiredPassiveFlag;

		public CustomTrackedMaximums customMaximumToCheck;

		public CustomTrackedStats customStatToCheck;

		public virtual bool CheckConditionsFulfilled()
		{
			//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_0054: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected I4, but got Unknown
			//IL_00d0: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected I4, 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_0158: 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_016f: Expected I4, but got Unknown
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected I4, but got Unknown
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: 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_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Expected I4, but got Unknown
			if (advancedPrerequisiteType == AdvancedPrerequisiteType.CUSTOM_FLAG)
			{
				return AdvancedGameStatsManager.Instance.GetFlag(customFlagToCheck) == requireCustomFlag;
			}
			if (advancedPrerequisiteType == AdvancedPrerequisiteType.CUSTOM_STAT_COMPARISION)
			{
				float playerStatValue = AdvancedGameStatsManager.Instance.GetPlayerStatValue(customStatToCheck);
				PrerequisiteOperation prerequisiteOperation = base.prerequisiteOperation;
				PrerequisiteOperation val = prerequisiteOperation;
				switch ((int)val)
				{
				case 0:
					return playerStatValue < base.comparisonValue;
				case 1:
					return playerStatValue == base.comparisonValue;
				case 2:
					return playerStatValue > base.comparisonValue;
				}
				Debug.LogError((object)"Switching on invalid stat comparison operation!");
			}
			else if (advancedPrerequisiteType == AdvancedPrerequisiteType.CUSTOM_MAXIMUM_COMPARISON)
			{
				float playerMaximum = AdvancedGameStatsManager.Instance.GetPlayerMaximum(customMaximumToCheck);
				PrerequisiteOperation prerequisiteOperation2 = base.prerequisiteOperation;
				PrerequisiteOperation val2 = prerequisiteOperation2;
				switch ((int)val2)
				{
				case 0:
					return playerMaximum < base.comparisonValue;
				case 1:
					return playerMaximum == base.comparisonValue;
				case 2:
					return playerMaximum > base.comparisonValue;
				}
				Debug.LogError((object)"Switching on invalid stat comparison operation!");
			}
			else
			{
				if (advancedPrerequisiteType != AdvancedPrerequisiteType.NUMBER_PASTS_COMPLETED_BETTER)
				{
					if (advancedPrerequisiteType == AdvancedPrerequisiteType.ENCOUNTER_OR_CUSTOM_FLAG)
					{
						EncounterDatabaseEntry val3 = null;
						if (!string.IsNullOrEmpty(base.encounteredObjectGuid))
						{
							val3 = EncounterDatabase.GetEntry(base.encounteredObjectGuid);
						}
						if (AdvancedGameStatsManager.Instance.GetFlag(customFlagToCheck) == requireCustomFlag)
						{
							return true;
						}
						if (val3 != null)
						{
							int num = GameStatsManager.Instance.QueryEncounterable(val3);
							PrerequisiteOperation prerequisiteOperation3 = base.prerequisiteOperation;
							PrerequisiteOperation val4 = prerequisiteOperation3;
							switch ((int)val4)
							{
							case 0:
								return num < base.requiredNumberOfEncounters;
							case 1:
								return num == base.requiredNumberOfEncounters;
							case 2:
								return num > base.requiredNumberOfEncounters;
							}
							Debug.LogError((object)"Switching on invalid stat comparison operation!");
						}
						else if ((Object)(object)base.encounteredRoom != (Object)null)
						{
							int num2 = GameStatsManager.Instance.QueryRoomEncountered(base.encounteredRoom.GUID);
							PrerequisiteOperation prerequisiteOperation4 = base.prerequisiteOperation;
							PrerequisiteOperation val5 = prerequisiteOperation4;
							switch ((int)val5)
							{
							case 0:
								return num2 < base.requiredNumberOfEncounters;
							case 1:
								return num2 == base.requiredNumberOfEncounters;
							case 2:
								return num2 > base.requiredNumberOfEncounters;
							}
							Debug.LogError((object)"Switching on invalid stat comparison operation!");
						}
						return false;
					}
					return CheckConditionsFulfilledOrig();
				}
				float num3 = GameStatsManager.Instance.GetNumberPastsBeaten();
				PrerequisiteOperation prerequisiteOperation5 = base.prerequisiteOperation;
				PrerequisiteOperation val6 = prerequisiteOperation5;
				switch ((int)val6)
				{
				case 0:
					return num3 < base.comparisonValue;
				case 1:
					return num3 == base.comparisonValue;
				case 2:
					return num3 > base.comparisonValue;
				}
				Debug.LogError((object)"Switching on invalid stat comparison operation!");
			}
			return false;
		}

		public bool CheckConditionsFulfilledOrig()
		{
			//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)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0056: Expected I4, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: 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_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected I4, but got Unknown
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Expected I4, but got Unknown
			//IL_03d7: 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_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Expected I4, but got Unknown
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)