Decompiled source of Biodiversity v0.2.8

BepInEx/plugins/Biodiversity/com.github.biodiversitylc.Biodiversity.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Biodiversity.Behaviours;
using Biodiversity.Behaviours.Heat;
using Biodiversity.Behaviours.Player;
using Biodiversity.Core.AssetLoading;
using Biodiversity.Core.Attributes;
using Biodiversity.Core.Config;
using Biodiversity.Core.Lang;
using Biodiversity.Creatures;
using Biodiversity.Creatures.Aloe;
using Biodiversity.Creatures.Aloe.BehaviourStates;
using Biodiversity.Creatures.Aloe.Types;
using Biodiversity.Creatures.Aloe.Types.Networking;
using Biodiversity.Creatures.ClockworkAngel.Scripts;
using Biodiversity.Creatures.CoilCrab;
using Biodiversity.Creatures.Core;
using Biodiversity.Creatures.Core.Search;
using Biodiversity.Creatures.Core.StateMachine;
using Biodiversity.Creatures.WaxSoldier.Animation;
using Biodiversity.Creatures.WaxSoldier.BehaviourStates;
using Biodiversity.Creatures.WaxSoldier.Misc;
using Biodiversity.Creatures.WaxSoldier.Misc.AttackActions;
using Biodiversity.Creatures.WaxSoldier.SearchStrategies;
using Biodiversity.Creatures.WaxSoldier.Transitions;
using Biodiversity.Items;
using Biodiversity.Items.DeveloperItems;
using Biodiversity.Items.Developeritems;
using Biodiversity.Patches;
using Biodiversity.Util;
using Biodiversity.Util.Animation;
using Biodiversity.Util.DataStructures;
using Biodiversity.Util.Scripts;
using Biodiversity.Util.SharedVariables;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using JetBrains.Annotations;
using LethalLevelLoader;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Linq;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations.Rigging;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Pool;
using UnityEngine.ProBuilder;
using UnityEngine.Scripting;
using UnityEngine.VFX;
using UnityEngine.Video;
using com.github.biodiversitylc.Biodiversity.NetcodePatcher;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[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("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("LethalLevelLoader")]
[assembly: IgnoresAccessChecksTo("LethalLib")]
[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("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("com.github.biodiversitylc.Biodiversity")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.8.0")]
[assembly: AssemblyInformationalVersion("0.2.8+0722bce3a154a21b2cbb3208558f081adad2e5b1")]
[assembly: AssemblyProduct("Biodiversity")]
[assembly: AssemblyTitle("com.github.biodiversitylc.Biodiversity")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.8.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class EasyIK : MonoBehaviour
{
	[Header("IK properties")]
	public int numberOfJoints = 2;

	public Transform ikTarget;

	public int iterations = 10;

	public float tolerance = 0.05f;

	private Transform[] jointTransforms;

	private Vector3 startPosition;

	private Vector3[] jointPositions;

	private float[] boneLength;

	private float jointChainLength;

	private float distanceToTarget;

	private Quaternion[] startRotation;

	private Vector3[] jointStartDirection;

	private Quaternion ikTargetStartRot;

	private Quaternion lastJointStartRot;

	[Header("Pole target (3 joint chain)")]
	public Transform poleTarget;

	[Header("Debug")]
	public bool debugJoints = true;

	public bool localRotationAxis;

	[Range(0f, 1f)]
	public float gizmoSize = 0.05f;

	public bool poleDirection;

	public bool poleRotationAxis;

	public GameObject anotherObject;

	private void Awake()
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		jointChainLength = 0f;
		jointTransforms = (Transform[])(object)new Transform[numberOfJoints];
		jointPositions = (Vector3[])(object)new Vector3[numberOfJoints];
		boneLength = new float[numberOfJoints];
		jointStartDirection = (Vector3[])(object)new Vector3[numberOfJoints];
		startRotation = (Quaternion[])(object)new Quaternion[numberOfJoints];
		ikTargetStartRot = ikTarget.rotation;
		Transform val = ((Component)this).transform;
		for (int i = 0; i < jointTransforms.Length; i++)
		{
			jointTransforms[i] = val;
			if (i == jointTransforms.Length - 1)
			{
				lastJointStartRot = val.rotation;
				break;
			}
			boneLength[i] = Vector3.Distance(val.position, val.GetChild(0).position);
			jointChainLength += boneLength[i];
			jointStartDirection[i] = val.GetChild(0).position - val.position;
			startRotation[i] = val.rotation;
			val = val.GetChild(0);
		}
	}

	private void Start()
	{
	}

	private void PoleConstraint()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: 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_003a: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: 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_00aa: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: 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_00dc: 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)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)poleTarget != (Object)null && numberOfJoints < 4)
		{
			Vector3 val = jointPositions[2] - jointPositions[0];
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			val = poleTarget.position - jointPositions[0];
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			val = jointPositions[1] - jointPositions[0];
			Vector3 normalized3 = ((Vector3)(ref val)).normalized;
			Vector3.OrthoNormalize(ref normalized, ref normalized2);
			Vector3.OrthoNormalize(ref normalized, ref normalized3);
			Quaternion val2 = Quaternion.FromToRotation(normalized3, normalized2);
			jointPositions[1] = val2 * (jointPositions[1] - jointPositions[0]) + jointPositions[0];
		}
	}

	private void Backward()
	{
		//IL_004b: 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_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: 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_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		for (int num = jointPositions.Length - 1; num >= 0; num--)
		{
			if (num == jointPositions.Length - 1)
			{
				jointPositions[num] = ((Component)ikTarget).transform.position;
			}
			else
			{
				Vector3[] array = jointPositions;
				int num2 = num;
				Vector3 val = jointPositions[num + 1];
				Vector3 val2 = jointPositions[num] - jointPositions[num + 1];
				array[num2] = val + ((Vector3)(ref val2)).normalized * boneLength[num];
			}
		}
	}

	private void Forward()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: 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_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < jointPositions.Length; i++)
		{
			if (i == 0)
			{
				jointPositions[i] = startPosition;
				continue;
			}
			Vector3[] array = jointPositions;
			int num = i;
			Vector3 val = jointPositions[i - 1];
			Vector3 val2 = jointPositions[i] - jointPositions[i - 1];
			array[num] = val + ((Vector3)(ref val2)).normalized * boneLength[i - 1];
		}
	}

	private void SolveIK()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: 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_0062: 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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < jointTransforms.Length; i++)
		{
			jointPositions[i] = jointTransforms[i].position;
		}
		distanceToTarget = Vector3.Distance(jointPositions[0], ikTarget.position);
		if (distanceToTarget > jointChainLength)
		{
			Vector3 val = ikTarget.position - jointPositions[0];
			for (int j = 1; j < jointPositions.Length; j++)
			{
				jointPositions[j] = jointPositions[j - 1] + ((Vector3)(ref val)).normalized * boneLength[j - 1];
			}
		}
		else
		{
			float num = Vector3.Distance(jointPositions[jointPositions.Length - 1], ikTarget.position);
			float num2 = 0f;
			while (num > tolerance)
			{
				startPosition = jointPositions[0];
				Backward();
				Forward();
				num2 += 1f;
				if (num2 > (float)iterations)
				{
					break;
				}
			}
		}
		PoleConstraint();
		for (int k = 0; k < jointPositions.Length - 1; k++)
		{
			jointTransforms[k].position = jointPositions[k];
			Quaternion val2 = Quaternion.FromToRotation(jointStartDirection[k], jointPositions[k + 1] - jointPositions[k]);
			jointTransforms[k].rotation = val2 * startRotation[k] * anotherObject.transform.rotation;
		}
		Quaternion val3 = lastJointStartRot * Quaternion.Inverse(ikTargetStartRot);
		jointTransforms.Last().rotation = ikTarget.rotation * val3;
	}

	private void LateUpdate()
	{
		SolveIK();
	}

	private void OnDrawGizmos()
	{
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: 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: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: 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_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		if (debugJoints)
		{
			Transform val = ((Component)this).transform;
			Transform child = ((Component)this).transform.GetChild(0);
			for (int i = 0; i < numberOfJoints; i++)
			{
				Vector3 val2;
				if (i == numberOfJoints - 2)
				{
					float num = Vector3.Distance(val.position, child.position);
					Vector3 position = val.position;
					val2 = child.position - val.position;
					Vector3 pos = position + ((Vector3)(ref val2)).normalized * num / 2f;
					Vector3 up = Vector3.up;
					val2 = child.position - val.position;
					DrawWireCapsule(pos, Quaternion.FromToRotation(up, ((Vector3)(ref val2)).normalized), gizmoSize, num, Color.cyan);
					break;
				}
				float num2 = Vector3.Distance(val.position, child.position);
				Vector3 position2 = val.position;
				val2 = child.position - val.position;
				Vector3 pos2 = position2 + ((Vector3)(ref val2)).normalized * num2 / 2f;
				Vector3 up2 = Vector3.up;
				val2 = child.position - val.position;
				DrawWireCapsule(pos2, Quaternion.FromToRotation(up2, ((Vector3)(ref val2)).normalized), gizmoSize, num2, Color.cyan);
				val = val.GetChild(0);
				child = val.GetChild(0);
			}
		}
		if (localRotationAxis)
		{
			Transform val3 = ((Component)this).transform;
			for (int j = 0; j < numberOfJoints; j++)
			{
				if (j == numberOfJoints - 1)
				{
					drawHandle(val3);
					continue;
				}
				drawHandle(val3);
				val3 = val3.GetChild(0);
			}
		}
		Transform transform = ((Component)this).transform;
		Transform child2 = transform.GetChild(0);
		Transform child3 = child2.GetChild(0);
	}

	private void drawHandle(Transform debugJoint)
	{
	}

	public static void DrawWireCapsule(Vector3 _pos, Quaternion _rot, float _radius, float _height, Color _color = default(Color))
	{
	}
}
[RequireComponent(typeof(Rigidbody), typeof(Collider))]
public class WaxSoldierBayonetAttackPhysics : NetworkBehaviour
{
	public enum BayonentMode
	{
		None,
		Spin,
		Stab
	}

	[Header("Attack Properties")]
	[SerializeField]
	private int spinDamage = 40;

	[SerializeField]
	private float spinKnockback = 16f;

	[SerializeField]
	private int stabDamage = 50;

	[SerializeField]
	private float stabKnockback = 8f;

	[Tooltip("How long (in seconds) a player is immune after being hit.")]
	[SerializeField]
	private float hitCooldown = 0.5f;

	[Header("References")]
	[SerializeField]
	private Transform bayonetTip;

	[SerializeField]
	public BoxCollider bayonetCollider;

	[SerializeField]
	private AudioSource audioSource;

	[SerializeField]
	private AudioClip stabIntoFleshSfx;

	public BayonentMode currentBayonetMode;

	private Collider[] bayonetHitBuffer;

	private readonly PlayerCooldownTracker _playerCooldownTracker = new PlayerCooldownTracker();

	private CachedValue<Vector3> _bayonetColliderHalfExtents;

	private Vector3 previousTipPosition;

	private int _bayonetHitMask;

	private void Awake()
	{
		bayonetHitBuffer = (Collider[])(object)new Collider[15];
		_bayonetHitMask = 1084754248;
		Rigidbody val = default(Rigidbody);
		if (((Component)this).TryGetComponent<Rigidbody>(ref val))
		{
			val.collisionDetectionMode = (CollisionDetectionMode)3;
			val.isKinematic = true;
		}
	}

	public override void OnNetworkSpawn()
	{
		((NetworkBehaviour)this).OnNetworkSpawn();
		if (!((NetworkBehaviour)this).IsServer)
		{
			((Behaviour)this).enabled = false;
		}
		else
		{
			EndAttack();
		}
	}

	private void Start()
	{
		_bayonetColliderHalfExtents = new CachedValue<Vector3>(() => bayonetCollider.size * 0.75f);
	}

	private void FixedUpdate()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: 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_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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)
		if (currentBayonetMode == BayonentMode.None)
		{
			return;
		}
		Vector3 position = bayonetTip.position;
		Vector3 val = position - previousTipPosition;
		if (((Vector3)(ref val)).magnitude > 0.01f)
		{
			int num = Physics.OverlapBoxNonAlloc(((Component)bayonetCollider).transform.position, _bayonetColliderHalfExtents.Value, bayonetHitBuffer, ((Component)bayonetCollider).transform.rotation, _bayonetHitMask, (QueryTriggerInteraction)2);
			for (int i = 0; i < num; i++)
			{
				Collider entity = bayonetHitBuffer[i];
				TryToDamageEntity(entity);
			}
		}
		previousTipPosition = position;
	}

	private bool TryToDamageEntity(Collider entity)
	{
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB val = default(PlayerControllerB);
		if (((Component)entity).CompareTag("Player") && ((Component)entity).TryGetComponent<PlayerControllerB>(ref val) && !PlayerUtil.IsPlayerDead(val))
		{
			ulong clientIdFromPlayer = PlayerUtil.GetClientIdFromPlayer(val);
			if (_playerCooldownTracker.IsOnCooldown(clientIdFromPlayer))
			{
				return false;
			}
			int damage = 0;
			float num = 0f;
			switch (currentBayonetMode)
			{
			case BayonentMode.Spin:
				damage = spinDamage;
				num = spinKnockback;
				break;
			case BayonentMode.Stab:
				damage = stabDamage;
				num = stabKnockback;
				break;
			}
			Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position;
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			DamagePlayerClientRpc(clientIdFromPlayer, damage, normalized * num, (CauseOfDeath)14);
			_playerCooldownTracker.Start(clientIdFromPlayer, hitCooldown);
			return true;
		}
		return false;
	}

	public void BeginAttack(BayonentMode mode)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		currentBayonetMode = mode;
		previousTipPosition = ((Component)bayonetTip).transform.position;
		((Behaviour)this).enabled = true;
	}

	public void EndAttack()
	{
		currentBayonetMode = BayonentMode.None;
		((Behaviour)this).enabled = false;
	}

	[ClientRpc]
	private void DamagePlayerClientRpc(ulong playerId, int damage, Vector3 force = default(Vector3), CauseOfDeath causeOfDeath = 0)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Invalid comparison between Unknown and I4
		//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3907917724u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, playerId);
			BytePacker.WriteValueBitPacked(val2, damage);
			((FastBufferWriter)(ref val2)).WriteValueSafe(ref force);
			((FastBufferWriter)(ref val2)).WriteValueSafe<CauseOfDeath>(ref causeOfDeath, default(ForEnums));
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3907917724u, val, (RpcDelivery)0);
		}
		if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
		{
			return;
		}
		base.__rpc_exec_stage = (__RpcExecStage)0;
		PlayerControllerB playerFromClientId = PlayerUtil.GetPlayerFromClientId(playerId);
		if (Object.op_Implicit((Object)(object)playerFromClientId))
		{
			if ((Object)(object)playerFromClientId == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				playerFromClientId.DamagePlayer(damage, true, true, causeOfDeath, 0, true, force);
			}
			float pitch = audioSource.pitch;
			if (audioSource.isPlaying)
			{
				audioSource.Stop();
			}
			audioSource.pitch = Random.Range(pitch - 0.1f, pitch + 0.1f);
			audioSource.PlayOneShot(stabIntoFleshSfx);
			WalkieTalkie.TransmitOneShotAudio(audioSource, stabIntoFleshSfx, audioSource.volume);
			audioSource.pitch = pitch;
		}
	}

	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
		((NetworkBehaviour)this).__registerRpc(3907917724u, new RpcReceiveHandler(__rpc_handler_3907917724), "DamagePlayerClientRpc");
		((NetworkBehaviour)this).__initializeRpcs();
	}

	private static void __rpc_handler_3907917724(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: 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_0091: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			ulong playerId = default(ulong);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
			int damage = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref damage);
			Vector3 force = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref force);
			CauseOfDeath causeOfDeath = default(CauseOfDeath);
			((FastBufferReader)(ref reader)).ReadValueSafe<CauseOfDeath>(ref causeOfDeath, default(ForEnums));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((WaxSoldierBayonetAttackPhysics)(object)target).DamagePlayerClientRpc(playerId, damage, force, causeOfDeath);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining)]
	protected internal override string __getTypeName()
	{
		return "WaxSoldierBayonetAttackPhysics";
	}
}
namespace Biodiversity
{
	public class BiodiversityConfig : BiodiverseConfigLoader<BiodiversityConfig>
	{
		private readonly HashSet<string> _enabledCreatures = new HashSet<string>();

		[field: NonSerialized]
		public string Language { get; private set; } = "en";


		[field: Header("Development")]
		[field: Tooltip("Whether to log more debug information to the console. 99% of people do NOT need to touch this.")]
		public bool VerboseLoggingEnabled { get; private set; }

		[field: Header("Other")]
		[field: Tooltip("The stab is real.")]
		public bool StabIsReal { get; private set; }

		internal BiodiversityConfig(ConfigFile configFile)
			: base(configFile)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			Dictionary<string, string> availableLanguages = BiodiversityPlugin.Instance.Localization.GetAvailableLanguages();
			AcceptableValueList<string> val = ((availableLanguages != null) ? new AcceptableValueList<string>(availableLanguages.Keys.ToArray()) : new AcceptableValueList<string>(new string[5] { "en", "es", "de", "ru", "fr" }));
			Language = configFile.Bind<string>("General", "Language", Language, new ConfigDescription("What language should Biodiversity use?\nSome languages may also need FontPatcher(https://thunderstore.io/c/lethal-company/p/LeKAKiD/FontPatcher/)\n", (AcceptableValueBase)(object)val, Array.Empty<object>())).Value;
		}

		internal void AddEnabledCreature(string creatureName)
		{
			BiodiversityPlugin.LogVerbose("[BiodiversityConfig] Adding enabled creature: " + creatureName);
			_enabledCreatures.Add(creatureName);
		}

		internal bool IsCreatureEnabled(string creatureName)
		{
			return _enabledCreatures.Contains(creatureName);
		}
	}
	[BepInPlugin("com.github.biodiversitylc.Biodiversity", "Biodiversity", "0.2.8")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BiodiversityPlugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		internal static CachedList<Assembly> CachedAssemblies;

		private static readonly (string, string)[] SillyQuotes = new(string, string)[9]
		{
			("don't get me wrong, I love women", "Monty"),
			("i love MEN with BIG ARMS and STRONGMAN LEGS", "Monty"),
			("thumpy wumpy", "Monty"),
			("Your body should get split in two", "Wesley"),
			("death for you and your bloodline", "Monty"),
			("the fiend is watching... NOT VERY SIGMA!!", "Rolevote"),
			("we love fat bitches(gender neutral) and body representation for fat bitches(still gender neutral)", "TiltedHat"),
			("Aloehood is a spectrum", "Ccode"),
			("Ogopogo is just a giant man buried in the ground grabbing you w his toes", "Monty")
		};

		public static BiodiversityPlugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static BiodiversityConfig Config { get; private set; }

		internal LangParser Localization { get; private set; }

		private void Awake()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			Stopwatch stopwatch = Stopwatch.StartNew();
			Logger = Logger.CreateLogSource("Biodiversity|0.2.8");
			Instance = this;
			CachedAssemblies = new CachedList<Assembly>(() => AppDomain.CurrentDomain.GetAssemblies().ToList());
			Logger.LogDebug((object)"Setting up localization...");
			try
			{
				Localization = new LangParser(Assembly.GetExecutingAssembly());
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Failed to initialize LangParser. Error: " + ex.Message));
			}
			Logger.LogDebug((object)"Creating base biodiversity config...");
			Config = new BiodiversityConfig(((BaseUnityPlugin)this).Config);
			LogVerbose("Creating Harmony instance...");
			_harmony = new Harmony("com.github.biodiversitylc.Biodiversity");
			LogVerbose("Applying essential Harmony patches...");
			try
			{
				_harmony.CreateClassProcessor(typeof(GameNetworkManagerPatch)).Patch();
				LogVerbose("Successfully patched GameNetworkManager.");
			}
			catch (Exception arg)
			{
				Logger.LogError((object)$"Failed to apply GameNetworkManagerPatch: {arg}");
			}
			Localization.SetLanguage(Config.Language);
			LogVerbose("Testing lang.test: " + Localization.GetTranslation("lang.test"));
			NetcodePatcher();
			stopwatch.Stop();
			Logger.LogInfo((object)string.Format("{0}:{1} has setup in {2}ms.", "com.github.biodiversitylc.Biodiversity", "0.2.8", stopwatch.ElapsedMilliseconds));
		}

		internal void FinishLoading()
		{
			Stopwatch stopwatch = Stopwatch.StartNew();
			LogVerbose("Starting FinishLoading...");
			VanillaEnemies.Init();
			LogVerbose("Loading VideoClip bundle.");
			LoadBundle("biodiversity_video_clips");
			LogVerbose("Registering the creatures...");
			List<Type> list = Assembly.GetExecutingAssembly().GetLoadableTypes().Where(delegate(Type x)
			{
				Type baseType2 = x.BaseType;
				return (object)baseType2 != null && baseType2.IsGenericType && x.BaseType.GetGenericTypeDefinition() == typeof(BiodiverseAIHandler<>);
			})
				.ToList();
			int num = 0;
			for (int i = 0; i < list.Count; i++)
			{
				Type type = list[i];
				string name = type.Name;
				HideHandlerAttribute customAttribute = type.GetCustomAttribute<HideHandlerAttribute>();
				if (customAttribute != null)
				{
					LogVerbose("Hiding " + name + " because it's marked as hidden.");
					continue;
				}
				DisableEnemyByDefaultAttribute customAttribute2 = type.GetCustomAttribute<DisableEnemyByDefaultAttribute>();
				bool flag = customAttribute2 == null;
				if (!((BaseUnityPlugin)this).Config.Bind<bool>("Creatures", name, flag, "Enable/disable the " + name).Value)
				{
					LogVerbose("Skipping " + name + " because it's disabled.");
					continue;
				}
				LogVerbose("Creating " + name + "...");
				try
				{
					type.GetConstructor(Array.Empty<Type>())?.Invoke(Array.Empty<object>());
					Config.AddEnabledCreature(name.Replace("Handler", ""));
					num++;
				}
				catch (Exception arg)
				{
					Logger.LogError((object)$"Failed to instantiate creature handler {name}: {arg}.");
				}
			}
			LogVerbose($"Sucessfully setup {num} creatures!");
			LogVerbose("Registering the items...");
			List<Type> list2 = Assembly.GetExecutingAssembly().GetLoadableTypes().Where(delegate(Type x)
			{
				Type baseType = x.BaseType;
				return (object)baseType != null && baseType.IsGenericType && x.BaseType.GetGenericTypeDefinition() == typeof(BiodiverseItemHandler<>);
			})
				.ToList();
			for (int j = 0; j < list2.Count; j++)
			{
				Type type2 = list2[j];
				string name2 = type2.Name;
				LogVerbose("Creating " + name2 + "...");
				try
				{
					type2.GetConstructor(Array.Empty<Type>())?.Invoke(Array.Empty<object>());
				}
				catch (Exception arg2)
				{
					Logger.LogError((object)$"Failed to instantiate item handler {name2}: {arg2}.");
				}
			}
			ApplyPatches();
			stopwatch.Stop();
			(string, string) tuple = SillyQuotes[Random.Range(0, SillyQuotes.Length)];
			Logger.LogInfo((object)("\"" + tuple.Item1 + "\" - " + tuple.Item2));
			LogVerbose(string.Format("{0}:{1} has loaded! ({2}ms).", "com.github.biodiversitylc.Biodiversity", "0.2.8", stopwatch.ElapsedMilliseconds));
		}

		private void ApplyPatches()
		{
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Expected O, but got Unknown
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Expected I4, but got Unknown
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, Assembly> dictionary = new Dictionary<string, Assembly>();
			foreach (Assembly cachedAssembly in CachedAssemblies)
			{
				dictionary.TryAdd(cachedAssembly.GetName().Name, cachedAssembly);
			}
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach (Type type in types)
			{
				if (type == typeof(GameNetworkManagerPatch))
				{
					continue;
				}
				CreaturePatchAttribute customAttribute = type.GetCustomAttribute<CreaturePatchAttribute>();
				if (customAttribute != null)
				{
					if (!Config.IsCreatureEnabled(customAttribute.CreatureName))
					{
						LogVerbose("Skipping patches in type '" + type.FullName + "' for creature '" + customAttribute.CreatureName + "' because its disabled in config.");
						continue;
					}
					LogVerbose("Patches in type '" + type.FullName + "' for creature '" + customAttribute.CreatureName + "' are ENABLED.");
				}
				List<ModConditionalPatch> list = type.GetCustomAttributes<ModConditionalPatch>(inherit: true).ToList();
				if (list.Any())
				{
					for (int j = 0; j < list.Count; j++)
					{
						ModConditionalPatch modConditionalPatch = list[j];
						string assemblyName = modConditionalPatch.AssemblyName;
						string targetClassName = modConditionalPatch.TargetClassName;
						string targetMethodName = modConditionalPatch.TargetMethodName;
						string localPatchMethodName = modConditionalPatch.LocalPatchMethodName;
						HarmonyPatchType patchType = modConditionalPatch.PatchType;
						if (!dictionary.TryGetValue(assemblyName, out var value))
						{
							continue;
						}
						LogVerbose("Mod " + assemblyName + " is installed! Patching " + targetClassName + "." + targetMethodName + " with " + localPatchMethodName);
						Type type2;
						try
						{
							type2 = value.GetType(targetClassName);
						}
						catch (Exception ex) when (((ex is ArgumentException || ex is FileNotFoundException || ex is FileLoadException || ex is BadImageFormatException) ? 1 : 0) != 0)
						{
							LogVerbose("Could not patch because an exception occurred while getting the target class '" + targetClassName + "': " + ex.Message);
							continue;
						}
						if (type2 == null)
						{
							LogVerbose("Could not patch because the target class '" + targetClassName + "' is null.");
							continue;
						}
						MethodInfo methodInfo = null;
						for (int k = 0; k < type2.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Length; k++)
						{
							MethodInfo methodInfo2 = type2.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)[k];
							if (!(methodInfo2.Name != targetMethodName))
							{
								methodInfo = methodInfo2;
								break;
							}
						}
						if (methodInfo == null)
						{
							LogVerbose("Could not patch because the target method '" + targetMethodName + "' is null.");
							continue;
						}
						MethodInfo method;
						try
						{
							method = type.GetMethod(localPatchMethodName, BindingFlags.Static | BindingFlags.NonPublic);
						}
						catch (Exception ex2) when (((ex2 is AmbiguousMatchException || ex2 is ArgumentException) ? 1 : 0) != 0)
						{
							LogVerbose("Could not patch because an exception occured while getting the local patch method '" + localPatchMethodName + "': " + ex2.Message);
							continue;
						}
						if (method == null)
						{
							LogVerbose("Could not patch because the local patch method '" + localPatchMethodName + "' is null.");
							continue;
						}
						HarmonyMethod val = new HarmonyMethod(method);
						switch (patchType - 1)
						{
						case 0:
							_harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
							break;
						case 1:
							_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
							break;
						case 2:
							_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null);
							break;
						case 3:
							_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null);
							break;
						default:
							Logger.LogError((object)("Could not patch because patch type '" + ((object)(HarmonyPatchType)(ref patchType)).ToString() + "' is incompatible."));
							break;
						}
						LogVerbose($"Successfully patched {targetClassName}.{targetMethodName} with {localPatchMethodName} as {patchType}");
					}
					continue;
				}
				object[] customAttributes = type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false);
				if (customAttributes.Length != 0)
				{
					try
					{
						_harmony.CreateClassProcessor(type).Patch();
					}
					catch (Exception arg)
					{
						Logger.LogError((object)$"Failed to apply Harmony patch(es) for type '{type.FullName}': {arg}");
					}
				}
			}
		}

		private static void NetcodePatcher()
		{
			try
			{
				IEnumerable<Type> loadableTypes = Assembly.GetExecutingAssembly().GetLoadableTypes();
				foreach (Type item in loadableTypes)
				{
					MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
					foreach (MethodInfo methodInfo in methods)
					{
						if (!Attribute.IsDefined(methodInfo, typeof(RuntimeInitializeOnLoadMethodAttribute)))
						{
							continue;
						}
						if (methodInfo.ContainsGenericParameters)
						{
							Logger.LogDebug((object)("[NetcodePatcher] Skipping generic method " + item.FullName + "." + methodInfo.Name + " with [RuntimeInitializeOnLoadMethod] attribute."));
						}
						else
						{
							try
							{
								methodInfo.Invoke(null, null);
							}
							catch (Exception arg)
							{
								Logger.LogError((object)$"Error invoking method {item.FullName}.{methodInfo.Name}: {arg}");
							}
						}
					}
				}
			}
			catch (ReflectionTypeLoadException ex)
			{
				Logger.LogError((object)$"[NetcodePatcher] Error loading types from assembly: {ex}");
				for (int j = 0; j < ex.LoaderExceptions.Length; j++)
				{
					Exception ex2 = ex.LoaderExceptions[j];
					if (ex2 != null)
					{
						Logger.LogError((object)("[NetcodePatcher] Loader Exception: " + ex2.Message));
					}
				}
			}
		}

		internal ConfigFile CreateConfig(string configName)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			return new ConfigFile(Utility.CombinePaths(new string[2]
			{
				Paths.ConfigPath,
				"me.biodiversity." + configName + ".cfg"
			}), false, MetadataHelper.GetMetadata((object)this));
		}

		internal static AssetBundle LoadBundle(string assetBundleName)
		{
			AssetBundle val;
			try
			{
				val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new InvalidOperationException("Could not find assetbundle: " + assetBundleName), "AssetBundles", assetBundleName));
			}
			catch (Exception arg)
			{
				Logger.LogWarning((object)$"Could not load assetbundle: {arg}");
				return null;
			}
			LogVerbose("[AssetBundle Loading] " + assetBundleName + " contains these objects: " + string.Join(",", val.GetAllAssetNames()));
			return val;
		}

		internal static void LogVerbose(object message)
		{
			if (Config.VerboseLoggingEnabled)
			{
				Logger.LogDebug(message);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.biodiversitylc.Biodiversity";

		public const string PLUGIN_NAME = "Biodiversity";

		public const string PLUGIN_VERSION = "0.2.8";
	}
}
namespace Biodiversity.Util
{
	public static class DebugShapeVisualizer
	{
		private static readonly int SrcBlend = Shader.PropertyToID("_SrcBlend");

		private static readonly int DstBlend = Shader.PropertyToID("_DstBlend");

		private static readonly int ZWrite = Shader.PropertyToID("_ZWrite");

		private static readonly int Cull = Shader.PropertyToID("_Cull");

		private static Material _debugMaterial;

		private static readonly List<LineRenderer> _linePool = new List<LineRenderer>();

		private static readonly List<Transform> _spherePool = new List<Transform>();

		private static readonly Dictionary<int, List<GameObject>> _activeVisuals = new Dictionary<int, List<GameObject>>();

		private static CachedUnityObject<Transform> _parent;

		public static Transform Parent
		{
			get
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				if (!_parent.HasValue)
				{
					GameObject val = GameObject.Find("BiodiverseDebugShapeVisualizer");
					if (!Object.op_Implicit((Object)(object)val))
					{
						val = new GameObject("BiodiverseDebugShapeVisualizer");
					}
					_parent.Set(val.transform);
				}
				return _parent.Value;
			}
		}

		public static void Clear(object owner)
		{
			int hashCode = owner.GetHashCode();
			if (_activeVisuals.TryGetValue(hashCode, out var value))
			{
				for (int i = 0; i < value.Count; i++)
				{
					GameObject val = value[i];
					val.SetActive(false);
				}
				value.Clear();
			}
		}

		public static void DrawLine(object owner, Vector3 start, Vector3 end, Color colour)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			LineRenderer nextLine = GetNextLine();
			((Component)nextLine).gameObject.SetActive(true);
			nextLine.startColor = colour;
			nextLine.endColor = colour;
			nextLine.SetPosition(0, start);
			nextLine.SetPosition(1, end);
			RegisterVisual(owner, ((Component)nextLine).gameObject);
		}

		public static void DrawSphere(object owner, Vector3 position, float radius, Color colour)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Transform nextSphere = GetNextSphere();
			((Component)nextSphere).gameObject.SetActive(true);
			nextSphere.position = position;
			nextSphere.localScale = Vector3.one * (radius * 2f);
			((Renderer)((Component)nextSphere).GetComponent<MeshRenderer>()).material.color = colour;
			RegisterVisual(owner, ((Component)nextSphere).gameObject);
		}

		private static void RegisterVisual(object owner, GameObject visualObject)
		{
			int hashCode = owner.GetHashCode();
			if (!_activeVisuals.TryGetValue(hashCode, out var value))
			{
				value = new List<GameObject>();
				_activeVisuals[hashCode] = value;
			}
			value.Add(visualObject);
		}

		private static LineRenderer GetNextLine()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			for (int i = 0; i < _linePool.Count; i++)
			{
				LineRenderer val = _linePool[i];
				if (!((Component)val).gameObject.activeInHierarchy)
				{
					return val;
				}
			}
			CreateMaterial();
			GameObject val2 = new GameObject("DebugLine")
			{
				hideFlags = (HideFlags)61
			};
			val2.transform.SetParent(Parent);
			LineRenderer val3 = val2.AddComponent<LineRenderer>();
			((Renderer)val3).material = _debugMaterial;
			val3.positionCount = 2;
			val3.startWidth = 0.02f;
			val3.endWidth = 0.02f;
			_linePool.Add(val3);
			return val3;
		}

		private static Transform GetNextSphere()
		{
			for (int i = 0; i < _spherePool.Count; i++)
			{
				Transform val = _spherePool[i];
				if (!((Component)val).gameObject.activeInHierarchy)
				{
					return val;
				}
			}
			CreateMaterial();
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val2).name = "DebugSphere";
			((Object)val2).hideFlags = (HideFlags)61;
			val2.transform.SetParent(Parent);
			Collider val3 = default(Collider);
			if (val2.TryGetComponent<Collider>(ref val3))
			{
				Object.Destroy((Object)(object)val3);
			}
			MeshRenderer val4 = default(MeshRenderer);
			if (!val2.TryGetComponent<MeshRenderer>(ref val4))
			{
				val4 = val2.AddComponent<MeshRenderer>();
			}
			((Renderer)val4).material = _debugMaterial;
			Transform transform = val2.transform;
			_spherePool.Add(transform);
			return transform;
		}

		private static void CreateMaterial()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)_debugMaterial))
			{
				Shader val = Shader.Find("Hidden/Internal-Colored");
				_debugMaterial = new Material(val)
				{
					hideFlags = (HideFlags)61
				};
				_debugMaterial.SetInt(SrcBlend, 5);
				_debugMaterial.SetInt(DstBlend, 10);
				_debugMaterial.SetInt(ZWrite, 0);
				_debugMaterial.SetInt(Cull, 0);
				_debugMaterial.renderQueue = 3000;
			}
		}
	}
	internal static class ExtensionMethods
	{
		internal static Vector3 Direction(this Vector3 from, Vector3 to)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = to - from;
			return ((Vector3)(ref val)).normalized;
		}

		internal static (int hours, int minutes) GetCurrentTime(this TimeOfDay timeOfDay)
		{
			int num = Mathf.FloorToInt(timeOfDay.normalizedTimeOfDay * 60f * (float)timeOfDay.numberOfHours + 360f);
			int item = Mathf.FloorToInt((float)(num / 60));
			return (item, num % 60);
		}

		internal static (int, int) ParseTimeString(this TimeOfDay timeOfDay, string timeString)
		{
			return (int.Parse(timeString.Split(":")[0]), int.Parse(timeString.Split(":")[1]));
		}

		internal static bool HasPassedTime(this TimeOfDay timeOfDay, (int, int) target)
		{
			return timeOfDay.HasPassedTime(timeOfDay.GetCurrentTime(), target);
		}

		internal static bool HasPassedTime(this TimeOfDay timeOfDay, (int, int) current, (int, int) target)
		{
			if (target.Item1 <= current.Item1)
			{
				return target.Item2 <= current.Item2;
			}
			return false;
		}

		public static void SafeSet<T>(this NetworkVariable<T> networkVariable, T newValue) where T : IEquatable<T>
		{
			if (!EqualityComparer<T>.Default.Equals(networkVariable.Value, newValue))
			{
				networkVariable.Value = newValue;
			}
		}

		internal static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
		{
			if (assembly == null)
			{
				throw new ArgumentNullException("assembly");
			}
			try
			{
				return assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				return ex.Types.Where((Type t) => t != null);
			}
		}

		internal static bool IsHostReflection(object instance)
		{
			return (bool)instance.GetType().GetProperty("IsHost")?.GetValue(instance);
		}

		internal static bool IsServerReflection(object instance)
		{
			return (bool)instance.GetType().GetProperty("IsServer")?.GetValue(instance);
		}

		public static Color RGBToHSV(Color rgb, out float h, out float s, out float v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Color.RGBToHSV(rgb, ref h, ref s, ref v);
			return rgb;
		}

		public static Color HSVToRGB(float h, float s, float v)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return Color.HSVToRGB(h, s, v);
		}

		public static float Quadratic(float x, float k)
		{
			return Mathf.Pow(Mathf.Clamp01(x), k);
		}
	}
	public static class LethalLibUtils
	{
		public static void TranslateTerminalNode(TerminalNode node)
		{
			node.displayText = BiodiversityPlugin.Instance.Localization.GetTranslation(node.displayText);
		}

		public static void RegisterEnemyWithConfig(bool enemyEnabled, string configMoonRarity, EnemyType enemy, TerminalNode terminalNode, TerminalKeyword terminalKeyword)
		{
			if (enemyEnabled)
			{
				var (dictionary, dictionary2) = ConfigParsing(configMoonRarity);
				Enemies.RegisterEnemy(enemy, dictionary, dictionary2, terminalNode, terminalKeyword);
			}
			else
			{
				Enemies.RegisterEnemy(enemy, 0, (LevelTypes)(-1), terminalNode, terminalKeyword);
			}
		}

		public static void RegisterScrapWithConfig(string configMoonRarity, Item scrap)
		{
			var (levelRarities, customLevelRarities) = ConfigParsing(configMoonRarity);
			RegisterScrapWithRuntimeIconSupport(scrap, levelRarities, customLevelRarities);
		}

		public static void RegisterScrapWithRuntimeIconSupport(Item spawnableItem, Dictionary<LevelTypes, int> levelRarities, Dictionary<string, int> customLevelRarities)
		{
			bool flag = false;
			foreach (string key in Chainloader.PluginInfos.Keys)
			{
				if (key == "com.github.lethalcompanymodding.runtimeicons")
				{
					flag = true;
				}
			}
			if (flag)
			{
				spawnableItem.itemIcon = null;
			}
			Items.RegisterScrap(spawnableItem, levelRarities, customLevelRarities);
		}

		public static void RegisterShopItemWithConfig(bool enabledScrap, Item item, TerminalNode terminalNode, int itemCost, string configMoonRarity)
		{
			Items.RegisterShopItem(item, (TerminalNode)null, (TerminalNode)null, terminalNode, itemCost);
			if (enabledScrap)
			{
				RegisterScrapWithConfig(configMoonRarity, item);
			}
		}

		public static (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ConfigParsing(string configMoonRarity)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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)
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			foreach (string item in from s in configMoonRarity.Split(',')
				select s.Trim())
			{
				string[] array = item.Split(':');
				if (array.Length != 2)
				{
					continue;
				}
				string text = array[0];
				if (!int.TryParse(array[1], out var result))
				{
					continue;
				}
				if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2))
				{
					dictionary[result2] = result;
					BiodiversityPlugin.LogVerbose($"Registered spawn rate for level type {result2} to {result}");
					continue;
				}
				string value = text + "Level";
				if (Enum.TryParse<LevelTypes>(value, ignoreCase: true, out result2))
				{
					dictionary[result2] = result;
					BiodiversityPlugin.LogVerbose($"Registered spawn rate for level type {result2} to {result}");
				}
				else
				{
					dictionary2[text] = result;
					BiodiversityPlugin.LogVerbose($"Registered spawn rate for custom level type {text} to {result}");
				}
			}
			return (dictionary, dictionary2);
		}
	}
	public static class LineOfSightUtil
	{
		internal static bool HasLineOfSight(Vector3 targetPosition, Transform eyeTransform, float viewWidth = 45f, float viewRange = 60f, float proximityAwareness = -1f, bool isFoggy = false)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_0095: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)eyeTransform))
			{
				return false;
			}
			Vector3 position = eyeTransform.position;
			Vector3 val = targetPosition - position;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			if (sqrMagnitude <= 0.0001f)
			{
				return true;
			}
			float num = viewRange;
			if (isFoggy)
			{
				num = Mathf.Clamp(viewRange, 0f, 30f);
			}
			float num2 = num * num;
			if (sqrMagnitude > num2)
			{
				return false;
			}
			float num3 = Mathf.Sqrt(sqrMagnitude);
			if (!(proximityAwareness >= 0f) || !(num3 <= proximityAwareness))
			{
				float num4 = Mathf.Clamp(viewWidth, 0f, 180f) * 0.5f * (MathF.PI / 180f);
				float num5 = Mathf.Cos(num4);
				float num6 = Vector3.Dot(eyeTransform.forward, val / num3);
				if (num6 < num5)
				{
					return false;
				}
			}
			if (Physics.Linecast(position, targetPosition, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				return false;
			}
			return true;
		}
	}
	internal static class PlayerUtil
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static PlayerControllerB GetPlayerFromClientId(ulong playerClientId)
		{
			return StartOfRound.Instance.allPlayerScripts[playerClientId];
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static PlayerControllerB GetPlayerFromClientId(int playerClientId)
		{
			return StartOfRound.Instance.allPlayerScripts[playerClientId];
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static ulong GetClientIdFromPlayer(PlayerControllerB player)
		{
			return player.playerClientId;
		}

		internal static bool IsPlayerDead(PlayerControllerB player)
		{
			if (!Object.op_Implicit((Object)(object)player))
			{
				return true;
			}
			if (!player.isPlayerDead)
			{
				return !player.isPlayerControlled;
			}
			return true;
		}

		internal static Vector3 GetVelocityOfPlayer(PlayerControllerB player)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)player).IsOwner)
			{
				if (Time.deltaTime > 0f)
				{
					return player.thisController.velocity / Time.deltaTime;
				}
				return Vector3.zero;
			}
			PlayerVelocityTracker playerVelocityTracker = default(PlayerVelocityTracker);
			if (((Component)player).TryGetComponent<PlayerVelocityTracker>(ref playerVelocityTracker))
			{
				return playerVelocityTracker.Velocity;
			}
			BiodiversityPlugin.LogVerbose("Player " + player.playerUsername + " is missing a PlayerVelocityTracker component.");
			return Vector3.zero;
		}
	}
	public class VanillaLayersUtil
	{
		public static readonly string[] layerNames = new string[31]
		{
			"Default", "TransparentFX", "Ignore Raycast", "Player", "Water", "UI", "Props", "HelmetVisor", "Room", "InteractableObject",
			"Foliage", "Colliders", "PhysicsObject", "Triggers", "MapRadar", "NavigationSurface", "MoldSpore", "Anomaly", "LineOfSight", "Enemies",
			"PlayerRagdoll", "MapHazards", "ScanNode", "EnemiesNotRendered", "MiscLevelGeometry", "Terrain", "PlaceableShipObjects", "PlacementBlocker", "Railing", "DecalStickableSurface",
			"Vehicle"
		};

		public static List<string> DecodeMask(int mask)
		{
			List<string> list = new List<string>();
			for (int i = 0; i < layerNames.Length; i++)
			{
				if ((mask & (1 << i)) != 0)
				{
					string arg = (string.IsNullOrEmpty(layerNames[i]) ? "<unnamed>" : layerNames[i]);
					list.Add($"{i}: {arg}");
				}
			}
			return list;
		}
	}
}
namespace Biodiversity.Util.SharedVariables
{
	public static class TeleporterStatus
	{
		public static PlayerControllerB PlayerGettingTeleported = null;

		public static bool Teleporting = true;

		public static ShipTeleporter currentTeleporter = null;

		public static bool? isInElevator = null;

		public static bool? isInHangarShipRoom = null;

		public static bool? isInFactory = null;

		public static PlayerControllerB PlayerGettingInverseTeleported = null;

		public static bool TeleportingInverse = true;

		public static ShipTeleporter currentTeleporterInverse = null;

		public static bool? isInElevatorInverse = null;

		public static bool? isInHangarShipRoomInverse = null;

		public static bool? isInFactoryInverse = null;

		public static bool CancelTeleport = false;

		public static bool CancelInverseTeleport = false;
	}
}
namespace Biodiversity.Util.Scripts
{
	internal class KeepY : MonoBehaviour
	{
		public float? StartingY;

		public void Init()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			StartingY = ((Component)this).transform.position.y;
		}

		public void LateUpdate()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (StartingY.HasValue)
			{
				((Component)this).transform.position = new Vector3(((Component)this).transform.position.x, StartingY.Value, ((Component)this).transform.position.z);
			}
		}
	}
	internal class SplineObject : MonoBehaviour
	{
		[SerializeField]
		private Transform startPoint;

		[SerializeField]
		private Transform Handle;

		[SerializeField]
		private Transform endPoint;

		[SerializeField]
		private Transform meta1;

		[SerializeField]
		private Transform meta2;

		private Transform point;

		[NonSerialized]
		public float interpolateAmount;

		[SerializeField]
		private bool Debug;

		private bool forward = true;

		private void Start()
		{
			point = ((Component)this).gameObject.transform;
		}

		private void Update()
		{
			if (Debug)
			{
				if (forward)
				{
					forward = !UpdateForward(0.3f, Time.deltaTime);
				}
				else
				{
					forward = UpdateBackward(0.3f, Time.deltaTime);
				}
			}
		}

		public bool UpdateForward(float speed, float delta)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			interpolateAmount += delta * speed;
			meta1.position = Vector3.Lerp(startPoint.position, Handle.position, interpolateAmount);
			meta2.position = Vector3.Lerp(Handle.position, endPoint.position, interpolateAmount);
			point.position = Vector3.Lerp(meta1.position, meta2.position, interpolateAmount);
			if (interpolateAmount >= 1f)
			{
				interpolateAmount = 1f;
				return true;
			}
			return false;
		}

		public bool UpdateBackward(float speed, float delta)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			interpolateAmount -= delta * speed;
			meta1.position = Vector3.Lerp(startPoint.position, Handle.position, interpolateAmount);
			meta2.position = Vector3.Lerp(Handle.position, endPoint.position, interpolateAmount);
			point.position = Vector3.Lerp(meta1.position, meta2.position, interpolateAmount);
			if (interpolateAmount <= 0f)
			{
				interpolateAmount = 0f;
				return true;
			}
			return false;
		}
	}
}
namespace Biodiversity.Util.DataStructures
{
	public class BulkPopulateDictionary<TKey, TValue>
	{
		private Lazy<Dictionary<TKey, TValue>> _lazyCache;

		private readonly Func<Dictionary<TKey, TValue>> _populateFunction;

		public Dictionary<TKey, TValue> Value => _lazyCache.Value;

		public BulkPopulateDictionary(Func<Dictionary<TKey, TValue>> populateFunction)
		{
			_populateFunction = populateFunction ?? throw new ArgumentNullException("populateFunction");
			_lazyCache = new Lazy<Dictionary<TKey, TValue>>(_populateFunction);
		}

		public void Invalidate()
		{
			_lazyCache = new Lazy<Dictionary<TKey, TValue>>(_populateFunction);
		}
	}
	public class CachedList<T> : IEnumerable<T>, IEnumerable
	{
		private readonly Func<List<T>> _computeListFunction;

		private readonly object _lock = new object();

		private List<T> _cachedList;

		private bool _hasValue;

		public List<T> Value
		{
			get
			{
				if (!_hasValue)
				{
					lock (_lock)
					{
						if (!_hasValue)
						{
							ComputeAndCacheListInternal();
						}
					}
				}
				return _cachedList ?? Enumerable.Empty<T>().ToList();
			}
		}

		public bool HasValue
		{
			get
			{
				lock (_lock)
				{
					return _hasValue;
				}
			}
		}

		public CachedList(Func<List<T>> computeListFunction)
		{
			_computeListFunction = computeListFunction ?? throw new ArgumentNullException("computeListFunction");
			_cachedList = null;
			_hasValue = false;
		}

		public void Reset()
		{
			lock (_lock)
			{
				_cachedList = null;
				_hasValue = false;
			}
		}

		private void ComputeAndCacheListInternal()
		{
			try
			{
				_cachedList = _computeListFunction();
				_hasValue = true;
			}
			catch
			{
				_hasValue = false;
				throw;
			}
		}

		public IEnumerator<T> GetEnumerator()
		{
			return Value.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}
	}
	public struct CachedUnityObject<T> : IEquatable<CachedUnityObject<T>> where T : Object
	{
		private T _value;

		private bool _hasValue;

		public bool HasValue
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				return _hasValue;
			}
		}

		public T Value
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				return _value;
			}
		}

		public CachedUnityObject(T value)
		{
			_value = value;
			_hasValue = (Object)(object)value != (Object)null;
		}

		public void Set(T newValue)
		{
			_value = newValue;
			_hasValue = (Object)(object)newValue != (Object)null;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void Reset()
		{
			_value = default(T);
			_hasValue = false;
		}

		public override string ToString()
		{
			if (!_hasValue)
			{
				return "No Value";
			}
			return ((object)_value).ToString() ?? "null";
		}

		public override bool Equals(object obj)
		{
			if (obj is CachedUnityObject<T> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(CachedUnityObject<T> other)
		{
			return (Object)(object)_value == (Object)(object)other._value;
		}

		public override int GetHashCode()
		{
			if (!_hasValue)
			{
				return 0;
			}
			return ((Object)_value).GetInstanceID();
		}

		public static bool operator ==(CachedUnityObject<T> left, CachedUnityObject<T> right)
		{
			return (Object)(object)left._value == (Object)(object)right._value;
		}

		public static bool operator !=(CachedUnityObject<T> left, CachedUnityObject<T> right)
		{
			return (Object)(object)left._value != (Object)(object)right._value;
		}
	}
	public class CachedValue<T>
	{
		private readonly Func<T> _computeValueFunction;

		private readonly object _lock = new object();

		private T _cachedValue;

		private bool _hasValue;

		public T Value
		{
			get
			{
				if (!_hasValue)
				{
					lock (_lock)
					{
						if (!_hasValue)
						{
							ComputeAndCacheValueInternal();
						}
					}
				}
				return _cachedValue;
			}
		}

		public bool HasValue
		{
			get
			{
				lock (_lock)
				{
					return _hasValue;
				}
			}
		}

		public CachedValue(Func<T> computeValueFunction, bool eager = false)
		{
			_computeValueFunction = computeValueFunction ?? throw new ArgumentNullException("computeValueFunction");
			_cachedValue = default(T);
			_hasValue = false;
			if (eager)
			{
				ComputeAndCacheValueInternal();
			}
		}

		public void Reset()
		{
			lock (_lock)
			{
				_cachedValue = default(T);
				_hasValue = false;
			}
		}

		private void ComputeAndCacheValueInternal()
		{
			try
			{
				_cachedValue = _computeValueFunction();
				_hasValue = true;
			}
			catch
			{
				_hasValue = false;
				throw;
			}
		}
	}
	public class LazyDictionary<TKey, TValue>
	{
		protected readonly Dictionary<TKey, TValue> Cache = new Dictionary<TKey, TValue>();

		protected readonly Func<TKey, TValue> _computeValueFunction;

		public virtual TValue this[TKey key]
		{
			get
			{
				if (Cache.TryGetValue(key, out var value))
				{
					return value;
				}
				TValue val = _computeValueFunction(key);
				Cache[key] = val;
				return val;
			}
		}

		public LazyDictionary(Func<TKey, TValue> computeValueFunction)
		{
			_computeValueFunction = computeValueFunction ?? throw new ArgumentNullException("computeValueFunction");
		}

		public void Invalidate(TKey key)
		{
			Cache.Remove(key);
		}

		public void Clear()
		{
			Cache.Clear();
		}
	}
	public class LazyUnityObjectDictionary<TKey, TValue> : LazyDictionary<TKey, TValue> where TValue : Object
	{
		public override TValue this[TKey key]
		{
			get
			{
				if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
				{
					return value;
				}
				TValue val = _computeValueFunction(key);
				Cache[key] = val;
				return val;
			}
		}

		public LazyUnityObjectDictionary(Func<TKey, TValue> computeValueFunction)
			: base(computeValueFunction)
		{
		}
	}
	[Serializable]
	public struct NetworkPositionalSyncFidelity
	{
		[Tooltip("Controls how aggressively the client's model catches up to the server's actual position. A smaller value is faster and snappier, but can appear jittery on laggy connections.")]
		public float InterpolationAggressiveness;

		[Tooltip("The distance the enemy must move from its last synced position before the server sends a new network update. A smaller value means more frequent, accurate updates at the cost of higher bandwidth.")]
		public float UpdateDistanceThreshold;
	}
	public struct OverridableFloat : IEquatable<OverridableFloat>
	{
		private float _defaultValue;

		private float _overrideValue;

		private bool _isOverridden;

		public float Value
		{
			get
			{
				if (!_isOverridden)
				{
					return _defaultValue;
				}
				return _overrideValue;
			}
		}

		public readonly bool IsOverridden => _isOverridden;

		public OverridableFloat(float defaultValue)
		{
			_defaultValue = defaultValue;
			_overrideValue = 0f;
			_isOverridden = false;
		}

		public void SetDefaultValue(float value)
		{
			_defaultValue = value;
		}

		public void Override(float value)
		{
			_overrideValue = value;
			_isOverridden = true;
		}

		public void UseDefault()
		{
			_isOverridden = false;
		}

		public override string ToString()
		{
			return Value.ToString(CultureInfo.InvariantCulture);
		}

		public static implicit operator float(OverridableFloat v)
		{
			return v.Value;
		}

		public static implicit operator OverridableFloat(float v)
		{
			return new OverridableFloat(v);
		}

		public bool Equals(OverridableFloat other)
		{
			return Value == other.Value;
		}

		public override bool Equals(object obj)
		{
			if (obj is OverridableFloat other)
			{
				return Equals(other);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return Value.GetHashCode();
		}

		public static bool operator ==(OverridableFloat left, OverridableFloat right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(OverridableFloat left, OverridableFloat right)
		{
			return !left.Equals(right);
		}
	}
	public class Pair<T1, T2>
	{
		public T1 First { get; set; }

		public T2 Second { get; set; }

		public Pair(T1 first, T2 second)
		{
			First = first;
			Second = second;
		}
	}
	public class PlayerCooldownTracker
	{
		private readonly Dictionary<ulong, double> _cooldowns = new Dictionary<ulong, double>();

		public bool IsOnCooldown(ulong playerClientId)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (_cooldowns.TryGetValue(playerClientId, out var value))
			{
				NetworkTime serverTime = NetworkManager.Singleton.ServerTime;
				if (((NetworkTime)(ref serverTime)).Time < value)
				{
					return true;
				}
				_cooldowns.Remove(playerClientId);
			}
			return false;
		}

		public bool IsOnCooldown(PlayerControllerB player)
		{
			return IsOnCooldown(PlayerUtil.GetClientIdFromPlayer(player));
		}

		public void Start(ulong playerClientId, float duration)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (duration <= 0f)
			{
				_cooldowns.Remove(playerClientId);
				return;
			}
			Dictionary<ulong, double> cooldowns = _cooldowns;
			NetworkTime serverTime = NetworkManager.Singleton.ServerTime;
			cooldowns[playerClientId] = ((NetworkTime)(ref serverTime)).Time + (double)duration;
		}

		public void Start(PlayerControllerB player, float duration)
		{
			Start(PlayerUtil.GetClientIdFromPlayer(player), duration);
		}

		public void Clear()
		{
			_cooldowns.Clear();
		}
	}
}
namespace Biodiversity.Util.Animation
{
	public abstract class BaseAnimatorState : StateMachineBehaviour
	{
		protected bool IsInitialized { get; set; }

		protected abstract void EnsureInitialized(Animator animator);

		public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((StateMachineBehaviour)this).OnStateEnter(animator, stateInfo, layerIndex);
			EnsureInitialized(animator);
		}

		public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((StateMachineBehaviour)this).OnStateExit(animator, stateInfo, layerIndex);
			EnsureInitialized(animator);
		}
	}
	public abstract class GenericAnimatorState<T1> : BaseAnimatorState where T1 : Component
	{
		protected T1 behaviour1 { get; private set; }

		protected override void EnsureInitialized(Animator animator)
		{
			if (!base.IsInitialized)
			{
				behaviour1 = ((Component)animator).GetComponent<T1>();
				if (!Object.op_Implicit((Object)(object)behaviour1))
				{
					BiodiversityPlugin.Logger.LogError((object)("'" + ((object)this).GetType().Name + "' could not find the required component of type '" + typeof(T1).Name + "' on the Animator's GameObject."));
				}
				base.IsInitialized = true;
			}
		}
	}
	public abstract class GenericAnimatorState<T1, T2> : BaseAnimatorState where T1 : Component where T2 : Component
	{
		protected T1 behaviour1 { get; private set; }

		protected T2 behaviour2 { get; private set; }

		protected override void EnsureInitialized(Animator animator)
		{
			if (!base.IsInitialized)
			{
				behaviour1 = ((Component)animator).GetComponent<T1>();
				if (!Object.op_Implicit((Object)(object)behaviour1))
				{
					BiodiversityPlugin.Logger.LogError((object)("'" + ((object)this).GetType().Name + "' could not find the required component of type '" + typeof(T1).Name + "' on the Animator's GameObject."));
				}
				behaviour2 = ((Component)animator).GetComponent<T2>();
				if (!Object.op_Implicit((Object)(object)behaviour2))
				{
					BiodiversityPlugin.Logger.LogError((object)("'" + ((object)this).GetType().Name + "' could not find the required component of type '" + typeof(T2).Name + "' on the Animator's GameObject."));
				}
				base.IsInitialized = true;
			}
		}
	}
}
namespace Biodiversity.Patches
{
	[CreaturePatch("CoilCrab")]
	[HarmonyPatch(typeof(RoundManager))]
	internal static class CoilCrabRoundManagerPatch
	{
		[HarmonyPatch("PredictAllOutsideEnemies")]
		[HarmonyPrefix]
		internal static void CoilCrabSpawnWeights(RoundManager __instance)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Invalid comparison between Unknown and I4
			BiodiversityPlugin.LogVerbose("Setting Coil crab dynamic weights");
			string text = ((Object)__instance.currentLevel).name;
			if (!Enum.IsDefined(typeof(LevelTypes), text))
			{
				text = Compatibility.GetLLLNameOfLevel(text);
			}
			text = text.Remove(text.Length - "Level".Length);
			BiodiversityPlugin.LogVerbose($"The name of the level (For the Coil-Crab debug): {text} ({text.Length})");
			SpawnableEnemyWithRarity val = null;
			foreach (SpawnableEnemyWithRarity daytimeEnemy in __instance.currentLevel.DaytimeEnemies)
			{
				if (daytimeEnemy.enemyType.enemyName == "Coil Crab")
				{
					val = daytimeEnemy;
				}
			}
			if (val == null)
			{
				BiodiversityPlugin.LogVerbose("Coil crab was not added in the non-stormy config so the crab will not be enabled on this moon.");
			}
			if (val == null)
			{
				return;
			}
			if ((int)TimeOfDay.Instance.currentLevelWeather == 2)
			{
				if (BiodiverseAIHandler<CoilCrabHandler>.Instance.StormyWeights.ContainsKey(text))
				{
					val.rarity = BiodiverseAIHandler<CoilCrabHandler>.Instance.StormyWeights[text];
					return;
				}
				val.rarity = 0;
				BiodiversityPlugin.LogVerbose("Coil Crab dynamic weights were set to zero because the stormy weights did not include the current moon.");
			}
			else if (BiodiverseAIHandler<CoilCrabHandler>.Instance.Weights.ContainsKey(text))
			{
				val.rarity = BiodiverseAIHandler<CoilCrabHandler>.Instance.Weights[text];
			}
			else
			{
				val.rarity = 0;
				BiodiversityPlugin.LogVerbose("Coil Crab dynamic weights were set to zero because the non-stormy weights did not include the current moon.");
			}
		}
	}
	[CreaturePatch("CoilCrab")]
	[HarmonyPatch(typeof(StartOfRound))]
	internal class CoilCrabStartOfRoundPatch
	{
		[HarmonyPatch("SwitchMapMonitorPurpose")]
		[HarmonyPostfix]
		internal static void CoilCrabSounds()
		{
			foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
			{
				if (((Object)items).name == "ComedyMask")
				{
					BiodiverseAIHandler<CoilCrabHandler>.Instance.Assets.CoilShellItem.pocketSFX = items.pocketSFX;
					BiodiverseAIHandler<CoilCrabHandler>.Instance.Assets.CoilShellItem.grabSFX = items.grabSFX;
					BiodiversityPlugin.LogVerbose("Found the select sfx for the shovel.");
					break;
				}
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal static class GameNetworkManagerPatch
	{
		internal static readonly HashSet<GameObject> NetworkPrefabsToRegister = new HashSet<GameObject>();

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void AddNetworkPrefabs()
		{
			BiodiversityPlugin.Instance.FinishLoading();
			if (NetworkPrefabsToRegister.Count > 0)
			{
				BiodiversityPlugin.LogVerbose($"Registering {NetworkPrefabsToRegister.Count} network prefabs...");
				foreach (GameObject item in NetworkPrefabsToRegister)
				{
					if (Object.op_Implicit((Object)(object)item))
					{
						NetworkManager.Singleton.AddNetworkPrefab(item);
						BiodiversityPlugin.LogVerbose("Registered " + ((Object)item).name + " as a network prefab.");
					}
				}
				BiodiversityPlugin.LogVerbose($"Successfully registered {NetworkPrefabsToRegister.Count} network prefabs.");
			}
			NetworkPrefabsToRegister.Clear();
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal static class PlayerControllerBPatch
	{
		[HarmonyPatch("TeleportPlayer")]
		[HarmonyPrefix]
		private static bool TeleportCalled(PlayerControllerB __instance, Vector3 pos, bool withRotation = false, float rot = 0f, bool allowInteractTrigger = false, bool enableController = true)
		{
			bool flag = false;
			if (TeleporterStatus.CancelTeleport && TeleporterStatus.Teleporting && (Object)(object)TeleporterStatus.PlayerGettingTeleported == (Object)(object)__instance)
			{
				flag = true;
				TeleporterStatus.CancelTeleport = false;
				__instance.isInElevator = TeleporterStatus.isInElevator.Value;
				__instance.isInHangarShipRoom = TeleporterStatus.isInHangarShipRoom.Value;
				__instance.isInsideFactory = TeleporterStatus.isInFactory.Value;
			}
			if (TeleporterStatus.CancelInverseTeleport && TeleporterStatus.TeleportingInverse && (Object)(object)TeleporterStatus.PlayerGettingInverseTeleported == (Object)(object)__instance)
			{
				flag = true;
				TeleporterStatus.CancelInverseTeleport = false;
				__instance.isInElevator = TeleporterStatus.isInElevatorInverse.Value;
				__instance.isInHangarShipRoom = TeleporterStatus.isInHangarShipRoomInverse.Value;
				__instance.isInsideFactory = TeleporterStatus.isInFactoryInverse.Value;
			}
			if (TeleporterStatus.Teleporting && (Object)(object)TeleporterStatus.PlayerGettingTeleported == (Object)(object)__instance)
			{
				BiodiversityPlugin.Logger.LogInfo((object)"Clearing teleport data");
				TeleporterStatus.Teleporting = false;
				TeleporterStatus.PlayerGettingTeleported = null;
				TeleporterStatus.currentTeleporter = null;
				TeleporterStatus.isInElevator = null;
				TeleporterStatus.isInHangarShipRoom = null;
				TeleporterStatus.isInFactory = null;
			}
			if (TeleporterStatus.TeleportingInverse && (Object)(object)TeleporterStatus.PlayerGettingInverseTeleported == (Object)(object)__instance)
			{
				BiodiversityPlugin.Logger.LogInfo((object)"Clearing inverse teleport data");
				TeleporterStatus.TeleportingInverse = false;
				TeleporterStatus.PlayerGettingInverseTeleported = null;
				TeleporterStatus.currentTeleporterInverse = null;
				TeleporterStatus.isInElevatorInverse = null;
				TeleporterStatus.isInHangarShipRoomInverse = null;
				TeleporterStatus.isInFactoryInverse = null;
			}
			return !flag;
		}
	}
	internal static class RoundManagerPatch
	{
		internal static readonly Dictionary<EnemyType, Func<bool>> SpawnRequirements = new Dictionary<EnemyType, Func<bool>>();

		private static bool CanEnemySpawn(EnemyType type)
		{
			if (SpawnRequirements.TryGetValue(type, out var value))
			{
				BiodiversityPlugin.LogVerbose("doing callback for " + type.enemyName);
				bool flag = value();
				if (!flag)
				{
					BiodiversityPlugin.LogVerbose("Callback for " + type.enemyName + " blocked the spawning!");
				}
				return flag;
			}
			return true;
		}

		[HarmonyPatch("SpawnRandomOutsideEnemy")]
		[HarmonyPatch("SpawnRandomDaytimeEnemy")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> ComplexSpawningRequirementsOutside(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			Label label = default(Label);
			return new CodeMatcher(instructions, generator).MatchForward(true, (CodeMatch[])(object)new CodeMatch[5]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(RoundManager), "SpawnProbabilities"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Br, (object)null, (string)null)
			}).Advance(1).ThrowIfInvalid("failed to find spawn probability assignment")
				.CreateLabel(ref label)
				.Start()
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(EnemyType), "spawningDisabled"), (string)null),
					new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null)
				})
				.ThrowIfInvalid("failed to find if condition")
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3]
				{
					new CodeInstruction(OpCodes.Ldloc_1, (object)null),
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RoundManagerPatch), "CanEnemySpawn", (Type[])null, (Type[])null)),
					new CodeInstruction(OpCodes.Brfalse, (object)label)
				})
				.InstructionEnumeration();
		}

		[HarmonyPatch("EnemyCannotBeSpawned")]
		[HarmonyPostfix]
		private static void ComplexSpawningRequirementsInside(RoundManager __instance, int enemyIndex, ref bool __result)
		{
			__result = __result && CanEnemySpawn(__instance.currentLevel.Enemies[enemyIndex].enemyType);
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	internal static class ShipTeleporterPatch
	{
		[HarmonyPatch("PressTeleportButtonClientRpc")]
		[HarmonyPrefix]
		private static void ButtonPressed(ShipTeleporter __instance)
		{
			try
			{
				if (!__instance.isInverseTeleporter)
				{
					BiodiversityPlugin.Logger.LogInfo((object)"Recording teleport data.");
					TeleporterStatus.Teleporting = true;
					TeleporterStatus.PlayerGettingTeleported = StartOfRound.Instance.mapScreen.targetedPlayer;
					TeleporterStatus.currentTeleporter = __instance;
					TeleporterStatus.isInElevator = TeleporterStatus.PlayerGettingTeleported.isInElevator;
					TeleporterStatus.isInHangarShipRoom = TeleporterStatus.PlayerGettingTeleported.isInHangarShipRoom;
					TeleporterStatus.isInFactory = TeleporterStatus.PlayerGettingTeleported.isInsideFactory;
				}
				else
				{
					BiodiversityPlugin.Logger.LogInfo((object)"Recording inverse teleport data.");
					TeleporterStatus.TeleportingInverse = true;
					TeleporterStatus.PlayerGettingInverseTeleported = StartOfRound.Instance.mapScreen.targetedPlayer;
					TeleporterStatus.currentTeleporterInverse = __instance;
					TeleporterStatus.isInElevatorInverse = TeleporterStatus.PlayerGettingInverseTeleported.isInElevator;
					TeleporterStatus.isInHangarShipRoomInverse = TeleporterStatus.PlayerGettingInverseTeleported.isInHangarShipRoom;
					TeleporterStatus.isInFactoryInverse = TeleporterStatus.PlayerGettingInverseTeleported.isInsideFactory;
				}
			}
			catch
			{
				BiodiversityPlugin.LogVerbose("Teleport data failed to set.");
				BiodiversityPlugin.Logger.LogInfo((object)"Clearing all teleport data.");
				TeleporterStatus.Teleporting = false;
				TeleporterStatus.PlayerGettingTeleported = null;
				TeleporterStatus.currentTeleporter = null;
				TeleporterStatus.isInElevator = null;
				TeleporterStatus.isInHangarShipRoom = null;
				TeleporterStatus.isInFactory = null;
				TeleporterStatus.TeleportingInverse = false;
				TeleporterStatus.PlayerGettingInverseTeleported = null;
				TeleporterStatus.currentTeleporterInverse = null;
				TeleporterStatus.isInElevatorInverse = null;
				TeleporterStatus.isInHangarShipRoomInverse = null;
				TeleporterStatus.isInFactoryInverse = null;
			}
		}
	}
}
namespace Biodiversity.Items
{
	public class BiodiverseItem : PhysicsProp
	{
		private readonly NetworkVariable<FixedString32Bytes> _networkBioId = new NetworkVariable<FixedString32Bytes>(default(FixedString32Bytes), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		protected EnemyAI enemyHeldBy;

		protected bool isHeldByPlayer;

		public string BioId
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				FixedString32Bytes value = _networkBioId.Value;
				return ((object)(FixedString32Bytes)(ref value)).ToString();
			}
		}

		protected Dictionary<string, AudioClip[]> AudioClips { get; set; } = new Dictionary<string, AudioClip[]>();


		protected Dictionary<string, AudioSource> AudioSources { get; set; } = new Dictionary<string, AudioSource>();


		public override void OnNetworkSpawn()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (((NetworkBehaviour)this).IsServer)
			{
				_networkBioId.Value = new FixedString32Bytes(Guid.NewGuid().ToString("N").Substring(0, 8));
			}
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			CollectAudioClipsAndSources();
		}

		protected virtual void CollectAudioClipsAndSources()
		{
			AudioClips = new Dictionary<string, AudioClip[]>();
			AudioSources = new Dictionary<string, AudioSource>();
		}

		[ServerRpc]
		protected void PlayRandomAudioClipTypeServerRpc(string audioClipType, string audioSourceType, bool interrupt = false, bool audibleInWalkieTalkie = true, bool audibleByEnemies = false, bool slightlyVaryPitch = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Invalid comparison between Unknown and I4
			//IL_01ef: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing r