Decompiled source of Begone Dog v2.0.0

BegoneDog.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Dungeonator;
using Gungeon;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BegoneDog")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BegoneDog")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("51ff5650-6cdb-4fc8-bd50-064422b0957d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BegoneDog;

public static class AtlasTools
{
	public static string AddToAtlas(string textureName, string overrideName = null)
	{
		ItemInfo info;
		return AddToAtlas(Plugin.bundle.LoadAsset<Texture2D>(textureName), out info, overrideName);
	}

	public static string AddToAtlas(string textureName, out ItemInfo info, string overrideName = null)
	{
		return AddToAtlas(Plugin.bundle.LoadAsset<Texture2D>(textureName), out info, overrideName);
	}

	public static string AddToAtlas(Texture2D tex, string overrideName = null)
	{
		ItemInfo info;
		return AddToAtlas(tex, out info, overrideName);
	}

	public static string AddToAtlas(Texture2D tex, out ItemInfo info, string overrideName = null)
	{
		string text = overrideName ?? ("begonedog_" + ((Object)tex).name);
		info = Plugin.UIRootPrefab.Manager.DefaultAtlas.AddNewItemToAtlas(tex, text);
		return text;
	}

	public static ItemInfo AddNewItemToAtlas(this dfAtlas atlas, Texture2D tex, string name = null)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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)
		//IL_0047: Expected O, but got Unknown
		//IL_0047: 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_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: 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)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Expected O, but got Unknown
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrEmpty(name))
		{
			name = ((Object)tex).name;
		}
		if (atlas[name] != (ItemInfo)null)
		{
			return atlas[name];
		}
		ItemInfo val = new ItemInfo
		{
			border = new RectOffset(),
			deleted = false,
			name = name,
			region = atlas.FindFirstValidEmptySpace(new IntVector2(((Texture)tex).width, ((Texture)tex).height)),
			rotated = false,
			sizeInPixels = new Vector2((float)((Texture)tex).width, (float)((Texture)tex).height),
			texture = tex,
			textureGUID = name
		};
		int num = Mathf.RoundToInt(((Rect)(ref val.region)).x * (float)((Texture)atlas.Texture).width);
		int num2 = Mathf.RoundToInt(((Rect)(ref val.region)).y * (float)((Texture)atlas.Texture).height);
		for (int i = num; i < Mathf.RoundToInt(((Rect)(ref val.region)).xMax * (float)((Texture)atlas.Texture).width); i++)
		{
			for (int j = num2; j < Mathf.RoundToInt(((Rect)(ref val.region)).yMax * (float)((Texture)atlas.Texture).height); j++)
			{
				atlas.Texture.SetPixel(i, j, tex.GetPixel(i - num, j - num2));
			}
		}
		atlas.Texture.Apply();
		atlas.AddItem(val);
		return val;
	}

	public static Rect FindFirstValidEmptySpace(this dfAtlas atlas, IntVector2 pixelScale)
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: 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_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a1: 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_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)atlas == (Object)null || (Object)(object)atlas.Texture == (Object)null || !ETGMod.IsReadable(atlas.Texture))
		{
			return new Rect(0f, 0f, 0f, 0f);
		}
		Vector2Int val = default(Vector2Int);
		((Vector2Int)(ref val))..ctor(0, 0);
		int num = -1;
		List<RectInt> pixelRegions = atlas.GetPixelRegions();
		bool flag;
		RectInt self = default(RectInt);
		do
		{
			flag = false;
			foreach (RectInt item in pixelRegions)
			{
				RectInt val2;
				if (item.Overlaps(new RectInt(val, pixelScale.ToVector2Int())))
				{
					flag = true;
					num++;
					if (num >= pixelRegions.Count)
					{
						return new Rect(0f, 0f, 0f, 0f);
					}
					val2 = pixelRegions[num];
					val = ((RectInt)(ref val2)).max + Vector2Int.one;
					if (((Vector2Int)(ref val)).x > ((Texture)atlas.Texture).width || ((Vector2Int)(ref val)).y > ((Texture)atlas.Texture).height)
					{
						atlas.ResizeAtlas(new IntVector2(((Texture)atlas.Texture).width * 2, ((Texture)atlas.Texture).height * 2));
					}
					break;
				}
				bool flag2 = false;
				foreach (RectInt item2 in pixelRegions)
				{
					RectInt current2 = item2;
					((RectInt)(ref self))..ctor(val, pixelScale.ToVector2Int());
					if (((RectInt)(ref current2)).x < ((RectInt)(ref self)).x || ((RectInt)(ref current2)).y < ((RectInt)(ref self)).y || !self.Overlaps(current2))
					{
						continue;
					}
					flag = true;
					flag2 = true;
					num++;
					if (num >= pixelRegions.Count)
					{
						return new Rect(0f, 0f, 0f, 0f);
					}
					val2 = pixelRegions[num];
					val = ((RectInt)(ref val2)).max + Vector2Int.one;
					if (((Vector2Int)(ref val)).x > ((Texture)atlas.Texture).width || ((Vector2Int)(ref val)).y > ((Texture)atlas.Texture).height)
					{
						atlas.ResizeAtlas(new IntVector2(((Texture)atlas.Texture).width * 2, ((Texture)atlas.Texture).height * 2));
					}
					break;
				}
				if (flag2)
				{
					break;
				}
			}
		}
		while (flag);
		RectInt val3 = default(RectInt);
		((RectInt)(ref val3))..ctor(val, pixelScale.ToVector2Int());
		if (((RectInt)(ref val3)).xMax > ((Texture)atlas.Texture).width || ((RectInt)(ref val3)).yMax > ((Texture)atlas.Texture).height)
		{
			atlas.ResizeAtlas(new IntVector2(((Texture)atlas.Texture).width * 2, ((Texture)atlas.Texture).height * 2));
		}
		RectInt val4 = default(RectInt);
		((RectInt)(ref val4))..ctor(val, pixelScale.ToVector2Int());
		Rect result = default(Rect);
		((Rect)(ref result))..ctor((float)((RectInt)(ref val4)).x / (float)((Texture)atlas.Texture).width, (float)((RectInt)(ref val4)).y / (float)((Texture)atlas.Texture).height, (float)((RectInt)(ref val4)).width / (float)((Texture)atlas.Texture).width, (float)((RectInt)(ref val4)).height / (float)((Texture)atlas.Texture).height);
		return result;
	}

	public static List<RectInt> GetPixelRegions(this dfAtlas atlas)
	{
		return atlas.Items.ConvertAll((Converter<ItemInfo, RectInt>)((ItemInfo item) => new RectInt(Mathf.RoundToInt(((Rect)(ref item.region)).x * (float)((Texture)atlas.Texture).width), Mathf.RoundToInt(((Rect)(ref item.region)).y * (float)((Texture)atlas.Texture).height), Mathf.RoundToInt(((Rect)(ref item.region)).width * (float)((Texture)atlas.Texture).width), Mathf.RoundToInt(((Rect)(ref item.region)).height * (float)((Texture)atlas.Texture).height))));
	}

	public static Vector2Int ToVector2Int(this IntVector2 vector)
	{
		//IL_0001: 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_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		return new Vector2Int(vector.x, vector.y);
	}

	public static bool Overlaps(this RectInt self, RectInt other)
	{
		return ((RectInt)(ref other)).xMax > ((RectInt)(ref self)).xMin && ((RectInt)(ref other)).xMin < ((RectInt)(ref self)).xMax && ((RectInt)(ref other)).yMax > ((RectInt)(ref self)).yMin && ((RectInt)(ref other)).yMin < ((RectInt)(ref self)).yMax;
	}

	public static void ResizeAtlas(this dfAtlas atlas, IntVector2 newDimensions)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: 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_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		Texture2D texture = atlas.Texture;
		if (!ETGMod.IsReadable(texture) || (((Texture)texture).width == newDimensions.x && ((Texture)texture).height == newDimensions.y))
		{
			return;
		}
		foreach (ItemInfo item in atlas.Items)
		{
			_ = item.region;
			if (true)
			{
				((Rect)(ref item.region)).x = ((Rect)(ref item.region)).x * (float)((Texture)texture).width / (float)newDimensions.x;
				((Rect)(ref item.region)).y = ((Rect)(ref item.region)).y * (float)((Texture)texture).height / (float)newDimensions.y;
				((Rect)(ref item.region)).width = ((Rect)(ref item.region)).width * (float)((Texture)texture).width / (float)newDimensions.x;
				((Rect)(ref item.region)).height = ((Rect)(ref item.region)).height * (float)((Texture)texture).height / (float)newDimensions.y;
			}
		}
		texture.ResizeBetter(newDimensions.x, newDimensions.y);
		atlas.Material.SetTexture("_MainTex", (Texture)(object)texture);
	}

	public static bool ResizeBetter(this Texture2D tex, int width, int height)
	{
		//IL_0057: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		if (ETGMod.IsReadable(tex))
		{
			Color[][] array = new Color[Math.Min(((Texture)tex).width, width)][];
			for (int i = 0; i < Math.Min(((Texture)tex).width, width); i++)
			{
				for (int j = 0; j < Math.Min(((Texture)tex).height, height); j++)
				{
					if (array[i] == null)
					{
						array[i] = (Color[])(object)new Color[Math.Min(((Texture)tex).height, height)];
					}
					array[i][j] = tex.GetPixel(i, j);
				}
			}
			bool result = tex.Resize(width, height);
			for (int k = 0; k < ((Texture)tex).width; k++)
			{
				for (int l = 0; l < ((Texture)tex).height; l++)
				{
					bool flag = false;
					if (k < array.Length && l < array[k].Length)
					{
						flag = true;
						tex.SetPixel(k, l, array[k][l]);
					}
					if (!flag)
					{
						tex.SetPixel(k, l, Color.clear);
					}
				}
			}
			tex.Apply();
			return result;
		}
		return tex.Resize(width, height);
	}
}
public class DogFuckingDies : MonoBehaviour
{
	public void Start()
	{
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}
}
public class ForeverUnpettable : MonoBehaviour
{
	public CompanionController cc;

	public void Start()
	{
		cc = ((Component)this).GetComponent<CompanionController>();
	}

	public void Update()
	{
		if ((Object)(object)cc != (Object)null && cc.CanBePet)
		{
			cc.CanBePet = false;
		}
	}
}
[HarmonyPatch]
public class OldJournal : PassiveItem
{
	public GenericLootTable ItemFindLootTable;

	public float ChanceToFindItemOnRoomClear = 0.05f;

	public static int Init()
	{
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Plugin.bundle.LoadAsset<GameObject>("begonedog_hunterjournal");
		tk2dSpriteCollectionData collection = ((BraveBehaviour)PickupObjectDatabase.GetById(155)).sprite.Collection;
		tk2dSprite.AddComponent(val, collection, collection.GetSpriteIdByName("diary_001"));
		OldJournal oldJournal = val.AddComponent<OldJournal>();
		oldJournal.ItemFindLootTable = LoadHelper.LoadAssetFromAnywhere<GenericLootTable>("CommonItemRoomClearDropTable");
		oldJournal.ChanceToFindItemOnRoomClear = 0.05f;
		Databases.Items.SetupItem((PickupObject)(object)oldJournal, "Hunter's Journal");
		((BraveBehaviour)oldJournal).encounterTrackable.journalData.AmmonomiconSprite = "diary_001";
		GunExt.SetShortDescription((PickupObject)(object)oldJournal, "Better Than Dogs");
		GunExt.SetLongDescription((PickupObject)(object)oldJournal, "Slightly increases drop rate.\n\nFilled with maps and the answers to half-forgotten riddles. Ever since the Hunter was a child, she had a knack for finding things.");
		Game.Items.Add("spapi:hunters_journal", (PickupObject)(object)oldJournal);
		Databases.Items.AddSpecific(false, (PickupObject)(object)oldJournal, false, "ANY");
		((PickupObject)oldJournal).quality = (ItemQuality)1;
		((PickupObject)oldJournal).ForcedPositionInAmmonomicon = PickupObjectDatabase.GetById(300).ForcedPositionInAmmonomicon;
		((PickupObject)(object)oldJournal).SetupUnlockOnFlag((GungeonFlags)18004, requiredFlagValue: true);
		return ((PickupObject)oldJournal).PickupObjectId;
	}

	public override void Pickup(PlayerController player)
	{
		((PassiveItem)this).Pickup(player);
		player.OnRoomClearEvent += HandleRoomCleared;
		PassiveItem.IncrementFlag(player, typeof(OldJournal));
	}

	public void HandleRoomCleared(PlayerController obj)
	{
		//IL_004a: 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_0056: 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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_005e: 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)
		if (Random.value < ChanceToFindItemOnRoomClear)
		{
			GameObject obj2 = ItemFindLootTable.SelectByWeight(false);
			Vector2 val;
			if (obj.CurrentRoom == null)
			{
				val = ((GameActor)obj).CenterPosition + Vector2.down * 2f;
			}
			else
			{
				IntVector2 bestRewardLocation = obj.CurrentRoom.GetBestRewardLocation(new IntVector2(1, 1), (RewardLocationStyle)0, true);
				val = ((IntVector2)(ref bestRewardLocation)).ToVector2();
			}
			LootEngine.SpawnItem(obj2, Vector2.op_Implicit(val), Vector2.up, 1f, true, true, false);
		}
	}

	public override void DisableEffect(PlayerController player)
	{
		if ((Object)(object)player != (Object)null)
		{
			PassiveItem.DecrementFlag(player, typeof(OldJournal));
			player.OnRoomClearEvent -= HandleRoomCleared;
		}
		((PassiveItem)this).DisableEffect(player);
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPrefix]
	public static bool ShowChestMimics(Chest __instance, ref Color __result)
	{
		//IL_002b: 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)
		if (PassiveItem.IsFlagSetAtAll(typeof(OldJournal)) && __instance.m_isMimic && !Dungeon.IsGenerating)
		{
			__result = Color.red;
			return false;
		}
		return true;
	}
}
[BepInPlugin("spapi.etg.begonedog", "Begone Dog", "2.0.0")]
[HarmonyPatch]
public class Plugin : BaseUnityPlugin
{
	public const string GUID = "spapi.etg.begonedog";

	public const string NAME = "Begone Dog";

	public const string VERSION = "2.0.0";

	public static AssetBundle bundle;

	public static GameUIRoot UIRootPrefab;

	public static GameObject modifiedHunter;

	public void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("spapi.etg.begonedog").PatchAll();
		using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BegoneDog.begonedogbundle"))
		{
			bundle = AssetBundle.LoadFromStream(stream);
		}
		AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid("c07ef60ae32b404f99e294a6f9acba75");
		AIActor orLoadByGuid2 = EnemyDatabase.GetOrLoadByGuid("ededff1deaf3430eaf8321d0c6b2bd80");
		AIActor orLoadByGuid3 = EnemyDatabase.GetOrLoadByGuid("ebf2314289ff4a4ead7ea7ef363a0a2e");
		AIActor orLoadByGuid4 = EnemyDatabase.GetOrLoadByGuid("ab4a779d6e8f429baafa4bf9e5dca3a9");
		((Component)orLoadByGuid).gameObject.AddComponent<DogFuckingDies>();
		((Component)orLoadByGuid).gameObject.AddComponent<ForeverUnpettable>();
		((Component)orLoadByGuid2).gameObject.AddComponent<ForeverUnpettable>();
		((Component)orLoadByGuid3).gameObject.AddComponent<DogFuckingDies>();
		((Component)orLoadByGuid3).gameObject.AddComponent<ForeverUnpettable>();
		((Component)orLoadByGuid4).gameObject.AddComponent<DogFuckingDies>();
		((Component)orLoadByGuid4).gameObject.AddComponent<ForeverUnpettable>();
		PickupObject byId = PickupObjectDatabase.GetById(300);
		byId.quality = (ItemQuality)(-100);
		((BraveBehaviour)byId).encounterTrackable.SuppressInInventory = true;
		((BraveBehaviour)byId).encounterTrackable.journalData.SuppressInAmmonomicon = true;
		EncounterDatabase.GetEntry(((BraveBehaviour)byId).encounterTrackable.EncounterGuid).journalData.SuppressInAmmonomicon = true;
		UIRootPrefab = LoadHelper.LoadAssetFromAnywhere<GameObject>("UI Root").GetComponent<GameUIRoot>();
		ItemInfo info;
		string spriteName = AtlasTools.AddToAtlas("hunterjournal", out info);
		dfSprite component = ((Component)LoadHelper.LoadAssetFromAnywhere<GameObject>("CHR_GuidePanel").transform.Find("TextPanel").Find("ItemsPanel (1)").Find("Sprite (3)")).GetComponent<dfSprite>();
		component.SpriteName = spriteName;
		((dfControl)component).size = info.sizeInPixels * 3f;
		ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)delegate
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			GameObject val = (GameObject)BraveResources.Load("PlayerGuide", ".prefab");
			int item = OldJournal.Init();
			if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent<PlayerController>() != (Object)null && val.GetComponent<PlayerController>().startingPassiveItemIds.Contains(300))
			{
				val.GetComponent<PlayerController>().startingPassiveItemIds.Remove(300);
				val.GetComponent<PlayerController>().startingPassiveItemIds.Add(item);
				modifiedHunter = val;
			}
		});
	}

	[HarmonyPatch(typeof(FoyerCharacterSelectFlag), "Start")]
	[HarmonyPostfix]
	public static void GetRidOfStuff(FoyerCharacterSelectFlag __instance)
	{
		Transform val = ((BraveBehaviour)__instance).transform.Find("Doggy");
		if ((Object)(object)val != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)val).gameObject);
		}
	}
}
public static class UnlockTools
{
	public static DungeonPrerequisite SetupUnlockOnFlag(this PickupObject self, GungeonFlags flag, bool requiredFlagValue)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
		{
			return null;
		}
		return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnFlag(flag, requiredFlagValue);
	}

	public static DungeonPrerequisite SetupUnlockOnFlag(this EncounterTrackable self, GungeonFlags flag, bool requiredFlagValue)
	{
		//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_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: 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_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		return self.AddPrerequisite(new DungeonPrerequisite
		{
			prerequisiteType = (PrerequisiteType)4,
			saveFlagToCheck = flag,
			requireFlag = requiredFlagValue
		});
	}

	public static DungeonPrerequisite AddPrerequisite(this PickupObject self, DungeonPrerequisite prereq)
	{
		return ((BraveBehaviour)self).encounterTrackable.AddPrerequisite(prereq);
	}

	public static DungeonPrerequisite AddPrerequisite(this EncounterTrackable self, DungeonPrerequisite prereq)
	{
		if (!string.IsNullOrEmpty(self.ProxyEncounterGuid))
		{
			self.ProxyEncounterGuid = "";
		}
		if (self.prerequisites == null)
		{
			self.prerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[1] { prereq };
		}
		else
		{
			DungeonPrerequisite[] prerequisites = self.prerequisites;
			prerequisites = CollectionExtensions.AddToArray<DungeonPrerequisite>(prerequisites, prereq);
			self.prerequisites = prerequisites;
		}
		EncounterDatabaseEntry entry = EncounterDatabase.GetEntry(self.EncounterGuid);
		if (!string.IsNullOrEmpty(entry.ProxyEncounterGuid))
		{
			entry.ProxyEncounterGuid = "";
		}
		if (entry.prerequisites == null)
		{
			entry.prerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[1] { prereq };
		}
		else
		{
			DungeonPrerequisite[] prerequisites2 = entry.prerequisites;
			prerequisites2 = CollectionExtensions.AddToArray<DungeonPrerequisite>(prerequisites2, prereq);
			entry.prerequisites = prerequisites2;
		}
		return prereq;
	}
}