Decompiled source of MysteryEggs v1.1.0

plugins/MysteryEggs.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.Logging;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MysteryEggs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+729c549b2ac7b1cf3e77b01893cb3e0c1049cfc3")]
[assembly: AssemblyProduct("MysteryEggs")]
[assembly: AssemblyTitle("MysteryEggs")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MysteryEggs
{
	public static class Asset
	{
		public static AssetBundle mainBundle;

		public const string bundleName = "mysteryeggsbundle";

		public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(typeof(MysteryEggsPlugin).Assembly.Location), "mysteryeggsbundle".ToLower());

		public static void Init()
		{
			mainBundle = AssetBundle.LoadFromFile(AssetBundlePath);
		}
	}
	internal class GoldEggBehavior : ItemBehavior
	{
		private float timeBetweenResummons = 30f;

		private float timeBetweenRetryResummons = 1f;

		private float resummonCooldown;

		private DeployableSlot slot = MysteryEggsPlugin.goldSlot;

		public static ItemDef GetItemDef()
		{
			return MysteryEggsPlugin.goldEgg;
		}

		private void Awake()
		{
			((Behaviour)this).enabled = false;
		}

		private void OnEnable()
		{
			resummonCooldown = timeBetweenRetryResummons;
		}

		private void FixedUpdate()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_00d8: 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)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			int stack = base.stack;
			CharacterMaster bodyMaster = base.body.master;
			if (!Object.op_Implicit((Object)(object)bodyMaster))
			{
				return;
			}
			int deployableCount = bodyMaster.GetDeployableCount(slot);
			if (deployableCount < stack)
			{
				resummonCooldown -= Time.fixedDeltaTime;
				if (resummonCooldown <= 0f)
				{
					CharacterSpawnCard val = ScriptableObject.CreateInstance<CharacterSpawnCard>();
					((SpawnCard)val).prefab = Prefabs.beetleMaster;
					val.itemsToGrant = (ItemCountPair[])(object)new ItemCountPair[1]
					{
						new ItemCountPair
						{
							itemDef = MysteryEggsPlugin.goldOnKill,
							count = 1
						}
					};
					DirectorSpawnRequest val2 = new DirectorSpawnRequest((SpawnCard)(object)val, new DirectorPlacementRule
					{
						placementMode = (PlacementMode)1,
						minDistance = 3f,
						maxDistance = 40f,
						spawnOnTarget = ((Component)this).transform
					}, RoR2Application.rng);
					val2.summonerBodyObject = ((Component)this).gameObject;
					val2.onSpawnedServer = (Action<SpawnResult>)Delegate.Combine(val2.onSpawnedServer, new Action<SpawnResult>(OnSpawned));
					DirectorCore.instance.TrySpawnObject(val2);
					resummonCooldown = timeBetweenResummons / (float)stack;
				}
			}
			void OnSpawned(SpawnResult result)
			{
				//IL_0001: 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_0023: Unknown result type (might be due to invalid IL or missing references)
				if (result.success)
				{
					bodyMaster.AddDeployable(result.spawnedInstance.GetComponent<Deployable>(), slot);
				}
				else
				{
					resummonCooldown = timeBetweenRetryResummons;
				}
			}
		}
	}
	internal static class Language
	{
		public static string TokensOutput = "";

		public static bool usingLanguageFolder = false;

		public static bool printingEnabled = false;

		public static void Init()
		{
			if (usingLanguageFolder)
			{
				Language.collectLanguageRootFolders += Language_collectLanguageRootFolders;
			}
		}

		private static void Language_collectLanguageRootFolders(List<string> obj)
		{
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)MysteryEggsPlugin.instance).Info.Location), "Language");
			if (Directory.Exists(text))
			{
				obj.Add(text);
			}
		}

		public static void Add(string token, string text)
		{
			if (!usingLanguageFolder)
			{
				LanguageAPI.Add(token, text);
			}
			if (printingEnabled)
			{
				TokensOutput = TokensOutput + "\n    \"" + token + "\" : \"" + text.Replace(Environment.NewLine, "\\n").Replace("\n", "\\n") + "\",";
			}
		}

		public static void PrintOutput(string fileName = "")
		{
			if (printingEnabled)
			{
				string text = "{\n    strings:\n    {" + TokensOutput + "\n    }\n}";
				Log.Message(fileName + ": \n" + text);
				if (!string.IsNullOrEmpty(fileName))
				{
					string path = Path.Combine(Directory.GetParent(((BaseUnityPlugin)MysteryEggsPlugin.instance).Info.Location).FullName, "Language", "en", fileName);
					File.WriteAllText(path, text);
				}
				TokensOutput = "";
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	internal class LunarEggBehavior : ItemBehavior
	{
		private float timeBetweenResummons = 10f;

		private float timeBetweenRetryResummons = 1f;

		private float resummonCooldown;

		private DeployableSlot slot = MysteryEggsPlugin.lunarSlot;

		public static ItemDef GetItemDef()
		{
			return MysteryEggsPlugin.lunarEgg;
		}

		private void Awake()
		{
			((Behaviour)this).enabled = false;
		}

		private void OnEnable()
		{
			resummonCooldown = timeBetweenRetryResummons;
		}

		private void FixedUpdate()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_00d8: 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)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			int stack = base.stack;
			CharacterMaster bodyMaster = base.body.master;
			if (!Object.op_Implicit((Object)(object)bodyMaster))
			{
				return;
			}
			int deployableCount = bodyMaster.GetDeployableCount(slot);
			if (deployableCount < stack)
			{
				resummonCooldown -= Time.fixedDeltaTime;
				if (resummonCooldown <= 0f)
				{
					CharacterSpawnCard val = ScriptableObject.CreateInstance<CharacterSpawnCard>();
					((SpawnCard)val).prefab = Prefabs.lemurianMaster;
					val.itemsToGrant = (ItemCountPair[])(object)new ItemCountPair[1]
					{
						new ItemCountPair
						{
							itemDef = MysteryEggsPlugin.lunarOnKill,
							count = 1
						}
					};
					DirectorSpawnRequest val2 = new DirectorSpawnRequest((SpawnCard)(object)val, new DirectorPlacementRule
					{
						placementMode = (PlacementMode)1,
						minDistance = 3f,
						maxDistance = 40f,
						spawnOnTarget = ((Component)this).transform
					}, RoR2Application.rng);
					val2.summonerBodyObject = ((Component)this).gameObject;
					val2.onSpawnedServer = (Action<SpawnResult>)Delegate.Combine(val2.onSpawnedServer, new Action<SpawnResult>(OnSpawned));
					DirectorCore.instance.TrySpawnObject(val2);
					resummonCooldown = timeBetweenResummons / (float)stack;
				}
			}
			void OnSpawned(SpawnResult result)
			{
				//IL_0001: 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_0023: Unknown result type (might be due to invalid IL or missing references)
				if (result.success)
				{
					bodyMaster.AddDeployable(result.spawnedInstance.GetComponent<Deployable>(), slot);
				}
				else
				{
					resummonCooldown = timeBetweenRetryResummons;
				}
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Slendykray.MysteryEggs", "MysteryEggs", "1.0.0")]
	public class MysteryEggsPlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static GetDeployableSameSlotLimit <>9__16_0;

			public static GetDeployableSameSlotLimit <>9__16_1;

			public static GetDeployableSameSlotLimit <>9__16_2;

			internal int <InitDeployableSlots>b__16_0(CharacterMaster master, int slot)
			{
				return master.inventory.GetItemCount(goldEgg);
			}

			internal int <InitDeployableSlots>b__16_1(CharacterMaster master, int slot)
			{
				return master.inventory.GetItemCount(lunarEgg);
			}

			internal int <InitDeployableSlots>b__16_2(CharacterMaster master, int slot)
			{
				return master.inventory.GetItemCount(voidEgg);
			}
		}

		public const string PluginGUID = "Slendykray.MysteryEggs";

		public const string PluginAuthor = "Slendykray";

		public const string PluginName = "MysteryEggs";

		public const string PluginVersion = "1.0.0";

		public static MysteryEggsPlugin instance;

		public static ItemDef lunarOnKill;

		public static ItemDef goldOnKill;

		public static ItemDef voidOnKill;

		public static ItemDef goldEgg;

		public static ItemDef lunarEgg;

		public static ItemDef voidEgg;

		public static DeployableSlot goldSlot;

		public static DeployableSlot lunarSlot;

		public static DeployableSlot voidSlot;

		public void Awake()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			Asset.Init();
			Prefabs.Init();
			InitItems();
			InitHelpers();
			InitDeployableSlots();
			Tokens.Init();
			CharacterBody.OnInventoryChanged += new hook_OnInventoryChanged(CharacterBody_OnInventoryChanged);
			GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal;
		}

		private void InitItems()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Expected O, but got Unknown
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: 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_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Expected O, but got Unknown
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			goldEgg = ScriptableObject.CreateInstance<ItemDef>();
			((Object)goldEgg).name = "GOLDEGG_NAME";
			goldEgg.nameToken = "GOLDEGG_NAME";
			goldEgg.pickupToken = "GOLDEGG_PICKUP";
			goldEgg.descriptionToken = "GOLDEGG_DESC";
			goldEgg.loreToken = "GOLDEGG_LORE";
			goldEgg._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
			goldEgg.pickupIconSprite = Asset.mainBundle.LoadAsset<Sprite>("texGold");
			GameObject val2 = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/FireBallDash/PickupEgg.prefab").WaitForCompletion(), "eggg");
			((Renderer)((Component)val2.transform.Find("mdlEgg")).GetComponent<MeshRenderer>()).material = Asset.mainBundle.LoadAsset<Material>("matGold");
			goldEgg.pickupModelPrefab = val2;
			goldEgg.canRemove = true;
			goldEgg.hidden = false;
			ItemDef obj = goldEgg;
			ItemTag[] array = new ItemTag[6];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj.tags = (ItemTag[])(object)array;
			ItemAPI.Add(new CustomItem(goldEgg, val));
			lunarEgg = ScriptableObject.CreateInstance<ItemDef>();
			((Object)lunarEgg).name = "LUNAREGG_NAME";
			lunarEgg.nameToken = "LUNAREGG_NAME";
			lunarEgg.pickupToken = "LUNAREGG_PICKUP";
			lunarEgg.descriptionToken = "LUNAREGG_DESC";
			lunarEgg.loreToken = "LUNAREGG_LORE";
			lunarEgg._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/LunarTierDef.asset").WaitForCompletion();
			lunarEgg.pickupIconSprite = Asset.mainBundle.LoadAsset<Sprite>("texLunar");
			GameObject val3 = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/FireBallDash/PickupEgg.prefab").WaitForCompletion(), "eggg");
			((Renderer)((Component)val3.transform.Find("mdlEgg")).GetComponent<MeshRenderer>()).material = Asset.mainBundle.LoadAsset<Material>("matLunar");
			lunarEgg.pickupModelPrefab = val3;
			lunarEgg.canRemove = true;
			lunarEgg.hidden = false;
			ItemDef obj2 = lunarEgg;
			ItemTag[] array2 = new ItemTag[6];
			RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj2.tags = (ItemTag[])(object)array2;
			ItemAPI.Add(new CustomItem(lunarEgg, val));
			voidEgg = ScriptableObject.CreateInstance<ItemDef>();
			((Object)voidEgg).name = "VOIDEGG_NAME";
			voidEgg.nameToken = "VOIDEGG_NAME";
			voidEgg.pickupToken = "VOIDEGG_PICKUP";
			voidEgg.descriptionToken = "VOIDEGG_DESC";
			voidEgg.loreToken = "VOIDEGG_LORE";
			voidEgg._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/DLC1/Common/VoidTier2Def.asset").WaitForCompletion();
			voidEgg.pickupIconSprite = Asset.mainBundle.LoadAsset<Sprite>("texVoid");
			GameObject val4 = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/FireBallDash/PickupEgg.prefab").WaitForCompletion(), "eggg");
			((Renderer)((Component)val4.transform.Find("mdlEgg")).GetComponent<MeshRenderer>()).material = Asset.mainBundle.LoadAsset<Material>("matVoid");
			voidEgg.pickupModelPrefab = val4;
			voidEgg.canRemove = true;
			voidEgg.hidden = false;
			ItemDef obj3 = voidEgg;
			ItemTag[] array3 = new ItemTag[6];
			RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj3.tags = (ItemTag[])(object)array3;
			voidEgg.requiredExpansion = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC1/Common/DLC1.asset").WaitForCompletion();
			ItemAPI.Add(new CustomItem(voidEgg, val));
			ItemRelationshipProvider val5 = ScriptableObject.CreateInstance<ItemRelationshipProvider>();
			((Object)val5).name = "MysteryEggContagiousItemProvider";
			val5.relationshipType = Addressables.LoadAssetAsync<ItemRelationshipType>((object)"RoR2/DLC1/Common/ContagiousItem.asset").WaitForCompletion();
			val5.relationships = (Pair[])(object)new Pair[1]
			{
				new Pair
				{
					itemDef1 = goldEgg,
					itemDef2 = voidEgg
				}
			};
			ContentAddition.AddItemRelationshipProvider(val5);
		}

		private void InitDeployableSlots()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0049: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			object obj = <>c.<>9__16_0;
			if (obj == null)
			{
				GetDeployableSameSlotLimit val = (CharacterMaster master, int slot) => master.inventory.GetItemCount(goldEgg);
				<>c.<>9__16_0 = val;
				obj = (object)val;
			}
			goldSlot = DeployableAPI.RegisterDeployableSlot((GetDeployableSameSlotLimit)obj);
			object obj2 = <>c.<>9__16_1;
			if (obj2 == null)
			{
				GetDeployableSameSlotLimit val2 = (CharacterMaster master, int slot) => master.inventory.GetItemCount(lunarEgg);
				<>c.<>9__16_1 = val2;
				obj2 = (object)val2;
			}
			lunarSlot = DeployableAPI.RegisterDeployableSlot((GetDeployableSameSlotLimit)obj2);
			object obj3 = <>c.<>9__16_2;
			if (obj3 == null)
			{
				GetDeployableSameSlotLimit val3 = (CharacterMaster master, int slot) => master.inventory.GetItemCount(voidEgg);
				<>c.<>9__16_2 = val3;
				obj3 = (object)val3;
			}
			voidSlot = DeployableAPI.RegisterDeployableSlot((GetDeployableSameSlotLimit)obj3);
		}

		private void InitHelpers()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//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_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_00c0: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//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_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Expected O, but got Unknown
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			goldOnKill = ScriptableObject.CreateInstance<ItemDef>();
			((Object)goldOnKill).name = "GOLDONKILL_NAME";
			goldOnKill.nameToken = "GOLDONKILL_NAME";
			goldOnKill.pickupToken = "GOLDONKILL_PICKUP";
			goldOnKill.descriptionToken = "GOLDONKILL_DESC";
			goldOnKill.loreToken = "GOLDONKILL_LORE";
			goldOnKill.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Core/texNullIcon.png").WaitForCompletion();
			goldOnKill.canRemove = false;
			goldOnKill.hidden = true;
			goldOnKill.tags = (ItemTag[])(object)new ItemTag[1] { (ItemTag)9 };
			goldOnKill.deprecatedTier = (ItemTier)5;
			ItemAPI.Add(new CustomItem(goldOnKill, val));
			lunarOnKill = ScriptableObject.CreateInstance<ItemDef>();
			((Object)lunarOnKill).name = "LUNARONKILL_NAME";
			lunarOnKill.nameToken = "LUNARONKILL_NAME";
			lunarOnKill.pickupToken = "LUNARONKILL_PICKUP";
			lunarOnKill.descriptionToken = "LUNARONKILL_DESC";
			lunarOnKill.loreToken = "LUNARONKILL_LORE";
			lunarOnKill.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Core/texNullIcon.png").WaitForCompletion();
			lunarOnKill.canRemove = false;
			lunarOnKill.hidden = true;
			lunarOnKill.tags = (ItemTag[])(object)new ItemTag[1] { (ItemTag)9 };
			lunarOnKill.deprecatedTier = (ItemTier)5;
			ItemAPI.Add(new CustomItem(lunarOnKill, val));
			voidOnKill = ScriptableObject.CreateInstance<ItemDef>();
			((Object)voidOnKill).name = "VOIDONKILL_NAME";
			voidOnKill.nameToken = "VOIDONKILL_NAME";
			voidOnKill.pickupToken = "VOIDONKILL_PICKUP";
			voidOnKill.descriptionToken = "VOIDONKILL_DESC";
			voidOnKill.loreToken = "VOIDONKILL_LORE";
			voidOnKill.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Core/texNullIcon.png").WaitForCompletion();
			voidOnKill.canRemove = false;
			voidOnKill.hidden = true;
			voidOnKill.tags = (ItemTag[])(object)new ItemTag[1] { (ItemTag)9 };
			voidOnKill.deprecatedTier = (ItemTier)5;
			ItemAPI.Add(new CustomItem(voidOnKill, val));
		}

		private void CharacterBody_OnInventoryChanged(orig_OnInventoryChanged orig, CharacterBody self)
		{
			if (NetworkServer.active)
			{
				self.AddItemBehavior<LunarEggBehavior>(self.inventory.GetItemCount(lunarEgg));
				self.AddItemBehavior<GoldEggBehavior>(self.inventory.GetItemCount(goldEgg));
				self.AddItemBehavior<VoidEggBehavior>(self.inventory.GetItemCount(voidEgg));
			}
			orig.Invoke(self);
		}

		private void GlobalEventManager_onCharacterDeathGlobal(DamageReport report)
		{
			//IL_002a: 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_0055: 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_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_0125: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)report.attacker) || !Object.op_Implicit((Object)(object)report.attackerBody))
			{
				return;
			}
			TeamIndex attackerTeamIndex = report.attackerTeamIndex;
			CharacterBody attackerBody = report.attackerBody;
			if (!Object.op_Implicit((Object)(object)attackerBody.inventory))
			{
				return;
			}
			int itemCount = attackerBody.inventory.GetItemCount(goldOnKill.itemIndex);
			if (itemCount > 0)
			{
				GameObject val = Object.Instantiate<GameObject>(LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/BonusMoneyPack"), ((Component)report.victim).gameObject.transform.position, Random.rotation);
				TeamFilter component = val.GetComponent<TeamFilter>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.teamIndex = attackerTeamIndex;
				}
				NetworkServer.Spawn(val);
			}
			int itemCount2 = attackerBody.inventory.GetItemCount(lunarOnKill.itemIndex);
			if (itemCount2 > 0)
			{
				PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(MiscPickups.LunarCoin.miscPickupIndex), ((Component)report.victim).transform.position, Vector3.up * 10f);
			}
			int itemCount3 = attackerBody.inventory.GetItemCount(voidOnKill.itemIndex);
			if (itemCount3 > 0)
			{
				if (Chainloader.PluginInfos.ContainsKey("bubbet.bubbetsitems"))
				{
					PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(MiscPickups.VoidCoin.miscPickupIndex), ((Component)report.victim).transform.position, Vector3.up * 10f);
				}
				else
				{
					PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(MiscPickups.LunarCoin.miscPickupIndex), ((Component)report.victim).transform.position, Vector3.up * 10f);
				}
			}
		}

		private void Update()
		{
		}
	}
	public static class Prefabs
	{
		public static GameObject beetleMaster;

		public static GameObject lemurianMaster;

		public static GameObject[] voidMasters;

		public static void Init()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: 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_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			beetleMaster = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/BeetleGuard/BeetleGuardMaster.prefab").WaitForCompletion(), "lunarboi");
			if (!Object.op_Implicit((Object)(object)beetleMaster.GetComponent<Deployable>()))
			{
				beetleMaster.AddComponent<Deployable>();
			}
			GameObject val = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/BeetleGuard/BeetleGuardBody.prefab").WaitForCompletion(), "beetleGoldBodyPrefab");
			CharacterBody component = val.GetComponent<CharacterBody>();
			component.baseRegen = 0.6f;
			component.levelRegen = 0.12f;
			component.baseMaxHealth = 800f;
			component.baseDamage = 20f;
			beetleMaster.GetComponent<CharacterMaster>().bodyPrefab = val;
			ContentAddition.AddBody(val);
			lemurianMaster = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Lemurian/LemurianMaster.prefab").WaitForCompletion(), "lunarboi");
			lemurianMaster.AddComponent<Deployable>();
			AISkillDriver val2 = lemurianMaster.AddComponent<AISkillDriver>();
			val2.moveTargetType = (TargetType)2;
			val2.movementType = (MovementType)1;
			val2.aimType = (AimType)1;
			val2.minDistance = 10f;
			val2.skillSlot = (SkillSlot)(-1);
			val2.customName = "ReturnToLeaderDefault";
			foreach (AISkillDriver item in lemurianMaster.transform)
			{
				AISkillDriver val3 = item;
				if (val3.customName.Contains("PathFromAfar"))
				{
					Object.Destroy((Object)(object)val3);
				}
			}
			GameObject val4 = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Lemurian/LemurianBody.prefab").WaitForCompletion(), "lemurianLunarBodyPrefab");
			CharacterBody component2 = val4.GetComponent<CharacterBody>();
			component2.baseRegen = 0.6f;
			component2.baseMaxHealth = 500f;
			lemurianMaster.GetComponent<CharacterMaster>().bodyPrefab = val4;
			ContentAddition.AddBody(val4);
			voidMasters = (GameObject[])(object)new GameObject[3]
			{
				PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Nullifier/NullifierMaster.prefab").WaitForCompletion(), "gg"),
				PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/VoidJailer/VoidJailerMaster.prefab").WaitForCompletion(), "gg"),
				PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/VoidMegaCrab/VoidMegaCrabMaster.prefab").WaitForCompletion(), "gg")
			};
			GameObject[] array = voidMasters;
			foreach (GameObject val5 in array)
			{
				val5.AddComponent<Deployable>();
				AISkillDriver val6 = val5.AddComponent<AISkillDriver>();
				val6.moveTargetType = (TargetType)2;
				val6.movementType = (MovementType)1;
				val6.aimType = (AimType)1;
				val6.minDistance = 10f;
				val6.skillSlot = (SkillSlot)(-1);
				val6.customName = "ReturnToLeaderDefault";
			}
		}
	}
	internal class Tokens
	{
		public static void Init()
		{
			Language.Add("GOLDEGG_NAME", "Golden Beetle Egg");
			Language.Add("GOLDEGG_PICKUP", "Recruit a " + UtilityText("Beetle Guard") + ". Drops " + DamageText("Gold") + " on kill.");
			Language.Add("GOLDEGG_DESC", "Every " + UtilityText("30") + " " + StackText("-50%") + " seconds summon a " + UtilityText("Beetle Guard") + ". Drops " + DamageText("Gold chunks") + " on kill. Can have up to " + UtilityText("1") + " " + StackText("+1") + ".");
			Language.Add("GOLDEGG_LORE", "goldddddddd");
			Language.Add("LUNAREGG_NAME", "Newt's Egg");
			Language.Add("LUNAREGG_PICKUP", "Recruit a " + UtilityText("Lemurian") + ". Drops " + UtilityText("Lunar coins") + " on kill.");
			Language.Add("LUNAREGG_DESC", "Every " + UtilityText("10") + " " + StackText("-50%") + " seconds summon a " + UtilityText("Lemurian") + ". Drops " + UtilityText("Lunar coins") + " on kill. Can have up to " + UtilityText("1") + " " + StackText("+1") + ".");
			Language.Add("LUNAREGG_LORE", "lunarrrrrr");
			string text = UtilityText("Lunar coins");
			if (Chainloader.PluginInfos.ContainsKey("bubbet.bubbetsitems"))
			{
				text = VoidText("Void markers");
			}
			Language.Add("VOIDEGG_NAME", "V01? 366");
			Language.Add("VOIDEGG_PICKUP", "Recruit a " + VoidText("Void ally") + ". Drops " + text + " on kill. " + VoidText("Corrupts all Golden Beetle Eggs") + ".");
			Language.Add("VOIDEGG_DESC", "Every " + UtilityText("60") + " " + StackText("-50%") + " seconds summon a " + VoidText("Void ally") + ". Drops " + text + " on kill. Can have up to " + UtilityText("1") + " " + StackText("+1") + ". " + VoidText("Corrupts all Golden Beetle Eggs") + ".");
			Language.Add("VOIDEGG_LORE", "voiddddd");
		}

		public static string UtilityText(string text)
		{
			return "<style=cIsUtility>" + text + "</style>";
		}

		public static string StackText(string text)
		{
			return "<style=cStack>(" + text + " per stack)</style>";
		}

		public static string DamageText(string text)
		{
			return "<style=cIsDamage>" + text + "</style>";
		}

		public static string VoidText(string text)
		{
			return "<style=cIsVoid>" + text + "</style>";
		}
	}
	internal class VoidEggBehavior : ItemBehavior
	{
		private float timeBetweenResummons = 60f;

		private float timeBetweenRetryResummons = 1f;

		private float resummonCooldown;

		private DeployableSlot slot = MysteryEggsPlugin.voidSlot;

		public static ItemDef GetItemDef()
		{
			return MysteryEggsPlugin.voidEgg;
		}

		private void Awake()
		{
			((Behaviour)this).enabled = false;
		}

		private void OnEnable()
		{
			resummonCooldown = timeBetweenRetryResummons;
		}

		private void FixedUpdate()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_00d1: 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)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			int stack = base.stack;
			CharacterMaster bodyMaster = base.body.master;
			if (!Object.op_Implicit((Object)(object)bodyMaster))
			{
				return;
			}
			int deployableCount = bodyMaster.GetDeployableCount(slot);
			if (deployableCount < stack)
			{
				resummonCooldown -= Time.fixedDeltaTime;
				if (resummonCooldown <= 0f)
				{
					int num = Random.Range(0, 3);
					CharacterSpawnCard val = ScriptableObject.CreateInstance<CharacterSpawnCard>();
					((SpawnCard)val).prefab = Prefabs.voidMasters[num];
					val.itemsToGrant = (ItemCountPair[])(object)new ItemCountPair[1]
					{
						new ItemCountPair
						{
							itemDef = MysteryEggsPlugin.voidOnKill,
							count = 1
						}
					};
					DirectorSpawnRequest val2 = new DirectorSpawnRequest((SpawnCard)(object)val, new DirectorPlacementRule
					{
						placementMode = (PlacementMode)1,
						minDistance = 3f,
						maxDistance = 40f,
						spawnOnTarget = ((Component)this).transform
					}, RoR2Application.rng);
					val2.summonerBodyObject = ((Component)this).gameObject;
					val2.onSpawnedServer = (Action<SpawnResult>)Delegate.Combine(val2.onSpawnedServer, new Action<SpawnResult>(OnSpawned));
					DirectorCore.instance.TrySpawnObject(val2);
					resummonCooldown = timeBetweenResummons / (float)stack;
				}
			}
			void OnSpawned(SpawnResult result)
			{
				//IL_0001: 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_0023: Unknown result type (might be due to invalid IL or missing references)
				if (result.success)
				{
					bodyMaster.AddDeployable(result.spawnedInstance.GetComponent<Deployable>(), slot);
				}
				else
				{
					resummonCooldown = timeBetweenRetryResummons;
				}
			}
		}
	}
}