Decompiled source of Biodiversity v0.1.3

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

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Biodiversity.Behaviours;
using Biodiversity.Creatures;
using Biodiversity.Creatures.Aloe.AnimatorStateMachineBehaviours;
using Biodiversity.Creatures.Aloe.BehaviourStates;
using Biodiversity.Creatures.Aloe.Types;
using Biodiversity.Creatures.Aloe.Types.Networking;
using Biodiversity.Patches;
using Biodiversity.Util;
using Biodiversity.Util.Assetloading;
using Biodiversity.Util.Config;
using Biodiversity.Util.Lang;
using Biodiversity.Util.Scripts;
using Biodiversity.Util.Types;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using JetBrains.Annotations;
using LethalLevelLoader;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
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.ProBuilder;
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("DissonanceVoip")]
[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.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.1.3.0")]
[assembly: AssemblyInformationalVersion("0.1.3+a620a39d21031f5e391fe143fc19b7ee6699f676")]
[assembly: AssemblyProduct("Biodiversity")]
[assembly: AssemblyTitle("com.github.biodiversitylc.Biodiversity")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<Vector3>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<Vector3>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<Quaternion>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<Quaternion>();
	}
}
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))
	{
	}
}
namespace Biodiversity
{
	public class BiodiversityConfig : BiodiverseConfigLoader<BiodiversityConfig>
	{
		[field: Header("Development")]
		[field: Tooltip("Whether to log more debug information to the console.")]
		public bool VerboseLogging { get; private set; }

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


		internal BiodiversityConfig(ConfigFile configFile)
			: base(configFile)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			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)new AcceptableValueList<string>(LangParser.languages.Keys.ToArray()), Array.Empty<object>())).Value;
		}
	}
	[BepInPlugin("com.github.biodiversitylc.Biodiversity", "Biodiversity", "0.1.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BiodiversityPlugin : BaseUnityPlugin
	{
		private static readonly (string, string)[] silly_quotes = new(string, string)[6]
		{
			("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")
		};

		public static BiodiversityPlugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static BiodiversityConfig Config { get; private set; }

		private void Awake()
		{
			Stopwatch stopwatch = Stopwatch.StartNew();
			Logger = Logger.CreateLogSource("com.github.biodiversitylc.Biodiversity");
			Instance = this;
			Logger.LogInfo((object)"Running Harmony patches...");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.github.biodiversitylc.Biodiversity");
			LangParser.Init();
			Logger.LogInfo((object)"Creating base biodiversity config.");
			Config = new BiodiversityConfig(((BaseUnityPlugin)this).Config);
			Logger.LogInfo((object)"Patching netcode.");
			NetcodePatcher();
			Logger.LogInfo((object)"Doing language stuff");
			LangParser.SetLanguage(Config.Language);
			Logger.LogInfo((object)LangParser.GetTranslation("lang.test"));
			stopwatch.Stop();
			Logger.LogInfo((object)string.Format("{0}:{1} has setup. ({2}ms)", "com.github.biodiversitylc.Biodiversity", "0.1.3", stopwatch.ElapsedMilliseconds));
		}

		internal void FinishLoading()
		{
			Stopwatch stopwatch = Stopwatch.StartNew();
			VanillaEnemies.Init();
			Logger.LogInfo((object)"Loading VideoClip bundle.");
			LoadBundle("biodiversity_video_clips");
			Logger.LogInfo((object)"Registering the silly little creatures.");
			List<Type> list = (from x in Assembly.GetExecutingAssembly().GetLoadableTypes()
				where x.BaseType != null && x.BaseType.IsGenericType && x.BaseType.GetGenericTypeDefinition() == typeof(BiodiverseAIHandler<>) && x.Name != "HoneyFeederHandler"
				select x).ToList();
			foreach (Type item in list)
			{
				if (!((BaseUnityPlugin)this).Config.Bind<bool>("Creatures", item.Name, true, (ConfigDescription)null).Value)
				{
					Logger.LogWarning((object)(item.Name + " was skipped because it's disabled."));
					continue;
				}
				Logger.LogDebug((object)("Creating " + item.Name));
				item.GetConstructor(Array.Empty<Type>()).Invoke(Array.Empty<object>());
			}
			Logger.LogInfo((object)$"Sucessfully setup {list.Count} silly creatures!");
			stopwatch.Stop();
			(string, string) tuple = silly_quotes[Random.Range(0, silly_quotes.Length)];
			Logger.LogInfo((object)("\"" + tuple.Item1 + "\" - " + tuple.Item2));
			Logger.LogInfo((object)string.Format("{0}:{1} has loaded! ({2}ms)", "com.github.biodiversitylc.Biodiversity", "0.1.3", stopwatch.ElapsedMilliseconds));
		}

		private (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) SolveLevels(string config, bool enabled)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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>();
			string[] array = config.Split(',');
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Trim().Split(':');
				if (array3.Length != 2)
				{
					continue;
				}
				int result = 0;
				if (int.TryParse(array3[1], out result))
				{
					if (Enum.TryParse<LevelTypes>(array3[0], ignoreCase: true, out LevelTypes result2))
					{
						dictionary[result2] = result;
						Logger.LogInfo((object)$"Registered spawn rate for level type {result2} to {result}");
					}
					else
					{
						dictionary2[array3[0]] = result;
						Logger.LogInfo((object)$"Registered spawn rate for custom level type {array3[0]} to {result}");
					}
				}
			}
			if (enabled)
			{
				return (dictionary, dictionary2);
			}
			return (null, null);
		}

		private void NetcodePatcher()
		{
			IEnumerable<Type> loadableTypes = Assembly.GetExecutingAssembly().GetLoadableTypes();
			foreach (Type item in loadableTypes)
			{
				MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array = methods;
				foreach (MethodInfo methodInfo in array)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		internal ConfigFile CreateConfig(string name)
		{
			//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." + name + ".cfg"
			}), false, MetadataHelper.GetMetadata((object)this));
		}

		internal AssetBundle LoadBundle(string name)
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "assets", name));
			Logger.LogDebug((object)("[AssetBundle Loading] " + name + " contains these objects: " + string.Join(",", val.GetAllAssetNames())));
			return val;
		}
	}
	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.1.3";
	}
}
namespace Biodiversity.Util
{
	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;
		}

		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 class PlayerUtil
	{
		internal static PlayerControllerB GetPlayerFromClientId(int playerClientId)
		{
			return StartOfRound.Instance.allPlayerScripts[playerClientId];
		}

		internal static bool IsPlayerDead(PlayerControllerB player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return true;
			}
			if (!player.isPlayerDead)
			{
				return !player.isPlayerControlled;
			}
			return true;
		}
	}
}
namespace Biodiversity.Util.Types
{
	public class CachedDictionary<TKey, TValue>
	{
		private readonly Dictionary<TKey, NullableObject<TValue>> _cache = new Dictionary<TKey, NullableObject<TValue>>();

		private readonly Func<TKey, TValue> _computeValueFunction;

		public TValue this[TKey key]
		{
			get
			{
				if (_cache.TryGetValue(key, out var value) && value.IsNotNull)
				{
					return value.Value;
				}
				value = new NullableObject<TValue>(_computeValueFunction(key));
				_cache[key] = value;
				return value.Value;
			}
		}

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

		public void Reset(TKey key)
		{
			if (_cache.TryGetValue(key, out var value))
			{
				value.Value = default(TValue);
			}
		}

		public void ResetAll()
		{
			foreach (TKey key in _cache.Keys)
			{
				_cache[key].Value = default(TValue);
			}
		}
	}
	public class CachedValue<T>
	{
		private readonly NullableObject<T> _cachedValue = new NullableObject<T>();

		private readonly Func<T> _computeValueFunction;

		public T Value
		{
			get
			{
				if (!_cachedValue.IsNotNull)
				{
					_cachedValue.Value = _computeValueFunction();
				}
				return _cachedValue.Value;
			}
		}

		public CachedValue(Func<T> computeValueFunction)
		{
			_computeValueFunction = computeValueFunction ?? throw new ArgumentNullException("computeValueFunction");
		}

		public void Reset()
		{
			_cachedValue.Value = default(T);
		}
	}
	public class NullableObject<T>
	{
		private T _value;

		public bool IsNotNull { get; private set; }

		public T Value
		{
			get
			{
				return _value;
			}
			set
			{
				_value = value;
				IsNotNull = !EqualityComparer<T>.Default.Equals(_value, default(T));
			}
		}

		public NullableObject(T value = default(T))
		{
			Value = value;
		}
	}
}
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.Lang
{
	internal class LangParser
	{
		internal static Dictionary<string, string> languages { get; private set; }

		internal static Dictionary<string, object> loadedLanguage { get; private set; }

		internal static void Init()
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Biodiversity.Util.Lang.defs.json");
			using StreamReader streamReader = new StreamReader(stream);
			string text = streamReader.ReadToEnd();
			languages = JsonConvert.DeserializeObject<Dictionary<string, string>>(text);
		}

		internal static Dictionary<string, object> LoadLanguage(string id)
		{
			using Stream stream = File.Open(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lang", id + ".json"), FileMode.Open);
			using StreamReader streamReader = new StreamReader(stream);
			string text = streamReader.ReadToEnd();
			return JsonConvert.DeserializeObject<Dictionary<string, object>>(text);
		}

		internal static void SetLanguage(string id)
		{
			loadedLanguage = LoadLanguage(id);
		}

		internal static string GetTranslation(string translation)
		{
			if (loadedLanguage.TryGetValue(translation, out var value))
			{
				return (string)value;
			}
			if (translation == "lang.missing")
			{
				BiodiversityPlugin.Logger.LogError((object)"LANG.MISSING IS MISSING!!!!!  THIS IS BAD!! VERY BAD!!");
				return "lang.missing; <translation_id>";
			}
			return GetTranslation("lang.missing").Replace("<translation_id>", translation);
		}

		internal static JArray GetTranslationSet(string translation)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			if (loadedLanguage.TryGetValue(translation, out var value))
			{
				BiodiversityPlugin.Logger.LogInfo((object)value.GetType());
				return (JArray)((value is JArray) ? value : null);
			}
			JArray val = new JArray();
			val.Add(JToken.op_Implicit(GetTranslation("lang.missing").Replace("<translation_id>", translation)));
			return val;
		}
	}
}
namespace Biodiversity.Util.Config
{
	[Serializable]
	public abstract class BiodiverseConfigLoader<T> where T : BiodiverseConfigLoader<T>
	{
		protected BiodiverseConfigLoader(ConfigFile configFile)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			string text = "Misc";
			Type typeFromHandle = typeof(T);
			configFile.SaveOnConfigSet = false;
			PropertyInfo[] properties = typeFromHandle.GetProperties();
			foreach (PropertyInfo propertyInfo in properties)
			{
				try
				{
					FieldInfo field = propertyInfo.DeclaringType.GetField("<" + propertyInfo.Name + ">k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic);
					if (field.GetCustomAttribute(typeof(NonSerializedAttribute)) != null)
					{
						continue;
					}
					HeaderAttribute val = (HeaderAttribute)field.GetCustomAttribute(typeof(HeaderAttribute));
					if (val != null)
					{
						text = val.header.Replace(" ", "");
					}
					string text2 = "This config option hasn't used [Tooltip] to set a description, so this default one will be here instead.";
					TooltipAttribute val2 = (TooltipAttribute)field.GetCustomAttribute(typeof(TooltipAttribute));
					if (val2 != null)
					{
						text2 = val2.tooltip;
					}
					ConfigDescription val3 = new ConfigDescription(text2, (AcceptableValueBase)null, Array.Empty<object>());
					RangeAttribute val4 = (RangeAttribute)field.GetCustomAttribute(typeof(RangeAttribute));
					val3 = ((val4 == null) ? new ConfigDescription(text2, (AcceptableValueBase)null, Array.Empty<object>()) : ((propertyInfo.PropertyType == typeof(int)) ? new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>((int)val4.min, (int)val4.max), Array.Empty<object>()) : new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<float>(val4.min, val4.max), Array.Empty<object>())));
					if (propertyInfo.PropertyType == typeof(float))
					{
						propertyInfo.SetValue(this, configFile.Bind<float>(text, propertyInfo.Name, (float)propertyInfo.GetValue(this), val3).Value);
					}
					if (propertyInfo.PropertyType == typeof(int))
					{
						propertyInfo.SetValue(this, configFile.Bind<int>(text, propertyInfo.Name, (int)propertyInfo.GetValue(this), val3).Value);
					}
					if (propertyInfo.PropertyType == typeof(string))
					{
						propertyInfo.SetValue(this, configFile.Bind<string>(text, propertyInfo.Name, (string)propertyInfo.GetValue(this), val3).Value);
					}
					if (propertyInfo.PropertyType == typeof(bool))
					{
						propertyInfo.SetValue(this, configFile.Bind<bool>(text, propertyInfo.Name, (bool)propertyInfo.GetValue(this), val3).Value);
					}
					goto IL_02af;
				}
				catch (Exception ex)
				{
					BiodiversityPlugin.Logger.LogError((object)("Exception while binding: " + propertyInfo.Name));
					BiodiversityPlugin.Logger.LogError((object)ex.ToString());
					goto IL_02af;
				}
				IL_02af:
				if (propertyInfo.PropertyType == typeof(EnemyRaritiesPerMoon))
				{
					EnemyRaritiesPerMoon enemyRaritiesPerMoon = (EnemyRaritiesPerMoon)propertyInfo.GetValue(this);
					enemyRaritiesPerMoon.Bind(configFile, propertyInfo.Name);
					propertyInfo.SetValue(this, enemyRaritiesPerMoon);
				}
			}
			configFile.SaveOnConfigSet = true;
			configFile.Save();
		}
	}
	public class EnemyRaritiesPerMoon
	{
		public Dictionary<LevelTypes, int> VanillaRarities;

		public Dictionary<string, int> ModdedRarities;

		public int DefaultRarity { get; private set; }

		public EnemyRaritiesPerMoon(int defaultRarity, Dictionary<LevelTypes, int> VanillaRarities = null, Dictionary<string, int> ModdedRarities = null)
		{
			DefaultRarity = defaultRarity;
			this.VanillaRarities = VanillaRarities ?? new Dictionary<LevelTypes, int>();
			this.ModdedRarities = ModdedRarities ?? new Dictionary<string, int>();
		}

		public void Bind(ConfigFile file, string section)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0028: Invalid comparison between Unknown and I4
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Invalid comparison between Unknown and I4
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_0053: 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)
			foreach (LevelTypes value in Enum.GetValues(typeof(LevelTypes)))
			{
				LevelTypes val = value;
				if ((int)val <= 1)
				{
					if ((int)val == -1 || (int)val == 1)
					{
						goto IL_0044;
					}
				}
				else if ((int)val == 1024 || (int)val == 15356)
				{
					goto IL_0044;
				}
				bool flag = false;
				goto IL_004a;
				IL_0044:
				flag = true;
				goto IL_004a;
				IL_004a:
				if (!flag)
				{
					VanillaRarities[val] = file.Bind<int>(section, ((object)(LevelTypes)(ref val)).ToString(), VanillaRarities.GetValueOrDefault(val, DefaultRarity), "Rarity for '" + ((object)(LevelTypes)(ref val)).ToString() + "' (vanilla)").Value;
				}
			}
			if (Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader"))
			{
				BiodiversityPlugin.Logger.LogDebug((object)"binding modded moons from lethal level loader.");
				BindLLL(file, section);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void BindLLL(ConfigFile file, string section)
		{
			BiodiversityPlugin.Logger.LogDebug((object)$"{PatchedContent.ExtendedMods.Count} mods");
			BiodiversityPlugin.Logger.LogDebug((object)(string.Join(", ", PatchedContent.AllLevelSceneNames) ?? ""));
			foreach (ExtendedMod extendedMod in PatchedContent.ExtendedMods)
			{
				if ((Object)(object)PatchedContent.VanillaMod == (Object)(object)extendedMod)
				{
					continue;
				}
				foreach (ExtendedLevel extendedLevel in extendedMod.ExtendedLevels)
				{
					string numberlessPlanetName = extendedLevel.NumberlessPlanetName;
					ModdedRarities[numberlessPlanetName] = file.Bind<int>(section, numberlessPlanetName, ModdedRarities.GetValueOrDefault(numberlessPlanetName, DefaultRarity), "Rarity for '" + numberlessPlanetName + "' (modded)").Value;
				}
			}
		}
	}
}
namespace Biodiversity.Util.Assetloading
{
	internal abstract class BiodiverseAssetBundle<T> where T : BiodiverseAssetBundle<T>
	{
		protected BiodiverseAssetBundle(string filePath)
		{
			AssetBundle val = BiodiversityPlugin.Instance.LoadBundle(filePath);
			Type typeFromHandle = typeof(T);
			FieldInfo[] fields = typeFromHandle.GetFields();
			foreach (FieldInfo fieldInfo in fields)
			{
				LoadFromBundleAttribute loadFromBundleAttribute = (LoadFromBundleAttribute)fieldInfo.GetCustomAttribute(typeof(LoadFromBundleAttribute));
				if (loadFromBundleAttribute != null)
				{
					fieldInfo.SetValue(this, LoadAsset(val, loadFromBundleAttribute.BundleFile));
				}
			}
			Object[] array = val.LoadAllAssets();
			foreach (Object val2 in array)
			{
				GameObject val3 = (GameObject)(object)((val2 is GameObject) ? val2 : null);
				if (val3 != null)
				{
					if ((Object)(object)val3.GetComponent<NetworkObject>() == (Object)null || GameNetworkManagerPatch.networkPrefabsToRegister.Contains(val3))
					{
						continue;
					}
					GameNetworkManagerPatch.networkPrefabsToRegister.Add(val3);
				}
				AudioClip val4 = (AudioClip)(object)((val2 is AudioClip) ? val2 : null);
				if (val4 != null && !val4.preloadAudioData)
				{
					BiodiversityPlugin.Logger.LogWarning((object)("Loading Audio data for '" + ((Object)val4).name + "' because it does not have preloadAudioData enabled!"));
					val4.LoadAudioData();
				}
				VideoClip val5 = (VideoClip)(object)((val2 is VideoClip) ? val2 : null);
				if (val5 != null)
				{
					BiodiversityPlugin.Logger.LogError((object)("VideoClip: '" + ((Object)val5).name + "' is being loaded from '" + typeof(T).Name + "' instead of the dedicated video clip bundle. It will not work correctly."));
				}
			}
			val.Unload(false);
		}

		private static Object LoadAsset(AssetBundle bundle, string path)
		{
			Object val = bundle.LoadAsset<Object>(path);
			if (val == (Object)null)
			{
				throw new ArgumentException(path + " is not valid in the assetbundle!");
			}
			return val;
		}
	}
	[AttributeUsage(AttributeTargets.Field)]
	internal class LoadFromBundleAttribute : Attribute
	{
		public string BundleFile { get; private set; }

		public LoadFromBundleAttribute(string bundleFile)
		{
			BundleFile = bundleFile;
			base..ctor();
		}
	}
}
namespace Biodiversity.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal static class EnemyAIPatch
	{
		private static IEnumerable<CodeInstruction> AllowSearchRoutineDelay(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase __originalMethod)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Expected O, but got Unknown
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Expected O, but got Unknown
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Expected O, but got Unknown
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Expected O, but got Unknown
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Expected O, but got Unknown
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Expected O, but got Unknown
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Expected O, but got Unknown
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Expected O, but got Unknown
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Expected O, but got Unknown
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Expected O, but got Unknown
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Expected O, but got Unknown
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Expected O, but got Unknown
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Expected O, but got Unknown
			Type declaringType = __originalMethod.DeclaringType;
			CodeMatcher val = new CodeMatcher(instructions, generator).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)null, (object)null, (string)null)
			});
			CodeInstruction val2 = null;
			while (val.IsValid)
			{
				val = val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
				{
					new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
					new CodeMatch((OpCode?)null, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(declaringType, "<>1__state"), (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ret, (object)null, (string)null)
				}).Advance(1);
				if (val.IsValid)
				{
					val2 = val.Instruction;
				}
			}
			if (val2 == null)
			{
				throw new InvalidProgramException("EnemyAI::CurrentSearchCoroutine doesn't have any yield return statements?? what?");
			}
			if (val2.opcode == OpCodes.Ldc_I4_6)
			{
				CodeInstruction val3 = new CodeInstruction(OpCodes.Ldc_I4_7, (object)null);
				Label label = default(Label);
				Label label2 = default(Label);
				val = val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[9]
				{
					new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(EnemyAI), "searchCoroutine"), (string)null),
					new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(NetworkBehaviour), "IsOwner"), (string)null),
					new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(NetworkBehaviour), "IsOwner"), (string)null),
					new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null)
				}).ThrowIfInvalid("Failed to find 'Destination Reached' code!")
					.CreateLabel(ref label)
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[17]
					{
						new CodeInstruction(OpCodes.Ldloc_1, (object)null),
						new CodeInstruction(OpCodes.Isinst, (object)typeof(BiodiverseAI)),
						new CodeInstruction(OpCodes.Brfalse, (object)label),
						new CodeInstruction(OpCodes.Ldarg_0, (object)null),
						new CodeInstruction(OpCodes.Ldloc_1, (object)null),
						new CodeInstruction(OpCodes.Castclass, (object)typeof(BiodiverseAI)),
						new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(BiodiverseAI), "GetDelayBeforeContinueSearch", (Type[])null, (Type[])null)),
						new CodeInstruction(OpCodes.Newobj, (object)AccessTools.Constructor(typeof(WaitForSeconds), new Type[1] { typeof(float) }, false)),
						new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(declaringType, "<>2__current")),
						new CodeInstruction(OpCodes.Ldarg_0, (object)null),
						val3,
						new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(declaringType, "<>1__state")),
						new CodeInstruction(OpCodes.Ldc_I4_1, (object)null),
						new CodeInstruction(OpCodes.Ret, (object)null),
						new CodeInstruction(OpCodes.Ldarg_0, (object)null),
						new CodeInstruction(OpCodes.Ldc_I4_M1, (object)null),
						new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(declaringType, "<>1__state"))
					})
					.Advance(-3)
					.CreateLabel(ref label2)
					.Start()
					.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
					{
						new CodeMatch((OpCode?)OpCodes.Switch, (object)null, (string)null)
					})
					.SetOperandAndAdvance((object)CollectionExtensions.AddItem<Label>((IEnumerable<Label>)(Label[])val.Instruction.operand, label2).ToArray())
					.Advance(-1);
				return val.InstructionEnumeration();
			}
			throw new InvalidProgramException("EnemyAI::CurrentSearchCoroutine has a new number of yield return statements.");
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal static class GameNetworkManagerPatch
	{
		internal static List<GameObject> networkPrefabsToRegister = new List<GameObject>();

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void AddNetworkPrefabs()
		{
			BiodiversityPlugin.Instance.FinishLoading();
			foreach (GameObject item in networkPrefabsToRegister)
			{
				NetworkManager.Singleton.AddNetworkPrefab(item);
				BiodiversityPlugin.Logger.LogDebug((object)("Registered " + ((Object)item).name + " as a network prefab."));
			}
			BiodiversityPlugin.Logger.LogInfo((object)$"Succesfully registered {networkPrefabsToRegister.Count} network prefabs.");
		}
	}
	internal static class RoundManagerPatch
	{
		internal static Dictionary<EnemyType, Func<bool>> spawnRequirements = new Dictionary<EnemyType, Func<bool>>();

		private static bool CanEnemySpawn(EnemyType type)
		{
			if (spawnRequirements.TryGetValue(type, out var value))
			{
				BiodiversityPlugin.Logger.LogInfo((object)("doing callback for " + type.enemyName));
				bool flag = value();
				if (!flag)
				{
					BiodiversityPlugin.Logger.LogInfo((object)("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);
		}
	}
}
namespace Biodiversity.Items.RubberDuck
{
	public class RubberDuckItem : PhysicsProp
	{
		public MeshRenderer m;

		public Material[] Materials;

		private AudioSource Source;

		private Animator animator;

		private void Awake()
		{
			SetRandomTextureClass setRandomTextureClass = ((Component)this).GetComponent<SetRandomTextureClass>();
			if ((Object)(object)setRandomTextureClass == (Object)null)
			{
				setRandomTextureClass = ((Component)this).gameObject.AddComponent<SetRandomTextureClass>();
			}
			setRandomTextureClass.Materials = Materials;
			animator = ((Component)this).GetComponent<Animator>();
			Source = ((Component)this).GetComponent<AudioSource>();
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			animator.Play("Squeeze", -1, 0f);
			Source.Play();
			MouthDogAI[] array = Object.FindObjectsOfType<MouthDogAI>();
			foreach (MouthDogAI val in array)
			{
				((EnemyAI)val).DetectNoise(((Component)this).gameObject.transform.position, 0.5f, 0, 0);
			}
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "RubberDuckItem";
		}
	}
	public class SetRandomTextureClass : NetworkBehaviour
	{
		private NetworkVariable<int> RubberDuckVariable = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public Material[] Materials;

		private MeshRenderer Mesh;

		private void Awake()
		{
			Mesh = ((Component)this).GetComponent<MeshRenderer>();
		}

		private void Start()
		{
			RubberDuckVariable.Value = Random.Range(0, Materials.Length);
		}

		private void Update()
		{
			((Renderer)Mesh).materials[0] = Materials[RubberDuckVariable.Value];
			((Renderer)Mesh).material = Materials[RubberDuckVariable.Value];
		}

		protected override void __initializeVariables()
		{
			if (RubberDuckVariable == null)
			{
				throw new Exception("SetRandomTextureClass.RubberDuckVariable cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)RubberDuckVariable).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)RubberDuckVariable, "RubberDuckVariable");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)RubberDuckVariable);
			((NetworkBehaviour)this).__initializeVariables();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "SetRandomTextureClass";
		}
	}
}
namespace Biodiversity.Items.Developeritems
{
	internal class DeveloperScarpAssets : BiodiverseAssetBundle<DeveloperScarpAssets>
	{
		[LoadFromBundle("RubberDuckAsset")]
		public Item DuckAsset;

		public DeveloperScarpAssets(string Bundle)
			: base(Bundle)
		{
		}
	}
	internal class DeveloperScarpHandler : BiodiverseAIHandler<DeveloperScarpHandler>
	{
		internal DeveloperScarpAssets Assets { get; set; }

		public DeveloperScarpHandler()
		{
			Assets = new DeveloperScarpAssets("devitems");
			Item[] array = (Item[])(object)new Item[1] { Assets.DuckAsset };
			for (int i = 0; i < array.Length; i++)
			{
				NetworkPrefabs.RegisterNetworkPrefab(array[i].spawnPrefab);
				Items.RegisterScrap(array[i], 5, (LevelTypes)(-1));
			}
		}
	}
}
namespace Biodiversity.Creatures
{
	public abstract class BiodiverseAI : EnemyAI
	{
		protected bool ShouldProcessEnemy()
		{
			if (!base.isEnemyDead)
			{
				return StartOfRound.Instance.allPlayersDead;
			}
			return true;
		}

		protected bool GetPlayersCloseBy(float radius, out List<PlayerControllerB> players)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			players = new List<PlayerControllerB>();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				Vector3 val2 = ((Component)this).transform.position - ((Component)val).transform.position;
				if (((Vector3)(ref val2)).magnitude <= radius)
				{
					players.Add(val);
				}
			}
			return players.Count != 0;
		}

		protected bool HasFinishedAgentPath()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (!base.agent.pathPending && base.agent.remainingDistance <= base.agent.stoppingDistance)
			{
				if (base.agent.hasPath)
				{
					Vector3 velocity = base.agent.velocity;
					if (((Vector3)(ref velocity)).sqrMagnitude != 0f)
					{
						goto IL_004e;
					}
				}
				return true;
			}
			goto IL_004e;
			IL_004e:
			return false;
		}

		protected static Vector3 GetRandomPositionOnNavMesh(Vector3 position, float radius = 10f)
		{
			//IL_0005: 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_0019: 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)
			RoundManager instance = RoundManager.Instance;
			Random random = new Random();
			return instance.GetRandomNavMeshPositionInBoxPredictable(position, 10f, default(NavMeshHit), random, -1);
		}

		protected Vector3 GetRandomPositionNearPlayer(PlayerControllerB player, float radius = 15f, float minDistance = 0f)
		{
			//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)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0026: 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)
			return GetRandomPositionOnNavMesh(((Component)player).transform.position + Random.insideUnitSphere * radius + Random.onUnitSphere * minDistance);
		}

		protected PlayerControllerB GetClosestPlayer(IEnumerable<PlayerControllerB> players)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return GetClosestPlayer(players, ((Component)this).transform.position);
		}

		protected PlayerControllerB GetClosestPlayer(IEnumerable<PlayerControllerB> players, Vector3 point)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return players.OrderBy((PlayerControllerB player) => Vector3.Distance(((Component)player).transform.position, point)).First();
		}

		protected void LogVerbose(object message)
		{
			if (BiodiversityPlugin.Config.VerboseLogging)
			{
				BiodiversityPlugin.Logger.LogDebug((object)$"[{base.enemyType.enemyName}] {message}");
			}
		}

		internal virtual float GetDelayBeforeContinueSearch()
		{
			return 0f;
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "BiodiverseAI";
		}
	}
	internal abstract class BiodiverseAIHandler<T> where T : BiodiverseAIHandler<T>
	{
		internal static T Instance { get; private set; }

		internal BiodiverseAIHandler()
		{
			Instance = (T)this;
		}

		protected void AddSpawnRequirement(EnemyType type, Func<bool> callback)
		{
			RoundManagerPatch.spawnRequirements.Add(type, callback);
		}

		protected void TranslateTerminalNode(TerminalNode node)
		{
			node.displayText = LangParser.GetTranslation(node.displayText);
		}

		protected 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);
			}
		}

		private 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_0096: 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_00de: 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.Logger.LogDebug((object)$"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.Logger.LogDebug((object)$"Registered spawn rate for level type {result2} to {result}");
				}
				else
				{
					dictionary2[text] = result;
					BiodiversityPlugin.Logger.LogDebug((object)$"Registered spawn rate for custom level type {text} to {result}");
				}
			}
			return (dictionary, dictionary2);
		}
	}
	public static class VanillaEnemies
	{
		public static EnemyType Flowerman { get; private set; }

		public static EnemyType Centipede { get; private set; }

		public static EnemyType MouthDog { get; private set; }

		public static EnemyType Crawler { get; private set; }

		public static EnemyType HoarderBug { get; private set; }

		public static EnemyType SandSpider { get; private set; }

		public static EnemyType Blob { get; private set; }

		public static EnemyType ForestGiant { get; private set; }

		public static EnemyType DressGirl { get; private set; }

		public static EnemyType SpringMan { get; private set; }

		public static EnemyType SandWorm { get; private set; }

		public static EnemyType Jester { get; private set; }

		public static EnemyType Puffer { get; private set; }

		public static EnemyType Doublewing { get; private set; }

		public static EnemyType DocileLocustBees { get; private set; }

		public static EnemyType RedLocustBees { get; private set; }

		public static EnemyType BaboonHawk { get; private set; }

		public static EnemyType Nutcracker { get; private set; }

		public static EnemyType MaskedPlayerEnemy { get; private set; }

		public static EnemyType RadMech { get; private set; }

		public static EnemyType Butler { get; private set; }

		public static EnemyType ButlerBees { get; private set; }

		public static EnemyType FlowerSnake { get; private set; }

		public static EnemyType BushWolf { get; private set; }

		public static EnemyType ClaySurgeon { get; private set; }

		internal static void Init()
		{
			List<string> list = new List<string>();
			BiodiversityPlugin.Logger.LogInfo((object)"Getting all vanilla enemy types.");
			EnemyAI val = default(EnemyAI);
			foreach (NetworkPrefab prefab in NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs)
			{
				if (prefab.Prefab.TryGetComponent<EnemyAI>(ref val))
				{
					BiodiversityPlugin.Logger.LogDebug((object)("Found enemy: " + ((Object)val.enemyType).name));
					PropertyInfo property = typeof(VanillaEnemies).GetProperty(((Object)val.enemyType).name);
					if (property == null)
					{
						list.Add(((Object)val.enemyType).name);
					}
					else
					{
						property.SetValue(null, val.enemyType);
					}
				}
			}
			BiodiversityPlugin.Logger.LogDebug((object)("Unknown enemy types: " + string.Join(", ", list)));
		}
	}
}
namespace Biodiversity.Creatures.WaxSoldier
{
	public class WaxSoldierAI : EnemyAI
	{
		public NetworkVariable<int> State = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public BoxCollider StabHITBOX;

		public Vector3 StartPosition;

		public Quaternion StartRotation;

		private AudioSource Theme;

		public NavMeshPath path;

		public override void Start()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			path = new NavMeshPath();
			Theme = ((Component)this).GetComponent<AudioSource>();
			StartPosition = ((Component)this).transform.position;
			StartRotation = ((Component)this).transform.rotation;
		}

		public override void DoAIInterval()
		{
			//IL_005e: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (State.Value == 0)
			{
				((EnemyAI)this).TargetClosestPlayer(1.5f, true, 90f);
				if (base.agent.remainingDistance <= 0.5f)
				{
					base.creatureAnimator.SetInteger("state", 0);
					((Component)this).transform.rotation = StartRotation;
				}
				((EnemyAI)this).SetDestinationToPosition(StartPosition, false);
				if (Theme.isPlaying)
				{
					Theme.Stop();
				}
				if (Object.op_Implicit((Object)(object)base.targetPlayer) && Vector3.Distance(((Component)this).gameObject.transform.position, ((Component)base.targetPlayer).gameObject.transform.position) <= 15f)
				{
					State.Value = 1;
				}
			}
			if (State.Value != 1)
			{
				return;
			}
			bool flag = ((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
			base.creatureAnimator.SetInteger("state", 1);
			if (!Object.op_Implicit((Object)(object)base.targetPlayer))
			{
				return;
			}
			((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
			if (Vector3.Distance(((Component)this).gameObject.transform.position, ((Component)base.targetPlayer).gameObject.transform.position) >= 20f && flag)
			{
				State.Value = 0;
				return;
			}
			if (!Theme.isPlaying)
			{
				Theme.Play();
			}
			if (Vector3.Distance(((Component)this).gameObject.transform.position, ((Component)base.targetPlayer).gameObject.transform.position) <= 4f)
			{
				((EnemyAI)this).SetDestinationToPosition(((Component)this).transform.position, false);
				((Component)this).transform.LookAt(((Component)base.targetPlayer).transform);
				((MonoBehaviour)this).StartCoroutine(Stab());
			}
		}

		public IEnumerator Stab()
		{
			State.Value = 3;
			base.creatureAnimator.SetInteger("state", 3);
			base.creatureAnimator.speed = 0.5f;
			yield return (object)new WaitForSeconds(0.15f);
			((Component)StabHITBOX).gameObject.SetActive(true);
			Collider[] array = Physics.OverlapBox(StabHITBOX.center, StabHITBOX.size, Quaternion.identity);
			foreach (Collider val in array)
			{
				PlayerControllerB component = ((Component)val).gameObject.GetComponent<PlayerControllerB>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.DamagePlayer(30, false, true, (CauseOfDeath)14, 0, false, ((Component)this).transform.forward * 3f);
				}
			}
			((Component)StabHITBOX).gameObject.SetActive(false);
			yield return (object)new WaitForSeconds(0.3f);
			base.creatureAnimator.speed = 1f;
			base.creatureAnimator.SetInteger("state", 0);
			yield return (object)new WaitForSeconds(0.1f);
			State.Value = 0;
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
		}

		protected override void __initializeVariables()
		{
			if (State == null)
			{
				throw new Exception("WaxSoldierAI.State cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)State).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)State, "State");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)State);
			((EnemyAI)this).__initializeVariables();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "WaxSoldierAI";
		}
	}
	internal class WaxSoldierAssets : BiodiverseAssetBundle<WaxSoldierAssets>
	{
		[LoadFromBundle("WaxSoldierType")]
		public EnemyType WaxSoldierType;

		[LoadFromBundle("WaxSoldierNode")]
		public TerminalNode WaxSoldierNode;

		[LoadFromBundle("WaxSoldierKey")]
		public TerminalKeyword WaxSoldierKey;

		public WaxSoldierAssets(string bundle)
			: base(bundle)
		{
		}
	}
	internal class WaxSoldierHandler : BiodiverseAIHandler<WaxSoldierHandler>
	{
		internal WaxSoldierAssets Assets { get; set; }

		public WaxSoldierHandler()
		{
			Assets = new WaxSoldierAssets("waxsoldier");
			NetworkPrefabs.RegisterNetworkPrefab(Assets.WaxSoldierType.enemyPrefab);
			Enemies.RegisterEnemy(Assets.WaxSoldierType, 0, (LevelTypes)(-1), Assets.WaxSoldierNode, Assets.WaxSoldierKey);
		}
	}
}
namespace Biodiversity.Creatures.Ogopogo
{
	public class HeadRotation : MonoBehaviour
	{
		public GameObject ThingToCopy;

		private void LateUpdate()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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)
			((Component)this).transform.rotation = ThingToCopy.transform.rotation * Quaternion.Euler(-74.022f, 0f, 0f);
		}
	}
	internal class OgopogoAI : BiodiverseAI
	{
		private enum State
		{
			Wandering,
			Chasing,
			Rising,
			Goingdown,
			Reset
		}

		private QuicksandTrigger water;

		private readonly QuicksandTrigger[] sandAndWater = Object.FindObjectsOfType<QuicksandTrigger>();

		private readonly List<QuicksandTrigger> waters = new List<QuicksandTrigger>();

		private const float WanderSpeed = 3.5f;

		private const float ChaseSpeed = 4f;

		private float detectionRange;

		private float loseRange;

		private float attackDistance;

		private const float RiseSpeed = 75f;

		private const float RiseHeight = 100f;

		[SerializeField]
		private Transform RaycastPos;

		private bool wallInFront;

		private float attackTimer;

		private bool dropRaycast;

		private bool wanderOff;

		private float wanderTimer;

		private Vector3 wanderPos = Vector3.zero;

		[SerializeField]
		private Transform SplineEnd;

		[SerializeField]
		private SplineObject splineObject;

		[NonSerialized]
		private bool splineDone;

		private const float SplineSpeed = 0.7f;

		private bool playerHasBeenGrabbed;

		[SerializeField]
		private Transform GrabPos;

		private readonly NullableObject<PlayerControllerB> playerGrabbed = new NullableObject<PlayerControllerB>();

		private readonly NullableObject<PlayerControllerB> chasedPlayer = new NullableObject<PlayerControllerB>();

		private CachedDictionary<ulong, MeshRenderer> playerVisorRenderers;

		private float[] _playerDistances;

		[SerializeField]
		private AudioClip warning;

		[SerializeField]
		private AudioClip emerge;

		[SerializeField]
		private AudioClip returnToWater;

		[SerializeField]
		private KeepY normalAudio;

		private float resetTimer;

		[SerializeField]
		private Transform defaultEye;

		private bool stunnedLastFrame;

		public Transform MapDot;

		public EasyIK IK;

		private static readonly int AnimID = Animator.StringToHash("AnimID");

		private static readonly int Stun = Animator.StringToHash("Stun");

		public override void Start()
		{
			//IL_00fa: 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_00d9: Invalid comparison between Unknown and I4
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			detectionRange = BiodiverseAIHandler<OgopogoHandler>.Instance.Config.DetectionRange;
			loseRange = BiodiverseAIHandler<OgopogoHandler>.Instance.Config.LoseRange;
			attackDistance = BiodiverseAIHandler<OgopogoHandler>.Instance.Config.AttackDistance;
			_playerDistances = new float[StartOfRound.Instance.allPlayerScripts.Length];
			try
			{
				QuicksandTrigger[] array = sandAndWater;
				foreach (QuicksandTrigger val in array)
				{
					if (val.isWater && !((Component)val).gameObject.CompareTag("SpawnDenialPoint") && ((Object)((Component)((Component)val).transform.root).gameObject).name != "Systems")
					{
						waters.Add(val);
					}
				}
				if (waters.Count == 0 || (int)TimeOfDay.Instance.currentLevelWeather == 4)
				{
					BiodiversityPlugin.Logger.LogWarning((object)"Despawning because no water exists that is spawnable or there is a flood.");
					RoundManager.Instance.DespawnEnemyOnServer(NetworkObjectReference.op_Implicit(new NetworkObjectReference(((Component)this).gameObject.GetComponent<NetworkObject>())));
					return;
				}
				water = waters[Random.Range(0, waters.Count)];
				((Component)this).transform.position = ((Component)water).transform.position;
				wanderOff = false;
				string[] array2 = BiodiverseAIHandler<OgopogoHandler>.Instance.Config.OgopogoWanderDisable.Split(",");
				foreach (string text in array2)
				{
					if (text == ((Object)StartOfRound.Instance.currentLevel).name)
					{
						wanderOff = true;
					}
				}
				bool flag = false;
				Dictionary<string, Vector3[]> dictionary = new Dictionary<string, Vector3[]>();
				dictionary.Add("VowLevel", (Vector3[])(object)new Vector3[2]
				{
					new Vector3(-104.8f, -22.061f, 110.33f),
					new Vector3(27f, -22.061f, -61.2f)
				});
				dictionary.Add("AdamanceLevel", (Vector3[])(object)new Vector3[2]
				{
					new Vector3(58.12f, -11.04f, -1.85f),
					new Vector3(52.08f, -11.04f, -12.59f)
				});
				Dictionary<string, Vector3[]> dictionary2 = dictionary;
				if (dictionary2.ContainsKey(((Object)StartOfRound.Instance.currentLevel).name))
				{
					flag = true;
					Vector3[] array3 = dictionary2[((Object)StartOfRound.Instance.currentLevel).name];
					int num = array3.Count();
					int num2 = Random.Range(0, num);
					((Component)this).transform.position = array3[num2];
				}
				foreach (QuicksandTrigger item in waters)
				{
					if (flag && Collision2d(((Component)this).transform.position, (Collider)(object)((Component)item).GetComponent<BoxCollider>()))
					{
						water = item;
					}
				}
				SetWanderPos();
			}
			catch (Exception ex)
			{
				Debug.LogException(ex);
			}
			normalAudio.Init();
			playerVisorRenderers = new CachedDictionary<ulong, MeshRenderer>((ulong playerId) => ((Component)StartOfRound.Instance.allPlayerScripts[playerId].localVisor).gameObject.GetComponentsInChildren<MeshRenderer>()[0]);
		}

		public override void Update()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: 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_019c: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			MapDot.position = (Vector3)(StartOfRound.Instance.mapScreen.targetedPlayer.isInsideFactory ? ((Component)this).transform.position : new Vector3(((Component)this).transform.position.x, ((Component)StartOfRound.Instance.mapScreen.targetedPlayer).transform.position.y, ((Component)this).transform.position.z));
			((Renderer)((EnemyAI)this).skinnedMeshRenderers[0]).enabled = !GameNetworkManager.Instance.localPlayerController.isInsideFactory;
			switch (((EnemyAI)this).currentBehaviourStateIndex)
			{
			case 0:
				wanderTimer += Time.deltaTime;
				break;
			case 4:
				resetTimer += Time.deltaTime;
				break;
			case 1:
				attackTimer -= Time.deltaTime;
				break;
			}
			if (((EnemyAI)this).currentBehaviourStateIndex == 0 || ((EnemyAI)this).currentBehaviourStateIndex == 1)
			{
				((EnemyAI)this).eye.position = ((Component)defaultEye).transform.position;
				((EnemyAI)this).eye.rotation = ((Component)defaultEye).transform.rotation;
			}
			else if (chasedPlayer.IsNotNull)
			{
				((EnemyAI)this).eye.position = ((Component)chasedPlayer.Value).transform.position + ((Component)chasedPlayer.Value).transform.forward * 1f;
				TurnObjectTowardsLocation(((Component)chasedPlayer.Value).transform.position, ((EnemyAI)this).eye);
			}
		}

		public void LateUpdate()
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				_playerDistances[val.playerClientId] = Distance2d(((Component)StartOfRound.Instance.shipBounds).gameObject, ((Component)val).gameObject);
			}
		}

		public void FixedUpdate()
		{
			//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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			wallInFront = CheckForWall();
			dropRaycast = Physics.Raycast(GrabPos.position, Vector3.down, 20f, 256);
			if (playerGrabbed.IsNotNull)
			{
				((Component)playerGrabbed.Value).transform.position = GrabPos.position;
				((Component)playerGrabbed.Value).transform.rotation = GrabPos.rotation;
				if (playerGrabbed.Value.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId)
				{
					((Renderer)playerGrabbed.Value.thisPlayerModelArms).enabled = false;
					((Renderer)playerVisorRenderers[playerGrabbed.Value.actualClientId]).enabled = false;
				}
				if (!GameNetworkManager.Instance.localPlayerController.isPlayerDead)
				{
					((Renderer)GameNetworkManager.Instance.localPlayerController.thisPlayerModelArms).enabled = true;
				}
				((Renderer)playerVisorRenderers[playerGrabbed.Value.actualClientId]).enabled = true;
			}
		}

		private void SetWanderPos()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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)
			BoxCollider component = ((Component)water).gameObject.GetComponent<BoxCollider>();
			ref Vector3 reference = ref wanderPos;
			Bounds bounds = ((Collider)component).bounds;
			float x = ((Bounds)(ref bounds)).min.x;
			bounds = ((Collider)component).bounds;
			reference.x = Random.Range(x, ((Bounds)(ref bounds)).max.x);
			wanderPos.y = ((Component)water).transform.position.y;
			ref Vector3 reference2 = ref wanderPos;
			bounds = ((Collider)component).bounds;
			float z = ((Bounds)(ref bounds)).min.z;
			bounds = ((Collider)component).bounds;
			reference2.z = Random.Range(z, ((Bounds)(ref bounds)).max.z);
			wanderTimer = 0f;
		}

		private PlayerControllerB GetClosestPlayer()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB result = null;
			float num = 0f;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!(((Component)val).transform.position.y >= ((Component)this).transform.position.y) && ((EnemyAI)this).currentBehaviourStateIndex != 2)
				{
					continue;
				}
				if (num == 0f)
				{
					num = Distance2d(((Component)val).gameObject, ((Component)this).gameObject);
					result = val;
					continue;
				}
				float num2 = Distance2d(((Component)val).gameObject, ((Component)this).gameObject);
				if (num2 < num)
				{
					num = num2;
					result = val;
				}
			}
			return result;
		}

		private bool PlayerCheck(float range)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (Distance2d(((Component)val).gameObject, ((Component)this).gameObject) < range && (((Component)val).transform.position.y >= ((Component)this).transform.position.y || ((EnemyAI)this).currentBehaviourStateIndex == 2) && _playerDistances[val.playerClientId] > 15f)
				{
					return true;
				}
			}
			return false;
		}

		private static float Distance2d(GameObject obj1, GameObject obj2)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Sqrt(Mathf.Pow(obj1.transform.position.x - obj2.transform.position.x, 2f) + Mathf.Pow(obj1.transform.position.z - obj2.transform.position.z, 2f));
		}

		private bool Collision2d(Vector3 pos, Collider col)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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)
			//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)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = col.bounds;
			return ((Bounds)(ref bounds)).Contains(new Vector3(pos.x, ((Component)water).transform.position.y, pos.z));
		}

		private void TurnTowardsLocation(Vector3 location)
		{
			//IL_0006: 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_001c: 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)
			((Component)this).transform.LookAt(new Vector3(location.x, ((Component)this).transform.position.y, location.z));
		}

		private static void TurnObjectTowardsLocation(Vector3 location, Transform objectRef)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			objectRef.LookAt(new Vector3(location.x, ((Component)objectRef).transform.position.y, location.z));
		}

		private void Rise(float speed)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.Translate(Vector3.up * speed * Time.deltaTime);
		}

		private void GoDown(float speed)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.Translate(Vector3.down * speed * Time.deltaTime);
		}

		[ClientRpc]
		public void UpdateForwardClientRpc(float hostDelta)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result typ