Decompiled source of SteveTheTroll v2.0.0

SteveTheTroll/SteveTheTroll.dll

Decompiled 19 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using KydlCore.Common;
using KydlCore.Core;
using KydlCore.Features.Hub.Contracts;
using KydlCore.Features.Items.Contracts;
using KydlCore.Ui;
using Microsoft.CodeAnalysis;
using SteveTheTroll.Bootstrap;
using SteveTheTroll.Configuration;
using SteveTheTroll.Core;
using SteveTheTroll.Features.Costume.Domain;
using SteveTheTroll.Features.Costume.Infrastructure;
using SteveTheTroll.Features.Hubs.Application;
using SteveTheTroll.Features.Hubs.Domain;
using SteveTheTroll.Features.Hubs.Infrastructure;
using SteveTheTroll.Features.Slippers.Domain;
using SteveTheTroll.Features.Slippers.Infrastructure;
using SteveTheTroll.Features.Trolls.Backpack.Application;
using SteveTheTroll.Features.Trolls.Backpack.Domain;
using SteveTheTroll.Features.Trolls.Backpack.Execution;
using SteveTheTroll.Features.Trolls.Backpack.Infrastructure;
using SteveTheTroll.Features.Trolls.Combat.Application;
using SteveTheTroll.Features.Trolls.Combat.Domain;
using SteveTheTroll.Features.Trolls.Combat.Execution;
using SteveTheTroll.Features.Trolls.Combat.Infrastructure;
using SteveTheTroll.Features.Trolls.Contracts;
using SteveTheTroll.Features.Trolls.Core;
using SteveTheTroll.Features.Trolls.Farming.Application;
using SteveTheTroll.Features.Trolls.Farming.Domain;
using SteveTheTroll.Features.Trolls.Farming.Execution;
using SteveTheTroll.Features.Trolls.Farming.Infrastructure;
using SteveTheTroll.Features.Trolls.Home.Domain;
using SteveTheTroll.Features.Trolls.Home.Infrastructure;
using SteveTheTroll.Features.Trolls.Infrastructure;
using SteveTheTroll.Features.Trolls.Movement.Domain;
using SteveTheTroll.Features.Trolls.Movement.Infrastructure;
using SteveTheTroll.Features.Trolls.Orders.Application;
using SteveTheTroll.Features.Trolls.Orders.Commands;
using SteveTheTroll.Features.Trolls.Orders.Domain;
using SteveTheTroll.Features.Trolls.Orders.Infrastructure;
using SteveTheTroll.Features.Trolls.Recovery.Application;
using SteveTheTroll.Features.Trolls.Recovery.Domain;
using SteveTheTroll.Features.Trolls.Recovery.Execution;
using SteveTheTroll.Features.Trolls.Recovery.Infrastructure;
using SteveTheTroll.Features.Trolls.Registry.Infrastructure;
using SteveTheTroll.Features.Trolls.Taming.Domain;
using SteveTheTroll.Features.Trolls.Taming.Infrastructure;
using SteveTheTroll.Features.Trolls.Water.Infrastructure;
using SteveTheTroll.Features.Trolls.World.Infrastructure;
using SteveTheTroll.Fit;
using SteveTheTroll.Integrations.KydlCore;
using SteveTheTroll.Integrations.Unity;
using SteveTheTroll.Presentation.Hub.Commands;
using SteveTheTroll.Presentation.Hub.Pages;
using SteveTheTroll.Presentation.Hub.Registration;
using SteveTheTroll.Presentation.Hub.ViewModels;
using SteveTheTroll.Presentation.Map;
using SteveTheTroll.Presentation.Notifications;
using SteveTheTroll.Testing;
using SteveTheTroll.Testing.Commands;
using SteveTheTroll.Testing.TestHooks;
using SteveTheTroll.Ui;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
using UnityEngine.UIElements;

[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 SteveTheTroll.Fit
{
	public static class FitGeometry
	{
		public const float MaxFootTurnDeg = 75f;

		public const float JumpDeg = 45f;

		public const float ToeBlendWidth = 0.03f;

		private const float MinSqr = 0.0001f;

		public const float SkinBlendEps = 0.002f;

		public static Vector3 Flat(Vector3 dir, Vector3 fallback)
		{
			//IL_0002: 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_0030: 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_0028: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(dir.x, 0f, dir.z);
			if (((Vector3)(ref val)).sqrMagnitude >= 0.0001f)
			{
				return ((Vector3)(ref val)).normalized;
			}
			((Vector3)(ref val))..ctor(fallback.x, 0f, fallback.z);
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
			{
				return ((Vector3)(ref val)).normalized;
			}
			return Vector3.forward;
		}

		public static Vector3 RotateY(Vector3 v, float deg)
		{
			//IL_0014: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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)
			float num = deg * ((float)Math.PI / 180f);
			float num2 = Mathf.Cos(num);
			float num3 = Mathf.Sin(num);
			return new Vector3(v.x * num2 + v.z * num3, v.y, (0f - v.x) * num3 + v.z * num2);
		}

		public static float YawDeg(Vector3 dir)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Atan2(dir.x, dir.z) * 57.29578f;
		}

		public static Vector3 FootForward(Vector3 toeDir, Vector3 shin, Vector3 playerForward)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0033: 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_004c: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_005b: 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_0061: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Flat(playerForward, Vector3.forward);
			if (((Vector3)(ref toeDir)).sqrMagnitude < 1E-10f)
			{
				return val;
			}
			Vector3 val2 = Vector3.Cross(shin, toeDir);
			Vector3 val3 = ((((Vector3)(ref val2)).sqrMagnitude > 1E-10f) ? Flat(Vector3.Cross(val2, Vector3.up), val) : Flat(toeDir, val));
			if (Vector3.Dot(val3, val) < 0f)
			{
				val3 = -val3;
			}
			float num = Vector3.SignedAngle(val, val3, Vector3.up);
			if (Mathf.Abs(num) > 75f)
			{
				val3 = RotateY(val, Mathf.Sign(num) * 75f);
			}
			return val3;
		}

		public static Vector3 FootFramePosition(Vector3 footPos, Vector3 footForward, bool leftFoot, float forward, float side, float up, float lift)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Flat(footForward, Vector3.forward);
			Vector3 val2 = Vector3.Cross(Vector3.up, val);
			float num = (leftFoot ? (-1f) : 1f);
			Vector3 result = footPos + val * forward + val2 * (num * side);
			result.y = footPos.y + up + lift;
			return result;
		}

		public static float FigureYawDeg(Vector3 footForward, float yawDeg)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return YawDeg(Flat(footForward, Vector3.forward)) + yawDeg;
		}

		public static float ToeAlong(Vector3 vertexWorld, Vector3 toePos, Vector3 footForward)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return Vector3.Dot(vertexWorld - toePos, footForward);
		}

		public static float ToeWeight(float along)
		{
			return Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(-0.03f, 0.03f, along));
		}

		public static float LogScaleFactor(Vector3 meshSize, float lossyScale, float lengthRatio, float height)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(meshSize.x, Mathf.Max(meshSize.y, meshSize.z)) * lossyScale;
			if (!(num > 1E-05f))
			{
				return 1f;
			}
			return lengthRatio * height / num;
		}

		public static Vector3 LogOffsetRatio(Vector3 offsetRatio, Vector3 extraOffset, float height)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return offsetRatio + extraOffset / Mathf.Max(0.0001f, height);
		}

		public static float FlipStep(Vector3 last, Vector3 now)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!(last == Vector3.zero))
			{
				return Vector3.Angle(last, now);
			}
			return 0f;
		}

		public static bool IsJump(float stepDeg)
		{
			return stepDeg > 45f;
		}

		public static float PairOffset(float width, float gap)
		{
			return width * 0.5f + gap * 0.5f;
		}

		public static int NearestK(Vector3 p, Vector3[] pts, int k, int[] idx, float[] dist)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			int num = 0;
			if (pts == null || k <= 0)
			{
				return 0;
			}
			for (int i = 0; i < pts.Length; i++)
			{
				Vector3 val = pts[i] - p;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				if (num != k || !(sqrMagnitude >= dist[num - 1]))
				{
					int num2 = ((num < k) ? num++ : (num - 1));
					while (num2 > 0 && dist[num2 - 1] > sqrMagnitude)
					{
						dist[num2] = dist[num2 - 1];
						idx[num2] = idx[num2 - 1];
						num2--;
					}
					dist[num2] = sqrMagnitude;
					idx[num2] = i;
				}
			}
			for (int j = 0; j < num; j++)
			{
				dist[j] = Mathf.Sqrt(dist[j]);
			}
			return num;
		}

		public static int BlendWeights(BoneWeight[] src, int[] idx, float[] dist, int count, int[] bones, float[] weights)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			int[] array = new int[count * 4];
			float[] array2 = new float[count * 4];
			int num = 0;
			for (int i = 0; i < count; i++)
			{
				BoneWeight val = src[idx[i]];
				float num2 = 1f / (dist[i] + 0.002f);
				num = AddWeight(array, array2, num, ((BoneWeight)(ref val)).boneIndex0, ((BoneWeight)(ref val)).weight0 * num2);
				num = AddWeight(array, array2, num, ((BoneWeight)(ref val)).boneIndex1, ((BoneWeight)(ref val)).weight1 * num2);
				num = AddWeight(array, array2, num, ((BoneWeight)(ref val)).boneIndex2, ((BoneWeight)(ref val)).weight2 * num2);
				num = AddWeight(array, array2, num, ((BoneWeight)(ref val)).boneIndex3, ((BoneWeight)(ref val)).weight3 * num2);
			}
			int j = 0;
			float num3 = 0f;
			for (int num4 = Mathf.Min(4, bones.Length); j < num4; j++)
			{
				int num5 = -1;
				for (int k = 0; k < num; k++)
				{
					if (array2[k] > 0f && (num5 < 0 || array2[k] > array2[num5]))
					{
						num5 = k;
					}
				}
				if (num5 < 0)
				{
					break;
				}
				bones[j] = array[num5];
				weights[j] = array2[num5];
				num3 += array2[num5];
				array2[num5] = 0f;
			}
			for (int l = 0; l < j; l++)
			{
				weights[l] /= num3;
			}
			return j;
		}

		private static int AddWeight(int[] ids, float[] sums, int m, int bone, float w)
		{
			if (w <= 0f)
			{
				return m;
			}
			for (int i = 0; i < m; i++)
			{
				if (ids[i] == bone)
				{
					sums[i] += w;
					return m;
				}
			}
			ids[m] = bone;
			sums[m] = w;
			return m + 1;
		}

		public static int StrongestBone(BoneWeight w)
		{
			int result = ((BoneWeight)(ref w)).boneIndex0;
			float num = ((BoneWeight)(ref w)).weight0;
			if (((BoneWeight)(ref w)).weight1 > num)
			{
				result = ((BoneWeight)(ref w)).boneIndex1;
				num = ((BoneWeight)(ref w)).weight1;
			}
			if (((BoneWeight)(ref w)).weight2 > num)
			{
				result = ((BoneWeight)(ref w)).boneIndex2;
				num = ((BoneWeight)(ref w)).weight2;
			}
			if (((BoneWeight)(ref w)).weight3 > num)
			{
				result = ((BoneWeight)(ref w)).boneIndex3;
			}
			return result;
		}

		public static bool FrameAxes(Vector3 a, Vector3 b, Vector3 c, out Vector3 forward, out Vector3 up)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			forward = b - a;
			up = Vector3.Cross(forward, c - a);
			if (((Vector3)(ref forward)).sqrMagnitude < 1E-12f || ((Vector3)(ref up)).sqrMagnitude < 1E-12f)
			{
				forward = Vector3.forward;
				up = Vector3.up;
				return false;
			}
			((Vector3)(ref forward)).Normalize();
			((Vector3)(ref up)).Normalize();
			return true;
		}

		public static Quaternion SafeFrame(Quaternion skinFrame, Quaternion footFrame, float maxDegrees, out bool usedFoot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			usedFoot = Quaternion.Angle(skinFrame, footFrame) > maxDegrees;
			if (!usedFoot)
			{
				return skinFrame;
			}
			return footFrame;
		}

		public static bool ShouldRebind(float tiltedSeconds, float afterSeconds, bool grounded, float speed, float stillSpeed, bool settling)
		{
			if (settling || !grounded)
			{
				return false;
			}
			if (tiltedSeconds < afterSeconds)
			{
				return false;
			}
			return speed <= stillSpeed;
		}

		public static Vector3 UprightForward(Vector3 socketForward, Vector3 up, Vector3 fallback)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			((Vector3)(ref up)).Normalize();
			Vector3 val = Vector3.ProjectOnPlane(socketForward, up);
			if (((Vector3)(ref val)).sqrMagnitude < 1E-06f)
			{
				val = Vector3.ProjectOnPlane(fallback, up);
			}
			if (((Vector3)(ref val)).sqrMagnitude < 1E-06f)
			{
				val = Vector3.ProjectOnPlane(Vector3.forward, up);
			}
			if (((Vector3)(ref val)).sqrMagnitude < 1E-06f)
			{
				val = Vector3.ProjectOnPlane(Vector3.right, up);
			}
			return ((Vector3)(ref val)).normalized;
		}

		public static Vector3 StepHeading(Vector3 prev, Vector3 target, float maxDegrees, Vector3 up)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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)
			//IL_004e: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (((Vector3)(ref prev)).sqrMagnitude < 1E-06f)
			{
				return target;
			}
			float num = Vector3.SignedAngle(prev, target, up);
			if (Mathf.Abs(num) <= maxDegrees)
			{
				return target;
			}
			float num2 = Mathf.Sign(num) * maxDegrees * ((float)Math.PI / 180f);
			float num3 = Mathf.Cos(num2);
			float num4 = Mathf.Sin(num2);
			Vector3 normalized = ((Vector3)(ref up)).normalized;
			return prev * num3 + Vector3.Cross(normalized, prev) * num4 + normalized * (Vector3.Dot(normalized, prev) * (1f - num3));
		}

		public static Vector3 LeanUp(Vector3 playerUp, Vector3 socketUp, float maxDegrees)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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)
			((Vector3)(ref playerUp)).Normalize();
			if (((Vector3)(ref socketUp)).sqrMagnitude < 1E-06f)
			{
				return playerUp;
			}
			((Vector3)(ref socketUp)).Normalize();
			if (Mathf.Acos(Mathf.Clamp(Vector3.Dot(playerUp, socketUp), -1f, 1f)) * 57.29578f <= maxDegrees)
			{
				return socketUp;
			}
			Vector3 val = Vector3.Cross(playerUp, socketUp);
			if (((Vector3)(ref val)).sqrMagnitude < 1E-08f)
			{
				return playerUp;
			}
			((Vector3)(ref val)).Normalize();
			float num = maxDegrees * ((float)Math.PI / 180f);
			float num2 = Mathf.Cos(num);
			float num3 = Mathf.Sin(num);
			Vector3 val2 = playerUp * num2 + Vector3.Cross(val, playerUp) * num3 + val * (Vector3.Dot(val, playerUp) * (1f - num2));
			return ((Vector3)(ref val2)).normalized;
		}

		public static bool WithinMeters(Vector3 a, Vector3 b, float maxMeters)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = a - b;
			return ((Vector3)(ref val)).sqrMagnitude <= maxMeters * maxMeters;
		}

		public static Vector3 BoxCorner(Bounds b, int i)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			return ((Bounds)(ref b)).center + Vector3.Scale(((Bounds)(ref b)).extents, new Vector3(((i & 1) == 0) ? (-1f) : 1f, ((i & 2) == 0) ? (-1f) : 1f, ((i & 4) == 0) ? (-1f) : 1f));
		}
	}
	public sealed class SkinTransfer : IDisposable
	{
		public const int Neighbours = 4;

		private readonly HashSet<Transform> _allowed;

		private readonly SkinnedMeshRenderer _body;

		private readonly int[] _boneIdx = new int[4];

		private readonly float[] _dist = new float[4];

		private readonly int[] _idx = new int[4];

		private Mesh _bake;

		private Transform[] _bones = (Transform[])(object)new Transform[0];

		private Vector3[] _pos = (Vector3[])(object)new Vector3[0];

		private BoneWeight[] _weights = (BoneWeight[])(object)new BoneWeight[0];

		public int Count => _pos.Length;

		public SkinTransfer(SkinnedMeshRenderer body, IEnumerable<Transform> allowedBones)
		{
			_body = body;
			_allowed = new HashSet<Transform>();
			if (allowedBones == null)
			{
				return;
			}
			foreach (Transform allowedBone in allowedBones)
			{
				if ((Object)(object)allowedBone != (Object)null)
				{
					_allowed.Add(allowedBone);
				}
			}
		}

		public int Refresh()
		{
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0108: 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_00c1: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			_pos = (Vector3[])(object)new Vector3[0];
			if ((Object)(object)_body == (Object)null || (Object)(object)_body.sharedMesh == (Object)null || _allowed.Count == 0)
			{
				TrollFitMath.Warn("SkinTransfer: no body mesh or no allowed bones - slipper falls back to foot + toe weights");
				return 0;
			}
			BoneWeight[] boneWeights = _body.sharedMesh.boneWeights;
			_bones = _body.bones;
			if (boneWeights.Length == 0 || _bones == null || _bones.Length == 0)
			{
				TrollFitMath.Warn("SkinTransfer: body '" + ((Object)_body).name + "' has no bone weights");
				return 0;
			}
			if ((Object)(object)_bake == (Object)null)
			{
				_bake = new Mesh();
			}
			_body.BakeMesh(_bake);
			Vector3[] vertices = _bake.vertices;
			Matrix4x4 val = Matrix4x4.TRS(((Component)_body).transform.position, ((Component)_body).transform.rotation, Vector3.one);
			List<Vector3> list = new List<Vector3>();
			List<BoneWeight> list2 = new List<BoneWeight>();
			for (int i = 0; i < vertices.Length && i < boneWeights.Length; i++)
			{
				int num = FitGeometry.StrongestBone(boneWeights[i]);
				if (num >= 0 && num < _bones.Length && _allowed.Contains(_bones[num]))
				{
					list.Add(((Matrix4x4)(ref val)).MultiplyPoint3x4(vertices[i]));
					list2.Add(boneWeights[i]);
				}
			}
			_pos = list.ToArray();
			_weights = list2.ToArray();
			TrollFitMath.Log("SkinTransfer: " + ((Object)_body).name + " " + vertices.Length + " verts, " + _pos.Length + " on " + _allowed.Count + " allowed bone(s)");
			return _pos.Length;
		}

		public int WeightsAt(Vector3 world, Transform[] bones, float[] weights)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			int count = FitGeometry.NearestK(world, _pos, 4, _idx, _dist);
			int num = FitGeometry.BlendWeights(_weights, _idx, _dist, count, _boneIdx, weights);
			for (int i = 0; i < num; i++)
			{
				bones[i] = ((_boneIdx[i] >= 0 && _boneIdx[i] < _bones.Length) ? _bones[_boneIdx[i]] : null);
			}
			return num;
		}

		public SkinPoint PointAt(Vector3 world)
		{
			//IL_000f: 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)
			Transform[] bones = (Transform[])(object)new Transform[4];
			float[] weights = new float[4];
			int num = WeightsAt(world, bones, weights);
			if (num <= 0)
			{
				return null;
			}
			return new SkinPoint(world, bones, weights, num);
		}

		public void Dispose()
		{
			if ((Object)(object)_bake != (Object)null)
			{
				if (Application.isPlaying)
				{
					Object.Destroy((Object)(object)_bake);
				}
				else
				{
					Object.DestroyImmediate((Object)(object)_bake);
				}
			}
			_bake = null;
		}
	}
	public sealed class SkinPoint
	{
		private readonly Transform[] _bones;

		private readonly Vector3[] _local;

		private readonly float[] _w;

		public int BoneCount => _bones.Length;

		public Vector3 Position
		{
			get
			{
				//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_0056: 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_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = Vector3.zero;
				for (int i = 0; i < _bones.Length; i++)
				{
					if ((Object)(object)_bones[i] != (Object)null)
					{
						val += _bones[i].TransformPoint(_local[i]) * _w[i];
					}
				}
				return val;
			}
		}

		public SkinPoint(Vector3 world, Transform[] bones, float[] weights, int count)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			List<Transform> list = new List<Transform>();
			List<Vector3> list2 = new List<Vector3>();
			List<float> list3 = new List<float>();
			float num = 0f;
			for (int i = 0; i < count; i++)
			{
				if (!((Object)(object)bones[i] == (Object)null) && !(weights[i] <= 0f))
				{
					list.Add(bones[i]);
					list2.Add(bones[i].InverseTransformPoint(world));
					list3.Add(weights[i]);
					num += weights[i];
				}
			}
			for (int j = 0; j < list3.Count; j++)
			{
				list3[j] /= num;
			}
			_bones = list.ToArray();
			_local = list2.ToArray();
			_w = list3.ToArray();
		}
	}
	public static class SlipperFit
	{
		public sealed class Part
		{
			public string Name;

			public SkinnedMeshRenderer Renderer;

			public int ToeWeighted;
		}

		public const float BlendWidth = 0.03f;

		public const string RootName = "SteveTheTroll_Slipper";

		public const string SocketName = "TrollSocket";

		public static readonly Quaternion MeshToFoot = Quaternion.Euler(0f, 180f, 0f);

		public static List<Part> Build([NotNull] GameObject partsPrefab, [NotNull] Transform parent, [NotNull] Transform foot, [NotNull] Transform toe, Vector3 playerForward, bool left, float forward, float side, float up, float yawDeg, float scale, out Transform root)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)partsPrefab == (Object)null)
			{
				throw new ArgumentNullException("partsPrefab");
			}
			if ((Object)(object)parent == (Object)null)
			{
				throw new ArgumentNullException("parent");
			}
			if ((Object)(object)foot == (Object)null)
			{
				throw new ArgumentNullException("foot");
			}
			if ((Object)(object)toe == (Object)null)
			{
				throw new ArgumentNullException("toe");
			}
			return Build(partsPrefab, parent, foot, toe, playerForward, left, forward, side, up, yawDeg, scale, 1f, null, out root);
		}

		public static List<Part> Build(GameObject partsPrefab, Transform parent, Transform foot, Transform toe, Vector3 playerForward, bool left, float forward, float side, float up, float yawDeg, float scale, float width, SkinTransfer skin, out Transform root)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_007c: 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_0083: 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_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_00a1: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			List<Part> list = new List<Part>();
			root = null;
			if ((Object)(object)partsPrefab == (Object)null || (Object)(object)foot == (Object)null)
			{
				TrollFitMath.Warn("SlipperFit: Build without " + (((Object)(object)partsPrefab == (Object)null) ? "parts prefab" : "foot"));
				return list;
			}
			GameObject val = new GameObject("SteveTheTroll_Slipper" + (left ? "_L" : "_R"));
			root = val.transform;
			root.SetParent(parent, false);
			Vector3 val2 = TrollFitMath.FootForward(foot, toe, playerForward);
			Vector3 val3 = FitGeometry.FootFramePosition(foot.position, val2, left, forward, side, up, 0f);
			root.SetPositionAndRotation(val3, Quaternion.Euler(0f, FitGeometry.FigureYawDeg(val2, yawDeg), 0f) * MeshToFoot);
			root.localScale = new Vector3(scale * width, scale, scale);
			bool flag = skin != null && skin.Count > 0;
			MeshFilter[] componentsInChildren = partsPrefab.GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val4 in componentsInChildren)
			{
				MeshRenderer component = ((Component)val4).GetComponent<MeshRenderer>();
				if (!((Object)(object)val4.sharedMesh == (Object)null) && !((Object)(object)component == (Object)null))
				{
					list.Add(BuildPart(root, val4, component, foot, toe, val2, flag ? skin : null));
				}
			}
			AddSocket(partsPrefab, root);
			TrollFitMath.Log("SlipperFit: " + ((Object)root).name + " at " + ((Vector3)(ref val3)).ToString("F3") + ", foot forward " + ((Vector3)(ref val2)).ToString("F2") + ", scale " + scale.ToString("F2") + " x width " + width.ToString("F2") + ", weights from " + (flag ? ("the player's skin (" + skin.Count + " source verts)") : "foot + toe") + ", " + list.Count + " part(s): " + string.Join(", ", list.ConvertAll((Part p) => p.Name + " (" + p.ToeWeighted + " toe verts, " + p.Renderer.bones.Length + " bones)").ToArray()));
			return list;
		}

		private static void AddSocket(GameObject partsPrefab, Transform root)
		{
			//IL_003a: 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)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Transform val = FindSocket(partsPrefab.transform);
			if ((Object)(object)val == (Object)null)
			{
				TrollFitMath.Warn("SlipperFit: prefab '" + ((Object)partsPrefab).name + "' has no 'TrollSocket' child - the troll has no anchor (rebuild the bundle)");
				return;
			}
			Transform transform = new GameObject("TrollSocket").transform;
			transform.SetParent(root, false);
			transform.localPosition = val.localPosition;
			transform.localRotation = val.localRotation;
			Action<string> log = TrollFitMath.Log;
			string[] obj = new string[6]
			{
				"SlipperFit: ",
				((Object)root).name,
				" socket at ",
				null,
				null,
				null
			};
			Vector3 val2 = transform.position;
			obj[3] = ((Vector3)(ref val2)).ToString("F3");
			obj[4] = ", faces ";
			val2 = transform.forward;
			obj[5] = ((Vector3)(ref val2)).ToString("F2");
			log(string.Concat(obj));
		}

		private static Transform FindSocket(Transform t)
		{
			Transform[] componentsInChildren = ((Component)t).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name == "TrollSocket")
				{
					return val;
				}
			}
			return null;
		}

		private static Part BuildPart(Transform root, MeshFilter mf, MeshRenderer mr, Transform foot, Transform toe, Vector3 fwd, SkinTransfer skin)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0025: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(((Object)mf).name);
			val.transform.SetParent(root, false);
			val.transform.localPosition = ((Component)mf).transform.localPosition;
			val.transform.localRotation = ((Component)mf).transform.localRotation;
			val.transform.localScale = ((Component)mf).transform.localScale;
			Mesh val2 = Object.Instantiate<Mesh>(mf.sharedMesh);
			((Object)val2).name = ((Object)mf.sharedMesh).name + "_skinned";
			Vector3[] vertices = val2.vertices;
			Matrix4x4 localToWorldMatrix = val.transform.localToWorldMatrix;
			List<Transform> list = new List<Transform> { foot };
			if (skin == null && (Object)(object)toe != (Object)null)
			{
				list.Add(toe);
			}
			BoneWeight[] array = ((skin != null) ? FromSkin(vertices, localToWorldMatrix, skin, list) : FootAndToe(vertices, localToWorldMatrix, toe, fwd));
			int num = (((Object)(object)toe != (Object)null) ? list.IndexOf(toe) : (-1));
			int num2 = 0;
			for (int i = 0; i < array.Length; i++)
			{
				if (num >= 0 && Weight(array[i], num) > 0.5f)
				{
					num2++;
				}
			}
			Matrix4x4[] array2 = (Matrix4x4[])(object)new Matrix4x4[list.Count];
			for (int j = 0; j < list.Count; j++)
			{
				array2[j] = list[j].worldToLocalMatrix * localToWorldMatrix;
			}
			val2.boneWeights = array;
			val2.bindposes = array2;
			SkinnedMeshRenderer val3 = val.AddComponent<SkinnedMeshRenderer>();
			val3.sharedMesh = val2;
			val3.bones = list.ToArray();
			val3.rootBone = foot;
			((Renderer)val3).sharedMaterials = ((Renderer)mr).sharedMaterials;
			val3.updateWhenOffscreen = true;
			return new Part
			{
				Name = ((Object)mf).name,
				Renderer = val3,
				ToeWeighted = num2
			};
		}

		private static BoneWeight[] FootAndToe(Vector3[] verts, Matrix4x4 toPart, Transform toe, Vector3 fwd)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			BoneWeight[] array = (BoneWeight[])(object)new BoneWeight[verts.Length];
			for (int i = 0; i < verts.Length; i++)
			{
				float num = (((Object)(object)toe != (Object)null) ? FitGeometry.ToeWeight(FitGeometry.ToeAlong(((Matrix4x4)(ref toPart)).MultiplyPoint3x4(verts[i]), toe.position, fwd)) : 0f);
				int num2 = i;
				BoneWeight val = default(BoneWeight);
				((BoneWeight)(ref val)).boneIndex0 = 0;
				((BoneWeight)(ref val)).weight0 = 1f - num;
				((BoneWeight)(ref val)).boneIndex1 = (((Object)(object)toe != (Object)null) ? 1 : 0);
				((BoneWeight)(ref val)).weight1 = num;
				array[num2] = val;
			}
			return array;
		}

		private static BoneWeight[] FromSkin(Vector3[] verts, Matrix4x4 toPart, SkinTransfer skin, List<Transform> bones)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			BoneWeight[] array = (BoneWeight[])(object)new BoneWeight[verts.Length];
			Transform[] array2 = (Transform[])(object)new Transform[4];
			float[] array3 = new float[4];
			int[] array4 = new int[4];
			for (int i = 0; i < verts.Length; i++)
			{
				int num = skin.WeightsAt(((Matrix4x4)(ref toPart)).MultiplyPoint3x4(verts[i]), array2, array3);
				BoneWeight val;
				if (num == 0)
				{
					int num2 = i;
					val = default(BoneWeight);
					((BoneWeight)(ref val)).boneIndex0 = 0;
					((BoneWeight)(ref val)).weight0 = 1f;
					array[num2] = val;
					continue;
				}
				Array.Clear(array4, 0, array4.Length);
				for (int j = 0; j < 4; j++)
				{
					if (j >= num)
					{
						array3[j] = 0f;
					}
					else if (!((Object)(object)array2[j] == (Object)null))
					{
						int num3 = bones.IndexOf(array2[j]);
						if (num3 < 0)
						{
							bones.Add(array2[j]);
							num3 = bones.Count - 1;
						}
						array4[j] = num3;
					}
				}
				int num4 = i;
				val = default(BoneWeight);
				((BoneWeight)(ref val)).boneIndex0 = array4[0];
				((BoneWeight)(ref val)).weight0 = array3[0];
				((BoneWeight)(ref val)).boneIndex1 = array4[1];
				((BoneWeight)(ref val)).weight1 = array3[1];
				((BoneWeight)(ref val)).boneIndex2 = array4[2];
				((BoneWeight)(ref val)).weight2 = array3[2];
				((BoneWeight)(ref val)).boneIndex3 = array4[3];
				((BoneWeight)(ref val)).weight3 = array3[3];
				array[num4] = val;
			}
			return array;
		}

		private static float Weight(BoneWeight w, int bone)
		{
			float num = 0f;
			if (((BoneWeight)(ref w)).boneIndex0 == bone)
			{
				num += ((BoneWeight)(ref w)).weight0;
			}
			if (((BoneWeight)(ref w)).boneIndex1 == bone)
			{
				num += ((BoneWeight)(ref w)).weight1;
			}
			if (((BoneWeight)(ref w)).boneIndex2 == bone)
			{
				num += ((BoneWeight)(ref w)).weight2;
			}
			if (((BoneWeight)(ref w)).boneIndex3 == bone)
			{
				num += ((BoneWeight)(ref w)).weight3;
			}
			return num;
		}
	}
	public static class TrollFitData
	{
		public const string SavedAt = "2026-10-27 16:12";

		public const float Height = 0.28f;

		public const float Forward = 0.19818f;

		public const float Side = 0.004f;

		public const float Up = -0.09495f;

		public const float Yaw = 0f;

		public const float SlipperForward = 0.09727f;

		public const float SlipperUp = -0.134f;

		public const float SlipperSide = 0.00909f;

		public const float SlipperYaw = 2.63637f;

		public const float SlipperScale = 1.1f;

		public const float SlipperWidth = 1.05394f;

		public const float LogLength = 0.55f;

		public static readonly float[] LogOffset = new float[3] { -0.05071f, -0.00696f, 0.17099f };

		public static readonly float[] LogEuler = new float[3] { 327.5392f, 305.5487f, 349.9485f };

		public static readonly float[] Delta = new float[172]
		{
			0f, 0f, 0f, 1f, 0.12187f, 0f, 0f, 0.99255f, 0.08716f, 0f,
			0f, -0.99619f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f,
			0.1712f, 0.02646f, 0.76194f, 0.62405f, -0.00228f, -0.0284f, -0.70653f, -0.70711f, 0f, 0f,
			0f, 1f, 0.1712f, -0.02646f, -0.76194f, 0.62405f, -0.00228f, 0.0284f, 0.70653f, -0.70711f,
			0f, 0f, 0f, 1f, -0.02937f, -0.00812f, 0.11738f, -0.99262f, -0.26596f, -0.03832f,
			0.3683f, 0.89003f, -0.0547f, 0.05722f, 0.77536f, 0.62654f, 0.15249f, -0.15371f, -0.04549f, -0.97522f,
			0f, 0f, 0f, 1f, -0.49438f, -0.17425f, -0.35735f, 0.773f, 0.03844f, 0.0374f,
			0.25582f, -0.96524f, 0.02738f, 0.71695f, -0.30196f, -0.62774f, -0.29995f, -0.00079f, -0.02125f, 0.95372f,
			0.29079f, -0.0377f, -0.06667f, -0.95372f, -0.29348f, 0.01729f, 0.06319f, 0.95372f, 0.29642f, -0.01614f,
			-0.04797f, -0.95372f, 0.29313f, -0.02363f, -0.06276f, -0.95372f, -0.29406f, 0.01718f, 0.06047f, 0.95372f,
			-0.26771f, 0.01742f, 0.13584f, 0.95372f, -0.29451f, -0.01294f, 0.05933f, 0.95372f, -0.29406f, 0.00496f,
			0.06265f, 0.95372f, -0.67319f, 0.2995f, -0.08927f, 0.67019f, 0f, 0f, 0f, 1f,
			0f, 0f, 0f, 1f, 0.05084f, -0.01998f, -0.02032f, -0.9983f, -0.21966f, -0.02009f,
			0.0587f, 0.9736f, -0.31661f, 0.01912f, 0.00476f, 0.94835f, 0.15685f, 0.00436f, 0.01153f, -0.98755f,
			-0.38189f, -0.01105f, 0.02267f, 0.92386f, -0.31879f, 0.00049f, 0.00675f, 0.9478f, 0.08871f, 0.00185f,
			0.00985f, -0.99601f, -0.36331f, 0.01573f, -0.01244f, 0.93145f, -0.39276f, -0.01289f, 0.00234f, 0.91955f,
			0.32441f, -0.03159f, -0.01089f, -0.94533f, -0.05292f, -0.03295f, 0.03451f, -0.99746f, -0.00344f, -0.02772f,
			0.08873f, -0.99566f
		};
	}
	public static class TrollFitMath
	{
		public const float MaxFootTurnDeg = 75f;

		public static Action<string> Log = delegate
		{
		};

		public static Action<string> Warn = delegate
		{
		};

		public static readonly string[] PosedBones = new string[43]
		{
			"Root", "Spine0", "Spine1", "Spine2", "Head", "LeftUpLeg", "LeftLeg", "LeftFoot", "RightUpLeg", "RightLeg",
			"RightFoot", "LeftShoulder", "LeftArm", "LeftForeArm", "LeftHand", "RightShoulder", "RightArm", "RightForeArm", "RightHand", "RightHandIndex1",
			"RightHandIndex2", "RightHandIndex3", "RightHandMiddle1", "RightHandMiddle2", "RightHandMiddle3", "RightHandRing1", "RightHandRing2", "RightHandRing3", "RightHandThumb1", "RightHandThumb2",
			"RightHandThumb3", "LeftHandIndex1", "LeftHandIndex2", "LeftHandIndex3", "LeftHandMiddle1", "LeftHandMiddle2", "LeftHandMiddle3", "LeftHandRing1", "LeftHandRing2", "LeftHandRing3",
			"LeftHandThumb1", "LeftHandThumb2", "LeftHandThumb3"
		};

		public static string ToeOf(string footBone)
		{
			return footBone.Replace("Foot", "ToeBase");
		}

		public static Vector3 Flat(Vector3 dir, Vector3 fallback)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return FitGeometry.Flat(dir, fallback);
		}

		public static Vector3 FootForward(Transform foot, Transform toe, Vector3 playerForward)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)foot == (Object)null || (Object)(object)toe == (Object)null)
			{
				return Flat(playerForward, Vector3.forward);
			}
			Vector3 shin = (((Object)(object)foot.parent != (Object)null) ? (foot.position - foot.parent.position) : Vector3.down);
			return FitGeometry.FootForward(toe.position - foot.position, shin, playerForward);
		}

		public static void Place(Vector3 footPos, Vector3 footForward, bool leftFoot, float forward, float side, float up, float yawDeg, float bottomBelowPivot, out Vector3 position, out Quaternion rotation)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			position = FitGeometry.FootFramePosition(footPos, footForward, leftFoot, forward, side, up, bottomBelowPivot);
			rotation = Quaternion.Euler(0f, FitGeometry.FigureYawDeg(footForward, yawDeg), 0f);
		}

		public static int ApplyPose(Transform[] bones, Quaternion[] rest, Quaternion[] delta, Quaternion[] extra)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			for (int i = 0; i < bones.Length; i++)
			{
				if (!((Object)(object)bones[i] == (Object)null))
				{
					Quaternion val = rest[i] * delta[i];
					if (extra != null && i < extra.Length)
					{
						val *= extra[i];
					}
					bones[i].localRotation = val;
					num++;
				}
			}
			return num;
		}

		public static bool MeasureY(SkinnedMeshRenderer body, Mesh scratch, out float minY, out float maxY)
		{
			//IL_0058: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			minY = float.MaxValue;
			maxY = float.MinValue;
			if ((Object)(object)body == (Object)null || (Object)(object)scratch == (Object)null)
			{
				Warn("TrollFitMath: MeasureY without " + (((Object)(object)body == (Object)null) ? "body" : "scratch mesh"));
				return false;
			}
			body.BakeMesh(scratch);
			Matrix4x4 val = Matrix4x4.TRS(((Component)body).transform.position, ((Component)body).transform.rotation, Vector3.one);
			Vector3[] vertices = scratch.vertices;
			for (int i = 0; i < vertices.Length; i++)
			{
				float y = ((Matrix4x4)(ref val)).MultiplyPoint3x4(vertices[i]).y;
				if (y < minY)
				{
					minY = y;
				}
				if (y > maxY)
				{
					maxY = y;
				}
			}
			Log("TrollFitMath: MeasureY " + ((Object)body).name + " " + vertices.Length + " verts, y " + minY.ToString("F3") + " .. " + maxY.ToString("F3") + " m");
			return vertices.Length != 0;
		}

		public static float PlaceLog(Transform logRoot, MeshFilter logMesh, Transform figure, Transform hand, float height, float lengthRatio, Vector3 offsetRatio, Vector3 euler)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return PlaceLog(logRoot, logMesh, figure, hand, height, lengthRatio, offsetRatio, euler, Vector3.zero, Quaternion.identity);
		}

		public static float PlaceLog(Transform logRoot, MeshFilter logMesh, Transform figure, Transform hand, float height, float lengthRatio, Vector3 offsetRatio, Vector3 euler, Vector3 extraOffset, Quaternion extraTurn)
		{
			//IL_0047: 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)
			//IL_004d: 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_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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b2: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ee: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)logRoot == (Object)null || (Object)(object)logMesh == (Object)null || (Object)(object)logMesh.sharedMesh == (Object)null || (Object)(object)figure == (Object)null || (Object)(object)hand == (Object)null)
			{
				Warn("TrollFitMath: PlaceLog missing a part");
				return 0f;
			}
			offsetRatio = FitGeometry.LogOffsetRatio(offsetRatio, extraOffset, height);
			logRoot.rotation = figure.rotation * extraTurn * Quaternion.Euler(euler);
			Bounds bounds = logMesh.sharedMesh.bounds;
			Vector3 size = ((Bounds)(ref bounds)).size;
			float num = Mathf.Max(size.x, Mathf.Max(size.y, size.z));
			logRoot.localScale *= FitGeometry.LogScaleFactor(size, ((Component)logMesh).transform.lossyScale.x, lengthRatio, height);
			Transform transform = ((Component)logMesh).transform;
			bounds = logMesh.sharedMesh.bounds;
			Vector3 val = transform.TransformPoint(((Bounds)(ref bounds)).center);
			Vector3 val2 = hand.position + figure.rotation * (offsetRatio * height);
			logRoot.position += val2 - val;
			float result = num * ((Component)logMesh).transform.lossyScale.x;
			Action<string> log = Log;
			string[] obj = new string[6]
			{
				"TrollFitMath: PlaceLog length ",
				result.ToString("F3"),
				" m (want ",
				(lengthRatio * height).ToString("F3"),
				"), lossy ",
				null
			};
			Vector3 lossyScale = ((Component)logMesh).transform.lossyScale;
			obj[5] = ((Vector3)(ref lossyScale)).ToString("F4");
			log(string.Concat(obj));
			return result;
		}

		public static Quaternion LogTurn(float yawDeg, float pitchDeg, float rollDeg)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			return Quaternion.AngleAxis(yawDeg, Vector3.up) * Quaternion.AngleAxis(pitchDeg, Vector3.right) * Quaternion.AngleAxis(rollDeg, Vector3.forward);
		}

		public static Vector3 KnuckleLine(Transform figure)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			Transform val = FindDeep(figure, "RightHandIndex1");
			Transform val2 = FindDeep(figure, "RightHandRing1");
			if (!((Object)(object)val != (Object)null) || !((Object)(object)val2 != (Object)null))
			{
				return Vector3.zero;
			}
			Vector3 val3 = val2.position - val.position;
			return ((Vector3)(ref val3)).normalized;
		}

		public static SkinnedMeshRenderer FindBody(Transform root)
		{
			SkinnedMeshRenderer val = null;
			SkinnedMeshRenderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val2 in componentsInChildren)
			{
				if ((Object)(object)val2.sharedMesh != (Object)null && ((Object)(object)val == (Object)null || val2.sharedMesh.vertexCount > val.sharedMesh.vertexCount))
				{
					val = val2;
				}
			}
			return val;
		}

		public static Transform FindDeep(Transform root, string name)
		{
			if (((Object)root).name == name)
			{
				return root;
			}
			for (int i = 0; i < root.childCount; i++)
			{
				Transform val = FindDeep(root.GetChild(i), name);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}
	}
	public static class TrollFur
	{
		public const string ShellPrefix = "FurShell_";

		public static List<SkinnedMeshRenderer> AddShells(SkinnedMeshRenderer body, Material template, int shells)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>();
			if ((Object)(object)body == (Object)null || (Object)(object)template == (Object)null || shells <= 0)
			{
				TrollFitMath.Warn("TrollFur: AddShells without " + (((Object)(object)body == (Object)null) ? "body" : (((Object)(object)template == (Object)null) ? "fur material" : "shells")));
				return list;
			}
			Texture val = (((Object)(object)((Renderer)body).sharedMaterial != (Object)null && ((Renderer)body).sharedMaterial.HasProperty("_MainTex")) ? ((Renderer)body).sharedMaterial.GetTexture("_MainTex") : null);
			for (int i = 1; i <= shells; i++)
			{
				GameObject val2 = new GameObject("FurShell_" + i)
				{
					layer = ((Component)body).gameObject.layer
				};
				val2.transform.SetParent(((Component)body).transform.parent, false);
				val2.transform.localPosition = ((Component)body).transform.localPosition;
				val2.transform.localRotation = ((Component)body).transform.localRotation;
				val2.transform.localScale = ((Component)body).transform.localScale;
				SkinnedMeshRenderer val3 = val2.AddComponent<SkinnedMeshRenderer>();
				val3.sharedMesh = body.sharedMesh;
				val3.bones = body.bones;
				val3.rootBone = body.rootBone;
				((Renderer)val3).localBounds = ((Renderer)body).localBounds;
				val3.updateWhenOffscreen = body.updateWhenOffscreen;
				((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0;
				Material val4 = new Material(template)
				{
					name = "TrollFur_" + i
				};
				if ((Object)(object)val != (Object)null)
				{
					val4.SetTexture("_MainTex", val);
				}
				val4.SetFloat("_Shell", (float)i / (float)shells);
				((Renderer)val3).sharedMaterial = val4;
				list.Add(val3);
			}
			TrollFitMath.Log("TrollFur: " + list.Count + " shell(s) on " + ((Object)body).name + " (" + body.sharedMesh.vertexCount + " verts each), albedo " + (((Object)(object)val != (Object)null) ? ((Object)val).name : "none"));
			return list;
		}

		public static Material MakePlush(SkinnedMeshRenderer body, Material template, Color tint, float smoothness)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)body == (Object)null || (Object)(object)template == (Object)null)
			{
				TrollFitMath.Warn("TrollFur: MakePlush without " + (((Object)(object)body == (Object)null) ? "body" : "material"));
				return null;
			}
			Texture val = (((Object)(object)((Renderer)body).sharedMaterial != (Object)null && ((Renderer)body).sharedMaterial.HasProperty("_MainTex")) ? ((Renderer)body).sharedMaterial.GetTexture("_MainTex") : null);
			Material val2 = new Material(template)
			{
				name = "TrollPlush"
			};
			if ((Object)(object)val != (Object)null)
			{
				val2.SetTexture("_MainTex", val);
			}
			val2.SetFloat("_Shell", 0f);
			val2.SetFloat("_Occlusion", 0f);
			SetPlush(val2, tint, smoothness);
			TrollFitMath.Log("TrollFur: plush material for " + ((Object)body).name + ", albedo " + (((Object)(object)val != (Object)null) ? ((Object)val).name : "none"));
			return val2;
		}

		public static bool SetPlush(Material m, Color tint, float smoothness)
		{
			//IL_0011: 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)
			if ((Object)(object)m == (Object)null)
			{
				return false;
			}
			m.SetColor("_Color", tint);
			m.SetFloat("_Glossiness", smoothness);
			return m.GetColor("_Color") == tint;
		}

		public static int Apply(List<SkinnedMeshRenderer> shells, float lengthM, float density, float thickness, float gravityM, Color tint, Color tip)
		{
			//IL_0067: 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)
			int num = 0;
			foreach (SkinnedMeshRenderer shell in shells)
			{
				if (!((Object)(object)shell == (Object)null) && !((Object)(object)((Renderer)shell).sharedMaterial == (Object)null))
				{
					Material sharedMaterial = ((Renderer)shell).sharedMaterial;
					sharedMaterial.SetFloat("_FurLength", lengthM);
					sharedMaterial.SetFloat("_Density", density);
					sharedMaterial.SetFloat("_Thickness", thickness);
					sharedMaterial.SetFloat("_Gravity", gravityM);
					sharedMaterial.SetColor("_Color", tint);
					sharedMaterial.SetColor("_TipColor", tip);
					num++;
				}
			}
			TrollFitMath.Log("TrollFur: Apply length " + lengthM.ToString("F4") + " m, density " + density.ToString("F0") + ", thickness " + thickness.ToString("F2") + ", droop " + gravityM.ToString("F4") + " m on " + num + " shell(s)");
			return num;
		}
	}
}
namespace SteveTheTroll.Ui
{
	internal sealed class CostumeData
	{
		internal sealed class Piece
		{
			internal readonly List<SlipperData.Ingredient> Recipe = new List<SlipperData.Ingredient>();

			internal float Armor;

			internal float ArmorPerLevel;

			internal int MaxQuality = 1;

			internal string Name = "";

			internal string SlotKey = "";

			internal int WornQuality;

			public override string ToString()
			{
				return Name + " (armor " + Armor + " +" + ArmorPerLevel + "/q, max q" + MaxQuality + ", worn q" + WornQuality + ", recipe " + Recipe.Count + ")";
			}
		}

		internal readonly List<SlipperData.Ingredient> ClubRecipe = new List<SlipperData.Ingredient>();

		internal readonly List<Piece> Pieces = new List<Piece>();

		internal readonly List<string> SetEffects = new List<string>();

		internal float ClubBlunt;

		internal float ClubChop;

		internal float ClubPickaxe;

		internal float ClubBluntPerLevel;

		internal float ClubChopPerLevel;

		internal float ClubPickaxePerLevel;

		internal string ClubDescription = "";

		internal int ClubMaxQuality = 1;

		internal string ClubName = "";

		internal string SetDescription = "";

		internal string SetName = "";

		internal int SetSize = 4;

		internal int SetWorn;

		internal string Station = "";

		internal int StationLevel = 1;

		internal static CostumeData Sample()
		{
			CostumeData costumeData = new CostumeData
			{
				SetName = "Steve The Troll",
				SetDescription = "The troll rush runs through your whole body.",
				SetWorn = 3,
				ClubName = "Troll Club",
				ClubDescription = "A whole tree trunk with a rope grip.",
				ClubBlunt = 150f,
				ClubChop = 50f,
				ClubPickaxe = 50f,
				ClubBluntPerLevel = 35f,
				ClubChopPerLevel = 20f,
				ClubPickaxePerLevel = 20f,
				ClubMaxQuality = 4,
				Station = "Workbench",
				StationLevel = 1
			};
			string[][] array = new string[3][]
			{
				new string[2] { "Troll Mascot Head", "stevethetroll_details_slot_helmet" },
				new string[2] { "Troll Mascot Suit", "stevethetroll_details_slot_chest" },
				new string[2] { "Troll Mascot Trousers", "stevethetroll_details_slot_legs" }
			};
			foreach (string[] array2 in array)
			{
				Piece piece = new Piece
				{
					Name = array2[0],
					SlotKey = array2[1],
					Armor = 20f,
					ArmorPerLevel = 5f,
					MaxQuality = 4,
					WornQuality = ((!array2[0].EndsWith("Head")) ? 1 : 0)
				};
				piece.Recipe.Add(new SlipperData.Ingredient("Troll hide", 5, 2));
				piece.Recipe.Add(new SlipperData.Ingredient("Deer hide", 4, 0));
				piece.Recipe.Add(new SlipperData.Ingredient("Blueberries", 6, 2));
				costumeData.Pieces.Add(piece);
			}
			costumeData.SetEffects.Add("+50 % movement speed");
			costumeData.SetEffects.Add("+25 % carry weight");
			costumeData.SetEffects.Add("-50 % stamina use");
			costumeData.SetEffects.Add("Up to 5 tamed trolls");
			costumeData.SetEffects.Add("-75 % stagger");
			costumeData.ClubRecipe.Add(new SlipperData.Ingredient("Core wood", 15, 5));
			costumeData.ClubRecipe.Add(new SlipperData.Ingredient("Fine wood", 15, 5));
			costumeData.ClubRecipe.Add(new SlipperData.Ingredient("Thistle", 10, 0));
			costumeData.ClubRecipe.Add(new SlipperData.Ingredient("Troll hide", 2, 0));
			return costumeData;
		}

		public override string ToString()
		{
			return "costume " + Pieces.Count + " piece(s), set '" + SetName + "' " + SetWorn + "/" + SetSize + " worn, " + SetEffects.Count + " effect(s), club '" + ClubName + "' " + ClubBlunt + "/" + ClubChop + "/" + ClubPickaxe;
		}
	}
	internal static class CostumeDetailsBuilder
	{
		internal static List<DetailGroup> Build(CostumeData d, Func<string, string> text)
		{
			List<DetailGroup> list = new List<DetailGroup>();
			if (d == null || text == null)
			{
				return list;
			}
			DetailGroup detailGroup = new DetailGroup(text("stevethetroll_details_set") + ": " + d.SetName);
			detailGroup.Add(text("stevethetroll_details_set_worn"), d.SetWorn.ToString(CultureInfo.InvariantCulture) + " / " + d.SetSize.ToString(CultureInfo.InvariantCulture) + ((d.SetWorn >= d.SetSize) ? (" - " + text("stevethetroll_details_set_active")) : ""));
			detailGroup.Add(text("stevethetroll_details_set_effects"), (d.SetEffects.Count > 0) ? string.Join(", ", d.SetEffects.ToArray()) : "-");
			list.Add(detailGroup);
			foreach (CostumeData.Piece piece in d.Pieces)
			{
				int num = Math.Max(1, piece.MaxQuality);
				DetailGroup detailGroup2 = new DetailGroup(piece.Name);
				detailGroup2.Add(text("stevethetroll_details_slot"), text(piece.SlotKey));
				detailGroup2.Add(text("stevethetroll_details_armor"), N(Armor(piece, 1)), (num > 1) ? N(Armor(piece, num)) : "");
				detailGroup2.Add(text("stevethetroll_details_worn"), (piece.WornQuality > 0) ? (text("stevethetroll_details_quality") + " " + piece.WornQuality) : text("stevethetroll_details_not_worn"));
				detailGroup2.Add(text("stevethetroll_details_recipe"), Lines(piece.Recipe, upgrade: false));
				if (num > 1)
				{
					detailGroup2.Add(text("stevethetroll_details_upgrade"), Lines(piece.Recipe, upgrade: true));
				}
				list.Add(detailGroup2);
			}
			int num2 = Math.Max(1, d.ClubMaxQuality);
			DetailGroup detailGroup3 = new DetailGroup(d.ClubName);
			detailGroup3.Add(text("stevethetroll_details_blunt"), N(d.ClubBlunt), (num2 > 1) ? N(d.ClubBlunt + d.ClubBluntPerLevel * (float)(num2 - 1)) : "");
			detailGroup3.Add(text("stevethetroll_details_chop"), N(d.ClubChop), (num2 > 1) ? N(d.ClubChop + d.ClubChopPerLevel * (float)(num2 - 1)) : "");
			detailGroup3.Add(text("stevethetroll_details_pickaxe"), N(d.ClubPickaxe), (num2 > 1) ? N(d.ClubPickaxe + d.ClubPickaxePerLevel * (float)(num2 - 1)) : "");
			detailGroup3.Add(text("stevethetroll_details_recipe"), Lines(d.ClubRecipe, upgrade: false));
			if (num2 > 1)
			{
				detailGroup3.Add(text("stevethetroll_details_upgrade"), Lines(d.ClubRecipe, upgrade: true));
			}
			detailGroup3.Add(text("stevethetroll_details_station"), d.Station + " (" + text("stevethetroll_details_level") + " " + d.StationLevel + ")");
			list.Add(detailGroup3);
			return list;
		}

		internal static float Armor(CostumeData.Piece p, int quality)
		{
			return p.Armor + p.ArmorPerLevel * (float)Math.Max(0, quality - 1);
		}

		private static string Lines(List<SlipperData.Ingredient> recipe, bool upgrade)
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (SlipperData.Ingredient item in recipe)
			{
				int num = (upgrade ? item.PerUpgrade : item.Amount);
				if (num > 0)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(", ");
					}
					stringBuilder.Append(num.ToString(CultureInfo.InvariantCulture)).Append(' ').Append(item.Name);
				}
			}
			if (stringBuilder.Length <= 0)
			{
				return "-";
			}
			return stringBuilder.ToString();
		}

		private static string N(float v)
		{
			return v.ToString("0.#", CultureInfo.InvariantCulture);
		}
	}
	internal sealed class DetailGroup
	{
		internal readonly List<DetailRow> Rows = new List<DetailRow>();

		internal readonly string Title;

		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 MaxValue;

		internal readonly string Value;

		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)
		{
			//IL_0010: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			VisualElement obj = RowBox();
			obj.Add((VisualElement)(object)Cell("", 210f, UiKit.TextDim, 18f));
			obj.Add((VisualElement)(object)Cell(q ?? "", 140f, UiKit.TextDim, 18f));
			obj.Add((VisualElement)(object)Cell(max ?? "", 140f, UiKit.TextDim, 18f));
			return obj;
		}

		private static VisualElement StatRow(DetailRow row, bool blockHasMax)
		{
			//IL_0012: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = RowBox();
			val.Add((VisualElement)(object)Cell(row.Label, 210f, UiKit.TextDim, 22f));
			val.Add((VisualElement)(object)Cell(row.Value, (blockHasMax && row.HasMax) ? 140f : (-1f), UiKit.Text, 22f));
			if (blockHasMax && row.HasMax)
			{
				val.Add((VisualElement)(object)Cell(row.MaxValue, 140f, UiKit.Gold, 22f));
			}
			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, Color color, float size)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			Label val = UiKit.Label(content, size, color, false);
			((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 static class HubText
	{
		internal static readonly Dictionary<string, string> En = new Dictionary<string, string>
		{
			{ "stevethetroll_sign_title", "Troll Hub sign" },
			{ "stevethetroll_sign_esc_close", "Esc closes" },
			{ "stevethetroll_sign_name", "Name" },
			{ "stevethetroll_sign_emoji", "Emoji" },
			{ "stevethetroll_sign_emoji_note", "Click an emoji to add it to the name." },
			{ "stevethetroll_sign_text", "Text" },
			{ "stevethetroll_sign_font", "Font" },
			{ "stevethetroll_sign_font_default", "Sign default" },
			{ "stevethetroll_sign_style", "Style" },
			{ "stevethetroll_sign_bold", "Bold" },
			{ "stevethetroll_sign_italic", "Italic" },
			{ "stevethetroll_sign_underline", "Underline" },
			{ "stevethetroll_sign_strike", "Strike" },
			{ "stevethetroll_sign_upper", "Upper case" },
			{ "stevethetroll_sign_align", "Alignment" },
			{ "stevethetroll_sign_left", "Left" },
			{ "stevethetroll_sign_center", "Centre" },
			{ "stevethetroll_sign_right", "Right" },
			{ "stevethetroll_sign_spacing", "Letter spacing" },
			{ "stevethetroll_sign_colour", "Text colour" },
			{ "stevethetroll_sign_letters", "Letter colours" },
			{ "stevethetroll_sign_letters_note", "Click letters to select them, then pick a colour, Paint, Rainbow or Gradient." },
			{ "stevethetroll_sign_all", "All" },
			{ "stevethetroll_sign_none", "None" },
			{ "stevethetroll_sign_paint", "Paint" },
			{ "stevethetroll_sign_rainbow", "Rainbow" },
			{ "stevethetroll_sign_gradient", "Gradient" },
			{ "stevethetroll_sign_clear", "Clear" },
			{ "stevethetroll_sign_pref", "Preferred style" },
			{ "stevethetroll_sign_pref_save", "Save as preferred" },
			{ "stevethetroll_sign_pref_use", "Use preferred" },
			{ "stevethetroll_sign_reset", "Reset style" },
			{ "stevethetroll_sign_pref_saved", "Preferred style saved." },
			{ "stevethetroll_sign_pref_failed", "Could not save the preferred style." },
			{ "stevethetroll_sign_pref_none", "No preferred style saved yet." },
			{ "stevethetroll_sign_pref_used", "Preferred style used." },
			{ "stevethetroll_sign_reset_done", "Style reset." },
			{ "stevethetroll_sign_select_first", "Select letters first." },
			{ "stevethetroll_sign_name_full", "The name is full." },
			{ "stevethetroll_sign_letters_reset", "Every letter had its own colour: cleared, so the text colour shows." },
			{ "stevethetroll_sign_save", "Save" },
			{ "stevethetroll_sign_cancel", "Cancel" },
			{ "stevethetroll_hub_piece", "Troll Hub" },
			{ "stevethetroll_hub_piece_desc", "Where your tamed trolls go when you log out and where they unload. Serves 500 m around it. Removing it gives back what it cost." },
			{ "stevethetroll_hub_tab", "Troll Hub" },
			{ "stevethetroll_hub_tab_heading", "Your Troll Hubs" },
			{ "stevethetroll_hub_tab_note", "A Troll Hub serves a 500 m circle: trolls unload there, rest there when you log out and heal there. Hubs stand at least 1000 m apart; 10 at most." },
			{ "stevethetroll_hub_tab_none", "You have no Troll Hub yet. Build one with the hammer (KY-Items)." },
			{ "stevethetroll_hub_tab_locked", "The Troll Hub appears in the hammer menu once the Steve The Troll set bonus has been active." },
			{ "stevethetroll_hub_tab_trolls", "Trolls" },
			{ "stevethetroll_hub_tab_no_trolls", "no troll" },
			{ "stevethetroll_hub_tab_assign", "Assign trolls" },
			{ "stevethetroll_hub_tab_auto", "Nearest hub" },
			{ "stevethetroll_hub_tab_hubs_off", "Troll Hubs are switched off in the config." },
			{ "stevethetroll_hub_tab_where", "{0} m from you" },
			{ "stevethetroll_hub_tab_count", "{0} of {1} hubs" },
			{ "stevethetroll_hub_msg_toomany", "You already have {0} Troll Hubs." },
			{ "stevethetroll_hub_msg_tooclose", "Too close to another Troll Hub ({0} m, at least {1} m)." },
			{ "stevethetroll_hub_msg_uneven", "The ground is too uneven for a Troll Hub." },
			{ "stevethetroll_hub_msg_locked", "The Troll Hub is not unlocked yet." },
			{ "stevethetroll_hub_msg_unlocked", "The Troll Hub can now be built with the hammer (KY-Items)." },
			{ "stevethetroll_hub_msg_half", "Your trolls need a Troll Hub: none within {0} m, so they work at half speed." },
			{ "stevethetroll_hub_msg_built", "{0} built." },
			{ "stevethetroll_hub_return", "{0} is {1} m from {2} - walks back to it ({3} m farm zone)." },
			{ "stevethetroll_hub_return_done", "{0} is back in the farm zone of {1}." },
			{ "stevethetroll_hub_hover_edit", "rename" }
		};
	}
	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 static class MainMenuView
	{
		internal const string SlippersModel = "slippers";

		internal const string CostumeModel = "costume";

		private const float NameWidth = 140f;

		private const float StatusWidth = 150f;

		private const float FocusWidth = 160f;

		private const float GoWidth = 110f;

		internal static VisualElement Build(Func<string, string> text, Action onClose, SlipperData slippers, Func<IModelScene> makeScene, ViewerSettings viewer, IList<TrollInfo> trolls, Action<string, string> focusChosen, Action<string> goFarm, int startTab = 0, long nowTicks = 0L, CostumeData costume = null, Func<IModelScene> makeCostumeScene = null, TrollActions actions = null)
		{
			UiScroll val2 = default(UiScroll);
			VisualElement val = UiKit.Window(text("stevethetroll_menu_title"), text("stevethetroll_menu_footer"), onClose, ref val2);
			bool flag = false;
			if (trolls != null)
			{
				foreach (TrollInfo troll in trolls)
				{
					if (troll.DiedTicks <= 0)
					{
						flag = true;
					}
				}
			}
			List<VisualElement> list = new List<VisualElement> { SlippersTab(text, slippers, makeScene, viewer) };
			List<string> list2 = new List<string> { text("stevethetroll_tab_slippers") };
			if (costume != null)
			{
				list.Add(CostumeTab(text, costume, makeCostumeScene, viewer));
				list2.Add(text("stevethetroll_tab_costume"));
			}
			if (flag)
			{
				list.Add(MyTrollsTab.Build(text, trolls, actions));
				list2.Add(text("stevethetroll_tab_mytrolls"));
				list.Add(WorkTab(text, trolls, focusChosen, goFarm));
				list2.Add(text("stevethetroll_tab_troll"));
				list.Add(TrollsTab(text, trolls, nowTicks));
				list2.Add(text("stevethetroll_tab_trolls"));
			}
			VisualElement[] tabs = list.ToArray();
			VisualElement[] array = tabs;
			foreach (VisualElement val3 in array)
			{
				val2.Content.Add(val3);
			}
			TabBar tabBar = new TabBar(list2.ToArray(), startTab, delegate(int index)
			{
				ShowTab(tabs, index);
			});
			ShowTab(tabs, tabBar.Selected);
			val.Insert(1, tabBar.Root);
			UiLog.Verbose("MainMenuView: built (" + tabs.Length + " tabs, start tab " + tabBar.Selected + ", slippers " + ((slippers != null) ? slippers.ToString() : "none") + ", 3D scene " + ((makeScene != null) ? "yes" : "no") + ", costume " + ((costume != null) ? costume.ToString() : "none") + ", trolls " + (trolls?.Count ?? 0) + ", troll tabs " + (flag ? "shown" : "hidden (no living tamed troll)") + ")");
			return val;
		}

		internal static VisualElement SlippersTab(Func<string, string> text, SlipperData d, Func<IModelScene> makeScene, ViewerSettings viewer)
		{
			//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 = "stevethetroll-slippers-tab"
			};
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			string title = ((d != null) ? d.Name : "");
			val.Add(ModelViewportView.Build(title, "slippers", makeScene, viewer, text("stevethetroll_viewer_hint"), text("stevethetroll_viewer_reset"), text("stevethetroll_viewer_unavailable")));
			if (d == null)
			{
				val.Add((VisualElement)(object)UiControls.Note(text("stevethetroll_details_unavailable")));
				return val;
			}
			val.Add(UiControls.Heading(d.Name));
			val.Add((VisualElement)(object)UiControls.Note(d.Description));
			val.Add(DetailsView.Build(SlipperDetailsBuilder.Build(d, text), text("stevethetroll_details_q1"), text("stevethetroll_details_qmax") + " " + d.MaxQuality));
			return val;
		}

		internal static VisualElement CostumeTab(Func<string, string> text, CostumeData d, Func<IModelScene> makeScene, ViewerSettings viewer)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			VisualElement val = new VisualElement
			{
				name = "stevethetroll-costume-tab"
			};
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.Add(ModelViewportView.Build(d.SetName, "costume", makeScene, viewer, text("stevethetroll_viewer_hint"), text("stevethetroll_viewer_reset"), text("stevethetroll_viewer_unavailable")));
			val.Add(UiControls.Heading(d.SetName));
			val.Add((VisualElement)(object)UiControls.Note(d.SetDescription));
			val.Add(DetailsView.Build(CostumeDetailsBuilder.Build(d, text), text("stevethetroll_details_q1"), text("stevethetroll_details_qmax") + " 4"));
			return val;
		}

		internal static VisualElement WorkTab(Func<string, string> text, IList<TrollInfo> trolls, Action<string, string> chosen, Action<string> goFarm)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0037: 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_021c: 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_0273: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = new VisualElement
			{
				name = "stevethetroll-work-tab"
			};
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.Add(UiControls.Heading(text("stevethetroll_focus_heading")));
			val.Add((VisualElement)(object)UiControls.Note(text("stevethetroll_focus_note")));
			if (trolls == null || trolls.Count == 0)
			{
				val.Add((VisualElement)(object)UiControls.Note(text("stevethetroll_troll_none")));
				return val;
			}
			val.Add(Row((VisualElement)Cell(text("stevethetroll_troll_name"), 140f, header: true), (VisualElement)Cell(text("stevethetroll_troll_doing"), 150f, header: true), (VisualElement)Cell(text("stevethetroll_focus_label"), 160f, header: true), (VisualElement)Cell("", 110f, header: true), (VisualElement)Cell(text("stevethetroll_troll_farming"), -1f, header: true)));
			foreach (TrollInfo troll2 in trolls)
			{
				TrollInfo troll = troll2;
				string content = text(troll2.Status) + (troll2.Loaded ? "" : " *");
				Button val2 = UiControls.Dropdown((IList<string>)TrollFocus.ChoicesFor(troll2.Biome, troll2.Focus), TrollFocus.Normalize(troll2.Focus), (Func<string, string>)((string v) => text(TrollFocus.KeyOf(v))), (Action<string>)delegate(string v)
				{
					string text2 = TrollFocus.Normalize(v);
					UiLog.Verbose("MainMenuView: focus of " + troll.Shown(null) + " [" + troll.Id + "] -> '" + text2 + "'");
					troll.Focus = text2;
					if (chosen != null)
					{
						chosen(troll.Id, text2);
					}
				});
				((VisualElement)val2).style.width = StyleLength.op_Implicit(160f);
				((VisualElement)val2).style.flexShrink = StyleFloat.op_Implicit(0f);
				Button val3 = UiControls.Button(text("stevethetroll_gofarm"), (Action)delegate
				{
					UiLog.Verbose("MainMenuView: Go farm pressed for " + troll.Shown(null) + " [" + troll.Id + "], focus '" + troll.Focus + "'");
					if (goFarm != null)
					{
						goFarm(troll.Id);
					}
				}, false);
				((VisualElement)val3).style.width = StyleLength.op_Implicit(110f);
				((VisualElement)val3).style.flexShrink = StyleFloat.op_Implicit(0f);
				Label doingCell = Cell(content, 150f, header: false);
				Label farmCell = Cell(TrollFocus.Shown(troll2.Farming, text), -1f, header: false);
				val.Add(Row((VisualElement)Cell(troll2.Shown(text), 140f, header: false), (VisualElement)doingCell, (VisualElement)val2, (VisualElement)val3, (VisualElement)farmCell));
				((VisualElement)doingCell).schedule.Execute((Action)delegate
				{
					string text2 = text(troll.Status) + (troll.Loaded ? "" : " *");
					string text3 = TrollFocus.Shown(troll.Farming, text);
					if (((TextElement)doingCell).text != text2)
					{
						UiLog.Verbose("MainMenuView: " + troll.Shown(null) + " now '" + text2 + "'");
						((TextElement)doingCell).text = text2;
					}
					if (((TextElement)farmCell).text != text3)
					{
						((TextElement)farmCell).text = text3;
					}
				}).Every(1000L);
			}
			val.Add((VisualElement)(object)UiControls.Note(text("stevethetroll_troll_lastseen_note")));
			return val;
		}

		internal static VisualElement TrollsTab(Func<string, string> text, IList<TrollInfo> trolls, long nowTicks)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = new VisualElement
			{
				name = "stevethetroll-trolls-tab"
			};
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			if (trolls == null || trolls.Count == 0)
			{
				val.Add((VisualElement)(object)UiControls.Note(text("stevethetroll_troll_none")));
				return val;
			}
			List<string> list = new List<string>();
			foreach (TrollInfo troll in trolls)
			{
				list.Add(troll.Id);
			}
			VisualElement details = new VisualElement
			{
				name = "stevethetroll-troll-details"
			};
			details.style.flexShrink = StyleFloat.op_Implicit(0f);
			string current2 = list[0];
			string shownState = null;
			long opened = DateTime.UtcNow.Ticks;
			Action<string, bool> build = delegate(string id, bool quiet)
			{
				TrollInfo trollInfo = null;
				foreach (TrollInfo troll2 in trolls)
				{
					if (troll2.Id == id)
					{
						trollInfo = troll2;
					}
				}
				string text2 = ((trollInfo != null) ? (trollInfo.Encode() + trollInfo.Loaded) : "");
				if (!quiet || !(text2 == shownState))
				{
					shownState = text2;
					current2 = id;
					details.Clear();
					details.Add(DetailsView.Build(TrollDetailsBuilder.Build(trollInfo, text, nowTicks + (DateTime.UtcNow.Ticks - opened)), "", ""));
					if (!quiet)
					{
						UiLog.Verbose("MainMenuView: troll details " + ((trollInfo != null) ? trollInfo.ToString() : ("none for " + id)));
					}
				}
			};
			Action<string> action = delegate(string id)
			{
				build(id, arg2: false);
			};
			details.schedule.Execute((Action)delegate
			{
				build(current2, arg2: true);
			}).Every(2000L);
			val.Add(UiControls.Row(text("stevethetroll_troll_pick"), (VisualElement)(object)UiControls.Dropdown((IList<string>)list, list[0], (Func<string, string>)delegate(string id)
			{
				foreach (TrollInfo troll3 in trolls)
				{
					if (troll3.Id == id)
					{
						return troll3.Shown(text);
					}
				}
				return id;
			}, action)));
			val.Add(deta