Decompiled source of BetterDropItemFixButAwesome v1.0.1

EvilDropItem.dll

Decompiled 6 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 EntityStates;
using HG;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.UI.MainMenu;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using RoR2.UI.MainMenu;
using RoR2BepInExPack.GameAssetPathsBetter;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityHotReloadNS;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EvilDropItem
{
	public static class CheesePrevention
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_CreatePickup <0>__GenericPickupControllerOnCreatePickup;

			public static hook_OnDisable <1>__GenericPickupControllerOnOnDisable;

			public static hook_OnInteractionBegin <2>__PickupPickerControllerOnOnInteractionBegin;

			public static hook_OnInteractionBegin <3>__PurchaseInteractionOnOnInteractionBegin;
		}

		public static List<GenericPickupController> thrownPickups = new List<GenericPickupController>();

		public static void Hooks()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			object obj = <>O.<0>__GenericPickupControllerOnCreatePickup;
			if (obj == null)
			{
				hook_CreatePickup val = GenericPickupControllerOnCreatePickup;
				<>O.<0>__GenericPickupControllerOnCreatePickup = val;
				obj = (object)val;
			}
			GenericPickupController.CreatePickup += (hook_CreatePickup)obj;
			object obj2 = <>O.<1>__GenericPickupControllerOnOnDisable;
			if (obj2 == null)
			{
				hook_OnDisable val2 = GenericPickupControllerOnOnDisable;
				<>O.<1>__GenericPickupControllerOnOnDisable = val2;
				obj2 = (object)val2;
			}
			GenericPickupController.OnDisable += (hook_OnDisable)obj2;
			object obj3 = <>O.<2>__PickupPickerControllerOnOnInteractionBegin;
			if (obj3 == null)
			{
				hook_OnInteractionBegin val3 = PickupPickerControllerOnOnInteractionBegin;
				<>O.<2>__PickupPickerControllerOnOnInteractionBegin = val3;
				obj3 = (object)val3;
			}
			PickupPickerController.OnInteractionBegin += (hook_OnInteractionBegin)obj3;
			object obj4 = <>O.<3>__PurchaseInteractionOnOnInteractionBegin;
			if (obj4 == null)
			{
				hook_OnInteractionBegin val4 = PurchaseInteractionOnOnInteractionBegin;
				<>O.<3>__PurchaseInteractionOnOnInteractionBegin = val4;
				obj4 = (object)val4;
			}
			PurchaseInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj4;
		}

		private static void PurchaseInteractionOnOnInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
		{
			if (((!self.displayNameToken.StartsWith("DUPLICATOR") || Configs.cheatPrinters.Value) && (!self.displayNameToken.StartsWith("BAZAAR_CAULDRON") || Configs.cheatCauldrons.Value)) || !PickupAlive())
			{
				orig.Invoke(self, activator);
			}
		}

		private static void PickupPickerControllerOnOnInteractionBegin(orig_OnInteractionBegin orig, PickupPickerController self, Interactor activator)
		{
			if (Configs.cheatScrappers.Value || !PickupAlive())
			{
				orig.Invoke(self, activator);
			}
		}

		private static void GenericPickupControllerOnOnDisable(orig_OnDisable orig, GenericPickupController self)
		{
			orig.Invoke(self);
			thrownPickups.Remove(self);
		}

		private static GenericPickupController GenericPickupControllerOnCreatePickup(orig_CreatePickup orig, ref CreatePickupInfo createpickupinfo)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			GenericPickupController val = orig.Invoke(ref createpickupinfo);
			if ((int)createpickupinfo.artifactFlag == -1225)
			{
				thrownPickups.Add(val);
			}
			return val;
		}

		private static void CleanupList()
		{
			List<GenericPickupController> list = new List<GenericPickupController>();
			foreach (GenericPickupController thrownPickup in thrownPickups)
			{
				if (Object.op_Implicit((Object)(object)thrownPickup))
				{
					list.Add(thrownPickup);
				}
			}
			thrownPickups = list;
		}

		private static bool PickupAlive()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			CleanupList();
			if (thrownPickups.Count <= 0)
			{
				return false;
			}
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = (Configs.FUCKING.Value ? "<style=cWorldEvent>grrr stop trying to <style=cIsHealth>cheat</style> and pick up your <style=cIsUtility>FUCKINGs items</style> ,..,</style>" : "<style=cWorldEvent>grrr stop trying to <style=cIsHealth>cheat</style> and pick up your <style=cIsUtility>freakings items</style> ,..,</style>")
			});
			return true;
		}
	}
	public class Configs
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Start <>9__7_0;

			public static Action<AsyncOperationHandle<GameObject>> <>9__8_0;

			public static Action<AsyncOperationHandle<GameObject>> <>9__8_1;

			internal void <LoadConfigs>b__7_0(orig_Start orig, MainMenuController self)
			{
				orig.Invoke(self);
				HandleInspectSetting(null, null);
			}

			internal void <HandleInspectSetting>b__8_0(AsyncOperationHandle<GameObject> handle)
			{
				ItemIconClicked component = handle.Result.GetComponent<ItemIconClicked>();
				if (Object.op_Implicit((Object)(object)component))
				{
					Object.Destroy((Object)(object)component);
				}
			}

			internal void <HandleInspectSetting>b__8_1(AsyncOperationHandle<GameObject> handle)
			{
				if (!Object.op_Implicit((Object)(object)handle.Result.GetComponent<ItemIconClicked>()))
				{
					handle.Result.AddComponent<ItemIconClicked>();
				}
			}
		}

		public static ConfigEntry<bool> FUCKING;

		public static ConfigEntry<bool> cheatScrappers;

		public static ConfigEntry<bool> cheatPrinters;

		public static ConfigEntry<bool> cheatCauldrons;

		public static ConfigEntry<bool> enableWithInspect;

		public static ConfigEntry<string> itemTierBlacklist;

		public static List<ItemTier> blacklistTiers = new List<ItemTier>();

		public static void LoadConfigs()
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			FUCKING = ((BaseUnityPlugin)EvilDropItem.instance).Config.Bind<bool>("BetterDropItemFixButAwesome", "FUCKING", false, "fucking ,..,");
			cheatScrappers = ((BaseUnityPlugin)EvilDropItem.instance).Config.Bind<bool>("BetterDropItemFixButAwesome", "allow scrappers when items are on the floor,..,", true, "");
			cheatPrinters = ((BaseUnityPlugin)EvilDropItem.instance).Config.Bind<bool>("BetterDropItemFixButAwesome", "allow printers when items are on the floor,..,", false, "");
			cheatCauldrons = ((BaseUnityPlugin)EvilDropItem.instance).Config.Bind<bool>("BetterDropItemFixButAwesome", "allow cauldrons when items are on the floor,..,", false, "");
			enableWithInspect = ((BaseUnityPlugin)EvilDropItem.instance).Config.Bind<bool>("BetterDropItemFixButAwesome", "pick items to drop from scoreboard when inspect setting is enabled,..,", false, "");
			enableWithInspect.SettingChanged += HandleInspectSetting;
			object obj = <>c.<>9__7_0;
			if (obj == null)
			{
				hook_Start val = delegate(orig_Start orig, MainMenuController self)
				{
					orig.Invoke(self);
					HandleInspectSetting(null, null);
				};
				<>c.<>9__7_0 = val;
				obj = (object)val;
			}
			MainMenuController.Start += (hook_Start)obj;
			itemTierBlacklist = ((BaseUnityPlugin)EvilDropItem.instance).Config.Bind<string>("BetterDropItemFixButAwesome", "item tier blacklist", "VoidTier1,VoidTier2,VoidTier3,VoidBoss,NoTier,Hex,Lunar", "options .,,. Tier1,VoidTier1,Tier2,VoidTier2,Tier3,VoidTier3,Boss,VoidBoss,Cursed,FoodTier,Lunar,NoTier,Page,Hex");
			itemTierBlacklist.SettingChanged += HandleTierBlacklist;
			HandleTierBlacklist(null, null);
		}

		private static void HandleInspectSetting(object sender, EventArgs eventArgs)
		{
			//IL_00c0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			bool? flag = ((firstLocalUser == null) ? ((bool?)null) : firstLocalUser.userProfile?.useInspectFeature);
			if (!flag.HasValue)
			{
				Log.Warning("inspect feature is null .,.,");
				return;
			}
			AsyncOperationHandle<GameObject> val;
			if (flag == true && enableWithInspect.Value)
			{
				Log.Debug("remoivg");
				val = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_UI.ItemIconScoreboard_InGame_prefab);
				val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
				{
					ItemIconClicked component = handle.Result.GetComponent<ItemIconClicked>();
					if (Object.op_Implicit((Object)(object)component))
					{
						Object.Destroy((Object)(object)component);
					}
				};
				return;
			}
			Log.Debug("addi");
			val = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_UI.ItemIconScoreboard_InGame_prefab);
			val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
			{
				if (!Object.op_Implicit((Object)(object)handle.Result.GetComponent<ItemIconClicked>()))
				{
					handle.Result.AddComponent<ItemIconClicked>();
				}
			};
		}

		public static void HandleTierBlacklist(object sender, EventArgs eventArgs)
		{
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			blacklistTiers = new List<ItemTier>();
			string[] array = itemTierBlacklist.Value.Split(",");
			foreach (string text in array)
			{
				if (1 == 0)
				{
				}
				ItemTier? val = text switch
				{
					"Tier1" => (ItemTier)0, 
					"VoidTier1" => (ItemTier)6, 
					"Tier2" => (ItemTier)1, 
					"VoidTier2" => (ItemTier)7, 
					"Tier3" => (ItemTier)2, 
					"VoidTier3" => (ItemTier)8, 
					"Boss" => (ItemTier)4, 
					"VoidBoss" => (ItemTier)9, 
					"NoTier" => (ItemTier)5, 
					"Page" => (ItemTier)12, 
					"Hex" => (ItemTier)13, 
					"Cursed" => (ItemTier)11, 
					"FoodTier" => (ItemTier)10, 
					"Lunar" => (ItemTier)3, 
					_ => null, 
				};
				if (1 == 0)
				{
				}
				ItemTier? val2 = val;
				if (val2.HasValue)
				{
					blacklistTiers.Add(val2.Value);
				}
			}
		}
	}
	[BepInPlugin("kina.EvilDropItem", "EvilDropItem", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class EvilDropItem : BaseUnityPlugin
	{
		private const string PluginGUID = "kina.EvilDropItem";

		private const string PluginAuthor = "kina";

		private const string PluginName = "EvilDropItem";

		private const string PluginVersion = "1.0.1";

		public static EvilDropItem instance;

		public static SkillDef primaryThrowItemDefOverride;

		public static GameObject projectilePrefab;

		public static GameObject arcVisualizerPrefab;

		public static GameObject endpointVisualizerPrefab;

		public static GameObject networkPrefab;

		private static bool UHRInstalled => Chainloader.PluginInfos.ContainsKey("iDeathHD.UnityHotReload");

		public void Awake()
		{
			//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)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			Log.Init(((BaseUnityPlugin)this).Logger);
			instance = this;
			Configs.LoadConfigs();
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_UI.ItemIcon_prefab);
			val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
			{
				handle.Result.AddComponent<ItemIconClicked>();
			};
			SetupProjectile();
			SetupSkillDef();
			bool flag = default(bool);
			ContentAddition.AddEntityState<ThrowItemSkillState>(ref flag);
			CheesePrevention.Hooks();
			NetworkingAPI.RegisterMessageType<RequestChefMessage>();
			NetworkingAPI.RegisterMessageType<SpawnChefTableMessage>();
			val = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Core.PlayerMaster_prefab);
			val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
			{
				UnityObjectExtensions.EnsureComponent<ItemThrowStorageNetworked>(handle.Result);
			};
		}

		private void SetupSkillDef()
		{
			//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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			primaryThrowItemDefOverride = ScriptableObject.CreateInstance<SkillDef>();
			primaryThrowItemDefOverride.icon = Addressables.LoadAssetAsync<Sprite>((object)RoR2_DLC3_Drifter.texDrifterSkillIcons_png_texDrifterSkillIcons_4_).WaitForCompletion();
			primaryThrowItemDefOverride.activationState = new SerializableEntityStateType(typeof(ThrowItemSkillState));
			primaryThrowItemDefOverride.activationStateMachineName = "Weapon";
			primaryThrowItemDefOverride.beginSkillCooldownOnSkillEnd = true;
			primaryThrowItemDefOverride.mustKeyPress = true;
			primaryThrowItemDefOverride.interruptPriority = (InterruptPriority)1;
			primaryThrowItemDefOverride.triggeredByPressRelease = true;
			primaryThrowItemDefOverride.dontAllowPastMaxStocks = false;
			primaryThrowItemDefOverride.beginSkillCooldownOnSkillEnd = true;
			primaryThrowItemDefOverride.skillNameToken = "Throw Item";
			primaryThrowItemDefOverride.skillDescriptionToken = "<style=cIsUtility>Throw your items</style> dealing <style=cIsDamage>more damage</style> based on the <style=cIsUtility>amount and quantity of items thrown</style>.";
			ContentAddition.AddSkillDef(primaryThrowItemDefOverride);
		}

		private void SetupProjectile()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			projectilePrefab = PrefabAPI.CreateEmptyPrefab("throwItemProjectile", true);
			ProjectileController val = projectilePrefab.AddComponent<ProjectileController>();
			val.authorityHandlesCollisionEvents = true;
			val.procCoefficient = 1f;
			val.CanBeParried = true;
			val.allowPrediction = false;
			GameObject val2 = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Common.Tier1Orb_prefab).WaitForCompletion(), "throwOrb", false);
			val2.AddComponent<ProjectileGhostController>();
			Object.Destroy((Object)(object)val2.GetComponent<Rigidbody>());
			val.ghostPrefab = val2;
			val.ghostPrefabAddress = null;
			ProjectileDamage val3 = projectilePrefab.AddComponent<ProjectileDamage>();
			val3.damageType = DamageTypeCombo.op_Implicit((DamageType)32);
			val3.damageType.damageSource = (DamageSource)1;
			ProjectileSimple val4 = projectilePrefab.AddComponent<ProjectileSimple>();
			val4.lifetime = 999999f;
			val4.desiredForwardSpeed = 50f;
			projectilePrefab.AddComponent<ThrowItemProjectileImpact>();
			projectilePrefab.AddComponent<ProjectileNetworkTransform>();
			SphereCollider val5 = projectilePrefab.AddComponent<SphereCollider>();
			val5.radius = 0.5f;
			Rigidbody val6 = projectilePrefab.AddComponent<Rigidbody>();
			val6.useGravity = true;
			val6.isKinematic = false;
			val6.interpolation = (RigidbodyInterpolation)1;
			val6.collisionDetectionMode = (CollisionDetectionMode)1;
			val6.mass = 1f;
			val6.drag = 0f;
			val6.angularDrag = 0.05f;
			ContentAddition.AddProjectile(projectilePrefab);
			AsyncOperationHandle<GameObject> val7 = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Common_VFX.BasicThrowableVisualizer_prefab);
			val7.Completed += delegate(AsyncOperationHandle<GameObject> handle)
			{
				arcVisualizerPrefab = handle.Result;
			};
			val7 = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Huntress.HuntressArrowRainIndicator_prefab);
			val7.Completed += delegate(AsyncOperationHandle<GameObject> handle)
			{
				endpointVisualizerPrefab = handle.Result;
			};
		}

		private void Update()
		{
			if (Input.GetKeyUp((KeyCode)288))
			{
				if (UHRInstalled)
				{
					Log.Debug("EvilDropItem.dll");
					UHRSupport.hotReload(typeof(EvilDropItem).Assembly, Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "EvilDropItem.dll"));
				}
				else
				{
					Log.Debug("couldnt finds unity hot reload !!");
				}
			}
		}
	}
	public class ItemIconClicked : MonoBehaviour, IPointerDownHandler, IEventSystemHandler
	{
		private ItemIcon itemIcon;

		private ItemIndex itemIndex;

		public void OnPointerDown(PointerEventData eventData)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			//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)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected I4, but got Unknown
			itemIcon = ((Component)this).GetComponent<ItemIcon>();
			if (Object.op_Implicit((Object)(object)itemIcon))
			{
				itemIndex = itemIcon.itemIndex;
			}
			if ((int)itemIndex == -1)
			{
				return;
			}
			Log.Debug("cliked on " + ItemCatalog.GetItemDef(itemIndex).nameToken + " ");
			Transform parent = ((Component)this).transform.GetParent();
			CharacterBody val = ((parent == null) ? null : ((Component)parent).gameObject.GetComponent<ItemInventoryDisplay>()?._characterBody);
			if (Object.op_Implicit((Object)(object)val) && val.inventory.GetItemCountPermanent(itemIndex) > 0)
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				CharacterBody val2 = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
				if (Object.op_Implicit((Object)(object)val2) && (Object)(object)val2 == (Object)(object)val)
				{
					NetMessageExtensions.Send((INetMessage)(object)new RequestChefMessage(val.networkIdentity, (int)itemIndex), (NetworkDestination)2);
				}
			}
		}
	}
	public class RequestChefMessage : INetMessage, ISerializableObject
	{
		private NetworkIdentity playerNetID;

		private int itemIndex;

		public RequestChefMessage()
		{
		}

		public RequestChefMessage(NetworkIdentity netID, int itemIndex)
		{
			playerNetID = netID;
			this.itemIndex = itemIndex;
		}

		public void Deserialize(NetworkReader reader)
		{
			playerNetID = reader.ReadNetworkIdentity();
			itemIndex = reader.ReadInt32();
		}

		public void OnReceived()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected I4, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			CharacterBody component = ((Component)playerNetID).GetComponent<CharacterBody>();
			ItemIndex val = (ItemIndex)itemIndex;
			ItemDef itemDef = ItemCatalog.GetItemDef(val);
			if (Configs.blacklistTiers.Contains(itemDef.tier))
			{
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "<style=cWorldEvent>you cant <style=cIsHealth>throw that one</style>,,.,.. <style=cIsUtility>idot</style> ,..,</style>"
				});
			}
			else
			{
				ItemThrowStorageNetworked component2 = ((Component)component.master).gameObject.GetComponent<ItemThrowStorageNetworked>();
				((SyncList<int>)(object)component2.itemIndexes).Add((int)val);
				component.inventory.RemoveItemPermanent(val, 1);
			}
		}

		public void Serialize(NetworkWriter writer)
		{
			writer.Write(playerNetID);
			writer.Write(itemIndex);
		}
	}
	public class SpawnChefTableMessage : INetMessage, ISerializableObject
	{
		private NetworkIdentity playerNetID;

		public SpawnChefTableMessage()
		{
		}

		public SpawnChefTableMessage(NetworkIdentity playerNetID)
		{
			this.playerNetID = playerNetID;
		}

		public void Deserialize(NetworkReader reader)
		{
			playerNetID = reader.ReadNetworkIdentity();
		}

		public void OnReceived()
		{
			Log.Debug("SpawnChefTableMessage Called...");
			CharacterBody component = ((Component)playerNetID).GetComponent<CharacterBody>();
			ItemThrowStorageNetworked component2 = ((Component)component.master).gameObject.GetComponent<ItemThrowStorageNetworked>();
			if ((Object)(object)component.skillLocator.primary.skillDef != (Object)(object)EvilDropItem.primaryThrowItemDefOverride)
			{
				component.skillLocator.primary.SetSkillOverride((object)null, EvilDropItem.primaryThrowItemDefOverride, (SkillOverridePriority)4);
			}
			component.skillLocator.primary.maxStock = ((SyncList<int>)(object)component2.itemIndexes).Count;
			component.skillLocator.primary.baseStock = ((SyncList<int>)(object)component2.itemIndexes).Count;
			component.skillLocator.primary.stock = ((SyncList<int>)(object)component2.itemIndexes).Count;
			component.skillLocator.primary.skillDef.baseMaxStock = ((SyncList<int>)(object)component2.itemIndexes).Count;
		}

		public void Serialize(NetworkWriter writer)
		{
			writer.Write(playerNetID);
		}
	}
	public class ItemThrowStorageNetworked : NetworkBehaviour
	{
		public SyncListInt itemIndexes = new SyncListInt();

		private static int kListitemIndexes;

		public override void OnStartClient()
		{
			SyncListInt obj = itemIndexes;
			((SyncList<int>)(object)obj).Callback = (SyncListChanged<int>)(object)Delegate.Combine((Delegate?)(object)((SyncList<int>)(object)obj).Callback, (Delegate?)(object)new SyncListChanged<int>(SyncListIntChanged));
		}

		public void OnEnable()
		{
			((Component)this).GetComponent<CharacterMaster>().onBodyStart += delegate
			{
				SyncListIntChanged((Operation<int>)0, -1);
			};
		}

		private void SyncListIntChanged(Operation<int> op, int itemindex)
		{
			CharacterBody body = ((Component)this).GetComponent<CharacterMaster>().GetBody();
			ItemThrowStorageNetworked component = ((Component)body.master).gameObject.GetComponent<ItemThrowStorageNetworked>();
			if ((Object)(object)body.skillLocator.primary.skillDef != (Object)(object)EvilDropItem.primaryThrowItemDefOverride && ((SyncList<int>)(object)component.itemIndexes).Count > 0)
			{
				body.skillLocator.primary.SetSkillOverride((object)this, EvilDropItem.primaryThrowItemDefOverride, (SkillOverridePriority)4);
			}
			else if (((SyncList<int>)(object)component.itemIndexes).Count == 0)
			{
				body.skillLocator.primary.UnsetSkillOverride((object)this, EvilDropItem.primaryThrowItemDefOverride, (SkillOverridePriority)4);
				return;
			}
			body.skillLocator.primary.maxStock = ((SyncList<int>)(object)component.itemIndexes).Count;
			body.skillLocator.primary.baseStock = ((SyncList<int>)(object)component.itemIndexes).Count;
			body.skillLocator.primary.stock = ((SyncList<int>)(object)component.itemIndexes).Count;
			body.skillLocator.primary.skillDef.baseMaxStock = ((SyncList<int>)(object)component.itemIndexes).Count;
		}

		private void UNetVersion()
		{
		}

		protected static void InvokeSyncListitemIndexes(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"SyncList itemIndexes called on server.");
			}
			else
			{
				((SyncList<int>)(object)((ItemThrowStorageNetworked)(object)obj).itemIndexes).HandleMsg(reader);
			}
		}

		static ItemThrowStorageNetworked()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			kListitemIndexes = 1255898086;
			NetworkBehaviour.RegisterSyncListDelegate(typeof(ItemThrowStorageNetworked), kListitemIndexes, new CmdDelegate(InvokeSyncListitemIndexes));
			NetworkCRC.RegisterBehaviour("ItemThrowStorageNetworked", 0);
		}

		private void Awake()
		{
			((SyncList<int>)(object)itemIndexes).InitializeBehaviour((NetworkBehaviour)(object)this, kListitemIndexes);
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			if (forceAll)
			{
				SyncListInt.WriteInstance(writer, itemIndexes);
				return true;
			}
			bool flag = false;
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 1) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				SyncListInt.WriteInstance(writer, itemIndexes);
			}
			if (!flag)
			{
				writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
			}
			return flag;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			if (initialState)
			{
				SyncListInt.ReadReference(reader, itemIndexes);
				return;
			}
			int num = (int)reader.ReadPackedUInt32();
			if ((num & 1) != 0)
			{
				SyncListInt.ReadReference(reader, itemIndexes);
			}
		}
	}
	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);
		}
	}
	public class ThrowItemProjectileImpact : MonoBehaviour, IProjectileImpactBehavior
	{
		private bool checkedFirstUpdate;

		private CharacterMaster ownerMaster;

		private ProjectileDamage projectileDamage;

		private ProjectileController projectileController;

		private List<int> itemIndexes = new List<int>();

		public void FixedUpdate()
		{
			if (checkedFirstUpdate)
			{
				return;
			}
			checkedFirstUpdate = true;
			if (!NetworkServer.active)
			{
				return;
			}
			projectileDamage = ((Component)this).gameObject.GetComponent<ProjectileDamage>();
			projectileController = ((Component)this).gameObject.GetComponent<ProjectileController>();
			ProjectileController component = ((Component)this).gameObject.GetComponent<ProjectileController>();
			object obj;
			if (component == null)
			{
				obj = null;
			}
			else
			{
				GameObject owner = component.owner;
				if (owner == null)
				{
					obj = null;
				}
				else
				{
					CharacterBody component2 = owner.GetComponent<CharacterBody>();
					obj = ((component2 != null) ? component2.master : null);
				}
			}
			ownerMaster = (CharacterMaster)obj;
			CharacterMaster obj2 = ownerMaster;
			ItemThrowStorageNetworked itemThrowStorageNetworked = ((obj2 != null) ? ((Component)obj2).GetComponent<ItemThrowStorageNetworked>() : null);
			Log.Debug("trying to set master storage, ., ");
			if (Object.op_Implicit((Object)(object)itemThrowStorageNetworked))
			{
				int[] array = ((IEnumerable<int>)itemThrowStorageNetworked.itemIndexes).ToArray();
				foreach (int num in array)
				{
					itemIndexes.Add(num);
					((SyncList<int>)(object)itemThrowStorageNetworked.itemIndexes).Remove(num);
				}
			}
		}

		public void OnEnable()
		{
			checkedFirstUpdate = false;
		}

		public void OnProjectileImpact(ProjectileImpactInfo impactInfo)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00e7: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_0174: Expected I4, but got Unknown
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: 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_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_037a: 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_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Expected O, but got Unknown
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: 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_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || itemIndexes.Count == 0)
			{
				return;
			}
			Log.Debug("impact ,., spawning new ,.., ., " + itemIndexes.Count);
			float num = 360f / (float)itemIndexes.Count;
			Vector3 val = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up) * (Vector3.up * 20f + Vector3.forward * 5f);
			Quaternion val2 = Quaternion.AngleAxis(num, Vector3.up);
			if (itemIndexes.Count == 1)
			{
				val = Quaternion.AngleAxis(0f, Vector3.up) * (Vector3.up * 20f);
				val2 = Quaternion.AngleAxis(0f, Vector3.up);
			}
			float num2 = 0f;
			foreach (int itemIndex in itemIndexes)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef((ItemIndex)itemIndex);
				float num3 = num2;
				ItemTier tier = itemDef.tier;
				if (1 == 0)
				{
				}
				float num4 = (int)tier switch
				{
					0 => 2f, 
					6 => 2f, 
					1 => 5f, 
					7 => 5f, 
					2 => 7f, 
					8 => 7f, 
					4 => 10f, 
					9 => 10f, 
					11 => 10f, 
					10 => 10f, 
					3 => 3f, 
					5 => 0f, 
					12 => 5f, 
					13 => 0f, 
					_ => 5f, 
				};
				if (1 == 0)
				{
				}
				num2 = num3 + num4;
				CreatePickupInfo val3 = default(CreatePickupInfo);
				((CreatePickupInfo)(ref val3)).pickup = new UniquePickup
				{
					pickupIndex = PickupCatalog.FindPickupIndex((ItemIndex)itemIndex),
					decayValue = 0f
				};
				val3.artifactFlag = (PickupArtifactFlag)(-1225);
				val3.duplicated = true;
				val3.recycled = true;
				CreatePickupInfo pickupInfo = val3;
				Vector3 estimatedPointOfImpact = impactInfo.estimatedPointOfImpact;
				estimatedPointOfImpact.y = impactInfo.estimatedPointOfImpact.y + 1f;
				CreatePickupDropletCopied(pickupInfo, estimatedPointOfImpact, val);
				val = val2 * val;
			}
			itemIndexes = new List<int>();
			BlastAttack val4 = new BlastAttack
			{
				baseDamage = projectileDamage.damage * num2 / 3f,
				baseForce = 40f + num2 * 100f,
				radius = 4f,
				teamIndex = (TeamIndex)(-1),
				damageColorIndex = (DamageColorIndex)3,
				falloffModel = (FalloffModel)0,
				crit = projectileDamage.crit,
				attacker = (Object.op_Implicit((Object)(object)projectileController.owner) ? projectileController.owner.gameObject : null),
				inflictor = ((Component)this).gameObject,
				position = impactInfo.estimatedPointOfImpact,
				procChainMask = projectileController.procChainMask,
				procCoefficient = projectileController.procCoefficient,
				damageType = DamageTypeCombo.op_Implicit((DamageType)32)
			};
			val4.Fire();
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		public static void CreatePickupDropletCopied(CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(PickupDropletController.pickupDropletPrefab, position, Quaternion.identity);
			PickupDropletController component = val.GetComponent<PickupDropletController>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.createPickupInfo = pickupInfo;
				component.NetworkpickupState = ((CreatePickupInfo)(ref pickupInfo)).pickup;
			}
			Rigidbody component2 = val.GetComponent<Rigidbody>();
			component2.velocity = velocity;
			component2.AddTorque(Random.Range(150f, 120f) * Random.onUnitSphere);
			NetworkServer.Spawn(val);
		}
	}
	public class ThrowItemSkillState : AimThrowableBase
	{
		public override void OnEnter()
		{
			((AimThrowableBaseAimOnly)this).maxDistance = 50f;
			((AimThrowableBaseAimOnly)this).rayRadius = 0f;
			((AimThrowableBaseAimOnly)this).arcVisualizerPrefab = EvilDropItem.arcVisualizerPrefab;
			((AimThrowableBaseAimOnly)this).projectilePrefab = EvilDropItem.projectilePrefab;
			((AimThrowableBaseAimOnly)this).endpointVisualizerPrefab = EvilDropItem.endpointVisualizerPrefab;
			((AimThrowableBaseAimOnly)this).endpointVisualizerRadiusScale = 4f;
			base.damageCoefficient = 1f;
			((AimThrowableBaseAimOnly)this).OnEnter();
		}

		public override void OnExit()
		{
			((AimThrowableBase)this).OnExit();
			((EntityState)this).skillLocator.primary.UnsetSkillOverride((object)null, EvilDropItem.primaryThrowItemDefOverride, (SkillOverridePriority)4);
		}
	}
	internal static class UHRSupport
	{
		internal static void hotReload(Assembly assembly, string path)
		{
			UnityHotReload.LoadNewAssemblyVersion(assembly, path);
		}
	}
	public static class Utils
	{
		public static void SliderConfig(float min, float max, ConfigEntry<float> config)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			StepSliderConfig val = new StepSliderConfig
			{
				max = max,
				min = min,
				FormatString = "{0:0}"
			};
			StepSliderOption val2 = new StepSliderOption(config, val);
			ModSettingsManager.AddOption((BaseOption)(object)val2);
		}

		public static void SliderConfig(int min, int max, ConfigEntry<int> config)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			IntSliderConfig val = new IntSliderConfig
			{
				max = max,
				min = min,
				formatString = "{0:0}"
			};
			IntSliderOption val2 = new IntSliderOption(config, val);
			ModSettingsManager.AddOption((BaseOption)(object)val2);
		}

		public static void CheckboxConfig(ConfigEntry<bool> config, bool restartRequired = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			CheckBoxConfig val = new CheckBoxConfig();
			((BaseOptionConfig)val).restartRequired = restartRequired;
			CheckBoxOption val2 = new CheckBoxOption(config, val);
			ModSettingsManager.AddOption((BaseOption)(object)val2);
		}

		public static void StringConfig(ConfigEntry<string> config)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			InputFieldConfig val = new InputFieldConfig();
			StringInputFieldOption val2 = new StringInputFieldOption(config, val);
			ModSettingsManager.AddOption((BaseOption)(object)val2);
		}

		public static void KeyboardConfig(ConfigEntry<KeyboardShortcut> config)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			KeyBindConfig val = new KeyBindConfig();
			KeyBindOption val2 = new KeyBindOption(config, val);
			ModSettingsManager.AddOption((BaseOption)(object)val2);
		}
	}
}