Decompiled source of SnowyCraftingCore v1.1.0

plugins/Snowlance.SnowyCraftingCore.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Dawn;
using Dusk;
using GameNetcodeStuff;
using HarmonyLib;
using InjectionLibrary.Attributes;
using Microsoft.CodeAnalysis;
using Snowlance.SnowyCraftingCore.NetcodePatcher;
using SnowyCraftingCore.Interfaces;
using SnowyCraftingCore.TerminalAdditions;
using SnowyCraftingCore.Unlockables;
using SnowyLib;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RequiresInjections]
[assembly: HandleErrors(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: AssemblyCompany("Snowlance.SnowyCraftingCore")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+7c04ec08750bc192d139d06638d3c8a200ac33c7")]
[assembly: AssemblyProduct("SnowyCraftingCore")]
[assembly: AssemblyTitle("Snowlance.SnowyCraftingCore")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SnowyCraftingCore
{
	public class AnalyzableIngredient : ChemistryIngredient, IEquatable<AnalyzableIngredient>
	{
		public Action<AnalyzableIngredient, PlayerControllerB> result;

		public bool holdItem;

		public AnalyzableIngredient()
		{
			item = new NamespacedKey<DawnItemInfo>();
			chemistryLiquidAppearance = new ChemistryLiquidAppearance();
			specialInstructions = "";
			result = delegate
			{
			};
			holdItem = true;
		}

		public AnalyzableIngredient(NamespacedKey<DawnItemInfo> item, Action<AnalyzableIngredient, PlayerControllerB> result, ChemistryLiquidAppearance? chemistryLiquidAppearance = null, string specialInstructions = "", bool holdItem = true)
		{
			base.item = item;
			base.chemistryLiquidAppearance = chemistryLiquidAppearance ?? new ChemistryLiquidAppearance();
			base.specialInstructions = specialInstructions;
			this.result = result;
			this.holdItem = holdItem;
		}

		public bool Equals(AnalyzableIngredient other)
		{
			return item == other.item;
		}

		public override string ToString()
		{
			return ((object)item).ToString();
		}
	}
	public class ChemistryFixedOutputReaction : ChemistryRecipe
	{
		public ChemistryFixedOutputReaction(ChemistryIngredient ingredientA, ChemistryIngredient ingredientB, ChemistryIngredient output, float mixTime = -1f)
			: base(ingredientA, ingredientB, (ChemistryIngredient chemistryIngredient, ChemistryIngredient chemistryIngredient2) => output, mixTime)
		{
		}
	}
	public class ChemistryIngredient : IEquatable<ChemistryIngredient>, INetworkSerializable
	{
		public NamespacedKey<DawnItemInfo> item;

		public ChemistryLiquidAppearance chemistryLiquidAppearance;

		public string specialInstructions;

		public ChemistryIngredient()
		{
			item = new NamespacedKey<DawnItemInfo>();
			chemistryLiquidAppearance = new ChemistryLiquidAppearance();
			specialInstructions = "";
		}

		public ChemistryIngredient(NamespacedKey<DawnItemInfo> item, ChemistryLiquidAppearance? chemistryLiquidAppearance = null, string specialInstructions = "")
		{
			this.item = item;
			this.chemistryLiquidAppearance = chemistryLiquidAppearance ?? new ChemistryLiquidAppearance();
			this.specialInstructions = specialInstructions;
		}

		public bool Equals(ChemistryIngredient other)
		{
			return item == other.item;
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<NamespacedKey<DawnItemInfo>>*)(&serializer))->SerializeValue<NamespacedKey<DawnItemInfo>>(ref item, default(ForNetworkSerializable));
			((BufferSerializer<ChemistryLiquidAppearance>*)(&serializer))->SerializeValue<ChemistryLiquidAppearance>(ref chemistryLiquidAppearance, default(ForNetworkSerializable));
			serializer.SerializeValue(ref specialInstructions, false);
		}

		public override string ToString()
		{
			return ((NamespacedKey)item).Key;
		}
	}
	public struct ChemistryLiquidAppearance : INetworkSerializable
	{
		public Color liquidColor;

		public float emissionIntensity;

		public ChemistryLiquidAppearance()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			liquidColor = default(Color);
			emissionIntensity = 0f;
		}

		public ChemistryLiquidAppearance(Color liquidColor = default(Color), float emissionIntensity = 0f)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			this.liquidColor = liquidColor;
			this.emissionIntensity = emissionIntensity;
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			serializer.SerializeValue(ref liquidColor);
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref emissionIntensity, default(ForPrimitives));
		}

		public override string ToString()
		{
			return $"Color: {((object)Unsafe.As<Color, Color>(ref liquidColor)/*cast due to .constrained prefix*/).ToString()}, EmissionIntensity: {emissionIntensity}";
		}
	}
	public class ChemistryRecipe(ChemistryIngredient ingredientA, ChemistryIngredient ingredientB, Func<ChemistryIngredient, ChemistryIngredient, ChemistryIngredient> reaction, float mixTime = -1f) : IEquatable<ChemistryRecipe>
	{
		public ChemistryIngredient ingredientA = ingredientA;

		public ChemistryIngredient ingredientB = ingredientB;

		public Func<ChemistryIngredient, ChemistryIngredient, ChemistryIngredient> reaction = reaction;

		public float mixTime = mixTime;

		public bool Equals(ChemistryRecipe other)
		{
			return (ingredientA == other.ingredientA && ingredientB == other.ingredientB) || (ingredientA == other.ingredientB && ingredientB == other.ingredientA);
		}

		public override string ToString()
		{
			return ingredientA?.ToString() + " + " + ingredientB?.ToString() + " = ???";
		}
	}
	public static class CraftingAPI
	{
		public static void RegisterIngredient(ChemistryIngredient ingredient)
		{
			if (ChemicalMixerBehavior.RegisteredIngredients.Contains(ingredient))
			{
				Plugin.logger.LogWarning((object)$"Could not register chemistry ingredient {ingredient}, a similar chemistry ingredient already exists");
			}
			else
			{
				ChemicalMixerBehavior.RegisteredIngredients.Add(ingredient);
			}
		}

		public static void RegisterIngredient(AnalyzableIngredient ingredient)
		{
			if (AnalyzerBehavior.RegisteredIngredients.Contains(ingredient))
			{
				Plugin.logger.LogWarning((object)$"Could not register analyzable ingredient {ingredient}, a similar analyzable ingredient already exists");
			}
			else
			{
				AnalyzerBehavior.RegisteredIngredients.Add(ingredient);
			}
		}

		public static void RegisterRecipe(ChemistryRecipe recipe)
		{
			if (ChemicalMixerBehavior.RegisteredRecipes.Contains(recipe))
			{
				Plugin.logger.LogWarning((object)$"Could not register chemistry recipe {recipe}, a similar recipe already exists");
			}
			else
			{
				ChemicalMixerBehavior.RegisteredRecipes.Add(recipe);
			}
		}

		public static void RegisterRecipe(DistilleryRecipe recipe)
		{
			if (AlembicBehavior.RegisteredRecipes.Contains(recipe))
			{
				Plugin.logger.LogWarning((object)$"Could not register distillery recipe {recipe}, a similar recipe already exists");
			}
			else
			{
				AlembicBehavior.RegisteredRecipes.Add(recipe);
			}
		}

		public static void LogRecipies()
		{
			Plugin.logger.LogInfo((object)"Alembic recipes");
			foreach (DistilleryRecipe registeredRecipe in AlembicBehavior.RegisteredRecipes)
			{
				Plugin.logger.LogInfo((object)registeredRecipe);
			}
			Plugin.logger.LogInfo((object)"ChemistryMixer recipes");
			foreach (ChemistryRecipe registeredRecipe2 in ChemicalMixerBehavior.RegisteredRecipes)
			{
				Plugin.logger.LogInfo((object)registeredRecipe2);
			}
		}
	}
	public class DistilleryFixedOutputReaction : DistilleryRecipe
	{
		public DistilleryFixedOutputReaction(ChemistryIngredient ingredient, ChemistryIngredient? output, float mixTime = -1f)
			: base(ingredient, (ChemistryIngredient chemistryIngredient) => output, mixTime)
		{
		}
	}
	public class DistilleryRecipe(ChemistryIngredient ingredient, Func<ChemistryIngredient, ChemistryIngredient?> reaction, float mixTime = -1f)
	{
		public ChemistryIngredient ingredient = ingredient;

		public Func<ChemistryIngredient, ChemistryIngredient?> reaction = reaction;

		public float mixTime = mixTime;

		public override string ToString()
		{
			return ingredient?.ToString() + " = ???";
		}
	}
	public interface IAnalyzableIngredient : IChemistryIngredient
	{
		Action<AnalyzableIngredient, PlayerControllerB> OnAnalyze();

		bool HoldItem();
	}
	public interface IChemistryIngredient
	{
		ChemistryIngredient? GetIngredient();

		void OnChemicalOutput(ChemistryIngredient ingredient);
	}
	public interface IChemistryOutputContainer
	{
		bool ReceiveChemistryOutput(ChemistryIngredient ingredient);
	}
	public interface IDistillableIngredient : IChemistryIngredient
	{
		ChemistryIngredient? DistilleryOutput();

		float DistilleryMixTime();

		bool DespawnItemAfterDistilleryInput();
	}
	public interface IMixableIngredient : IChemistryIngredient
	{
		bool DespawnItemAfterInput();
	}
	[BepInPlugin("Snowlance.SnowyCraftingCore", "SnowyCraftingCore", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("Snowlance.SnowyCraftingCore");

		public static Plugin PluginInstance { get; private set; }

		public static ManualLogSource logger { get; private set; }

		public static DuskMod Mod { get; private set; }

		public static PlayerControllerB localPlayer => StartOfRound.Instance.localPlayerController;

		public static bool IsServerOrHost => NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost;

		public static PlayerControllerB? PlayerFromId(ulong id)
		{
			return StartOfRound.Instance.allPlayerScripts.Where((PlayerControllerB x) => x.actualClientId == id).FirstOrDefault();
		}

		private void Awake()
		{
			if ((Object)(object)PluginInstance == (Object)null)
			{
				PluginInstance = this;
			}
			logger = ((BaseUnityPlugin)PluginInstance).Logger;
			harmony.PatchAll();
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "snowycraftingcore_mainassets"));
			Mod = DuskMod.RegisterMod((BaseUnityPlugin)(object)this, val);
			Mod.RegisterContentHandlers();
			InitializeNetworkBehaviours();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Snowlance.SnowyCraftingCore v1.1.0 has loaded!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			ManualLogSource obj = logger;
			if (obj != null)
			{
				obj.LogDebug((object)"Finished initializing network behaviours");
			}
		}
	}
	internal class SnowyCraftingCoreContentHandler : ContentHandler<SnowyCraftingCoreContentHandler>
	{
		public class SmallItemDispenserAssets : AssetBundleLoader<SmallItemDispenserAssets>
		{
			[LoadFromBundle("SmallItemDispenser.prefab")]
			public GameObject SmallItemDispenserPrefab { get; private set; } = null;

			public SmallItemDispenserAssets(DuskMod mod, string filePath)
				: base(mod, filePath)
			{
			}
		}

		public class ApparatusPowerPortAssets : AssetBundleLoader<ApparatusPowerPortAssets>
		{
			[LoadFromBundle("ApparatusPowerPort.prefab")]
			public GameObject ApparatusPowerPortPrefab { get; private set; } = null;

			public ApparatusPowerPortAssets(DuskMod mod, string filePath)
				: base(mod, filePath)
			{
			}
		}

		public class AnalyzerAssets : AssetBundleLoader<AnalyzerAssets>
		{
			public AnalyzerAssets(DuskMod mod, string filePath)
				: base(mod, filePath)
			{
			}
		}

		public class AlembicAssets : AssetBundleLoader<AlembicAssets>
		{
			public AlembicAssets(DuskMod mod, string filePath)
				: base(mod, filePath)
			{
			}
		}

		public class ChemicalMixerAssets : AssetBundleLoader<ChemicalMixerAssets>
		{
			public ChemicalMixerAssets(DuskMod mod, string filePath)
				: base(mod, filePath)
			{
			}
		}

		public SmallItemDispenserAssets? SmallItemDispenser;

		public ApparatusPowerPortAssets? ApparatusPowerPort;

		public AnalyzerAssets? Analyzer;

		public AlembicAssets? Alembic;

		public ChemicalMixerAssets? ChemicalMixer;

		public SnowyCraftingCoreContentHandler(DuskMod mod)
			: base(mod)
		{
			((ContentHandler)this).RegisterContent<ApparatusPowerPortAssets>("apparatus_power_port", ref ApparatusPowerPort, false);
			((ContentHandler)this).RegisterContent<SmallItemDispenserAssets>("small_item_dispenser", ref SmallItemDispenser, false);
			((ContentHandler)this).RegisterContent<AnalyzerAssets>("analyzer", ref Analyzer, false);
			((ContentHandler)this).RegisterContent<AlembicAssets>("alembic", ref Alembic, false);
			((ContentHandler)this).RegisterContent<ChemicalMixerAssets>("chemical_mixer", ref ChemicalMixer, false);
		}
	}
	internal static class SnowyCraftingCoreKeys
	{
		public static readonly NamespacedKey<DawnUnlockableItemInfo> Analyzer = NamespacedKey<DawnUnlockableItemInfo>.From("snowy_crafting_core", "analyzer");

		public static readonly NamespacedKey<DawnUnlockableItemInfo> Alembic = NamespacedKey<DawnUnlockableItemInfo>.From("snowy_crafting_core", "alembic");

		public static readonly NamespacedKey<DawnUnlockableItemInfo> ChemicalMixer = NamespacedKey<DawnUnlockableItemInfo>.From("snowy_crafting_core", "chemical_mixer");
	}
	[HarmonyPatch]
	internal static class TESTING
	{
		private static bool open;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
		public static void PingScan_performedPostFix()
		{
			try
			{
				if (Utils.testing)
				{
				}
			}
			catch
			{
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		public static void SubmitChat_performedPrefix(HUDManager __instance)
		{
			try
			{
				if (!Utils.testing)
				{
					return;
				}
				string text = __instance.chatTextField.text;
				string[] array = text.Split(" ");
				switch (array[0])
				{
				case "/recipes":
					CraftingAPI.LogRecipies();
					break;
				case "/power":
				{
					if (!((Object)(object)ApparatusPowerPort.Instance == (Object)null) && array.Length != 1 && float.TryParse(array[1], out var result))
					{
						bool flag = ApparatusPowerPort.Instance.UsePower(result);
						HUDManager.Instance.DisplayTip("UsePower", "UsePower " + (flag ? "success" : "failed"), false, false, "LC_Tip1");
					}
					break;
				}
				case "/powera":
				{
					if (array.Length != 1 && float.TryParse(array[1], out var result2))
					{
						LungProp val = Object.FindObjectOfType<LungProp>();
						if (!((Object)(object)val == (Object)null))
						{
							bool flag2 = ((ILungPropInterface)val).UsePower(result2);
							HUDManager.Instance.DisplayTip("UsePowera", "UsePowera " + (flag2 ? "success" : "failed"), false, false, "LC_Tip1");
						}
					}
					break;
				}
				case "/test":
					HUDManager.Instance.DisplayTip("test", "test", false, false, "LC_Tip1");
					break;
				case "/testport":
					SmallItemDispenser.DEBUG_testingSlot = !SmallItemDispenser.DEBUG_testingSlot;
					SmallItemDispenser.Instance?.OpenPort(SmallItemDispenser.DEBUG_testingSlot);
					break;
				}
			}
			catch
			{
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Snowlance.SnowyCraftingCore";

		public const string PLUGIN_NAME = "SnowyCraftingCore";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace SnowyCraftingCore.Unlockables
{
	internal class AlembicBehavior : NetworkBehaviour
	{
		[SerializeField]
		private InteractTrigger inputTrigger = null;

		[SerializeField]
		private Collider inputTriggerCollider = null;

		[SerializeField]
		private Collider outputTriggerCollider = null;

		[SerializeField]
		private MeshRenderer inputRenderer = null;

		[SerializeField]
		private MeshRenderer outputRenderer = null;

		[SerializeField]
		private ParticleSystem inputParticleSystem = null;

		[SerializeField]
		private ParticleSystem outputParticleSystem = null;

		[SerializeField]
		private AudioSource audioSource = null;

		private ChemistryIngredient? inputIngredient;

		private ChemistryIngredient? outputIngredient;

		private DistilleryRecipe? currentlyMixingRecipe;

		private ParticleSystemRenderer inputParticleSystemRenderer = null;

		private bool mixing;

		private ChemistryLiquidAppearance inputDefaultColor;

		private const float defaultMixingTime = 10f;

		public static List<DistilleryRecipe> RegisteredRecipes { get; internal set; } = new List<DistilleryRecipe>();

		public void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			inputDefaultColor = new ChemistryLiquidAppearance(((Renderer)inputRenderer).material.color, 2f);
			inputParticleSystemRenderer = ((Component)inputParticleSystem).GetComponent<ParticleSystemRenderer>();
		}

		public void Update()
		{
			inputTriggerCollider.enabled = inputIngredient == null && outputIngredient == null && (Object)(object)Plugin.localPlayer.currentlyHeldObjectServer != (Object)null;
			inputTrigger.interactable = (Object)(object)Plugin.localPlayer.currentlyHeldObjectServer != (Object)null && !Plugin.localPlayer.currentlyHeldObjectServer.itemProperties.twoHanded;
			outputTriggerCollider.enabled = outputIngredient != null;
		}

		public void InputTrigger_Interact()
		{
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Plugin.localPlayer.currentlyHeldObjectServer == (Object)null || Plugin.localPlayer.currentlyHeldObjectServer.itemProperties.twoHanded)
			{
				return;
			}
			GrabbableObject currentlyHeldObjectServer = Plugin.localPlayer.currentlyHeldObjectServer;
			NamespacedKey<DawnItemInfo> itemKey = ((DawnBaseInfo<DawnItemInfo>)(object)ItemExtensions.GetDawnInfo(currentlyHeldObjectServer.itemProperties)).TypedKey;
			ChemistryIngredient chemistryIngredient = null;
			bool flag = true;
			if (currentlyHeldObjectServer is IChemistryIngredient chemistryIngredient2)
			{
				Plugin.logger.LogDebug((object)"item is IChemistryIngredient");
				chemistryIngredient = chemistryIngredient2.GetIngredient();
				Plugin.logger.LogDebug((object)("Got IChemistryIngredient: " + chemistryIngredient));
				if (chemistryIngredient != null && chemistryIngredient2 is IDistillableIngredient distillableIngredient)
				{
					ChemistryIngredient chemistryIngredient3 = distillableIngredient.DistilleryOutput();
					float mixTime = distillableIngredient.DistilleryMixTime();
					if (distillableIngredient.DespawnItemAfterDistilleryInput())
					{
						Plugin.localPlayer.DespawnHeldObject();
					}
					InputIngredientRpc(chemistryIngredient, chemistryIngredient3, mixTime);
					return;
				}
			}
			if (chemistryIngredient == null)
			{
				chemistryIngredient = ChemicalMixerBehavior.RegisteredIngredients.Where((ChemistryIngredient x) => x.item == itemKey).FirstOrDefault();
			}
			if (chemistryIngredient == null)
			{
				Plugin.logger.LogDebug((object)("Unable to find registered ingredient for " + ((Object)currentlyHeldObjectServer).name + ", creating default ingredient"));
				Color liquidColor = Random.ColorHSV();
				chemistryIngredient = new ChemistryIngredient(itemKey, new ChemistryLiquidAppearance(liquidColor, 5f));
			}
			if (flag)
			{
				Plugin.localPlayer.DespawnHeldObject();
			}
			InputIngredientRpc(chemistryIngredient);
		}

		public void OutputTrigger_Interact()
		{
			if (inputIngredient != null || outputIngredient != null)
			{
				OutputTrigger_InteractRpc(Plugin.localPlayer.actualClientId);
			}
		}

		private void SetInputFlaskColor(ChemistryLiquidAppearance color)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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)
			Plugin.logger.LogDebug((object)("Setting input flash color to " + color.ToString()));
			((Renderer)inputRenderer).material.color = color.liquidColor;
			((Renderer)inputRenderer).material.SetColor("_EmissiveColor", color.liquidColor);
			((Renderer)inputRenderer).material.SetFloat("_EmissiveIntensity", color.emissionIntensity);
			((Renderer)inputParticleSystemRenderer).material.color = color.liquidColor;
			((Renderer)inputParticleSystemRenderer).material.SetColor("_EmissiveColor", color.liquidColor);
			((Renderer)inputParticleSystemRenderer).material.SetFloat("_EmissiveIntensity", color.emissionIntensity);
		}

		private void SetOutputFlaskColor(ChemistryLiquidAppearance color)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)("Setting output flash color to " + color.ToString()));
			((Renderer)outputRenderer).enabled = true;
			((Renderer)outputRenderer).sharedMaterial.color = color.liquidColor;
			((Renderer)outputRenderer).sharedMaterial.SetColor("_EmissiveColor", color.liquidColor);
			((Renderer)outputRenderer).sharedMaterial.SetFloat("_EmissiveIntensity", color.emissionIntensity);
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void InputIngredientRpc(ChemistryIngredient ingredient)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(37495252u, val3, val, (SendTo)6, (RpcDelivery)0);
				bool flag = ingredient != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<ChemistryIngredient>(ref ingredient, default(ForNetworkSerializable));
				}
				((NetworkBehaviour)this).__endSendRpc(ref val2, 37495252u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			ChemistryIngredient ingredient2 = ingredient;
			Plugin.logger.LogDebug((object)"InputIngredientRpc");
			inputIngredient = null;
			currentlyMixingRecipe = null;
			inputIngredient = ingredient2;
			SetInputFlaskColor(ingredient2.chemistryLiquidAppearance);
			if (currentlyMixingRecipe == null)
			{
				currentlyMixingRecipe = RegisteredRecipes.Where((DistilleryRecipe x) => x.ingredient.Equals(ingredient2)).FirstOrDefault();
			}
			Plugin.logger.LogDebug((object)((currentlyMixingRecipe != null) ? "Recipe found" : "Recipe not found"));
			mixing = true;
			MixIngredients();
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void InputIngredientRpc(ChemistryIngredient ingredient, ChemistryIngredient? outputIngredient, float mixTime)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(4200551090u, val3, val, (SendTo)6, (RpcDelivery)0);
				bool flag = ingredient != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<ChemistryIngredient>(ref ingredient, default(ForNetworkSerializable));
				}
				bool flag2 = outputIngredient != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<ChemistryIngredient>(ref outputIngredient, default(ForNetworkSerializable));
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref mixTime, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendRpc(ref val2, 4200551090u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			ChemistryIngredient ingredient2 = ingredient;
			Plugin.logger.LogDebug((object)"InputIngredientRpc");
			inputIngredient = ingredient2;
			currentlyMixingRecipe = new DistilleryFixedOutputReaction(ingredient2, outputIngredient, mixTime);
			SetInputFlaskColor(ingredient2.chemistryLiquidAppearance);
			if (currentlyMixingRecipe == null)
			{
				currentlyMixingRecipe = RegisteredRecipes.Where((DistilleryRecipe x) => x.ingredient.Equals(ingredient2)).FirstOrDefault();
			}
			Plugin.logger.LogDebug((object)((currentlyMixingRecipe != null) ? "Recipe found" : "Recipe not found"));
			mixing = true;
			MixIngredients();
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void OutputTrigger_InteractRpc(ulong clientId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(371832359u, val3, val, (SendTo)6, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 371832359u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			ulong clientId2 = clientId;
			if (outputIngredient == null || mixing)
			{
				return;
			}
			PlayerControllerB val4 = Plugin.PlayerFromId(clientId2);
			if ((Object)(object)val4 == (Object)null)
			{
				return;
			}
			GrabbableObject outputItem;
			if (((NetworkBehaviour)this).IsServer && (!((Object)(object)val4.currentlyHeldObjectServer != (Object)null) || !(val4.currentlyHeldObjectServer is IChemistryOutputContainer chemistryOutputContainer) || !chemistryOutputContainer.ReceiveChemistryOutput(outputIngredient)))
			{
				outputItem = Utils.SpawnItem(outputIngredient.item, ((Component)val4).transform.position, default(Quaternion), (Transform)null, false);
				if ((Object)(object)outputItem != (Object)null)
				{
					((MonoBehaviour)this).StartCoroutine(sendSpawnOutputIngredient(outputIngredient));
				}
			}
			outputParticleSystem.Stop();
			((Renderer)outputRenderer).enabled = false;
			outputIngredient = null;
			IEnumerator sendSpawnOutputIngredient(ChemistryIngredient outputIngredient)
			{
				yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)((NetworkBehaviour)outputItem).NetworkObject != (Object)null && ((NetworkBehaviour)outputItem).NetworkObject.IsSpawned));
				SpawnOutputIngredientRpc(clientId2, NetworkObjectReference.op_Implicit(((NetworkBehaviour)outputItem).NetworkObject), outputIngredient);
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void SpawnOutputIngredientRpc(ulong clientId, NetworkObjectReference netRef, ChemistryIngredient outputIngredient)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2326705827u, val3, val, (SendTo)6, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				bool flag = outputIngredient != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<ChemistryIngredient>(ref outputIngredient, default(ForNetworkSerializable));
				}
				((NetworkBehaviour)this).__endSendRpc(ref val2, 2326705827u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			Plugin.logger.LogDebug((object)"SpawnOutputIngredientRpc");
			NetworkObject val4 = default(NetworkObject);
			if (!((NetworkObjectReference)(ref netRef)).TryGet(ref val4, (NetworkManager)null))
			{
				Plugin.logger.LogError((object)"Failed to get network object from network object reference");
				return;
			}
			GrabbableObject val5 = default(GrabbableObject);
			if (!((Component)val4).TryGetComponent<GrabbableObject>(ref val5))
			{
				Plugin.logger.LogError((object)"Failed to get grabbable object from network object");
				return;
			}
			if (val5 is IChemistryIngredient chemistryIngredient)
			{
				Plugin.logger.LogDebug((object)"Outputting IChemistryIngredient");
				chemistryIngredient.OnChemicalOutput(outputIngredient);
			}
			if (Plugin.localPlayer.actualClientId == clientId)
			{
				PlayerControllerBExtensions.GrabGrabbableObject(Plugin.localPlayer, val5);
			}
		}

		private void MixIngredients()
		{
			Plugin.logger.LogDebug((object)"Mixing ingredients coroutine");
			((MonoBehaviour)this).StartCoroutine(mixIngredients());
			IEnumerator mixIngredients()
			{
				yield return null;
				audioSource.Play();
				float mixTime = ((currentlyMixingRecipe != null && currentlyMixingRecipe.mixTime > 0f) ? currentlyMixingRecipe.mixTime : 10f);
				yield return (object)new WaitForSeconds(mixTime);
				if (currentlyMixingRecipe != null)
				{
					outputIngredient = currentlyMixingRecipe.reaction(inputIngredient);
					if (outputIngredient != null)
					{
						SetOutputFlaskColor(outputIngredient.chemistryLiquidAppearance);
						outputParticleSystem.Play();
					}
				}
				SetInputFlaskColor(inputDefaultColor);
				currentlyMixingRecipe = null;
				inputIngredient = null;
				mixing = false;
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(37495252u, new RpcReceiveHandler(__rpc_handler_37495252), "InputIngredientRpc");
			((NetworkBehaviour)this).__registerRpc(4200551090u, new RpcReceiveHandler(__rpc_handler_4200551090), "InputIngredientRpc");
			((NetworkBehaviour)this).__registerRpc(371832359u, new RpcReceiveHandler(__rpc_handler_371832359), "OutputTrigger_InteractRpc");
			((NetworkBehaviour)this).__registerRpc(2326705827u, new RpcReceiveHandler(__rpc_handler_2326705827), "SpawnOutputIngredientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_37495252(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				ChemistryIngredient ingredient = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ChemistryIngredient>(ref ingredient, default(ForNetworkSerializable));
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AlembicBehavior)(object)target).InputIngredientRpc(ingredient);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4200551090(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				ChemistryIngredient ingredient = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ChemistryIngredient>(ref ingredient, default(ForNetworkSerializable));
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				ChemistryIngredient chemistryIngredient = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ChemistryIngredient>(ref chemistryIngredient, default(ForNetworkSerializable));
				}
				float mixTime = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref mixTime, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AlembicBehavior)(object)target).InputIngredientRpc(ingredient, chemistryIngredient, mixTime);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_371832359(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong clientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AlembicBehavior)(object)target).OutputTrigger_InteractRpc(clientId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2326705827(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00b8: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong clientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				NetworkObjectReference netRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				ChemistryIngredient chemistryIngredient = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ChemistryIngredient>(ref chemistryIngredient, default(ForNetworkSerializable));
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AlembicBehavior)(object)target).SpawnOutputIngredientRpc(clientId, netRef, chemistryIngredient);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "AlembicBehavior";
		}
	}
	internal class AnalyzerBehavior : NetworkBehaviour
	{
		[SerializeField]
		private Animator animator = null;

		[SerializeField]
		private AudioSource audioSource = null;

		[SerializeField]
		private InteractTrigger interactTrigger = null;

		[SerializeField]
		private Collider interactTriggerCollider = null;

		[SerializeField]
		private MeshRenderer testTubeRenderer = null;

		[SerializeField]
		private MeshRenderer testTubeFluidRenderer = null;

		private AnalyzableIngredient? analyzingIngredient;

		private PlayerControllerB? playerAnalyzing;

		private GrabbableObject? heldObject;

		private bool inAnimation;

		public static List<AnalyzableIngredient> RegisteredIngredients { get; internal set; } = new List<AnalyzableIngredient>();

		public void Update()
		{
			interactTrigger.interactable = (Object)(object)Plugin.localPlayer.currentlyHeldObjectServer != (Object)null || (Object)(object)heldObject != (Object)null;
			interactTrigger.hoverTip = (((Object)(object)heldObject != (Object)null) ? "Take ingredient [E]" : "Analyze [E]");
			interactTriggerCollider.enabled = !inAnimation;
		}

		public void OnFinishSpinning()
		{
			if (!analyzingIngredient.holdItem)
			{
				((Renderer)testTubeRenderer).enabled = false;
				((Renderer)testTubeFluidRenderer).enabled = false;
			}
			inAnimation = false;
			AnalyzableIngredient analyzableIngredient = analyzingIngredient;
			PlayerControllerB arg = playerAnalyzing;
			analyzingIngredient = null;
			playerAnalyzing = null;
			audioSource.Stop();
			analyzableIngredient?.result(analyzableIngredient, arg);
		}

		public void OnTriggerInteract()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			if (!inAnimation)
			{
				if ((Object)(object)heldObject != (Object)null)
				{
					GrabHeldItemRpc(Plugin.localPlayer.actualClientId);
				}
				else if ((Object)(object)Plugin.localPlayer.currentlyHeldObjectServer != (Object)null && (Plugin.localPlayer.currentlyHeldObjectServer is IAnalyzableIngredient || RegisteredIngredients.Any((AnalyzableIngredient x) => (object)x.item == ((DawnBaseInfo<DawnItemInfo>)(object)ItemExtensions.GetDawnInfo(Plugin.localPlayer.currentlyHeldObjectServer.itemProperties)).Key)))
				{
					ProcessIngredientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)Plugin.localPlayer.currentlyHeldObjectServer).NetworkObject));
				}
			}
		}

		private void SetTestTubeColor(ChemistryLiquidAppearance color)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			((Renderer)testTubeFluidRenderer).material.color = color.liquidColor;
			((Renderer)testTubeFluidRenderer).material.SetColor("_EmissiveColor", color.liquidColor);
			((Renderer)testTubeFluidRenderer).material.SetFloat("_EmissiveIntensity", color.emissionIntensity);
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void GrabHeldItemRpc(ulong clientId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(669634439u, val3, val, (SendTo)6, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 669634439u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			if ((Object)(object)heldObject == (Object)null)
			{
				return;
			}
			PlayerControllerB val4 = Plugin.PlayerFromId(clientId);
			if (!((Object)(object)val4 == (Object)null))
			{
				heldObject.EnableItemMeshes(true);
				heldObject.EnablePhysics(true);
				if ((Object)(object)val4 == (Object)(object)Plugin.localPlayer)
				{
					PlayerControllerBExtensions.GrabGrabbableObject(val4, heldObject);
				}
				heldObject = null;
				((Renderer)testTubeRenderer).enabled = false;
				((Renderer)testTubeFluidRenderer).enabled = false;
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void ProcessIngredientRpc(NetworkObjectReference netRef)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(19884282u, val3, val, (SendTo)6, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendRpc(ref val2, 19884282u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			NetworkObject val4 = default(NetworkObject);
			if (!((NetworkObjectReference)(ref netRef)).TryGet(ref val4, (NetworkManager)null))
			{
				Plugin.logger.LogError((object)"Failed to get networkobject from networkobjectreference");
				return;
			}
			GrabbableObject val5 = default(GrabbableObject);
			if (!((Component)val4).TryGetComponent<GrabbableObject>(ref val5))
			{
				Plugin.logger.LogError((object)"Failed to get grabbableobject from networkobject");
				return;
			}
			NamespacedKey<DawnItemInfo> itemKey = ((DawnBaseInfo<DawnItemInfo>)(object)ItemExtensions.GetDawnInfo(val5.itemProperties)).TypedKey;
			AnalyzableIngredient analyzableIngredient = null;
			if (val5 is IAnalyzableIngredient analyzableIngredient2)
			{
				ChemistryIngredient chemistryIngredient = analyzableIngredient2.GetIngredient();
				if (chemistryIngredient == null)
				{
					chemistryIngredient = new ChemistryIngredient(itemKey);
				}
				analyzableIngredient = new AnalyzableIngredient(itemKey, analyzableIngredient2.OnAnalyze(), chemistryIngredient.chemistryLiquidAppearance, chemistryIngredient.specialInstructions, analyzableIngredient2.HoldItem());
			}
			if (analyzableIngredient == null)
			{
				analyzableIngredient = RegisteredIngredients.Where((AnalyzableIngredient x) => x.item == itemKey).FirstOrDefault();
			}
			if (analyzableIngredient == null)
			{
				return;
			}
			analyzingIngredient = analyzableIngredient;
			SetTestTubeColor(analyzableIngredient.chemistryLiquidAppearance);
			if (analyzableIngredient.holdItem)
			{
				if ((Object)(object)Plugin.localPlayer == (Object)(object)val5.playerHeldBy)
				{
					Plugin.localPlayer.DiscardHeldObject(true, ((NetworkBehaviour)this).NetworkObject, ((Component)this).transform.position, false);
				}
				val5.EnableItemMeshes(false);
				val5.EnablePhysics(false);
				heldObject = val5;
			}
			((Renderer)testTubeFluidRenderer).enabled = true;
			((Renderer)testTubeRenderer).enabled = true;
			inAnimation = true;
			audioSource.Play();
			animator.SetTrigger("spin");
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(669634439u, new RpcReceiveHandler(__rpc_handler_669634439), "GrabHeldItemRpc");
			((NetworkBehaviour)this).__registerRpc(19884282u, new RpcReceiveHandler(__rpc_handler_19884282), "ProcessIngredientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_669634439(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong clientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AnalyzerBehavior)(object)target).GrabHeldItemRpc(clientId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_19884282(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_004f: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AnalyzerBehavior)(object)target).ProcessIngredientRpc(netRef);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "AnalyzerBehavior";
		}
	}
	internal class ChemicalMixerBehavior : NetworkBehaviour
	{
		[SerializeField]
		private InteractTrigger input1Trigger = null;

		[SerializeField]
		private InteractTrigger input2Trigger = null;

		[SerializeField]
		private InteractTrigger outputTrigger = null;

		[SerializeField]
		private Collider input1TriggerCollider = null;

		[SerializeField]
		private Collider input2TriggerCollider = null;

		[SerializeField]
		private Collider outputTriggerCollider = null;

		[SerializeField]
		private MeshRenderer input1Renderer = null;

		[SerializeField]
		private MeshRenderer input2Renderer = null;

		[SerializeField]
		private MeshRenderer outputRenderer = null;

		[SerializeField]
		private ParticleSystem input1ParticleSystem = null;

		[SerializeField]
		private ParticleSystem input2ParticleSystem = null;

		[SerializeField]
		private ParticleSystem outputParticleSystem = null;

		[SerializeField]
		private AudioSource audioSource = null;

		[SerializeField]
		private Transform explosionPosition = null;

		[SerializeField]
		private Sprite mixIcon = null;

		[SerializeField]
		private Sprite handIcon = null;

		private ChemistryIngredient? input1Ingredient;

		private ChemistryIngredient? input2Ingredient;

		private ChemistryIngredient? outputIngredient;

		private ChemistryRecipe? currentlyMixingRecipe;

		private bool mixing;

		private const float defaultMixingTime = 10f;

		public static List<ChemistryIngredient> RegisteredIngredients { get; internal set; } = new List<ChemistryIngredient>();

		public static List<ChemistryRecipe> RegisteredRecipes { get; internal set; } = new List<ChemistryRecipe>();

		public void Awake()
		{
			input1TriggerCollider = ((Component)input1Trigger).GetComponent<Collider>();
			input2TriggerCollider = ((Component)input2Trigger).GetComponent<Collider>();
			outputTriggerCollider = ((Component)outputTrigger).GetComponent<Collider>();
		}

		public void Update()
		{
			input1TriggerCollider.enabled = input1Ingredient == null && (Object)(object)Plugin.localPlayer.currentlyHeldObjectServer != (Object)null;
			input2TriggerCollider.enabled = input2Ingredient == null && (Object)(object)Plugin.localPlayer.currentlyHeldObjectServer != (Object)null;
			outputTriggerCollider.enabled = (input1Ingredient != null && input2Ingredient != null) || outputIngredient != null;
			if (input1Ingredient != null && input2Ingredient != null && outputIngredient == null)
			{
				outputTrigger.hoverTip = "Mix [E]";
				outputTrigger.hoverIcon = mixIcon;
			}
			else if (outputIngredient != null)
			{
				outputTrigger.hoverTip = "Take Ingredient [E]";
				outputTrigger.hoverIcon = handIcon;
			}
		}

		public void InputTriggerInteract(int flaskInputIndex)
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Plugin.localPlayer.currentlyHeldObjectServer == (Object)null || Plugin.localPlayer.currentlyHeldObjectServer.itemProperties.twoHanded)
			{
				return;
			}
			Plugin.logger.LogDebug((object)"InputTriggerInteract");
			GrabbableObject currentlyHeldObjectServer = Plugin.localPlayer.currentlyHeldObjectServer;
			NamespacedKey<DawnItemInfo> itemKey = ((DawnBaseInfo<DawnItemInfo>)(object)ItemExtensions.GetDawnInfo(currentlyHeldObjectServer.itemProperties)).TypedKey;
			ChemistryIngredient chemistryIngredient = null;
			bool flag = true;
			if (currentlyHeldObjectServer is IChemistryIngredient chemistryIngredient2)
			{
				chemistryIngredient = chemistryIngredient2.GetIngredient();
				if (chemistryIngredient2 is IMixableIngredient mixableIngredient)
				{
					flag = mixableIngredient.DespawnItemAfterInput();
				}
			}
			if (chemistryIngredient == null)
			{
				chemistryIngredient = RegisteredIngredients.Where((ChemistryIngredient x) => x.item == itemKey).FirstOrDefault();
			}
			if (chemistryIngredient == null)
			{
				Color liquidColor = Random.ColorHSV();
				chemistryIngredient = new ChemistryIngredient(itemKey, new ChemistryLiquidAppearance(liquidColor));
			}
			if (flag)
			{
				Plugin.localPlayer.DespawnHeldObject();
			}
			InputIngredientRpc(chemistryIngredient, flaskInputIndex);
		}

		public void Input1Trigger_Interact()
		{
			InputTriggerInteract(1);
		}

		public void Input2Trigger_Interact()
		{
			InputTriggerInteract(2);
		}

		public void OutputTrigger_Interact()
		{
			if ((input1Ingredient != null && input2Ingredient != null) || outputIngredient != null)
			{
				OutputTrigger_InteractRpc(Plugin.localPlayer.actualClientId);
			}
		}

		private void SetInput1FlaskColor(ChemistryLiquidAppearance color)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			((Renderer)input1Renderer).enabled = true;
			((Renderer)input1Renderer).sharedMaterial.color = color.liquidColor;
			((Renderer)input1Renderer).sharedMaterial.SetColor("_EmissiveColor", color.liquidColor);
			((Renderer)input1Renderer).sharedMaterial.SetFloat("_EmissiveIntensity", color.emissionIntensity);
		}

		private void SetInput2FlaskColor(ChemistryLiquidAppearance color)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			((Renderer)input2Renderer).enabled = true;
			((Renderer)input2Renderer).sharedMaterial.color = color.liquidColor;
			((Renderer)input2Renderer).sharedMaterial.SetColor("_EmissiveColor", color.liquidColor);
			((Renderer)input2Renderer).sharedMaterial.SetFloat("_EmissiveIntensity", color.emissionIntensity);
		}

		private void SetOutputFlaskColor(ChemistryLiquidAppearance color)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			((Renderer)outputRenderer).enabled = true;
			((Renderer)outputRenderer).sharedMaterial.color = color.liquidColor;
			((Renderer)outputRenderer).sharedMaterial.SetColor("_EmissiveColor", color.liquidColor);
			((Renderer)outputRenderer).sharedMaterial.SetFloat("_EmissiveIntensity", color.emissionIntensity);
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void InputIngredientRpc(ChemistryIngredient ingredient, int flaskInputIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3640411672u, val3, val, (SendTo)6, (RpcDelivery)0);
				bool flag = ingredient != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<ChemistryIngredient>(ref ingredient, default(ForNetworkSerializable));
				}
				BytePacker.WriteValueBitPacked(val2, flaskInputIndex);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 3640411672u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1)
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				switch (flaskInputIndex)
				{
				case 1:
					input1Ingredient = ingredient;
					SetInput1FlaskColor(ingredient.chemistryLiquidAppearance);
					break;
				case 2:
					input2Ingredient = ingredient;
					SetInput2FlaskColor(ingredient.chemistryLiquidAppearance);
					break;
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void OutputTrigger_InteractRpc(ulong clientId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: 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_0203: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2304917220u, val3, val, (SendTo)6, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 2304917220u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			ulong clientId2 = clientId;
			if (((input1Ingredient == null || input2Ingredient == null) && outputIngredient == null) || mixing)
			{
				return;
			}
			GrabbableObject outputItem;
			if (input1Ingredient != null && input2Ingredient != null && outputIngredient == null)
			{
				currentlyMixingRecipe = RegisteredRecipes.Where((ChemistryRecipe x) => (x.ingredientA.Equals(input1Ingredient) && x.ingredientB.Equals(input2Ingredient)) || (x.ingredientA.Equals(input2Ingredient) && x.ingredientB.Equals(input1Ingredient))).FirstOrDefault();
				mixing = true;
				MixIngredients();
			}
			else
			{
				if (outputIngredient == null)
				{
					return;
				}
				PlayerControllerB val4 = Plugin.PlayerFromId(clientId2);
				if ((Object)(object)val4 == (Object)null)
				{
					return;
				}
				if (((NetworkBehaviour)this).IsServer && (!((Object)(object)val4.currentlyHeldObjectServer != (Object)null) || !(val4.currentlyHeldObjectServer is IChemistryOutputContainer chemistryOutputContainer) || !chemistryOutputContainer.ReceiveChemistryOutput(outputIngredient)))
				{
					outputItem = Utils.SpawnItem(outputIngredient.item, ((Component)val4).transform.position, default(Quaternion), (Transform)null, false);
					if ((Object)(object)outputItem != (Object)null)
					{
						((MonoBehaviour)this).StartCoroutine(sendSpawnOutputIngredient(outputIngredient));
					}
				}
				outputParticleSystem.Stop();
				((Renderer)outputRenderer).enabled = false;
				outputIngredient = null;
			}
			IEnumerator sendSpawnOutputIngredient(ChemistryIngredient outputIngredient)
			{
				yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)((NetworkBehaviour)outputItem).NetworkObject != (Object)null && ((NetworkBehaviour)outputItem).NetworkObject.IsSpawned));
				SpawnOutputIngredientRpc(clientId2, NetworkObjectReference.op_Implicit(((NetworkBehaviour)outputItem).NetworkObject), outputIngredient);
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void SpawnOutputIngredientRpc(ulong clientId, NetworkObjectReference netRef, ChemistryIngredient outputIngredient)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3828631210u, val3, val, (SendTo)6, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				bool flag = outputIngredient != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<ChemistryIngredient>(ref outputIngredient, default(ForNetworkSerializable));
				}
				((NetworkBehaviour)this).__endSendRpc(ref val2, 3828631210u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			NetworkObject val4 = default(NetworkObject);
			GrabbableObject val5 = default(GrabbableObject);
			if (((NetworkObjectReference)(ref netRef)).TryGet(ref val4, (NetworkManager)null) && ((Component)val4).TryGetComponent<GrabbableObject>(ref val5))
			{
				if (val5 is IChemistryIngredient chemistryIngredient)
				{
					chemistryIngredient.OnChemicalOutput(outputIngredient);
				}
				if (Plugin.localPlayer.actualClientId == clientId)
				{
					PlayerControllerBExtensions.GrabGrabbableObject(Plugin.localPlayer, val5);
				}
			}
		}

		private void MixIngredients()
		{
			((MonoBehaviour)this).StartCoroutine(mixIngredients());
			IEnumerator mixIngredients()
			{
				yield return null;
				input1ParticleSystem.Play();
				input2ParticleSystem.Play();
				audioSource.Play();
				float mixTime = ((currentlyMixingRecipe != null && currentlyMixingRecipe.mixTime > 0f) ? currentlyMixingRecipe.mixTime : 10f);
				yield return (object)new WaitForSeconds(mixTime);
				if (currentlyMixingRecipe != null)
				{
					outputIngredient = currentlyMixingRecipe.reaction(input1Ingredient, input2Ingredient);
					SetOutputFlaskColor(outputIngredient.chemistryLiquidAppearance);
					outputParticleSystem.Play();
				}
				else
				{
					Landmine.SpawnExplosion(explosionPosition.position, true, 0f, 1f, 5, 5f, (GameObject)null, false);
				}
				currentlyMixingRecipe = null;
				input1ParticleSystem.Stop();
				input2ParticleSystem.Stop();
				input1Ingredient = null;
				input2Ingredient = null;
				((Renderer)input1Renderer).enabled = false;
				((Renderer)input2Renderer).enabled = false;
				mixing = false;
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3640411672u, new RpcReceiveHandler(__rpc_handler_3640411672), "InputIngredientRpc");
			((NetworkBehaviour)this).__registerRpc(2304917220u, new RpcReceiveHandler(__rpc_handler_2304917220), "OutputTrigger_InteractRpc");
			((NetworkBehaviour)this).__registerRpc(3828631210u, new RpcReceiveHandler(__rpc_handler_3828631210), "SpawnOutputIngredientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_3640411672(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				ChemistryIngredient ingredient = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ChemistryIngredient>(ref ingredient, default(ForNetworkSerializable));
				}
				int flaskInputIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref flaskInputIndex);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChemicalMixerBehavior)(object)target).InputIngredientRpc(ingredient, flaskInputIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2304917220(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong clientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChemicalMixerBehavior)(object)target).OutputTrigger_InteractRpc(clientId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3828631210(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00b8: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong clientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				NetworkObjectReference netRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				ChemistryIngredient chemistryIngredient = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ChemistryIngredient>(ref chemistryIngredient, default(ForNetworkSerializable));
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChemicalMixerBehavior)(object)target).SpawnOutputIngredientRpc(clientId, netRef, chemistryIngredient);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ChemicalMixerBehavior";
		}
	}
}
namespace SnowyCraftingCore.TerminalAdditions
{
	public class ApparatusPowerPort : NetworkBehaviour
	{
		[SerializeField]
		private AudioSource audioSource = null;

		[SerializeField]
		private AudioClip openSFX = null;

		[SerializeField]
		private AudioClip closeSFX = null;

		[SerializeField]
		private Animator animator = null;

		[SerializeField]
		private Transform apparatusPosition = null;

		[SerializeField]
		private InteractTrigger interactTrigger = null;

		[SerializeField]
		private Collider interactTriggerCollider = null;

		private LungProp? apparatusInSlot;

		private static Vector3 positionOffset = new Vector3(-0.05f, 0.395f, -0.7f);

		private static Vector3 rotationOffset = new Vector3(90f, 0f, 0f);

		public static ApparatusPowerPort? Instance { get; private set; } = null;

		public bool IsApparatusInSlot => (Object)(object)apparatusInSlot != (Object)null;

		public float ApparatusPowerLeft { get; private set; }

		public bool IsOpen { get; private set; }

		private static Transform TerminalTransform => ((Component)Utils.terminal).gameObject.transform.parent.parent;

		private static Transform HangarShipTransform => ((Component)Utils.terminal).gameObject.transform.parent.parent.parent;

		internal static void Init()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			if (Plugin.IsServerOrHost)
			{
				if (ContentHandler<SnowyCraftingCoreContentHandler>.Instance.ApparatusPowerPort == null)
				{
					return;
				}
				GameObject val = Object.Instantiate<GameObject>(ContentHandler<SnowyCraftingCoreContentHandler>.Instance.ApparatusPowerPort.ApparatusPowerPortPrefab, HangarShipTransform);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
			positionOffset = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<Vector3>("Apparatus Power Port Options", "Position Offset", new Vector3(-0.05f, 0.395f, -0.7f), "Position offset from the terminals position").Value;
			rotationOffset = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<Vector3>("Apparatus Power Port Options", "Rotation Offset", new Vector3(90f, 0f, 0f), "Rotation offset from the terminals position").Value;
			TerminalAPI.RegisterTerminalCommand(new TerminalCommand("power", (Func<string[], string>)delegate
			{
				string result = (Instance.IsOpen ? "Closing" : "Opening") + " apparatus power port\n\n";
				Instance.TogglePortRpc();
				return result;
			}, "Other", "Power", "Open/close the apparatus power port"));
		}

		internal void Start()
		{
			if (Instance == null)
			{
				Instance = this;
			}
			((Component)this).transform.SetParent(HangarShipTransform);
		}

		internal void Update()
		{
			if (!((Object)(object)Plugin.localPlayer == (Object)null))
			{
				interactTriggerCollider.enabled = !IsApparatusInSlot && IsOpen;
				interactTrigger.interactable = (Object)(object)Plugin.localPlayer.currentlyHeldObjectServer != (Object)null && Plugin.localPlayer.currentlyHeldObjectServer is LungProp;
				if ((Object)(object)apparatusInSlot != (Object)null && ((Object)(object)((GrabbableObject)apparatusInSlot).playerHeldBy != (Object)null || ((GrabbableObject)apparatusInSlot).isHeldByEnemy))
				{
					AudioSource component = ((Component)apparatusInSlot).gameObject.GetComponent<AudioSource>();
					component.Stop();
					component.loop = false;
					apparatusInSlot = null;
				}
			}
		}

		private void LateUpdate()
		{
			//IL_000c: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.rotation = TerminalTransform.rotation;
			((Component)this).transform.Rotate(rotationOffset);
			((Component)this).transform.position = TerminalTransform.position;
			Vector3 val = positionOffset;
			val = TerminalTransform.rotation * val;
			Transform transform = ((Component)this).transform;
			transform.position += val;
			if ((Object)(object)apparatusInSlot != (Object)null)
			{
				((Component)apparatusInSlot).transform.position = apparatusPosition.position;
				((Component)apparatusInSlot).transform.rotation = apparatusPosition.rotation;
			}
		}

		private void TogglePort()
		{
			IsOpen = !IsOpen;
			animator.SetBool("open", IsOpen);
			if (IsOpen)
			{
				audioSource.PlayOneShot(openSFX);
			}
			else
			{
				audioSource.PlayOneShot(closeSFX);
			}
			if (!((Object)(object)apparatusInSlot != (Object)null))
			{
				return;
			}
			((GrabbableObject)apparatusInSlot).EnablePhysics(IsOpen);
			((GrabbableObject)apparatusInSlot).EnableItemMeshes(IsOpen);
			((Behaviour)((Component)apparatusInSlot).gameObject.GetComponentInChildren<Light>()).enabled = IsOpen;
			AudioSource component = ((Component)apparatusInSlot).gameObject.GetComponent<AudioSource>();
			if (IsOpen)
			{
				if (((ILungPropInterface)apparatusInSlot).PowerRemaining > 0f)
				{
					component.loop = true;
					component.Play();
				}
			}
			else
			{
				component.Stop();
			}
		}

		public bool CanUsePower(float amount)
		{
			if ((Object)(object)apparatusInSlot == (Object)null)
			{
				return false;
			}
			return ((ILungPropInterface)apparatusInSlot).CanUsePower(amount);
		}

		public bool UsePower(float amount)
		{
			if ((Object)(object)apparatusInSlot == (Object)null)
			{
				return false;
			}
			bool flag = ((ILungPropInterface)apparatusInSlot).CanUsePower(amount);
			if (flag)
			{
				UsePowerRpc(amount);
			}
			return flag;
		}

		public void OnInteract()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if (!IsApparatusInSlot && !((Object)(object)Plugin.localPlayer.currentlyHeldObjectServer == (Object)null) && Plugin.localPlayer.currentlyHeldObjectServer is LungProp && !Plugin.localPlayer.isGrabbingObjectAnimation)
			{
				GrabbableObject currentlyHeldObjectServer = Plugin.localPlayer.currentlyHeldObjectServer;
				Plugin.localPlayer.DiscardHeldObject(true, ((NetworkBehaviour)this).NetworkObject, ((Component)((NetworkBehaviour)this).NetworkObject).transform.InverseTransformPoint(apparatusPosition.position), false);
				SetApparatusInSlotRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)currentlyHeldObjectServer).NetworkObject));
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void UsePowerRpc(float amount)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(46059577u, val3, val, (SendTo)6, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref amount, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendRpc(ref val2, 46059577u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1)
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if ((Object)(object)apparatusInSlot == (Object)null)
				{
					Plugin.logger.LogError((object)"Cant use power, apparatus not in slot");
				}
				else
				{
					((ILungPropInterface)apparatusInSlot).UsePower(amount);
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void SetApparatusInSlotRpc(NetworkObjectReference netRef)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1572961156u, val3, val, (SendTo)6, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendRpc(ref val2, 1572961156u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1)
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				NetworkObject val4 = default(NetworkObject);
				LungProp val5 = default(LungProp);
				if (!IsApparatusInSlot && ((NetworkObjectReference)(ref netRef)).TryGet(ref val4, (NetworkManager)null) && ((Component)val4).TryGetComponent<LungProp>(ref val5))
				{
					apparatusInSlot = val5;
					apparatusInSlot.isLungDockedInElevator = true;
					AudioSource component = ((Component)apparatusInSlot).gameObject.GetComponent<AudioSource>();
					component.PlayOneShot(apparatusInSlot.connectSFX);
					component.loop = true;
					component.Play();
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void TogglePortRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = new RpcAttributeParams
					{
						RequireOwnership = false
					};
					RpcParams val3 = default(RpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2793327561u, val3, val, (SendTo)6, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendRpc(ref val2, 2793327561u, val3, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1)
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					TogglePort();
				}
			}
		}

		protected override void __initializeVariables()