Decompiled source of ReinforcedBots v1.0.0

Mods/ReinforcedBots.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.Warehouse;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using ReinforcedBots;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(ReinforcedBotsMod), "Reinforced Bots", "1.0.0", "Seth", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ReinforcedBots
{
	public sealed class AtlasBot : IBot
	{
		private class Part
		{
			public Transform t;

			public Rigidbody rb;

			public ConfigurableJoint joint;

			public Collider[] colliders;

			public Vector3 startPos;

			public Quaternion startRot;

			public Vector2 x;

			public Vector2 z;

			public Vector2 y;

			public float maxTorque;

			public float strength = 1f;

			public bool touching;
		}

		public const int Observations = 227;

		public const int Actions = 30;

		private const float StandHeight = 1.9f;

		private const float DecisionEvery = 0.06f;

		private const float TargetSign = -1f;

		private const int ScanLines = 3;

		private const int ScanSteps = 12;

		private const int OwnLayer = 10;

		private const int WorldMask = -1025;

		private static readonly string[] PartNames = new string[12]
		{
			"Pelvis", "Torso", "ThighL", "ShinL", "FootL", "ThighR", "ShinR", "FootR", "UpperArmL", "ForearmL",
			"UpperArmR", "ForearmR"
		};

		private readonly Brain _brain;

		private readonly List<Part> _parts = new List<Part>();

		private readonly Transform _head;

		private readonly float[] _obs;

		private readonly float[] _act = new float[30];

		public const int MotionObservations = 232;

		private static readonly float[] ClipDuration = new float[3] { 7.9583f, 1.2917f, 0.5833f };

		private static readonly float[] ClipSpeed = new float[3] { 0f, 0.9714f, 5.746f };

		private const float PersonPelvis = 1.0514f;

		private readonly bool _motion;

		private float _phase;

		private float _legRatio = 1f;

		private float _idleFor;

		private float _walkSpeed;

		private int _clip = 1;

		private readonly HashSet<int> _own = new HashSet<int>();

		private Vector3 _target;

		private Vector3 _frameFwd = Vector3.forward;

		private Vector3 _home;

		private Quaternion _frame = Quaternion.identity;

		private float _sinceDecision = 1f;

		private float _downFor;

		private float _retargetIn;

		public float Speed;

		public bool Commanded;

		public Vector3 CommandTarget;

		public GameObject Root { get; }

		public Vector3 Position => _parts[0].rb.position;

		public bool Down => _downFor > 0.5f;

		public bool Alive
		{
			get
			{
				if ((Object)(object)Root != (Object)null && _parts.Count > 0)
				{
					return (Object)(object)_parts[0].rb != (Object)null;
				}
				return false;
			}
		}

		private Rigidbody Pelvis => _parts[0].rb;

		private Rigidbody Torso => _parts[1].rb;

		public AtlasBot(GameObject root, Brain brain, float speed, bool armsHitBody = false, bool motion = false)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			Root = root;
			_brain = brain;
			Speed = speed;
			_motion = motion;
			_walkSpeed = speed;
			_obs = new float[motion ? 232 : 227];
			_phase = Random.value;
			Il2CppArrayBase<Transform> componentsInChildren = root.GetComponentsInChildren<Transform>(true);
			string[] partNames = PartNames;
			foreach (string text in partNames)
			{
				Transform val = null;
				foreach (Transform item in componentsInChildren)
				{
					if (((Object)item).name == text)
					{
						val = item;
						break;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					throw new Exception("the Atlas prefab has no part called " + text);
				}
				Part part = new Part
				{
					t = val,
					rb = ((Component)val).GetComponent<Rigidbody>(),
					joint = ((Component)val).GetComponent<ConfigurableJoint>(),
					colliders = Il2CppArrayBase<Collider>.op_Implicit(((Component)val).GetComponents<Collider>())
				};
				Transform val2 = null;
				foreach (Transform item2 in componentsInChildren)
				{
					if (((Object)item2).name == "Pose_" + text)
					{
						val2 = item2;
						break;
					}
				}
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = val;
				}
				part.startPos = root.transform.InverseTransformPoint(val2.position);
				part.startRot = Quaternion.Inverse(root.transform.rotation) * val2.rotation;
				part.rb.solverIterations = 20;
				part.rb.solverVelocityIterations = 8;
				part.rb.maxAngularVelocity = 25f;
				Ranges(text, part);
				_parts.Add(part);
				_own.Add(((Object)part.rb).GetInstanceID());
			}
			foreach (Transform item3 in componentsInChildren)
			{
				if (((Object)item3).name == "Head")
				{
					_head = item3;
				}
			}
			if ((Object)(object)_head == (Object)null)
			{
				_head = _parts[1].t;
			}
			Il2CppArrayBase<Collider> componentsInChildren2 = root.GetComponentsInChildren<Collider>(true);
			foreach (Collider item4 in componentsInChildren2)
			{
				foreach (Collider item5 in componentsInChildren2)
				{
					if (((Object)item4).GetInstanceID() != ((Object)item5).GetInstanceID())
					{
						string text2 = (Object.op_Implicit((Object)(object)item4.attachedRigidbody) ? ((Object)item4.attachedRigidbody).name : ((Object)item4).name);
						string text3 = (Object.op_Implicit((Object)(object)item5.attachedRigidbody) ? ((Object)item5.attachedRigidbody).name : ((Object)item5).name);
						bool num = IsLeg(text2) && IsLeg(text3) && text2[text2.Length - 1] != text3[text3.Length - 1];
						bool flag = armsHitBody && (ArmHitsBody(text2, text3) || ArmHitsBody(text3, text2));
						if (!num && !flag)
						{
							Physics.IgnoreCollision(item4, item5, true);
						}
					}
				}
			}
			_home = _parts[0].rb.position;
			_target = _home + root.transform.forward * 5f;
			_legRatio = _parts[0].startPos.y / 1.0514f;
		}

		private static bool ArmHitsBody(string arm, string body)
		{
			if (!arm.StartsWith("Forearm") || (!(body == "Torso") && !(body == "Pelvis")))
			{
				if (arm.StartsWith("UpperArm"))
				{
					return body == "Pelvis";
				}
				return false;
			}
			return true;
		}

		private static bool IsLeg(string n)
		{
			if (!n.StartsWith("Thigh") && !n.StartsWith("Shin"))
			{
				return n.StartsWith("Foot");
			}
			return true;
		}

		private static void Ranges(string name, Part p)
		{
			//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_002d: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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)
			//IL_00f6: 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_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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			if (name == "Torso")
			{
				p.x = new Vector2(-15f, 45f);
				p.z = new Vector2(-15f, 15f);
				p.y = new Vector2(-25f, 25f);
				p.maxTorque = 1200f;
			}
			else if (name.StartsWith("Thigh"))
			{
				p.x = new Vector2(-100f, 30f);
				p.z = new Vector2(-25f, 25f);
				p.maxTorque = 1500f;
			}
			else if (name.StartsWith("Shin"))
			{
				p.x = new Vector2(0f, 130f);
				p.maxTorque = 1500f;
			}
			else if (name.StartsWith("Foot"))
			{
				p.x = new Vector2(-35f, 40f);
				p.z = new Vector2(-15f, 15f);
				p.maxTorque = 600f;
			}
			else if (name == "UpperArmR")
			{
				p.x = new Vector2(-150f, 60f);
				p.z = new Vector2(-10f, 90f);
				p.maxTorque = 500f;
			}
			else if (name == "UpperArmL")
			{
				p.x = new Vector2(-150f, 60f);
				p.z = new Vector2(-90f, 10f);
				p.maxTorque = 500f;
			}
			else if (name.StartsWith("Forearm"))
			{
				p.x = new Vector2(-140f, 0f);
				p.maxTorque = 350f;
			}
		}

		public void FixedTick(float dt)
		{
			//IL_0001: 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_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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = _target - Pelvis.position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude > 0.04f)
			{
				_frameFwd = ((Vector3)(ref val)).normalized;
			}
			_frame = Quaternion.LookRotation(_frameFwd, Vector3.up);
			if (_motion)
			{
				_clip = ((!(Speed < 0.2f)) ? ((Speed < 2.2f) ? 1 : 2) : 0);
				float num = 1f;
				if (_clip != 0)
				{
					float num2 = ClipSpeed[_clip] * _legRatio;
					num = ((_clip == 1) ? Mathf.Clamp(Speed / num2, 0.6f, 1.6f) : Mathf.Clamp(Speed / num2, 0.45f, 1.1f));
				}
				_phase = Mathf.Repeat(_phase + dt * num / ClipDuration[_clip], 1f);
			}
			_sinceDecision += dt;
			if (!(_sinceDecision < 0.06f))
			{
				_sinceDecision = 0f;
				Roam(0.06f);
				Observe();
				_brain.Run(_obs, _act);
				Act();
			}
		}

		private float GroundBelow(Vector3 p, float fallback)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(p + Vector3.up * 0.5f, Vector3.down, ref val, 6f, -1025, (QueryTriggerInteraction)1))
			{
				return fallback;
			}
			return ((RaycastHit)(ref val)).point.y;
		}

		private void Roam(float dt)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_005d: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = Pelvis.position;
			float num = GroundBelow(position, position.y - 1f);
			_downFor = ((position.y - num < 0.55f) ? (_downFor + dt) : 0f);
			if (_downFor > 15f)
			{
				_downFor = 0f;
				Vector3 ground = new Vector3(position.x, num, position.z);
				Quaternion rotation = Pelvis.rotation;
				Stand(ground, ((Quaternion)(ref rotation)).eulerAngles.y);
			}
			if (Commanded)
			{
				_target = CommandTarget;
				return;
			}
			if (_motion && _walkSpeed > 0f)
			{
				Vector3 val = _target - position;
				val.y = 0f;
				if (Speed > 0f && ((Vector3)(ref val)).magnitude < 1.2f)
				{
					Speed = 0f;
					_idleFor = Random.Range(3f, 8f);
					return;
				}
				if (Speed <= 0f)
				{
					_idleFor -= dt;
					if (_idleFor > 0f)
					{
						return;
					}
					Speed = _walkSpeed;
					_retargetIn = 0f;
				}
			}
			if (Speed <= 0f)
			{
				return;
			}
			_retargetIn -= dt;
			Vector3 val2 = _target - position;
			val2.y = 0f;
			if (!(((Vector3)(ref val2)).magnitude < 1.2f) && !(_retargetIn <= 0f))
			{
				return;
			}
			RaycastHit val3 = default(RaycastHit);
			for (int i = 0; i < 12; i++)
			{
				float num2 = Random.Range(0f, (float)Math.PI * 2f);
				float num3 = Random.Range(4f, 12f);
				if (Physics.Raycast(_home + new Vector3(Mathf.Cos(num2) * num3, 0f, Mathf.Sin(num2) * num3) + Vector3.up * 2f, Vector3.down, ref val3, 4f, -1025, (QueryTriggerInteraction)1) && !(Mathf.Abs(((RaycastHit)(ref val3)).point.y - num) > 0.6f))
				{
					Vector3 val4 = position + Vector3.up * 0.3f;
					Vector3 val5 = ((RaycastHit)(ref val3)).point + Vector3.up * 1f - val4;
					if (!Physics.Raycast(val4, ((Vector3)(ref val5)).normalized, ((Vector3)(ref val5)).magnitude, -1025, (QueryTriggerInteraction)1))
					{
						_target = ((RaycastHit)(ref val3)).point + Vector3.up * 0.6f;
						break;
					}
				}
			}
			_retargetIn = 40f;
		}

		public void Stand(Vector3 ground, float yaw)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_005d: 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_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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.Euler(0f, yaw, 0f);
			foreach (Part part in _parts)
			{
				part.rb.velocity = Vector3.zero;
				part.rb.angularVelocity = Vector3.zero;
				part.t.SetPositionAndRotation(ground + val * part.startPos, val * part.startRot);
				part.rb.position = part.t.position;
				part.rb.rotation = part.t.rotation;
				if ((Object)(object)part.joint != (Object)null)
				{
					part.joint.targetRotation = Quaternion.identity;
					SetStrength(part, 1f);
				}
			}
		}

		private void Observe()
		{
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00e8: 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_00f3: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0125: 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_012c: 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_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: 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_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: 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)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			int n = 0;
			Quaternion val = Quaternion.Inverse(_frame);
			Vector3 val2 = Vector3.zero;
			foreach (Part part2 in _parts)
			{
				val2 += part2.rb.velocity;
			}
			val2 /= (float)_parts.Count;
			Vector3 val3 = _frameFwd * Speed;
			Vector3 position = Pelvis.position;
			float num = GroundBelow(position, position.y - 3f);
			F(Vector3.Distance(val3, val2));
			V(val * val2);
			V(val * val3);
			Q(Quaternion.FromToRotation(((Component)Torso).transform.forward, _frameFwd));
			V(val * ((Component)Torso).transform.up);
			V(Vector3.ClampMagnitude(val * (_target - position), 30f) / 10f);
			F(Mathf.Clamp(position.y - num, 0f, 3f));
			F(Mathf.Clamp((_head.position.y - num) / 1.9f, 0f, 1.5f));
			for (int i = 0; i < _parts.Count; i++)
			{
				Part part = _parts[i];
				part.touching = Touching(part);
				F(part.touching ? 1f : 0f);
				V(val * part.rb.velocity);
				V(val * part.rb.angularVelocity);
				if (i != 0)
				{
					V(val * (part.rb.position - position));
					Q(part.rb.rotation);
					F(part.strength);
				}
			}
			Vector3 val4 = _frame * Vector3.right;
			RaycastHit val6 = default(RaycastHit);
			for (int j = -1; j <= 1; j++)
			{
				for (int k = 1; k <= 12; k++)
				{
					Vector3 val5 = position + val4 * ((float)j * 0.3f) + _frameFwd * ((float)k * 0.35f);
					val5.y = num + 1.5f;
					float num2 = (Physics.Raycast(val5, Vector3.down, ref val6, 5f, -1025, (QueryTriggerInteraction)1) ? (((RaycastHit)(ref val6)).point.y - num) : (-3.5f));
					F(Mathf.Clamp(num2, -3.5f, 1.5f));
				}
			}
			if (_motion)
			{
				F(Mathf.Sin(_phase * (float)Math.PI * 2f));
				F(Mathf.Cos(_phase * (float)Math.PI * 2f));
				F((_clip == 0) ? 1f : 0f);
				F((_clip == 1) ? 1f : 0f);
				F((_clip == 2) ? 1f : 0f);
			}
			if (n != _obs.Length)
			{
				throw new Exception("observation count is " + n + ", the brain wants " + _obs.Length);
			}
			void F(float v)
			{
				_obs[n++] = v;
			}
			void Q(Quaternion q)
			{
				//IL_0017: 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_0053: 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)
				_obs[n++] = q.x;
				_obs[n++] = q.y;
				_obs[n++] = q.z;
				_obs[n++] = q.w;
			}
			void V(Vector3 v)
			{
				//IL_0017: 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_0053: Unknown result type (might be due to invalid IL or missing references)
				_obs[n++] = v.x;
				_obs[n++] = v.y;
				_obs[n++] = v.z;
			}
		}

		private bool Touching(Part p)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			Collider[] colliders = p.colliders;
			foreach (Collider val in colliders)
			{
				if (!((Object)(object)val == (Object)null))
				{
					Bounds bounds = val.bounds;
					if (Physics.CheckBox(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).extents + new Vector3(0.02f, 0.02f, 0.02f), Quaternion.identity, -1025, (QueryTriggerInteraction)1))
					{
						return true;
					}
				}
			}
			return false;
		}

		private void Act()
		{
			//IL_002d: 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_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)
			//IL_007c: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (Part part in _parts)
			{
				if (!((Object)(object)part.joint == (Object)null))
				{
					float num2 = Pick(part.x, _act[num++]);
					float num3 = ((part.z == Vector2.zero) ? 0f : Pick(part.z, _act[num++]));
					float num4 = ((part.y == Vector2.zero) ? 0f : Pick(part.y, _act[num++]));
					part.joint.targetRotation = Quaternion.Euler(-1f * num2, -1f * num4, -1f * num3);
				}
			}
			foreach (Part part2 in _parts)
			{
				if ((Object)(object)part2.joint != (Object)null)
				{
					SetStrength(part2, (Mathf.Clamp(_act[num++], -1f, 1f) + 1f) * 0.5f);
				}
			}
		}

		private static float Pick(Vector2 range, float action)
		{
			//IL_0000: 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)
			return Mathf.Lerp(range.x, range.y, (Mathf.Clamp(action, -1f, 1f) + 1f) * 0.5f);
		}

		private static void SetStrength(Part p, float s)
		{
			//IL_000d: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			p.strength = s;
			JointDrive slerpDrive = p.joint.slerpDrive;
			((JointDrive)(ref slerpDrive)).maximumForce = s * p.maxTorque;
			p.joint.slerpDrive = slerpDrive;
		}
	}
	public sealed class Brain
	{
		private float[] _mean;

		private float[] _std;

		private float[][] _w;

		private float[][] _b;

		private int[] _rows;

		private int[] _cols;

		private float[] _a;

		private float[] _h;

		public int Inputs { get; private set; }

		public int Outputs { get; private set; }

		public static Brain Load(Stream s)
		{
			Brain brain = new Brain();
			using BinaryReader binaryReader = new BinaryReader(s);
			brain.Inputs = binaryReader.ReadInt32();
			brain._mean = ReadFloats(binaryReader, brain.Inputs);
			brain._std = ReadFloats(binaryReader, brain.Inputs);
			int num = binaryReader.ReadInt32();
			brain._w = new float[num][];
			brain._b = new float[num][];
			brain._rows = new int[num];
			brain._cols = new int[num];
			int num2 = brain.Inputs;
			for (int i = 0; i < num; i++)
			{
				brain._rows[i] = binaryReader.ReadInt32();
				brain._cols[i] = binaryReader.ReadInt32();
				brain._w[i] = ReadFloats(binaryReader, brain._rows[i] * brain._cols[i]);
				brain._b[i] = ReadFloats(binaryReader, brain._rows[i]);
				num2 = Math.Max(num2, brain._rows[i]);
			}
			brain.Outputs = brain._rows[num - 1];
			brain._a = new float[num2];
			brain._h = new float[num2];
			return brain;
		}

		private static float[] ReadFloats(BinaryReader r, int n)
		{
			byte[] array = r.ReadBytes(n * 4);
			if (array.Length != n * 4)
			{
				throw new EndOfStreamException("brain file is cut short");
			}
			float[] array2 = new float[n];
			Buffer.BlockCopy(array, 0, array2, 0, array.Length);
			return array2;
		}

		public void Run(float[] obs, float[] act)
		{
			float[] array = _a;
			float[] array2 = _h;
			for (int i = 0; i < Inputs; i++)
			{
				float num = (obs[i] - _mean[i]) / _std[i];
				array[i] = ((num < -5f) ? (-5f) : ((num > 5f) ? 5f : num));
			}
			int num2 = _w.Length;
			for (int j = 0; j < num2; j++)
			{
				float[] array3 = _w[j];
				float[] array4 = _b[j];
				int num3 = _rows[j];
				int num4 = _cols[j];
				bool flag = j == num2 - 1;
				int k = 0;
				int num5 = 0;
				for (; k < num3; k++)
				{
					float num6 = array4[k];
					int num7 = 0;
					while (num7 < num4)
					{
						num6 += array3[num5] * array[num7];
						num7++;
						num5++;
					}
					array2[k] = (flag ? num6 : (num6 / (1f + (float)Math.Exp(0f - num6))));
				}
				float[] array5 = array;
				array = array2;
				array2 = array5;
			}
			for (int l = 0; l < Outputs; l++)
			{
				float num8 = array[l];
				act[l] = ((num8 < -3f) ? (-3f) : ((num8 > 3f) ? 3f : num8)) / 3f;
			}
		}
	}
	public sealed class BullBot : IBot
	{
		private class Part
		{
			public Transform t;

			public Rigidbody rb;

			public ConfigurableJoint joint;

			public Collider[] colliders;

			public Vector3 startPos;

			public Quaternion startRot;

			public float strength = 1f;
		}

		private enum Mood
		{
			Idle,
			Wander,
			Chase,
			Search
		}

		public const int Observations = 200;

		public const int Actions = 20;

		private const float DecisionEvery = 0.06f;

		private const float MaxTorque = 300000f;

		private const int OwnLayer = 10;

		private const int WorldMask = -1025;

		private const float SightRange = 45f;

		private const float SightHalfAngle = 70f;

		private const float NoticeRange = 8f;

		private const float Memory = 6f;

		private const float WanderSpeed = 3f;

		private const float ChaseSpeed = 8f;

		private const float StopShort = 4.5f;

		private static readonly string[] PartNames = new string[9] { "Body", "UpperFL", "LowerFL", "UpperFR", "LowerFR", "UpperRL", "LowerRL", "UpperRR", "LowerRR" };

		private readonly Brain _brain;

		private readonly List<Part> _parts = new List<Part>();

		private readonly float[] _obs = new float[200];

		private readonly float[] _act = new float[20];

		private Vector3 _target;

		private Vector3 _frameFwd = Vector3.forward;

		private Vector3 _lastSeen;

		private Quaternion _frame = Quaternion.identity;

		private float _speed;

		private float _sinceDecision = 1f;

		private float _downFor;

		private float _moodFor;

		private float _sinceSeen = 999f;

		private Mood _mood;

		public GameObject Root { get; }

		public bool Alive
		{
			get
			{
				if ((Object)(object)Root != (Object)null && _parts.Count > 0)
				{
					return (Object)(object)_parts[0].rb != (Object)null;
				}
				return false;
			}
		}

		private Rigidbody Hull => _parts[0].rb;

		public BullBot(GameObject root, Brain brain)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			Root = root;
			_brain = brain;
			Il2CppArrayBase<Transform> componentsInChildren = root.GetComponentsInChildren<Transform>(true);
			string[] partNames = PartNames;
			foreach (string text in partNames)
			{
				Transform val = null;
				Transform val2 = null;
				foreach (Transform item in componentsInChildren)
				{
					if (((Object)item).name == text)
					{
						val = item;
					}
					else if (((Object)item).name == "Pose_" + text)
					{
						val2 = item;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					throw new Exception("the BullCrab prefab has no part called " + text);
				}
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = val;
				}
				Part part = new Part
				{
					t = val,
					rb = ((Component)val).GetComponent<Rigidbody>(),
					joint = ((Component)val).GetComponent<ConfigurableJoint>(),
					colliders = Il2CppArrayBase<Collider>.op_Implicit(((Component)val).GetComponents<Collider>()),
					startPos = root.transform.InverseTransformPoint(val2.position),
					startRot = Quaternion.Inverse(root.transform.rotation) * val2.rotation
				};
				part.rb.solverIterations = 24;
				part.rb.solverVelocityIterations = 8;
				part.rb.maxAngularVelocity = 20f;
				_parts.Add(part);
			}
			Il2CppArrayBase<Collider> componentsInChildren2 = root.GetComponentsInChildren<Collider>(true);
			for (int j = 0; j < componentsInChildren2.Length; j++)
			{
				for (int k = j + 1; k < componentsInChildren2.Length; k++)
				{
					Physics.IgnoreCollision(componentsInChildren2[j], componentsInChildren2[k], true);
				}
			}
			_target = Hull.position + root.transform.forward * 8f;
			_moodFor = Random.Range(2f, 5f);
		}

		public void FixedTick(float dt)
		{
			//IL_0001: 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_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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = _target - Hull.position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
			{
				_frameFwd = ((Vector3)(ref val)).normalized;
			}
			_frame = Quaternion.LookRotation(_frameFwd, Vector3.up);
			_sinceDecision += dt;
			if (!(_sinceDecision < 0.06f))
			{
				_sinceDecision = 0f;
				Think(0.06f);
				Observe();
				_brain.Run(_obs, _act);
				Act();
			}
		}

		private void Think(float dt)
		{
			//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_000c: 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_0038: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = Hull.position;
			RaycastHit val = default(RaycastHit);
			bool flag = Physics.Raycast(position, Vector3.down, ref val, 12f, -1025, (QueryTriggerInteraction)1);
			float num = (flag ? ((RaycastHit)(ref val)).point.y : (position.y - 1.7f));
			_downFor = ((flag && ((RaycastHit)(ref val)).distance < 0.7f) ? (_downFor + dt) : 0f);
			if (_downFor > 6f)
			{
				_downFor = 0f;
				Vector3 ground = new Vector3(position.x, num, position.z);
				Quaternion rotation = Hull.rotation;
				Stand(ground, ((Quaternion)(ref rotation)).eulerAngles.y);
			}
			_sinceSeen += dt;
			Transform val2 = null;
			try
			{
				val2 = Player.Head;
			}
			catch
			{
			}
			if ((Object)(object)val2 != (Object)null)
			{
				Vector3 val3 = val2.position - position;
				float magnitude = ((Vector3)(ref val3)).magnitude;
				Vector3 val4 = default(Vector3);
				((Vector3)(ref val4))..ctor(val3.x, 0f, val3.z);
				bool flag2 = magnitude < 8f;
				if (!flag2 && magnitude < 45f && Vector3.Angle(((Component)Hull).transform.forward, val4) < 70f)
				{
					Vector3 val5 = position + Vector3.up * 0.4f;
					Vector3 val6 = val2.position - val5;
					RaycastHit val7 = default(RaycastHit);
					flag2 = !Physics.Raycast(val5, ((Vector3)(ref val6)).normalized, ref val7, ((Vector3)(ref val6)).magnitude, -1025, (QueryTriggerInteraction)1) || ((RaycastHit)(ref val7)).distance > ((Vector3)(ref val6)).magnitude - 1.2f;
				}
				if (flag2)
				{
					_sinceSeen = 0f;
					_lastSeen = val2.position;
				}
			}
			if (_sinceSeen < 6f)
			{
				_mood = Mood.Chase;
				Vector3 val8 = _lastSeen - position;
				val8.y = 0f;
				_target = new Vector3(_lastSeen.x, num + 1f, _lastSeen.z);
				_speed = ((((Vector3)(ref val8)).magnitude > 4.5f) ? 8f : 0f);
				return;
			}
			if (_mood == Mood.Chase)
			{
				_mood = Mood.Search;
				_moodFor = 12f;
			}
			_moodFor -= dt;
			Vector3 val9 = _target - position;
			val9.y = 0f;
			switch (_mood)
			{
			case Mood.Search:
				_speed = 4.5f;
				if (((Vector3)(ref val9)).magnitude < 4f || _moodFor <= 0f)
				{
					_mood = Mood.Idle;
					_moodFor = Random.Range(3f, 7f);
				}
				break;
			case Mood.Idle:
				_speed = 0f;
				if (_moodFor <= 0f && PickWanderPoint(position, num))
				{
					_mood = Mood.Wander;
					_moodFor = 25f;
				}
				break;
			case Mood.Wander:
				_speed = 3f;
				if (((Vector3)(ref val9)).magnitude < 3.5f || _moodFor <= 0f)
				{
					_mood = Mood.Idle;
					_moodFor = Random.Range(4f, 10f);
				}
				break;
			case Mood.Chase:
				break;
			}
		}

		private bool PickWanderPoint(Vector3 here, float ground)
		{
			//IL_0027: 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)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			RaycastHit val4 = default(RaycastHit);
			for (int i = 0; i < 10; i++)
			{
				float num = Random.Range(0f, (float)Math.PI * 2f);
				float num2 = Random.Range(8f, 22f);
				if (Physics.Raycast(here + new Vector3(Mathf.Cos(num) * num2, 0f, Mathf.Sin(num) * num2) + Vector3.up * 4f, Vector3.down, ref val, 10f, -1025, (QueryTriggerInteraction)1) && !(Mathf.Abs(((RaycastHit)(ref val)).point.y - ground) > 1.5f))
				{
					Vector3 val2 = here + Vector3.up * 0.5f;
					Vector3 val3 = ((RaycastHit)(ref val)).point + Vector3.up * 2f - val2;
					if (!Physics.SphereCast(val2, 1.2f, ((Vector3)(ref val3)).normalized, ref val4, ((Vector3)(ref val3)).magnitude, -1025, (QueryTriggerInteraction)1))
					{
						_target = ((RaycastHit)(ref val)).point + Vector3.up;
						return true;
					}
				}
			}
			_moodFor = 2f;
			return false;
		}

		public void Stand(Vector3 ground, float yaw)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_005d: 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_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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.Euler(0f, yaw, 0f);
			foreach (Part part in _parts)
			{
				part.rb.velocity = Vector3.zero;
				part.rb.angularVelocity = Vector3.zero;
				part.t.SetPositionAndRotation(ground + val * part.startPos, val * part.startRot);
				part.rb.position = part.t.position;
				part.rb.rotation = part.t.rotation;
				if ((Object)(object)part.joint != (Object)null)
				{
					part.joint.targetRotation = Quaternion.identity;
					SetStrength(part, 1f);
				}
			}
		}

		private void Observe()
		{
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_009a: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_00e9: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_010e: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			int n = 0;
			Quaternion val = Quaternion.Inverse(_frame);
			Vector3 val2 = Vector3.zero;
			foreach (Part part2 in _parts)
			{
				val2 += part2.rb.velocity;
			}
			val2 /= (float)_parts.Count;
			Vector3 val3 = _frameFwd * _speed;
			Vector3 position = Hull.position;
			F(Vector3.Distance(val3, val2));
			V(val * val2);
			V(val * val3);
			Q(Quaternion.FromToRotation(((Component)Hull).transform.forward, _frameFwd));
			V(val * ((Component)Hull).transform.up);
			V(Vector3.ClampMagnitude(val * (_target - position), 60f) / 10f);
			RaycastHit val4 = default(RaycastHit);
			F((Physics.Raycast(position, Vector3.down, ref val4, 12f, -1025, (QueryTriggerInteraction)1) ? ((RaycastHit)(ref val4)).distance : 12f) / 12f);
			for (int i = 0; i < _parts.Count; i++)
			{
				Part part = _parts[i];
				F(Touching(part) ? 1f : 0f);
				V(val * part.rb.velocity);
				V(val * part.rb.angularVelocity);
				if (i != 0)
				{
					V(val * (part.rb.position - position));
					Q(part.rb.rotation);
					F(part.strength);
				}
			}
			Vector3 val5 = _frame * Vector3.right;
			Vector3 frameFwd = _frameFwd;
			RaycastHit val7 = default(RaycastHit);
			for (int j = 0; j < 7; j++)
			{
				for (int k = 0; k < 7; k++)
				{
					Vector3 val6 = position + val5 * ((float)(k - 3) * 1.5f) + frameFwd * ((float)(j - 2) * 1.5f) + Vector3.up * 0.5f;
					float v = ((!Physics.CheckSphere(val6, 0.05f, -1025, (QueryTriggerInteraction)1)) ? ((!Physics.Raycast(val6, Vector3.down, ref val7, 10f, -1025, (QueryTriggerInteraction)1)) ? (-1.5f) : Mathf.Clamp((((RaycastHit)(ref val7)).point.y - position.y) / 6f, -1.5f, 0.5f)) : 0.5f);
					F(v);
				}
			}
			RaycastHit val9 = default(RaycastHit);
			for (int l = 0; l < 2; l++)
			{
				for (int m = 0; m < 3; m++)
				{
					Vector3 val8 = position + val5 * ((float)(m - 1) * 2f) + frameFwd * ((float)l * 3f) + Vector3.up * 1.6f;
					float v2 = ((!Physics.CheckSphere(val8, 0.05f, -1025, (QueryTriggerInteraction)1)) ? (Physics.Raycast(val8, Vector3.up, ref val9, 5f, -1025, (QueryTriggerInteraction)1) ? (((RaycastHit)(ref val9)).distance / 5f) : 1f) : 0f);
					F(v2);
				}
			}
			if (n != 200)
			{
				throw new Exception("observation count is " + n + ", the brain wants " + 200);
			}
			void F(float num)
			{
				_obs[n++] = num;
			}
			void Q(Quaternion q)
			{
				//IL_0017: 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_0053: 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)
				_obs[n++] = q.x;
				_obs[n++] = q.y;
				_obs[n++] = q.z;
				_obs[n++] = q.w;
			}
			void V(Vector3 val10)
			{
				//IL_0017: 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_0053: Unknown result type (might be due to invalid IL or missing references)
				_obs[n++] = val10.x;
				_obs[n++] = val10.y;
				_obs[n++] = val10.z;
			}
		}

		private static bool Touching(Part p)
		{
			//IL_0034: 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_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_006e: 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)
			//IL_0072: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0106: 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_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_0134: Unknown result type (might be due to invalid IL or missing references)
			Collider[] colliders = p.colliders;
			foreach (Collider val in colliders)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				CapsuleCollider val2 = ((Il2CppObjectBase)val).TryCast<CapsuleCollider>();
				if ((Object)(object)val2 != (Object)null)
				{
					Vector3 val3 = ((Component)val).transform.up * Mathf.Max(0f, val2.height * 0.5f - val2.radius);
					Vector3 val4 = ((Component)val).transform.TransformPoint(val2.center);
					if (Physics.CheckCapsule(val4 - val3, val4 + val3, val2.radius + 0.03f, -1025, (QueryTriggerInteraction)1))
					{
						return true;
					}
					continue;
				}
				SphereCollider val5 = ((Il2CppObjectBase)val).TryCast<SphereCollider>();
				if ((Object)(object)val5 != (Object)null)
				{
					if (Physics.CheckSphere(((Component)val).transform.TransformPoint(val5.center), val5.radius + 0.03f, -1025, (QueryTriggerInteraction)1))
					{
						return true;
					}
					continue;
				}
				BoxCollider val6 = ((Il2CppObjectBase)val).TryCast<BoxCollider>();
				if ((Object)(object)val6 != (Object)null && Physics.CheckBox(((Component)val).transform.TransformPoint(val6.center), val6.size * 0.5f + new Vector3(0.03f, 0.03f, 0.03f), ((Component)val).transform.rotation, -1025, (QueryTriggerInteraction)1))
				{
					return true;
				}
			}
			return false;
		}

		private void Act()
		{
			int num = 0;
			for (int i = 0; i < 4; i++)
			{
				Part p = _parts[1 + i * 2];
				Part p2 = _parts[2 + i * 2];
				SetTarget(p, _act[num++], _act[num++]);
				SetTarget(p2, _act[num++], 0f);
				SetStrength(p, (Mathf.Clamp(_act[num++], -1f, 1f) + 1f) * 0.5f);
				SetStrength(p2, (Mathf.Clamp(_act[num++], -1f, 1f) + 1f) * 0.5f);
			}
		}

		private static void SetTarget(Part p, float x, float z)
		{
			//IL_0008: 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_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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			ConfigurableJoint joint = p.joint;
			SoftJointLimit val = joint.lowAngularXLimit;
			float limit = ((SoftJointLimit)(ref val)).limit;
			val = joint.highAngularXLimit;
			float num = Mathf.Lerp(limit, ((SoftJointLimit)(ref val)).limit, (Mathf.Clamp(x, -1f, 1f) + 1f) * 0.5f);
			val = joint.angularZLimit;
			float num2 = ((SoftJointLimit)(ref val)).limit * Mathf.Clamp(z, -1f, 1f);
			joint.targetRotation = Quaternion.Euler(num, 0f, num2);
		}

		private static void SetStrength(Part p, float s)
		{
			//IL_000d: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			p.strength = s;
			JointDrive slerpDrive = p.joint.slerpDrive;
			((JointDrive)(ref slerpDrive)).maximumForce = Mathf.Max(0.02f, s) * 300000f;
			p.joint.slerpDrive = slerpDrive;
		}
	}
	public interface IBot
	{
		GameObject Root { get; }

		bool Alive { get; }

		void FixedTick(float dt);

		void Stand(Vector3 ground, float yaw);
	}
	public sealed class DroneBot : IBot
	{
		private class Part
		{
			public Transform t;

			public Rigidbody rb;

			public ConfigurableJoint joint;

			public Vector3 startPos;

			public Quaternion startRot;

			public Quaternion restRel;

			public float power = 1f;

			public float wanted = 1f;
		}

		public const int Observations = 50;

		public const int Actions = 12;

		private const float DecisionEvery = 0.04f;

		private const int OwnLayer = 10;

		private const int WorldMask = -1025;

		private const float BodyMass = 500f;

		private const float ThrusterMass = 40f;

		private const float TotalMass = 660f;

		private const float HoverThrust = 1618.65f;

		private const float SwivelX = 60f;

		private const float SwivelZ = 25f;

		private const float SpinUp = 0.15f;

		private const float RoamRadius = 28f;

		private static readonly string[] PartNames = new string[5] { "Body", "ThrusterFL", "ThrusterFR", "ThrusterRL", "ThrusterRR" };

		private readonly Brain _brain;

		private readonly List<Part> _parts = new List<Part>();

		private readonly float[] _obs = new float[50];

		private readonly float[] _act = new float[12];

		private Vector3 _target;

		private Vector3 _home;

		private Vector3 _frameFwd = Vector3.forward;

		private Quaternion _frame = Quaternion.identity;

		private float _speed = 5f;

		private float _sinceDecision = 1f;

		private float _holdFor;

		private float _legFor;

		private bool _holding;

		public GameObject Root { get; }

		public bool Alive
		{
			get
			{
				if ((Object)(object)Root != (Object)null && _parts.Count > 0)
				{
					return (Object)(object)_parts[0].rb != (Object)null;
				}
				return false;
			}
		}

		private Rigidbody Body => _parts[0].rb;

		public DroneBot(GameObject root, Brain brain)
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			Root = root;
			_brain = brain;
			Il2CppArrayBase<Transform> componentsInChildren = root.GetComponentsInChildren<Transform>(true);
			string[] partNames = PartNames;
			foreach (string text in partNames)
			{
				Transform val = null;
				Transform val2 = null;
				foreach (Transform item in componentsInChildren)
				{
					if (((Object)item).name == text)
					{
						val = item;
					}
					else if (((Object)item).name == "Pose_" + text)
					{
						val2 = item;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					throw new Exception("the Heavy Drone prefab has no part called " + text);
				}
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = val;
				}
				Part part = new Part
				{
					t = val,
					rb = ((Component)val).GetComponent<Rigidbody>(),
					joint = ((Component)val).GetComponent<ConfigurableJoint>(),
					startPos = root.transform.InverseTransformPoint(val2.position),
					startRot = Quaternion.Inverse(root.transform.rotation) * val2.rotation
				};
				part.rb.solverIterations = 16;
				part.rb.solverVelocityIterations = 6;
				part.rb.maxAngularVelocity = 20f;
				part.rb.useGravity = true;
				_parts.Add(part);
			}
			for (int j = 1; j < _parts.Count; j++)
			{
				_parts[j].restRel = Quaternion.Inverse(_parts[0].startRot) * _parts[j].startRot;
			}
			Body.centerOfMass = Vector3.zero;
			Body.inertiaTensor = new Vector3(900f, 1400f, 900f);
			Body.inertiaTensorRotation = Quaternion.identity;
			Il2CppArrayBase<Collider> componentsInChildren2 = root.GetComponentsInChildren<Collider>(true);
			for (int k = 0; k < componentsInChildren2.Length; k++)
			{
				for (int l = k + 1; l < componentsInChildren2.Length; l++)
				{
					Physics.IgnoreCollision(componentsInChildren2[k], componentsInChildren2[l], true);
				}
			}
			Vector3 position = root.transform.position;
			Quaternion rotation = root.transform.rotation;
			Stand(position, ((Quaternion)(ref rotation)).eulerAngles.y);
		}

		public void FixedTick(float dt)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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)
			//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_008c: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			float num = 1f - Mathf.Exp((0f - dt) / 0.15f);
			for (int i = 1; i < _parts.Count; i++)
			{
				Part part = _parts[i];
				part.power = Mathf.Lerp(part.power, part.wanted, num);
				part.rb.AddForce(part.t.up * (part.power * 1618.65f));
			}
			Vector3 val = _target - Body.position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude > 9f)
			{
				_frameFwd = ((Vector3)(ref val)).normalized;
			}
			_frame = Quaternion.LookRotation(_frameFwd, Vector3.up);
			_sinceDecision += dt;
			if (!(_sinceDecision < 0.04f))
			{
				_sinceDecision = 0f;
				Think(0.04f);
				Observe();
				_brain.Run(_obs, _act);
				Act();
			}
		}

		private void Think(float dt)
		{
			//IL_0001: 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)
			float num = Vector3.Distance(_target, Body.position);
			_legFor -= dt;
			if (!_holding && (num < 2f || _legFor <= 0f))
			{
				_holding = true;
				_holdFor = Random.Range(1f, 7f);
			}
			if (_holding)
			{
				_holdFor -= dt;
				if (_holdFor <= 0f)
				{
					NextPoint();
				}
			}
		}

		private void NextPoint()
		{
			//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_0013: 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_0022: 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_0029: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00ac: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = Body.position;
			RaycastHit val3 = default(RaycastHit);
			RaycastHit val5 = default(RaycastHit);
			for (int i = 0; i < 16; i++)
			{
				Vector2 val = Random.insideUnitCircle * 28f;
				Vector3 val2 = _home + new Vector3(val.x, 0f, val.y);
				if (!Physics.Raycast(val2 + Vector3.up * 40f, Vector3.down, ref val3, 80f, -1025, (QueryTriggerInteraction)1))
				{
					continue;
				}
				val2 = ((RaycastHit)(ref val3)).point + Vector3.up * Random.Range(6f, 20f);
				if (!Physics.CheckSphere(val2, 4f, -1025, (QueryTriggerInteraction)1))
				{
					Vector3 val4 = val2 - position;
					if (!(((Vector3)(ref val4)).magnitude < 8f) && !Physics.SphereCast(position, 2.2f, ((Vector3)(ref val4)).normalized, ref val5, ((Vector3)(ref val4)).magnitude, -1025, (QueryTriggerInteraction)1))
					{
						_target = val2;
						break;
					}
				}
			}
			_speed = Random.Range(3f, 8f);
			_holding = false;
			_legFor = 30f;
		}

		public void Stand(Vector3 ground, float yaw)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0066: 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_0069: 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_007a: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.Euler(0f, yaw, 0f);
			Vector3 val2 = ground + Vector3.up * 4f;
			foreach (Part part in _parts)
			{
				part.rb.velocity = Vector3.zero;
				part.rb.angularVelocity = Vector3.zero;
				part.t.SetPositionAndRotation(val2 + val * part.startPos, val * part.startRot);
				part.rb.position = part.t.position;
				part.rb.rotation = part.t.rotation;
				if ((Object)(object)part.joint != (Object)null)
				{
					part.joint.targetRotation = Quaternion.identity;
				}
				part.power = (part.wanted = 1f);
			}
			_home = Body.position;
			_target = Body.position;
			_holding = true;
			_holdFor = 3f;
		}

		private static float Ray(Vector3 from, Vector3 dir, float range)
		{
			//IL_0000: 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)
			RaycastHit val = default(RaycastHit);
			if (!Physics.SphereCast(from, 0.4f, dir, ref val, range, -1025, (QueryTriggerInteraction)1))
			{
				return 1f;
			}
			return ((RaycastHit)(ref val)).distance / range;
		}

		private Vector3 GoalVelocity()
		{
			//IL_0001: 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_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_008c: 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_0074: 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_0064: 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_0047: 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)
			Vector3 val = _target - Body.position;
			float magnitude = ((Vector3)(ref val)).magnitude;
			float num = (_holding ? 0f : _speed);
			if (_holding)
			{
				if (!(magnitude < 0.01f))
				{
					return val / magnitude * Mathf.Min(_speed, magnitude * 0.9f);
				}
				return Vector3.zero;
			}
			if (!(magnitude < 0.01f))
			{
				return val / magnitude * Mathf.Min(num, magnitude * 0.9f);
			}
			return Vector3.zero;
		}

		private void Observe()
		{
			//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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_0115: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: 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_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			int n = 0;
			Quaternion val = Quaternion.Inverse(_frame);
			Rigidbody body = Body;
			Vector3 position = body.position;
			Vector3 val2 = body.velocity * 500f;
			for (int i = 1; i < _parts.Count; i++)
			{
				val2 += _parts[i].rb.velocity * 40f;
			}
			V(val * GoalVelocity() / 5f);
			V(val * (val2 / 660f) / 5f);
			V(val * ((Component)body).transform.up);
			Q(Quaternion.FromToRotation(((Component)body).transform.forward, _frameFwd));
			V(val * body.angularVelocity);
			V(Vector3.ClampMagnitude(val * (_target - position), 60f) / 10f);
			F(Ray(position, Vector3.down, 30f));
			Quaternion val3 = Quaternion.Inverse(body.rotation);
			for (int j = 1; j < _parts.Count; j++)
			{
				Part part = _parts[j];
				Q(val3 * part.rb.rotation * Quaternion.Inverse(part.restRel));
				F(part.power - 1f);
			}
			for (int k = 0; k < 8; k++)
			{
				F(Ray(position, _frame * Quaternion.Euler(0f, (float)k * 45f, 0f) * Vector3.forward, 20f));
			}
			F(Ray(position, Vector3.up, 20f));
			Vector3 val4 = _frameFwd + Vector3.down;
			F(Ray(position, ((Vector3)(ref val4)).normalized, 20f));
			if (n != 50)
			{
				throw new Exception("observation count is " + n + ", the brain wants " + 50);
			}
			void F(float v)
			{
				_obs[n++] = v;
			}
			void Q(Quaternion q)
			{
				//IL_0017: 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_0053: 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)
				_obs[n++] = q.x;
				_obs[n++] = q.y;
				_obs[n++] = q.z;
				_obs[n++] = q.w;
			}
			void V(Vector3 v)
			{
				//IL_0017: 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_0053: Unknown result type (might be due to invalid IL or missing references)
				_obs[n++] = v.x;
				_obs[n++] = v.y;
				_obs[n++] = v.z;
			}
		}

		private void Act()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			for (int i = 1; i < _parts.Count; i++)
			{
				Part part = _parts[i];
				float num2 = 60f * Mathf.Clamp(_act[num++], -1f, 1f);
				float num3 = 25f * Mathf.Clamp(_act[num++], -1f, 1f);
				part.joint.targetRotation = Quaternion.Euler(num2, 0f, num3);
				part.wanted = 1f + Mathf.Clamp(_act[num++], -1f, 1f);
			}
		}
	}
	public sealed class IzhBot : IBot
	{
		private class Part
		{
			public Transform t;

			public Rigidbody rb;

			public ConfigurableJoint joint;

			public Collider[] colliders;

			public Vector3 startPos;

			public Quaternion startRot;

			public float strength = 1f;

			public float maxTorque;
		}

		public const int Observations = 200;

		public const int Actions = 20;

		private const float DecisionEvery = 0.06f;

		private const float UpperTorque = 3200f;

		private const float LowerTorque = 4200f;

		private const int OwnLayer = 10;

		private const int WorldMask = -1025;

		private static readonly string[] PartNames = new string[9] { "Body", "UpperFL", "LowerFL", "UpperFR", "LowerFR", "UpperRL", "LowerRL", "UpperRR", "LowerRR" };

		private readonly Brain _brain;

		private readonly List<Part> _parts = new List<Part>();

		private readonly float[] _obs = new float[200];

		private readonly float[] _act = new float[20];

		private Vector3 _target;

		private Vector3 _home;

		private Vector3 _frameFwd = Vector3.forward;

		private Quaternion _frame = Quaternion.identity;

		private float _speed;

		private float _sinceDecision = 1f;

		private float _downFor;

		private float _moodFor;

		private bool _walking;

		public GameObject Root { get; }

		public bool Alive
		{
			get
			{
				if ((Object)(object)Root != (Object)null && _parts.Count > 0)
				{
					return (Object)(object)_parts[0].rb != (Object)null;
				}
				return false;
			}
		}

		private Rigidbody Body => _parts[0].rb;

		public IzhBot(GameObject root, Brain brain)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			Root = root;
			_brain = brain;
			Il2CppArrayBase<Transform> componentsInChildren = root.GetComponentsInChildren<Transform>(true);
			string[] partNames = PartNames;
			foreach (string text in partNames)
			{
				Transform val = null;
				Transform val2 = null;
				foreach (Transform item in componentsInChildren)
				{
					if (((Object)item).name == text)
					{
						val = item;
					}
					else if (((Object)item).name == "Pose_" + text)
					{
						val2 = item;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					throw new Exception("the Izhevsk prefab has no part called " + text);
				}
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = val;
				}
				Part part = new Part
				{
					t = val,
					rb = ((Component)val).GetComponent<Rigidbody>(),
					joint = ((Component)val).GetComponent<ConfigurableJoint>(),
					colliders = Il2CppArrayBase<Collider>.op_Implicit(((Component)val).GetComponents<Collider>()),
					startPos = root.transform.InverseTransformPoint(val2.position),
					startRot = Quaternion.Inverse(root.transform.rotation) * val2.rotation,
					maxTorque = (text.StartsWith("Upper") ? 3200f : 4200f)
				};
				part.rb.solverIterations = 20;
				part.rb.solverVelocityIterations = 8;
				part.rb.maxAngularVelocity = 20f;
				_parts.Add(part);
			}
			Il2CppArrayBase<Collider> componentsInChildren2 = root.GetComponentsInChildren<Collider>(true);
			for (int j = 0; j < componentsInChildren2.Length; j++)
			{
				for (int k = j + 1; k < componentsInChildren2.Length; k++)
				{
					Physics.IgnoreCollision(componentsInChildren2[j], componentsInChildren2[k], true);
				}
			}
			BoxCollider component = ((Component)Body).GetComponent<BoxCollider>();
			if ((Object)(object)component != (Object)null)
			{
				Body.centerOfMass = component.center;
			}
			_home = Body.position;
			_target = Body.position + root.transform.forward * 6f;
			_moodFor = Random.Range(2f, 5f);
		}

		public void FixedTick(float dt)
		{
			//IL_0001: 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_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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = _target - Body.position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
			{
				_frameFwd = ((Vector3)(ref val)).normalized;
			}
			_frame = Quaternion.LookRotation(_frameFwd, Vector3.up);
			_sinceDecision += dt;
			if (!(_sinceDecision < 0.06f))
			{
				_sinceDecision = 0f;
				Think(0.06f);
				Observe();
				_brain.Run(_obs, _act);
				Act();
			}
		}

		private void Think(float dt)
		{
			//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_000c: 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_0038: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Un