Decompiled source of DomsExpandedIngredientsAndEffects v1.2.0

DomsExpandedIngredientsAndEffects-Mono.dll

Decompiled 2 months 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 DomsExpandedIngredientsAndEffects;
using DomsExpandedIngredientsAndEffects.Effects;
using DomsExpandedIngredientsAndEffects.Effects.Descriptors;
using DomsExpandedIngredientsAndEffects.Framework;
using DomsExpandedIngredientsAndEffects.Ingredients;
using DomsExpandedIngredientsAndEffects.Patches;
using DomsExpandedIngredientsAndEffects.Utilities;
using FishNet;
using FishNet.Connection;
using FishNet.Object;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using ScheduleOne;
using ScheduleOne.Audio;
using ScheduleOne.AvatarFramework;
using ScheduleOne.Core.Items.Framework;
using ScheduleOne.DevUtilities;
using ScheduleOne.Effects;
using ScheduleOne.Effects.MixMaps;
using ScheduleOne.Interaction;
using ScheduleOne.ItemFramework;
using ScheduleOne.Levelling;
using ScheduleOne.Map;
using ScheduleOne.Messaging;
using ScheduleOne.NPCs;
using ScheduleOne.ObjectScripts;
using ScheduleOne.PlayerScripts;
using ScheduleOne.Product;
using ScheduleOne.Quests;
using ScheduleOne.StationFramework;
using ScheduleOne.UI;
using ScheduleOne.UI.Phone.Delivery;
using ScheduleOne.UI.Shop;
using ScheduleOne.UI.Stations;
using ScheduleOne.Weather;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(DomsCustomEffects), "Dom's Custom Effects", "1.0.0", "Dom", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("DomsExpandedIngredientsAndEffects-Mono")]
[assembly: AssemblyConfiguration("Mono")]
[assembly: AssemblyDescription("Custom drugs and effects using S1API")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+eea8148f75a32f7711442c3d3be242370e62c997")]
[assembly: AssemblyProduct("DomsExpandedIngredientsAndEffects-Mono")]
[assembly: AssemblyTitle("DomsExpandedIngredientsAndEffects-Mono")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 DomsExpandedIngredientsAndEffects
{
	public class DomsCustomEffects : MelonMod
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__8_0;

			public static UnityAction <>9__15_0;

			internal void <InjectDeliveryShopEntries>b__8_0()
			{
			}

			internal void <SpawnVendorStand>b__15_0()
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				LevelManager instance = NetworkSingleton<LevelManager>.Instance;
				if (!((Object)(object)instance == (Object)null))
				{
					if (!(instance.GetFullRank() >= new FullRank((ERank)5, 4)))
					{
						MelonCoroutines.Start(ShowRejectionMessage());
					}
					else
					{
						OpenAlchemistShop();
					}
				}
			}
		}

		private static bool _injected;

		public static ShopInterface _magicJuiceShop;

		private static Canvas _magicJuiceCanvas;

		private static RectTransform _magicJuiceContainer;

		public static bool _alchemistMessageSent;

		private static MSGConversation _alchemistConversation;

		public override void OnSceneWasInitialized(int buildIndex, string sceneName)
		{
			if (!_injected && (sceneName.ToLower().Contains("main") || sceneName.ToLower().Contains("game")))
			{
				OnInject();
			}
		}

		public override void OnInitializeMelon()
		{
		}

		private void OnInject()
		{
			try
			{
				MelonLogger.Msg("Mod: Starting content injection...");
				Registry instance = Singleton<Registry>.Instance;
				ProductManager instance2 = NetworkSingleton<ProductManager>.Instance;
				if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null)
				{
					MelonLogger.Error("Mod: Registry or ProductManager not found!");
					return;
				}
				MoonDustIngredient moonDustIngredient = new MoonDustIngredient();
				moonDustIngredient.Register(instance, instance2);
				LipstickIngredient lipstickIngredient = new LipstickIngredient();
				lipstickIngredient.Register(instance, instance2);
				AirhornIngredient airhornIngredient = new AirhornIngredient();
				airhornIngredient.Register(instance, instance2);
				MagicJuiceIngredient magicJuiceIngredient = new MagicJuiceIngredient();
				magicJuiceIngredient.Register(instance, instance2);
				FertilizerIngredient fertilizerIngredient = new FertilizerIngredient();
				fertilizerIngredient.Register(instance, instance2);
				HotSauceIngredient hotSauceIngredient = new HotSauceIngredient();
				hotSauceIngredient.Register(instance, instance2);
				EffectCombination[] array = new EffectCombination[40]
				{
					new EffectCombination("moongravity", "foggy", new VoidEffectDef()),
					new EffectCombination("heliuminfusion", "energizing", new BunnyEffectDef()),
					new EffectCombination("moongravity", "toxic", new AlienEffectDef()),
					new EffectCombination("moongravity", "moongravity", new MartianEffectDef()),
					new EffectCombination("martianeffect", "alieneffect", new SuperMartianEffectDef()),
					new EffectCombination("heliuminfusion", "sedating", new NebulaEffectDef()),
					new EffectCombination("heliuminfusion", "sneaky", new PhantomEffectDef()),
					new EffectCombination("phantomeffect", "heliuminfusion", new WraithEffectDef()),
					new EffectCombination("voluptuouseffect", "energizing", new GoldRushEffectDef()),
					new EffectCombination("voluptuouseffect", "voideffect", new SingleEventUpsetEffectDef()),
					new EffectCombination("heliuminfusion", "giraffying", new TallEffectDef()),
					new EffectCombination("talleffect", "foggy", new InversionEffectDef()),
					new EffectCombination("voluptuouseffect", "calming", new SirenEffectDef()),
					new EffectCombination("voluptuouseffect", "balding", new DivaEffectDef()),
					new EffectCombination("goldrusheffect", "martianeffect", new GildedMartianEffectDef()),
					new EffectCombination("voluptuouseffect", "electrifying", new ChargedEffectDef()),
					new EffectCombination("airhornbase", "sneaky", new TrollEffectDef()),
					new EffectCombination("airhornbase", "energizing", new FiestaEffectDef()),
					new EffectCombination("trolleffect", "airhornbase", new CreepyEffectDef()),
					new EffectCombination("magicbase", "magicbase", new SuperMagicEffectDef()),
					new EffectCombination("magicbase", "calming", new MakeItRainEffectDef()),
					new EffectCombination("magicbase", "energizing", new SuperChargeEffectDef()),
					new EffectCombination("supermagic", "slippery", new ProfitBoostEffectDef()),
					new EffectCombination("supercharge", "supermagic", new SuperSuperChargeEffectDef()),
					new EffectCombination("earthyeffect", "calming", new RootBoundEffectDef()),
					new EffectCombination("rootbound", "toxic", new OvergrownEffectDef()),
					new EffectCombination("overgrown", "energizing", new BloomEffectDef()),
					new EffectCombination("bloom", "foggy", new CompostEffectDef()),
					new EffectCombination("spicyeffect", "toxic", new FiveAlarmEffectDef()),
					new EffectCombination("fivealarm", "energizing", new CapsaicinRushEffectDef()),
					new EffectCombination("capsaicinrush", "sneaky", new DragonBreathEffectDef()),
					new EffectCombination("dragonbreath", "sedating", new InfernoEffectDef()),
					new EffectCombination("voluptuouseffect", "foggy", new FemmeFataleEffectDef()),
					new EffectCombination("divaeffect", "toxic", new VenomKissEffectDef()),
					new EffectCombination("airhornbase", "toxic", new ThunderclapEffectDef()),
					new EffectCombination("fiestaeffect", "sedating", new WhiteNoiseEffectDef()),
					new EffectCombination("earthyeffect", "voluptuouseffect", new WildflowerEffectDef()),
					new EffectCombination("voluptuouseffect", "spicyeffect", new BurningPassionEffectDef()),
					new EffectCombination("earthyeffect", "airhornbase", new UpheavalEffectDef()),
					new EffectCombination("magicbase", "toxic", new PhantasmEffectDef())
				};
				foreach (EffectCombination combo in array)
				{
					CustomMixRegistry.Register(combo);
				}
				CustomMixRegistry.Register(new MultiEffectCombination(new string[2] { "heliuminfusion", "foggy" }, "longfaced", new InversionEffectDef()));
				MelonCoroutines.Start(AddIngredientsToShops());
				MelonCoroutines.Start(SpawnMagicJuiceVendor());
				_injected = true;
				MelonLogger.Msg("Mod: Injection complete.");
			}
			catch (Exception ex)
			{
				MelonLogger.Error("Injection Error: " + ex.Message + "\n" + ex.StackTrace);
			}
		}

		public static Sprite LoadCustomIcon(string fileName)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = Path.Combine(Directory.GetCurrentDirectory(), "Mods", "DomsCustomEffects", "Icons", fileName);
				if (!File.Exists(text))
				{
					MelonLogger.Warning("[Icon] Not found: " + text);
					return null;
				}
				byte[] array = File.ReadAllBytes(text);
				Texture2D val = new Texture2D(2, 2);
				ImageConversion.LoadImage(val, array);
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[Icon] Failed: " + ex.Message);
				return null;
			}
		}

		public static Texture2D LoadCustomTexture(string fileName)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			try
			{
				string path = Path.Combine(Directory.GetCurrentDirectory(), "Mods", "DomsCustomEffects", "Icons", fileName);
				if (!File.Exists(path))
				{
					return null;
				}
				byte[] array = File.ReadAllBytes(path);
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				ImageConversion.LoadImage(val, array);
				return val;
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[Texture] Failed: " + ex.Message);
				return null;
			}
		}

		public static AudioClip LoadCustomSound(string fileName)
		{
			try
			{
				string text = Path.Combine(Directory.GetCurrentDirectory(), "Mods", "DomsCustomEffects", "Sounds", fileName);
				if (!File.Exists(text))
				{
					MelonLogger.Warning("[Sound] Not found: " + text);
					return null;
				}
				byte[] data = File.ReadAllBytes(text);
				AudioClip val = WavUtility.ToAudioClip(data, fileName);
				if ((Object)(object)val == (Object)null)
				{
					MelonLogger.Warning("[Sound] Failed to decode " + fileName + " — try converting to .wav");
				}
				return val;
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[Sound] Failed: " + ex.Message);
				return null;
			}
		}

		private static IEnumerator AddIngredientsToShops()
		{
			yield return (object)new WaitForSeconds(2f);
			List<ShopInterface> shops = ShopInterface.AllShops;
			SetRankRequirement(FertilizerIngredient.Definition, (ERank)1, 1);
			SetRankRequirement(HotSauceIngredient.Definition, (ERank)2, 3);
			SetRankRequirement(MoonDustIngredient.Definition, (ERank)3, 5);
			SetRankRequirement(LipstickIngredient.Definition, (ERank)4, 3);
			SetRankRequirement(AirhornIngredient.Definition, (ERank)5, 1);
			string[] gasCodes = new string[2] { "gas_mart_central", "gas_mart_west" };
			string[] array = gasCodes;
			foreach (string code in array)
			{
				ShopInterface shop = null;
				foreach (ShopInterface s in shops)
				{
					if (s.ShopCode == code)
					{
						shop = s;
						break;
					}
				}
				if ((Object)(object)shop == (Object)null)
				{
					MelonLogger.Warning("[Shop] Could not find shop: " + code);
					continue;
				}
				AddIngredientToShop(shop, FertilizerIngredient.Definition, 3f, canBeDelivered: true);
				AddIngredientToShop(shop, HotSauceIngredient.Definition, 5f, canBeDelivered: true);
				AddIngredientToShop(shop, MoonDustIngredient.Definition, 6f, canBeDelivered: true);
				AddIngredientToShop(shop, LipstickIngredient.Definition, 5f, canBeDelivered: true);
				AddIngredientToShop(shop, AirhornIngredient.Definition, 5f, canBeDelivered: true);
			}
			yield return null;
			InjectDeliveryShopEntries();
		}

		private static void InjectDeliveryShopEntries()
		{
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			DeliveryApp instance = PlayerSingleton<DeliveryApp>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				MelonLogger.Warning("[Shop] DeliveryApp not found.");
				return;
			}
			DeliveryShop[] componentsInChildren = ((Component)instance).GetComponentsInChildren<DeliveryShop>(true);
			DeliveryShop[] array = componentsInChildren;
			foreach (DeliveryShop val in array)
			{
				if ((Object)(object)val.MatchingShop == (Object)null || (val.MatchingShop.ShopCode != "gas_mart_central" && val.MatchingShop.ShopCode != "gas_mart_west"))
				{
					continue;
				}
				FieldInfo field = typeof(DeliveryShop).GetField("ListingEntryPrefab", BindingFlags.Instance | BindingFlags.Public);
				FieldInfo field2 = typeof(DeliveryShop).GetField("ListingContainer", BindingFlags.Instance | BindingFlags.Public);
				FieldInfo field3 = typeof(DeliveryShop).GetField("listingEntries", BindingFlags.Instance | BindingFlags.NonPublic);
				object? obj = field?.GetValue(val);
				ListingEntry val2 = (ListingEntry)((obj is ListingEntry) ? obj : null);
				object? obj2 = field2?.GetValue(val);
				RectTransform val3 = (RectTransform)((obj2 is RectTransform) ? obj2 : null);
				List<ListingEntry> list = field3?.GetValue(val) as List<ListingEntry>;
				if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || list == null)
				{
					MelonLogger.Warning("[Shop] Could not get DeliveryShop fields for " + val.MatchingShop.ShopName + ".");
					continue;
				}
				foreach (ShopListing listing in val.MatchingShop.Listings)
				{
					if (listing.CanBeDelivered && !list.Exists((ListingEntry e) => ((BaseItemDefinition)(e.MatchingListing?.Item?)).ID == ((BaseItemDefinition)(listing.Item?)).ID))
					{
						ListingEntry val4 = Object.Instantiate<ListingEntry>(val2, (Transform)(object)val3);
						val4.Initialize(listing);
						UnityEvent onQuantityChanged = val4.onQuantityChanged;
						object obj3 = <>c.<>9__8_0;
						if (obj3 == null)
						{
							UnityAction val5 = delegate
							{
							};
							<>c.<>9__8_0 = val5;
							obj3 = (object)val5;
						}
						onQuantityChanged.AddListener((UnityAction)obj3);
						list.Add(val4);
					}
				}
				object? obj4 = typeof(DeliveryShop).GetField("ContentsContainer", BindingFlags.Instance | BindingFlags.Public)?.GetValue(val);
				RectTransform val6 = (RectTransform)((obj4 is RectTransform) ? obj4 : null);
				if ((Object)(object)val6 != (Object)null)
				{
					int num = Mathf.CeilToInt((float)list.Count / 2f);
					val6.sizeDelta = new Vector2(val6.sizeDelta.x, 230f + (float)num * 60f);
				}
			}
		}

		private static void SetRankRequirement(PropertyItemDefinition def, ERank rank, int tier)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			if (!((Object)(object)def == (Object)null))
			{
				((StorableItemDefinition)def).RequiresLevelToPurchase = true;
				((StorableItemDefinition)def).RequiredRank = new FullRank(rank, tier);
				LevelManager instance = NetworkSingleton<LevelManager>.Instance;
				if ((Object)(object)instance != (Object)null)
				{
					instance.AddUnlockable(new Unlockable(new FullRank(rank, tier), ((BaseItemDefinition)def).Name, ((BaseItemDefinition)def).Icon));
				}
			}
		}

		private static void AddIngredientToShop(ShopInterface shop, PropertyItemDefinition def, float price, bool canBeDelivered = false)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			if ((Object)(object)def == (Object)null || (Object)(object)shop == (Object)null)
			{
				return;
			}
			foreach (ShopListing listing in shop.Listings)
			{
				if (((BaseItemDefinition)(listing.Item?)).ID == ((BaseItemDefinition)def).ID)
				{
					return;
				}
			}
			ShopListing val = new ShopListing
			{
				name = ((BaseItemDefinition)def).Name,
				Item = (StorableItemDefinition)(object)def,
				LimitedStock = false,
				DefaultStock = -1,
				CanBeDelivered = canBeDelivered
			};
			FieldInfo field = typeof(ShopListing).GetField("OverridePrice", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field2 = typeof(ShopListing).GetField("OverriddenPrice", BindingFlags.Instance | BindingFlags.NonPublic);
			field?.SetValue(val, true);
			field2?.SetValue(val, price);
			shop.Listings.Add(val);
			val.Initialize(shop);
			typeof(ShopInterface).GetMethod("CreateListingUI", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(shop, new object[1] { val });
		}

		private static IEnumerator SpawnMagicJuiceVendor()
		{
			yield return (object)new WaitForSeconds(3f);
			ShopInterface sourceShop = null;
			foreach (ShopInterface s in ShopInterface.AllShops)
			{
				if (s.ShopCode == "gas_mart_central")
				{
					sourceShop = s;
					break;
				}
			}
			if ((Object)(object)sourceShop == (Object)null)
			{
				MelonLogger.Warning("[Vendor] Could not find source shop to clone.");
				yield break;
			}
			GameObject shopGO = Object.Instantiate<GameObject>(((Component)sourceShop).gameObject);
			((Object)shopGO).name = "MagicJuiceVendorShop";
			_magicJuiceShop = shopGO.GetComponent<ShopInterface>();
			_magicJuiceShop.ShopName = "The Alchemist Table";
			_magicJuiceShop.ShopCode = "magic_juice_vendor";
			_magicJuiceCanvas = shopGO.GetComponentInChildren<Canvas>(true);
			_magicJuiceContainer = _magicJuiceShop.Container;
			if ((Object)(object)_magicJuiceShop.StoreNameLabel != (Object)null)
			{
				((TMP_Text)_magicJuiceShop.StoreNameLabel).text = "The Alchemist Table";
			}
			FieldInfo shopScreenField = typeof(ShopInterface).GetField("shopScreen", BindingFlags.Instance | BindingFlags.NonPublic);
			UIScreen ownScreen = shopGO.GetComponentInChildren<UIScreen>(true);
			if (shopScreenField != null && (Object)(object)ownScreen != (Object)null)
			{
				shopScreenField.SetValue(_magicJuiceShop, ownScreen);
			}
			else
			{
				MelonLogger.Warning($"[Vendor] shopScreen fix failed — field:{shopScreenField != null} screen:{(Object)(object)ownScreen != (Object)null}");
			}
			Cart cart = shopGO.GetComponentInChildren<Cart>(true);
			if ((Object)(object)cart != (Object)null)
			{
				cart.Shop = _magicJuiceShop;
			}
			else
			{
				MelonLogger.Warning("[Vendor] Could not find Cart component on cloned shop.");
			}
			RectTransform listingContainer = _magicJuiceShop.ListingContainer;
			if ((Object)(object)listingContainer != (Object)null)
			{
				for (int i = ((Transform)listingContainer).childCount - 1; i >= 0; i--)
				{
					Object.Destroy((Object)(object)((Component)((Transform)listingContainer).GetChild(i)).gameObject);
				}
			}
			(typeof(ShopInterface).GetField("listingUI", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(_magicJuiceShop) as List<ListingUI>)?.Clear();
			_magicJuiceShop.Listings.Clear();
			yield return null;
			SetRankRequirement(MagicJuiceIngredient.Definition, (ERank)5, 4);
			AddIngredientToShop(_magicJuiceShop, MagicJuiceIngredient.Definition, 200f);
			SpawnVendorStand();
		}

		private static void SpawnVendorStand()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0028: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_00f7: 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_0136: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Expected O, but got Unknown
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Expected O, but got Unknown
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Expected O, but got Unknown
			Vector3 position = default(Vector3);
			((Vector3)(ref position))..ctor(-15.7f, -5.04f, 173.82f);
			GameObject val = new GameObject("MagicJuiceVendorStand");
			val.transform.position = position;
			val.transform.rotation = Quaternion.Euler(0f, 30f, 0f);
			Shader val2 = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard");
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val3).name = "VendorTable";
			val3.transform.SetParent(val.transform);
			val3.transform.localPosition = new Vector3(0f, 0.75f, 0f);
			val3.transform.localRotation = Quaternion.identity;
			val3.transform.localScale = new Vector3(1.2f, 0.1f, 0.7f);
			Material val4 = new Material(val2);
			val4.color = new Color(0.15f, 0.05f, 0.25f);
			val3.GetComponent<Renderer>().material = val4;
			val3.layer = LayerMask.NameToLayer("Default");
			val3.GetComponent<Collider>().isTrigger = false;
			Material val5 = new Material(val2);
			val5.color = new Color(0.1f, 0.03f, 0.18f);
			Vector3[] array = (Vector3[])(object)new Vector3[4]
			{
				new Vector3(0.55f, 0.35f, 0.3f),
				new Vector3(-0.55f, 0.35f, 0.3f),
				new Vector3(0.55f, 0.35f, -0.3f),
				new Vector3(-0.55f, 0.35f, -0.3f)
			};
			Vector3[] array2 = array;
			foreach (Vector3 localPosition in array2)
			{
				GameObject val6 = GameObject.CreatePrimitive((PrimitiveType)3);
				val6.transform.SetParent(val.transform);
				val6.transform.localPosition = localPosition;
				val6.transform.localRotation = Quaternion.identity;
				val6.transform.localScale = new Vector3(0.07f, 0.7f, 0.07f);
				val6.GetComponent<Renderer>().material = val5;
				val6.layer = LayerMask.NameToLayer("Default");
				val6.GetComponent<Collider>().isTrigger = false;
			}
			GameObject val7 = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val7).name = "MagicOrb";
			val7.transform.SetParent(val.transform);
			val7.transform.localPosition = new Vector3(0f, 0.92f, 0f);
			val7.transform.localRotation = Quaternion.identity;
			val7.transform.localScale = Vector3.one * 0.22f;
			Material val8 = new Material(val2);
			val8.color = new Color(0.6f, 0f, 1f);
			val8.EnableKeyword("_EMISSION");
			val8.SetColor("_EmissionColor", new Color(0.5f, 0f, 0.9f) * 3f);
			val7.GetComponent<Renderer>().material = val8;
			Object.Destroy((Object)(object)val7.GetComponent<Collider>());
			GameObject val9 = new GameObject("InteractionCollider");
			val9.transform.SetParent(val.transform);
			val9.transform.localPosition = new Vector3(0f, 0.55f, 0f);
			val9.transform.localRotation = Quaternion.identity;
			val9.layer = LayerMask.NameToLayer("Interaction");
			BoxCollider val10 = val9.AddComponent<BoxCollider>();
			((Collider)val10).isTrigger = true;
			val10.size = new Vector3(1.2f, 1.4f, 0.7f);
			InteractableObject val11 = val9.AddComponent<InteractableObject>();
			val11.SetMessage("Browse The Alchemist Table");
			val11.MaxInteractionRange = 3f;
			val11.SetInteractableState((EInteractableState)0);
			UnityEvent onInteractStart = val11.onInteractStart;
			object obj = <>c.<>9__15_0;
			if (obj == null)
			{
				UnityAction val12 = delegate
				{
					//IL_0015: Unknown result type (might be due to invalid IL or missing references)
					//IL_001c: Unknown result type (might be due to invalid IL or missing references)
					LevelManager instance = NetworkSingleton<LevelManager>.Instance;
					if (!((Object)(object)instance == (Object)null))
					{
						if (!(instance.GetFullRank() >= new FullRank((ERank)5, 4)))
						{
							MelonCoroutines.Start(ShowRejectionMessage());
						}
						else
						{
							OpenAlchemistShop();
						}
					}
				};
				<>c.<>9__15_0 = val12;
				obj = (object)val12;
			}
			onInteractStart.AddListener((UnityAction)obj);
			MelonCoroutines.Start(AddVendorMapPOI(val));
		}

		private static void OpenAlchemistShop()
		{
			if (!((Object)(object)_magicJuiceShop == (Object)null))
			{
				_magicJuiceShop.SetIsOpen(true);
				if ((Object)(object)_magicJuiceCanvas != (Object)null)
				{
					((Behaviour)_magicJuiceCanvas).enabled = true;
				}
				if ((Object)(object)_magicJuiceContainer != (Object)null)
				{
					((Component)_magicJuiceContainer).gameObject.SetActive(true);
				}
				MelonCoroutines.Start(WatchForShopClose());
			}
		}

		private static void ForceCloseAlchemistShop()
		{
			if (!((Object)(object)_magicJuiceShop == (Object)null))
			{
				_magicJuiceShop.SetIsOpen(false);
				if ((Object)(object)_magicJuiceCanvas != (Object)null)
				{
					((Behaviour)_magicJuiceCanvas).enabled = false;
				}
				if ((Object)(object)_magicJuiceContainer != (Object)null)
				{
					((Component)_magicJuiceContainer).gameObject.SetActive(false);
				}
			}
		}

		private static IEnumerator WatchForShopClose()
		{
			yield return (object)new WaitForSeconds(0.3f);
			while ((Object)(object)_magicJuiceShop != (Object)null && _magicJuiceShop.IsOpen)
			{
				if (GameInput.GetButtonDown((ButtonCode)10) || GameInput.GetButtonDown((ButtonCode)11))
				{
					ForceCloseAlchemistShop();
					yield break;
				}
				PlayerMovement player = PlayerSingleton<PlayerMovement>.Instance;
				if ((Object)(object)player != (Object)null)
				{
					float dist = Vector3.Distance(((Component)player).transform.position, new Vector3(-15.7f, -5.04f, 173.82f));
					if (dist > 8f)
					{
						ForceCloseAlchemistShop();
						yield break;
					}
				}
				yield return null;
			}
			if ((Object)(object)_magicJuiceCanvas != (Object)null)
			{
				((Behaviour)_magicJuiceCanvas).enabled = false;
			}
			if ((Object)(object)_magicJuiceContainer != (Object)null)
			{
				((Component)_magicJuiceContainer).gameObject.SetActive(false);
			}
		}

		private static IEnumerator ShowRejectionMessage()
		{
			float elapsed = 0f;
			float duration = 0.9f;
			while (elapsed < duration)
			{
				HUD instance = Singleton<HUD>.Instance;
				if (instance != null)
				{
					CrosshairText crosshairText = instance.CrosshairText;
					if (crosshairText != null)
					{
						crosshairText.Show("Get outta here kid.", Color32.op_Implicit(new Color32(byte.MaxValue, (byte)80, (byte)80, byte.MaxValue)));
					}
				}
				elapsed += Time.deltaTime;
				yield return null;
			}
		}

		private static IEnumerator AddVendorMapPOI(GameObject vendorGO)
		{
			yield return (object)new WaitForSeconds(1f);
			LevelManager lm = NetworkSingleton<LevelManager>.Instance;
			if ((Object)(object)lm == (Object)null)
			{
				yield break;
			}
			POI existingPOI = Object.FindObjectOfType<POI>();
			if ((Object)(object)existingPOI == (Object)null)
			{
				MelonLogger.Warning("[Vendor] Could not find POI to clone.");
				yield break;
			}
			GameObject poiGO = Object.Instantiate<GameObject>(((Component)existingPOI).gameObject, vendorGO.transform);
			poiGO.transform.localPosition = new Vector3(0f, 2f, 0f);
			POI poi = poiGO.GetComponent<POI>();
			poi.SetMainText("The Alchemist Table");
			poi.onUICreated.AddListener((UnityAction)delegate
			{
				MelonCoroutines.Start(SetPOIIcon(poi));
			});
			bool meetsRank = lm.GetFullRank() >= new FullRank((ERank)5, 4);
			((Behaviour)poi).enabled = meetsRank;
			poiGO.SetActive(meetsRank);
			if (meetsRank && !_alchemistMessageSent)
			{
				_alchemistMessageSent = true;
				CreateAlchemistConversation();
				SendAlchemistPhoneMessage();
			}
			lm.onRankChanged = (Action<FullRank, FullRank>)Delegate.Combine(lm.onRankChanged, (Action<FullRank, FullRank>)delegate(FullRank before, FullRank after)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				bool flag = after >= new FullRank((ERank)5, 4);
				((Behaviour)poi).enabled = flag;
				poiGO.SetActive(flag);
				if (flag && !_alchemistMessageSent)
				{
					_alchemistMessageSent = true;
					CreateAlchemistConversation();
					SendAlchemistPhoneMessage();
				}
			});
		}

		private static IEnumerator SetPOIIcon(POI poi)
		{
			yield return null;
			if ((Object)(object)poi.IconContainer == (Object)null)
			{
				MelonLogger.Warning("[Vendor] POI IconContainer is null.");
				yield break;
			}
			for (int i = ((Transform)poi.IconContainer).childCount - 1; i >= 0; i--)
			{
				Object.Destroy((Object)(object)((Component)((Transform)poi.IconContainer).GetChild(i)).gameObject);
			}
			yield return null;
			Texture2D tex = LoadCustomTexture("MagicJuice.png");
			if ((Object)(object)tex == (Object)null)
			{
				MelonLogger.Warning("[Vendor] Could not load MagicJuice.png for POI icon.");
				yield break;
			}
			GameObject iconGO = new GameObject("AlchemistIcon");
			iconGO.transform.SetParent((Transform)(object)poi.IconContainer, false);
			RectTransform rect = iconGO.AddComponent<RectTransform>();
			rect.sizeDelta = new Vector2(20f, 20f);
			Image img = iconGO.AddComponent<Image>();
			img.sprite = Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f));
			((Graphic)img).color = Color.white;
			img.preserveAspect = true;
		}

		private static void SendAlchemistUnlockNotification()
		{
			MelonCoroutines.Start(SendAlchemistNotificationDelayed());
		}

		private static IEnumerator SendAlchemistNotificationDelayed()
		{
			yield return (object)new WaitForSeconds(2f);
			NotificationsManager nm = Singleton<NotificationsManager>.Instance;
			if ((Object)(object)nm == (Object)null)
			{
				MelonLogger.Warning("[Vendor] NotificationsManager not found.");
				yield break;
			}
			Sprite notifIcon = null;
			Texture2D tex = LoadCustomTexture("MagicJuice.png");
			if ((Object)(object)tex != (Object)null)
			{
				notifIcon = Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f));
			}
			nm.SendNotification("The Alchemist Table", "The alchemist table beckons you to pay a visit... You can find it on the map.", notifIcon, 8f, true);
		}

		private static void CreateAlchemistConversation()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				NPC val = null;
				foreach (NPC item in NPCManager.NPCRegistry)
				{
					if ((Object)(object)item != (Object)null)
					{
						val = item;
						break;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					MelonLogger.Warning("[Alchemist] No NPC found to clone.");
					return;
				}
				GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject);
				((Object)val2).name = "AlchemistFakeNPC";
				val2.transform.position = new Vector3(0f, -1000f, 0f);
				NPC component = val2.GetComponent<NPC>();
				component.FirstName = "The Alchemist Table";
				component.hasLastName = false;
				component.LastName = "";
				component.ID = "the_alchemist_vendor";
				val2.SetActive(false);
				Texture2D val3 = LoadCustomTexture("MagicJuice.png");
				if ((Object)(object)val3 != (Object)null)
				{
					Sprite value = Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f));
					typeof(NPC).GetField("MugshotSprite", BindingFlags.Instance | BindingFlags.Public)?.SetValue(component, value);
				}
				val2.SetActive(true);
				val2.SetActive(false);
				_alchemistConversation = new MSGConversation(component, "The Alchemist Table");
				_alchemistConversation.SetIsKnown(true);
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[Alchemist] Failed to create conversation: " + ex.Message + "\n" + ex.StackTrace);
			}
		}

		private static void SendAlchemistPhoneMessage()
		{
			if (_alchemistConversation == null)
			{
				MelonLogger.Warning("[Alchemist] Conversation not ready.");
			}
			else
			{
				MelonCoroutines.Start(SendAlchemistMessageDelayed());
			}
		}

		private static IEnumerator SendAlchemistMessageDelayed()
		{
			yield return (object)new WaitForSeconds(2f);
			try
			{
				Message msg = new Message("The alchemist table beckons you to pay a visit... You can find it on the map.", (ESenderType)1, true, Random.Range(int.MinValue, int.MaxValue));
				_alchemistConversation.SendMessage(msg, true, false);
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[Alchemist] Failed to send message: " + ex.Message + "\n" + ex.StackTrace);
			}
		}
	}
	public static class ModInfo
	{
		public const string Name = "Dom's Custom Effects";

		public const string Version = "1.1.0";

		public const string Author = "Dom";
	}
}
namespace DomsExpandedIngredientsAndEffects.Utilities
{
	public static class SoundHelper
	{
		public static float SFXVolume
		{
			get
			{
				try
				{
					AudioManager instance = Singleton<AudioManager>.Instance;
					return ((Object)(object)instance != (Object)null) ? instance.GetVolume((EAudioType)2, true) : 1f;
				}
				catch
				{
					return 1f;
				}
			}
		}

		public static float MusicVolume
		{
			get
			{
				try
				{
					AudioManager instance = Singleton<AudioManager>.Instance;
					return ((Object)(object)instance != (Object)null) ? instance.GetVolume((EAudioType)4, true) : 1f;
				}
				catch
				{
					return 1f;
				}
			}
		}
	}
	public static class WavUtility
	{
		public static AudioClip ToAudioClip(byte[] data, string name)
		{
			try
			{
				int num = data[22] | (data[23] << 8);
				int num2 = data[24] | (data[25] << 8) | (data[26] << 16) | (data[27] << 24);
				int num3 = data[34] | (data[35] << 8);
				int num4 = 44;
				for (int i = 12; i < data.Length - 4; i++)
				{
					if (data[i] == 100 && data[i + 1] == 97 && data[i + 2] == 116 && data[i + 3] == 97)
					{
						num4 = i + 8;
						break;
					}
				}
				int num5 = (data.Length - num4) / (num3 / 8);
				float[] array = new float[num5];
				switch (num3)
				{
				case 16:
				{
					for (int k = 0; k < num5; k++)
					{
						short num6 = (short)(data[num4 + k * 2] | (data[num4 + k * 2 + 1] << 8));
						array[k] = (float)num6 / 32768f;
					}
					break;
				}
				case 8:
				{
					for (int j = 0; j < num5; j++)
					{
						array[j] = (float)(data[num4 + j] - 128) / 128f;
					}
					break;
				}
				}
				AudioClip val = AudioClip.Create(name, num5 / num, num, num2, false);
				val.SetData(array, 0);
				return val;
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[WavUtility] Failed to parse " + name + ": " + ex.Message);
				return null;
			}
		}
	}
}
namespace DomsExpandedIngredientsAndEffects.Ingredients
{
	public class AirhornIngredient : CustomIngredient
	{
		public static PropertyItemDefinition Definition { get; private set; }

		public override string ID => "airhorn";

		public override string Name => "Airhorn";

		public override string IconFileName => "Airhorn.png";

		public override CustomEffect MixEffect => new AirhornBaseEffectDef();

		public override CustomEffect MapEffect => new AirhornMapEffectDef();

		public override Vector2 MapPosition => new Vector2(1.5f, -2f);

		public override float MapRadius => 0.45f;

		public override EDrugType TargetDrugType => (EDrugType)0;

		public new void Register(Registry registry, ProductManager productManager)
		{
			base.Register(registry, productManager);
			Definition = base.ItemDefinition;
		}
	}
	public class FertilizerIngredient : CustomIngredient
	{
		public static PropertyItemDefinition Definition { get; private set; }

		public override string ID => "dom_fertilizer";

		public override string Name => "Fertilizer";

		public override string IconFileName => "Fertilizer.png";

		public override CustomEffect MixEffect => new EarthyEffectDef();

		public override CustomEffect MapEffect => new FertilizerMapEffectDef();

		public override Vector2 MapPosition => new Vector2(2.5f, 2f);

		public override float MapRadius => 0.45f;

		public override EDrugType TargetDrugType => (EDrugType)0;

		public new void Register(Registry registry, ProductManager productManager)
		{
			base.Register(registry, productManager);
			Definition = base.ItemDefinition;
		}
	}
	public class HotSauceIngredient : CustomIngredient
	{
		public static PropertyItemDefinition Definition { get; private set; }

		public override string ID => "hotsauce";

		public override string Name => "Hot Sauce";

		public override string IconFileName => "HotSauce.png";

		public override CustomEffect MixEffect => new SpicyEffectDef();

		public override CustomEffect MapEffect => new HotSauceMapEffectDef();

		public override Vector2 MapPosition => new Vector2(-0.5f, -2.5f);

		public override float MapRadius => 0.45f;

		public override EDrugType TargetDrugType => (EDrugType)0;

		public new void Register(Registry registry, ProductManager productManager)
		{
			base.Register(registry, productManager);
			Definition = base.ItemDefinition;
		}
	}
	public class LipstickIngredient : CustomIngredient
	{
		public static PropertyItemDefinition Definition { get; private set; }

		public override string ID => "lipstick";

		public override string Name => "Lipstick";

		public override string IconFileName => "Lipstick.png";

		public override CustomEffect MixEffect => new VoluptuousEffectDef();

		public override CustomEffect MapEffect => new LipstickMapEffectDef();

		public override Vector2 MapPosition => new Vector2(-2f, 1.5f);

		public override float MapRadius => 0.45f;

		public override EDrugType TargetDrugType => (EDrugType)0;

		public new void Register(Registry registry, ProductManager productManager)
		{
			base.Register(registry, productManager);
			Definition = base.ItemDefinition;
		}
	}
	public class MagicJuiceIngredient : CustomIngredient
	{
		public static PropertyItemDefinition Definition { get; private set; }

		public override string ID => "magicjuice";

		public override string Name => "Magic Juice";

		public override string IconFileName => "MagicJuice.png";

		public override CustomEffect MixEffect => new MagicBaseEffectDef();

		public override CustomEffect MapEffect => new MagicJuiceMapEffectDef();

		public override Vector2 MapPosition => new Vector2(-3f, 1f);

		public override float MapRadius => 0.45f;

		public override EDrugType TargetDrugType => (EDrugType)0;

		public new void Register(Registry registry, ProductManager productManager)
		{
			base.Register(registry, productManager);
			Definition = base.ItemDefinition;
		}
	}
	public class MoonDustIngredient : CustomIngredient
	{
		public static PropertyItemDefinition Definition { get; private set; }

		public override string ID => "moondust";

		public override string Name => "Moon Dust";

		public override string IconFileName => "MoonDust.png";

		public override CustomEffect MixEffect => new HeliumInfusionEffect();

		public override CustomEffect MapEffect => new MoonGravityEffectDef();

		public override Vector2 MapPosition => new Vector2(0f, 3.5f);

		public override float MapRadius => 0.45f;

		public override EDrugType TargetDrugType => (EDrugType)0;

		public new void Register(Registry registry, ProductManager productManager)
		{
			base.Register(registry, productManager);
			Definition = base.ItemDefinition;
		}
	}
}
namespace DomsExpandedIngredientsAndEffects.Helpers
{
	public static class MelonLoggerExtensions
	{
		public static void Debug(this Instance logger, string message, bool stacktrace = true)
		{
			MelonDebug.Msg(stacktrace ? ("[" + GetCallerInfo() + "] " + message) : message);
		}

		private static string GetCallerInfo()
		{
			StackTrace stackTrace = new StackTrace();
			for (int i = 2; i < stackTrace.FrameCount; i++)
			{
				StackFrame frame = stackTrace.GetFrame(i);
				MethodBase method = frame.GetMethod();
				if (!(method?.DeclaringType == null))
				{
					return method.DeclaringType.FullName + "." + method.Name;
				}
			}
			return "unknown";
		}
	}
	public static class Il2CppListExtensions
	{
		public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
		{
			return list ?? Enumerable.Empty<T>();
		}

		public static object ToNativeList<T>(this List<T> source)
		{
			return source ?? new List<T>();
		}
	}
	public static class Utils
	{
		private static readonly Instance Logger = new Instance("DomsExpandedIngredientsAndEffects-Utils");

		public static T? FindObjectByName<T>(string objectName) where T : Object
		{
			try
			{
				T[] array = Resources.FindObjectsOfTypeAll<T>();
				foreach (T val in array)
				{
					if (!(((Object)val).name != objectName))
					{
						Logger.Msg("Found " + typeof(T).Name + " '" + objectName + "' directly in loaded objects");
						return val;
					}
				}
				return default(T);
			}
			catch (Exception ex)
			{
				Logger.Error("Error finding " + typeof(T).Name + " '" + objectName + "': " + ex.Message);
				return default(T);
			}
		}

		public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component
		{
			List<T> list = new List<T>();
			if ((Object)(object)obj == (Object)null)
			{
				return list;
			}
			T[] components = obj.GetComponents<T>();
			if (components.Length != 0)
			{
				list.AddRange(components);
			}
			for (int i = 0; i < obj.transform.childCount; i++)
			{
				Transform child = obj.transform.GetChild(i);
				list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject));
			}
			return list;
		}

		public static bool Is<T>(object obj, out T? result) where T : class
		{
			if (obj is T val)
			{
				result = val;
				return true;
			}
			result = null;
			return false;
		}

		public static IEnumerator WaitForPlayer(IEnumerator routine)
		{
			while ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
			{
				yield return null;
			}
			MelonCoroutines.Start(routine);
		}

		public static IEnumerator WaitForNetwork(IEnumerator routine)
		{
			while (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
			{
				yield return null;
			}
			MelonCoroutines.Start(routine);
		}

		public static IEnumerator WaitForCondition(Func<bool> condition, float timeout = float.NaN, Action? onTimeout = null, Action? onFinish = null)
		{
			float startTime = Time.time;
			while (!condition())
			{
				if (!float.IsNaN(timeout) && Time.time - startTime > timeout)
				{
					onTimeout?.Invoke();
					yield break;
				}
				yield return null;
			}
			onFinish?.Invoke();
		}

		public static string GetHierarchyPath(this Transform transform)
		{
			if ((Object)(object)transform == (Object)null)
			{
				return "null";
			}
			string text = ((Object)transform).name;
			Transform parent = transform.parent;
			while ((Object)(object)parent != (Object)null)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}

		public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
		{
			T component = gameObject.GetComponent<T>();
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
			component = gameObject.AddComponent<T>();
			Logger.Msg("Added component " + typeof(T).Name + " to GameObject " + ((Object)gameObject).name);
			return component;
		}

		public static Material? DrawDebugVisuals(this GameObject gameObject, Color? color = null)
		{
			//IL_0040: 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_006d: 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: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			Renderer component = gameObject.GetComponent<Renderer>();
			if ((Object)(object)component == (Object)null)
			{
				Logger.Error("GameObject " + ((Object)gameObject).name + " has no Renderer component");
				return null;
			}
			Color valueOrDefault = color.GetValueOrDefault();
			if (!color.HasValue)
			{
				((Color)(ref valueOrDefault))..ctor(1f, 0f, 1f, 0.5f);
				color = valueOrDefault;
			}
			Shader val = Shader.Find("Universal Render Pipeline/Lit");
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Material val2 = new Material(val);
			if (val2.HasProperty("_Surface"))
			{
				val2.SetFloat("_Surface", 1f);
			}
			Color value = color.Value;
			if (value.a <= 0f)
			{
				value.a = 0.2f;
			}
			if (val2.HasProperty("_BaseColor"))
			{
				val2.SetColor("_BaseColor", value);
			}
			if (val2.HasProperty("_EmissionColor"))
			{
				val2.EnableKeyword("_EMISSION");
				val2.SetColor("_EmissionColor", new Color(value.r, value.g, value.b) * 1.5f);
			}
			val2.SetInt("_ZWrite", 0);
			val2.renderQueue = 3000;
			Material material = component.material;
			component.material = val2;
			return material;
		}
	}
}
namespace DomsExpandedIngredientsAndEffects.Patches
{
	public class RegisteredCombination
	{
		public string ExistingEffectID { get; }

		public string IngredientEffectID { get; }

		public CustomEffect OutputEffect { get; }

		public Effect BuiltOutputEffect { get; }

		public RegisteredCombination(EffectCombination combo)
		{
			ExistingEffectID = combo.ExistingEffectID;
			IngredientEffectID = combo.IngredientEffectID;
			OutputEffect = combo.OutputEffect;
			BuiltOutputEffect = combo.OutputEffect.Build();
		}
	}
	public static class CustomMixRegistry
	{
		private static List<RegisteredCombination> _combinations;

		private static List<Effect> _outputEffects;

		private static List<MultiEffectCombination> _multiCombinations;

		public static List<RegisteredCombination> Combinations => _combinations ?? (_combinations = new List<RegisteredCombination>());

		public static List<Effect> OutputEffects => _outputEffects ?? (_outputEffects = new List<Effect>());

		public static List<MultiEffectCombination> MultiCombinations => _multiCombinations ?? (_multiCombinations = new List<MultiEffectCombination>());

		public static void Register(EffectCombination combo)
		{
			RegisteredCombination registeredCombination = new RegisteredCombination(combo);
			Combinations.Add(registeredCombination);
			OutputEffects.Add(registeredCombination.BuiltOutputEffect);
		}

		public static void Register(MultiEffectCombination combo)
		{
			MultiCombinations.Add(combo);
			OutputEffects.Add(combo.BuiltOutputEffect);
		}
	}
	public class MultiEffectCombination
	{
		public string[] RequiredEffectIDs { get; }

		public string IngredientEffectID { get; }

		public CustomEffect OutputEffect { get; }

		public Effect BuiltOutputEffect { get; }

		public MultiEffectCombination(string[] requiredEffectIDs, string ingredientEffectID, CustomEffect outputEffect)
		{
			RequiredEffectIDs = requiredEffectIDs;
			IngredientEffectID = ingredientEffectID;
			OutputEffect = outputEffect;
			BuiltOutputEffect = outputEffect.Build();
		}
	}
	[HarmonyPatch]
	public class StabilityFix
	{
		[HarmonyPatch]
		public class UIErrorHandler
		{
			private static MethodBase TargetMethod()
			{
				return (AccessTools.TypeByName("ScheduleOne.UI.NewMixScreen") ?? AccessTools.TypeByName("Il2CppScheduleOne.UI.NewMixScreen"))?.GetMethods().FirstOrDefault((MethodInfo m) => m.Name == "Open" && m.GetParameters().Length >= 2);
			}

			[HarmonyFinalizer]
			public static Exception Finalizer(Exception __exception)
			{
				if (__exception != null)
				{
					MelonLogger.Error("[STABILITY] UI Crash: " + __exception.Message);
				}
				return null;
			}
		}

		[HarmonyPatch(typeof(MixOperation), "IsOutputKnown")]
		public class MixOperation_IsOutputKnown_Patch
		{
			[HarmonyPrefix]
			public static bool Prefix(MixOperation __instance, ref ProductDefinition knownProduct, ref bool __result)
			{
				try
				{
					if (string.IsNullOrEmpty(__instance.ProductID) || string.IsNullOrEmpty(__instance.IngredientID))
					{
						return true;
					}
					ProductManager instance = NetworkSingleton<ProductManager>.Instance;
					if ((Object)(object)instance == (Object)null)
					{
						return true;
					}
					StationRecipe recipe = instance.GetRecipe(__instance.ProductID, __instance.IngredientID);
					if ((Object)(object)recipe != (Object)null)
					{
						ItemDefinition obj = recipe.Product?.Item;
						ProductDefinition val = (ProductDefinition)(object)((obj is ProductDefinition) ? obj : null);
						if (val != null)
						{
							knownProduct = val;
							__result = true;
							return false;
						}
					}
				}
				catch (Exception ex)
				{
					MelonLogger.Error("[STABILITY] IsOutputKnown error: " + ex.Message);
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(ProductManager), "GetRecipe", new Type[]
		{
			typeof(string),
			typeof(string)
		})]
		public class FixGetRecipePatch
		{
			[HarmonyPrefix]
			public static bool Prefix(ProductManager __instance, string product, string mixer, ref StationRecipe __result)
			{
				try
				{
					List<StationRecipe> mixRecipes = GetMixRecipes(__instance);
					if (mixRecipes == null)
					{
						return true;
					}
					foreach (StationRecipe item in mixRecipes)
					{
						if (item?.Ingredients != null && item.Ingredients.Count >= 2)
						{
							string text = ((BaseItemDefinition)(item.Ingredients[0].Items?[0]?)).ID;
							string text2 = ((BaseItemDefinition)(item.Ingredients[1].Items?[0]?)).ID;
							if ((text == product && text2 == mixer) || (text2 == product && text == mixer))
							{
								__result = item;
								return false;
							}
						}
					}
				}
				catch
				{
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(ProductManager), "GetRecipe", new Type[]
		{
			typeof(List<Effect>),
			typeof(Effect)
		})]
		public class FixGetRecipeOverloadPatch
		{
			[HarmonyPrefix]
			public static bool Prefix(ProductManager __instance, List<Effect> productProperties, Effect mixerProperty, ref StationRecipe __result)
			{
				try
				{
					if (productProperties == null || (Object)(object)mixerProperty == (Object)null)
					{
						return true;
					}
					List<StationRecipe> mixRecipes = GetMixRecipes(__instance);
					if (mixRecipes == null)
					{
						return true;
					}
					foreach (StationRecipe item in mixRecipes)
					{
						if (item?.Ingredients == null || item.Ingredients.Count < 2)
						{
							continue;
						}
						ItemDefinition obj = item.Ingredients[0].Items?[0];
						PropertyItemDefinition val = (PropertyItemDefinition)(object)((obj is PropertyItemDefinition) ? obj : null);
						ItemDefinition obj2 = item.Ingredients[1].Items?[0];
						PropertyItemDefinition val2 = (PropertyItemDefinition)(object)((obj2 is PropertyItemDefinition) ? obj2 : null);
						if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
						{
							continue;
						}
						List<Effect> list = ((item.Ingredients[1].Items[0] is ProductDefinition) ? val2.Properties : val.Properties);
						List<Effect> list2 = ((item.Ingredients[1].Items[0] is ProductDefinition) ? val.Properties : val2.Properties);
						if (list == null || list2 == null || list.Count != productProperties.Count || list2.Count != 1)
						{
							continue;
						}
						bool flag = true;
						foreach (Effect productProperty in productProperties)
						{
							if ((Object)(object)productProperty == (Object)null)
							{
								flag = false;
								break;
							}
							bool flag2 = false;
							foreach (Effect item2 in list)
							{
								if ((Object)(object)item2 != (Object)null && item2.ID == productProperty.ID)
								{
									flag2 = true;
									break;
								}
							}
							if (!flag2)
							{
								flag = false;
								break;
							}
						}
						if (!flag || !((Object)(object)list2[0] != (Object)null) || !(list2[0].ID == mixerProperty.ID))
						{
							continue;
						}
						__result = item;
						return false;
					}
				}
				catch
				{
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(ProductManager), "GetKnownProduct")]
		public class FixGetKnownProductPatch
		{
			[HarmonyPrefix]
			public static bool Prefix(ProductManager __instance, EDrugType type, List<Effect> properties, ref ProductDefinition __result)
			{
				//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)
				try
				{
					if (properties == null)
					{
						return true;
					}
					for (int num = __instance.AllProducts.Count - 1; num >= 0; num--)
					{
						ProductDefinition val = __instance.AllProducts[num];
						if (val?.DrugTypes != null && val.DrugTypes.Count != 0 && val.DrugTypes[0].DrugType == type && ((PropertyItemDefinition)val).Properties != null && ((PropertyItemDefinition)val).Properties.Count == properties.Count)
						{
							bool flag = true;
							foreach (Effect property in properties)
							{
								if ((Object)(object)property == (Object)null)
								{
									flag = false;
									break;
								}
								bool flag2 = false;
								foreach (Effect property2 in ((PropertyItemDefinition)val).Properties)
								{
									if ((Object)(object)property2 != (Object)null && property2.ID == property.ID)
									{
										flag2 = true;
										break;
									}
								}
								if (!flag2)
								{
									flag = false;
									break;
								}
							}
							if (flag)
							{
								__result = val;
								return false;
							}
						}
					}
				}
				catch (Exception ex)
				{
					MelonLogger.Error("[STABILITY] FixGetKnownProduct error: " + ex.Message);
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(EffectMixCalculator), "MixProperties")]
		public class DoubleMixUpgradePatch
		{
			[HarmonyPrefix]
			public static bool Prefix(List<Effect> __0, Effect __1, EDrugType __2, ref List<Effect> __result)
			{
				try
				{
					List<Effect> list = new List<Effect>();
					if (__0 != null)
					{
						foreach (Effect item in __0)
						{
							if ((Object)(object)item != (Object)null)
							{
								list.Add(item);
							}
						}
					}
					if ((Object)(object)__1 == (Object)null)
					{
						WriteBack(list, ref __result);
						return false;
					}
					string heliumID = "heliuminfusion";
					string moonGravityID = "moongravity";
					bool flag = false;
					foreach (RegisteredCombination combo2 in CustomMixRegistry.Combinations)
					{
						Effect val = EffectListFind(list, (Effect e) => e?.ID == combo2.ExistingEffectID);
						if ((Object)(object)val != (Object)null && __1.ID == combo2.IngredientEffectID)
						{
							int index = list.IndexOf(val);
							list[index] = combo2.BuiltOutputEffect;
							EffectListRemoveAll(list, (Effect e) => e?.ID == combo2.IngredientEffectID && (Object)(object)e != (Object)(object)combo2.BuiltOutputEffect);
							flag = true;
							break;
						}
						if (!(combo2.ExistingEffectID != combo2.IngredientEffectID))
						{
							continue;
						}
						Effect val2 = EffectListFind(list, (Effect e) => e?.ID == combo2.IngredientEffectID);
						if ((Object)(object)val2 != (Object)null && __1.ID == combo2.ExistingEffectID)
						{
							int index2 = list.IndexOf(val2);
							list[index2] = combo2.BuiltOutputEffect;
							EffectListRemoveAll(list, (Effect e) => e?.ID == combo2.ExistingEffectID && (Object)(object)e != (Object)(object)combo2.BuiltOutputEffect);
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						foreach (MultiEffectCombination combo in CustomMixRegistry.MultiCombinations)
						{
							bool flag2 = true;
							string[] requiredEffectIDs = combo.RequiredEffectIDs;
							foreach (string id2 in requiredEffectIDs)
							{
								if (!EffectListAny(list, (Effect e) => e?.ID == id2))
								{
									flag2 = false;
									break;
								}
							}
							bool flag3 = __1.ID == combo.IngredientEffectID;
							bool flag4 = EffectListAny(list, (Effect e) => e?.ID == combo.IngredientEffectID);
							if (!flag2 || !(flag3 || flag4))
							{
								continue;
							}
							string[] requiredEffectIDs2 = combo.RequiredEffectIDs;
							foreach (string id in requiredEffectIDs2)
							{
								EffectListRemoveAll(list, (Effect e) => e?.ID == id);
							}
							EffectListRemoveAll(list, (Effect e) => e?.ID == combo.IngredientEffectID);
							list.Add(combo.BuiltOutputEffect);
							flag = true;
							break;
						}
					}
					if (flag)
					{
						RunChainCheck(list);
						WriteBack(list, ref __result);
						return false;
					}
					if ((__1.ID == moonGravityID || __1.ID == heliumID) && EffectListAny(list, (Effect e) => (Object)(object)e != (Object)null && e.ID == heliumID))
					{
						ProductManager instance = NetworkSingleton<ProductManager>.Instance;
						Effect val3 = null;
						if (instance?.WeedMixMap?.Effects != null)
						{
							foreach (MixerMapEffect effect in instance.WeedMixMap.Effects)
							{
								if (effect?.Property?.ID == moonGravityID)
								{
									val3 = effect.Property;
									break;
								}
							}
						}
						if ((Object)(object)val3 == (Object)null && Singleton<PropertyUtility>.Instance?.AllProperties != null)
						{
							foreach (Effect allProperty in Singleton<PropertyUtility>.Instance.AllProperties)
							{
								if (allProperty?.ID == moonGravityID)
								{
									val3 = allProperty;
									break;
								}
							}
						}
						if ((Object)(object)val3 != (Object)null)
						{
							EffectListRemoveAll(list, (Effect e) => (Object)(object)e != (Object)null && (e.ID == heliumID || e.ID == __1.ID));
							list.Add(val3);
							int num = EffectListCount(list, (Effect e) => (Object)(object)e != (Object)null && e.ID == moonGravityID);
							if (num >= 2)
							{
								foreach (RegisteredCombination combination in CustomMixRegistry.Combinations)
								{
									if (combination.ExistingEffectID == moonGravityID && combination.IngredientEffectID == moonGravityID)
									{
										EffectListRemoveAll(list, (Effect e) => (Object)(object)e != (Object)null && e.ID == moonGravityID);
										list.Add(combination.BuiltOutputEffect);
										break;
									}
								}
							}
							RunChainCheck(list);
							WriteBack(list, ref __result);
							return false;
						}
					}
					return true;
				}
				catch (Exception ex)
				{
					MelonLogger.Error("[STABILITY] DoubleMixUpgrade error: " + ex.Message);
					return true;
				}
			}

			[HarmonyPostfix]
			public static void Postfix(List<Effect> __0, Effect __1, EDrugType __2, ref List<Effect> __result)
			{
				try
				{
					if (__result == null)
					{
						return;
					}
					List<Effect> list = new List<Effect>();
					foreach (Effect item in __result)
					{
						if ((Object)(object)item != (Object)null)
						{
							list.Add(item);
						}
					}
					RunChainCheck(list);
					WriteBack(list, ref __result);
				}
				catch (Exception ex)
				{
					MelonLogger.Error("[STABILITY] MixProperties Postfix error: " + ex.Message);
				}
			}

			private static void WriteBack(List<Effect> r, ref List<Effect> __result)
			{
				__result = r;
			}

			private static void RunChainCheck(List<Effect> result)
			{
				bool flag = true;
				while (flag)
				{
					flag = false;
					foreach (RegisteredCombination combo in CustomMixRegistry.Combinations)
					{
						Effect val = EffectListFind(result, (Effect e) => e?.ID == combo.ExistingEffectID);
						Effect val2 = EffectListFind(result, (Effect e) => e?.ID == combo.IngredientEffectID);
						if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)val != (Object)(object)val2)
						{
							int index = result.IndexOf(val);
							result[index] = combo.BuiltOutputEffect;
							result.Remove(val2);
							flag = true;
							break;
						}
					}
					if (flag)
					{
						continue;
					}
					foreach (MultiEffectCombination combo2 in CustomMixRegistry.MultiCombinations)
					{
						bool flag2 = true;
						string[] requiredEffectIDs = combo2.RequiredEffectIDs;
						foreach (string id2 in requiredEffectIDs)
						{
							if (!EffectListAny(result, (Effect e) => e?.ID == id2))
							{
								flag2 = false;
								break;
							}
						}
						Effect val3 = EffectListFind(result, (Effect e) => e?.ID == combo2.IngredientEffectID);
						if (!flag2 || !((Object)(object)val3 != (Object)null))
						{
							continue;
						}
						string[] requiredEffectIDs2 = combo2.RequiredEffectIDs;
						foreach (string id in requiredEffectIDs2)
						{
							EffectListRemoveAll(result, (Effect e) => e?.ID == id);
						}
						result.Remove(val3);
						result.Add(combo2.BuiltOutputEffect);
						flag = true;
						break;
					}
				}
			}
		}

		[HarmonyPatch(typeof(PropertyUtility), "GetProperties", new Type[] { typeof(List<string>) })]
		public class FixPropertyUtilityGetProperties
		{
			[HarmonyPostfix]
			public static void Postfix(List<string> __0, ref List<Effect> __result)
			{
				if (__0 == null || __result == null)
				{
					return;
				}
				List<Effect> list = __result;
				if (list.Count == __0.Count)
				{
					return;
				}
				ProductManager instance = NetworkSingleton<ProductManager>.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					return;
				}
				foreach (string id in __0)
				{
					if (!EffectListAny(list, (Effect e) => (Object)(object)e != (Object)null && e.ID == id))
					{
						Effect val = FindEffectInMixMaps(instance, id) ?? FindEffectInIngredients(instance, id) ?? OutputEffectsFirstOrDefault(id);
						if ((Object)(object)val != (Object)null)
						{
							list.Add(val);
						}
						else
						{
							MelonLogger.Warning("[STABILITY] Could not recover effect ID: " + id);
						}
					}
				}
				__result = list;
			}

			private static Effect FindEffectInMixMaps(ProductManager pm, string id)
			{
				MixerMap[] array = (MixerMap[])(object)new MixerMap[4] { pm.WeedMixMap, pm.MethMixMap, pm.CokeMixMap, pm.ShroomMixMap };
				MixerMap[] array2 = array;
				foreach (MixerMap val in array2)
				{
					if (val?.Effects == null)
					{
						continue;
					}
					foreach (MixerMapEffect effect in val.Effects)
					{
						if (effect?.Property?.ID == id)
						{
							return effect.Property;
						}
					}
				}
				return null;
			}

			private static Effect FindEffectInIngredients(ProductManager pm, string id)
			{
				if (pm.ValidMixIngredients == null)
				{
					return null;
				}
				foreach (PropertyItemDefinition validMixIngredient in pm.ValidMixIngredients)
				{
					if (validMixIngredient?.Properties == null)
					{
						continue;
					}
					foreach (Effect property in validMixIngredient.Properties)
					{
						if (property?.ID == id)
						{
							return property;
						}
					}
				}
				return null;
			}
		}

		[HarmonyPatch(typeof(Contract), "SubmitPayment")]
		public class ProfitBoostPatch
		{
			[HarmonyPrefix]
			public static void Prefix(Contract __instance, ref float bonusTotal)
			{
				if (ProfitBoostEffect.IsActive)
				{
					float num = __instance.Payment * 0.15f;
					bonusTotal += num;
				}
			}
		}

		[HarmonyPatch(typeof(DealCompletionPopup), "PlayPopup")]
		public class ProfitBoostPopupPatch
		{
			[HarmonyPrefix]
			public static void Prefix(float basePayment, ref List<BonusPayment> bonuses)
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Expected O, but got Unknown
				if (ProfitBoostEffect.IsActive)
				{
					float num = basePayment * 0.15f;
					bonuses = new List<BonusPayment>(bonuses);
					bonuses.Add(new BonusPayment("Magic Juice +15%", num));
				}
			}
		}

		private static readonly BindingFlags _private = BindingFlags.Instance | BindingFlags.NonPublic;

		private static bool _isProcessing = false;

		private static bool _mixNamedFired = false;

		private static bool _mixNamedRunning = false;

		private static string _mixRecipesFieldName = null;

		private static bool EffectListAny(IEnumerable<Effect> list, Func<Effect, bool> pred)
		{
			if (list == null)
			{
				return false;
			}
			foreach (Effect item in list)
			{
				if (pred(item))
				{
					return true;
				}
			}
			return false;
		}

		private static Effect EffectListFind(IEnumerable<Effect> list, Func<Effect, bool> pred)
		{
			if (list == null)
			{
				return null;
			}
			foreach (Effect item in list)
			{
				if (pred(item))
				{
					return item;
				}
			}
			return null;
		}

		private static int EffectListCount(IEnumerable<Effect> list, Func<Effect, bool> pred)
		{
			int num = 0;
			if (list == null)
			{
				return num;
			}
			foreach (Effect item in list)
			{
				if (pred(item))
				{
					num++;
				}
			}
			return num;
		}

		private static void EffectListRemoveAll(List<Effect> list, Func<Effect, bool> pred)
		{
			if (list == null)
			{
				return;
			}
			for (int num = list.Count - 1; num >= 0; num--)
			{
				if (pred(list[num]))
				{
					list.RemoveAt(num);
				}
			}
		}

		private static Effect OutputEffectsFirstOrDefault(string id)
		{
			foreach (Effect outputEffect in CustomMixRegistry.OutputEffects)
			{
				if (outputEffect?.ID == id)
				{
					return outputEffect;
				}
			}
			return null;
		}

		private static List<StationRecipe> GetMixRecipes(ProductManager pm)
		{
			if (_mixRecipesFieldName != null)
			{
				FieldInfo field = typeof(ProductManager).GetField(_mixRecipesFieldName, BindingFlags.Instance | BindingFlags.NonPublic);
				if (field != null && field.GetValue(pm) is List<StationRecipe> result)
				{
					return result;
				}
			}
			FieldInfo fieldInfo = AccessTools.Field(typeof(ProductManager), "mixRecipes");
			if (fieldInfo != null && fieldInfo.GetValue(pm) is List<StationRecipe> result2)
			{
				_mixRecipesFieldName = "mixRecipes";
				return result2;
			}
			FieldInfo[] fields = typeof(ProductManager).GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo2 in fields)
			{
				if (fieldInfo2.FieldType == typeof(List<StationRecipe>) && fieldInfo2.GetValue(pm) is List<StationRecipe> result3)
				{
					_mixRecipesFieldName = fieldInfo2.Name;
					MelonLogger.Msg("[STABILITY] Found mixRecipes field: " + fieldInfo2.Name);
					return result3;
				}
			}
			MelonLogger.Warning("[STABILITY] Could not find mixRecipes field.");
			return null;
		}

		[HarmonyPatch(typeof(MixingStationCanvas), "MixingDone")]
		[HarmonyPrefix]
		public static bool MixingDonePrefix()
		{
			if (_isProcessing)
			{
				return false;
			}
			_isProcessing = true;
			MelonCoroutines.Start(ReleaseLock());
			return true;
		}

		[HarmonyPatch(typeof(MixingStationCanvas), "MixingDone")]
		[HarmonyFinalizer]
		public static Exception MixingDoneFinalizer(Exception __exception)
		{
			if (__exception != null)
			{
				MelonLogger.Error("[STABILITY] MixingDone crash: " + __exception.Message + "\n" + __exception.StackTrace);
			}
			return null;
		}

		private static IEnumerator ReleaseLock()
		{
			yield return (object)new WaitForSeconds(1.5f);
			_isProcessing = false;
		}

		[HarmonyPatch(typeof(MixingStationCanvas), "Open")]
		[HarmonyPostfix]
		public static void OpenPostfix()
		{
			_mixNamedFired = false;
			_mixNamedRunning = false;
		}

		[HarmonyPatch(typeof(MixingStationCanvas), "MixNamed")]
		[HarmonyPrefix]
		public static bool MixNamedPrefix(MixingStationCanvas __instance, string mixName)
		{
			if (_mixNamedRunning)
			{
				return false;
			}
			_mixNamedRunning = true;
			NewMixScreen instance = Singleton<NewMixScreen>.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				typeof(NewMixScreen).GetField("onMixNamed", BindingFlags.Instance | BindingFlags.Public)?.SetValue(instance, null);
			}
			MelonCoroutines.Start(MixNamedDelayed(__instance, mixName));
			return false;
		}

		private static IEnumerator MixNamedDelayed(MixingStationCanvas canvas, string mixName)
		{
			if ((Object)(object)canvas.MixingStation == (Object)null || canvas.MixingStation.CurrentMixOperation == null)
			{
				_mixNamedRunning = false;
				yield break;
			}
			string productID = canvas.MixingStation.CurrentMixOperation.ProductID;
			string ingredientID = canvas.MixingStation.CurrentMixOperation.IngredientID;
			int quantity = canvas.MixingStation.CurrentMixOperation.Quantity;
			EQuality quality = canvas.MixingStation.CurrentMixOperation.ProductQuality;
			NetworkSingleton<ProductManager>.Instance.FinishAndNameMix(productID, ingredientID, mixName);
			yield return null;
			yield return null;
			ProductDefinition knownProduct = default(ProductDefinition);
			if (canvas.MixingStation.CurrentMixOperation != null && canvas.MixingStation.CurrentMixOperation.IsOutputKnown(ref knownProduct))
			{
				canvas.MixingStation.TryCreateOutputItems();
			}
			else
			{
				try
				{
					ProductDefinition baseProduct = Registry.GetItem<ProductDefinition>(productID);
					PropertyItemDefinition ingredient = Registry.GetItem<PropertyItemDefinition>(ingredientID);
					if ((Object)(object)baseProduct == (Object)null || (Object)(object)ingredient == (Object)null || ingredient.Properties.Count == 0)
					{
						_mixNamedRunning = false;
						yield break;
					}
					List<Effect> outputProperties = EffectMixCalculator.MixProperties(((PropertyItemDefinition)baseProduct).Properties, ingredient.Properties[0], baseProduct.DrugType);
					ProductDefinition outputProduct = Object.Instantiate<ProductDefinition>(baseProduct);
					((Object)outputProduct).name = mixName;
					((BaseItemDefinition)outputProduct).Name = mixName;
					((PropertyItemDefinition)outputProduct).Initialize(outputProperties);
					outputProduct.GenerateAppearanceSettings();
					((BaseItemDefinition)outputProduct).ID = ProductManager.MakeIDFileSafe(mixName);
					if (!Registry.ItemExists(((BaseItemDefinition)outputProduct).ID))
					{
						Singleton<Registry>.Instance.AddToRegistry((ItemDefinition)(object)outputProduct);
					}
					ProductManager pm = NetworkSingleton<ProductManager>.Instance;
					if ((Object)(object)pm != (Object)null)
					{
						if (!pm.AllProducts.Contains(outputProduct))
						{
							pm.AllProducts.Add(outputProduct);
						}
						if (!ProductManager.DiscoveredProducts.Contains(outputProduct))
						{
							ProductManager.DiscoveredProducts.Add(outputProduct);
						}
						if (!pm.ProductNames.Contains(mixName))
						{
							pm.ProductNames.Add(mixName);
						}
						pm.SetPrice((NetworkConnection)null, ((BaseItemDefinition)outputProduct).ID, outputProduct.MarketValue);
						pm.CreateMixRecipe((NetworkConnection)null, ((BaseItemDefinition)baseProduct).ID, ((BaseItemDefinition)ingredient).ID, ((BaseItemDefinition)outputProduct).ID);
					}
					ItemInstance defaultInstance = ((ItemDefinition)outputProduct).GetDefaultInstance(quantity);
					QualityItemInstance outputInstance = (QualityItemInstance)(object)((defaultInstance is QualityItemInstance) ? defaultInstance : null);
					outputInstance.SetQuality(quality);
					canvas.MixingStation.OutputSlot.AddItem((ItemInstance)(object)outputInstance, false);
					canvas.MixingStation.SetMixOperation((NetworkConnection)null, (MixOperation)null, 0);
				}
				catch (Exception ex2)
				{
					Exception ex = ex2;
					MelonLogger.Error("[STABILITY] Manual output failed: " + ex.Message);
					_mixNamedRunning = false;
					yield break;
				}
			}
			float elapsed = 0f;
			while (canvas.MixingStation.OutputSlot.Quantity == 0)
			{
				elapsed += Time.deltaTime;
				if (elapsed >= 3f)
				{
					break;
				}
				yield return null;
			}
			((Component)canvas.MixingStation.DiscoveryBox).gameObject.SetActive(false);
			((Behaviour)canvas.Canvas).enabled = true;
			((Component)canvas.Container).gameObject.SetActive(true);
			_mixNamedFired = true;
			Type type = typeof(MixingStationCanvas);
			type.GetMethod("UpdateDisplayMode", _private)?.Invoke(canvas, null);
			type.GetMethod("UpdateInstruction", _private)?.Invoke(canvas, null);
			type.GetMethod("UpdatePreview", _private)?.Invoke(canvas, null);
			type.GetMethod("UpdateBeginButton", _private)?.Invoke(canvas, null);
			_mixNamedRunning = false;
		}

		[HarmonyPatch(typeof(MixingStationCanvas), "UpdateDisplayMode")]
		[HarmonyPostfix]
		public static void UpdateDisplayModePostfix(MixingStationCanvas __instance)
		{
			if (!_mixNamedFired)
			{
				return;
			}
			try
			{
				if (!((Component)__instance.TitleContainer).gameObject.activeSelf && !((Component)__instance.MainContainer).gameObject.activeSelf && !((Component)__instance.OutputSlotUI).gameObject.activeSelf)
				{
					((Component)__instance.TitleContainer).gameObject.SetActive(true);
					((Component)__instance.MainContainer).gameObject.SetActive(true);
					_mixNamedFired = false;
				}
			}
			catch
			{
			}
		}
	}
}
namespace DomsExpandedIngredientsAndEffects.Framework
{
	public abstract class CustomEffect
	{
		public abstract string ID { get; }

		public abstract string Name { get; }

		public abstract Color Color { get; }

		public virtual Vector2 MixDirection => Vector2.up;

		public virtual float MixMagnitude => 0.45f;

		public virtual float Addictiveness => 0.1f;

		public virtual int ValueChange => 0;

		public virtual float ValueMultiplier => 1f;

		public abstract Effect CreateInstance();

		public Effect Build()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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)
			Effect val = CreateInstance();
			((Object)val).name = ID;
			val.Name = Name;
			val.ID = ID;
			val.ProductColor = Color;
			val.LabelColor = Color;
			val.MixDirection = MixDirection;
			val.MixMagnitude = MixMagnitude;
			val.Addictiveness = Addictiveness;
			val.ValueChange = ValueChange;
			val.ValueMultiplier = ValueMultiplier;
			return val;
		}

		protected static Effect CreateEffectInstance(Type type)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			return (Effect)ScriptableObject.CreateInstance(type.Name);
		}
	}
	public abstract class CustomIngredient
	{
		public abstract string ID { get; }

		public abstract string Name { get; }

		public abstract string IconFileName { get; }

		public abstract CustomEffect MixEffect { get; }

		public abstract CustomEffect MapEffect { get; }

		public abstract Vector2 MapPosition { get; }

		public abstract float MapRadius { get; }

		public abstract EDrugType TargetDrugType { get; }

		public PropertyItemDefinition ItemDefinition { get; private set; }

		public void Register(Registry registry, ProductManager productManager)
		{
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			try
			{
				Effect item = MixEffect.Build();
				Effect property = MapEffect.Build();
				PropertyItemDefinition item2 = Registry.GetItem<PropertyItemDefinition>("iodine");
				if ((Object)(object)item2 == (Object)null)
				{
					MelonLogger.Error("[" + Name + "] Could not find iodine template.");
					return;
				}
				ItemDefinition = Object.Instantiate<PropertyItemDefinition>(item2);
				((Object)ItemDefinition).name = ID;
				((BaseItemDefinition)ItemDefinition).Name = Name;
				((BaseItemDefinition)ItemDefinition).ID = ID;
				ItemDefinition.Properties = new List<Effect> { item };
				if (IconFileName != null)
				{
					((BaseItemDefinition)ItemDefinition).Icon = DomsCustomEffects.LoadCustomIcon(IconFileName);
				}
				registry.AddToRegistry((ItemDefinition)(object)ItemDefinition);
				productManager.ValidMixIngredients.Add(ItemDefinition);
				MixerMap mixerMap = productManager.GetMixerMap(TargetDrugType);
				if ((Object)(object)mixerMap != (Object)null)
				{
					mixerMap.Effects.Add(new MixerMapEffect
					{
						Property = property,
						Position = MapPosition,
						Radius = MapRadius
					});
				}
				else
				{
					MelonLogger.Warning($"[{Name}] MixerMap not found for {TargetDrugType}.");
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[" + Name + "] Registration failed: " + ex.Message + "\n" + ex.StackTrace);
			}
		}
	}
	public class EffectCombination
	{
		public string ExistingEffectID { get; }

		public string IngredientEffectID { get; }

		public CustomEffect OutputEffect { get; }

		public float OutputRadius { get; }

		public EffectCombination(string existingEffectID, string ingredientEffectID, CustomEffect outputEffect, float outputRadius = 0.45f)
		{
			ExistingEffectID = existingEffectID;
			IngredientEffectID = ingredientEffectID;
			OutputEffect = outputEffect;
			OutputRadius = outputRadius;
		}
	}
}
namespace DomsExpandedIngredientsAndEffects.Effects
{
	public class AirhornBaseEffect : Effect
	{
		private static AudioClip _airhornClip;

		public override void ApplyToPlayer(Player player)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)player == (Object)null) && ((NetworkBehaviour)player).IsOwner)
			{
				PlayAirhorn(((Component)player).transform.position);
			}
		}

		public override void ClearFromPlayer(Player player)
		{
		}

		public override void ApplyToNPC(NPC npc)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)npc == (Object)null))
			{
				PlayAirhorn(((Component)npc).transform.position);
			}
		}

		public override void ClearFromNPC(NPC npc)
		{
		}

		private static void PlayAirhorn(Vector3 position)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_airhornClip == (Object)null)
			{
				_airhornClip = DomsCustomEffects.LoadCustomSound("Airhorn.wav");
			}
			if ((Object)(object)_airhornClip == (Object)null)
			{
				MelonLogger.Warning("[Airhorn] Airhorn.wav not found in Sounds folder.");
			}
			else
			{
				AudioSource.PlayClipAtPoint(_airhornClip, position, SoundHelper.SFXVolume);
			}
		}
	}
	internal static class AirhornVisuals
	{
		internal static IEnumerator ThunderFlash()
		{
			GameObject go = FertilizerVisuals.CreateScreenOverlay(new Color(0.75f, 0.9f, 1f, 0f));
			Image img = go.GetComponentInChildren<Image>();
			for (float t2 = 0f; t2 < 0.08f; t2 += Time.deltaTime)
			{
				if ((Object)(object)img != (Object)null)
				{
					((Graphic)img).color = new Color(0.75f, 0.9f, 1f, Mathf.Clamp01(t2 / 0.08f));
				}
				yield return null;
			}
			if ((Object)(object)img != (Object)null)
			{
				((Graphic)img).color = new Color(0.75f, 0.9f, 1f, 1f);
			}
			yield return (object)new WaitForSeconds(0.05f);
			for (float t = 0f; t < 0.45f; t += Time.deltaTime)
			{
				if ((Object)(object)img != (Object)null)
				{
					((Graphic)img).color = new Color(0.75f, 0.9f, 1f, Mathf.Clamp01(1f - t / 0.45f));
				}
				yield return null;
			}
			if ((Object)(object)go != (Object)null)
			{
				Object.Destroy((Object)(object)go);
			}
		}
	}
	public class ThunderclapEffect : Effect
	{
		private static readonly Dictionary<int, GameObject> _overlays = new Dictionary<int, GameObject>();

		public override void ApplyToPlayer(Player player)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			int instanceID = ((Object)((Component)player).transform).GetInstanceID();
			if (_overlays.ContainsKey(instanceID))
			{
				return;
			}
			try
			{
				MelonCoroutines.Start(AirhornVisuals.ThunderFlash());
				_overlays[instanceID] = FertilizerVisuals.CreateScreenOverlay(new Color(0.1f, 0.25f, 0.85f, 0.08f));
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[Thunderclap] Apply failed: " + ex.Message);
			}
		}

		public override void ClearFromPlayer(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			int instanceID = ((Object)((Component)player).transform).GetInstanceID();
			if (_overlays.TryGetValue(instanceID, out var value))
			{
				if ((Object)(object)value != (Object)null)
				{
					Object.Destroy((Object)(object)value);
				}
				_overlays.Remove(instanceID);
			}
		}

		public override void ApplyToNPC(NPC npc)
		{
		}

		public override void ClearFromNPC(NPC npc)
		{
		}
	}
	public class WhiteNoiseEffect : Effect
	{
		private static readonly Dictionary<int, GameObject> _overlays = new Dictionary<int, GameObject>();

		private static readonly Dictionary<int, float> _npcSpeeds = new Dictionary<int, float>();

		public override void ApplyToPlayer(Player player)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			int instanceID = ((Object)((Component)player).transform).GetInstanceID();
			if (_overlays.ContainsKey(instanceID))
			{
				return;
			}
			try
			{
				_overlays[instanceID] = FertilizerVisuals.CreateScreenOverlay(new Color(0.55f, 0.55f, 0.55f, 0.32f));
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[WhiteNoise] Apply failed: " + ex.Message);
			}
		}

		public override void ClearFromPlayer(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			int instanceID = ((Object)((Component)player).transform).GetInstanceID();
			if (_overlays.TryGetValue(instanceID, out var value))
			{
				if ((Object)(object)value != (Object)null)
				{
					Object.Destroy((Object)(object)value);
				}
				_overlays.Remove(instanceID);
			}
		}

		public override void ApplyToNPC(NPC npc)
		{
			if ((Object)(object)npc == (Object)null)
			{
				return;
			}
			int instanceID = ((Object)((Component)npc).transform).GetInstanceID();
			try
			{
				NavMeshAgent component = ((Component)npc).GetComponent<NavMeshAgent>();
				if ((Object)(object)component != (Object)null)
				{
					_npcSpeeds[instanceID] = component.speed;
					component.speed *= 0.45f;
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[WhiteNoise] NPC slow failed: " + ex.Message);
			}
		}

		public override void ClearFromNPC(NPC npc)
		{
			if ((Object)(object)npc == (Object)null)
			{
				return;
			}
			int instanceID = ((Object)((Component)npc).transform).GetInstanceID();
			try
			{
				NavMeshAgent component = ((Component)npc).GetComponent<NavMeshAgent>();
				if ((Object)(object)component != (Object)null && _npcSpeeds.TryGetValue(instanceID, out var value))
				{
					component.speed = value;
					_npcSpeeds.Remove(instanceID);
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[WhiteNoise] NPC restore failed: " + ex.Message);
			}
		}
	}
	public class AirhornMapEffect : Effect
	{
		public override void ApplyToNPC(NPC npc)
		{
		}

		public override void ClearFromNPC(NPC npc)
		{
		}

		public override void ApplyToPlayer(Player player)
		{
		}

		public override void ClearFromPlayer(Player player)
		{
		}
	}
	public class AlienEffect : Effect
	{
		private const string STACK_KEY = "alien";

		private static readonly Color AlienGreen = new Color(0.4f, 0.55f, 0.3f);

		public override void ApplyToPlayer(Player player)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null || !((NetworkBehaviour)player).IsOwner)
			{
				return;
			}
			Avatar avatar = player.Avatar;
			if (avatar != null)
			{
				AvatarEffects effects = avatar.Effects;
				if (effects != null)
				{
					effects.SkinColorSmoother.AddOverride(AlienGreen, 7, "alien");
				}
			}
		}

		public override void ClearFromPlayer(Player player)
		{
			if ((Object)(object)player == (Object)null || !((NetworkBehaviour)player).IsOwner)
			{
				return;
			}
			Avatar avatar = player.Avatar;
			if (avatar != null)
			{
				AvatarEffects effects = avatar.Effects;
				if (effects != null)
				{
					effects.SkinColorSmoother.RemoveOverride("alien");
				}
			}
		}

		public override void ApplyToNPC(NPC npc)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)npc == (Object)null)
			{
				return;
			}
			Avatar avatar = npc.Avatar;
			if (avatar != null)
			{
				AvatarEffects effects = avatar.Effects;
				if (effects != null)
				{
					effects.SkinColorSmoother.AddOverride(AlienGreen, 7, "alien");
				}
			}
		}

		public override void ClearFromNPC(NPC npc)
		{
			if ((Object)(object)npc == (Object)null)
			{
				return;
			}
			Avatar avatar = npc.Avatar;
			if (avatar != null)
			{
				AvatarEffects effects = avatar.Effects;
				if (effects != null)
				{
					effects.SkinColorSmoother.RemoveOverride("alien");
				}
			}
		}
	}
	public class BunnyEffect : Effect
	{
		private const string STACK_KEY = "bunny";

		public override void ApplyToPlayer(Player player)
		{
			if (!((Object)(object)player == (Object)null) && ((NetworkBehaviour)player).IsOwner)
			{
				PlayerMovement.JumpMultiplier = 2f;
				PlayerMovement.GravityMultiplier = 1f;
			}
		}

		public override void ClearFromPlayer(Player player)
		{
			if (!((Object)(object)player == (Object)null) && ((NetworkBehaviour)player).IsOwner)
			{
				PlayerMovement.JumpMultiplier = 1f;
				PlayerMovement.GravityMultiplier = 1f;
			}
		}

		public override void ApplyToNPC(NPC npc)
		{
		}

		public override void ClearFromNPC(NPC npc)
		{
		}
	}
	public class ChargedEffect : Effect
	{
		private const string STACK_KEY = "charged";

		private static readonly Color ElectricYellow = new Color(1f, 0.95f, 0.1f);

		public override void ApplyToPlayer(Player player)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)player == (Object)null) && ((NetworkBehaviour)player).IsOwner)
			{
				AvatarEffects val = player.Avatar?.Effects;
				if (!((Object)(object)val == (Object)null))
				{
					PlayerMovement.StaticMoveSpeedMultiplier = 1.3f;
					val.OverrideEyeColor(ElectricYellow, 0.6f, true);
					val.SetGlowingOn(new Color(0.5f, 0.5f, 0f), true);
					val.SetZapped(true, true);
				}
			}
		}

		public override void ClearFromPlayer(Player player)
		{
			if (!((Object)(object)player == (Object)null) && ((NetworkBehaviour)player).IsOwner)
			{
				AvatarEffects val = player.Avatar?.Effects;
				if (!((Object)(object)val == (Object)null))
				{
					PlayerMovement.StaticMoveSpeedMultiplier = 1f;
					val.ResetEyeColor(true);
					val.SetGlowingOff(true);
					val.SetZapped(false, true);
				}
			}
		}

		public override void ApplyToNPC(NPC npc)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)npc == (Object)null)
			{
				return;
			}
			AvatarEffects val = npc.Avatar?.Effects;
			if (!((Object)(object)val == (Object)null))
			{
				if ((Object)(object)npc.Movement?.SpeedController != (Object)null)
				{
					npc.Movement.SpeedController.SpeedMultiplier = 1.3f;
				}
				val.OverrideEyeColor(ElectricYellow, 0.6f, true);
				val.SetGlowingOn(new Color(0.5f, 0.5f, 0f), true);
				val.SetZapped(true, true);
			}
		}

		public override void ClearFromNPC(NPC npc)
		{
			if ((Object)(object)npc == (Object)null)
			{
				return;
			}
			AvatarEffects val = npc.Avatar?.Effects;
			if (!((Object)(object)val == (Object)null))
			{
				if ((Object)(object)npc.Movement?.SpeedController != (Object)null)
				{
					npc.Movement.SpeedController.SpeedMultiplier = 1f;
				}
				val.ResetEyeColor(true);
				val.SetGlowingOff(true);
				val.SetZapped(false, true);
			}
		}
	}
	public class CreepyEffect : Effect
	{
		private static AudioClip _creepyClip;

		private static bool _playerPlaying;

		public override void ApplyToPlayer(Player player)
		{
			if (!((Object)(object)player == (Object)null) && ((NetworkBehaviour)player).IsOwner && !_playerPlaying)
			{
				_playerPlaying = true;
				MelonCoroutines.Start(PlayCreepyLoop(((Component)player).transform, isPlayer: true));
			}
		}

		public override void ClearFromPlayer(Player player)
		{
			_playerPlaying = false;
		}

		public override void ApplyToNPC(NPC npc)
		{
			if (!((Object)(object)npc == (Object)null))
			{
				MelonCoroutines.Start(PlayCreepyLoop(((Component)npc).transform, isPlayer: false));
			}
		}

		public override void ClearFromNPC(NPC npc)
		{
		}

		private static IEnumerator PlayCreepyLoop(Transform target, bool isPlayer)
		{
			if ((Object)(object)_creepyClip == (Object)null)
			{
				_creepyClip = DomsCustomEffects.LoadCustomSound("Creepy.wav");
			}
			if ((Object)(object)_creepyClip == (Object)null)
			{
				MelonLogger.Warning("[Creepy] Creepy.wav not found.");
			}
			else
			{
				AudioSource.PlayClipAtPoint(_creepyClip, target.position, SoundHelper.MusicVolume);
			}
			yield break;
		}
	}
	internal static class CrossEffectVisuals
	{
		internal static GameObject SpawnPinkFire(Transform root)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002e: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: 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_026b: Expected O, but got Unknown
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("CrossFX_PinkFire");
			val.transform.SetParent(root);
			val.transform.localPosition = new Vector3(0f, 0.1f, 0f);
			val.transform.localRotation = Quaternion.identity;
			GameObject val2 = new GameObject("PinkFire_Particles");
			val2.transform.SetParent(val.transform);
			val2.transform.localPosition = Vector3.zero;
			val2.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
			ParticleSystem val3 = val2.AddComponent<ParticleSystem>();
			MainModule main = val3.main;
			((MainModule)(ref main)).duration = 999f;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1.2f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0.5f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.03f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.2f, 0.6f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.12f);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			EmissionModule emission = val3.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(160f);
			ShapeModule shape = val3.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 35f;
			((ShapeModule)(ref shape)).radius = 0.35f;
			ColorOverLifetimeModule colorOverLifetime = val3.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val4 = new Gradient();
			val4.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(new Color(1f, 0.8f, 0.9f), 0f),
				new GradientColorKey(new Color(1f, 0.2f, 0.6f), 0.4f),
				new Gradient