Decompiled source of PhreelsTinyContentPack v0.2.12

PhreelsContentPack.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using LookingGlass.ItemStatsNameSpace;
using On.RoR2;
using PhreelsContentPack.HelperClasses;
using PhreelsContentPack.Items.T1;
using PhreelsContentPack.Items.T2;
using PhreelsContentPack.Items.T3;
using R2API;
using R2API.Utils;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;
using VAPI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PhreelsContentPack")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PhreelsContentPack")]
[assembly: AssemblyTitle("PhreelsContentPack")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace PhreelsContentPack
{
	internal static class LookingGlassCompat
	{
		private struct Line
		{
			public string description;

			public ValueType valueType;

			public MeasurementUnits units;

			public Line(string description, ValueType valueType, MeasurementUnits units)
			{
				//IL_0008: 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_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)
				this.description = description;
				this.valueType = valueType;
				this.units = units;
			}
		}

		public const string GUID = "droppod.lookingglass";

		private static bool vapiLoaded;

		public static bool IsLookingGlassInstalled => Chainloader.PluginInfos.ContainsKey("droppod.lookingglass");

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void Init(bool VAPILoaded)
		{
			vapiLoaded = VAPILoaded;
			((ResourceAvailability)(ref ItemCatalog.availability)).CallWhenAvailable((Action)RegisterItemStats);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static ItemStatsDef Create(Line[] lines)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_002c: 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)
			ItemStatsDef val = new ItemStatsDef();
			for (int i = 0; i < lines.Length; i++)
			{
				Line line = lines[i];
				val.descriptions.Add(line.description);
				val.valueTypes.Add(line.valueType);
				val.measurementUnits.Add(line.units);
			}
			return val;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void AddItem(ItemDef item, Func<int, List<float>> values, params Line[] lines)
		{
			ItemStatsDef val = Create(lines);
			val.calculateValuesFlat = values;
			Register(item, val);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void AddChanceItem(ItemDef item, Func<float, int, float, List<float>> values, params Line[] lines)
		{
			ItemStatsDef val = Create(lines);
			val.hasChance = true;
			val.calculateValuesNew = (float luck, int stackCount, float procChance) => values(luck, stackCount, procChance);
			Register(item, val);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void AddMasterItem(ItemDef item, Func<CharacterMaster, int, List<float>> values, params Line[] lines)
		{
			ItemStatsDef val = Create(lines);
			val.calculateValues = values;
			Register(item, val);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void Register(ItemDef item, ItemStatsDef def)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected I4, but got Unknown
			if (Object.op_Implicit((Object)(object)item) && (int)item.itemIndex != -1)
			{
				ItemDefinitions.allItemDefinitions[(int)item.itemIndex] = def;
			}
		}

		private static float Stack(float initial, float additional, int count)
		{
			return initial + additional * (float)(count - 1);
		}

		private static float ChanceWithLuck(float chance, float luck)
		{
			chance = Math.Min(chance, 1f);
			int num = (int)Math.Ceiling(luck);
			if (num > 0)
			{
				return 1f - (float)Math.Pow(1f - chance, num + 1);
			}
			if (num < 0)
			{
				return (float)Math.Pow(chance, -num + 1);
			}
			return chance;
		}

		private static int CountAllies(CharacterBody body)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (TeamComponent teamMember in TeamComponent.GetTeamMembers(body.teamComponent.teamIndex))
			{
				if (Object.op_Implicit((Object)(object)teamMember) && Object.op_Implicit((Object)(object)teamMember.body) && (Object)(object)teamMember.body != (Object)(object)body && Object.op_Implicit((Object)(object)teamMember.body.healthComponent) && teamMember.body.healthComponent.alive)
				{
					num++;
				}
			}
			return num;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void RegisterItemStats()
		{
			try
			{
				if (Main.DetachedStinger_Enable.Value)
				{
					RegisterDetachedStinger();
				}
				if (Main.PirateCoin_Enable.Value)
				{
					RegisterPirateCoin();
				}
				if (Main.EasternLantern_Enable.Value)
				{
					RegisterEasternLantern();
				}
				if (Main.IntergamemodeChessboard_Enable.Value)
				{
					RegisterChessboard();
				}
				if (Main.PalmTree_Enable.Value)
				{
					RegisterPalmTree();
				}
			}
			catch (Exception ex)
			{
				Main.Log.LogError((object)("Failed to register LookingGlass item stats: " + ex));
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void RegisterDetachedStinger()
		{
			if (vapiLoaded)
			{
				AddChanceItem(DetachedStinger.itemDefinition, (float luck, int count, float proc) => new List<float>
				{
					ChanceWithLuck((float)count * Main.DetachedStinger_ChancetoInflict.Value * 0.01f * proc, luck),
					(float)count * Main.DetachedStinger_DealExtraDamageToVariants.Value * 0.01f
				}, new Line("Poison Chance: ", (ValueType)1, (MeasurementUnits)1), new Line("Damage vs Variants: ", (ValueType)1, (MeasurementUnits)1));
			}
			else
			{
				AddChanceItem(DetachedStinger.itemDefinition, (float luck, int count, float proc) => new List<float> { ChanceWithLuck((float)count * Main.DetachedStinger_ChancetoInflict.Value * 0.01f * proc, luck) }, new Line("Poison Chance: ", (ValueType)1, (MeasurementUnits)1));
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void RegisterPirateCoin()
		{
			AddMasterItem(PirateCoin.itemDefinition, delegate(CharacterMaster master, int count)
			{
				float num = Main.PirateCoin_PercentageHPWhiteItem.Value * (float)Math.Pow(Main.PirateCoin_PercentageHPWhiteItemMultiplierAtStacks.Value, count - 1);
				float num2 = 0f;
				if (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)master.inventory))
				{
					num2 = master.inventory.GetTotalItemCountOfTier((ItemTier)0) + master.inventory.GetTotalItemCountOfTier((ItemTier)6);
				}
				return new List<float>
				{
					num,
					num2 * num
				};
			}, new Line("Health per Common Item: ", (ValueType)3, (MeasurementUnits)1), new Line("Current Health Bonus: ", (ValueType)3, (MeasurementUnits)1));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void RegisterEasternLantern()
		{
			AddMasterItem(EasternLantern.itemDefinition, delegate(CharacterMaster master, int count)
			{
				float num = Stack(Main.EasternLantern_InitialRegenPerAlly.Value, Main.EasternLantern_AdditionalRegenPerAlly.Value, count);
				CharacterBody val = (Object.op_Implicit((Object)(object)master) ? master.GetBody() : null);
				int num2 = ((Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.teamComponent)) ? CountAllies(val) : 0);
				return new List<float>
				{
					num,
					num2,
					(float)num2 * num
				};
			}, new Line("Regen per Ally: ", (ValueType)0, (MeasurementUnits)3), new Line("Allies: ", (ValueType)2, (MeasurementUnits)4), new Line("Current Regen Bonus: ", (ValueType)0, (MeasurementUnits)3));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void RegisterChessboard()
		{
			AddChanceItem(Chessboard.itemDefinition, (float luck, int count, float proc) => new List<float>
			{
				ChanceWithLuck(Stack(Main.IntergamemodeChessboard_InitialChancetoInflict.Value, Main.IntergamemodeChessboard_AdditionalChancetoInflict.Value, count) * 0.01f * proc, luck),
				1 + 2 * (count - 1),
				(float)Math.Round(Main.IntergamemodeChessboard_DebuffStacks.Value * (float)count),
				Math.Min(Math.Max(Main.IntergamemodeChessboard_MovementSpeedReduction.Value, 0f), 1f)
			}, new Line("Devastate Chance: ", (ValueType)1, (MeasurementUnits)1), new Line("Curse Stacks: ", (ValueType)1, (MeasurementUnits)4), new Line("Extra Debuff Stacks: ", (ValueType)1, (MeasurementUnits)4), new Line("Movement Speed Reduction: ", (ValueType)2, (MeasurementUnits)1));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void RegisterPalmTree()
		{
			AddMasterItem(PalmTree.itemDefinition, delegate(CharacterMaster master, int count)
			{
				float num = (float)count * Main.PalmTree_AdditionalBaseDamage.Value * 0.01f;
				CharacterBody val = (Object.op_Implicit((Object)(object)master) ? master.GetBody() : null);
				int num2 = ((Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)PalmTree.KillCounterBuff)) ? val.GetBuffCount(PalmTree.KillCounterBuff) : 0);
				return new List<float>
				{
					num,
					num2,
					(float)num2 * num
				};
			}, new Line("Damage per Kill: ", (ValueType)1, (MeasurementUnits)1), new Line("Kills: ", (ValueType)2, (MeasurementUnits)4), new Line("Current Damage Bonus: ", (ValueType)1, (MeasurementUnits)1));
		}
	}
	[BepInPlugin("com.phreel.phreelitemmod", "PhreelsItemPack", "0.2.11")]
	[BepInDependency("com.bepis.r2api", "5.3.0")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		public const string ModGuid = "com.phreel.phreelitemmod";

		public const string ModName = "PhreelsItemPack";

		public const string ModVer = "0.2.11";

		public bool VAPILoaded;

		public static AssetBundle MainAssets;

		internal static ManualLogSource Log;

		public static ConfigEntry<bool> LookingGlass_Enable { get; set; }

		public static ConfigEntry<bool> PirateCoin_Enable { get; set; }

		public static ConfigEntry<float> PirateCoin_PercentageHPWhiteItem { get; set; }

		public static ConfigEntry<float> PirateCoin_PercentageHPWhiteItemMultiplierAtStacks { get; set; }

		public static ConfigEntry<bool> PalmTree_Enable { get; set; }

		public static ConfigEntry<float> PalmTree_AdditionalBaseDamage { get; set; }

		public static ConfigEntry<bool> IntergamemodeChessboard_Enable { get; set; }

		public static ConfigEntry<float> IntergamemodeChessboard_InitialChancetoInflict { get; set; }

		public static ConfigEntry<float> IntergamemodeChessboard_AdditionalChancetoInflict { get; set; }

		public static ConfigEntry<float> IntergamemodeChessboard_DebuffStacks { get; set; }

		public static ConfigEntry<float> IntergamemodeChessboard_MovementSpeedReduction { get; set; }

		public static ConfigEntry<bool> DetachedStinger_Enable { get; set; }

		public static ConfigEntry<float> DetachedStinger_ChancetoInflict { get; set; }

		public static ConfigEntry<float> DetachedStinger_DealExtraDamageToVariants { get; set; }

		public static ConfigEntry<bool> EasternLantern_Enable { get; set; }

		public static ConfigEntry<float> EasternLantern_InitialRegenPerAlly { get; set; }

		public static ConfigEntry<float> EasternLantern_AdditionalRegenPerAlly { get; set; }

		public void ConfigInit()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_002b: Expected O, but got Unknown
			//IL_0040: 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_005f: Expected O, but got Unknown
			//IL_005f: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_0093: Expected O, but got Unknown
			//IL_00a8: 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_00c3: Expected O, but got Unknown
			//IL_00c3: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_00f7: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_0127: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_015b: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Expected O, but got Unknown
			//IL_018f: Expected O, but got Unknown
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			//IL_01c3: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Expected O, but got Unknown
			//IL_01f7: Expected O, but got Unknown
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Expected O, but got Unknown
			//IL_0227: Expected O, but got Unknown
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Expected O, but got Unknown
			//IL_025b: Expected O, but got Unknown
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			//IL_028f: Expected O, but got Unknown
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Expected O, but got Unknown
			//IL_02bf: Expected O, but got Unknown
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Expected O, but got Unknown
			//IL_02f3: Expected O, but got Unknown
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Expected O, but got Unknown
			//IL_0327: Expected O, but got Unknown
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Expected O, but got Unknown
			//IL_0357: Expected O, but got Unknown
			PirateCoin_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Tier2 - Pirate Coin", "Enable item"), true, new ConfigDescription("Allow the user to find this item in runs.", (AcceptableValueBase)null, Array.Empty<object>()));
			PirateCoin_PercentageHPWhiteItem = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Tier2 - Pirate Coin", "Additional base HP for each Common item"), 0.015f, new ConfigDescription("Percentage increase per Common item of base max health", (AcceptableValueBase)null, Array.Empty<object>()));
			PirateCoin_PercentageHPWhiteItemMultiplierAtStacks = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Tier2 - Pirate Coin", "Stack multiplier"), 1.2f, new ConfigDescription("Each additional stack multiplies the HP increase by this amount", (AcceptableValueBase)null, Array.Empty<object>()));
			PalmTree_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Tier3 - Palm Tree", "Enable item"), true, new ConfigDescription("Allow the user to find this item in runs.", (AcceptableValueBase)null, Array.Empty<object>()));
			PalmTree_AdditionalBaseDamage = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Tier3 - Palm Tree", "Additional damage"), 1f, new ConfigDescription("Additional base damage % per enemy kill", (AcceptableValueBase)null, Array.Empty<object>()));
			IntergamemodeChessboard_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Tier3 - Devastator Chessboard", "Enable item"), true, new ConfigDescription("Allow the user to find this item in runs.", (AcceptableValueBase)null, Array.Empty<object>()));
			IntergamemodeChessboard_InitialChancetoInflict = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Tier3 - Devastator Chessboard", "Initial inflict chance"), 20f, new ConfigDescription("Chance to devastate on hit", (AcceptableValueBase)null, Array.Empty<object>()));
			IntergamemodeChessboard_AdditionalChancetoInflict = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Tier3 - Devastator Chessboard", "Additional inflict chance"), 20f, new ConfigDescription("Chance to devastate on hit", (AcceptableValueBase)null, Array.Empty<object>()));
			IntergamemodeChessboard_DebuffStacks = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Tier3 - Devastator Chessboard", "Existing debuff stacks"), 10f, new ConfigDescription("Additional debuff stacks per item stack", (AcceptableValueBase)null, Array.Empty<object>()));
			IntergamemodeChessboard_MovementSpeedReduction = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Tier3 - Devastator Chessboard", "Movement speed reduction"), 0.8f, new ConfigDescription("Movement speed reduction in decimal", (AcceptableValueBase)null, Array.Empty<object>()));
			DetachedStinger_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Tier1 - Detached Stinger", "Enable item"), true, new ConfigDescription("Allow the user to find this item in runs.", (AcceptableValueBase)null, Array.Empty<object>()));
			DetachedStinger_ChancetoInflict = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Tier1 - Detached Stinger", "Chance to inflict poison"), 9f, new ConfigDescription("Chance to inflict Poison", (AcceptableValueBase)null, Array.Empty<object>()));
			DetachedStinger_DealExtraDamageToVariants = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Tier1 - Detached Stinger", "Extra Damage against variants"), 10f, new ConfigDescription("Deal extra damage to variants", (AcceptableValueBase)null, Array.Empty<object>()));
			EasternLantern_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Tier2 - Eastern Lantern", "Enable item"), true, new ConfigDescription("Allow the user to find this item in runs.", (AcceptableValueBase)null, Array.Empty<object>()));
			EasternLantern_InitialRegenPerAlly = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Tier2 - Eastern Lantern", "Initial regen per ally"), 2f, new ConfigDescription("Initial regen per ally in your team", (AcceptableValueBase)null, Array.Empty<object>()));
			EasternLantern_AdditionalRegenPerAlly = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Tier2 - Eastern Lantern", "Additional regen per ally"), 1.5f, new ConfigDescription("Additional regen per ally in your team", (AcceptableValueBase)null, Array.Empty<object>()));
			LookingGlass_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Mod Compatability: LookingGlass", "Enable Compatability Patches?"), true, new ConfigDescription("Add item stats to LookingGlass (if installed)?", (AcceptableValueBase)null, Array.Empty<object>()));
		}

		public void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			VAPILoaded = Chainloader.PluginInfos.ContainsKey("com.Nebby.VAPI");
			ConfigInit();
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("PhreelsContentPack.phreelcontentpack"))
			{
				MainAssets = AssetBundle.LoadFromStream(stream);
			}
			if (DetachedStinger_Enable.Value)
			{
				if (VAPILoaded)
				{
					DetachedStinger.InitiateWithVAPIEnabled();
				}
				else
				{
					DetachedStinger.Initiate();
				}
			}
			if (PirateCoin_Enable.Value)
			{
				PirateCoin.Initiate();
			}
			if (EasternLantern_Enable.Value)
			{
				EasternLantern.Initiate();
			}
			if (IntergamemodeChessboard_Enable.Value)
			{
				Chessboard.Initiate();
			}
			if (PalmTree_Enable.Value)
			{
				PalmTree.Initiate();
			}
			if (LookingGlassCompat.IsLookingGlassInstalled && LookingGlass_Enable.Value)
			{
				LookingGlassCompat.Init(VAPILoaded);
			}
		}
	}
}
namespace PhreelsContentPack.Utils
{
	internal class Scalings
	{
		public static float HyperbolicChance(float baseChance, float scaling, int stacks)
		{
			if (stacks > 0)
			{
				return baseChance * (1f - 1f / (1f + scaling * (float)stacks));
			}
			return 0f;
		}

		public static float LinearChance(float baseChance, float scaling, int stacks)
		{
			if (stacks > 0)
			{
				return baseChance + scaling * (float)(stacks - 1);
			}
			return 0f;
		}
	}
}
namespace PhreelsContentPack.Items.T3
{
	internal class Chessboard
	{
		private static string itemName = "Chessboard";

		private static string upperName = itemName.ToUpper();

		public static ItemDef itemDefinition = CreateItem();

		public static BuffDef DevastateMovement { get; private set; }

		public static GameObject LoadPrefab()
		{
			return Main.MainAssets.LoadAsset<GameObject>("Assets/ClayfootStudios/Prefabs/Chess_Board.prefab");
		}

		public static Sprite LoadSprite()
		{
			return Main.MainAssets.LoadAsset<Sprite>("Assets/Palm tree/Chessboard.png");
		}

		private static void CreateBuff()
		{
			//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)
			DevastateMovement = ScriptableObject.CreateInstance<BuffDef>();
			((Object)DevastateMovement).name = "DevastateMovement";
			DevastateMovement.buffColor = new Color(0.25f, 0f, 0.25f);
			DevastateMovement.canStack = false;
			DevastateMovement.isDebuff = true;
			DevastateMovement.iconSprite = LegacyResourcesAPI.Load<BuffDef>("BuffDefs/VoidFogStrong").iconSprite;
			ContentAddition.AddBuffDef(DevastateMovement);
		}

		public static ItemDef CreateItem()
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			ItemDef val = ScriptableObject.CreateInstance<ItemDef>();
			((Object)val).name = itemName;
			val.nameToken = "PCP_" + upperName + "_NAME";
			val.pickupToken = "PCP_" + upperName + "_PICKUP";
			val.descriptionToken = "PCP_" + upperName + "_DESC";
			val.loreToken = "PCP_" + upperName + "_LORE";
			ItemTag[] array = new ItemTag[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			val.tags = (ItemTag[])(object)array;
			val.deprecatedTier = (ItemTier)2;
			val.canRemove = true;
			val.hidden = false;
			val.pickupModelPrefab = LoadPrefab();
			val.pickupIconSprite = LoadSprite();
			return val;
		}

		public static ItemDisplayRuleDict CreateDisplayRules()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			helpers.PrepareItemDisplayModel(PrefabAPI.InstantiateClone(LoadPrefab(), ((Object)LoadPrefab()).name + "Display", false));
			return new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
		}

		public static void AddTokens()
		{
			LanguageAPI.Add("PCP_" + upperName + "_NAME", "Devastator Chessboard");
			LanguageAPI.Add("PCP_" + upperName + "_PICKUP", "Chance to devastate on hit");
			LanguageAPI.Add("PCP_" + upperName + "_DESC", $"On hit, you have a <style=cIsDamage>{Main.IntergamemodeChessboard_InitialChancetoInflict.Value}% chance</style> <style=cStack>(+{Main.IntergamemodeChessboard_AdditionalChancetoInflict.Value}% per stack)</style> to inflict <style=cIsUtility>the Eclipse 8 Permanent Health debuff</style> <style=cStack>(+2 stacks of Curse per item stack)</style> while also <style=cIsDamage>adding +{Main.IntergamemodeChessboard_DebuffStacks.Value} stacks of stackable debuffs already on the enemy</style> <style=cStack>(+{Main.IntergamemodeChessboard_DebuffStacks.Value} per stack)</style> and <style=cIsDamage>decreasing their movement speed by {Main.IntergamemodeChessboard_MovementSpeedReduction.Value * 100f}% permanently.</style>");
			LanguageAPI.Add("PCP_" + upperName + "_LORE", "How the exact fuck is this even a thing, too broken imo");
		}

		private static void AddHooks(ItemDef itemDefToHooks)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			GlobalEventManager.OnHitEnemy += (hook_OnHitEnemy)delegate(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
			{
				orig.Invoke(self, damageInfo, victim);
				CharacterBody val = default(CharacterBody);
				CharacterBody val2 = default(CharacterBody);
				if (NetworkServer.active && Object.op_Implicit((Object)(object)damageInfo.attacker) && Object.op_Implicit((Object)(object)victim) && damageInfo.attacker.TryGetComponent<CharacterBody>(ref val) && Object.op_Implicit((Object)(object)val.inventory) && Object.op_Implicit((Object)(object)val.master) && victim.TryGetComponent<CharacterBody>(ref val2))
				{
					int itemCountEffective = val.inventory.GetItemCountEffective(itemDefToHooks);
					if (itemCountEffective > 0 && Util.CheckRoll((Main.IntergamemodeChessboard_InitialChancetoInflict.Value + (float)(itemCountEffective - 1) * Main.IntergamemodeChessboard_AdditionalChancetoInflict.Value) * damageInfo.procCoefficient, val.master))
					{
						int num = Mathf.RoundToInt(Main.IntergamemodeChessboard_DebuffStacks.Value * (float)itemCountEffective);
						BuffDef[] buffDefs = BuffCatalog.buffDefs;
						foreach (BuffDef val3 in buffDefs)
						{
							if (Object.op_Implicit((Object)(object)val3) && val3.isDebuff && val3.canStack && (Object)(object)val3 != (Object)(object)Buffs.PermanentCurse && val2.HasBuff(val3))
							{
								for (int j = 0; j < num; j++)
								{
									val2.AddBuff(val3);
								}
							}
						}
						int num2 = 1 + 2 * (itemCountEffective - 1);
						for (int k = 0; k < num2; k++)
						{
							val2.AddBuff(Buffs.PermanentCurse);
						}
						if (!val2.HasBuff(DevastateMovement))
						{
							val2.AddBuff(DevastateMovement);
						}
					}
				}
			};
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(DevastateMovementBuffBehavior);
		}

		private static void DevastateMovementBuffBehavior(CharacterBody sender, StatHookEventArgs args)
		{
			if (sender.HasBuff(DevastateMovement))
			{
				args.moveSpeedTotalMult *= 1f - Mathf.Clamp01(Main.IntergamemodeChessboard_MovementSpeedReduction.Value);
			}
		}

		public static void Initiate()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			ItemAPI.Add(new CustomItem(itemDefinition, CreateDisplayRules()));
			AddTokens();
			CreateBuff();
			AddHooks(itemDefinition);
		}
	}
	internal class PalmTree
	{
		private class PalmTreeKillTracker : MonoBehaviour
		{
			public int kills;
		}

		private static string itemName = "PalmTree";

		private static string upperName = itemName.ToUpper();

		public static ItemDef itemDefinition = CreateItem();

		public static BuffDef KillCounterBuff { get; private set; }

		public static GameObject LoadPrefab()
		{
			return Main.MainAssets.LoadAsset<GameObject>("Assets/Palm tree/2.prefabs/palm_tree.prefab");
		}

		public static Sprite LoadSprite()
		{
			return Main.MainAssets.LoadAsset<Sprite>("Assets/Palm tree/Palm Tree.png");
		}

		public static ItemDef CreateItem()
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			ItemDef val = ScriptableObject.CreateInstance<ItemDef>();
			((Object)val).name = itemName;
			val.nameToken = "PCP_" + upperName + "_NAME";
			val.pickupToken = "PCP_" + upperName + "_PICKUP";
			val.descriptionToken = "PCP_" + upperName + "_DESC";
			val.loreToken = "PCP_" + upperName + "_LORE";
			val.tags = (ItemTag[])(object)new ItemTag[2]
			{
				(ItemTag)1,
				(ItemTag)31
			};
			val.deprecatedTier = (ItemTier)2;
			val.canRemove = true;
			val.hidden = false;
			val.pickupModelPrefab = LoadPrefab();
			val.pickupIconSprite = LoadSprite();
			return val;
		}

		public static ItemDisplayRuleDict CreateDisplayRules()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			helpers.PrepareItemDisplayModel(PrefabAPI.InstantiateClone(LoadPrefab(), ((Object)LoadPrefab()).name + "Display", false));
			return new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
		}

		public static void AddTokens()
		{
			LanguageAPI.Add("PCP_" + upperName + "_NAME", "Palm Tree");
			LanguageAPI.Add("PCP_" + upperName + "_PICKUP", "Additional base damage for each kill");
			LanguageAPI.Add("PCP_" + upperName + "_DESC", $"For each <style=cIsDamage>kill</style> your base damage is increased by <style=cIsDamage>{Main.PalmTree_AdditionalBaseDamage.Value}</style>% <style=cStack>(+{Main.PalmTree_AdditionalBaseDamage.Value}% per stack)</style> base damage. Further stacks count in already killed enemies.");
			LanguageAPI.Add("PCP_" + upperName + "_LORE", "Crash Bandicoot palm tree, what the fuck");
		}

		private static void CreateBuff()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			KillCounterBuff = ScriptableObject.CreateInstance<BuffDef>();
			((Object)KillCounterBuff).name = "PalmTreeKills";
			KillCounterBuff.buffColor = Color.white;
			KillCounterBuff.canStack = true;
			KillCounterBuff.isDebuff = false;
			KillCounterBuff.isHidden = true;
			ContentAddition.AddBuffDef(KillCounterBuff);
		}

		private static void SyncKillBuff(CharacterBody body, int kills)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (body.GetBuffCount(KillCounterBuff) != kills)
			{
				body.SetBuffCount(KillCounterBuff.buffIndex, kills);
			}
		}

		private static void AddHooks(ItemDef itemDefToHooks)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			GlobalEventManager.onCharacterDeathServer += OnCharacterDeathServer;
			CharacterBody.onBodyStartGlobal += OnBodyStartGlobal;
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(GetStatCoefficients);
			void GetStatCoefficients(CharacterBody self, StatHookEventArgs args)
			{
				if (Object.op_Implicit((Object)(object)self.inventory))
				{
					int itemCountEffective = self.inventory.GetItemCountEffective(itemDefToHooks);
					int buffCount = self.GetBuffCount(KillCounterBuff);
					if (itemCountEffective > 0 && buffCount > 0)
					{
						args.damageMultAdd += (float)(itemCountEffective * buffCount) * (Main.PalmTree_AdditionalBaseDamage.Value / 100f);
					}
				}
			}
			static void OnBodyStartGlobal(CharacterBody body)
			{
				if (NetworkServer.active && Object.op_Implicit((Object)(object)body.master))
				{
					PalmTreeKillTracker component = ((Component)body.master).GetComponent<PalmTreeKillTracker>();
					if (Object.op_Implicit((Object)(object)component))
					{
						SyncKillBuff(body, component.kills);
					}
				}
			}
			void OnCharacterDeathServer(DamageReport damageReport)
			{
				CharacterBody attackerBody = damageReport.attackerBody;
				CharacterMaster attackerMaster = damageReport.attackerMaster;
				if (Object.op_Implicit((Object)(object)attackerBody) && Object.op_Implicit((Object)(object)attackerMaster) && Object.op_Implicit((Object)(object)attackerBody.inventory) && attackerBody.inventory.GetItemCountEffective(itemDefToHooks) > 0)
				{
					PalmTreeKillTracker palmTreeKillTracker = ((Component)attackerMaster).GetComponent<PalmTreeKillTracker>();
					if (!Object.op_Implicit((Object)(object)palmTreeKillTracker))
					{
						palmTreeKillTracker = ((Component)attackerMaster).gameObject.AddComponent<PalmTreeKillTracker>();
					}
					palmTreeKillTracker.kills++;
					SyncKillBuff(attackerBody, palmTreeKillTracker.kills);
				}
			}
		}

		public static void Initiate()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			ItemAPI.Add(new CustomItem(itemDefinition, CreateDisplayRules()));
			AddTokens();
			CreateBuff();
			AddHooks(itemDefinition);
		}
	}
}
namespace PhreelsContentPack.Items.T2
{
	internal class EasternLantern
	{
		private static string itemName = "EasternLantern";

		private static string upperName = itemName.ToUpper();

		public static ItemDef itemDefinition = CreateItem();

		public static GameObject LoadPrefab()
		{
			return Main.MainAssets.LoadAsset<GameObject>("Assets/Palm tree/EasternLantern.prefab");
		}

		public static Sprite LoadSprite()
		{
			return Main.MainAssets.LoadAsset<Sprite>("Assets/Palm tree/EasternLantern.png");
		}

		public static ItemDef CreateItem()
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			ItemDef val = ScriptableObject.CreateInstance<ItemDef>();
			((Object)val).name = itemName;
			val.nameToken = "PCP_" + upperName + "_NAME";
			val.pickupToken = "PCP_" + upperName + "_PICKUP";
			val.descriptionToken = "PCP_" + upperName + "_DESC";
			val.loreToken = "PCP_" + upperName + "_LORE";
			ItemTag[] array = new ItemTag[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			val.tags = (ItemTag[])(object)array;
			val.deprecatedTier = (ItemTier)1;
			val.canRemove = true;
			val.hidden = false;
			val.pickupModelPrefab = LoadPrefab();
			val.pickupIconSprite = LoadSprite();
			return val;
		}

		public static ItemDisplayRuleDict CreateDisplayRules()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			helpers.PrepareItemDisplayModel(PrefabAPI.InstantiateClone(LoadPrefab(), ((Object)LoadPrefab()).name + "Display", false));
			return new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
		}

		public static void AddTokens()
		{
			LanguageAPI.Add("PCP_" + upperName + "_NAME", "Far Eastern Lantern");
			LanguageAPI.Add("PCP_" + upperName + "_PICKUP", "Increase your HP regen by the amount of allies you have.");
			LanguageAPI.Add("PCP_" + upperName + "_DESC", $"<style=cIsHealing>Increases base health regeneration by +{Main.EasternLantern_InitialRegenPerAlly.Value}hp/s</style> <style=cStack>(+{Main.EasternLantern_AdditionalRegenPerAlly.Value} hp/s per stack)</style> for each ally you have.");
			LanguageAPI.Add("PCP_" + upperName + "_LORE", "Did you know that the lanterns in Chinese culture represent family?");
		}

		private static void AddHooks(ItemDef itemDefToHooks)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(EasternLanternRecalculateStats);
			CharacterBody.onBodyStartGlobal += OnBodyChanged;
			CharacterBody.onBodyDestroyGlobal += OnBodyChanged;
			GlobalEventManager.onCharacterDeathServer += OnCharacterDeathServer;
			static int CountAllies(CharacterBody body)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				int num = 0;
				foreach (TeamComponent teamMember in TeamComponent.GetTeamMembers(body.teamComponent.teamIndex))
				{
					if (Object.op_Implicit((Object)(object)teamMember) && Object.op_Implicit((Object)(object)teamMember.body) && (Object)(object)teamMember.body != (Object)(object)body && Object.op_Implicit((Object)(object)teamMember.body.healthComponent) && teamMember.body.healthComponent.alive)
					{
						num++;
					}
				}
				return num;
			}
			void EasternLanternRecalculateStats(CharacterBody body, StatHookEventArgs args)
			{
				if (Object.op_Implicit((Object)(object)body.inventory) && Object.op_Implicit((Object)(object)body.teamComponent))
				{
					int itemCountEffective = body.inventory.GetItemCountEffective(itemDefToHooks);
					if (itemCountEffective > 0)
					{
						float num = Main.EasternLantern_InitialRegenPerAlly.Value + (float)(itemCountEffective - 1) * Main.EasternLantern_AdditionalRegenPerAlly.Value;
						args.baseRegenAdd += (float)CountAllies(body) * num;
					}
				}
			}
			void OnBodyChanged(CharacterBody body)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.teamComponent))
				{
					RefreshLanternHolders(body.teamComponent.teamIndex);
				}
			}
			void OnCharacterDeathServer(DamageReport damageReport)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				RefreshLanternHolders(damageReport.victimTeamIndex);
			}
			void RefreshLanternHolders(TeamIndex teamIndex)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				foreach (TeamComponent teamMember2 in TeamComponent.GetTeamMembers(teamIndex))
				{
					if (Object.op_Implicit((Object)(object)teamMember2) && Object.op_Implicit((Object)(object)teamMember2.body) && Object.op_Implicit((Object)(object)teamMember2.body.inventory) && teamMember2.body.inventory.GetItemCountEffective(itemDefToHooks) > 0)
					{
						teamMember2.body.MarkAllStatsDirty();
					}
				}
			}
		}

		public static void Initiate()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			ItemAPI.Add(new CustomItem(itemDefinition, CreateDisplayRules()));
			AddTokens();
			AddHooks(itemDefinition);
		}
	}
	internal class PirateCoin
	{
		private static string itemName = "PirateCoin";

		private static string upperName = itemName.ToUpper();

		public static ItemDef itemDefinition = CreateItem();

		public static GameObject LoadPrefab()
		{
			return Main.MainAssets.LoadAsset<GameObject>("Assets/DavePixel/PirateCoin/Prefabs/PirateCoin.prefab");
		}

		public static Sprite LoadSprite()
		{
			return Main.MainAssets.LoadAsset<Sprite>("Assets/Palm tree/PirateCoin.png");
		}

		public static ItemDef CreateItem()
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			ItemDef val = ScriptableObject.CreateInstance<ItemDef>();
			((Object)val).name = itemName;
			val.nameToken = "PCP_" + upperName + "_NAME";
			val.pickupToken = "PCP_" + upperName + "_PICKUP";
			val.descriptionToken = "PCP_" + upperName + "_DESC";
			val.loreToken = "PCP_" + upperName + "_LORE";
			ItemTag[] array = new ItemTag[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			val.tags = (ItemTag[])(object)array;
			val.deprecatedTier = (ItemTier)1;
			val.canRemove = true;
			val.hidden = false;
			val.pickupModelPrefab = LoadPrefab();
			val.pickupIconSprite = LoadSprite();
			return val;
		}

		public static ItemDisplayRuleDict CreateDisplayRules()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			helpers.PrepareItemDisplayModel(PrefabAPI.InstantiateClone(LoadPrefab(), ((Object)LoadPrefab()).name + "Display", false));
			return new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
		}

		public static void AddTokens()
		{
			LanguageAPI.Add("PCP_" + upperName + "_NAME", "Pirate Coin");
			LanguageAPI.Add("PCP_" + upperName + "_PICKUP", "Increase your HP based on the amount of White items you own.");
			LanguageAPI.Add("PCP_" + upperName + "_DESC", $"<style=cIsHealing>Increase your base HP by {Main.PirateCoin_PercentageHPWhiteItem.Value * 100f}%</style> for each Common item in your inventory. <style=cStack>Further stacks of the item, multiplies the HP increase effect by {Main.PirateCoin_PercentageHPWhiteItemMultiplierAtStacks.Value} times.</style>");
			LanguageAPI.Add("PCP_" + upperName + "_LORE", "One shipwrecked man's treasure is another sailor's savior of the day.");
		}

		private static void AddHooks(ItemDef itemDefToHooks)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(PirateCoinRecalculateStats);
			void PirateCoinRecalculateStats(CharacterBody body, StatHookEventArgs args)
			{
				if (Object.op_Implicit((Object)(object)body.inventory))
				{
					int itemCountEffective = body.inventory.GetItemCountEffective(itemDefToHooks);
					if (itemCountEffective > 0)
					{
						float num = 0f;
						num += (float)body.inventory.GetTotalItemCountOfTier((ItemTier)0);
						num += (float)body.inventory.GetTotalItemCountOfTier((ItemTier)6);
						float value = Main.PirateCoin_PercentageHPWhiteItem.Value;
						float num2 = (float)Math.Pow(Main.PirateCoin_PercentageHPWhiteItemMultiplierAtStacks.Value, itemCountEffective - 1);
						args.healthMultAdd += num * value * num2;
					}
				}
			}
		}

		public static void Initiate()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			ItemAPI.Add(new CustomItem(itemDefinition, CreateDisplayRules()));
			AddTokens();
			AddHooks(itemDefinition);
		}
	}
}
namespace PhreelsContentPack.Items.T1
{
	internal class DetachedStinger
	{
		private static string itemName = "DetachedStinger";

		private static string upperName = itemName.ToUpper();

		public static ItemDef itemDefinition = CreateItem();

		public static GameObject LoadPrefab()
		{
			return Main.MainAssets.LoadAsset<GameObject>("Assets/Palm tree/DetachedStinger.prefab");
		}

		public static Sprite LoadSprite()
		{
			return Main.MainAssets.LoadAsset<Sprite>("Assets/Palm tree/DetachedStinger.png");
		}

		public static ItemDef CreateItem()
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			ItemDef val = ScriptableObject.CreateInstance<ItemDef>();
			((Object)val).name = itemName;
			val.nameToken = "PCP_" + upperName + "_NAME";
			val.pickupToken = "PCP_" + upperName + "_PICKUP";
			val.descriptionToken = "PCP_" + upperName + "_DESC";
			val.loreToken = "PCP_" + upperName + "_LORE";
			val.tags = (ItemTag[])(object)new ItemTag[2]
			{
				(ItemTag)1,
				(ItemTag)31
			};
			val.deprecatedTier = (ItemTier)0;
			val.canRemove = true;
			val.hidden = false;
			val.pickupModelPrefab = LoadPrefab();
			val.pickupIconSprite = LoadSprite();
			return val;
		}

		public static ItemDisplayRuleDict CreateDisplayRules()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			helpers.PrepareItemDisplayModel(PrefabAPI.InstantiateClone(LoadPrefab(), ((Object)LoadPrefab()).name + "Display", false));
			return new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
		}

		public static void AddTokens()
		{
			LanguageAPI.Add("PCP_" + upperName + "_NAME", "Detached Stinger");
			LanguageAPI.Add("PCP_" + upperName + "_PICKUP", "Chance to inflict poison on hit.");
			LanguageAPI.Add("PCP_" + upperName + "_DESC", $"On hit, you have an <style=cIsDamage>{Main.DetachedStinger_ChancetoInflict.Value}% chance</style> <style=cStack>(+{Main.DetachedStinger_ChancetoInflict.Value}% per stack)</style> to <style=cIsDamage>poison</style> your target");
			LanguageAPI.Add("PCP_" + upperName + "_LORE", "Thank you Mr.Bones");
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddTokensWithVAPIEnabled()
		{
			LanguageAPI.Add("PCP_" + upperName + "_NAME", "Detached Stinger");
			LanguageAPI.Add("PCP_" + upperName + "_PICKUP", "Chance to inflict poison on hit. Deal more damage to variants.");
			LanguageAPI.Add("PCP_" + upperName + "_DESC", $"On hit, you have an <style=cIsDamage>{Main.DetachedStinger_ChancetoInflict.Value}% chance</style> <style=cStack>(+{Main.DetachedStinger_ChancetoInflict.Value}% per stack)</style> to <style=cIsDamage>poison</style> your target. Additionally deal <style=cIsDamage>{Main.DetachedStinger_DealExtraDamageToVariants.Value}% more damage</style> <style=cStack>(+{Main.DetachedStinger_DealExtraDamageToVariants.Value}% per stack)</style> to variant enemies.");
			LanguageAPI.Add("PCP_" + upperName + "_LORE", "Thank you Mr.Bones");
		}

		private static void AddHooks(ItemDef itemDefToHooks)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			GlobalEventManager.OnHitEnemy += new hook_OnHitEnemy(InflictPoison);
		}

		private static void InflictPoison(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
		{
			//IL_0083: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody val = default(CharacterBody);
			if (NetworkServer.active && Object.op_Implicit((Object)(object)damageInfo.attacker) && Object.op_Implicit((Object)(object)victim) && Object.op_Implicit((Object)(object)victim.GetComponent<CharacterBody>()) && damageInfo.attacker.TryGetComponent<CharacterBody>(ref val) && Object.op_Implicit((Object)(object)val.inventory))
			{
				int itemCountEffective = val.inventory.GetItemCountEffective(itemDefinition);
				if (itemCountEffective > 0 && Util.CheckRoll((float)itemCountEffective * Main.DetachedStinger_ChancetoInflict.Value * damageInfo.procCoefficient, val.master))
				{
					damageInfo.damageType |= DamageTypeCombo.op_Implicit((DamageType)4096);
				}
			}
			orig.Invoke(self, damageInfo, victim);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void AddHooksWithVAPIEnabled(ItemDef itemDefToHooks)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			GlobalEventManager.OnHitEnemy += new hook_OnHitEnemy(InflictPoison);
			HealthComponent.TakeDamage += new hook_TakeDamage(DealExtraDamageToVariants);
			void DealExtraDamageToVariants(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
			{
				if (NetworkServer.active && Object.op_Implicit((Object)(object)damageInfo.attacker) && Object.op_Implicit((Object)(object)damageInfo.attacker.GetComponent<CharacterBody>()) && Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)((Component)self).GetComponent<CharacterBody>()))
				{
					CharacterBody component = ((Component)self).GetComponent<CharacterBody>();
					Inventory inventory = damageInfo.attacker.GetComponent<CharacterBody>().inventory;
					if ((Object)(object)inventory != (Object)null)
					{
						int itemCountEffective = inventory.GetItemCountEffective(itemDefToHooks);
						if (itemCountEffective > 0 && component.HasBuff(Buffs.bdVariant))
						{
							damageInfo.damage *= 1f + (float)itemCountEffective * (Main.DetachedStinger_DealExtraDamageToVariants.Value / 100f);
						}
					}
				}
				orig.Invoke(self, damageInfo);
			}
		}

		public static void Initiate()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			ItemAPI.Add(new CustomItem(itemDefinition, CreateDisplayRules()));
			AddTokens();
			AddHooks(itemDefinition);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void InitiateWithVAPIEnabled()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			ItemAPI.Add(new CustomItem(itemDefinition, CreateDisplayRules()));
			AddTokensWithVAPIEnabled();
			AddHooksWithVAPIEnabled(itemDefinition);
		}
	}
}
namespace PhreelsContentPack.Items.Buffs
{
	public abstract class BuffBase<T> : BuffBase where T : BuffBase<T>
	{
		public static T instance { get; private set; }

		public BuffBase()
		{
			if (instance != null)
			{
				throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting BuffBase was instantiated twice");
			}
			instance = this as T;
		}
	}
	public abstract class BuffBase
	{
		public BuffDef BuffDef;

		public abstract string BuffName { get; }

		public abstract Color Color { get; }

		public virtual bool CanStack { get; set; }

		public virtual bool IsDebuff { get; set; }

		public abstract Sprite BuffIcon { get; }

		public abstract void Init();

		public void CreateBuff()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			BuffDef = ScriptableObject.CreateInstance<BuffDef>();
			((Object)BuffDef).name = BuffName;
			BuffDef.buffColor = Color;
			BuffDef.canStack = CanStack;
			BuffDef.isDebuff = IsDebuff;
			BuffDef.iconSprite = BuffIcon;
			ContentAddition.AddBuffDef(BuffDef);
		}

		public abstract void Hooks();
	}
}
namespace PhreelsContentPack.HelperClasses
{
	public class helpers
	{
		public static GameObject PrepareItemDisplayModel(GameObject itemDisplayModel)
		{
			//IL_001f: 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_003e: 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)
			ItemDisplay val = itemDisplayModel.AddComponent<ItemDisplay>();
			List<RendererInfo> list = new List<RendererInfo>();
			Renderer[] componentsInChildren = itemDisplayModel.GetComponentsInChildren<Renderer>();
			foreach (Renderer val2 in componentsInChildren)
			{
				RendererInfo item = new RendererInfo
				{
					renderer = val2,
					defaultMaterial = val2.material
				};
				list.Add(item);
			}
			val.rendererInfos = list.ToArray();
			return itemDisplayModel;
		}
	}
}