Decompiled source of MilkMolars v1.0.0

plugins/Snowlance.MilkMolars.dll

Decompiled a month ago
using System;
using System.Collections;
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 Microsoft.CodeAnalysis;
using MilkMolars;
using MoreShipUpgrades.Managers;
using Snowlance.MilkMolars.NetcodePatcher;
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: 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.MilkMolars")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a41481589c3399e66ec2246fe60b15b354113e74")]
[assembly: AssemblyProduct("MilkMolars")]
[assembly: AssemblyTitle("Snowlance.MilkMolars")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 MilkMolars
{
	[HarmonyPatch(typeof(DepositItemsDesk))]
	internal class DepositItemsDeskPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("delayedAcceptanceOfItems")]
		public static void DepositItemsDesk_delayedAcceptanceOfItems_PostFix(DepositItemsDesk __instance, GrabbableObject[] objectsOnDesk)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			foreach (GrabbableObject val in objectsOnDesk)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if (val is MilkMolarBehavior milkMolarBehavior)
				{
					if ((Object)(object)milkMolarBehavior.lastPlayerHeldBy != (Object)null)
					{
						milkMolarBehavior.ActivateMolarRpc((int)milkMolarBehavior.lastPlayerHeldBy.actualClientId);
					}
					else
					{
						milkMolarBehavior.ActivateMolarRpc();
					}
				}
				if (val is MegaMilkMolarBehavior megaMilkMolarBehavior)
				{
					if ((Object)(object)megaMilkMolarBehavior.lastPlayerHeldBy != (Object)null)
					{
						megaMilkMolarBehavior.ActivateMolarRpc((int)megaMilkMolarBehavior.lastPlayerHeldBy.actualClientId);
					}
					else
					{
						megaMilkMolarBehavior.ActivateMolarRpc();
					}
				}
			}
		}
	}
	internal class MegaMilkMolarBehavior : PhysicsProp
	{
		[HideInInspector]
		public PlayerControllerB? lastPlayerHeldBy;

		[HideInInspector]
		public PlayerControllerB? playerFoundBy;

		private Vector3 restingRotation = Vector3.zero;

		[HideInInspector]
		public NetworkVariable<int> ContributeAmount = new NetworkVariable<int>(1, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[HideInInspector]
		public NetworkVariable<int> SharedContributeAmount = new NetworkVariable<int>(1, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[HideInInspector]
		public NetworkVariable<Plugin.ActivateMethod> ActivateMethod = new NetworkVariable<Plugin.ActivateMethod>(Plugin.ActivateMethod.Use, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[HideInInspector]
		public NetworkVariable<bool> UpgradePointsToFinder = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[HideInInspector]
		public NetworkVariable<bool> NonPlayersCanActivate = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static bool PlaySound = true;

		public static float SoundVolume = 1f;

		public static bool ShowNotification = true;

		public static int cfgContributeAmount = 1;

		public static int cfgSharedContributeAmount = 1;

		public static Plugin.ActivateMethod cfgActivateMethod = Plugin.ActivateMethod.Use;

		public static bool cfgUpgradePointsToFinder = false;

		public static bool cfgNonPlayersCanActivate = false;

		[InitConfig]
		public static void Init()
		{
			PlaySound = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<bool>("Mega Milk Molar Options", "Mega Milk Molar | Play Sound", true, "Play sound when milk molar is activated").Value;
			SoundVolume = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<float>("Mega Milk Molar Options", "Mega Milk Molar | Sound Volume", 1f, "Sound volume when milk molar is activated").Value;
			ShowNotification = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<bool>("Mega Milk Molar Options", "Mega Milk Molar | Show Notification", true, "Show a notification on the HUD when a Mega Milk Molar is activated").Value;
			cfgContributeAmount = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<int>("Mega Milk Molar Options", "Mega Milk Molar | Contribute Amount", 3, "How many points to give to the player who activates it").Value;
			cfgSharedContributeAmount = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<int>("Mega Milk Molar Options", "Mega Milk Molar | Shared Contribute Amount", 3, "How many points to give to give other players (Only works if Shared is set to true)").Value;
			cfgActivateMethod = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<Plugin.ActivateMethod>("Mega Milk Molar Options", "Mega Milk Molar | Activate Method", Plugin.ActivateMethod.Grab, "Activation method for Mega Milk Molars.\nGrab: Grabbing the Mega Milk Molar will activate it.\nUse: Using the Mega Milk Molar while its in your inventory will activate it.\nShip: Mega Milk Molar will activate when brought inside the ship.\nSell: Mega Milk Molar will activate when sold to the company.").Value;
			cfgUpgradePointsToFinder = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<bool>("Mega Milk Molar Options", "Mega Milk Molar | Upgrade Points to Finder", false, "This only works when `ActivateMethod` is `SHIP` or `SELL`. Setting this to true will only give points(ContributeAmount) to the first person who held the Mega Milk Molar when activating it. SharedContributeAmount will be given to other players.").Value;
			cfgNonPlayersCanActivate = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<bool>("Mega Milk Molar Options", "Mega Milk Molar | NonPlayersCanActivate", false, "This only works if `ActivateMethod` is `ReturnToShip`. If true, if anything that isnt a player drops the milk molar in the ship, it will still activate and all players will get `SharedContributeAmount`.").Value;
		}

		public override void Start()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsServer)
			{
				ContributeAmount.Value = cfgContributeAmount;
				SharedContributeAmount.Value = cfgSharedContributeAmount;
				ActivateMethod.Value = cfgActivateMethod;
				UpgradePointsToFinder.Value = cfgUpgradePointsToFinder;
				NonPlayersCanActivate.Value = cfgNonPlayersCanActivate;
				if (Random.Range(0, 2) == 0)
				{
					SetRestingRotationRpc(new Vector3(90f, 0f, 0f));
				}
			}
			((GrabbableObject)this).Start();
			if (ActivateMethod.Value == Plugin.ActivateMethod.Use)
			{
				((GrabbableObject)this).itemProperties.toolTips = new string[1] { "Activate [LMB]" };
			}
			if (ActivateMethod.Value == Plugin.ActivateMethod.Grab)
			{
				((GrabbableObject)this).grabbable = false;
				((GrabbableObject)this).customGrabTooltip = "Activate [E]";
			}
		}

		public override void Update()
		{
			GameUpdate();
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				lastPlayerHeldBy = ((GrabbableObject)this).playerHeldBy;
				if (playerFoundBy == null)
				{
					playerFoundBy = ((GrabbableObject)this).playerHeldBy;
				}
			}
		}

		private void GameUpdate()
		{
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			if (((GrabbableObject)this).currentUseCooldown >= 0f)
			{
				((GrabbableObject)this).currentUseCooldown = ((GrabbableObject)this).currentUseCooldown - Time.deltaTime;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (((GrabbableObject)this).isBeingUsed && ((GrabbableObject)this).itemProperties.requiresBattery)
				{
					if (((GrabbableObject)this).insertedBattery.charge > 0f)
					{
						if (!((GrabbableObject)this).itemProperties.itemIsTrigger)
						{
							Battery insertedBattery = ((GrabbableObject)this).insertedBattery;
							insertedBattery.charge -= Time.deltaTime / ((GrabbableObject)this).itemProperties.batteryUsage;
						}
					}
					else if (!((GrabbableObject)this).insertedBattery.empty)
					{
						((GrabbableObject)this).insertedBattery.empty = true;
						if (((GrabbableObject)this).isBeingUsed)
						{
							Debug.Log((object)"Use up batteries local");
							((GrabbableObject)this).isBeingUsed = false;
							((GrabbableObject)this).UseUpBatteries();
							((GrabbableObject)this).UseUpItemBatteriesServerRpc();
						}
					}
				}
				if (!((GrabbableObject)this).wasOwnerLastFrame)
				{
					((GrabbableObject)this).wasOwnerLastFrame = true;
				}
			}
			else if (((GrabbableObject)this).wasOwnerLastFrame)
			{
				((GrabbableObject)this).wasOwnerLastFrame = false;
			}
			if (!((GrabbableObject)this).isHeld && (Object)(object)((GrabbableObject)this).parentObject == (Object)null)
			{
				if (((GrabbableObject)this).fallTime < 1f)
				{
					((GrabbableObject)this).reachedFloorTarget = false;
					((GrabbableObject)this).FallWithCurve();
					if (((Component)this).transform.localPosition.y - ((GrabbableObject)this).targetFloorPosition.y < 0.05f && !((GrabbableObject)this).hasHitGround)
					{
						((GrabbableObject)this).PlayDropSFX();
						((GrabbableObject)this).OnHitGround();
					}
					return;
				}
				if (!((GrabbableObject)this).reachedFloorTarget)
				{
					if (!((GrabbableObject)this).hasHitGround)
					{
						((GrabbableObject)this).PlayDropSFX();
						((GrabbableObject)this).OnHitGround();
					}
					((GrabbableObject)this).reachedFloorTarget = true;
					if (((GrabbableObject)this).floorYRot == -1)
					{
						((Component)this).transform.rotation = Quaternion.Euler(restingRotation.x, ((Component)this).transform.eulerAngles.y, restingRotation.z);
					}
					else
					{
						((Component)this).transform.rotation = Quaternion.Euler(restingRotation.x, (float)(((GrabbableObject)this).floorYRot + ((GrabbableObject)this).itemProperties.floorYOffset) + 90f, restingRotation.z);
					}
				}
				((Component)this).transform.localPosition = ((GrabbableObject)this).targetFloorPosition;
			}
			else
			{
				if (!((GrabbableObject)this).isHeld && !((GrabbableObject)this).isHeldByEnemy)
				{
					return;
				}
				((GrabbableObject)this).reachedFloorTarget = false;
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && !((GrabbableObject)this).isPocketed && ((GrabbableObject)this).playerHeldBy.scrapJiggleAudioDelay > -4f)
				{
					if (((GrabbableObject)this).playerHeldBy.scrapJiggleAudioDelay <= 0f)
					{
						((GrabbableObject)this).playerHeldBy.scrapJiggleAudioDelay = -5f;
						((GrabbableObject)this).JiggleItemEffect(Random.Range(0.18f, 0.36f));
					}
					else
					{
						PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy;
						playerHeldBy.scrapJiggleAudioDelay -= Time.deltaTime;
					}
				}
			}
		}

		public override void DiscardItem()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			if (ActivateMethod.Value == Plugin.ActivateMethod.ReturnToShip)
			{
				if (((NetworkBehaviour)this).IsOwner)
				{
					HUDManager.Instance.ClearControlTips();
					if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
					{
						((GrabbableObject)this).playerHeldBy.IsInspectingItem = false;
						((GrabbableObject)this).playerHeldBy.activatingItem = false;
					}
				}
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
				{
					if ((Object)(object)Plugin.localPlayer == (Object)(object)((GrabbableObject)this).playerHeldBy && ((GrabbableObject)this).playerHeldBy.isInHangarShipRoom)
					{
						ActivateMolarWithDelay((int)Plugin.localPlayer.actualClientId);
					}
				}
				else if (NonPlayersCanActivate.Value && ((Component)this).transform.position.y > -100f)
				{
					Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds;
					if (((Bounds)(ref bounds)).ClosestPoint(((Component)this).transform.position) == ((Component)this).transform.position)
					{
						ActivateMolarWithDelay();
					}
				}
				((GrabbableObject)this).playerHeldBy = null;
			}
			else
			{
				((GrabbableObject)this).DiscardItem();
			}
		}

		public void ActivateMolarWithDelay(int clientId = -1)
		{
			((MonoBehaviour)this).StartCoroutine(activateMolarWithDelay(clientId));
			IEnumerator activateMolarWithDelay(int playerActivatingId)
			{
				yield return null;
				ActivateMolarRpc(playerActivatingId);
			}
		}

		public override void InteractItem()
		{
			if (ActivateMethod.Value == Plugin.ActivateMethod.Grab)
			{
				ActivateMolarRpc((int)Plugin.localPlayer.actualClientId);
			}
			else
			{
				((GrabbableObject)this).InteractItem();
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && ((NetworkBehaviour)this).IsOwner && ActivateMethod.Value == Plugin.ActivateMethod.Use)
			{
				ActivateMolarRpc((int)Plugin.localPlayer.actualClientId);
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void ActivateMolarRpc(int playerActivatingId = -1)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0051: 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_0064: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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)((NetworkBehaviour)this).__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2518205547u, val3, val, (SendTo)6, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerActivatingId);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 2518205547u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			Plugin.logger.LogDebug((object)"Activating mega milk molar");
			PlayerControllerB val4 = ((playerActivatingId == -1) ? null : Plugin.PlayerFromId((ulong)playerActivatingId));
			val4 = (PlayerControllerB)((UpgradePointsToFinder.Value && (ActivateMethod.Value == Plugin.ActivateMethod.ReturnToShip || ActivateMethod.Value == Plugin.ActivateMethod.SellToCompany)) ? ((object)playerFoundBy) : ((object)val4));
			if ((Object)(object)Plugin.localPlayer == (Object)(object)val4 && ContributeAmount.Value > 0)
			{
				NotificationOverlay.ShowNotification(mega: true, ShowNotification, PlaySound, SoundVolume);
				Plugin.AddCurrency(ContributeAmount.Value);
			}
			else if ((Object)(object)Plugin.localPlayer != (Object)(object)val4 && SharedContributeAmount.Value > 0)
			{
				NotificationOverlay.ShowNotification(mega: true, ShowNotification, PlaySound, SoundVolume);
				Plugin.AddCurrency(SharedContributeAmount.Value);
			}
			switch (ActivateMethod.Value)
			{
			case Plugin.ActivateMethod.Grab:
				if (((NetworkBehaviour)this).IsServer)
				{
					((NetworkBehaviour)this).NetworkObject.Despawn(true);
				}
				break;
			case Plugin.ActivateMethod.Use:
				if (((NetworkBehaviour)this).IsOwner)
				{
					Plugin.localPlayer.DespawnHeldObject();
				}
				break;
			case Plugin.ActivateMethod.ReturnToShip:
				if (((NetworkBehaviour)this).IsServer)
				{
					((NetworkBehaviour)this).NetworkObject.Despawn(true);
				}
				break;
			case Plugin.ActivateMethod.SellToCompany:
				break;
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void SetRestingRotationRpc(Vector3 rotation)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0051: 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_0064: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = default(RpcAttributeParams);
					RpcParams val3 = default(RpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(353734868u, val3, val, (SendTo)6, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref rotation);
					((NetworkBehaviour)this).__endSendRpc(ref val2, 353734868u, val3, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					restingRotation = rotation;
				}
			}
		}

		protected override void __initializeVariables()
		{
			if (ContributeAmount == null)
			{
				throw new Exception("MegaMilkMolarBehavior.ContributeAmount cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)ContributeAmount).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)ContributeAmount, "ContributeAmount");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)ContributeAmount);
			if (SharedContributeAmount == null)
			{
				throw new Exception("MegaMilkMolarBehavior.SharedContributeAmount cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)SharedContributeAmount).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SharedContributeAmount, "SharedContributeAmount");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)SharedContributeAmount);
			if (ActivateMethod == null)
			{
				throw new Exception("MegaMilkMolarBehavior.ActivateMethod cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)ActivateMethod).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)ActivateMethod, "ActivateMethod");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)ActivateMethod);
			if (UpgradePointsToFinder == null)
			{
				throw new Exception("MegaMilkMolarBehavior.UpgradePointsToFinder cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)UpgradePointsToFinder).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)UpgradePointsToFinder, "UpgradePointsToFinder");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)UpgradePointsToFinder);
			if (NonPlayersCanActivate == null)
			{
				throw new Exception("MegaMilkMolarBehavior.NonPlayersCanActivate cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)NonPlayersCanActivate).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)NonPlayersCanActivate, "NonPlayersCanActivate");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)NonPlayersCanActivate);
			((PhysicsProp)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(2518205547u, new RpcReceiveHandler(__rpc_handler_2518205547), "ActivateMolarRpc");
			((NetworkBehaviour)this).__registerRpc(353734868u, new RpcReceiveHandler(__rpc_handler_353734868), "SetRestingRotationRpc");
			((PhysicsProp)this).__initializeRpcs();
		}

		private static void __rpc_handler_2518205547(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)
			{
				int playerActivatingId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerActivatingId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MegaMilkMolarBehavior)(object)target).ActivateMolarRpc(playerActivatingId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_353734868(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 restingRotationRpc = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref restingRotationRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MegaMilkMolarBehavior)(object)target).SetRestingRotationRpc(restingRotationRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "MegaMilkMolarBehavior";
		}
	}
	internal class MilkMolarBehavior : PhysicsProp
	{
		[HideInInspector]
		public PlayerControllerB? lastPlayerHeldBy;

		[HideInInspector]
		public PlayerControllerB? playerFoundBy;

		private Vector3 restingRotation = Vector3.zero;

		[HideInInspector]
		public NetworkVariable<int> ContributeAmount = new NetworkVariable<int>(1, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[HideInInspector]
		public NetworkVariable<int> SharedContributeAmount = new NetworkVariable<int>(1, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[HideInInspector]
		public NetworkVariable<Plugin.ActivateMethod> ActivateMethod = new NetworkVariable<Plugin.ActivateMethod>(Plugin.ActivateMethod.Use, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[HideInInspector]
		public NetworkVariable<bool> UpgradePointsToFinder = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[HideInInspector]
		public NetworkVariable<bool> NonPlayersCanActivate = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static bool PlaySound = true;

		public static float SoundVolume = 1f;

		public static bool ShowNotification = true;

		public static int cfgContributeAmount = 1;

		public static int cfgSharedContributeAmount = 1;

		public static Plugin.ActivateMethod cfgActivateMethod = Plugin.ActivateMethod.Use;

		public static bool cfgUpgradePointsToFinder = false;

		public static bool cfgNonPlayersCanActivate = false;

		[InitConfig]
		public static void Init()
		{
			PlaySound = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<bool>("Milk Molar Options", "Milk Molar | Play Sound", true, "Play sound when milk molar is activated").Value;
			SoundVolume = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<float>("Milk Molar Options", "Milk Molar | Sound Volume", 1f, "Sound volume when milk molar is activated").Value;
			ShowNotification = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<bool>("Milk Molar Options", "Milk Molar | Show Notification", true, "Show a notification on the HUD when a Milk Molar is activated").Value;
			cfgContributeAmount = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<int>("Milk Molar Options", "Milk Molar | Contribute Amount", 1, "How many points to give to the player who activates it").Value;
			cfgSharedContributeAmount = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<int>("Milk Molar Options", "Milk Molar | Shared Contribute Amount", 1, "How many points to give to give other players (Only works if Shared is set to true)").Value;
			cfgActivateMethod = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<Plugin.ActivateMethod>("Milk Molar Options", "Milk Molar | Activate Method", Plugin.ActivateMethod.Grab, "Activation method for Milk Molars.\nGrab: Grabbing the Milk Molar will activate it.\nUse: Using the Milk Molar while its in your inventory will activate it.\nShip: Milk Molar will activate when brought inside the ship.\nSell: Milk Molar will activate when sold to the company.").Value;
			cfgUpgradePointsToFinder = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<bool>("Milk Molar Options", "Milk Molar | Upgrade Points to Finder", false, "This only works when `ActivateMethod` is `SHIP` or `SELL`. Setting this to true will only give points(ContributeAmount) to the first person who held the Milk Molar when activating it. SharedContributeAmount will be given to other players.").Value;
			cfgNonPlayersCanActivate = ((BaseUnityPlugin)Plugin.PluginInstance).Config.Bind<bool>("Milk Molar Options", "Milk Molar | NonPlayersCanActivate", false, "This only works if `ActivateMethod` is `ReturnToShip`. If true, if anything that isnt a player drops the milk molar in the ship, it will still activate and all players will get `SharedContributeAmount`.").Value;
		}

		public override void Start()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsServer)
			{
				ContributeAmount.Value = cfgContributeAmount;
				SharedContributeAmount.Value = cfgSharedContributeAmount;
				ActivateMethod.Value = cfgActivateMethod;
				UpgradePointsToFinder.Value = cfgUpgradePointsToFinder;
				NonPlayersCanActivate.Value = cfgNonPlayersCanActivate;
				if (Random.Range(0, 2) == 0)
				{
					SetRestingRotationRpc(new Vector3(90f, 0f, 0f));
				}
			}
			((GrabbableObject)this).Start();
			if (ActivateMethod.Value == Plugin.ActivateMethod.Use)
			{
				((GrabbableObject)this).itemProperties.toolTips = new string[1] { "Activate [LMB]" };
			}
			if (ActivateMethod.Value == Plugin.ActivateMethod.Grab)
			{
				((GrabbableObject)this).grabbable = false;
				((GrabbableObject)this).customGrabTooltip = "Activate [E]";
			}
		}

		public override void Update()
		{
			GameUpdate();
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				lastPlayerHeldBy = ((GrabbableObject)this).playerHeldBy;
				if (playerFoundBy == null)
				{
					playerFoundBy = ((GrabbableObject)this).playerHeldBy;
				}
			}
		}

		private void GameUpdate()
		{
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			if (((GrabbableObject)this).currentUseCooldown >= 0f)
			{
				((GrabbableObject)this).currentUseCooldown = ((GrabbableObject)this).currentUseCooldown - Time.deltaTime;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (((GrabbableObject)this).isBeingUsed && ((GrabbableObject)this).itemProperties.requiresBattery)
				{
					if (((GrabbableObject)this).insertedBattery.charge > 0f)
					{
						if (!((GrabbableObject)this).itemProperties.itemIsTrigger)
						{
							Battery insertedBattery = ((GrabbableObject)this).insertedBattery;
							insertedBattery.charge -= Time.deltaTime / ((GrabbableObject)this).itemProperties.batteryUsage;
						}
					}
					else if (!((GrabbableObject)this).insertedBattery.empty)
					{
						((GrabbableObject)this).insertedBattery.empty = true;
						if (((GrabbableObject)this).isBeingUsed)
						{
							Debug.Log((object)"Use up batteries local");
							((GrabbableObject)this).isBeingUsed = false;
							((GrabbableObject)this).UseUpBatteries();
							((GrabbableObject)this).UseUpItemBatteriesServerRpc();
						}
					}
				}
				if (!((GrabbableObject)this).wasOwnerLastFrame)
				{
					((GrabbableObject)this).wasOwnerLastFrame = true;
				}
			}
			else if (((GrabbableObject)this).wasOwnerLastFrame)
			{
				((GrabbableObject)this).wasOwnerLastFrame = false;
			}
			if (!((GrabbableObject)this).isHeld && (Object)(object)((GrabbableObject)this).parentObject == (Object)null)
			{
				if (((GrabbableObject)this).fallTime < 1f)
				{
					((GrabbableObject)this).reachedFloorTarget = false;
					((GrabbableObject)this).FallWithCurve();
					if (((Component)this).transform.localPosition.y - ((GrabbableObject)this).targetFloorPosition.y < 0.05f && !((GrabbableObject)this).hasHitGround)
					{
						((GrabbableObject)this).PlayDropSFX();
						((GrabbableObject)this).OnHitGround();
					}
					return;
				}
				if (!((GrabbableObject)this).reachedFloorTarget)
				{
					if (!((GrabbableObject)this).hasHitGround)
					{
						((GrabbableObject)this).PlayDropSFX();
						((GrabbableObject)this).OnHitGround();
					}
					((GrabbableObject)this).reachedFloorTarget = true;
					if (((GrabbableObject)this).floorYRot == -1)
					{
						((Component)this).transform.rotation = Quaternion.Euler(restingRotation.x, ((Component)this).transform.eulerAngles.y, restingRotation.z);
					}
					else
					{
						((Component)this).transform.rotation = Quaternion.Euler(restingRotation.x, (float)(((GrabbableObject)this).floorYRot + ((GrabbableObject)this).itemProperties.floorYOffset) + 90f, restingRotation.z);
					}
				}
				((Component)this).transform.localPosition = ((GrabbableObject)this).targetFloorPosition;
			}
			else
			{
				if (!((GrabbableObject)this).isHeld && !((GrabbableObject)this).isHeldByEnemy)
				{
					return;
				}
				((GrabbableObject)this).reachedFloorTarget = false;
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && !((GrabbableObject)this).isPocketed && ((GrabbableObject)this).playerHeldBy.scrapJiggleAudioDelay > -4f)
				{
					if (((GrabbableObject)this).playerHeldBy.scrapJiggleAudioDelay <= 0f)
					{
						((GrabbableObject)this).playerHeldBy.scrapJiggleAudioDelay = -5f;
						((GrabbableObject)this).JiggleItemEffect(Random.Range(0.18f, 0.36f));
					}
					else
					{
						PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy;
						playerHeldBy.scrapJiggleAudioDelay -= Time.deltaTime;
					}
				}
			}
		}

		public override void DiscardItem()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			if (ActivateMethod.Value == Plugin.ActivateMethod.ReturnToShip)
			{
				if (((NetworkBehaviour)this).IsOwner)
				{
					HUDManager.Instance.ClearControlTips();
					if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
					{
						((GrabbableObject)this).playerHeldBy.IsInspectingItem = false;
						((GrabbableObject)this).playerHeldBy.activatingItem = false;
					}
				}
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
				{
					if ((Object)(object)Plugin.localPlayer == (Object)(object)((GrabbableObject)this).playerHeldBy && ((GrabbableObject)this).playerHeldBy.isInHangarShipRoom)
					{
						ActivateMolarWithDelay((int)Plugin.localPlayer.actualClientId);
					}
				}
				else if (NonPlayersCanActivate.Value && ((Component)this).transform.position.y > -100f)
				{
					Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds;
					if (((Bounds)(ref bounds)).ClosestPoint(((Component)this).transform.position) == ((Component)this).transform.position)
					{
						ActivateMolarWithDelay();
					}
				}
				((GrabbableObject)this).playerHeldBy = null;
			}
			else
			{
				((GrabbableObject)this).DiscardItem();
			}
		}

		public void ActivateMolarWithDelay(int clientId = -1)
		{
			((MonoBehaviour)this).StartCoroutine(activateMolarWithDelay(clientId));
			IEnumerator activateMolarWithDelay(int playerActivatingId)
			{
				yield return null;
				ActivateMolarRpc(playerActivatingId);
			}
		}

		public override void InteractItem()
		{
			if (ActivateMethod.Value == Plugin.ActivateMethod.Grab)
			{
				ActivateMolarRpc((int)Plugin.localPlayer.actualClientId);
			}
			else
			{
				((GrabbableObject)this).InteractItem();
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && ((NetworkBehaviour)this).IsOwner && ActivateMethod.Value == Plugin.ActivateMethod.Use)
			{
				ActivateMolarRpc((int)Plugin.localPlayer.actualClientId);
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void ActivateMolarRpc(int playerActivatingId = -1)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0051: 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_0064: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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)((NetworkBehaviour)this).__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3130653740u, val3, val, (SendTo)6, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerActivatingId);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 3130653740u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			Plugin.logger.LogDebug((object)"Activating milk molar");
			PlayerControllerB val4 = ((playerActivatingId == -1) ? null : Plugin.PlayerFromId((ulong)playerActivatingId));
			val4 = (PlayerControllerB)((UpgradePointsToFinder.Value && (ActivateMethod.Value == Plugin.ActivateMethod.ReturnToShip || ActivateMethod.Value == Plugin.ActivateMethod.SellToCompany)) ? ((object)playerFoundBy) : ((object)val4));
			if ((Object)(object)Plugin.localPlayer == (Object)(object)val4 && ContributeAmount.Value > 0)
			{
				NotificationOverlay.ShowNotification(mega: false, ShowNotification, PlaySound, SoundVolume);
				Plugin.AddCurrency(ContributeAmount.Value);
			}
			else if ((Object)(object)Plugin.localPlayer != (Object)(object)val4 && SharedContributeAmount.Value > 0)
			{
				NotificationOverlay.ShowNotification(mega: false, ShowNotification, PlaySound, SoundVolume);
				Plugin.AddCurrency(SharedContributeAmount.Value);
			}
			switch (ActivateMethod.Value)
			{
			case Plugin.ActivateMethod.Grab:
				if (((NetworkBehaviour)this).IsServer)
				{
					((NetworkBehaviour)this).NetworkObject.Despawn(true);
				}
				break;
			case Plugin.ActivateMethod.Use:
				if (((NetworkBehaviour)this).IsOwner)
				{
					Plugin.localPlayer.DespawnHeldObject();
				}
				break;
			case Plugin.ActivateMethod.ReturnToShip:
				if (((NetworkBehaviour)this).IsServer)
				{
					((NetworkBehaviour)this).NetworkObject.Despawn(true);
				}
				break;
			case Plugin.ActivateMethod.SellToCompany:
				break;
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void SetRestingRotationRpc(Vector3 rotation)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0051: 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_0064: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = default(RpcAttributeParams);
					RpcParams val3 = default(RpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2658894359u, val3, val, (SendTo)6, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref rotation);
					((NetworkBehaviour)this).__endSendRpc(ref val2, 2658894359u, val3, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					restingRotation = rotation;
				}
			}
		}

		protected override void __initializeVariables()
		{
			if (ContributeAmount == null)
			{
				throw new Exception("MilkMolarBehavior.ContributeAmount cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)ContributeAmount).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)ContributeAmount, "ContributeAmount");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)ContributeAmount);
			if (SharedContributeAmount == null)
			{
				throw new Exception("MilkMolarBehavior.SharedContributeAmount cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)SharedContributeAmount).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SharedContributeAmount, "SharedContributeAmount");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)SharedContributeAmount);
			if (ActivateMethod == null)
			{
				throw new Exception("MilkMolarBehavior.ActivateMethod cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)ActivateMethod).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)ActivateMethod, "ActivateMethod");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)ActivateMethod);
			if (UpgradePointsToFinder == null)
			{
				throw new Exception("MilkMolarBehavior.UpgradePointsToFinder cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)UpgradePointsToFinder).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)UpgradePointsToFinder, "UpgradePointsToFinder");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)UpgradePointsToFinder);
			if (NonPlayersCanActivate == null)
			{
				throw new Exception("MilkMolarBehavior.NonPlayersCanActivate cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)NonPlayersCanActivate).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)NonPlayersCanActivate, "NonPlayersCanActivate");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)NonPlayersCanActivate);
			((PhysicsProp)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(3130653740u, new RpcReceiveHandler(__rpc_handler_3130653740), "ActivateMolarRpc");
			((NetworkBehaviour)this).__registerRpc(2658894359u, new RpcReceiveHandler(__rpc_handler_2658894359), "SetRestingRotationRpc");
			((PhysicsProp)this).__initializeRpcs();
		}

		private static void __rpc_handler_3130653740(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)
			{
				int playerActivatingId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerActivatingId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MilkMolarBehavior)(object)target).ActivateMolarRpc(playerActivatingId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2658894359(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 restingRotationRpc = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref restingRotationRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MilkMolarBehavior)(object)target).SetRestingRotationRpc(restingRotationRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "MilkMolarBehavior";
		}
	}
	public class MilkMolarsContentHandler : ContentHandler<MilkMolarsContentHandler>
	{
		public class MilkMolarsAssetsAssets : AssetBundleLoader<MilkMolarsAssetsAssets>
		{
			[LoadFromBundle("NotificationOverlay.prefab")]
			public GameObject NotificationOverlayPrefab { get; private set; } = null;

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

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

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

		public MilkMolarsAssetsAssets? MilkMolarsAssets;

		public MilkMolarAssets? MilkMolar;

		public MegaMilkMolarAssets? MegaMilkMolar;

		public MilkMolarsContentHandler(DuskMod mod)
			: base(mod)
		{
			((ContentHandler)this).RegisterContent<MilkMolarsAssetsAssets>("milkmolars_assets", ref MilkMolarsAssets, false);
			((ContentHandler)this).RegisterContent<MilkMolarAssets>("milkmolar", ref MilkMolar, false);
			((ContentHandler)this).RegisterContent<MegaMilkMolarAssets>("megamilkmolar", ref MegaMilkMolar, false);
		}
	}
	public static class MilkMolarsKeys
	{
		public static readonly NamespacedKey<DawnItemInfo> MilkMolar = NamespacedKey<DawnItemInfo>.From("milkmolars", "milk_molar");

		public static readonly NamespacedKey<DawnItemInfo> MegaMilkMolar = NamespacedKey<DawnItemInfo>.From("milkmolars", "mega_milk_molar");
	}
	internal class NotificationOverlay : MonoBehaviour
	{
		public Animator animator = null;

		public AudioSource audioSource = null;

		public static void ShowNotification(bool mega, bool showVisual, bool playSFX, float volume)
		{
			if (!showVisual && !playSFX)
			{
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(ContentHandler<MilkMolarsContentHandler>.Instance.MilkMolarsAssets.NotificationOverlayPrefab);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			NotificationOverlay component = val.GetComponent<NotificationOverlay>();
			if (!((Object)(object)component == (Object)null))
			{
				if (showVisual)
				{
					component.animator.SetTrigger(mega ? "showmega" : "show");
				}
				if (playSFX)
				{
					component.audioSource.volume = volume;
					component.audioSource.Play();
				}
				Object.Destroy((Object)(object)val, 6f);
			}
		}
	}
	[BepInPlugin("Snowlance.MilkMolars", "MilkMolars", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public enum ActivateMethod
		{
			Grab,
			Use,
			ReturnToShip,
			SellToCompany
		}

		private readonly Harmony harmony = new Harmony("Snowlance.MilkMolars");

		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), "milkmolars_mainassets"));
			Mod = DuskMod.RegisterMod((BaseUnityPlugin)(object)this, val);
			Mod.RegisterContentHandlers();
			InitializeNetworkBehaviours();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Snowlance.MilkMolars v1.0.0 has loaded!");
		}

		public static void AddCurrency(int amount)
		{
			CurrencyManager.Instance.AddCurrencyAmount(amount, false);
		}

		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);
					}
				}
			}
			logger.LogDebug((object)"Finished initializing network behaviours");
		}
	}
	[HarmonyPatch]
	public static class TESTING
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
		public static void PingScan_performedPostFix()
		{
			if (Utils.testing)
			{
			}
		}

		[StaticUpdate]
		public static void Update()
		{
			if (Utils.testing)
			{
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		public static void SubmitChat_performedPrefix(HUDManager __instance)
		{
			try
			{
				if (Utils.testing && ((NetworkBehaviour)__instance).IsServer)
				{
					string text = __instance.chatTextField.text;
					string[] array = text.Split(" ");
					string text2 = array[0];
					string text3 = text2;
				}
			}
			catch (Exception ex)
			{
				Plugin.logger.LogError((object)ex);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Snowlance.MilkMolars";

		public const string PLUGIN_NAME = "MilkMolars";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<Plugin.ActivateMethod>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<Plugin.ActivateMethod>();
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		}
	}
}
namespace Snowlance.MilkMolars.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}