Decompiled source of Unique Potions v0.6.3

UniquePotions.dll

Decompiled 19 hours ago
using System;
using System.Collections;
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.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOAlchemy;
using REPOLib.Modules;
using UniquePotions.Potions;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("UniquePotions")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UniquePotions")]
[assembly: AssemblyTitle("UniquePotions")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 UniquePotions
{
	internal class AOEIndicator : MonoBehaviour
	{
		public static GameObject prefab;

		public float radius;

		public Material material;

		public float duration;

		public float fadeTime;

		private float timeAlive = 0f;

		public float spinVel;

		public static void CreateAOE(Material material, float rad, Vector3 pos, float dur = 0.5f, float spin = 50f, float fade = 0.5f)
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			AOEIndicator component = Object.Instantiate<GameObject>(prefab, pos, Quaternion.identity).GetComponent<AOEIndicator>();
			component.radius = rad;
			((Renderer)((Component)component).GetComponent<MeshRenderer>()).material = material;
			((Component)component).transform.localScale = Vector3.zero;
			component.material = material;
			component.duration = dur;
			component.fadeTime = fade;
			component.spinVel = spin;
		}

		private void Update()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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)
			if (timeAlive > duration)
			{
				material.SetFloat("_Opacity", material.GetFloat("_Opacity") - Time.deltaTime / fadeTime);
				if (timeAlive > duration + fadeTime)
				{
					material.SetFloat("_Opacity", 1f);
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
			float deltaTime = Time.deltaTime;
			float x = ((Component)this).transform.localScale.x;
			timeAlive += deltaTime;
			x += (radius - x) * deltaTime * 10f;
			((Component)this).transform.localScale = Vector3.one * x;
			((Component)this).transform.Rotate(new Vector3(0f, spinVel * deltaTime, 0f));
		}
	}
	internal class GravityField : MonoBehaviour
	{
		internal List<PhysGrabObject> objectAffected = new List<PhysGrabObject>();

		private bool localPlayerAffected = false;

		private float fieldRadius = 6f;

		private PhysGrabObject physGrabObject;

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			((Component)this).transform.localScale = Vector3.zero;
		}

		private void Update()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_006d: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			float x = ((Component)this).transform.localScale.x;
			x += (1f - x) * Time.deltaTime * 2f;
			((Component)this).transform.localScale = Vector3.one * x;
			localPlayerAffected = SemiFunc.LocalPlayerOverlapCheck(fieldRadius * x, ((Component)this).transform.position, false);
			objectAffected = SemiFunc.PhysGrabObjectGetAllWithinRange(fieldRadius * x, ((Component)this).transform.position, false, default(LayerMask), (PhysGrabObject)null);
			if (localPlayerAffected)
			{
				PlayerController.instance.AntiGravity(0.1f);
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			foreach (PhysGrabObject item in objectAffected)
			{
				if (Object.op_Implicit((Object)(object)item) && (Object)(object)physGrabObject != (Object)(object)item)
				{
					item.OverrideDrag(0.5f, 0.1f);
					item.OverrideAngularDrag(0.5f, 0.1f);
					item.OverrideZeroGravity(0.1f);
				}
			}
		}
	}
	[BepInPlugin("UniquePotions", "UniquePotions", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("REPO.exe")]
	public class Plugin : BaseUnityPlugin
	{
		public struct PotionConfigs
		{
			public string category;

			public ConfigEntry<bool> spawnGeneric;

			public ConfigEntry<bool> spawnWizard;

			public ConfigEntry<bool> spawnManor;

			public ConfigEntry<bool> spawnArctic;

			public ConfigEntry<bool> craftable;

			public PotionConfigs(string category, bool enabled = true)
			{
				ConfigFile config = ((BaseUnityPlugin)instance).Config;
				this.category = category;
				craftable = config.Bind<bool>(category, "Craftable", true, "Should this potion be craftable");
				spawnGeneric = config.Bind<bool>(category, "Spawn in all maps", enabled, "Should this potion spawn in all maps");
				spawnWizard = config.Bind<bool>(category, "Spawn in Wizard", enabled, "Should this potion spawn in Swiftbroom Academy");
				spawnManor = config.Bind<bool>(category, "Spawn in Manor", enabled, "Should this potion spawn in Headman Manor");
				spawnArctic = config.Bind<bool>(category, "Spawn in Arctic", enabled, "Should this potion spawn in McJannek Station");
			}

			public List<string> GetMaps()
			{
				List<string> list = new List<string>();
				if (spawnGeneric.Value)
				{
					list.Add("Valuables - Generic");
				}
				if (spawnWizard.Value)
				{
					list.Add("Valuables - Wizard");
				}
				if (spawnManor.Value)
				{
					list.Add("Valuables - Manor");
				}
				if (spawnArctic.Value)
				{
					list.Add("Valuables - Arctic");
				}
				return list;
			}
		}

		public struct ElixirConfigs
		{
			public string category;

			public ConfigEntry<bool> enabled;

			public ConfigEntry<bool> craftable;

			public ConfigEntry<bool> refill;

			public ElixirConfigs(string category, bool refill = true)
			{
				ConfigFile config = ((BaseUnityPlugin)instance).Config;
				this.category = category;
				enabled = config.Bind<bool>(category, "Purchaseable", true, "Should this elixir be purchaseable");
				craftable = config.Bind<bool>(category, "Craftable", true, "Should this elixir be craftable");
				this.refill = config.Bind<bool>(category, "Refill between levels", refill, "Should this elixir respawn and refill between levels");
			}
		}

		public struct IngredientConfigs
		{
			public string category;

			public ConfigEntry<bool> enabled;

			public IngredientConfigs(string category)
			{
				ConfigFile config = ((BaseUnityPlugin)instance).Config;
				this.category = category;
				enabled = config.Bind<bool>("Ingredient " + category, "Enabled", true, "Should this ingredient spawn");
			}
		}

		public static Plugin instance;

		public static PotionConfigs gravityPotionConfigs;

		public static PotionConfigs goldPotionConfigs;

		public static ConfigEntry<float> goldPotionMultiplier;

		public static PotionConfigs healthPotionConfigs;

		public static ConfigEntry<int> healthPotionHealing;

		public static ConfigEntry<int> healthPotionHealingSolo;

		public static ConfigEntry<float> healthPotionHealingValuable;

		public static PotionConfigs unstablePotionConfigs;

		public static PotionConfigs portalPotionConfigs;

		public static PotionConfigs phoenixPotionConfigs;

		public static PotionConfigs singularityPotionConfigs;

		public static ElixirConfigs staminaElixirConfigs;

		public static ElixirConfigs rocketElixirConfigs;

		public static ConfigEntry<int> rocketElixirPlayerDamage;

		public static ConfigEntry<int> rocketElixirEnemyDamage;

		private Harmony harmony = new Harmony("UniquePotions");

		private AssetBundle assetBundle;

		public static Value ingredientValue;

		private void Awake()
		{
			instance = this;
			SetUpConfigs();
			assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "uniquepotions"));
			SetUpPrefabs();
			LoadGravityPotion();
			LoadGoldPotion();
			LoadHealthPotion();
			LoadUnstablePotion();
			LoadPhoenixPotion();
			LoadPortalPotion();
			LoadSingularityPotion();
			LoadStaminaElixir();
			LoadRocketElixir();
			LoadIngredients();
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin UniquePotions is loaded!");
		}

		private T LoadPotion<T>(string path, PotionConfigs configs, List<string> recipe, string iconPath, Color color) where T : AlchemyItem
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = assetBundle.LoadAsset<GameObject>(path);
			T val2 = val.AddComponent<T>();
			((AlchemyItem)val2).color = color;
			((AlchemyItem)val2).icon = assetBundle.LoadAsset<Sprite>(iconPath);
			if (configs.GetMaps().Count > 0)
			{
				Valuables.RegisterValuable(val, configs.GetMaps());
			}
			if (configs.craftable.Value)
			{
				Tools.RegisterRecipe(recipe, (AlchemyItem)(object)val2);
			}
			return val2;
		}

		private void SetUpConfigs()
		{
			gravityPotionConfigs = new PotionConfigs("Gravity Potion");
			goldPotionConfigs = new PotionConfigs("Gold Potion");
			goldPotionMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Gold Potion", "Money Multiplier", 1.2f, "How much the gold potion should multiply the price of valuables by");
			healthPotionConfigs = new PotionConfigs("Health Potion");
			healthPotionHealing = ((BaseUnityPlugin)this).Config.Bind<int>("Health Potion", "Healing Multiplayer", 20, "How much health the health potion should give players in multiplayer");
			healthPotionHealingSolo = ((BaseUnityPlugin)this).Config.Bind<int>("Health Potion", "Healing Solo", 40, "How much health the health potion should give the player in singleplayer");
			healthPotionHealingValuable = ((BaseUnityPlugin)this).Config.Bind<float>("Health Potion", "Healing Valuables", 0.1f, "Percent of value the health potion should restore on damaged valuables");
			unstablePotionConfigs = new PotionConfigs("Unstable Potion");
			phoenixPotionConfigs = new PotionConfigs("Resurrection Potion");
			portalPotionConfigs = new PotionConfigs("Portal Potions", enabled: false);
			singularityPotionConfigs = new PotionConfigs("Singularity Potion");
			staminaElixirConfigs = new ElixirConfigs("Stamina Elixir");
			rocketElixirConfigs = new ElixirConfigs("Rocket Elixir", refill: false);
			rocketElixirPlayerDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Rocket Elixir", "Player Damage", 75, "How much damage the rocket elixir should do to players");
			rocketElixirEnemyDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Rocket Elixir", "Enemy Damage", 160, "How much damage the rocket elixir should do to enemies");
		}

		private List<string> GetMap(int map)
		{
			return map switch
			{
				1 => new List<string> { "Valuables - Wizard" }, 
				2 => new List<string> { "Valuables - Manor" }, 
				3 => new List<string> { "Valuables - Arctic" }, 
				_ => new List<string> { "Valuables - Generic" }, 
			};
		}

		private void SetUpPrefabs()
		{
			GameObject val = assetBundle.LoadAsset<GameObject>("Assets/Mods/UniquePotions/Effects/AOEIndicator.prefab");
			val.AddComponent<AOEIndicator>();
			AOEIndicator.prefab = val;
		}

		private void LoadGravityPotion()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			GravityPotion.instance = LoadPotion<GravityPotion>("Assets/Mods/UniquePotions/Potions/GravityPotion/GravityPotion.prefab", gravityPotionConfigs, new List<string> { "Void", "Metal" }, "Assets/Mods/UniquePotions/Potions/GravityPotion/GravityPotion.png", new Color(0.41f, 0.64f, 1f));
			GameObject val = assetBundle.LoadAsset<GameObject>("Assets/Mods/UniquePotions/Potions/GravityPotion/GravityField.prefab");
			val.AddComponent<GravityField>();
			GravityPotion.gravityFieldPrefab = val;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Gravity Potion Loaded!");
		}

		private void LoadGoldPotion()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			GoldPotion.instance = LoadPotion<GoldPotion>("Assets/Mods/UniquePotions/Potions/GoldPotion/GoldPotion.prefab", goldPotionConfigs, new List<string> { "Metal", "Metal" }, "Assets/Mods/UniquePotions/Potions/GoldPotion/GoldPotion.png", new Color(0.75f, 0.42f, 0.13f));
			GoldPotion.effectMaterial = assetBundle.LoadAsset<Material>("Assets/Mods/UniquePotions/Potions/GoldPotion/AOEIndicator.mat");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Gold Potion Loaded!");
		}

		private void LoadHealthPotion()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			HealthPotion.instance = LoadPotion<HealthPotion>("Assets/Mods/UniquePotions/Potions/HealthPotion/HealthPotion.prefab", healthPotionConfigs, new List<string> { "Cookie", "Heart" }, "Assets/Mods/UniquePotions/Potions/HealthPotion/HealthPotion.png", new Color(0.46f, 1f, 0.44f));
			HealthPotion.effectMaterial = assetBundle.LoadAsset<Material>("Assets/Mods/UniquePotions/Potions/HealthPotion/AOEIndicator.mat");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Health Potion Loaded!");
		}

		private void LoadUnstablePotion()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			UnstablePotion.instance = LoadPotion<UnstablePotion>("Assets/Mods/UniquePotions/Potions/UnstablePotion/UnstablePotion.prefab", unstablePotionConfigs, new List<string> { "Heart", "Metal" }, "Assets/Mods/UniquePotions/Potions/UnstablePotion/UnstablePotion.png", new Color(1f, 0.41f, 0.43f));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Unstable Potion Loaded!");
		}

		private void LoadPhoenixPotion()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			PhoenixPotion.instance = LoadPotion<PhoenixPotion>("Assets/Mods/UniquePotions/Potions/PhoenixPotion/PhoenixPotion.prefab", phoenixPotionConfigs, new List<string> { "Cookie", "Cookie" }, "Assets/Mods/UniquePotions/Potions/PhoenixPotion/PhoenixPotion.png", new Color(1f, 0.41f, 0.43f));
			PhoenixPotion.effectMaterial = assetBundle.LoadAsset<Material>("Assets/Mods/UniquePotions/Potions/PhoenixPotion/AOEIndicator.mat");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Phoenix Potion Loaded!");
		}

		private void LoadPortalPotion()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			PortalPotion.instance = LoadPotion<PortalPotion>("Assets/Mods/UniquePotions/Potions/PortalPotion/PortalPotion.prefab", portalPotionConfigs, new List<string> { "Void", "Void" }, "Assets/Mods/UniquePotions/Potions/PortalPotion/PortalPotion.png", new Color(0.77f, 0.19f, 1f));
			NetworkPrefabs.RegisterNetworkPrefab(PortalPotion.portalPrefab = assetBundle.LoadAsset<GameObject>("Assets/Mods/UniquePotions/Potions/PortalPotion/Portal.prefab"));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Portal Potions Loaded!");
		}

		private void LoadSingularityPotion()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			SingularityPotion.instance = LoadPotion<SingularityPotion>("Assets/Mods/UniquePotions/Potions/SingularityPotion/SingularityPotion.prefab", singularityPotionConfigs, new List<string> { "Void", "Heart" }, "Assets/Mods/UniquePotions/Potions/SingularityPotion/SingularityPotion.png", new Color(1f, 1f, 1f));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Singularity Potion Loaded!");
		}

		private void LoadIngredients()
		{
			ingredientValue = assetBundle.LoadAsset<Value>("Assets/Mods/UniquePotions/Ingredients/Value - Ingredient.asset");
			LoadIngredient("Cookie", "Assets/Mods/UniquePotions/Ingredients/Cookie.prefab");
			LoadIngredient("Heart", "Assets/Mods/UniquePotions/Ingredients/Heart.prefab");
			LoadIngredient("Void", "Assets/Mods/UniquePotions/Ingredients/VoidJuice.prefab");
			LoadIngredient("Metal", "Assets/Mods/UniquePotions/Ingredients/Metal.prefab");
		}

		private GameObject LoadIngredient(string id, string path)
		{
			IngredientConfigs ingredientConfigs = new IngredientConfigs(id);
			GameObject val = assetBundle.LoadAsset<GameObject>(path);
			Ingredient val2 = val.AddComponent<Ingredient>();
			val2.ingredientID = id;
			Tools.RegisterIngredient(val2, ingredientConfigs.enabled.Value);
			return val;
		}

		private T LoadElixir<T>(string path, ElixirConfigs configs, List<string> recipe, string iconPath, Color color) where T : AlchemyItem
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = assetBundle.LoadAsset<GameObject>(path);
			T val2 = val.AddComponent<T>();
			((AlchemyItem)val2).color = color;
			((AlchemyItem)val2).icon = assetBundle.LoadAsset<Sprite>(iconPath);
			Item item = val.GetComponent<ItemAttributes>().item;
			item.prefab = val;
			if (configs.enabled.Value)
			{
				Items.RegisterItem(item);
				((AlchemyItem)val2).prefabID = ResourcesHelper.GetItemPrefabPath(item);
			}
			if (configs.craftable.Value)
			{
				Tools.RegisterRecipe(recipe, (AlchemyItem)(object)val2);
			}
			return val2;
		}

		private void LoadStaminaElixir()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			StaminaElixir.instance = LoadElixir<StaminaElixir>("Assets/Mods/UniquePotions/Elixirs/StaminaElixir/StaminaElixir.prefab", staminaElixirConfigs, new List<string> { "Cookie", "Metal" }, "Assets/Mods/UniquePotions/Elixirs/StaminaElixir/StaminaElixir.png", new Color(1f, 0.75f, 0.29f));
			ItemMine val = ((Component)StaminaElixir.instance).gameObject.AddComponent<ItemMine>();
			val.lightArmed = ((Component)StaminaElixir.instance).GetComponent<Light>();
			val.meshRenderer = ((Component)StaminaElixir.instance).GetComponent<MeshRenderer>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Stamina Elixir Loaded!");
		}

		private void LoadRocketElixir()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			RocketElixir.instance = LoadElixir<RocketElixir>("Assets/Mods/UniquePotions/Elixirs/RocketElixir/RocketElixir.prefab", rocketElixirConfigs, new List<string> { "Heart", "Heart" }, "Assets/Mods/UniquePotions/Elixirs/RocketElixir/RocketElixir.png", new Color(1f, 0.41f, 0.43f));
			ItemMine val = ((Component)RocketElixir.instance).gameObject.AddComponent<ItemMine>();
			val.lightArmed = ((Component)RocketElixir.instance).GetComponent<Light>();
			val.meshRenderer = ((Component)RocketElixir.instance).GetComponent<MeshRenderer>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Rocket Elixir Loaded!");
		}
	}
	internal class Portal : MonoBehaviour
	{
		public Portal pairedPortal;

		public Portal mainPortal;

		public bool isMainPortal = false;

		private float radius = 0.75f;

		private const float duration = 30f;

		private float timeAlive = 0f;

		private List<PhysGrabObject> objects = new List<PhysGrabObject>();

		private void Start()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject, 30f);
		}

		private void Update()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if ((Object)(object)pairedPortal == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			List<PhysGrabObject> list = SemiFunc.PhysGrabObjectGetAllWithinRange(radius, ((Component)this).transform.position, false, default(LayerMask), (PhysGrabObject)null);
			foreach (PhysGrabObject item in list)
			{
				if (CanTeleport(item))
				{
					TeleportObject(item);
				}
			}
			foreach (PhysGrabObject item2 in SemiFunc.PhysGrabObjectGetAllWithinRange(radius, ((Component)pairedPortal).transform.position, false, default(LayerMask), (PhysGrabObject)null))
			{
				list.Add(item2);
			}
			List<PhysGrabObject> list2 = new List<PhysGrabObject>(mainPortal.objects);
			foreach (PhysGrabObject @object in mainPortal.objects)
			{
				if (!Enumerable.Contains(list, @object))
				{
					list2.Remove(@object);
				}
			}
		}

		public bool CanTeleport(PhysGrabObject obj)
		{
			return !Enumerable.Contains(mainPortal.objects, obj);
		}

		private void TeleportObject(PhysGrabObject obj)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			mainPortal.objects.Add(obj);
			obj.Teleport(((Component)pairedPortal).transform.position, ((Component)obj).transform.rotation);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "UniquePotions";

		public const string PLUGIN_NAME = "UniquePotions";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace UniquePotions.Potions
{
	internal class BattlePotion : AlchemyItem
	{
		public static ValuableObject valuableInstance;

		public static BattlePotion instance;

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((Component)this).GetComponent<PhysGrabObjectImpactDetector>().onDestroy.AddListener(new UnityAction(CallEnemies));
		}

		private void CallEnemies()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			SemiFunc.EnemyInvestigate(((Component)this).transform.position, 9999f);
		}
	}
	internal class GoldPotion : AlchemyItem
	{
		public static ValuableObject valuableInstance;

		public static GoldPotion instance;

		private ParticleSystem smoke;

		private ParticleSystem fire;

		private AudioSource fuse;

		private ItemToggle toggle;

		public float splashRadius = 3f;

		public static Material effectMaterial;

		private bool activated = false;

		private float fuseDuration = 2f;

		private float fuseTime = 0f;

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((Component)this).GetComponent<PhysGrabObjectImpactDetector>().onDestroy.AddListener(new UnityAction(ApplyBuff));
			smoke = ((Component)((Component)this).transform.Find("Smoke Particles")).GetComponent<ParticleSystem>();
			fire = ((Component)((Component)this).transform.Find("Fire Particles")).GetComponent<ParticleSystem>();
			fuse = ((Component)((Component)this).transform.Find("Fuse Audio")).GetComponent<AudioSource>();
			toggle = ((Component)this).GetComponent<ItemToggle>();
			((Component)fire).gameObject.SetActive(false);
			((Component)smoke).gameObject.SetActive(false);
		}

		private void ApplyBuff()
		{
			//IL_0018: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			AOEIndicator.CreateAOE(effectMaterial, splashRadius * 2f, ((Component)this).transform.position);
			List<PhysGrabObject> list = SemiFunc.PhysGrabObjectGetAllWithinRange(splashRadius, ((Component)this).transform.position, false, default(LayerMask), (PhysGrabObject)null);
			List<ValuableObject> list2 = new List<ValuableObject>();
			foreach (PhysGrabObject item in list)
			{
				ValuableObject component = ((Component)item).GetComponent<ValuableObject>();
				if (!((Object)(object)component == (Object)null) && !Enumerable.Contains(list2, component))
				{
					component.dollarValueCurrent = Mathf.Floor(component.dollarValueCurrent * Plugin.goldPotionMultiplier.Value);
					list2.Add(component);
				}
			}
		}

		private void Update()
		{
			if (toggle.toggleState)
			{
				if (!activated)
				{
					((Component)fuse).GetComponent<AudioSource>().Play();
					((Component)fire).gameObject.SetActive(true);
					((Component)smoke).gameObject.SetActive(true);
				}
				activated = true;
			}
			if (activated)
			{
				fuseTime += Time.deltaTime;
				if (fuseTime >= fuseDuration)
				{
					((Component)this).GetComponent<PhysGrabObjectImpactDetector>().DestroyObject(true);
				}
			}
		}
	}
	internal class GravityPotion : AlchemyItem
	{
		public static ValuableObject valuableInstance;

		public static GravityPotion instance;

		public static GameObject gravityFieldPrefab;

		private void Start()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			PhysGrabObjectImpactDetector component = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			component.onDestroy.AddListener(new UnityAction(CreateGravityField));
		}

		private void Update()
		{
			((Component)this).GetComponent<Rigidbody>().useGravity = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>().inCart;
		}

		public void CreateGravityField()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(gravityFieldPrefab, ((Component)this).transform.position, Quaternion.identity, ((Component)LevelGenerator.Instance).transform);
		}
	}
	internal class HealthPotion : AlchemyItem
	{
		public static ValuableObject valuableInstance;

		public static HealthPotion instance;

		public float healRadius = 3f;

		public static Material effectMaterial;

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((Component)this).GetComponent<PhysGrabObjectImpactDetector>().onDestroy.AddListener(new UnityAction(startHeal));
		}

		private void startHeal()
		{
			//IL_0018: 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_009c: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			AOEIndicator.CreateAOE(effectMaterial, healRadius * 2f, ((Component)this).transform.position);
			bool flag = SemiFunc.LocalPlayerOverlapCheck(healRadius, ((Component)this).transform.position, false);
			PlayerAvatar val = PlayerAvatar.instance;
			if (flag)
			{
				int value = Plugin.healthPotionHealing.Value;
				if (!GameManager.Multiplayer())
				{
					value = Plugin.healthPotionHealingSolo.Value;
				}
				val.playerHealth.HealOther(value, true);
			}
			List<PhysGrabObject> list = SemiFunc.PhysGrabObjectGetAllWithinRange(healRadius, ((Component)this).transform.position, false, default(LayerMask), (PhysGrabObject)null);
			List<ValuableObject> list2 = new List<ValuableObject>();
			foreach (PhysGrabObject item in list)
			{
				ValuableObject component = ((Component)item).GetComponent<ValuableObject>();
				if (!((Object)(object)component == (Object)null) && !Enumerable.Contains(list2, component))
				{
					component.dollarValueCurrent = Math.Min(component.dollarValueOriginal, component.dollarValueCurrent + Mathf.Floor(component.dollarValueOriginal * Plugin.healthPotionHealingValuable.Value));
					list2.Add(component);
				}
			}
		}
	}
	internal class PhoenixPotion : AlchemyItem
	{
		[CompilerGenerated]
		private sealed class <delayedDestroy>d__8 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public float delay;

			public PhoenixPotion <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <delayedDestroy>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.exploding = true;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.splashRadius = 9999f;
					((Component)<>4__this).GetComponent<PhysGrabObjectImpactDetector>().DestroyObject(true);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static ValuableObject valuableInstance;

		public static PhoenixPotion instance;

		private float splashRadius = 2f;

		private float soloRadius = 4f;

		public static Material effectMaterial;

		private bool exploding = false;

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((Component)this).GetComponent<PhysGrabObjectImpactDetector>().onDestroy.AddListener(new UnityAction(RevivePlayers));
		}

		private void Update()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMultiplayer() || exploding)
			{
				return;
			}
			List<PhysGrabObject> list = SemiFunc.PhysGrabObjectGetAllWithinRange(soloRadius, ((Component)this).transform.position, false, default(LayerMask), (PhysGrabObject)null);
			foreach (PhysGrabObject item in list)
			{
				if ((Object)(object)((Component)item).GetComponent<PlayerDeathHead>() != (Object)null)
				{
					((MonoBehaviour)this).StartCoroutine(delayedDestroy(1.5f));
					break;
				}
			}
		}

		[IteratorStateMachine(typeof(<delayedDestroy>d__8))]
		private IEnumerator delayedDestroy(float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <delayedDestroy>d__8(0)
			{
				<>4__this = this,
				delay = delay
			};
		}

		private void RevivePlayers()
		{
			//IL_0011: 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)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			AOEIndicator.CreateAOE(effectMaterial, 4f, ((Component)this).transform.position);
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			List<PhysGrabObject> list = SemiFunc.PhysGrabObjectGetAllWithinRange(splashRadius, ((Component)this).transform.position, false, default(LayerMask), (PhysGrabObject)null);
			foreach (PhysGrabObject item in list)
			{
				PlayerDeathHead component = ((Component)item).GetComponent<PlayerDeathHead>();
				if ((Object)(object)component != (Object)null)
				{
					component.FlashEyeRPC(true);
					component.Revive();
				}
			}
		}
	}
	internal class PortalPotion : AlchemyItem
	{
		public static ValuableObject valuableInstance;

		public static PortalPotion instance;

		public bool isSecond = false;

		public bool portalCreated = false;

		public PortalPotion pairedPotion;

		public ParticleSystem particles;

		public static GameObject portalPrefab;

		private void Start()
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			particles = ((Component)((Component)this).transform.Find("Object/Particles")).GetComponent<ParticleSystem>();
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (!isSecond)
				{
					GameObject val = Valuables.SpawnValuable(valuableInstance, ((Component)this).transform.position + ((Component)this).transform.right * 0.2f, ((Component)this).transform.rotation);
					pairedPotion = val.GetComponent<PortalPotion>();
					pairedPotion.isSecond = true;
					pairedPotion.pairedPotion = this;
					((Component)pairedPotion).GetComponent<ValuableObject>().valuePreset = ((Component)this).GetComponent<ValuableObject>().valuePreset;
					ValuableObject component = ((Component)this).GetComponent<ValuableObject>();
				}
				PhysGrabObjectImpactDetector component2 = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
				component2.onDestroy.AddListener(new UnityAction(CreatePortals));
			}
		}

		private void Update()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			((Component)particles).gameObject.SetActive((Object)(object)pairedPotion != (Object)null);
			if ((Object)(object)pairedPotion != (Object)null)
			{
				((Component)particles).transform.LookAt(((Component)pairedPotion.particles).transform.position);
			}
		}

		private void CreatePortals()
		{
			CreatePortal();
		}

		public Portal CreatePortal()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			portalCreated = true;
			GameObject val = NetworkPrefabs.SpawnNetworkPrefab(((Object)portalPrefab).name, ((Component)this).transform.position + Vector3.up, ((Component)this).transform.rotation, (byte)0, (object[])null);
			Portal portal = val.AddComponent<Portal>();
			if (SemiFunc.IsMasterClientOrSingleplayer() && !pairedPotion.portalCreated)
			{
				((Object)val).name = "MainPortal";
				portal.isMainPortal = true;
				portal.mainPortal = portal;
				portal.pairedPortal = pairedPotion.CreatePortal();
				portal.pairedPortal.pairedPortal = portal;
				portal.pairedPortal.mainPortal = portal;
				((Component)pairedPotion).GetComponent<PhysGrabObjectImpactDetector>().DestroyObject(true);
			}
			return portal;
		}
	}
	internal class RocketElixir : AlchemyItem
	{
		public static RocketElixir instance;

		public float grabStrengthMultiplier = 2f;

		public float torqueMultiplier = 2f;

		public float grabVerticalOffset = -0.5f;

		public float aimVerticalOffset = 90f;

		private Vector3 startPos;

		private Quaternion StartRot;

		private ItemMine mine;

		private ItemToggle itemToggle;

		private Rigidbody body;

		private PhysGrabObjectImpactDetector detector;

		private ParticleScriptExplosion particleScriptExplosion;

		private PhysGrabObject physGrabObject;

		private NotValuableObject notValuableObject;

		private bool prevToggleState = false;

		private bool activated = false;

		private void Start()
		{
			//IL_005c: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			mine = ((Component)this).GetComponent<ItemMine>();
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
			body = ((Component)this).GetComponent<Rigidbody>();
			detector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			notValuableObject = ((Component)this).GetComponent<NotValuableObject>();
			startPos = ((Component)this).transform.position;
			StartRot = ((Component)this).transform.rotation;
			detector.onDestroy.AddListener(new UnityAction(Explode));
		}

		private void Update()
		{
			if (((Behaviour)mine).enabled)
			{
				((Behaviour)mine).enabled = false;
			}
			if (itemToggle.toggleState != prevToggleState)
			{
				Activate();
			}
			prevToggleState = itemToggle.toggleState;
			if (activated && ((Component)this).GetComponent<ItemEquippable>().IsEquipped())
			{
				Deactivate();
			}
			UpdateRotation();
		}

		private void UpdateRotation()
		{
			//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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !physGrabObject.grabbed)
			{
				return;
			}
			Quaternion val = Quaternion.Euler(aimVerticalOffset, 0f, 0f);
			Quaternion val2 = Quaternion.Euler(0f, 0f, 0f);
			Quaternion identity = Quaternion.identity;
			bool flag = false;
			bool flag2 = false;
			bool flag3 = true;
			foreach (PhysGrabber item in physGrabObject.playerGrabbing)
			{
				if (flag3)
				{
					flag3 = false;
				}
				if (item.isRotating)
				{
					flag = true;
				}
			}
			if (!flag)
			{
				physGrabObject.TurnXYZ(val, val2, identity);
			}
			float num = grabVerticalOffset;
			if (flag2)
			{
				num += 0.5f;
			}
			physGrabObject.OverrideGrabVerticalPosition(num);
			if (!flag)
			{
				if (grabStrengthMultiplier != 1f)
				{
					physGrabObject.OverrideGrabStrength(grabStrengthMultiplier, 0.1f);
				}
				if (torqueMultiplier != 1f)
				{
					physGrabObject.OverrideTorqueStrength(torqueMultiplier, 0.1f);
				}
			}
			if (flag)
			{
				physGrabObject.OverrideAngularDrag(40f, 0.1f);
				physGrabObject.OverrideTorqueStrength(6f, 0.1f);
			}
		}

		private void Activate()
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			if (!activated)
			{
				activated = true;
				body.useGravity = false;
				body.angularDrag = 50f;
				((Component)((Component)this).transform.Find("Particles")).gameObject.SetActive(true);
				((Component)((Component)this).transform.Find("Object/Mesh/Love Potion Cork")).gameObject.SetActive(false);
				if (SemiFunc.RunIsShop() && !base.wasCrafted)
				{
					detector.onAllImpacts.AddListener(new UnityAction(ExplodeAndReset));
					return;
				}
				detector.destroyDisable = false;
				notValuableObject.hasHealth = true;
				detector.onAllImpacts.AddListener(new UnityAction(Destroy));
			}
		}

		private void FixedUpdate()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (activated)
			{
				body.AddForce(((Component)this).transform.up * 50f, (ForceMode)5);
			}
		}

		private void ExplodeAndReset()
		{
			//IL_000f: 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_003c: 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)
			Explode();
			((Component)this).transform.position = startPos;
			((Component)this).transform.rotation = StartRot;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				body.velocity = Vector3.zero;
				body.angularVelocity = Vector3.zero;
			}
		}

		private void Deactivate()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			detector.destroyDisable = true;
			detector.onAllImpacts.RemoveListener(new UnityAction(ExplodeAndReset));
			detector.onAllImpacts.RemoveListener(new UnityAction(Destroy));
			activated = false;
			body.useGravity = true;
			body.angularDrag = 0.05f;
			((Component)((Component)this).transform.Find("Particles")).gameObject.SetActive(false);
			((Component)((Component)this).transform.Find("Object/Mesh/Love Potion Cork")).gameObject.SetActive(true);
		}

		private void Destroy()
		{
			if (Plugin.staminaElixirConfigs.refill.Value || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				detector.DestroyObject(true);
			}
			else
			{
				mine.DestroyMine();
			}
		}

		private void Explode()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			particleScriptExplosion.Spawn(((Component)this).transform.position, 1.2f, Plugin.rocketElixirPlayerDamage.Value, Plugin.rocketElixirEnemyDamage.Value, 4f, false, false, 1f);
			Deactivate();
		}
	}
	internal class SingularityPotion : AlchemyItem
	{
		public static ValuableObject valuableInstance;

		public static SingularityPotion instance;

		private PhysGrabObject physGrabObject;

		private bool wasGrabbed = false;

		private float magnetRange = 1f;

		private void Start()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			((Component)this).transform.Find("Radius").localScale = Vector3.zero;
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			((Component)this).GetComponent<PhysGrabObjectImpactDetector>().onDestroy.AddListener(new UnityAction(Implode));
		}

		private void FixedUpdate()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_00a3: 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_00b1: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: 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)
			//IL_01a1: 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_01b2: 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_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			if (physGrabObject.grabbed)
			{
				wasGrabbed = true;
			}
			if (wasGrabbed)
			{
				Transform val = ((Component)this).transform.Find("Radius");
				float x = val.localScale.x;
				x += (magnetRange * 2f - x) * Time.deltaTime * 10f;
				val.localScale = Vector3.one * x;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			List<PhysGrabObject> list = SemiFunc.PhysGrabObjectGetAllWithinRange(magnetRange, ((Component)this).transform.Find("Object").position, false, default(LayerMask), (PhysGrabObject)null);
			List<PhysGrabObject> list2 = new List<PhysGrabObject>();
			foreach (PhysGrabObject item in list)
			{
				if ((Object)(object)((Component)item).GetComponent<SingularityPotion>() == (Object)null && !Enumerable.Contains(list2, item))
				{
					list2.Add(item);
				}
			}
			foreach (PhysGrabObject item2 in list2)
			{
				if (!((Component)item2).GetComponent<PhysGrabObjectImpactDetector>().inCart && !((Object)(object)((Component)item2).GetComponent<PhysGrabCart>() != (Object)null))
				{
					Vector3 val2 = ((Component)this).transform.Find("Object").position - ((Component)item2).transform.position;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					val2 = ((Component)this).transform.Find("Object").position - ((Component)item2).transform.position;
					float magnitude = ((Vector3)(ref val2)).magnitude;
					if (magnitude > 0.45f)
					{
						item2.rb.AddForce(normalized * Mathf.Clamp(item2.rb.mass * magnitude * 50f, 0.2f, 10f));
					}
					item2.rb.velocity = physGrabObject.rb.velocity;
					item2.OverrideZeroGravity(0.1f);
				}
			}
		}

		private void Implode()
		{
			//IL_000d: 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_008f: 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)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).GetComponent<ParticleScriptExplosion>().Spawn(((Component)this).transform.position, 3f, 20, 80, 0f, true, false, 1f);
			if (SemiFunc.LocalPlayerOverlapCheck(3f, ((Component)this).transform.Find("Object").position, false))
			{
				PlayerAvatar.instance.tumble.TumbleRequest(true, false);
				PlayerAvatar.instance.tumble.TumbleOverrideTime(2f);
			}
			List<PhysGrabObject> list = SemiFunc.PhysGrabObjectGetAllWithinRange(3f, ((Component)this).transform.Find("Object").position, false, default(LayerMask), (PhysGrabObject)null);
			List<PhysGrabObject> list2 = new List<PhysGrabObject>();
			foreach (PhysGrabObject item in list)
			{
				if (!Enumerable.Contains(list2, item))
				{
					list2.Add(item);
				}
			}
			foreach (PhysGrabObject item2 in list2)
			{
				Vector3 val = ((Component)this).transform.position - ((Component)item2).transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				item2.rb.velocity = normalized * 15f;
			}
		}
	}
	internal class StaminaElixir : AlchemyItem
	{
		public static StaminaElixir instance;

		private ItemMine mine;

		private ItemToggle itemToggle;

		private PhysGrabObject physGrabObject;

		private List<GameObject> fluids;

		private Light light;

		private bool prevToggleState = false;

		public int charges = 3;

		private Vector3 startPos;

		private Quaternion startRot;

		private float cooldown = 0.5f;

		private float timeSinceUse = 0f;

		private void Start()
		{
			//IL_0008: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			startPos = ((Component)this).transform.position;
			startRot = ((Component)this).transform.rotation;
			mine = ((Component)this).GetComponent<ItemMine>();
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			fluids = new List<GameObject>
			{
				((Component)((Component)this).transform.Find("Object/Glass/Fluid1")).gameObject,
				((Component)((Component)this).transform.Find("Object/Glass/Fluid2")).gameObject,
				((Component)((Component)this).transform.Find("Object/Glass/Fluid3")).gameObject
			};
			light = ((Component)((Component)this).transform.Find("Object/Light - Small Lamp")).GetComponent<Light>();
			UpdateCharges();
		}

		private bool CanUse()
		{
			return charges > 0 && timeSinceUse > cooldown;
		}

		private void Update()
		{
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			if (((Behaviour)mine).enabled)
			{
				((Behaviour)mine).enabled = false;
			}
			timeSinceUse += Time.deltaTime;
			if (itemToggle.toggleState != prevToggleState && CanUse())
			{
				if (Enumerable.Contains(physGrabObject.playerGrabbing, PlayerAvatar.instance.physGrabber))
				{
					PlayerController.instance.EnergyCurrent = PlayerController.instance.EnergyStart;
					CameraGlitch.Instance.PlayShortHeal();
				}
				charges--;
				timeSinceUse = 0f;
				UpdateCharges();
				if (charges <= 0)
				{
					if (SemiFunc.RunIsShop() && !base.wasCrafted)
					{
						((Component)this).GetComponent<PhysGrabObjectImpactDetector>().onAllBreaks.AddListener(new UnityAction(BreakAndReset));
					}
					else
					{
						((Component)this).GetComponent<PhysGrabObjectImpactDetector>().destroyDisable = false;
						((Component)this).GetComponent<NotValuableObject>().hasHealth = true;
						if (!Plugin.staminaElixirConfigs.refill.Value && SemiFunc.IsMasterClientOrSingleplayer())
						{
							((Component)this).GetComponent<PhysGrabObjectImpactDetector>().onDestroy.AddListener(new UnityAction(RemoveElixir));
						}
					}
				}
			}
			prevToggleState = itemToggle.toggleState;
		}

		private void UpdateCharges()
		{
			((Behaviour)light).enabled = charges > 0;
			for (int i = 0; i < fluids.Count(); i++)
			{
				fluids[i].SetActive(i + 1 == charges);
			}
		}

		private void RemoveElixir()
		{
			mine.DestroyMine();
		}

		private void BreakAndReset()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			PhysGrabObjectImpactDetector component = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			component.onAllBreaks.RemoveListener(new UnityAction(BreakAndReset));
			GameDirector.instance.CameraImpact.ShakeDistance(10f, 1f, 6f, ((Component)this).transform.position, 0.1f);
			GameObject val = Object.Instantiate<GameObject>(((Component)component.particles).gameObject, ((Component)this).transform.position, Quaternion.identity);
			val.GetComponent<PhysObjectParticles>().DestroyParticles();
			charges = 3;
			UpdateCharges();
			((Component)this).transform.position = startPos;
			((Component)this).transform.rotation = startRot;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				Rigidbody component2 = ((Component)this).GetComponent<Rigidbody>();
				component2.velocity = Vector3.zero;
				component2.angularVelocity = Vector3.zero;
			}
		}
	}
	internal class UnstablePotion : AlchemyItem
	{
		public static ValuableObject valuableInstance;

		public static UnstablePotion instance;

		private Rigidbody rb;

		private PhysGrabObject physGrabObject;

		private PhysGrabObjectImpactDetector detector;

		private ParticleScriptExplosion particleScriptExplosion;

		private Light light;

		private float effectProgress = 0f;

		private float detonationTimer = 30f;

		private float lightProgress = 0f;

		private bool activated = false;

		private void Start()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			rb = ((Component)this).GetComponent<Rigidbody>();
			light = ((Component)((Component)this).transform.Find("Object/Light - Small Lamp")).GetComponent<Light>();
			detector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
			detector.onDestroy.AddListener(new UnityAction(Detonate));
		}

		private void Update()
		{
			if (physGrabObject.playerGrabbing.Any())
			{
				Activate();
			}
			if (activated)
			{
				effectProgress += Time.deltaTime;
				lightProgress += Math.Min(effectProgress, 25f) * 1f * Time.deltaTime;
				light.intensity = 0.5f + Math.Min(effectProgress, 10f) * 0.1f + Math.Min(effectProgress, 10f) * 0.1f * (float)Math.Sin(lightProgress);
				detonationTimer -= Time.deltaTime;
				if (!(detonationTimer <= 0f))
				{
				}
			}
		}

		public void Activate()
		{
			if (!activated)
			{
				activated = true;
				((Component)((Component)this).transform.Find("Object/Particles")).gameObject.SetActive(true);
			}
		}

		public void Detonate()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			particleScriptExplosion.Spawn(((Component)this).transform.position, 1.5f, 50, 150, 1f, false, false, 2f);
		}

		private void FixedUpdate()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			if (Random.Range(0, 100) < 25)
			{
				float num = Math.Min(effectProgress, 25f) * 0.04f;
				rb.AddForce(Random.insideUnitSphere * 0.5f * num, (ForceMode)1);
				rb.AddTorque(Random.insideUnitSphere * 1f * num, (ForceMode)1);
			}
		}
	}
}