Decompiled source of WSADMounts v1.0.2

WSADMounts/WSADMounts.dll

Decompiled 20 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using KydlCore.Common;
using KydlCore.Core;
using KydlCore.Features.Diagnostics.Contracts;
using KydlCore.Features.Hub.Contracts;
using KydlCore.ServerSync;
using KydlCore.Ui;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Playables;
using UnityEngine.Rendering;
using UnityEngine.UIElements;
using WSADMounts.Bootstrap;
using WSADMounts.Configuration;
using WSADMounts.Core;
using WSADMounts.Features.Riding.Domain;
using WSADMounts.Features.Riding.Infrastructure;
using WSADMounts.Integrations.Valheim;
using WSADMounts.Presentation.Hub.Registration;
using WSADMounts.Testing.TestHooks;
using WSADMounts.Ui;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
[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 WSADMounts.Ui
{
	internal sealed class DetailGroup
	{
		internal readonly string Title;

		internal readonly List<DetailRow> Rows = new List<DetailRow>();

		internal DetailGroup(string title)
		{
			Title = title ?? "";
		}

		internal DetailRow Add(string label, string value, string maxValue = "")
		{
			DetailRow detailRow = new DetailRow(label, value, maxValue);
			Rows.Add(detailRow);
			return detailRow;
		}

		public override string ToString()
		{
			return Title + " (" + Rows.Count + " rows)";
		}
	}
	internal sealed class DetailRow
	{
		internal readonly string Label;

		internal readonly string Value;

		internal readonly string MaxValue;

		internal bool HasMax => MaxValue.Length > 0;

		internal DetailRow(string label, string value, string maxValue = "")
		{
			Label = label ?? "";
			Value = value ?? "";
			MaxValue = maxValue ?? "";
		}

		public override string ToString()
		{
			return Label + " = " + Value + (HasMax ? (" -> " + MaxValue) : "");
		}
	}
	internal static class DetailsView
	{
		private const float LabelWidth = 210f;

		private const float ValueWidth = 140f;

		internal static VisualElement Build(IList<DetailGroup> groups, string qualityHeader, string maxQualityHeader)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = new VisualElement
			{
				name = "kydl-details"
			};
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			int num = 0;
			if (groups != null)
			{
				foreach (DetailGroup group in groups)
				{
					val.Add(UiControls.Heading(group.Title));
					bool flag = false;
					foreach (DetailRow row in group.Rows)
					{
						if (row.HasMax)
						{
							flag = true;
							break;
						}
					}
					if (flag)
					{
						val.Add(ColumnHeader(qualityHeader, maxQualityHeader));
					}
					foreach (DetailRow row2 in group.Rows)
					{
						val.Add(StatRow(row2, flag));
						num++;
					}
				}
			}
			UiLog.Verbose("DetailsView: " + (groups?.Count ?? 0) + " group(s), " + num + " row(s)");
			return val;
		}

		private static VisualElement ColumnHeader(string q, string max)
		{
			VisualElement obj = RowBox();
			obj.Add((VisualElement)(object)Cell("", 210f, (TextRole)5));
			obj.Add((VisualElement)(object)Cell(q ?? "", 140f, (TextRole)5));
			obj.Add((VisualElement)(object)Cell(max ?? "", 140f, (TextRole)5));
			return obj;
		}

		private static VisualElement StatRow(DetailRow row, bool blockHasMax)
		{
			VisualElement val = RowBox();
			val.Add((VisualElement)(object)Cell(row.Label, 210f, (TextRole)3));
			val.Add((VisualElement)(object)Cell(row.Value, (blockHasMax && row.HasMax) ? 140f : (-1f), (TextRole)0));
			if (blockHasMax && row.HasMax)
			{
				val.Add((VisualElement)(object)Cell(row.MaxValue, 140f, (TextRole)2));
			}
			return val;
		}

		private static VisualElement RowBox()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			VisualElement val = new VisualElement();
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)1);
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.style.marginTop = StyleLength.op_Implicit(2f);
			val.style.marginBottom = StyleLength.op_Implicit(2f);
			return val;
		}

		private static Label Cell(string content, float width, TextRole role)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0028: 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)
			Label val = UiKit.TextLabel(content, role);
			((VisualElement)val).style.whiteSpace = StyleEnum<WhiteSpace>.op_Implicit((WhiteSpace)0);
			if (width >= 0f)
			{
				((VisualElement)val).style.width = StyleLength.op_Implicit(width);
				((VisualElement)val).style.flexShrink = StyleFloat.op_Implicit(0f);
			}
			else
			{
				((VisualElement)val).style.flexGrow = StyleFloat.op_Implicit(1f);
				((VisualElement)val).style.flexShrink = StyleFloat.op_Implicit(1f);
			}
			return val;
		}
	}
	internal interface IModelScene : IDisposable
	{
		Texture Texture { get; }

		bool Show(string modelId);

		bool Resize(int widthPx, int heightPx);

		bool Render(float yawDeg, float pitchDeg, float zoom, float panX, float panY, float panZ);
	}
	internal sealed class ModelViewerRig : IModelScene, IDisposable
	{
		internal static readonly Vector3 Park = new Vector3(0f, -1500f, 0f);

		internal const float FieldOfView = 30f;

		private const float LogEverySeconds = 0.5f;

		private readonly Func<string, GameObject> _makeModel;

		private readonly ViewerSettings _settings;

		private readonly Action<string> _log;

		private readonly int _layer;

		private readonly string _rigName;

		private GameObject _root;

		private GameObject _pivot;

		private GameObject _model;

		private Camera _camera;

		private readonly List<Light> _lights = new List<Light>();

		private RenderTexture _texture;

		private string _modelId;

		private float _halfWidth;

		private float _halfHeight;

		private float _radius;

		private float _lastLog = -100f;

		private float _lastLightLog = -100f;

		private int _renders;

		public Texture Texture => (Texture)(object)_texture;

		internal unsafe ModelViewerRig(Func<string, GameObject> makeModel, int layer, ViewerSettings settings, Color background, Action<string> log, string rigName = "Kydl_ViewerRig")
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00b9: 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_00d3: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			_makeModel = makeModel;
			_settings = settings ?? new ViewerSettings();
			_log = log;
			_layer = Mathf.Clamp(layer, 0, 31);
			_rigName = (string.IsNullOrEmpty(rigName) ? "Kydl_ViewerRig" : rigName);
			if (_layer != layer)
			{
				Log("ModelViewerRig: layer " + layer + " is outside 0..31, using " + _layer);
			}
			_root = new GameObject(_rigName);
			_root.transform.position = Park;
			_pivot = new GameObject("Pivot");
			_pivot.transform.SetParent(_root.transform, false);
			GameObject val = new GameObject("Camera");
			val.transform.SetParent(_root.transform, false);
			_camera = val.AddComponent<Camera>();
			((Behaviour)_camera).enabled = false;
			_camera.cullingMask = 1 << _layer;
			_camera.clearFlags = (CameraClearFlags)2;
			_camera.backgroundColor = background;
			_camera.fieldOfView = 30f;
			_camera.nearClipPlane = 0.02f;
			_camera.farClipPlane = 200f;
			_camera.allowHDR = false;
			_camera.useOcclusionCulling = false;
			_camera.renderingPath = (RenderingPath)1;
			AddLight(val.transform, "KeyLight", new Vector3(25f, 30f, 0f), _settings.KeyLight);
			AddLight(val.transform, "FillLight", new Vector3(-10f, -45f, 0f), _settings.FillLight);
			string[] obj = new string[10]
			{
				"ModelViewerRig: made at ",
				V(Park),
				", layer ",
				_layer.ToString(),
				", fov ",
				30f.ToString(),
				" deg, background ",
				null,
				null,
				null
			};
			Color val2 = background;
			obj[7] = ((object)(*(Color*)(&val2))/*cast due to .constrained prefix*/).ToString();
			obj[8] = ", ";
			obj[9] = _settings?.ToString();
			Log(string.Concat(obj));
		}

		private void AddLight(Transform parent, string name, Vector3 euler, float intensity)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localRotation = Quaternion.Euler(euler);
			Light val2 = val.AddComponent<Light>();
			val2.type = (LightType)1;
			val2.intensity = intensity;
			val2.color = new Color(1f, 0.96f, 0.9f);
			val2.shadows = (LightShadows)0;
			val2.cullingMask = 1 << _layer;
			val2.renderMode = (LightRenderMode)1;
			((Behaviour)val2).enabled = false;
			_lights.Add(val2);
		}

		public bool Show(string modelId)
		{
			//IL_011d: 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_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: 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_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: 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)
			//IL_0256: 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_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_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: 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_02af: 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_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: 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_021d: 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)
			if ((Object)(object)_root == (Object)null)
			{
				Log("ModelViewerRig: Show(" + modelId + ") after Dispose - ignored");
				return false;
			}
			if ((Object)(object)_model != (Object)null)
			{
				_model.SetActive(false);
				Object.Destroy((Object)(object)_model);
				_model = null;
			}
			_modelId = modelId;
			if (string.IsNullOrEmpty(modelId))
			{
				Log("ModelViewerRig: no model to show");
				return false;
			}
			GameObject val = null;
			Log("ModelViewerRig: making the model '" + modelId + "'");
			try
			{
				val = ((_makeModel != null) ? _makeModel(modelId) : null);
			}
			catch (Exception ex)
			{
				Log("ModelViewerRig: making the model '" + modelId + "' failed: " + ex.GetType().Name + ": " + ex.Message);
			}
			if ((Object)(object)val == (Object)null)
			{
				Log("ModelViewerRig: no model for '" + modelId + "' (model maker gave null)");
				return false;
			}
			_model = val;
			_pivot.transform.localRotation = Quaternion.identity;
			_model.transform.SetParent(_pivot.transform, false);
			_model.transform.localPosition = Vector3.zero;
			_model.transform.localRotation = Quaternion.identity;
			int num = Prepare(_model);
			if (num == 0)
			{
				Log("ModelViewerRig: model '" + modelId + "' has no renderers - nothing to see");
				return false;
			}
			Bounds val2 = WorldBounds(_model);
			Vector3 size = ((Bounds)(ref val2)).size;
			Quaternion localRotation = Quaternion.identity;
			string text = "X";
			if (size.y >= size.x && size.y >= size.z)
			{
				localRotation = Quaternion.Euler(0f, 0f, -90f);
				text = "Y";
			}
			else if (size.z >= size.x && size.z >= size.y)
			{
				localRotation = Quaternion.Euler(0f, 90f, 0f);
				text = "Z";
			}
			_model.transform.localRotation = localRotation;
			Bounds val3 = WorldBounds(_model);
			Transform transform = _model.transform;
			transform.position -= ((Bounds)(ref val3)).center - _pivot.transform.position;
			Bounds val4 = WorldBounds(_model);
			_halfWidth = ((Bounds)(ref val4)).extents.x;
			_halfHeight = Mathf.Max(((Bounds)(ref val4)).extents.y, ((Bounds)(ref val4)).extents.z);
			Vector3 extents = ((Bounds)(ref val4)).extents;
			_radius = ((Vector3)(ref extents)).magnitude;
			Log("ModelViewerRig: showing '" + modelId + "': " + num + " renderer(s), size " + V(((Bounds)(ref val2)).size) + " m, longest axis " + text + " laid across, centre offset " + V(((Bounds)(ref val4)).center - _pivot.transform.position) + " m, half width " + F(_halfWidth) + " / height " + F(_halfHeight) + " / radius " + F(_radius) + " m");
			return true;
		}

		private int Prepare(GameObject model)
		{
			int num = 0;
			int num2 = 0;
			Transform[] componentsInChildren = model.GetComponentsInChildren<Transform>(true);
			int i;
			for (i = 0; i < componentsInChildren.Length; i++)
			{
				((Component)componentsInChildren[i]).gameObject.layer = _layer;
			}
			Renderer[] componentsInChildren2 = model.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer obj in componentsInChildren2)
			{
				obj.shadowCastingMode = (ShadowCastingMode)0;
				obj.receiveShadows = false;
				SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((obj is SkinnedMeshRenderer) ? obj : null);
				if ((Object)(object)val != (Object)null)
				{
					val.updateWhenOffscreen = true;
				}
				num++;
			}
			Collider[] componentsInChildren3 = model.GetComponentsInChildren<Collider>(true);
			for (i = 0; i < componentsInChildren3.Length; i++)
			{
				componentsInChildren3[i].enabled = false;
				num2++;
			}
			string[] obj2 = new string[9]
			{
				"ModelViewerRig: prepared model '",
				((Object)model).name,
				"': ",
				num.ToString(),
				" renderer(s) on layer ",
				null,
				null,
				null,
				null
			};
			i = _layer;
			obj2[5] = i.ToString();
			obj2[6] = ", ";
			obj2[7] = num2.ToString();
			obj2[8] = " collider(s) off";
			Log(string.Concat(obj2));
			return num;
		}

		private static Bounds WorldBounds(GameObject go)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
			if (componentsInChildren.Length == 0)
			{
				return new Bounds(go.transform.position, Vector3.zero);
			}
			Bounds bounds = componentsInChildren[0].bounds;
			for (int i = 1; i < componentsInChildren.Length; i++)
			{
				((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds);
			}
			return bounds;
		}

		public bool Resize(int widthPx, int heightPx)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			if ((Object)(object)_root == (Object)null)
			{
				Log("ModelViewerRig: Resize after Dispose - ignored");
				return false;
			}
			int num = Mathf.Clamp(widthPx, 16, 4096);
			int num2 = Mathf.Clamp(heightPx, 16, 4096);
			if ((Object)(object)_texture != (Object)null && ((Texture)_texture).width == num && ((Texture)_texture).height == num2)
			{
				return true;
			}
			if ((Object)(object)_texture != (Object)null)
			{
				_camera.targetTexture = null;
				_texture.Release();
				Object.Destroy((Object)(object)_texture);
			}
			_texture = new RenderTexture(num, num2, 24, (RenderTextureFormat)0)
			{
				name = _rigName + "_Texture",
				antiAliasing = 4
			};
			_texture.Create();
			_camera.targetTexture = _texture;
			Log("ModelViewerRig: texture " + num + "x" + num2 + " px (asked " + widthPx + "x" + heightPx + ")");
			return true;
		}

		public bool Render(float yawDeg, float pitchDeg, float zoom, float panX, float panY, float panZ)
		{
			//IL_00b7: 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_00dd: 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_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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_root == (Object)null || (Object)(object)_texture == (Object)null)
			{
				Log("ModelViewerRig: Render skipped (" + (((Object)(object)_root == (Object)null) ? "disposed" : "no texture yet") + ")");
				return false;
			}
			float num = (float)((Texture)_texture).width / (float)((Texture)_texture).height;
			float num2 = ViewerMath.FitDistance(_halfWidth, _halfHeight, _radius, 30f, num, _settings.Margin);
			float num3 = num2 / Mathf.Max(0.01f, zoom);
			float num4 = 2f * num2 * Mathf.Tan((float)Math.PI / 12f);
			Vector3 val = new Vector3(panX, panY, panZ) * num4;
			ViewerMath.Orbit(yawDeg, pitchDeg, num3, out var x, out var y, out var z);
			Vector3 val2 = _pivot.transform.position + val;
			((Component)_camera).transform.position = val2 + new Vector3(x, y, z);
			((Component)_camera).transform.LookAt(val2, Vector3.up);
			_camera.nearClipPlane = Mathf.Clamp(num3 - ((Vector3)(ref val)).magnitude - _radius * 1.2f, 0.01f, 0.5f);
			RenderLit();
			_renders++;
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (realtimeSinceStartup - _lastLog >= 0.5f)
			{
				_lastLog = realtimeSinceStartup;
				Log("ModelViewerRig: render #" + _renders + " of " + (_modelId ?? "nothing") + ": yaw " + F(yawDeg) + " / pitch " + F(pitchDeg) + " deg, zoom x" + F(zoom) + ", fit " + F(num2) + " m, distance " + F(num3) + " m, aspect " + F(num) + ", pan " + V(val) + " m (" + V(new Vector3(panX, panY, panZ)) + " view heights of " + F(num4) + " m), near " + F(_camera.nearClipPlane) + " m, model " + (((Object)(object)_model != (Object)null) ? "shown" : "none"));
			}
			return true;
		}

		private unsafe void RenderLit()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			AmbientMode ambientMode = RenderSettings.ambientMode;
			Color ambientLight = RenderSettings.ambientLight;
			float ambientIntensity = RenderSettings.ambientIntensity;
			bool fog = RenderSettings.fog;
			try
			{
				if (_lights.Count > 0 && (Object)(object)_lights[0] != (Object)null)
				{
					_lights[0].intensity = _settings.KeyLight;
				}
				if (_lights.Count > 1 && (Object)(object)_lights[1] != (Object)null)
				{
					_lights[1].intensity = _settings.FillLight;
				}
				for (int i = 0; i < _lights.Count; i++)
				{
					if ((Object)(object)_lights[i] != (Object)null)
					{
						((Behaviour)_lights[i]).enabled = true;
					}
				}
				RenderSettings.ambientMode = (AmbientMode)3;
				RenderSettings.ambientLight = new Color(_settings.Ambient, _settings.Ambient * 0.95f, _settings.Ambient * 0.9f);
				RenderSettings.ambientIntensity = 1f;
				RenderSettings.fog = false;
				_camera.Render();
			}
			finally
			{
				int num = 0;
				for (int j = 0; j < _lights.Count; j++)
				{
					if ((Object)(object)_lights[j] != (Object)null)
					{
						((Behaviour)_lights[j]).enabled = false;
						if (((Behaviour)_lights[j]).enabled)
						{
							num++;
						}
					}
				}
				float realtimeSinceStartup = Time.realtimeSinceStartup;
				if (realtimeSinceStartup - _lastLightLog >= 2f)
				{
					_lastLightLog = realtimeSinceStartup;
					string[] obj = new string[12]
					{
						"ModelViewerRig: lights ",
						_lights.Count.ToString(),
						" switched on for this render only, ",
						num.ToString(),
						" still on after it (expect 0); ambient put back to ",
						((object)(*(AmbientMode*)(&ambientMode))/*cast due to .constrained prefix*/).ToString(),
						" / ",
						null,
						null,
						null,
						null,
						null
					};
					Color val = ambientLight;
					obj[7] = ((object)(*(Color*)(&val))/*cast due to .constrained prefix*/).ToString();
					obj[8] = " x";
					obj[9] = ambientIntensity.ToString();
					obj[10] = ", fog ";
					obj[11] = fog.ToString();
					Log(string.Concat(obj));
				}
				RenderSettings.ambientMode = ambientMode;
				RenderSettings.ambientLight = ambientLight;
				RenderSettings.ambientIntensity = ambientIntensity;
				RenderSettings.fog = fog;
			}
		}

		public void Dispose()
		{
			if (!((Object)(object)_root == (Object)null))
			{
				if ((Object)(object)_camera != (Object)null)
				{
					_camera.targetTexture = null;
				}
				if ((Object)(object)_texture != (Object)null)
				{
					_texture.Release();
					Object.Destroy((Object)(object)_texture);
					_texture = null;
				}
				Object.Destroy((Object)(object)_root);
				_root = null;
				_model = null;
				_camera = null;
				Log("ModelViewerRig: disposed after " + _renders + " render(s)");
			}
		}

		private static string F(float v)
		{
			return v.ToString("0.###", CultureInfo.InvariantCulture);
		}

		private static string V(Vector3 v)
		{
			//IL_0010: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			return "(" + F(v.x) + ", " + F(v.y) + ", " + F(v.z) + ")";
		}

		private void Log(string s)
		{
			if (_log != null)
			{
				_log(s);
			}
		}
	}
	internal static class ModelViewportView
	{
		private sealed class Viewport
		{
			private readonly IModelScene _scene;

			private readonly ViewerOrbit _orbit;

			private readonly Image _image;

			private readonly VisualElement _frame;

			private readonly string _modelId;

			private bool _dragging;

			private bool _panning;

			private int _dragButton = -1;

			private Vector2 _last;

			private int _pointer = -1;

			internal Viewport(string title, string modelId, IModelScene scene, ViewerSettings settings, VisualElement frame, string hint, string reset)
			{
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Expected O, but got Unknown
				//IL_0094: 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_00c8: 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_00fc: 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_0144: 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_018f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b9: 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_01e7: Expected O, but got Unknown
				//IL_01ee: 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_0218: Unknown result type (might be due to invalid IL or missing references)
				//IL_0229: Unknown result type (might be due to invalid IL or missing references)
				Viewport viewport = this;
				_scene = scene;
				_frame = frame;
				_modelId = modelId;
				_orbit = new ViewerOrbit(settings, (Action<string>)UiLog.Verbose);
				_image = new Image
				{
					name = "kydl-viewport-image",
					scaleMode = (ScaleMode)0
				};
				((VisualElement)_image).style.position = StyleEnum<Position>.op_Implicit((Position)1);
				((VisualElement)_image).style.left = StyleLength.op_Implicit(0f);
				((VisualElement)_image).style.top = StyleLength.op_Implicit(0f);
				((VisualElement)_image).style.right = StyleLength.op_Implicit(0f);
				((VisualElement)_image).style.bottom = StyleLength.op_Implicit(0f);
				frame.Add((VisualElement)(object)_image);
				Label val = UiKit.TextLabel(title ?? "", (TextRole)6);
				((VisualElement)val).style.position = StyleEnum<Position>.op_Implicit((Position)1);
				((VisualElement)val).style.left = StyleLength.op_Implicit(10f);
				((VisualElement)val).style.top = StyleLength.op_Implicit(6f);
				((VisualElement)val).pickingMode = (PickingMode)1;
				frame.Add((VisualElement)(object)val);
				Label val2 = UiKit.TextLabel(hint ?? "", (TextRole)5);
				((VisualElement)val2).style.position = StyleEnum<Position>.op_Implicit((Position)1);
				((VisualElement)val2).style.left = StyleLength.op_Implicit(10f);
				((VisualElement)val2).style.bottom = StyleLength.op_Implicit(8f);
				((VisualElement)val2).pickingMode = (PickingMode)1;
				frame.Add((VisualElement)(object)val2);
				VisualElement val3 = new VisualElement
				{
					name = "kydl-viewport-buttons"
				};
				val3.style.position = StyleEnum<Position>.op_Implicit((Position)1);
				val3.style.right = StyleLength.op_Implicit(6f);
				val3.style.bottom = StyleLength.op_Implicit(4f);
				val3.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
				val3.Add((VisualElement)(object)UiControls.Button("+", (Action)delegate
				{
					viewport.Changed(viewport._orbit.StepZoom(1f), "zoom in button");
				}, false));
				val3.Add((VisualElement)(object)UiControls.Button("-", (Action)delegate
				{
					viewport.Changed(viewport._orbit.StepZoom(-1f), "zoom out button");
				}, false));
				val3.Add((VisualElement)(object)UiControls.Button(reset ?? "Reset", (Action)delegate
				{
					viewport.Changed(viewport._orbit.Reset(), "reset button");
				}, false));
				frame.Add(val3);
				((CallbackEventHandler)_image).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)OnDown, (TrickleDown)0);
				((CallbackEventHandler)_image).RegisterCallback<PointerMoveEvent>((EventCallback<PointerMoveEvent>)OnMove, (TrickleDown)0);
				((CallbackEventHandler)_image).RegisterCallback<PointerUpEvent>((EventCallback<PointerUpEvent>)OnUp, (TrickleDown)0);
				((CallbackEventHandler)_image).RegisterCallback<PointerCaptureOutEvent>((EventCallback<PointerCaptureOutEvent>)delegate
				{
					viewport.EndDrag("capture lost");
				}, (TrickleDown)0);
				((CallbackEventHandler)frame).RegisterCallback<WheelEvent>((EventCallback<WheelEvent>)OnWheel, (TrickleDown)0);
				((CallbackEventHandler)frame).RegisterCallback<GeometryChangedEvent>((EventCallback<GeometryChangedEvent>)delegate
				{
					viewport.OnResized(frame);
				}, (TrickleDown)0);
				((CallbackEventHandler)frame).RegisterCallback<DetachFromPanelEvent>((EventCallback<DetachFromPanelEvent>)delegate
				{
					viewport.Teardown();
				}, (TrickleDown)0);
				bool flag = _scene.Show(_modelId);
				_orbit.Reset();
				UiLog.Verbose("ModelViewportView: 3D viewport built for '" + _modelId + "', model " + (flag ? "shown" : "NOT shown (see the ModelViewerRig lines above)") + " (" + settings?.ToString() + ")");
			}

			private void OnDown(PointerDownEvent e)
			{
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				if (((PointerEventBase<PointerDownEvent>)(object)e).button == 0 || ((PointerEventBase<PointerDownEvent>)(object)e).button == 1)
				{
					if (_dragging)
					{
						UiLog.Verbose("ModelViewportView: button " + ((PointerEventBase<PointerDownEvent>)(object)e).button + " pressed during a " + (_panning ? "pan" : "rotate") + " drag (button " + _dragButton + ") - ignored");
						return;
					}
					_dragging = true;
					_panning = ((PointerEventBase<PointerDownEvent>)(object)e).button == 1;
					_dragButton = ((PointerEventBase<PointerDownEvent>)(object)e).button;
					_pointer = ((PointerEventBase<PointerDownEvent>)(object)e).pointerId;
					_last = new Vector2(((PointerEventBase<PointerDownEvent>)(object)e).position.x, ((PointerEventBase<PointerDownEvent>)(object)e).position.y);
					PointerCaptureHelper.CapturePointer((IEventHandler)(object)_image, ((PointerEventBase<PointerDownEvent>)(object)e).pointerId);
					((EventBase)e).StopPropagation();
					UiLog.Verbose("ModelViewportView: " + (_panning ? "pan" : "rotate") + " drag started at " + P(_last) + " (button " + ((PointerEventBase<PointerDownEvent>)(object)e).button + ", pointer " + ((PointerEventBase<PointerDownEvent>)(object)e).pointerId + ", frame " + FrameHeightPx().ToString("0", CultureInfo.InvariantCulture) + " UI px high)");
				}
			}

			private void OnMove(PointerMoveEvent e)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: 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_003b: 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_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				if (!_dragging || ((PointerEventBase<PointerMoveEvent>)(object)e).pointerId != _pointer)
				{
					return;
				}
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(((PointerEventBase<PointerMoveEvent>)(object)e).position.x, ((PointerEventBase<PointerMoveEvent>)(object)e).position.y);
				Vector2 val2 = val - _last;
				_last = val;
				if (!(((Vector2)(ref val2)).sqrMagnitude <= 0f))
				{
					if (_panning ? _orbit.Pan(val2.x, val2.y, FrameHeightPx()) : _orbit.Drag(val2.x, val2.y))
					{
						Draw(null);
					}
					((EventBase)e).StopPropagation();
				}
			}

			private void OnUp(PointerUpEvent e)
			{
				if (((PointerEventBase<PointerUpEvent>)(object)e).button == _dragButton && ((PointerEventBase<PointerUpEvent>)(object)e).pointerId == _pointer)
				{
					if (PointerCaptureHelper.HasPointerCapture((IEventHandler)(object)_image, ((PointerEventBase<PointerUpEvent>)(object)e).pointerId))
					{
						PointerCaptureHelper.ReleasePointer((IEventHandler)(object)_image, ((PointerEventBase<PointerUpEvent>)(object)e).pointerId);
					}
					EndDrag("button " + ((PointerEventBase<PointerUpEvent>)(object)e).button + " released");
					((EventBase)e).StopPropagation();
				}
			}

			private void EndDrag(string why)
			{
				if (_dragging)
				{
					_dragging = false;
					_pointer = -1;
					UiLog.Verbose("ModelViewportView: " + (_panning ? "pan" : "rotate") + " drag ended (" + why + "), view " + _orbit);
					_panning = false;
					_dragButton = -1;
				}
			}

			private float FrameHeightPx()
			{
				//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)
				Rect contentRect = _frame.contentRect;
				return ((Rect)(ref contentRect)).height;
			}

			private void OnWheel(WheelEvent e)
			{
				//IL_0008: 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)
				Changed(_orbit.Wheel(e.delta.y), "wheel " + e.delta.y.ToString("0.##", CultureInfo.InvariantCulture));
				((EventBase)e).StopPropagation();
			}

			private void OnResized(VisualElement frame)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				Rect contentRect = frame.contentRect;
				float num = PixelsPerPoint();
				int num2 = Mathf.RoundToInt(((Rect)(ref contentRect)).width * num);
				int num3 = Mathf.RoundToInt(((Rect)(ref contentRect)).height * num);
				if (num2 < 16 || num3 < 16)
				{
					UiLog.Verbose("ModelViewportView: frame " + ((Rect)(ref contentRect)).width + "x" + ((Rect)(ref contentRect)).height + " UI px is too small (hidden tab?), no texture");
					return;
				}
				UiLog.Verbose("ModelViewportView: frame " + ((Rect)(ref contentRect)).width.ToString("0", CultureInfo.InvariantCulture) + "x" + ((Rect)(ref contentRect)).height.ToString("0", CultureInfo.InvariantCulture) + " UI px x " + num.ToString("0.###", CultureInfo.InvariantCulture) + " = " + num2 + "x" + num3 + " screen px");
				if (_scene.Resize(num2, num3))
				{
					_image.image = _scene.Texture;
				}
				Draw("resized");
			}

			private static float PixelsPerPoint()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Invalid comparison between Unknown and I4
				//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_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)
				PanelSettings settings = UiKit.Settings;
				if (!((Object)(object)settings == (Object)null) && (int)settings.scaleMode == 2)
				{
					Vector2Int referenceResolution = settings.referenceResolution;
					if (((Vector2Int)(ref referenceResolution)).y > 0)
					{
						float num = (((Object)(object)settings.targetTexture != (Object)null) ? ((Texture)settings.targetTexture).height : Screen.height);
						referenceResolution = settings.referenceResolution;
						return Mathf.Clamp(num / (float)((Vector2Int)(ref referenceResolution)).y, 0.25f, 8f);
					}
				}
				return 1f;
			}

			private void Changed(bool changed, string why)
			{
				if (changed)
				{
					Draw(why);
					return;
				}
				UiLog.Verbose("ModelViewportView: " + why + " - view unchanged (" + _orbit?.ToString() + ")");
			}

			private void Draw(string why)
			{
				bool flag = _scene.Render(_orbit.Yaw, _orbit.Pitch, _orbit.Zoom, _orbit.PanX, _orbit.PanY, _orbit.PanZ);
				((VisualElement)_image).MarkDirtyRepaint();
				if (why != null)
				{
					UiLog.Verbose("ModelViewportView: drawn after " + why + " (" + _orbit?.ToString() + ")" + (flag ? "" : " - scene did not render"));
				}
			}

			private void Teardown()
			{
				_image.image = null;
				_scene.Dispose();
				UiLog.Verbose("ModelViewportView: viewport closed, 3D scene of '" + _modelId + "' disposed");
			}

			private static string P(Vector2 v)
			{
				return "(" + v.x.ToString("0", CultureInfo.InvariantCulture) + ", " + v.y.ToString("0", CultureInfo.InvariantCulture) + ")";
			}
		}

		internal static VisualElement Build(string title, string modelId, Func<IModelScene> makeScene, ViewerSettings settings, string hint, string reset, string unavailable)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009a: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			settings = settings ?? new ViewerSettings();
			settings.Clamp((Action<string>)UiLog.Verbose);
			VisualElement val = new VisualElement
			{
				name = "kydl-viewport"
			};
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.style.height = StyleLength.op_Implicit(settings.FrameHeight);
			val.style.marginTop = StyleLength.op_Implicit(10f);
			val.style.backgroundColor = StyleColor.op_Implicit(UiKit.Track);
			UiKit.Borders(val, 1f, UiKit.Border);
			UiKit.Radius(val, 4f);
			val.style.overflow = StyleEnum<Overflow>.op_Implicit((Overflow)1);
			IModelScene modelScene = null;
			try
			{
				modelScene = makeScene?.Invoke();
			}
			catch (Exception ex)
			{
				UiLog.Error("ModelViewportView: making the 3D scene failed: " + ex.GetType().Name + ": " + ex.Message);
			}
			if (modelScene == null)
			{
				val.style.justifyContent = StyleEnum<Justify>.op_Implicit((Justify)1);
				val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
				val.Add((VisualElement)(object)UiKit.TextLabel(title ?? "", (TextRole)7));
				val.Add((VisualElement)(object)UiKit.TextLabel(unavailable ?? "", (TextRole)3));
				UiLog.Verbose("ModelViewportView: no 3D scene, showing the title '" + title + "' only");
				return val;
			}
			new Viewport(title, modelId, modelScene, settings, val, hint, reset);
			return val;
		}
	}
	internal sealed class TabBar
	{
		private const float RailMargin = 18f;

		private readonly List<Button> _buttons = new List<Button>();

		private readonly Action<int> _changed;

		private int _selected = -1;

		internal VisualElement Root { get; private set; }

		internal int Selected => _selected;

		internal TabBar(IList<string> names, int selected, Action<int> changed)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0041: 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_0075: 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_00a9: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: 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_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: 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_01cf: 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)
			_changed = changed;
			Root = new VisualElement
			{
				name = "kydl-tabs"
			};
			Root.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			Root.style.flexShrink = StyleFloat.op_Implicit(0f);
			Root.style.marginLeft = StyleLength.op_Implicit(18f);
			Root.style.marginRight = StyleLength.op_Implicit(18f);
			Root.style.marginTop = StyleLength.op_Implicit(8f);
			Root.style.borderBottomWidth = StyleFloat.op_Implicit(1f);
			Root.style.borderBottomColor = StyleColor.op_Implicit(UiKit.Border);
			for (int i = 0; i < names.Count; i++)
			{
				int index = i;
				Button val = new Button((Action)delegate
				{
					Select(index);
				})
				{
					text = names[i]
				};
				((VisualElement)val).style.flexShrink = StyleFloat.op_Implicit(0f);
				((VisualElement)val).style.marginLeft = StyleLength.op_Implicit(0f);
				((VisualElement)val).style.marginRight = StyleLength.op_Implicit(4f);
				((VisualElement)val).style.marginTop = StyleLength.op_Implicit(0f);
				((VisualElement)val).style.marginBottom = StyleLength.op_Implicit(0f);
				UiKit.Pad((VisualElement)(object)val, 8f, 22f);
				((VisualElement)val).style.borderTopWidth = StyleFloat.op_Implicit(0f);
				((VisualElement)val).style.borderLeftWidth = StyleFloat.op_Implicit(0f);
				((VisualElement)val).style.borderRightWidth = StyleFloat.op_Implicit(0f);
				((VisualElement)val).style.borderBottomWidth = StyleFloat.op_Implicit(3f);
				UiKit.Radius((VisualElement)(object)val, 0f);
				UiKit.Fade((VisualElement)(object)val, new string[2] { "background-color", "color" });
				((CallbackEventHandler)val).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
				{
					Paint(index, hover: true);
				}, (TrickleDown)0);
				((CallbackEventHandler)val).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
				{
					Paint(index, hover: false);
				}, (TrickleDown)0);
				_buttons.Add(val);
				Root.Add((VisualElement)(object)val);
			}
			Show(Mathf.Clamp(selected, 0, Math.Max(0, names.Count - 1)));
			UiLog.Verbose("TabBar: built with " + names.Count + " tab(s) [" + string.Join(", ", names) + "], selected " + _selected);
		}

		internal bool Select(int index)
		{
			if (index < 0 || index >= _buttons.Count)
			{
				UiLog.Verbose("TabBar: tab " + index + " does not exist (" + _buttons.Count + " tabs), selection stays " + _selected);
				return _selected == index;
			}
			if (index == _selected)
			{
				return _selected == index;
			}
			UiLog.Verbose("TabBar: tab " + _selected + " -> " + index + " ('" + ((TextElement)_buttons[index]).text + "')");
			Show(index);
			if (_changed != null)
			{
				_changed(index);
			}
			return _selected == index;
		}

		private void Show(int index)
		{
			_selected = index;
			for (int i = 0; i < _buttons.Count; i++)
			{
				Paint(i, hover: false);
			}
		}

		private void Paint(int index, bool hover)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0056: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			Button obj = _buttons[index];
			bool flag = index == _selected;
			((VisualElement)obj).style.backgroundColor = StyleColor.op_Implicit(flag ? UiKit.PanelLight : (hover ? UiKit.PanelHover : Color.clear));
			UiKit.TabText((VisualElement)(object)obj, flag, hover);
			((VisualElement)obj).style.borderBottomColor = StyleColor.op_Implicit(flag ? UiKit.Gold : Color.clear);
		}
	}
	internal static class UiText
	{
		internal static readonly Dictionary<string, string> En = new Dictionary<string, string>
		{
			{ "wsadmounts_menu_title", "WSADMounts" },
			{ "wsadmounts_menu_footer", "Esc to close" },
			{ "wsadmounts_tab_settings", "Settings" }
		};

		internal static string English(string key)
		{
			if (!En.TryGetValue(key, out var value))
			{
				return key;
			}
			return value;
		}
	}
	internal static class ViewerMath
	{
		private const double Rad = Math.PI / 180.0;

		internal const float MinDistanceRadii = 1.5f;

		internal static float FitDistance(float halfWidth, float halfHeight, float radius, float verticalFovDeg, float aspect, float margin)
		{
			if (!(verticalFovDeg > 1f) || !(verticalFovDeg < 179f))
			{
				verticalFovDeg = 30f;
			}
			if (!(aspect > 0.01f) || float.IsInfinity(aspect))
			{
				aspect = 1f;
			}
			if (!(margin >= 0f) || float.IsInfinity(margin))
			{
				margin = 0f;
			}
			if (!(radius > 0f) || float.IsInfinity(radius))
			{
				radius = 0.5f;
			}
			halfWidth = ((halfWidth > 0f && !float.IsInfinity(halfWidth)) ? halfWidth : radius);
			halfHeight = ((halfHeight > 0f && !float.IsInfinity(halfHeight)) ? halfHeight : radius);
			double num = Math.Tan((double)verticalFovDeg * 0.5 * (Math.PI / 180.0));
			double num2 = num * (double)aspect;
			double num3 = 1.0 + (double)margin;
			double val = (double)halfWidth * num3 / num2;
			double val2 = (double)halfHeight * num3 / num;
			return (float)Math.Max(radius * 1.5f, Math.Max(val, val2));
		}

		internal static float ClampPitch(float pitch, float limit)
		{
			limit = Math.Max(0f, Math.Min(89f, float.IsNaN(limit) ? 0f : limit));
			if (float.IsNaN(pitch))
			{
				return 0f;
			}
			return Math.Max(0f - limit, Math.Min(limit, pitch));
		}

		internal static float WrapYaw(float yaw)
		{
			if (float.IsNaN(yaw) || float.IsInfinity(yaw))
			{
				return 0f;
			}
			double num = (double)yaw % 360.0;
			if (num > 180.0)
			{
				num -= 360.0;
			}
			if (num <= -180.0)
			{
				num += 360.0;
			}
			return (float)num;
		}

		internal static float StepZoom(float zoom, float steps, float factor, float min, float max)
		{
			if (!(min > 0f))
			{
				min = 0.01f;
			}
			if (max < min)
			{
				max = min;
			}
			if (!(factor > 1f))
			{
				factor = 1f;
			}
			if (!(zoom > 0f) || float.IsInfinity(zoom))
			{
				zoom = 1f;
			}
			double val = (double)zoom * Math.Pow(factor, float.IsNaN(steps) ? 0f : steps);
			return (float)Math.Max(min, Math.Min(max, val));
		}

		internal static void Orbit(float yawDeg, float pitchDeg, float distance, out float x, out float y, out float z)
		{
			double num = (double)yawDeg * (Math.PI / 180.0);
			double num2 = (double)pitchDeg * (Math.PI / 180.0);
			double num3 = (double)distance * Math.Cos(num2);
			x = (float)((0.0 - num3) * Math.Sin(num));
			y = (float)((double)distance * Math.Sin(num2));
			z = (float)((0.0 - num3) * Math.Cos(num));
		}

		internal static void CameraAxes(float yawDeg, float pitchDeg, out float rx, out float ry, out float rz, out float ux, out float uy, out float uz)
		{
			double num = (double)yawDeg * (Math.PI / 180.0);
			double num2 = (double)pitchDeg * (Math.PI / 180.0);
			double num3 = Math.Sin(num);
			double num4 = Math.Cos(num);
			double num5 = Math.Sin(num2);
			double num6 = Math.Cos(num2);
			rx = (float)num4;
			ry = 0f;
			rz = (float)(0.0 - num3);
			ux = (float)(num5 * num3);
			uy = (float)num6;
			uz = (float)(num5 * num4);
		}

		internal static bool ClampLength(ref float x, ref float y, ref float z, float limit)
		{
			if (float.IsNaN(x) || float.IsNaN(y) || float.IsNaN(z))
			{
				x = 0f;
				y = 0f;
				z = 0f;
				return true;
			}
			limit = (float.IsNaN(limit) ? 0f : Math.Max(0f, limit));
			double num = Math.Sqrt((double)x * (double)x + (double)y * (double)y + (double)z * (double)z);
			if (num <= (double)limit)
			{
				return false;
			}
			double num2 = ((num > 0.0) ? ((double)limit / num) : 0.0);
			x = (float)((double)x * num2);
			y = (float)((double)y * num2);
			z = (float)((double)z * num2);
			return true;
		}
	}
	internal sealed class ViewerOrbit
	{
		private readonly ViewerSettings _settings;

		private const float Tiny = 1E-06f;

		private readonly Action<string> _log;

		internal float Yaw { get; private set; }

		internal float Pitch { get; private set; }

		internal float Zoom { get; private set; }

		internal float PanX { get; private set; }

		internal float PanY { get; private set; }

		internal float PanZ { get; private set; }

		private static bool Differs(float a, float b)
		{
			return !(Math.Abs(a - b) <= 1E-06f);
		}

		internal ViewerOrbit(ViewerSettings settings, Action<string> log = null)
		{
			_settings = settings ?? new ViewerSettings();
			_log = log;
			Reset();
		}

		internal bool Reset()
		{
			float num = ViewerMath.WrapYaw(_settings.StartYaw);
			float num2 = ViewerMath.ClampPitch(_settings.StartPitch, _settings.PitchLimit);
			bool flag = PanX != 0f || PanY != 0f || PanZ != 0f;
			bool flag2 = Differs(num, Yaw) || Differs(num2, Pitch) || Differs(Zoom, 1f) || flag;
			Yaw = num;
			Pitch = num2;
			Zoom = 1f;
			PanX = 0f;
			PanY = 0f;
			PanZ = 0f;
			Log("ViewerOrbit: reset to " + this?.ToString() + (flag2 ? "" : " (already there)"));
			return flag2;
		}

		internal bool Pan(float dx, float dy, float frameHeightPx)
		{
			if (float.IsNaN(dx) || float.IsNaN(dy))
			{
				Log("ViewerOrbit: pan with NaN ignored");
				return false;
			}
			if (!(frameHeightPx >= 1f) || float.IsInfinity(frameHeightPx))
			{
				Log("ViewerOrbit: pan ignored, frame height " + F(frameHeightPx) + " px is not usable");
				return false;
			}
			float num = _settings.PanSpeed / (frameHeightPx * Math.Max(0.01f, Zoom));
			ViewerMath.CameraAxes(Yaw, Pitch, out var rx, out var ry, out var rz, out var ux, out var uy, out var uz);
			float x = PanX + ((0f - rx) * dx + ux * dy) * num;
			float y = PanY + ((0f - ry) * dx + uy * dy) * num;
			float z = PanZ + ((0f - rz) * dx + uz * dy) * num;
			bool flag = ViewerMath.ClampLength(ref x, ref y, ref z, _settings.PanLimit);
			int num2;
			if (!(Math.Abs(x - PanX) > 1E-06f) && !(Math.Abs(y - PanY) > 1E-06f))
			{
				num2 = ((Math.Abs(z - PanZ) > 1E-06f) ? 1 : 0);
				if (num2 == 0)
				{
					if (flag)
					{
						Log("ViewerOrbit: pan at the limit (" + F(_settings.PanLimit) + " view heights), view " + this);
					}
					return (byte)num2 != 0;
				}
			}
			else
			{
				num2 = 1;
			}
			PanX = x;
			PanY = y;
			PanZ = z;
			return (byte)num2 != 0;
		}

		internal bool Drag(float dx, float dy)
		{
			if (float.IsNaN(dx) || float.IsNaN(dy))
			{
				Log("ViewerOrbit: drag with NaN ignored");
				return false;
			}
			float num = ViewerMath.WrapYaw(Yaw - dx * _settings.RotateSpeed);
			float num2 = ViewerMath.ClampPitch(Pitch + dy * _settings.RotateSpeed, _settings.PitchLimit);
			bool result = Differs(num, Yaw) || Differs(num2, Pitch);
			Yaw = num;
			Pitch = num2;
			return result;
		}

		internal bool StepZoom(float steps)
		{
			float num = ViewerMath.StepZoom(Zoom, steps, _settings.ZoomStep, _settings.ZoomMin, _settings.ZoomMax);
			bool flag = Differs(num, Zoom);
			Log("ViewerOrbit: zoom " + F(Zoom) + " -> " + F(num) + " (" + F(steps) + " step(s), range " + F(_settings.ZoomMin) + ".." + F(_settings.ZoomMax) + ")" + (flag ? "" : " - at the limit"));
			Zoom = num;
			return flag;
		}

		internal bool Wheel(float deltaY)
		{
			if (deltaY == 0f || float.IsNaN(deltaY))
			{
				return false;
			}
			return StepZoom((deltaY > 0f) ? (-1f) : 1f);
		}

		private static string F(float v)
		{
			return v.ToString("0.##", CultureInfo.InvariantCulture);
		}

		public override string ToString()
		{
			return "yaw " + F(Yaw) + " deg, pitch " + F(Pitch) + " deg, zoom x" + F(Zoom) + ", pan (" + F(PanX) + ", " + F(PanY) + ", " + F(PanZ) + ") view heights";
		}

		private void Log(string s)
		{
			if (_log != null)
			{
				_log(s);
			}
		}
	}
	internal sealed class ViewerSettings
	{
		internal const float RotateSpeedMin = 0.05f;

		internal const float RotateSpeedMax = 2f;

		internal const float RotateSpeedDefault = 0.4f;

		internal const float ZoomStepMin = 1.02f;

		internal const float ZoomStepMax = 2f;

		internal const float ZoomStepDefault = 1.2f;

		internal const float ZoomMaxMin = 1f;

		internal const float ZoomMaxMax = 20f;

		internal const float ZoomMaxDefault = 8f;

		internal const float ZoomMinMin = 0.2f;

		internal const float ZoomMinMax = 1f;

		internal const float ZoomMinDefault = 0.5f;

		internal const float PitchLimitMin = 0f;

		internal const float PitchLimitMax = 89f;

		internal const float PitchLimitDefault = 80f;

		internal const float FrameHeightMin = 200f;

		internal const float FrameHeightMax = 800f;

		internal const float FrameHeightDefault = 420f;

		internal const float MarginMin = 0f;

		internal const float MarginMax = 0.5f;

		internal const float MarginDefault = 0.08f;

		internal const float StartYawMin = -180f;

		internal const float StartYawMax = 180f;

		internal const float StartYawDefault = 20f;

		internal const float StartPitchMin = -89f;

		internal const float StartPitchMax = 89f;

		internal const float StartPitchDefault = 12f;

		internal const float PanSpeedMin = 0.2f;

		internal const float PanSpeedMax = 3f;

		internal const float PanSpeedDefault = 1f;

		internal const float PanLimitMin = 0f;

		internal const float PanLimitMax = 3f;

		internal const float PanLimitDefault = 0.8f;

		internal const float KeyLightMin = 0f;

		internal const float KeyLightMax = 2f;

		internal const float KeyLightDefault = 0.7f;

		internal const float FillLightMin = 0f;

		internal const float FillLightMax = 1.5f;

		internal const float FillLightDefault = 0.25f;

		internal const float AmbientMin = 0f;

		internal const float AmbientMax = 1f;

		internal const float AmbientDefault = 0.22f;

		internal float RotateSpeed = 0.4f;

		internal float ZoomStep = 1.2f;

		internal float ZoomMax = 8f;

		internal float ZoomMin = 0.5f;

		internal float PitchLimit = 80f;

		internal float FrameHeight = 420f;

		internal float Margin = 0.08f;

		internal float StartYaw = 20f;

		internal float StartPitch = 12f;

		internal float PanSpeed = 1f;

		internal float PanLimit = 0.8f;

		internal float KeyLight = 0.7f;

		internal float FillLight = 0.25f;

		internal float Ambient = 0.22f;

		internal int Clamp(Action<string> log = null)
		{
			int changed = 0;
			RotateSpeed = Fix("RotateSpeed", RotateSpeed, 0.05f, 2f, 0.4f, ref changed, log);
			ZoomStep = Fix("ZoomStep", ZoomStep, 1.02f, 2f, 1.2f, ref changed, log);
			ZoomMax = Fix("ZoomMax", ZoomMax, 1f, 20f, 8f, ref changed, log);
			ZoomMin = Fix("ZoomMin", ZoomMin, 0.2f, 1f, 0.5f, ref changed, log);
			PitchLimit = Fix("PitchLimit", PitchLimit, 0f, 89f, 80f, ref changed, log);
			FrameHeight = Fix("FrameHeight", FrameHeight, 200f, 800f, 420f, ref changed, log);
			Margin = Fix("Margin", Margin, 0f, 0.5f, 0.08f, ref changed, log);
			StartYaw = Fix("StartYaw", StartYaw, -180f, 180f, 20f, ref changed, log);
			StartPitch = Fix("StartPitch", StartPitch, -89f, 89f, 12f, ref changed, log);
			PanSpeed = Fix("PanSpeed", PanSpeed, 0.2f, 3f, 1f, ref changed, log);
			PanLimit = Fix("PanLimit", PanLimit, 0f, 3f, 0.8f, ref changed, log);
			KeyLight = Fix("KeyLight", KeyLight, 0f, 2f, 0.7f, ref changed, log);
			FillLight = Fix("FillLight", FillLight, 0f, 1.5f, 0.25f, ref changed, log);
			Ambient = Fix("Ambient", Ambient, 0f, 1f, 0.22f, ref changed, log);
			if (StartPitch > PitchLimit || StartPitch < 0f - PitchLimit)
			{
				float startPitch = StartPitch;
				StartPitch = Math.Max(0f - PitchLimit, Math.Min(PitchLimit, StartPitch));
				changed++;
				log?.Invoke("ViewerSettings: StartPitch " + F(startPitch) + " is outside PitchLimit " + F(PitchLimit) + ", using " + F(StartPitch));
			}
			log?.Invoke("ViewerSettings: " + this?.ToString() + " (" + changed + " value(s) put into range)");
			return changed;
		}

		private static float Fix(string name, float v, float min, float max, float def, ref int changed, Action<string> log)
		{
			float num = ((float.IsNaN(v) || float.IsInfinity(v)) ? def : Math.Max(min, Math.Min(max, v)));
			if (!(Math.Abs(num - v) <= 1E-06f))
			{
				changed++;
				log?.Invoke("ViewerSettings: " + name + " " + F(v) + " is outside " + F(min) + ".." + F(max) + ", using " + F(num));
			}
			return num;
		}

		private static string F(float v)
		{
			return v.ToString("0.###", CultureInfo.InvariantCulture);
		}

		public override string ToString()
		{
			return "rotate " + F(RotateSpeed) + " deg/px, zoom step x" + F(ZoomStep) + ", zoom " + F(ZoomMin) + ".." + F(ZoomMax) + ", pitch limit " + F(PitchLimit) + " deg, frame " + F(FrameHeight) + " px, margin " + F(Margin) + ", start yaw " + F(StartYaw) + " / pitch " + F(StartPitch) + " deg, pan speed x" + F(PanSpeed) + ", pan limit " + F(PanLimit) + " view heights, light key " + F(KeyLight) + " / fill " + F(FillLight) + " / ambient " + F(Ambient);
		}
	}
}
namespace WSADMounts.Testing
{
	internal static class InGameTests
	{
		private static string Startup_ConfigBound()
		{
			if (ModSettings.EnableMod == null)
			{
				return "FAIL: ModSettings.Bind did not run (EnableMod is null)";
			}
			if (!ModSettings.On)
			{
				return "SKIP: EnableMod is off in the config";
			}
			return "PASS: EnableMod on";
		}

		private static string Startup_FeaturesInstalled()
		{
			ModInstaller current = ModInstaller.Current;
			if (current == null)
			{
				return "FAIL: ModInstaller.Install did not run";
			}
			int num = 0;
			foreach (IFeature item in current.Features.All)
			{
				if (current.Features.IsRunning(item.Id))
				{
					num++;
				}
			}
			ModLog.Verbose("InGameTests: Startup_FeaturesInstalled " + current.Features.Count + " feature(s), " + num + " running");
			if (current.Features.Count <= 0)
			{
				return "FAIL: no feature registered";
			}
			return "PASS: " + current.Features.Count + " feature(s), " + num + " running";
		}

		private static string Startup_CoreLoaded()
		{
			bool flag = Chainloader.PluginInfos.ContainsKey("com.kydldev.KydlCore");
			ModLog.Verbose("InGameTests: Startup_CoreLoaded " + flag);
			if (!flag)
			{
				return "FAIL: com.kydldev.KydlCore is not loaded (this mod requires it)";
			}
			return "PASS: com.kydldev.KydlCore is loaded";
		}

		private static string World_PlayerPresent()
		{
			//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)
			Player localPlayer = Player.m_localPlayer;
			ModLog.Verbose("InGameTests: World_PlayerPresent player " + (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetPlayerName() : "null"));
			if (!((Object)(object)localPlayer != (Object)null))
			{
				return "FAIL: no local player 5 s after the world loaded";
			}
			string playerName = localPlayer.GetPlayerName();
			Vector3 position = ((Component)localPlayer).transform.position;
			return "PASS: " + playerName + " at " + ((Vector3)(ref position)).ToString("F1");
		}
	}
}
namespace WSADMounts.Testing.TestHooks
{
	internal sealed class AirSampler : MonoBehaviour
	{
		private const float MaxSeconds = 20f;

		private float _until;

		internal float StartY { get; private set; }

		internal float PeakY { get; private set; }

		internal void Begin()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			StartY = ((Component)this).transform.position.y;
			PeakY = StartY;
			_until = Time.time + 20f;
			ModLog.Verbose($"AirSampler.Begin: {((Object)this).name} at y {StartY:0.00} m for {20f:0} s");
		}

		private void Update()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time > _until)
			{
				ModLog.Verbose($"AirSampler: {((Object)this).name} done (peak {PeakY - StartY:0.00} m above the start)");
				Object.Destroy((Object)(object)this);
				return;
			}
			float y = ((Component)this).transform.position.y;
			if (y > PeakY)
			{
				PeakY = y;
			}
			ModLog.Every("AirSampler.Update", 2.0, $"AirSampler: {((Object)this).name} y {y:0.00} m, peak {PeakY - StartY:0.00} m above the start");
		}
	}
	internal static class BoulderTestHooks
	{
		private static readonly string[] Rocks = new string[9] { "rock1_mountain", "rock2_mountain", "rock3_mountain", "rock4_coast", "rock2_heath", "rock3_ice", "rock4_forest", "Rock_3", "Rock_4" };

		private static readonly List<GameObject> Placed = new List<GameObject>();

		private static readonly List<Bounds> PlacedBounds = new List<Bounds>();

		private static GameObject _rock;

		private static Vector3 _forward = Vector3.forward;

		[TestHook("WSADMounts.boulderSpawn")]
		private static string BoulderSpawn(double ahead = 12.0, double side = 0.0, double height = 1.3, double size = 6.0, bool behind = false)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00bd: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_0108: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_0163: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: 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_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: 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)
			Character val = (((Object)(object)RidingTestHooks.TestMount != (Object)null) ? RidingTestHooks.TestMount.GetComponent<Character>() : null);
			if ((Object)(object)val == (Object)null)
			{
				ModLog.Warn("BoulderTestHooks.BoulderSpawn: no test mount");
				return "no mount";
			}
			if (!behind || PlacedBounds.Count == 0)
			{
				Remove("new boulder");
				_forward = Flat(((Component)val).transform.forward);
			}
			Vector3 forward = _forward;
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(forward.z, 0f, 0f - forward.x);
			float num = (float)size / 2f;
			Vector3 val3 = ((behind && PlacedBounds.Count > 0) ? Behind(PlacedBounds[PlacedBounds.Count - 1], forward, num) : (((Component)val).transform.position + forward * (val.GetRadius() + (float)ahead + num) + val2 * (float)side));
			float num3 = default(float);
			float num2 = (((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(val3, ref num3)) ? num3 : val3.y);
			string text = PickRock(val3, forward);
			if ((Object)(object)_rock == (Object)null)
			{
				ModLog.Warn($"BoulderTestHooks.BoulderSpawn: no rock whose colliders match its mesh among {Rocks.Length}");
				return "no fitting rock";
			}
			Bounds val4 = Visible(_rock);
			Vector3 localScale = _rock.transform.localScale;
			localScale.x *= (float)size / Mathf.Max(0.1f, ((Bounds)(ref val4)).size.x);
			localScale.y *= (float)height / Mathf.Max(0.1f, ((Bounds)(ref val4)).size.y);
			localScale.z *= (float)size / Mathf.Max(0.1f, ((Bounds)(ref val4)).size.z);
			_rock.transform.localScale = localScale;
			Physics.SyncTransforms();
			Bounds val5 = Visible(_rock);
			Transform transform = _rock.transform;
			transform.position += new Vector3(0f, num2 - ((Bounds)(ref val5)).min.y + 0.05f, 0f);
			Physics.SyncTransforms();
			Bounds item = BoundsOf(_rock);
			Placed.Add(_rock);
			PlacedBounds.Add(item);
			ModLog.Check("BoulderTestHooks: boulder collider top above the ground", (double)(((Bounds)(ref item)).max.y - num2), (double)(float)height, 0.30000001192092896, "m");
			(((Component)val).GetComponent<BoulderWatch>() ?? ((Component)val).gameObject.AddComponent<BoulderWatch>()).Begin(PlacedBounds);
			string text2 = $"boulder {PlacedBounds.Count} {text} top {((Bounds)(ref item)).max.y - num2:0.00} m, {((Bounds)(ref item)).size.x:0.0} x {((Bounds)(ref item)).size.z:0.0} m, " + $"near edge {Vector3.Dot(((Bounds)(ref item)).center - ((Component)val).transform.position, forward) - ((Bounds)(ref item)).size.z / 2f:0.0} m ahead of the mount, side {side:0.0} m, behind the last {behind}";
			ModLog.Info($"BoulderTestHooks.BoulderSpawn: {text2} (raw size {((Bounds)(ref val4)).size}, ground {num2:0.00})");
			return text2;
		}

		[TestHook("WSADMounts.boulderJumpPoint")]
		private static string BoulderJumpPoint(double air = 0.8, int rock = 1)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b0: 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_00bc: 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)
			Character val = (((Object)(object)RidingTestHooks.TestMount != (Object)null) ? RidingTestHooks.TestMount.GetComponent<Character>() : null);
			if ((Object)(object)val == (Object)null || rock < 1 || rock > PlacedBounds.Count)
			{
				ModLog.Warn($"BoulderTestHooks.BoulderJumpPoint: mount {(Object)(object)val != (Object)null}, boulder {rock} of {PlacedBounds.Count}");
				return "no mount or no boulder";
			}
			Vector3 val2 = Flat(((Component)val).transform.forward);
			Bounds val3 = PlacedBounds[rock - 1];
			float num = Vector3.Dot(((Bounds)(ref val3)).center - ((Component)val).transform.position, val2);
			Vector3 velocity = val.GetVelocity();
			Vector2 val4 = new Vector2(velocity.x, velocity.z);
			float magnitude = ((Vector2)(ref val4)).magnitude;
			bool flag = val.IsOnGround();
			bool flag2 = flag && num <= magnitude * (float)air;
			if (flag2 || ModLog.IsDue("BoulderTestHooks.JumpPoint", 0.5))
			{
				ModLog.Info(string.Format("BoulderTestHooks.BoulderJumpPoint: boulder {0} middle {1:0.0} m ahead, speed {2:0.0} m/s x {3:0.0} s = {4:0.0} m, on ground {5} -> {6}", rock, num, magnitude, air, (double)magnitude * air, flag, flag2 ? "jump" : "wait"));
			}
			if (!flag2)
			{
				return "wait";
			}
			return "jump";
		}

		[TestHook("WSADMounts.boulderLanded")]
		private static string BoulderLanded(int rock = 1)
		{
			BoulderWatch boulderWatch = (((Object)(object)RidingTestHooks.TestMount != (Object)null) ? RidingTestHooks.TestMount.GetComponent<BoulderWatch>() : null);
			string text = (((Object)(object)boulderWatch != (Object)null) ? boulderWatch.Facts() : "no watch");
			bool flag = (Object)(object)boulderWatch != (Object)null && boulderWatch.LandedOn(rock - 1);
			ModLog.Info("BoulderTestHooks.BoulderLanded: " + text + " -> " + (flag ? "ok" : "bad"));
			if (!flag)
			{
				return "bad: not on top - " + text;
			}
			return "ok";
		}

		[TestHook("WSADMounts.rideInputStop")]
		private static string RideInputStop()
		{
			RideTestInput.Disarm("rideInputStop hook");
			return "input stopped";
		}

		[TestHook("WSADMounts.boulderRemove")]
		private static string BoulderRemove()
		{
			Remove("boulderRemove hook");
			return "boulder removed";
		}

		internal static void Remove(string why)
		{
			int num = 0;
			foreach (GameObject item in Placed)
			{
				if (!((Object)(object)item == (Object)null))
				{
					num++;
					ZNetView component = item.GetComponent<ZNetView>();
					if ((Object)(object)component != (Object)null && component.IsValid())
					{
						component.Destroy();
					}
					else
					{
						Object.Destroy((Object)(object)item);
					}
				}
			}
			Placed.Clear();
			PlacedBounds.Clear();
			_rock = null;
			ModLog.Verbose($"BoulderTestHooks.Remove: {why}, removed {num} boulder(s)");
		}

		private static Vector3 Behind(Bounds last, Vector3 forward, float half)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0034: 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_004c: 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_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_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)
			float num = Mathf.Abs(Vector3.Dot(((Bounds)(ref last)).extents, new Vector3(Mathf.Abs(forward.x), 0f, Mathf.Abs(forward.z))));
			Vector3 val = new Vector3(((Bounds)(ref last)).center.x, ((Bounds)(ref last)).min.y, ((Bounds)(ref last)).center.z) + forward * (num + half);
			ModLog.Verbose($"BoulderTestHooks.Behind: last boulder half depth {num:0.0} m -> centre {val}");
			return val;
		}

		private static string PickRock(Vector3 at, Vector3 forward)
		{
			//IL_003a: 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_003c: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0088: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			string[] rocks = Rocks;
			foreach (string text in rocks)
			{
				GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(text) : null);
				if (!((Object)(object)val == (Object)null))
				{
					_rock = Object.Instantiate<GameObject>(val, at, Quaternion.LookRotation(forward));
					Physics.SyncTransforms();
					Bounds val2 = Visible(_rock);
					Vector3 size = ((Bounds)(ref val2)).size;
					val2 = BoundsOf(_rock);
					Vector3 size2 = ((Bounds)(ref val2)).size;
					bool flag = size.y > 0.1f && Close(size.x, size2.x) && Close(size.y, size2.y) && Close(size.z, size2.z);
					ModLog.Info(string.Format("BoulderTestHooks.PickRock: {0} visible {1}, colliders {2} -> {3}", text, size, size2, flag ? "used" : "skipped"));
					if (flag)
					{
						return text;
					}
					Object.Destroy((Object)(object)_rock);
					_rock = null;
				}
			}
			ModLog.Warn("BoulderTestHooks.PickRock: none fits");
			return "<none>";
		}

		private static bool Close(float a, float b)
		{
			return Mathf.Abs(a - b) <= 0.3f * Mathf.Max(a, b);
		}

		private static Bounds Visible(GameObject go)
		{
			//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_007d: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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)
			Bounds bounds = default(Bounds);
			((Bounds)(ref bounds))..ctor(go.transform.position, Vector3.zero);
			bool flag = true;
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				if (val.enabled && ((Component)val).gameObject.activeInHierarchy && !(val is ParticleSystemRenderer))
				{
					if (flag)
					{
						bounds = val.bounds;
						flag = false;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val.bounds);
					}
				}
			}
			ModLog.Verbose($"BoulderTestHooks.Visible: {((Object)go).name} -> {((Bounds)(ref bounds)).size} at {((Bounds)(ref bounds)).center}");
			return bounds;
		}

		private static Bounds BoundsOf(GameObject go)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_0052: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			Collider[] componentsInChildren = go.GetComponentsInChildren<Collider>();
			Bounds bounds = default(Bounds);
			((Bounds)(ref bounds))..ctor(go.transform.position, Vector3.zero);
			bool flag = true;
			Collider[] array = componentsInChildren;
			foreach (Collider val in array)
			{
				if (val.enabled && !val.isTrigger)
				{
					if (flag)
					{
						bounds = val.bounds;
						flag = false;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val.bounds);
					}
				}
			}
			ModLog.Verbose($"BoulderTestHooks.BoundsOf: {((Object)go).name} {componentsInChildren.Length} collider(s) -> {((Bounds)(ref bounds)).size} at {((Bounds)(ref bounds)).center}");
			return bounds;
		}

		private static Vector3 Flat(Vector3 v)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			v.y = 0f;
			if (!(((Vector3)(ref v)).sqrMagnitude > 1E-06f))
			{
				return Vector3.forward;
			}
			return ((Vector3)(ref v)).normalized;
		}
	}
	internal sealed class BoulderWatch : MonoBehaviour
	{
		private const float MaxSeconds = 30f;

		private readonly List<Bounds> _rocks = new List<Bounds>();

		private readonly List<bool> _landed = new List<bool>();

		private Character _mount;

		private float _until;

		private float _peak;

		private float _start;

		private bool _wasGrounded = true;

		private string _touchdown = string.Empty;

		internal bool LandedOn(int index)
		{
			if (index >= 0 && index < _landed.Count)
			{
				return _landed[index];
			}
			return false;
		}

		internal void Begin(List<Bounds> rocks)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			_rocks.Clear();
			_rocks.AddRange(rocks);
			_landed.Clear();
			rocks.ForEach(delegate
			{
				_landed.Add(item: false);
			});
			_mount = ((Component)this).GetComponent<Character>();
			_until = Time.time + 30f;
			_start = ((Component)this).transform.position.y;
			_peak = _start;
			_touchdown = string.Empty;
			_wasGrounded = true;
			ModLog.Verbose(string.Format("BoulderWatch.Begin: {0} at y {1:0.00} m, {2} boulder(s), tops {3}", ((Object)this).name, _start, rocks.Count, string.Join(", ", rocks.ConvertAll((Bounds r) => $"{((Bounds)(ref r)).max.y - _start:0.00} m").ToArray())));
		}

		internal string Facts()
		{
			//IL_001f: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			for (int i = 0; i < _rocks.Count; i++)
			{
				object arg = i + 1;
				Bounds val = _rocks[i];
				list.Add($"boulder {arg} (top {((Bounds)(ref val)).max.y - _start:0.00} m) landed {_landed[i]}");
			}
			string text = string.Format("{0}; peak {1:0.00} m above the start, now y {2:0.00} m; {3}", string.Join(", ", list.ToArray()), _peak - _start, ((Component)this).transform.position.y - _start, (_touchdown.Length > 0) ? _touchdown : "no touch-down seen");
			ModLog.Verbose("BoulderWatch.Facts: " + text);
			return text;
		}

		private void Update()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_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_0160: 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_0255: 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_017c: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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)
			if (Time.time > _until || (Object)(object)_mount == (Object)null)
			{
				ModLog.Verbose("BoulderWatch: " + ((Object)this).name + " done - " + Facts());
				Object.Destroy((Object)(object)this);
				return;
			}
			Vector3 position = ((Component)this).transform.position;
			_peak = Mathf.Max(_peak, position.y);
			bool flag = _mount.IsOnGround();
			if (_touchdown.Length == 0 && flag && !_wasGrounded && _peak - _start > 0.5f && _rocks.Count > 0)
			{
				Bounds val = _rocks[0];
				Vector3 val2 = ((Bounds)(ref val)).center - position;
				_touchdown = $"first touch-down after the jump {Vector3.Dot(val2, ((Component)this).transform.forward):0.0} m before boulder 1's middle (negative = past it), {Vector3.Dot(val2, ((Component)this).transform.right):0.0} m to its side, y {position.y - _start:0.00} m";
				ModLog.Info("BoulderWatch: " + ((Object)this).name + " " + _touchdown);
			}
			_wasGrounded = flag;
			for (int i = 0; i < _rocks.Count; i++)
			{
				Bounds val3 = _rocks[i];
				bool flag2 = position.x > ((Bounds)(ref val3)).min.x && position.x < ((Bounds)(ref val3)).max.x && position.z > ((Bounds)(ref val3)).min.z && position.z < ((Bounds)(ref val3)).max.z;
				if (!_landed[i] && flag2 && flag && position.y >= ((Bounds)(ref val3)).max.y - 0.35f)
				{
					_landed[i] = true;
					ModLog.Info($"BoulderWatch: {((Object)this).name} landed on boulder {i + 1} at y {position.y - _start:0.00} m above the start");
				}
			}
			ModLog.Every("BoulderWatch.Update", 1.0, $"BoulderWatch: {((Object)this).name} y {position.y - _start:0.00} m, on ground {flag}");
		}
	}
	internal static class ModTestHooks
	{
		[TestHook("WSADMounts.arena")]
		private static string Arena()
		{
			return TestArena.MovePlayer();
		}

		[TestHook("WSADMounts.selftest")]
		private static string SelfTest()
		{
			return TestLabSupport.RunInGameTests(typeof(InGameTests), true);
		}

		[TestHook("WSADMounts.featureRunning")]
		private static bool FeatureRunning(string id)
		{
			bool flag = ModInstaller.Current != null && ModInstaller.Current.Features.IsRunning(id);
			ModLog.Verbose(string.Format("ModTestHooks.FeatureRunning: '{0}' running {1} (installer {2})", id, flag, (ModInstaller.Current != null) ? "present" : "missing"));
			return flag;
		}
	}
	internal static class MountActionTestHooks
	{
		private static Character Mount
		{
			get
			{
				if (!((Object)(object)RidingTestHooks.TestMount != (Object)null))
				{
					return null;
				}
				return RidingTestHooks.TestMount.GetComponent<Character>();
			}
		}

		[TestHook("WSADMounts.riding")]
		private static string Riding()
		{
			Player localPlayer = Player.m_localPlayer;
			bool flag = (Object)(object)localPlayer != (Object)null && ((Character)localPlayer).IsRiding();
			ModLog.Info($"MountActionTestHooks.Riding: player {(Object)(object)localPlayer != (Object)null}, riding {flag}, attached {(Object)(object)localPlayer != (Object)null && ((Character)localPlayer).IsAttached()}");
			return $"riding {flag}";
		}

		[TestHook("WSADMounts.airMark")]
		private static string AirMark()
		{
			Character mount = Mount;
			if ((Object)(object)mount == (Object)null)
			{
				ModLog.Warn("MountActionTestHooks.AirMark: no test mount");
				return "no mount";
			}
			AirSampler airSampler = ((Component)mount).GetComponent<AirSampler>() ?? ((Component)mount).gameObject.AddComponent<AirSampler>();
			airSampler.Begin();
			string text = $"air marked at {airSampler.StartY:0.00} m";
			ModLog.Info("MountActionTestHooks.AirMark: " + mount.m_name + " " + text);
			return text;
		}

		[TestHook("WSADMounts.airPeak")]
		private static string AirPeak(double min)
		{
			AirSampler airSampler = (((Object)(object)Mount != (Object)null) ? ((Component)Mount).GetComponent<AirSampler>() : null);
			float num = (((Object)(object)airSampler != (Object)null) ? (airSampler.PeakY - airSampler.StartY) : (-1f));
			string text = (((double)num >= min) ? "ok" : $"bad: rose {num:0.00} m, {min:0.##} m expected (sampler {(Object)(object)airSampler != (Object)null})");
			ModLog.Info($"MountActionTestHooks.AirPeak({min:0.##}): rose {num:0.00} m -> {text}");
			return text;
		}

		[TestHook("WSADMounts.lastMountAction")]
		private static string LastMountAction()
		{
			string lastAction = MountActions.LastAction;
			MountActions.ForgetLast("lastMountAction hook");
			ModLog.Info("MountActionTestHooks.LastMountAction: " + lastAction);
			return lastAction;
		}

		[TestHook("WSADMounts.mountIdle")]
		private static string MountIdle()
		{
			Character mount = Mount;
			string text = (((Object)(object)mount == (Object)null) ? "no mount" : (mount.InAttack() ? "in attack" : "idle"));
			if (ModLog.IsDue("MountActionTestHooks.MountIdle", 1.0))
			{
				ModLog.Verbose("MountActionTestHooks.MountIdle: " + text);
			}
			return text;
		}

		[TestHook("WSADMounts.jumpClip")]
		private static string JumpClip()
		{
			bool flag = (Object)(object)RidingTestHooks.TestMount != (Object)null && (Object)(object)RidingTestHooks.TestMount.GetComponent<JumpClipPlayer>() != (Object)null;
			string text = $"playing {flag}, last {JumpClipPlayer.LastReport}";
			ModLog.Info("MountActionTestHooks.JumpClip: " + text);
			return text;
		}

		[TestHook("WSADMounts.rideTuning")]
		private static string RideTuning()
		{
			Character mount = Mount;
			Sadle val = (((Object)(object)mount != (Object)null) ? ((Component)mount).GetComponentInChildren<Sadle>(true) : null);
			if ((Object)(object)mount == (Object)null)
			{
				ModLog.Warn("MountActionTestHooks.RideTuning: no test mount");
				return "no mount";
			}
			string text = $"tuned {MountTuning.IsTuned(mount)} acceleration={mount.m_acceleration:0.##} turn={mount.m_turnSpeed:0.#} deg/s runTurn={mount.m_runTurnSpeed:0.#} deg/s " + $"run={mount.m_runSpeed:0.##} m/s drain={(((Object)(object)val != (Object)null) ? val.m_runStaminaDrain : (-1f)):0.##}/s jump={mount.m_jumpForce:0.##} m/s";
			ModLog.Info("MountActionTestHooks.RideTuning: " + mount.m_name + " " + text);
			return text;
		}

		[TestHook("WSADMounts.speed")]
		private static string Speed(double min, double max)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0023: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			Character mount = Mount;
			Vector3 val = (((Object)(object)mount != (Object)null) ? mount.GetVelocity() : Vector3.zero);
			Vector2 val2 = new Vector2(val.x, val.z);
			float magnitude = ((Vector2)(ref val2)).magnitude;
			bool flag = (Object)(object)mount != (Object)null && (double)magnitude >= min && (double)magnitude <= max;
			string result = (flag ? "ok" : $"bad: {magnitude:0.00} m/s, {min:0.##}..{max:0.##} m/s expected (mount {(Object)(object)mount != (Object)null}, run {(Object)(object)mount != (Object)null && mount.IsRunning()})");
			ModLog.Info(string.Format("MountActionTestHooks.Speed({0:0.##}..{1:0.##}): {2:0.00} m/s, running {3} -> {4}", min, max, magnitude, (Object)(object)mount != (Object)null && mount.IsRunning(), flag ? "ok" : "bad"));
			return result;
		}
	}
	internal static class MountTargetTestHooks
	{
		private static Character _target;

		private static float _targetStart;

		private static float _riderStart;

		[TestHook("WSADMounts.targetSpawn")]
		private static string TargetSpawn(string prefab = "Boar", double gap = 1.2)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00e8: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			Character val = (((Object)(object)RidingTestHooks.TestMount != (Object)null) ? RidingTestHooks.TestMount.GetComponent<Character>() : null);
			GameObject val2 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(prefab) : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				ModLog.Warn($"MountTargetTestHooks.TargetSpawn: mount {(Object)(object)val != (Object)null}, prefab '{prefab}' {(Object)(object)val2 != (Object)null}");
				return "no mount or no prefab";
			}
			Vector3 forward = ((Component)val).transform.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			float num = val.GetRadius() + (float)gap;
			Vector3 val3 = ((Component)val).transform.position + forward * num;
			float num2 = default(float);
			if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(val3, ref num2))
			{
				val3.y = num2 + 0.1f;
			}
			GameObject obj = Object.Instantiate<GameObject>(val2, val3, Quaternion.LookRotation(-forward));
			_target = obj.GetComponent<Character>();
			BaseAI component = obj.GetComponent<BaseAI>();
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = false;
			}
			_targetStart = (((Object)(object)_target != (Object)null) ? _target.GetHealth() : (-1f));
			string text = $"target {prefab} health {_ta