Decompiled source of Lords Complementary Compilation v1.0.3

LccMod.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using Alexandria.ItemAPI;
using BepInEx;
using Dungeonator;
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("Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mod")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d6d7a494-722e-4763-959b-c2d6b6a42b01")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace LccMod;

[HarmonyPatch]
public class Chunkan : PassiveItem
{
	private int totalJunk;

	private bool effectsApplied = false;

	public static void Register()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		string text = "Chunkan";
		string text2 = "LccMod/Resources/Chunkan";
		GameObject val = new GameObject(text);
		Chunkan chunkan = val.AddComponent<Chunkan>();
		ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
		string text3 = "MORE JUNK, MORE PROTEIN!";
		string text4 = "This absolute unit of a junkan sustains himself on a solitary diet of raw junk. A true Junkatarian!\n\nYou can see him flexing inside your pockets. And he's asking you for more protein, more power, MORE JUNK! His arms are so buff that they might even protect you from harm, if he has enough to bulk up.";
		ItemBuilder.SetupItem((PickupObject)(object)chunkan, text3, text4, "lcc");
		((PickupObject)chunkan).quality = (ItemQuality)4;
	}

	public override void Pickup(PlayerController player)
	{
		((PassiveItem)this).Pickup(player);
		PassiveItem.IncrementFlag(player, typeof(Chunkan));
		if (!effectsApplied)
		{
			effectsApplied = true;
			LootEngine.GivePrefabToPlayer(((Component)PickupObjectDatabase.GetById(127)).gameObject, player);
			HealthHaver healthHaver = ((BraveBehaviour)player).healthHaver;
			healthHaver.Armor += 2f;
		}
		CalculateJunk(player);
		ApplyStatBuffs();
	}

	public override DebrisObject Drop(PlayerController player)
	{
		PassiveItem.DecrementFlag(player, typeof(Chunkan));
		RemoveStatBuffs();
		return ((PassiveItem)this).Drop(player);
	}

	private void RemoveStatBuffs()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Invalid comparison between Unknown and I4
		if ((Object)(object)((PassiveItem)this).Owner == (Object)null)
		{
			return;
		}
		StatModifier[] array = ((PassiveItem)this).Owner.ownerlessStatModifiers.ToArray();
		foreach (StatModifier val in array)
		{
			if ((int)val.statToBoost == 5)
			{
				((PassiveItem)this).Owner.ownerlessStatModifiers.Remove(val);
			}
		}
		((PassiveItem)this).Owner.stats.RecalculateStats(((PassiveItem)this).Owner, true, true);
	}

	private void ApplyStatBuffs()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: 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_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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_003c: Expected O, but got Unknown
		if (!((Object)(object)((PassiveItem)this).Owner == (Object)null))
		{
			float amount = 0.05f * (float)totalJunk;
			StatModifier item = new StatModifier
			{
				amount = amount,
				statToBoost = (StatType)5,
				modifyType = (ModifyMethod)0
			};
			((PassiveItem)this).Owner.ownerlessStatModifiers.Add(item);
			((PassiveItem)this).Owner.stats.RecalculateStats(((PassiveItem)this).Owner, true, true);
		}
	}

	private void CalculateJunk(PlayerController player)
	{
		foreach (PassiveItem passiveItem in player.passiveItems)
		{
			if (((PickupObject)passiveItem).PickupObjectId == 127)
			{
				totalJunk++;
			}
		}
	}

	private int CalculateJunkCount()
	{
		int num = 0;
		foreach (PassiveItem passiveItem in ((PassiveItem)this).Owner.passiveItems)
		{
			if (((PickupObject)passiveItem).PickupObjectId == 127)
			{
				num++;
			}
		}
		return num;
	}

	public override void Update()
	{
		((PassiveItem)this).Update();
		if (!((Object)(object)((PassiveItem)this).Owner == (Object)null))
		{
			int num = CalculateJunkCount();
			if (num != totalJunk)
			{
				RemoveStatBuffs();
				totalJunk = num;
				ApplyStatBuffs();
			}
		}
	}

	[HarmonyPatch(typeof(GameManager), "LoadNextLevel")]
	[HarmonyPatch(typeof(GameManager), "LoadCustomFlowForDebug")]
	[HarmonyPatch(typeof(GameManager), "LoadCustomLevel")]
	[HarmonyPrefix]
	public static void ApplyArmorPrefix()
	{
		if (GameManager.Instance.AllPlayers == null)
		{
			return;
		}
		PlayerController[] allPlayers = GameManager.Instance.AllPlayers;
		foreach (PlayerController val in allPlayers)
		{
			if ((Object)(object)val != (Object)null && PassiveItem.IsFlagSetForCharacter(val, typeof(Chunkan)))
			{
				ApplyArmor(val);
			}
		}
	}

	private static void ApplyArmor(PlayerController player)
	{
		int num = 0;
		foreach (PassiveItem passiveItem in player.passiveItems)
		{
			if (((PickupObject)passiveItem).PickupObjectId == 127)
			{
				num++;
			}
		}
		if (num >= 2)
		{
			int num2 = num / 2;
			HealthHaver healthHaver = ((BraveBehaviour)player).healthHaver;
			healthHaver.Armor += (float)num2;
		}
	}
}
[HarmonyPatch]
public class EctosyDispenser : PassiveItem
{
	private const float CoolnessPerHalfHeart = 0.5f;

	public static void Register()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		string text = "Ectosy Dispenser";
		string text2 = "LccMod/Resources/ectosy_dispenser_sprite";
		GameObject val = new GameObject(text);
		EctosyDispenser ectosyDispenser = val.AddComponent<EctosyDispenser>();
		ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
		string text3 = "Cool Blooded";
		string text4 = "Have you ever wondered what happens to those hearts you left behind, in the previous floor? Did you ever think about what those heart-dispensers might've done with them? Do you really want to know?\n\nYou see, the moment you leave their sights, all your precious hearts are being traded and gambled away, in Shelling's unmarked cassino-dispenser. For great gains and profits!\n\nThanks to your new 'stylish' contact, you're now in the loop getting a cut of the action, in streetcred!";
		ItemBuilder.SetupItem((PickupObject)(object)ectosyDispenser, text3, text4, "lcc");
		((PickupObject)ectosyDispenser).quality = (ItemQuality)2;
	}

	public override void Pickup(PlayerController player)
	{
		((PassiveItem)this).Pickup(player);
		PassiveItem.IncrementFlag(player, typeof(EctosyDispenser));
	}

	public override DebrisObject Drop(PlayerController player)
	{
		PassiveItem.DecrementFlag(player, typeof(EctosyDispenser));
		return ((PassiveItem)this).Drop(player);
	}

	[HarmonyPatch(typeof(GameManager), "LoadNextLevel")]
	[HarmonyPatch(typeof(GameManager), "LoadCustomFlowForDebug")]
	[HarmonyPatch(typeof(GameManager), "LoadCustomLevel")]
	[HarmonyPrefix]
	public static void ApplyCoolnessPrefix()
	{
		if (GameManager.Instance.AllPlayers == null)
		{
			return;
		}
		PlayerController[] allPlayers = GameManager.Instance.AllPlayers;
		foreach (PlayerController val in allPlayers)
		{
			if ((Object)(object)val != (Object)null && PassiveItem.IsFlagSetForCharacter(val, typeof(EctosyDispenser)))
			{
				ApplyCoolness(val);
			}
		}
	}

	private static void ApplyCoolness(PlayerController player)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: 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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: 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_0036: Expected O, but got Unknown
		if (HeartDispenser.CurrentHalfHeartsStored > 0)
		{
			float amount = (float)HeartDispenser.CurrentHalfHeartsStored * 0.5f;
			StatModifier item = new StatModifier
			{
				statToBoost = (StatType)4,
				amount = amount,
				modifyType = (ModifyMethod)0
			};
			player.ownerlessStatModifiers.Add(item);
			player.stats.RecalculateStats(player, true, true);
		}
	}
}
public class ExamplePassive : PassiveItem
{
	public static void Register()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		string text = "Example Item Name";
		string text2 = "LccMod/Resources/example_item_sprite";
		GameObject val = new GameObject(text);
		ExamplePassive examplePassive = val.AddComponent<ExamplePassive>();
		ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
		string text3 = "Example Short Desc.";
		string text4 = "Example Long Description\n\nWow this description is really looooooooooong!";
		ItemBuilder.SetupItem((PickupObject)(object)examplePassive, text3, text4, "example");
		ItemBuilder.AddPassiveStatModifier((PickupObject)(object)examplePassive, (StatType)3, 1f, (ModifyMethod)0);
		ItemBuilder.AddPassiveStatModifier((PickupObject)(object)examplePassive, (StatType)4, 1f, (ModifyMethod)0);
		((PickupObject)examplePassive).quality = (ItemQuality)2;
	}

	public override void Pickup(PlayerController player)
	{
		((PassiveItem)this).Pickup(player);
		Module.Log("Player picked up " + ((PickupObject)this).DisplayName);
	}

	public override void DisableEffect(PlayerController player)
	{
		Module.Log("Player dropped or got rid of " + ((PickupObject)this).DisplayName);
	}
}
[HarmonyPatch]
public class GFC : PassiveItem
{
	public static void Register()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		string text = "GFC";
		string text2 = "LccMod/Resources/GFC";
		GameObject val = new GameObject(text);
		GFC gFC = val.AddComponent<GFC>();
		ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
		string text3 = "Barrel licking good!";
		string text4 = "After you've had a small taste of these tender freshly fried avian gungeon inhabitants, you've acquired a taste for MORE!\n\nEvery bite is so satisfying, so much so, in fact, that you feel the strength to go on for longer! Perhaps just to find more chickens...";
		ItemBuilder.SetupItem((PickupObject)(object)gFC, text3, text4, "lcc");
		ItemBuilder.AddPassiveStatModifier((PickupObject)(object)gFC, (StatType)3, 1f, (ModifyMethod)0);
		((PickupObject)gFC).quality = (ItemQuality)2;
	}

	public override void Pickup(PlayerController player)
	{
		((PassiveItem)this).Pickup(player);
		PassiveItem.IncrementFlag(player, typeof(GFC));
	}

	public override DebrisObject Drop(PlayerController player)
	{
		PassiveItem.DecrementFlag(player, typeof(GFC));
		return ((PassiveItem)this).Drop(player);
	}

	[HarmonyPatch(typeof(AIActor))]
	[HarmonyPatch("Die")]
	[HarmonyPrefix]
	public static void Prefix(AIActor __instance)
	{
		if (!((Object)(object)__instance != (Object)null) || !(__instance.EnemyGuid == "76bc43539fc24648bff4568c75c686d1") || GameManager.Instance.AllPlayers == null)
		{
			return;
		}
		PlayerController[] allPlayers = GameManager.Instance.AllPlayers;
		foreach (PlayerController val in allPlayers)
		{
			if ((Object)(object)val != (Object)null && PassiveItem.IsFlagSetForCharacter(val, typeof(GFC)))
			{
				HealOnChickenKill();
			}
		}
	}

	private static void HealOnChickenKill()
	{
		PlayerController primaryPlayer = GameManager.Instance.PrimaryPlayer;
		if ((Object)(object)primaryPlayer != (Object)null && (Object)(object)((BraveBehaviour)primaryPlayer).healthHaver != (Object)null && ((BraveBehaviour)primaryPlayer).healthHaver.GetCurrentHealth() < ((BraveBehaviour)primaryPlayer).healthHaver.GetMaxHealth())
		{
			float num = 0.5f;
			((BraveBehaviour)primaryPlayer).healthHaver.ApplyHealing(num);
		}
	}
}
[HarmonyPatch]
public class Headhunter : PassiveItem
{
	private static int bossesKilled;

	public static void Register()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		string text = "Headhunter";
		string text2 = "LccMod/Resources/HeadHunter";
		GameObject val = new GameObject(text);
		Headhunter headhunter = val.AddComponent<Headhunter>();
		ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
		string text3 = "Boom. Headshot.";
		string text4 = "A list of very powerful individuals. All figureheads for their individual domains. Having a bigger back just means having a bigger target. Every big hit completed makes you more powerful in the chase of an even bigger payout the next time.\n\nProfessionals have standards. Be polite. Be efficient. Have a plan to kill everyone you meet.";
		ItemBuilder.SetupItem((PickupObject)(object)headhunter, text3, text4, "lcc");
		((PickupObject)headhunter).quality = (ItemQuality)3;
	}

	public override void Pickup(PlayerController player)
	{
		((PassiveItem)this).Pickup(player);
		PassiveItem.IncrementFlag(player, typeof(Headhunter));
	}

	public override DebrisObject Drop(PlayerController player)
	{
		RemoveStatBuffs();
		PassiveItem.DecrementFlag(player, typeof(Headhunter));
		return ((PassiveItem)this).Drop(player);
	}

	private void RemoveStatBuffs()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Invalid comparison between Unknown and I4
		StatModifier[] array = ((PassiveItem)this).Owner.ownerlessStatModifiers.ToArray();
		foreach (StatModifier val in array)
		{
			if ((int)val.statToBoost == 5)
			{
				((PassiveItem)this).Owner.ownerlessStatModifiers.Remove(val);
			}
		}
		((PassiveItem)this).Owner.stats.RecalculateStats(((PassiveItem)this).Owner, true, true);
	}

	[HarmonyPatch(typeof(RoomHandler), "HandleBossClearReward")]
	[HarmonyPostfix]
	public static void BossKillPostfix()
	{
		if (GameManager.Instance.AllPlayers == null)
		{
			return;
		}
		PlayerController[] allPlayers = GameManager.Instance.AllPlayers;
		foreach (PlayerController val in allPlayers)
		{
			if ((Object)(object)val != (Object)null && PassiveItem.IsFlagSetForCharacter(val, typeof(Headhunter)))
			{
				bossesKilled++;
				ApplyBossKillBoost(val);
			}
		}
	}

	private static void ApplyBossKillBoost(PlayerController player)
	{
		//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_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_0019: 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_0021: Expected O, but got Unknown
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: 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_002e: 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_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		StatModifier item = new StatModifier
		{
			statToBoost = (StatType)30,
			amount = 0.1f,
			modifyType = (ModifyMethod)0
		};
		StatModifier item2 = new StatModifier
		{
			statToBoost = (StatType)22,
			amount = 0.1f,
			modifyType = (ModifyMethod)0
		};
		LootEngine.SpawnCurrency(((BraveBehaviour)player).specRigidbody.UnitCenter, bossesKilled, true);
		for (int i = 0; i < bossesKilled * 10; i++)
		{
			LootEngine.GivePrefabToPlayer(((Component)PickupObjectDatabase.GetById(68)).gameObject, player);
		}
		player.ownerlessStatModifiers.Add(item2);
		player.ownerlessStatModifiers.Add(item);
		player.stats.RecalculateStats(player, true, true);
	}
}
public class Junklets : PassiveItem
{
	public static void Register()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		string text = "Junklets";
		string text2 = "LccMod/Resources/Bunklets";
		GameObject val = new GameObject(text);
		Junklets junklets = val.AddComponent<Junklets>();
		ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
		string text3 = "Body Bags";
		string text4 = "The inhabitants of the Gungeon are rotten to the core. So might as well store their remains in convient lil junk bags.\n\nBut you'll be held personally responsible for the cleanup!";
		ItemBuilder.SetupItem((PickupObject)(object)junklets, text3, text4, "lcc");
		((PickupObject)junklets).quality = (ItemQuality)5;
	}

	public override void Pickup(PlayerController player)
	{
		((PassiveItem)this).Pickup(player);
		player.OnAnyEnemyReceivedDamage = (Action<float, bool, HealthHaver>)Delegate.Combine(player.OnAnyEnemyReceivedDamage, new Action<float, bool, HealthHaver>(OnAnyEnemyReceivedDamage));
	}

	public override void DisableEffect(PlayerController player)
	{
		player.OnAnyEnemyReceivedDamage = (Action<float, bool, HealthHaver>)Delegate.Remove(player.OnAnyEnemyReceivedDamage, new Action<float, bool, HealthHaver>(OnAnyEnemyReceivedDamage));
	}

	private void OnAnyEnemyReceivedDamage(float damage, bool fatal, HealthHaver healthHaver)
	{
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Expected O, but got Unknown
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Expected O, but got Unknown
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Expected O, but got Unknown
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Expected O, but got Unknown
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0357: Unknown result type (might be due to invalid IL or missing references)
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		//IL_0324: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: 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)
		if (!((Object)(object)healthHaver != (Object)null) || !((Object)(object)((BraveBehaviour)healthHaver).aiActor != (Object)null))
		{
			return;
		}
		int num = 0;
		foreach (PassiveItem passiveItem in ((PassiveItem)this).Owner.passiveItems)
		{
			if (((PickupObject)passiveItem).PickupObjectId == 580)
			{
				num++;
			}
		}
		if (fatal)
		{
			if (Random.value < 0.05f && !healthHaver.IsBoss)
			{
				SpawnManager.SpawnVFX((GameObject)ResourceCache.Acquire("Global VFX/VFX_Item_Spawn_Poof"), Vector2.op_Implicit(((GameActor)((BraveBehaviour)healthHaver).aiActor).CenterPosition), Quaternion.identity);
				GameObject val = new GameObject("sound");
				val.transform.position = Vector2.op_Implicit(((GameActor)((BraveBehaviour)healthHaver).aiActor).CenterPosition);
				AkSoundEngine.PostEvent("Play_ENM_wizardred_appear_01", val);
				Object.Destroy((Object)(object)val, 1f);
				((BraveBehaviour)healthHaver).aiActor.HandleRewards();
				((BraveBehaviour)healthHaver).aiActor.EraseFromExistence(false);
				if (Random.value < 0.001f)
				{
					LootEngine.SpawnItem(((Component)PickupObjectDatabase.GetById(641)).gameObject, Vector2.op_Implicit(((GameActor)((BraveBehaviour)healthHaver).aiActor).CenterPosition), Vector2.zero, 1f, false, true, false);
				}
				else if (Random.value < 0.01f && num == 0)
				{
					LootEngine.SpawnItem(((Component)PickupObjectDatabase.GetById(580)).gameObject, Vector2.op_Implicit(((GameActor)((BraveBehaviour)healthHaver).aiActor).CenterPosition), Vector2.zero, 1f, false, true, false);
				}
				else
				{
					LootEngine.SpawnItem(((Component)PickupObjectDatabase.GetById(127)).gameObject, Vector2.op_Implicit(((GameActor)((BraveBehaviour)healthHaver).aiActor).CenterPosition), Vector2.zero, 1f, false, true, false);
				}
			}
		}
		else if (Random.value < 0.005f && !((BraveBehaviour)healthHaver).aiActor.InBossAmmonomiconTab)
		{
			SpawnManager.SpawnVFX((GameObject)ResourceCache.Acquire("Global VFX/VFX_Item_Spawn_Poof"), Vector2.op_Implicit(((GameActor)((BraveBehaviour)healthHaver).aiActor).CenterPosition), Quaternion.identity);
			GameObject val2 = new GameObject("sound");
			val2.transform.position = Vector2.op_Implicit(((GameActor)((BraveBehaviour)healthHaver).aiActor).CenterPosition);
			AkSoundEngine.PostEvent("Play_ENM_wizardred_appear_01", val2);
			Object.Destroy((Object)(object)val2, 1f);
			((BraveBehaviour)healthHaver).aiActor.HandleRewards();
			((BraveBehaviour)healthHaver).aiActor.EraseFromExistence(false);
			if (Random.value < 0.001f)
			{
				LootEngine.SpawnItem(((Component)PickupObjectDatabase.GetById(641)).gameObject, Vector2.op_Implicit(((GameActor)((BraveBehaviour)healthHaver).aiActor).CenterPosition), Vector2.zero, 1f, false, true, false);
			}
			else if (Random.value < 0.01f && num == 0)
			{
				LootEngine.SpawnItem(((Component)PickupObjectDatabase.GetById(580)).gameObject, Vector2.op_Implicit(((GameActor)((BraveBehaviour)healthHaver).aiActor).CenterPosition), Vector2.zero, 1f, false, true, false);
			}
			else
			{
				LootEngine.SpawnItem(((Component)PickupObjectDatabase.GetById(127)).gameObject, Vector2.op_Implicit(((GameActor)((BraveBehaviour)healthHaver).aiActor).CenterPosition), Vector2.zero, 1f, false, true, false);
			}
		}
	}
}
public class LockHeadMortin : PassiveItem
{
	private int currentKeys;

	public static void Register()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		string text = "Lock-Head Mortin";
		string text2 = "LccMod/Resources/lock_head_mortin_sprite";
		GameObject val = new GameObject(text);
		LockHeadMortin lockHeadMortin = val.AddComponent<LockHeadMortin>();
		ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
		string text3 = "Tactical to a key!";
		string text4 = "Those keys of yours, aren't they just cough, 'free real-estate', cough...  Even when going unused they will now reveal their full potential. Order now for your PMG TODAY!!!!";
		ItemBuilder.SetupItem((PickupObject)(object)lockHeadMortin, text3, text4, "lcc");
		((PickupObject)lockHeadMortin).quality = (ItemQuality)2;
	}

	public override void Pickup(PlayerController player)
	{
		((PassiveItem)this).Pickup(player);
		currentKeys = player.carriedConsumables.KeyBullets;
		RemoveStatBuffs();
		AddStatBuffs();
	}

	public override DebrisObject Drop(PlayerController player)
	{
		RemoveStatBuffs();
		currentKeys = 0;
		return ((PassiveItem)this).Drop(player);
	}

	private void AddStatBuffs()
	{
		//IL_0053: 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_0060: 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_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Expected O, but got Unknown
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Expected O, but got Unknown
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: 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_00de: 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_00e7: Expected O, but got Unknown
		if (!((Object)(object)((PassiveItem)this).Owner == (Object)null) && currentKeys > 0)
		{
			float num = 0.25f * (float)currentKeys;
			float amount = 0.25f * (float)currentKeys;
			float amount2 = 0.25f * (float)currentKeys;
			StatModifier val = new StatModifier
			{
				amount = 0f - num,
				statToBoost = (StatType)2,
				modifyType = (ModifyMethod)0
			};
			if (((PassiveItem)this).Owner.stats.GetStatValue((StatType)2) + val.amount < 0f)
			{
				val.amount = 0f - ((PassiveItem)this).Owner.stats.GetStatValue((StatType)2);
			}
			StatModifier item = new StatModifier
			{
				amount = amount,
				statToBoost = (StatType)6,
				modifyType = (ModifyMethod)0
			};
			StatModifier item2 = new StatModifier
			{
				amount = amount2,
				statToBoost = (StatType)26,
				modifyType = (ModifyMethod)0
			};
			((PassiveItem)this).Owner.ownerlessStatModifiers.Add(val);
			((PassiveItem)this).Owner.ownerlessStatModifiers.Add(item);
			((PassiveItem)this).Owner.ownerlessStatModifiers.Add(item2);
			((PassiveItem)this).Owner.stats.RecalculateStats(((PassiveItem)this).Owner, true, true);
		}
	}

	private void RemoveStatBuffs()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Invalid comparison between Unknown and I4
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Invalid comparison between Unknown and I4
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Invalid comparison between Unknown and I4
		if ((Object)(object)((PassiveItem)this).Owner == (Object)null)
		{
			return;
		}
		StatModifier[] array = ((PassiveItem)this).Owner.ownerlessStatModifiers.ToArray();
		foreach (StatModifier val in array)
		{
			if ((int)val.statToBoost == 2 || (int)val.statToBoost == 6 || (int)val.statToBoost == 26)
			{
				((PassiveItem)this).Owner.ownerlessStatModifiers.Remove(val);
			}
		}
		((PassiveItem)this).Owner.stats.RecalculateStats(((PassiveItem)this).Owner, true, true);
	}

	public override void Update()
	{
		((PassiveItem)this).Update();
		if (!((Object)(object)((PassiveItem)this).Owner == (Object)null))
		{
			int keyBullets = ((PassiveItem)this).Owner.carriedConsumables.KeyBullets;
			if (keyBullets != currentKeys)
			{
				RemoveStatBuffs();
				currentKeys = keyBullets;
				AddStatBuffs();
			}
		}
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("creator.etg.lordfortress", "Lord's Complementary Compilation", "1.0.3")]
public class Module : BaseUnityPlugin
{
	public const string GUID = "creator.etg.lordfortress";

	public const string NAME = "Lord's Complementary Compilation";

	public const string VERSION = "1.0.3";

	public const string TEXT_COLOR = "#9E0700";

	private Harmony _harmony;

	public void GMStart(GameManager g)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		_harmony = new Harmony("creator.etg.lordfortress");
		EctosyDispenser.Register();
		LockHeadMortin.Register();
		GFC.Register();
		Trashsure.Register();
		Chunkan.Register();
		Headhunter.Register();
		Junklets.Register();
		List<string> list = new List<string> { "lcc:lock-head_mortin", "briefcase_of_cash" };
		CustomSynergies.Add("Military Spending", list, (List<string>)null, true);
		List<string> list2 = new List<string> { "lcc:lock-head_mortin", "ballot" };
		CustomSynergies.Add("Lobbying", list2, (List<string>)null, true);
		_harmony.PatchAll();
		Log("Lord's Complementary Compilation v1.0.3 started successfully.", "#9E0700");
	}

	public void Start()
	{
		ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
	}

	public static void Log(string text, string color = "#FFFFFF")
	{
		ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false);
	}
}
[HarmonyPatch]
public class Trashsure : PassiveItem
{
	[HarmonyPatch(typeof(BasicStatPickup))]
	[HarmonyPatch("Pickup")]
	public class BasicStatPickup_Pickup_Patch
	{
		public static bool Triggering;

		[HarmonyPrefix]
		public static void Prefix(BasicStatPickup __instance, PlayerController player)
		{
			if (!Triggering && ((PickupObject)__instance).PickupObjectId == 127 && PassiveItem.IsFlagSetForCharacter(player, typeof(Trashsure)) && !((PassiveItem)__instance).m_pickedUpThisRun)
			{
				Triggering = true;
				GiveExtraJunk(player);
				Triggering = false;
			}
		}
	}

	public static void Register()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		string text = "Trashsure";
		string text2 = "LccMod/Resources/Trashsure";
		GameObject val = new GameObject(text);
		Trashsure trashsure = val.AddComponent<Trashsure>();
		ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
		string text3 = "Another Man's Trash";
		string text4 = "What's better than one piece of junk? TWO pieces of junk of course!\n\nWith this great invention, when you pickup a piece of junk it will just quantum entangle junk from somewhere else, sometimes, to your other hand. This is how we solve the world's junk problem. Just put it 'elsewhere'! And that 'elsewhere' just happens to be YOUR pockets.";
		ItemBuilder.SetupItem((PickupObject)(object)trashsure, text3, text4, "lcc");
		((PickupObject)trashsure).quality = (ItemQuality)2;
	}

	public override void Pickup(PlayerController player)
	{
		((PassiveItem)this).Pickup(player);
		PassiveItem.IncrementFlag(player, typeof(Trashsure));
	}

	public override DebrisObject Drop(PlayerController player)
	{
		PassiveItem.DecrementFlag(player, typeof(Trashsure));
		return ((PassiveItem)this).Drop(player);
	}

	public static void GiveExtraJunk(PlayerController player)
	{
		if (!(Random.value < 0.5f))
		{
			return;
		}
		int num = 0;
		foreach (PassiveItem passiveItem in player.passiveItems)
		{
			if (((PickupObject)passiveItem).PickupObjectId == 580)
			{
				num++;
			}
		}
		if (Random.value < 0.05f && num == 0)
		{
			LootEngine.GivePrefabToPlayer(((Component)PickupObjectDatabase.GetById(580)).gameObject, player);
		}
		else if (Random.value < 0.01f)
		{
			LootEngine.GivePrefabToPlayer(((Component)PickupObjectDatabase.GetById(641)).gameObject, player);
		}
		else
		{
			LootEngine.GivePrefabToPlayer(((Component)PickupObjectDatabase.GetById(127)).gameObject, player);
		}
	}
}