Decompiled source of AFK Training Dummy v1.0.0

TrainingDummy.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[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 TrainingDummy
{
	internal static class Banter
	{
		private static readonly string[] Idle = new string[26]
		{
			"The only easy day was yesterday, son.", "Back in the delta we slept in shifts. In trees. With a spear. Don't ask about the snake.", "I don't know but I've been told, a troll hits hard but he's real old!", "Two is one, one is none. Bring a spare sword.", "I once carried a boat on my head for a whole week. Never found out why.", "Mud, cold water, sand in the boots. That's a Tuesday.", "Slow is smooth, smooth is fast. Feel that? That's smooth.", "Hooyah! ...What? It's just a thing we say where I'm from.", "If you're cold, you're alive. If you're cold and wet, you're a professional.", "We had frogs back then. Ate them too. Tastes like boar. Everything tastes like boar.",
			"Quiet professionals don't talk this much. I'm retired.", "Hell week taught me two things: sleep is a rumour and a dry sock is a feast.", "I'm not saying I won the war. I'm saying it stopped after I got there.", "Sugar cookie! That's what we called a muddy recruit. You are a very sweet one.", "Night vision? We had a moon and a prayer.", "Eat your berries, they fix the knees. Don't ask me how I know.", "Ring the bell? There's no bell, boy. There's only the next swing.", "Sound off! One, two! Three, four! Break it down: one, two, three, four, ONE-TWO-THREE-FOUR!", "My knees are older than the Black Forest and twice as creaky.", "I'm not yelling. This is my indoor voice. We were mostly outdoors.",
			"Charlie Mike! Means keep going. Don't ask which Charlie.", "The jungle doesn't care about your feelings, kid. Neither do I. Carry on.", "I once crossed a river with a rope, a knife and a bad attitude. Two out of three held.", "Left! Left! Left, right, left! Who's got the sword? You've got the sword!", "Drop and give me twenty. Or thirty. I'm not your mother.", "EKHHH WE HAVE GO TO THE CHOPPA..."
		};

		private static readonly string[] Training = new string[14]
		{
			"Left, right, left! Hold that stance!", "Feet, hips, shoulders. Like a frog on a lily pad!", "One more swing. And another. And another. Good. You're still standing, that's all the medal you need.", "I don't know but I've been told, hit the dummy, don't be bold!", "Pain is just weakness leaving the body. Or a bad knee. Hard to tell at my age.", "Again! Slow is smooth, smooth is fast!", "You call that a swing? My grandmother swings harder. She was a swinger. Of axes.", "Breathe, kid. In through the nose. Out through the war.", "Good! Now do it for twenty more minutes. And then twenty more.", "Back in the delta they'd have made you do it with a log on your shoulder. Lucky you.",
			"Sound off! One, two! Three, four! Hit it once, hit it more!", "Don't look at me, look at the dummy! I'm the handsome one, I know.", "That's it. Ugly but effective. I like ugly but effective.", "EKHHH WE HAVE GO TO THE CHOPPA..."
		};

		private static readonly string[] Scolds = new string[7] { "COWARD!", "WHERE DO YOU THINK YOU ARE GOING, YOU COWARD?!", "QUITTER! MY GRANDMOTHER TRAINS LONGER!", "GET BACK HERE, SOLDIER! THE ONLY EASY DAY WAS YESTERDAY!", "TIRED ALREADY? WEAK! COWARD!", "DROP AND GIVE ME TWENTY, YOU COWARD!", "THE DUMMY DIDN'T QUIT ON YOU, COWARD!" };

		private static string last = "";

		internal static string Scolding()
		{
			return Scolds[Random.Range(0, Scolds.Length)];
		}

		internal static string Next(bool training)
		{
			string[] array = (training ? Training : Idle);
			int num = 0;
			string text;
			do
			{
				text = array[Random.Range(0, array.Length)];
				num++;
			}
			while (text == last && num < 6);
			last = text;
			return text;
		}
	}
	internal static class TrainingItems
	{
		private static string raw;

		private static List<KeyValuePair<string, float>> list = new List<KeyValuePair<string, float>>();

		internal static List<KeyValuePair<string, float>> All
		{
			get
			{
				string text = TrainingDummyPlugin.ItemMinutes.Value ?? "";
				if (text != raw)
				{
					raw = text;
					list = new List<KeyValuePair<string, float>>();
					string[] array = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
					for (int i = 0; i < array.Length; i++)
					{
						string[] array2 = array[i].Split('=');
						if (array2.Length == 2 && float.TryParse(array2[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && result > 0f)
						{
							list.Add(new KeyValuePair<string, float>(array2[0].Trim(), result));
						}
					}
					list.Sort((KeyValuePair<string, float> a, KeyValuePair<string, float> b) => a.Value.CompareTo(b.Value));
				}
				return list;
			}
		}

		internal static float Capacity => TrainingDummyPlugin.SegmentMinutes.Value * 3f;

		internal static ItemDrop Item(string prefab)
		{
			GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(prefab) : null);
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return val.GetComponent<ItemDrop>();
		}
	}
	public sealed class TrainingDummyUse : MonoBehaviour, Interactable, Hoverable
	{
		public const string PieceName = "TD_DummySeals";

		private const string KeyMinutes = "td_min";

		private const string KeyUser = "td_user";

		private const string KeyBeat = "td_beat";

		private ZNetView nview;

		private static readonly string[] HoverWords = new string[16]
		{
			"Crossfit WOD", "Burpees, no excuses", "Leg day", "Warm up, then swing", "Pump some iron", "Cardio with a spear", "Hit the gym", "Reps, reps, reps", "Sweat it out", "Beast mode",
			"Murph, but with swords", "Drop and give me twenty", "Tabata, viking style", "No pain, no gain", "Deadlift your enemies", "Hell week, light edition"
		};

		private BaseAI[] brains;

		private float nextWord;

		private float nextCreak;

		private float nextSpark;

		private static readonly HashSet<string> described = new HashSet<string>();

		private static readonly string[] SmokyWords = new string[11]
		{
			"smoke", "steam", "dust", "fume", "haze", "cloud", "puff", "ash", "vapor", "mist",
			"fog"
		};

		private ZDO Zdo
		{
			get
			{
				if (!((Object)(object)nview != (Object)null) || !nview.IsValid())
				{
					return null;
				}
				return nview.GetZDO();
			}
		}

		internal float Stored
		{
			get
			{
				ZDO zdo = Zdo;
				if (zdo == null)
				{
					return 0f;
				}
				return zdo.GetFloat("td_min", 0f);
			}
		}

		internal bool BusyWithOther
		{
			get
			{
				ZDO zdo = Zdo;
				if (zdo == null)
				{
					return false;
				}
				long num = zdo.GetLong("td_user", 0L);
				if (num == 0L || ((Object)(object)Player.m_localPlayer != (Object)null && num == Player.m_localPlayer.GetPlayerID()))
				{
					return false;
				}
				if ((Object)(object)ZNet.instance != (Object)null)
				{
					return ZNet.instance.GetTimeSeconds() - (double)zdo.GetFloat("td_beat", 0f) < 8.0;
				}
				return false;
			}
		}

		internal ZDOID Id => Zdo?.m_uid ?? ZDOID.None;

		internal int Trainers
		{
			get
			{
				ZDO zdo = Zdo;
				if (zdo == null)
				{
					return 0;
				}
				return zdo.GetInt("td_n", 0);
			}
		}

		private void Awake()
		{
			nview = ((Component)this).GetComponentInParent<ZNetView>();
			brains = ((Component)this).GetComponents<BaseAI>();
		}

		private void Update()
		{
			//IL_001d: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Training.Swinging(this);
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			Vector3 val = ((Component)localPlayer).transform.position - ((Component)this).transform.position;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude > 28f)
			{
				return;
			}
			float stored = Stored;
			bool num = stored >= 0.1f && stored < 3f;
			bool flag2 = stored < 1f;
			if (num && Time.time >= nextSpark)
			{
				nextSpark = Time.time + (flag2 ? Random.Range(0.8f, 1.6f) : Random.Range(2.2f, 4f));
				Sparks((!flag2) ? 1 : 4);
			}
			if (flag && stored > 0.02f && stored < 3f && Time.time >= nextCreak)
			{
				nextCreak = Time.time + (flag2 ? Random.Range(4f, 8f) : Random.Range(22f, 36f));
				Effect("sfx_trainingdummy_idle", Center());
			}
			if (!flag || !((Object)(object)Chat.instance != (Object)null) || !(Time.time >= nextWord))
			{
				return;
			}
			if (magnitude > 16f)
			{
				nextWord = Time.time + 3f;
				return;
			}
			nextWord = Time.time + Random.Range(8f, 13f);
			try
			{
				Chat.instance.SetNpcText(((Component)this).gameObject, new Vector3(0f, 2.4f, 0f), 24f, 6.5f, "", Banter.Next(training: true), false);
			}
			catch (Exception ex)
			{
				TrainingDummyPlugin.Log.LogWarning((object)("The dummy could not speak: " + ex.Message));
				nextWord = Time.time + 60f;
			}
		}

		internal void Scold()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)Chat.instance != (Object)null)
				{
					Chat.instance.SetNpcText(((Component)this).gameObject, new Vector3(0f, 2.4f, 0f), 30f, 6f, "", Banter.Scolding(), true);
				}
			}
			catch (Exception ex)
			{
				TrainingDummyPlugin.Log.LogWarning((object)("The dummy could not shout: " + ex.Message));
			}
		}

		private static bool Smoky(string text)
		{
			string[] smokyWords = SmokyWords;
			foreach (string value in smokyWords)
			{
				if (text.Contains(value))
				{
					return true;
				}
			}
			return false;
		}

		private static void Effect(string prefabName, Vector3 at, bool noSmoke = false)
		{
			//IL_0027: 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_00eb: 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_00f4: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(prefabName) : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, at, Quaternion.identity);
			if (!noSmoke)
			{
				return;
			}
			bool flag = described.Add(prefabName);
			StringBuilder stringBuilder = (flag ? new StringBuilder() : null);
			ParticleSystem[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val3 in componentsInChildren)
			{
				ParticleSystemRenderer component = ((Component)val3).GetComponent<ParticleSystemRenderer>();
				Material val4 = (((Object)(object)component != (Object)null) ? ((Renderer)component).sharedMaterial : null);
				string text = ((Object)((Component)val3).gameObject).name.ToLowerInvariant();
				string text2 = (((Object)(object)val4 != (Object)null) ? ((Object)val4).name.ToLowerInvariant() : "");
				string text3 = (((Object)(object)val4 != (Object)null && (Object)(object)val4.mainTexture != (Object)null) ? ((Object)val4.mainTexture).name.ToLowerInvariant() : "");
				MainModule main = val3.main;
				MinMaxCurve val5 = ((MainModule)(ref main)).startSize;
				float constantMax = ((MinMaxCurve)(ref val5)).constantMax;
				val5 = ((MainModule)(ref main)).startLifetime;
				float constantMax2 = ((MinMaxCurve)(ref val5)).constantMax;
				bool flag2 = Smoky(text) || Smoky(text2) || Smoky(text3) || (constantMax >= 0.5f && constantMax2 >= 1.5f);
				if (flag)
				{
					stringBuilder.Append(((Object)((Component)val3).gameObject).name).Append(" [").Append(text2)
						.Append(" / ")
						.Append(text3)
						.Append(" / size ")
						.Append(constantMax.ToString("0.##"))
						.Append(" / life ")
						.Append(constantMax2.ToString("0.##"))
						.Append(flag2 ? " / OUT" : " / kept")
						.Append("]  ");
				}
				if (flag2)
				{
					Object.Destroy((Object)(object)((Component)val3).gameObject);
				}
			}
			if (flag)
			{
				TrainingDummyPlugin.Log.LogInfo((object)("Training Dummy: the parts of " + prefabName + ": " + stringBuilder.ToString().Trim()));
			}
		}

		internal void Sparks(int bursts)
		{
			//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_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_0043: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Center();
			for (int i = 0; i < bursts; i++)
			{
				Vector3 at = val + new Vector3(Random.Range(-0.4f, 0.4f), Random.Range(-0.3f, 0.6f), Random.Range(-0.4f, 0.4f));
				Effect("vfx_ForgeAddFuel", at, noSmoke: true);
				Effect("vfx_HitSparks", at, noSmoke: true);
			}
		}

		internal void SetStored(float minutes)
		{
			ZDO zdo = Zdo;
			if (zdo != null)
			{
				nview.ClaimOwnership();
				zdo.Set("td_min", Mathf.Clamp(minutes, 0f, TrainingItems.Capacity));
			}
		}

		internal void Stamp(bool on)
		{
			ZDO zdo = Zdo;
			if (zdo != null && !((Object)(object)Player.m_localPlayer == (Object)null))
			{
				nview.ClaimOwnership();
				zdo.Set("td_user", on ? Player.m_localPlayer.GetPlayerID() : 0);
				zdo.Set("td_beat", ((Object)(object)ZNet.instance != (Object)null) ? ((float)ZNet.instance.GetTimeSeconds()) : 0f);
			}
		}

		internal Vector3 Center()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0059: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			Bounds bounds = default(Bounds);
			((Bounds)(ref bounds))..ctor(((Component)this).transform.position + Vector3.up, Vector3.zero);
			Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>();
			foreach (Collider val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && !val.isTrigger)
				{
					if (!flag)
					{
						bounds = val.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val.bounds);
					}
				}
			}
			return ((Bounds)(ref bounds)).center;
		}

		internal string ColliderKinds()
		{
			StringBuilder stringBuilder = new StringBuilder();
			Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>();
			foreach (Collider val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null)
				{
					stringBuilder.Append(((object)val).GetType().Name).Append(val.isTrigger ? "(trigger) " : " ");
				}
			}
			return stringBuilder.ToString().Trim();
		}

		internal Vector3 Closest(Vector3 from)
		{
			//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_0096: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			Vector3 result = ((Component)this).transform.position;
			float num = float.MaxValue;
			Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>();
			foreach (Collider val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && !val.isTrigger)
				{
					MeshCollider val2 = (MeshCollider)(object)((val is MeshCollider) ? val : null);
					Vector3 val3;
					if (!((Object)(object)val2 != (Object)null) || val2.convex)
					{
						val3 = val.ClosestPoint(from);
					}
					else
					{
						Bounds bounds = val.bounds;
						val3 = ((Bounds)(ref bounds)).ClosestPoint(from);
					}
					Vector3 val4 = val3;
					Vector3 val5 = val4 - from;
					float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						result = val4;
					}
				}
			}
			return result;
		}

		public string GetHoverName()
		{
			return "DummySeals";
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public string GetHoverText()
		{
			float stored = Stored;
			string text = "DummySeals" + ((Training.Active && Training.Dummy == this && Training.Paused) ? " (paused)" : "");
			text = ((!(stored > 0.05f)) ? (text + "\ninactive") : (text + "\n" + Mathf.CeilToInt(stored) + " min stored"));
			int num = Mathf.Abs((int)(Time.time / 12f) + ((Object)this).GetInstanceID()) % HoverWords.Length;
			string text2 = ((Localization.instance != null) ? Localization.instance.Localize("$KEY_Use") : "E");
			return text + "\n[<color=yellow><b>" + text2 + "</b></color>] " + HoverWords[num];
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer)
			{
				return false;
			}
			TrainingWindow.Open(this);
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}
	}
	internal static class DummySeals
	{
		internal const string PrefabName = "TD_DummySeals";

		internal const string Vanilla = "piece_TrainingDummy";

		internal const string DisplayName = "DummySeals";

		private static GameObject storage;

		private static readonly Tuple<string, int>[] FallbackCost = new Tuple<string, int>[3]
		{
			Tuple.Create("Wood", 20),
			Tuple.Create("LeatherScraps", 10),
			Tuple.Create("Flint", 5)
		};

		internal static void Release()
		{
			if ((Object)(object)storage != (Object)null)
			{
				Object.Destroy((Object)(object)storage);
			}
			storage = null;
		}

		internal static void Register(ZNetScene scene)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Expected O, but got Unknown
			Release();
			GameObject prefab = scene.GetPrefab("piece_TrainingDummy");
			if ((Object)(object)prefab == (Object)null)
			{
				TrainingDummyPlugin.Log.LogWarning((object)"The game's piece_TrainingDummy was not found in this game version, no DummySeals.");
				return;
			}
			storage = new GameObject("Training Dummy storage");
			storage.SetActive(false);
			storage.transform.SetParent(((Component)scene).transform, false);
			GameObject prefab2 = scene.GetPrefab("Hammer");
			PieceTable val = (((Object)(object)prefab2 != (Object)null) ? prefab2.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces : null);
			if ((Object)(object)val != (Object)null)
			{
				val.m_pieces.RemoveAll((GameObject p) => (Object)(object)p == (Object)null || ((Object)p).name == "TD_DummySeals");
			}
			GameObject val2 = Object.Instantiate<GameObject>(prefab, storage.transform, false);
			((Object)val2).name = "TD_DummySeals";
			Character component = val2.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_health = 1000000f;
				component.m_regenAllHPTime = 5f;
				component.m_name = "DummySeals";
				component.m_staggerWhenBlocked = false;
				component.m_staggerDamageFactor = 0f;
			}
			Piece val3 = val2.GetComponent<Piece>() ?? val2.AddComponent<Piece>();
			int num = ((val3.m_resources != null) ? val3.m_resources.Length : 0);
			val3.m_name = "DummySeals";
			val3.m_description = "A training dummy that trains your skill while you stand in front of it. Press E to add fuel and start.";
			val3.m_category = (PieceCategory)0;
			GameObject prefab3 = scene.GetPrefab("piece_workbench");
			val3.m_craftingStation = (((Object)(object)prefab3 != (Object)null) ? prefab3.GetComponent<CraftingStation>() : null);
			if ((Object)(object)val3.m_craftingStation == (Object)null)
			{
				TrainingDummyPlugin.Log.LogWarning((object)"DummySeals: the workbench was not found, so no workbench is needed to build it.");
			}
			val3.m_enabled = true;
			val3.m_canBeRemoved = true;
			if (num == 0)
			{
				List<Requirement> list = new List<Requirement>();
				Tuple<string, int>[] fallbackCost = FallbackCost;
				foreach (Tuple<string, int> tuple in fallbackCost)
				{
					GameObject prefab4 = scene.GetPrefab(tuple.Item1);
					ItemDrop val4 = (((Object)(object)prefab4 != (Object)null) ? prefab4.GetComponent<ItemDrop>() : null);
					if ((Object)(object)val4 == (Object)null)
					{
						TrainingDummyPlugin.Log.LogWarning((object)("DummySeals: requirement " + tuple.Item1 + " not found, left out."));
						continue;
					}
					list.Add(new Requirement
					{
						m_resItem = val4,
						m_amount = tuple.Item2,
						m_recover = true
					});
				}
				val3.m_resources = list.ToArray();
			}
			StringBuilder stringBuilder = new StringBuilder();
			Requirement[] resources = val3.m_resources;
			foreach (Requirement val5 in resources)
			{
				if (val5 != null && (Object)(object)val5.m_resItem != (Object)null)
				{
					stringBuilder.Append(((Object)((Component)val5.m_resItem).gameObject).name).Append('x').Append(val5.m_amount)
						.Append(' ');
				}
			}
			val2.AddComponent<TrainingDummyUse>();
			Dictionary<int, GameObject> obj = (Dictionary<int, GameObject>)AccessTools.Field(typeof(ZNetScene), "m_namedPrefabs").GetValue(scene);
			int stableHashCode = StringExtensionMethods.GetStableHashCode("TD_DummySeals");
			obj[stableHashCode] = val2;
			if (!scene.m_prefabs.Contains(val2))
			{
				scene.m_prefabs.Add(val2);
			}
			if ((Object)(object)val != (Object)null)
			{
				val.m_pieces.Add(val2);
			}
			TrainingDummyPlugin.Log.LogInfo((object)("DummySeals registered" + (((Object)(object)val != (Object)null) ? " (hammer, Misc tab)" : " (no hammer table found)") + "; recipe " + ((num > 0) ? "of the game's piece" : "plain") + ": " + stringBuilder.ToString().Trim() + "."));
		}
	}
	[HarmonyPatch(typeof(Player), "HaveRequirements", new Type[]
	{
		typeof(Piece),
		typeof(RequirementMode)
	})]
	internal static class UnlockPatch
	{
		private static void Postfix(Player __instance, Piece piece, RequirementMode mode, ref bool __result)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			if (!__result && (int)mode == 1 && !((Object)(object)piece == (Object)null) && !(((Object)((Component)piece).gameObject).name != "TD_DummySeals"))
			{
				__result = true;
			}
		}
	}
	[BepInPlugin("p0kahontazz.trainingdummy", "Training Dummy", "1.0.0")]
	public sealed class TrainingDummyPlugin : BaseUnityPlugin
	{
		public const string Id = "p0kahontazz.trainingdummy";

		public const string Version = "1.0.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<string> ItemMinutes;

		internal static ConfigEntry<float> SegmentMinutes;

		internal static ConfigEntry<float> SkillBonus;

		internal static ConfigEntry<float> LowStamina;

		internal static ConfigEntry<float> ResumeStamina;

		internal static ConfigEntry<float> MaxDistance;

		internal static ConfigEntry<bool> PauseOnMove;

		private Harmony harmony;

		private void Awake()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			ItemMinutes = ((BaseUnityPlugin)this).Config.Bind<string>("Items", "Materials", "SurtlingCore=2,Ectoplasm=3,Guck=3,Ruby=4,AmberPearl=4,FlametalNew=5,SilverNecklace=5,Eitr=6,BlackCore=7,MoltenCore=9", "The materials the dummy takes and the minutes of training one of each gives (prefab=minutes, separated by commas). The panel has three segments of SegmentMinutes: the higher the tier of the material, the more minutes it gives. The panel has fifteen strokes of SegmentMinutes / 5 minutes each (2 minutes by default: 30 minutes in all).");
			ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "ListVersion", 0, "Set by the mod: when the default list of materials changes it replaces the one in this file once.");
			if (val.Value < 3)
			{
				ItemMinutes.Value = (string)((ConfigEntryBase)ItemMinutes).DefaultValue;
				val.Value = 3;
			}
			SegmentMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("Items", "SegmentMinutes", 10f, new ConfigDescription("The length of one of the three segments of the panel, in minutes (the dummy holds three: 30 minutes by default).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
			SkillBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Training", "SkillGainMultiplier", 1.5f, new ConfigDescription("How much faster the skill rises while you train on the dummy than in a normal fight (1.5 = 50% more).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>()));
			LowStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Training", "LowStamina", 0.1f, new ConfigDescription("Below this part of your stamina the character stops swinging and waits for it to come back (0.1 = 10%).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.5f), Array.Empty<object>()));
			ResumeStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Training", "ResumeStamina", 0.7f, new ConfigDescription("The character swings again when the stamina is back at this part (0.7 = 70%).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>()));
			MaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Training", "MaxDistance", 3.2f, new ConfigDescription("How far from the dummy you may stand while training, in metres; farther away the training pauses.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 8f), Array.Empty<object>()));
			PauseOnMove = ((BaseUnityPlugin)this).Config.Bind<bool>("Training", "PauseWhenYouMove", true, "Moving (walking, jumping) pauses the training; press E on the dummy to continue.");
			harmony = new Harmony("p0kahontazz.trainingdummy");
			Type[] array = new Type[18]
			{
				typeof(RegisterPatch),
				typeof(UnregisterPatch),
				typeof(UnlockPatch),
				typeof(TakeInputPatch),
				typeof(VisiblePatch),
				typeof(MouseCapturePatch),
				typeof(EnemyPatch),
				typeof(NoStaggerPatch),
				typeof(NotStaggeringPatch),
				typeof(DummyHoverTextPatch),
				typeof(DummyHoverNamePatch),
				typeof(MoveToSlotPatch),
				typeof(RightClickSlotPatch),
				typeof(HidePatch),
				typeof(HarmlessPatch),
				typeof(EscapePatch),
				typeof(ControlsPatch),
				typeof(SkillPatch)
			};
			foreach (Type type in array)
			{
				try
				{
					harmony.CreateClassProcessor(type).Patch();
				}
				catch (Exception ex)
				{
					Log.LogError((object)("Patch " + type.Name + " failed: " + ex));
				}
			}
			Log.LogInfo((object)"Training Dummy 1.0.0 loaded.");
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		private void LateUpdate()
		{
			try
			{
				Training.Hold();
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Training Dummy: " + ex));
			}
		}

		private void Update()
		{
			try
			{
				Training.Tick();
				TrainingWindow.Tick();
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Training Dummy: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	internal static class RegisterPatch
	{
		private static void Postfix(ZNetScene __instance)
		{
			try
			{
				DummySeals.Register(__instance);
			}
			catch (Exception ex)
			{
				TrainingDummyPlugin.Log.LogError((object)("Training Dummy registration failed: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(ZNetScene), "OnDestroy")]
	internal static class UnregisterPatch
	{
		private static void Prefix()
		{
			DummySeals.Release();
		}
	}
	[HarmonyPatch(typeof(Player), "TakeInput")]
	internal static class TakeInputPatch
	{
		private static void Postfix(ref bool __result)
		{
			if (TrainingWindow.IsOpen)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "IsVisible")]
	internal static class VisiblePatch
	{
		private static void Postfix(ref bool __result)
		{
			if (TrainingWindow.IsOpen)
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
	internal static class MouseCapturePatch
	{
		private static bool Prefix()
		{
			if (!TrainingWindow.IsOpen)
			{
				return true;
			}
			ZCursor.LockState = (CursorLockMode)0;
			ZCursor.Show();
			return false;
		}
	}
	[HarmonyPatch(typeof(Menu), "Update")]
	internal static class EscapePatch
	{
		private static bool Prefix()
		{
			if (!TrainingWindow.IsOpen)
			{
				return true;
			}
			if (ZInput.GetKeyDown((KeyCode)27, true))
			{
				TrainingWindow.Close();
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "GetHoverText")]
	internal static class DummyHoverTextPatch
	{
		private static void Postfix(Character __instance, ref string __result)
		{
			TrainingDummyUse trainingDummyUse = (((Object)(object)__instance != (Object)null) ? ((Component)__instance).GetComponent<TrainingDummyUse>() : null);
			if ((Object)(object)trainingDummyUse != (Object)null)
			{
				__result = trainingDummyUse.GetHoverText();
			}
		}
	}
	[HarmonyPatch(typeof(Character), "GetHoverName")]
	internal static class DummyHoverNamePatch
	{
		private static void Postfix(Character __instance, ref string __result)
		{
			if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).GetComponent<TrainingDummyUse>() != (Object)null)
			{
				__result = "DummySeals";
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "OnSelectedItem")]
	internal static class MoveToSlotPatch
	{
		private static bool Prefix(InventoryGui __instance, InventoryGrid grid, ItemData item, Modifier mod)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			if (!TrainingWindow.IsOpen || (int)mod != 2 || item == null || grid != __instance.m_playerGrid)
			{
				return true;
			}
			return !TrainingWindow.TryMoveToSlot(item);
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "OnRightClickItem")]
	internal static class RightClickSlotPatch
	{
		private static bool Prefix(InventoryGui __instance, InventoryGrid grid, ItemData item)
		{
			if (!TrainingWindow.IsOpen || item == null || grid != __instance.m_playerGrid)
			{
				return true;
			}
			if (!ZInput.GetKey((KeyCode)306, true) && !ZInput.GetKey((KeyCode)305, true))
			{
				return true;
			}
			return !TrainingWindow.TryMoveToSlot(item);
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Hide")]
	internal static class HidePatch
	{
		private static void Postfix()
		{
			TrainingWindow.Close();
		}
	}
	[HarmonyPatch(typeof(Player), "SetControls")]
	internal static class ControlsPatch
	{
		private static void Prefix(Player __instance, ref Vector3 movedir, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun)
		{
			if (Training.Active && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				Training.Controls(ref movedir, ref attack, ref attackHold, ref secondaryAttack, ref secondaryAttackHold, ref block, ref blockHold, ref jump, ref crouch, ref run, ref autoRun);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "RPC_Damage")]
	internal static class HarmlessPatch
	{
		private static void Prefix(Character __instance, HitData hit)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (hit != null && !((Object)(object)__instance == (Object)null) && __instance.IsPlayer())
				{
					Character attacker = hit.GetAttacker();
					if (!((Object)(object)attacker == (Object)null) && !((Object)(object)((Component)attacker).GetComponent<TrainingDummyUse>() == (Object)null))
					{
						hit.m_damage = default(DamageTypes);
						hit.m_pushForce = 0f;
						hit.m_staggerMultiplier = 0f;
						hit.m_statusEffectHash = 0;
						hit.m_backstabBonus = 1f;
						hit.m_blockable = true;
					}
				}
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(BaseAI), "IsEnemy", new Type[]
	{
		typeof(Character),
		typeof(Character)
	})]
	internal static class EnemyPatch
	{
		private static void Postfix(Character a, Character b, ref bool __result)
		{
			if (__result)
			{
				TrainingDummyUse trainingDummyUse = null;
				if ((Object)(object)a != (Object)null)
				{
					trainingDummyUse = ((Component)a).GetComponent<TrainingDummyUse>();
				}
				if ((Object)(object)trainingDummyUse == (Object)null && (Object)(object)b != (Object)null)
				{
					trainingDummyUse = ((Component)b).GetComponent<TrainingDummyUse>();
				}
				if (!((Object)(object)trainingDummyUse == (Object)null))
				{
					__result = Training.Swinging(trainingDummyUse);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Character), "Stagger")]
	internal static class NoStaggerPatch
	{
		private static bool Prefix(Character __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				return (Object)(object)((Component)__instance).GetComponent<TrainingDummyUse>() == (Object)null;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "IsStaggering")]
	internal static class NotStaggeringPatch
	{
		private static void Postfix(Character __instance, ref bool __result)
		{
			if (__result && (Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).GetComponent<TrainingDummyUse>() != (Object)null)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(Skills), "RaiseSkill")]
	internal static class SkillPatch
	{
		private static void Prefix(Skills __instance, ref float factor)
		{
			if (Training.Active && !Training.Paused && (Object)(object)Player.m_localPlayer != (Object)null && __instance == ((Character)Player.m_localPlayer).GetSkills())
			{
				factor *= TrainingDummyPlugin.SkillBonus.Value;
				Training.Gains++;
			}
		}
	}
	internal static class Training
	{
		internal static bool Active;

		internal static bool Paused;

		internal static bool BlockMode;

		internal static bool Resting;

		internal static bool Approaching;

		private static float approachUntil;

		internal static TrainingDummyUse Dummy;

		internal static string Note = "";

		internal static int Swings;

		internal static int Gains;

		private static float remaining;

		private static float nextAttack;

		private static float nextBlock;

		private static float nextSave;

		private static float nextBeat;

		private static float blockHeldAt;

		private static Vector3 anchor;

		private static Rigidbody frozenBody;

		private static RigidbodyConstraints savedConstraints;

		private static bool blocking;

		private static readonly HashSet<SkillType> Melee = new HashSet<SkillType>
		{
			(SkillType)1,
			(SkillType)2,
			(SkillType)3,
			(SkillType)4,
			(SkillType)5,
			(SkillType)7,
			(SkillType)12,
			(SkillType)11
		};

		private static readonly HashSet<SkillType> Ranged = new HashSet<SkillType>
		{
			(SkillType)8,
			(SkillType)14
		};

		private static readonly Dictionary<ItemData, float> durability = new Dictionary<ItemData, float>();

		private static readonly Dictionary<string, int> ammoSeen = new Dictionary<string, int>();

		private static bool drawing;

		private static readonly MethodInfo BlockAttack = AccessTools.Method(typeof(Humanoid), "BlockAttack", new Type[2]
		{
			typeof(HitData),
			typeof(Character)
		}, (Type[])null);

		internal const string NothingToTrain = "You stupid? What do you want to train with it?";

		internal const string NeedShield = "You need a shield in your hand to train blocking.";

		private const float StandDistance = 1f;

		private static bool loggedGap;

		internal static float Remaining
		{
			get
			{
				if (!Active)
				{
					if (!((Object)(object)Dummy != (Object)null))
					{
						return 0f;
					}
					return Dummy.Stored;
				}
				return remaining;
			}
		}

		private static void Freeze(Player player)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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)
			Unfreeze();
			Rigidbody val = (((Object)(object)player != (Object)null) ? ((Component)player).GetComponent<Rigidbody>() : null);
			if (!((Object)(object)val == (Object)null))
			{
				frozenBody = val;
				savedConstraints = val.constraints;
				val.constraints = (RigidbodyConstraints)(savedConstraints | 2 | 8);
			}
		}

		private static void Unfreeze()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)frozenBody != (Object)null)
			{
				frozenBody.constraints = savedConstraints;
			}
			frozenBody = null;
		}

		internal static void Capabilities(Player player, out bool canAttack, out bool canBlock, out string weapon)
		{
			//IL_0036: 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_0096: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			canAttack = (canBlock = false);
			weapon = "nothing";
			if (!((Object)(object)player == (Object)null))
			{
				ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon();
				ItemData leftItem = ((Humanoid)player).LeftItem;
				if (currentWeapon != null)
				{
					canAttack = Melee.Contains(currentWeapon.m_shared.m_skillType) || Ranged.Contains(currentWeapon.m_shared.m_skillType);
					weapon = ((Localization.instance != null) ? Localization.instance.Localize(currentWeapon.m_shared.m_name) : currentWeapon.m_shared.m_name);
				}
				canBlock = leftItem != null && (int)leftItem.m_shared.m_itemType == 5;
			}
		}

		internal static Sprite TrainingIcon(Player player, bool block)
		{
			if ((Object)(object)player == (Object)null)
			{
				return null;
			}
			ItemData val = (block ? ((Humanoid)player).LeftItem : ((Humanoid)player).GetCurrentWeapon());
			try
			{
				return (val != null) ? val.GetIcon() : null;
			}
			catch
			{
				return null;
			}
		}

		internal static ItemData TrainedItem(Player player, bool block)
		{
			if (!((Object)(object)player == (Object)null))
			{
				if (!block)
				{
					return ((Humanoid)player).GetCurrentWeapon();
				}
				return ((Humanoid)player).LeftItem;
			}
			return null;
		}

		internal static SkillType TrainedSkill(Player player, bool block)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return (SkillType)0;
			}
			if (block)
			{
				return (SkillType)6;
			}
			return (SkillType)(((??)((Humanoid)player).GetCurrentWeapon()?.m_shared.m_skillType) ?? 0);
		}

		internal unsafe static string SkillName(SkillType skill)
		{
			string text = "$skill_" + ((object)(*(SkillType*)(&skill))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant();
			if (Localization.instance == null)
			{
				return ((object)(*(SkillType*)(&skill))/*cast due to .constrained prefix*/).ToString();
			}
			return Localization.instance.Localize(text);
		}

		internal static bool SetMode(bool block)
		{
			Player localPlayer = Player.m_localPlayer;
			Capabilities(localPlayer, out var canAttack, out var canBlock, out var weapon);
			if (block ? (!canBlock) : (!canAttack))
			{
				Say(block ? "You need a shield in your hand to train blocking." : "You stupid? What do you want to train with it?");
				return false;
			}
			BlockMode = block;
			blocking = false;
			drawing = false;
			ammoSeen.Clear();
			if (!block && IsRanged(localPlayer) && AmmoOf(localPlayer).Count == 0)
			{
				Say("Put some ammunition in your inventory first (it is not used up).");
				BlockMode = true;
				return false;
			}
			Say(block ? "Training the block." : ("Training: " + weapon + "."));
			return true;
		}

		internal static bool Swinging(TrainingDummyUse dummy)
		{
			if (Active && !Paused && !Approaching)
			{
				return Dummy == dummy;
			}
			return false;
		}

		internal static bool Start(TrainingDummyUse dummy, bool blockMode)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)dummy == (Object)null)
			{
				return false;
			}
			if (dummy.BusyWithOther)
			{
				Say("Somebody else is training on this dummy.");
				return false;
			}
			if (dummy.Stored < 0.05f)
			{
				Say("Put materials into the dummy first.");
				return false;
			}
			Capabilities(localPlayer, out var canAttack, out var canBlock, out var weapon);
			if (blockMode ? (!canBlock) : (!canAttack))
			{
				Say(blockMode ? "You need a shield in your hand to train blocking." : "You stupid? What do you want to train with it?");
				return false;
			}
			BlockMode = blockMode;
			if (!blockMode && IsRanged(localPlayer) && AmmoOf(localPlayer).Count == 0)
			{
				Say("Put some ammunition in your inventory first (it is not used up).");
				return false;
			}
			durability.Clear();
			ammoSeen.Clear();
			drawing = false;
			Dummy = dummy;
			BlockMode = blockMode;
			remaining = dummy.Stored;
			Active = true;
			Paused = false;
			Resting = false;
			Swings = 0;
			Gains = 0;
			nextAttack = Time.time + 0.6f;
			nextBlock = Time.time + 1.5f;
			nextSave = Time.time + 1f;
			blocking = false;
			dummy.Stamp(on: true);
			Approaching = false;
			if (Far(localPlayer, training: false))
			{
				Approaching = true;
				approachUntil = Time.time + 8f;
			}
			else
			{
				Settle(localPlayer);
			}
			Say(blockMode ? "Training the block." : ("Training: " + weapon + "."), warning: false);
			return true;
		}

		private static void Settle(Player player)
		{
			//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)
			Approaching = false;
			anchor = ((Component)player).transform.position;
			Freeze(player);
		}

		internal static void Resume()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (!Active || (Object)(object)Dummy == (Object)null)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null && Far(localPlayer, training: true))
			{
				Say("Step up to the dummy to continue.");
				return;
			}
			if ((Object)(object)localPlayer != (Object)null)
			{
				anchor = ((Component)localPlayer).transform.position;
			}
			Paused = false;
			Resting = false;
			nextAttack = Time.time + 0.6f;
			Say("Training continues.", warning: false);
		}

		internal static void Pause(string why)
		{
			if (Active)
			{
				Stop(why, quit: true);
			}
		}

		internal static void Stop(string why, bool quit = false)
		{
			TrainingDummyUse dummy = Dummy;
			bool active = Active;
			if ((Object)(object)Dummy != (Object)null)
			{
				Save();
				Dummy.Stamp(on: false);
			}
			Unfreeze();
			Active = false;
			Paused = false;
			Resting = false;
			Approaching = false;
			blocking = false;
			Dummy = null;
			if (why != "")
			{
				Say(why, warning: false);
			}
			if (quit && active && (Object)(object)dummy != (Object)null)
			{
				dummy.Scold();
			}
		}

		private static void Save()
		{
			if ((Object)(object)Dummy != (Object)null && Active)
			{
				Dummy.SetStored(remaining);
			}
		}

		internal static void Add(float minutes)
		{
			remaining = Mathf.Min(TrainingItems.Capacity, remaining + minutes);
			Save();
		}

		private static void Say(string text, bool warning = true)
		{
			Note = text;
			if ((Object)(object)Player.m_localPlayer != (Object)null && text != "")
			{
				((Character)Player.m_localPlayer).Message((MessageType)((!warning) ? 1 : 2), text, 0, (Sprite)null, false);
			}
		}

		internal static bool IsRanged(Player player)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			ItemData val = (((Object)(object)player != (Object)null) ? ((Humanoid)player).GetCurrentWeapon() : null);
			if (!BlockMode && val != null)
			{
				return Ranged.Contains(val.m_shared.m_skillType);
			}
			return false;
		}

		private static float Gap(Player player)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0025: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Dummy.Closest(((Component)player).transform.position) - ((Component)player).transform.position;
			val.y = 0f;
			return ((Vector3)(ref val)).magnitude;
		}

		private static bool Far(Player player, bool training)
		{
			if ((Object)(object)Dummy == (Object)null)
			{
				return true;
			}
			if (IsRanged(player))
			{
				return Gap(player) > 30f;
			}
			float num = Gap(player);
			if (!loggedGap)
			{
				loggedGap = true;
				TrainingDummyPlugin.Log.LogInfo((object)("Training Dummy: gap to the dummy " + num.ToString("0.00") + " m, colliders: " + Dummy.ColliderKinds()));
			}
			return num > 1f + (training ? 1.5f : 0.4f);
		}

		private static Dictionary<string, int> AmmoOf(Player player)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon();
			if (currentWeapon == null)
			{
				return dictionary;
			}
			string ammoType = currentWeapon.m_shared.m_ammoType;
			if (string.IsNullOrEmpty(ammoType))
			{
				return dictionary;
			}
			foreach (ItemData allItem in ((Humanoid)player).GetInventory().GetAllItems())
			{
				if (allItem.m_shared.m_ammoType == ammoType && (int)allItem.m_shared.m_itemType == 9 && (Object)(object)allItem.m_dropPrefab != (Object)null)
				{
					dictionary.TryGetValue(((Object)allItem.m_dropPrefab).name, out var value);
					dictionary[((Object)allItem.m_dropPrefab).name] = value + allItem.m_stack;
				}
			}
			return dictionary;
		}

		private static void Guard(Player player)
		{
			ItemData[] array = (ItemData[])(object)new ItemData[2]
			{
				((Humanoid)player).GetCurrentWeapon(),
				((Humanoid)player).LeftItem
			};
			foreach (ItemData val in array)
			{
				if (val != null && val.m_shared.m_useDurability)
				{
					if (!durability.TryGetValue(val, out var value))
					{
						durability[val] = val.m_durability;
					}
					else if (val.m_durability < value)
					{
						val.m_durability = value;
					}
					else
					{
						durability[val] = val.m_durability;
					}
				}
			}
			if (!IsRanged(player))
			{
				return;
			}
			Dictionary<string, int> dictionary = AmmoOf(player);
			foreach (KeyValuePair<string, int> item in ammoSeen)
			{
				dictionary.TryGetValue(item.Key, out var value2);
				if (value2 < item.Value)
				{
					GameObject val2 = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(item.Key) : null);
					if ((Object)(object)val2 != (Object)null)
					{
						((Humanoid)player).GetInventory().AddItem(val2, item.Value - value2);
					}
				}
			}
			ammoSeen.Clear();
			foreach (KeyValuePair<string, int> item2 in AmmoOf(player))
			{
				ammoSeen[item2.Key] = item2.Value;
			}
		}

		internal static void Tick()
		{
			//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_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_0067: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			if (!Active)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || (Object)(object)Dummy == (Object)null)
			{
				Stop("");
			}
			else if (Approaching)
			{
				Vector3 val = Dummy.Closest(((Component)localPlayer).transform.position) - ((Component)localPlayer).transform.position;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
				{
					((Character)localPlayer).SetLookDir(((Vector3)(ref val)).normalized, 0f);
				}
				if (Gap(localPlayer) <= 1f)
				{
					Settle(localPlayer);
					nextAttack = Time.time + 0.6f;
				}
				else if (Time.time >= approachUntil)
				{
					Stop("You cannot reach the dummy.");
				}
				else if (Time.time >= nextSave)
				{
					nextSave = Time.time + 1f;
					Dummy.Stamp(on: true);
				}
			}
			else if (!Paused)
			{
				if (Far(localPlayer, training: true))
				{
					Pause("");
					return;
				}
				if (IsRanged(localPlayer))
				{
					Vector3 val2 = Dummy.Center() - ((Character)localPlayer).GetEyePoint();
					((Character)localPlayer).SetLookDir(((Vector3)(ref val2)).normalized, 0f);
				}
				else
				{
					Vector3 val3 = Dummy.Closest(((Component)localPlayer).transform.position) - ((Component)localPlayer).transform.position;
					val3.y = 0f;
					if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f)
					{
						((Character)localPlayer).SetLookDir(((Vector3)(ref val3)).normalized, 0f);
					}
				}
				Guard(localPlayer);
				float staminaPercentage = ((Character)localPlayer).GetStaminaPercentage();
				if (!Resting && staminaPercentage < TrainingDummyPlugin.LowStamina.Value)
				{
					Resting = true;
					Note = "Resting: waiting for stamina.";
				}
				else if (Resting && staminaPercentage >= TrainingDummyPlugin.ResumeStamina.Value)
				{
					Resting = false;
					Note = "Training.";
				}
				remaining -= Time.deltaTime / 60f;
				if (Time.time >= nextSave)
				{
					nextSave = Time.time + 1f;
					Save();
					Dummy.Stamp(on: true);
				}
				if (remaining <= 0f)
				{
					remaining = 0f;
					Save();
					Stop("The training is over.");
				}
			}
			else if (Time.time >= nextSave)
			{
				nextSave = Time.time + 2f;
				Dummy.Stamp(on: true);
			}
		}

		internal static void Hold()
		{
			//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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (!Active || Paused || Approaching)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)localPlayer).transform.position;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(position.x - anchor.x, 0f, position.z - anchor.z);
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0004f))
			{
				position.x = anchor.x;
				position.z = anchor.z;
				((Component)localPlayer).transform.position = position;
				Rigidbody component = ((Component)localPlayer).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.position = position;
					Vector3 velocity = component.velocity;
					component.velocity = new Vector3(0f, velocity.y, 0f);
				}
			}
		}

		internal static void Controls(ref Vector3 movedir, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (Paused)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if (Approaching)
			{
				if (TrainingDummyPlugin.PauseOnMove.Value && ((((Vector3)(ref movedir)).sqrMagnitude > 0.01f) | jump))
				{
					Stop("");
					return;
				}
				movedir = new Vector3(0f, 0f, 1f);
				run = false;
				jump = false;
				crouch = false;
				autoRun = false;
				attack = false;
				attackHold = false;
				secondaryAttack = false;
				secondaryAttackHold = false;
				block = false;
				blockHold = false;
				return;
			}
			if (TrainingDummyPlugin.PauseOnMove.Value && ((((Vector3)(ref movedir)).sqrMagnitude > 0.01f) | jump))
			{
				Pause("");
				return;
			}
			movedir = Vector3.zero;
			run = false;
			jump = false;
			crouch = false;
			autoRun = false;
			secondaryAttack = false;
			secondaryAttackHold = false;
			if (BlockMode)
			{
				attack = false;
				attackHold = false;
				blockHold = !Resting;
				block = !Resting && !blocking;
				blocking = !Resting;
				return;
			}
			block = false;
			blockHold = false;
			if ((Object)(object)localPlayer != (Object)null && IsRanged(localPlayer))
			{
				RangedControls(localPlayer, ref attack, ref attackHold);
			}
			else if (!Resting && (Object)(object)localPlayer != (Object)null && !((Character)localPlayer).InAttack() && Time.time >= nextAttack)
			{
				attack = true;
				attackHold = false;
				nextAttack = Time.time + 0.3f;
				Swings++;
			}
			else
			{
				attack = false;
				attackHold = false;
			}
		}

		private static void RangedControls(Player player, ref bool attack, ref bool attackHold)
		{
			attack = false;
			attackHold = false;
			if (Resting)
			{
				drawing = false;
				return;
			}
			Attack val = ((Humanoid)player).GetCurrentWeapon()?.m_shared.m_attack;
			if (val == null)
			{
				return;
			}
			if (val.m_requiresReload && !((Humanoid)player).IsWeaponLoaded())
			{
				attack = !((Character)player).InAttack();
				attackHold = true;
			}
			else if (val.m_bowDraw)
			{
				if (!drawing && !((Character)player).InAttack() && Time.time >= nextAttack)
				{
					attack = true;
					attackHold = true;
					drawing = true;
				}
				else if (drawing)
				{
					if (((Humanoid)player).GetAttackDrawPercentage() >= 0.98f)
					{
						drawing = false;
						attackHold = false;
						nextAttack = Time.time + 0.5f;
						Swings++;
					}
					else
					{
						attackHold = true;
					}
				}
			}
			else if (!((Character)player).InAttack() && Time.time >= nextAttack)
			{
				attack = true;
				nextAttack = Time.time + 0.5f;
				Swings++;
			}
		}

		private static void TakeBlockedHit(Player player)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//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_0036: 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_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_0057: 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)
			if (BlockAttack == null)
			{
				return;
			}
			try
			{
				HitData val = new HitData();
				val.m_damage.m_blunt = 1f;
				val.m_dir = -((Component)player).transform.forward;
				val.m_point = ((Component)player).transform.position + ((Component)player).transform.forward + Vector3.up;
				val.m_pushForce = 0f;
				val.m_staggerMultiplier = 0f;
				val.m_blockable = true;
				val.m_dodgeable = false;
				BlockAttack.Invoke(player, new object[2] { val, null });
			}
			catch (Exception ex)
			{
				TrainingDummyPlugin.Log.LogWarning((object)("The blocked hit failed: " + ex.Message));
			}
		}
	}
	internal static class TrainingWindow
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Image, bool> <>9__63_0;

			public static Func<Image, float> <>9__63_2;

			public static Func<Font, bool> <>9__68_0;

			public static UnityAction <>9__68_1;

			public static Action <>9__68_2;

			public static Action <>9__68_3;

			internal bool <Discover>b__63_0(Image i)
			{
				string text = (((Object)i).name + " " + ((Object)i.sprite).name).ToLowerInvariant();
				string[] array = new string[12]
				{
					"darken", "blob", "shadow", "glow", "select", "icon", "scroll", "handle", "bar", "highlight",
					"button", "tab"
				};
				foreach (string value in array)
				{
					if (text.Contains(value))
					{
						return true;
					}
				}
				return false;
			}

			internal float <Discover>b__63_2(Image i)
			{
				//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_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				Rect rect = ((Graphic)i).rectTransform.rect;
				float width = ((Rect)(ref rect)).width;
				rect = ((Graphic)i).rectTransform.rect;
				return width * ((Rect)(ref rect)).height;
			}

			internal bool <Build>b__68_0(Font f)
			{
				if ((Object)(object)f != (Object)null)
				{
					return ((Object)f).name == "Norsebold";
				}
				return false;
			}

			internal void <Build>b__68_1()
			{
				ClickSound();
				SlotClicked();
			}

			internal void <Build>b__68_2()
			{
				listOpen = !listOpen;
				Layout();
				Refresh();
			}

			internal void <Build>b__68_3()
			{
				Training.Stop("Training stopped. The minutes that are left stay in the dummy.", quit: true);
			}
		}

		private static GameObject root;

		private static RectTransform panelRt;

		private static TrainingDummyUse dummy;

		private static Image[] ticks = (Image[])(object)new Image[0];

		private static TMP_Text trainLabel;

		private static TMP_Text warnLine;

		private static TMP_Text state;

		private static TMP_Text timer;

		private static TMP_Text weaponLine;

		private static TMP_Text noteLine;

		private static TMP_Text startLabel;

		private static TMP_Text modeLabel;

		private static TMP_Text slotCount;

		private static TMP_Text slotInfo;

		private static Image slotIcon;

		private static Image trainIcon;

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

		private static Button addButton;

		private static Button startButton;

		private static bool blockMode;

		private static bool listOpen;

		private static float nextRefresh;

		private static float listHeightOpen;

		private static float listHeightClosed;

		private static bool loggedItem;

		private static string slotPrefab = "";

		private static int slotAmount;

		private const float PanelWidth = 900f;

		private const float ShiftX = 420f;

		private const float TickCount = 15f;

		private static readonly FieldInfo DragItemField = AccessTools.Field(typeof(InventoryGui), "m_dragItem");

		private static readonly FieldInfo DragInventoryField = AccessTools.Field(typeof(InventoryGui), "m_dragInventory");

		private static readonly FieldInfo DragAmountField = AccessTools.Field(typeof(InventoryGui), "m_dragAmount");

		private static readonly MethodInfo SetupDrag = AccessTools.Method(typeof(InventoryGui), "SetupDragItem", new Type[3]
		{
			typeof(ItemData),
			typeof(Inventory),
			typeof(int)
		}, (Type[])null);

		private static readonly Color Beige = new Color(0.98f, 0.95f, 0.9f);

		private static readonly Color Grey = new Color(0.65f, 0.62f, 0.58f);

		private static readonly Color Orange = new Color(1f, 0.63f, 0.235f);

		private static readonly Color Green = new Color(0.45f, 0.9f, 0.45f);

		private static readonly Color Amber = new Color(1f, 0.63f, 0.235f);

		private static readonly Color Red = new Color(0.96f, 0.36f, 0.28f);

		private static readonly Color Empty = new Color(0f, 0f, 0f, 0.5f);

		private static readonly Color RowBack = new Color(1f, 1f, 1f, 0.05f);

		private static readonly Dictionary<string, Sprite> sprites = new Dictionary<string, Sprite>();

		private static Sprite panelSprite;

		private static Type panelType;

		private static Color panelColor = new Color(0.25f, 0.17f, 0.1f, 0.97f);

		private static float panelPpu = 1f;

		private static Material panelMaterial;

		private static Button buttonTemplate;

		private static TMP_FontAsset font;

		private static Color titleColor = new Color(1f, 0.63f, 0.235f);

		private static Color bodyColor = new Color(0.98f, 0.95f, 0.9f);

		private static bool skin;

		private static Sprite flat;

		internal static bool IsOpen => (Object)(object)root != (Object)null;

		internal static TMP_FontAsset BodyFont()
		{
			if ((Object)(object)font == (Object)null)
			{
				Discover();
			}
			return font;
		}

		internal static void Open(TrainingDummyUse piece)
		{
			Close();
			Animator val = (Animator)(((Object)(object)InventoryGui.instance != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
			bool flag = (Object)(object)val != (Object)null && val.GetBool("visible");
			dummy = piece;
			slotPrefab = "";
			slotAmount = 0;
			listOpen = false;
			loggedItem = false;
			Training.Capabilities(Player.m_localPlayer, out var canAttack, out var canBlock, out var _);
			blockMode = (Training.Active ? Training.BlockMode : (!canAttack && canBlock));
			Build();
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance != (Object)null && !flag)
			{
				try
				{
					instance.Show((Container)null, 1);
				}
				catch (Exception ex)
				{
					TrainingDummyPlugin.Log.LogWarning((object)("The inventory could not be opened: " + ex.Message));
				}
			}
			Refresh();
		}

		internal static void Close()
		{
			if ((Object)(object)root != (Object)null)
			{
				GiveBack();
				Object.Destroy((Object)(object)root);
			}
			root = null;
			dummy = null;
			listParts.Clear();
		}

		internal static void Tick()
		{
			if (!((Object)(object)root == (Object)null))
			{
				if ((Object)(object)dummy == (Object)null)
				{
					Close();
				}
				else if (Time.unscaledTime >= nextRefresh)
				{
					nextRefresh = Time.unscaledTime + 0.2f;
					Refresh();
				}
			}
		}

		private static RectTransform Rect(string name, Transform parent, Vector2 aMin, Vector2 aMax, Vector2 oMin, Vector2 oMax)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0045: 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)
			RectTransform component = new GameObject(name, new Type[1] { typeof(RectTransform) })
			{
				layer = LayerMask.NameToLayer("UI")
			}.GetComponent<RectTransform>();
			((Transform)component).SetParent(parent, false);
			component.anchorMin = aMin;
			component.anchorMax = aMax;
			component.offsetMin = oMin;
			component.offsetMax = oMax;
			return component;
		}

		private static Image Box(string name, Transform parent, Vector2 aMin, Vector2 aMax, Vector2 oMin, Vector2 oMax, Color color)
		{
			//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_0004: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			Image obj = ((Component)Rect(name, parent, aMin, aMax, oMin, oMax)).gameObject.AddComponent<Image>();
			((Graphic)obj).color = color;
			return obj;
		}

		private static Sprite FindSprite(string name)
		{
			if (sprites.TryGetValue(name, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = null;
			Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>();
			foreach (Sprite val in array)
			{
				if ((Object)(object)val != (Object)null && ((Object)val).name == name)
				{
					value = val;
					break;
				}
			}
			sprites[name] = value;
			return value;
		}

		private static bool Draws(TMP_FontAsset f)
		{
			if ((Object)(object)f == (Object)null)
			{
				return false;
			}
			try
			{
				return f.HasCharacter('A', true, true) && f.HasCharacter('g', true, true) && f.HasCharacter('7', true, true);
			}
			catch
			{
				return false;
			}
		}

		private static void Discover()
		{
			//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_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			skin = false;
			panelSprite = null;
			buttonTemplate = null;
			InventoryGui instance = InventoryGui.instance;
			TMP_FontAsset val = null;
			try
			{
				val = (((Object)(object)instance != (Object)null && (Object)(object)instance.m_recipeDecription != (Object)null) ? instance.m_recipeDecription.font : null);
				if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_recipeDecription != (Object)null)
				{
					bodyColor = ((Graphic)instance.m_recipeDecription).color;
				}
			}
			catch
			{
			}
			TMP_FontAsset val2 = (Draws(val) ? val : null);
			if ((Object)(object)val2 == (Object)null)
			{
				TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
				foreach (TMP_FontAsset val3 in array)
				{
					if ((Object)(object)val3 != (Object)null && ((Object)val3).name.IndexOf("Averia", StringComparison.OrdinalIgnoreCase) >= 0 && Draws(val3))
					{
						val2 = val3;
						break;
					}
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				try
				{
					TMP_FontAsset defaultFontAsset = TMP_Settings.defaultFontAsset;
					if (Draws(defaultFontAsset))
					{
						val2 = defaultFontAsset;
					}
				}
				catch
				{
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
				foreach (TMP_FontAsset val4 in array)
				{
					if (Draws(val4))
					{
						val2 = val4;
						break;
					}
				}
			}
			font = val2 ?? val;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_crafting == (Object)null)
			{
				return;
			}
			try
			{
				List<Image> list = ((Component)instance.m_crafting).GetComponentsInChildren<Image>(true).ToList();
				Transform parent = ((Transform)instance.m_crafting).parent;
				int num = 0;
				while (num < 3 && (Object)(object)parent != (Object)null)
				{
					Image component = ((Component)parent).GetComponent<Image>();
					if ((Object)(object)component != (Object)null)
					{
						list.Add(component);
					}
					num++;
					parent = parent.parent;
				}
				Func<Image, bool> bad = delegate(Image val6)
				{
					string text = (((Object)val6).name + " " + ((Object)val6.sprite).name).ToLowerInvariant();
					string[] array2 = new string[12]
					{
						"darken", "blob", "shadow", "glow", "select", "icon", "scroll", "handle", "bar", "highlight",
						"button", "tab"
					};
					foreach (string value in array2)
					{
						if (text.Contains(value))
						{
							return true;
						}
					}
					return false;
				};
				Image val5 = list.Where((Image val6) => (Object)(object)val6.sprite != (Object)null && !bad(val6) && ((Graphic)val6).color.a > 0.5f).OrderByDescending(delegate(Image val6)
				{
					//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_0019: Unknown result type (might be due to invalid IL or missing references)
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					Rect rect = ((Graphic)val6).rectTransform.rect;
					float width = ((Rect)(ref rect)).width;
					rect = ((Graphic)val6).rectTransform.rect;
					return width * ((Rect)(ref rect)).height;
				}).FirstOrDefault();
				if ((Object)(object)val5 != (Object)null)
				{
					panelSprite = val5.sprite;
					panelType = val5.type;
					panelColor = ((Graphic)val5).color;
					panelPpu = val5.pixelsPerUnitMultiplier;
					panelMaterial = ((Graphic)val5).material;
				}
				buttonTemplate = instance.m_craftButton;
				skin = (Object)(object)val5 != (Object)null;
			}
			catch (Exception ex)
			{
				TrainingDummyPlugin.Log.LogWarning((object)("Training Dummy window: the game's skin was not found (" + ex.Message + "), plain colours are used."));
			}
		}

		private static TMP_Text Label(string name, Transform parent, Vector2 aMin, Vector2 aMax, Vector2 oMin, Vector2 oMax, string text, float size, Color color, TextAlignmentOptions align)
		{
			//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_0004: 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_0041: 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)
			TextMeshProUGUI val = ((Component)Rect(name, parent, aMin, aMax, oMin, oMax)).gameObject.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)font != (Object)null)
			{
				((TMP_Text)val).font = font;
			}
			((TMP_Text)val).text = text;
			((TMP_Text)val).fontSize = size;
			((Graphic)val).color = color;
			((TMP_Text)val).alignment = align;
			((Graphic)val).raycastTarget = false;
			((TMP_Text)val).enableWordWrapping = false;
			((TMP_Text)val).overflowMode = (TextOverflowModes)0;
			return (TMP_Text)(object)val;
		}

		private static bool Keep(Component c)
		{
			if (!(c is Graphic) && !(c is Selectable) && !(c is Mask) && !(c is RectMask2D) && !(c is LayoutGroup) && !(c is ContentSizeFitter) && !(c is LayoutElement))
			{
				return c is BaseMeshEffect;
			}
			return true;
		}

		private static Button MakeButton(string name, Transform parent, Vector2 aMin, Vector2 aMax, Vector2 oMin, Vector2 oMax, string text, Color colour, Action click, out TMP_Text labelOut, float size = 30f)
		{
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			Image val2;
			Button val3;
			if (skin && (Object)(object)buttonTemplate != (Object)null)
			{
				GameObject val = Object.Instantiate<GameObject>(((Component)buttonTemplate).gameObject, parent, false);
				((Object)val).name = name;
				val.SetActive(true);
				ColorBlock colors = ((Selectable)buttonTemplate).colors;
				Transition transition = ((Selectable)buttonTemplate).transition;
				SpriteState spriteState = ((Selectable)buttonTemplate).spriteState;
				foreach (MonoBehaviour item in val.GetComponentsInChildren<MonoBehaviour>(true).ToList())
				{
					if ((Object)(object)item != (Object)null && !Keep((Component)(object)item))
					{
						Object.DestroyImmediate((Object)(object)item);
					}
				}
				foreach (Selectable item2 in val.GetComponentsInChildren<Selectable>(true).ToList())
				{
					if ((Object)(object)item2 != (Object)null)
					{
						Object.DestroyImmediate((Object)(object)item2);
					}
				}
				val2 = val.GetComponent<Image>();
				val3 = val.AddComponent<Button>();
				((Selectable)val3).targetGraphic = (Graphic)(object)val2;
				((Selectable)val3).transition = transition;
				((Selectable)val3).colors = colors;
				((Selectable)val3).spriteState = spriteState;
				TMP_Text[] componentsInChildren = val.GetComponentsInChildren<TMP_Text>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Component)componentsInChildren[i]).gameObject.SetActive(false);
				}
				RectTransform val4 = (RectTransform)val.transform;
				val4.anchorMin = aMin;
				val4.anchorMax = aMax;
				val4.offsetMin = oMin;
				val4.offsetMax = oMax;
			}
			else
			{
				val2 = Box(name, parent, aMin, aMax, oMin, oMax, new Color(0.1f, 0.07f, 0.04f, 0.9f));
				val3 = ((Component)val2).gameObject.AddComponent<Button>();
				((Selectable)val3).targetGraphic = (Graphic)(object)val2;
			}
			((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
			{
				ClickSound();
				click();
			});
			TMP_Text val5 = Label("text", ((Component)val2).transform, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero, text, size, colour, (TextAlignmentOptions)514);
			TrainingButtonTint trainingButtonTint = ((Component)val3).gameObject.AddComponent<TrainingButtonTint>();
			trainingButtonTint.Target = val3;
			trainingButtonTint.Label = val5;
			trainingButtonTint.Colour = colour;
			labelOut = val5;
			return val3;
		}

		private static void ClickSound()
		{
			//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)
			GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("sfx_gui_button") : null);
			if ((Object)(object)val != (Object)null && (Object)(object)Utils.GetMainCamera() != (Object)null)
			{
				Object.Instantiate<GameObject>(val, ((Component)Utils.GetMainCamera()).transform.position, Quaternion.identity);
			}
		}

		private static void Build()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: 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_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0620: Unknown result type (might be due to invalid IL or missing references)
			//IL_0639: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_069c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0707: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Unknown result type (might be due to invalid IL or missing references)
			//IL_0713: Unknown result type (might be due to invalid IL or missing references)
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_072c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Expected O, but got Unknown
			//IL_0769: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_0784: Unknown result type (might be due to invalid IL or missing references)
			//IL_078e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0833: Unknown result type (might be due to invalid IL or missing references)
			//IL_0834: Unknown result type (might be due to invalid IL or missing references)
			//IL_083f: Unknown result type (might be due to invalid IL or missing references)
			//IL_084e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0853: Unknown result type (might be due to invalid IL or missing references)
			//IL_087c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0881: Unknown result type (might be due to invalid IL or missing references)
			//IL_0890: Unknown result type (might be due to invalid IL or missing references)
			//IL_089f: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a29: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a38: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a47: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a69: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a84: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ace: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aeb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0afa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b1a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b28: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b68: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b74: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b92: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bcf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c3a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d0f: Unknown result type (might be due to invalid IL or missing references)
			//IL_093d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0942: Unknown result type (might be due to invalid IL or missing references)
			//IL_0951: Unknown result type (might be due to invalid IL or missing references)
			//IL_0960: Unknown result type (might be due to invalid IL or missing references)
			//IL_096c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0988: Unknown result type (might be due to invalid IL or missing references)
			//IL_098d: Unknown result type (might be due to invalid IL or missing references)
			//IL_099c: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_09db: Unknown result type (might be due to invalid IL or missing references)
			Discover();
			List<KeyValuePair<string, float>> all = TrainingItems.All;
			int num = Mathf.Max(1, (all.Count + 2) / 3);
			listHeightOpen = 382f + (float)num * 50f + 222f;
			listHeightClosed = 586f;
			root = new GameObject("TD_Window", new Type[1] { typeof(RectTransform) });
			root.layer = LayerMask.NameToLayer("UI");
			Canvas obj = root.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 900;
			CanvasScaler obj2 = root.AddComponent<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(2300f, 1294f);
			obj2.matchWidthOrHeight = 0.5f;
			root.AddComponent<GraphicRaycaster>();
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0f, 1f);
			Vector2 aMax = default(Vector2);
			((Vector2)(ref aMax))..ctor(1f, 1f);
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(0f, 0f);
			Vector2 val4 = default(Vector2);
			((Vector2)(ref val4))..ctor(1f, 0f);
			Image val5 = Box("panel", root.transform, val, val, new Vector2(-30f, (0f - listHeightOpen) / 2f), new Vector2(870f, listHeightOpen / 2f), new Color(0.25f, 0.17f, 0.1f, 0.97f));
			if (skin)
			{
				val5.sprite = panelSprite;
				val5.type = panelType;
				((Graphic)val5).color = panelColor;
				val5.pixelsPerUnitMultiplier = panelPpu;
				if ((Object)(object)panelMaterial != (Object)null)
				{
					((Graphic)val5).material = panelMaterial;
				}
			}
			panelRt = ((Graphic)val5).rectTransform;
			Font val6 = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font f) => (Object)(object)f != (Object)null && ((Object)f).name == "Norsebold"));
			if ((Object)(object)val6 != (Object)null)
			{
				RectTransform obj3 = Rect("title", ((Component)val5).transform, val2, aMax, new Vector2(40f, -80f), new Vector2(-40f, -20f));
				Text obj4 = ((Component)obj3).gameObject.AddComponent<Text>();
				obj4.font = val6;
				obj4.fontSize = 46;
				((Graphic)obj4).color = titleColor;
				obj4.alignment = (TextAnchor)4;
				((Graphic)obj4).raycastTarget = false;
				obj4.horizontalOverflow = (HorizontalWrapMode)1;
				obj4.verticalOverflow = (VerticalWrapMode)1;
				obj4.text = "DummySeals";
				Outline obj5 = ((Component)obj3).gameObject.AddComponent<Outline>();
				((Shadow)obj5).effectColor = Color.black;
				((Shadow)obj5).effectDistance = new Vector2(2.5f, -2.5f);
			}
			else
			{
				Label("title", ((Component)val5).transform, val2, aMax, new Vector2(40f, -80f), new Vector2(-40f, -20f), "DUMMYSEALS", 44f, titleColor, (TextAlignmentOptions)514);
			}
			state = Label("state", ((Component)val5).transform, val2, aMax, new Vector2(40f, -106f), new Vector2(-40f, -80f), "", 26f, bodyColor, (TextAlignmentOptions)514);
			Sprite val7 = FindSprite("BraidLineHorisontalMedium");
			if ((Object)(object)val7 != (Object)null)
			{
				Image obj6 = Box("braid", ((Component)val5).transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-400f, -134f), new Vector2(400f, -112f), new Color(1f, 1f, 1f, 0.55f));
				obj6.sprite = val7;
				((Graphic)obj6).raycastTarget = false;
			}
			ticks = (Image[])(object)new Image[15];
			Color[] array = (Color[])(object)new Color[3] { Green, Amber, Red };
			for (int num2 = 0; num2 < 15; num2++)
			{
				float num3 = 33f + (float)num2 * 56f;
				Image val8 = Box("tick" + num2, ((Component)val5).transform, val2, val2, new Vector2(num3, -208f), new Vector2(num3 + 50f, -140f), Empty);
				Image val9 = Box("fill", ((Component)val8).transform, Vector2.zero, Vector2.one, new Vector2(4f, 4f), new Vector2(-4f, -4f), array[num2 / 5]);
				val9.sprite = FlatSprite();
				val9.type = (Type)3;
				val9.fillMethod = (FillMethod)1;
				val9.fillOrigin = 0;
				val9.fillAmount = 0f;
				((Graphic)val9).raycastTarget = false;
				ticks[num2] = val9;
			}
			timer = Label("timer", ((Component)val5).transform, val2, aMax, new Vector2(30f, -282f), new Vector2(-30f, -212f), "", 44f, Beige, (TextAlignmentOptions)514);
			Image val10 = Box("slot", ((Component)val5).transform, val2, val2, new Vector2(30f, -364f), new Vector2(104f, -290f), Empty);
			Button obj7 = ((Component)val10).gameObject.AddComponent<Button>();
			((Selectable)obj7).targetGraphic = (Graphic)(object)val10;
			ColorBlock colors = ((Selectable)obj7).colors;
			((ColorBlock)(ref colors)).highlightedColor = new Color(1.4f, 1.3f, 1.2f, 1f);
			((Selectable)obj7).colors = colors;
			ButtonClickedEvent onClick = obj7.onClick;
			object obj8 = <>c.<>9__68_1;
			if (obj8 == null)
			{
				UnityAction val11 = delegate
				{
					ClickSound();
					SlotClicked();
				};
				<>c.<>9__68_1 = val11;
				obj8 = (object)val11;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj8);
			slotIcon = Box("icon", ((Component)val10).transform, Vector2.zero, Vector2.one, new Vector2(5f, 5f), new Vector2(-5f, -5f), new Color(1f, 1f, 1f, 0f));
			((Graphic)slotIcon).raycastTarget = false;
			slotIcon.preserveAspect = true;
			slotCount = Label("count", ((Component)val10).transform, Vector2.zero, Vector2.one, new Vector2(4f, 2f), new Vector2(-6f, -2f), "", 28f, Beige, (TextAlignmentOptions)1028);
			slotInfo = Label("slotinfo", ((Component)val5).transform, val2, aMax, new Vector2(470f, -364f), new Vector2(-30f, -290f), "", 24f, Beige, (TextAlignmentOptions)513);
			addButton = MakeButton("add", ((Component)val5).transform, val2, val2, new Vector2(118f, -355f), new Vector2(268f, -299f), "Add Fuel", Green, AddFuel, out var labelOut, 26f);
			MakeButton("toggle", ((Component)val5).transform, val2, val2, new Vector2(284f, -355f), new Vector2(454f, -299f), "Materials", Orange, delegate
			{
				listOpen = !listOpen;
				Layout();
				Refresh();
			}, out labelOut, 26f);
			for (int num4 = 0; num4 < all.Count; num4++)
			{
				string key = all[num4].Key;
				float value = all[num4].Value;
				int num5 = num4 % 3;
				int num6 = num4 / 3;
				float num7 = 30f + (float)num5 * 290f;
				float num8 = -382f - (float)num6 * 50f;
				Image val12 = Box("item" + num4