Decompiled source of JotunnLib v0.1.10

JotunnLib.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using JotunnLib.Entities;
using JotunnLib.Events;
using JotunnLib.Managers;
using JotunnLib.Utils;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("JotunnLib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JotunnLib")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a6082a59-38be-4cab-9078-2c8fcda65b8f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]
[assembly: AssemblyVersion("1.0.0.0")]
internal static class ObjImporter
{
	private struct meshStruct
	{
		public Vector3[] vertices;

		public Vector3[] normals;

		public Vector2[] uv;

		public Vector2[] uv1;

		public Vector2[] uv2;

		public int[] triangles;

		public int[] faceVerts;

		public int[] faceUVs;

		public Vector3[] faceData;

		public string name;

		public string fileName;
	}

	public static Mesh ImportFile(string filePath)
	{
		//IL_004f: 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_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: 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_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Expected O, but got Unknown
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		meshStruct mesh = createMeshStruct(filePath);
		populateMeshStruct(ref mesh);
		Vector3[] array = (Vector3[])(object)new Vector3[mesh.faceData.Length];
		Vector2[] array2 = (Vector2[])(object)new Vector2[mesh.faceData.Length];
		Vector3[] array3 = (Vector3[])(object)new Vector3[mesh.faceData.Length];
		int num = 0;
		Vector3[] faceData = mesh.faceData;
		foreach (Vector3 val in faceData)
		{
			array[num] = mesh.vertices[(int)val.x - 1];
			if (val.y >= 1f)
			{
				array2[num] = mesh.uv[(int)val.y - 1];
			}
			if (val.z >= 1f)
			{
				array3[num] = mesh.normals[(int)val.z - 1];
			}
			num++;
		}
		Mesh val2 = new Mesh
		{
			vertices = array,
			uv = array2,
			normals = array3,
			triangles = mesh.triangles
		};
		val2.RecalculateBounds();
		val2.Optimize();
		return val2;
	}

	private static meshStruct createMeshStruct(string filename)
	{
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		int num5 = 0;
		meshStruct result = default(meshStruct);
		result.fileName = filename;
		StreamReader streamReader = File.OpenText(filename);
		string s = streamReader.ReadToEnd();
		streamReader.Close();
		using (StringReader stringReader = new StringReader(s))
		{
			string text = stringReader.ReadLine();
			char[] separator = new char[1] { ' ' };
			while (text != null)
			{
				if (!text.StartsWith("f ") && !text.StartsWith("v ") && !text.StartsWith("vt ") && !text.StartsWith("vn "))
				{
					text = stringReader.ReadLine();
					if (text != null)
					{
						text = text.Replace("  ", " ");
					}
					continue;
				}
				text = text.Trim();
				string[] array = text.Split(separator, 50);
				switch (array[0])
				{
				case "v":
					num2++;
					break;
				case "vt":
					num3++;
					break;
				case "vn":
					num4++;
					break;
				case "f":
					num5 = num5 + array.Length - 1;
					num += 3 * (array.Length - 2);
					break;
				}
				text = stringReader.ReadLine();
				if (text != null)
				{
					text = text.Replace("  ", " ");
				}
			}
		}
		result.triangles = new int[num];
		result.vertices = (Vector3[])(object)new Vector3[num2];
		result.uv = (Vector2[])(object)new Vector2[num3];
		result.normals = (Vector3[])(object)new Vector3[num4];
		result.faceData = (Vector3[])(object)new Vector3[num5];
		return result;
	}

	private static void populateMeshStruct(ref meshStruct mesh)
	{
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0382: Unknown result type (might be due to invalid IL or missing references)
		//IL_034e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0353: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ba: 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_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0324: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0448: Unknown result type (might be due to invalid IL or missing references)
		//IL_044a: Unknown result type (might be due to invalid IL or missing references)
		StreamReader streamReader = File.OpenText(mesh.fileName);
		string s = streamReader.ReadToEnd();
		streamReader.Close();
		using StringReader stringReader = new StringReader(s);
		string text = stringReader.ReadLine();
		char[] separator = new char[1] { ' ' };
		char[] separator2 = new char[1] { '/' };
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		int num5 = 0;
		int num6 = 0;
		int num7 = 0;
		while (text != null)
		{
			if (!text.StartsWith("f ") && !text.StartsWith("v ") && !text.StartsWith("vt ") && !text.StartsWith("vn ") && !text.StartsWith("g ") && !text.StartsWith("usemtl ") && !text.StartsWith("mtllib ") && !text.StartsWith("vt1 ") && !text.StartsWith("vt2 ") && !text.StartsWith("vc ") && !text.StartsWith("usemap "))
			{
				text = stringReader.ReadLine();
				if (text != null)
				{
					text = text.Replace("  ", " ");
				}
				continue;
			}
			text = text.Trim();
			string[] array = text.Split(separator, 50);
			switch (array[0])
			{
			case "v":
				mesh.vertices[num3] = new Vector3(Convert.ToSingle(array[1]), Convert.ToSingle(array[2]), Convert.ToSingle(array[3]));
				num3++;
				break;
			case "vt":
				mesh.uv[num5] = new Vector2(Convert.ToSingle(array[1]), Convert.ToSingle(array[2]));
				num5++;
				break;
			case "vt1":
				mesh.uv[num6] = new Vector2(Convert.ToSingle(array[1]), Convert.ToSingle(array[2]));
				num6++;
				break;
			case "vt2":
				mesh.uv[num7] = new Vector2(Convert.ToSingle(array[1]), Convert.ToSingle(array[2]));
				num7++;
				break;
			case "vn":
				mesh.normals[num4] = new Vector3(Convert.ToSingle(array[1]), Convert.ToSingle(array[2]), Convert.ToSingle(array[3]));
				num4++;
				break;
			case "f":
			{
				int num8 = 1;
				List<int> list = new List<int>();
				while (num8 < array.Length && (array[num8] ?? "").Length > 0)
				{
					Vector3 val = default(Vector3);
					string[] array2 = array[num8].Split(separator2, 3);
					val.x = Convert.ToInt32(array2[0]);
					if (array2.Length > 1)
					{
						if (array2[1] != "")
						{
							val.y = Convert.ToInt32(array2[1]);
						}
						val.z = Convert.ToInt32(array2[2]);
					}
					num8++;
					mesh.faceData[num2] = val;
					list.Add(num2);
					num2++;
				}
				for (num8 = 1; num8 + 2 < array.Length; num8++)
				{
					mesh.triangles[num] = list[0];
					num++;
					mesh.triangles[num] = list[num8];
					num++;
					mesh.triangles[num] = list[num8 + 1];
					num++;
				}
				break;
			}
			}
			text = stringReader.ReadLine();
			if (text != null)
			{
				text = text.Replace("  ", " ");
			}
		}
	}
}
namespace JotunnLib
{
	public abstract class Manager : MonoBehaviour
	{
		internal virtual void Init()
		{
		}

		internal virtual void Load()
		{
		}

		internal virtual void Register()
		{
		}
	}
	[BepInPlugin("com.bepinex.plugins.jotunnlib", "JotunnLib", "0.1.9")]
	public class JotunnLib : BaseUnityPlugin
	{
		public const string Version = "0.1.9";

		public const string ModGuid = "com.bepinex.plugins.jotunnlib";

		private readonly List<Type> managerTypes = new List<Type>
		{
			typeof(LocalizationManager),
			typeof(EventManager),
			typeof(CommandManager),
			typeof(InputManager),
			typeof(SkillManager),
			typeof(PrefabManager),
			typeof(PieceManager),
			typeof(ObjectManager),
			typeof(ZoneManager)
		};

		private readonly List<Manager> managers = new List<Manager>();

		internal static GameObject RootObject;

		private void Awake()
		{
			//IL_0005: 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_001e: Expected O, but got Unknown
			new Harmony("jotunnlib").PatchAll();
			RootObject = new GameObject("_JotunnLibRoot");
			Object.DontDestroyOnLoad((Object)(object)RootObject);
			foreach (Type managerType in managerTypes)
			{
				managers.Add((Manager)(object)RootObject.AddComponent(managerType));
			}
			foreach (Manager manager in managers)
			{
				manager.Init();
			}
			initCommands();
			Debug.Log((object)"JotunnLib v0.1.9 loaded successfully");
		}

		private void initCommands()
		{
		}
	}
}
namespace JotunnLib.Utils
{
	public class ReflectionUtils
	{
		public static object InvokePrivate(object instance, string name, object[] args = null)
		{
			MethodInfo method = instance.GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.NonPublic);
			if (method == null)
			{
				Type[] types = ((args == null) ? new Type[0] : args.Select((object arg) => arg.GetType()).ToArray());
				method = instance.GetType().GetMethod(name, types);
			}
			if (method == null)
			{
				Debug.LogError((object)("Method " + name + " does not exist on type: " + instance.GetType()));
				return null;
			}
			return method.Invoke(instance, args);
		}

		public static T GetPrivateField<T>(object instance, string name)
		{
			FieldInfo field = instance.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic);
			if (field == null)
			{
				Debug.LogError((object)("Variable " + name + " does not exist on type: " + instance.GetType()));
				return default(T);
			}
			return (T)field.GetValue(instance);
		}

		public static void SetPrivateField(object instance, string name, object value)
		{
			FieldInfo field = instance.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic);
			if (field == null)
			{
				Debug.LogError((object)("Variable " + name + " does not exist on type: " + instance.GetType()));
			}
			else
			{
				field.SetValue(instance, value);
			}
		}

		public static T GetPrivateStaticField<T>(Type type, string name)
		{
			FieldInfo field = type.GetField(name, BindingFlags.Static | BindingFlags.NonPublic);
			if (field == null)
			{
				Debug.LogError((object)("Variable " + name + " does not exist on static type: " + type));
				return default(T);
			}
			return (T)field.GetValue(null);
		}
	}
	public static class AssetUtils
	{
		public static Texture2D LoadTexture(string texturePath)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_002d: Expected O, but got Unknown
			string path = Path.Combine(Paths.PluginPath, texturePath);
			if (!File.Exists(path))
			{
				return null;
			}
			byte[] array = File.ReadAllBytes(path);
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, array);
			return val;
		}

		public static Mesh LoadMesh(string meshPath)
		{
			string text = Path.Combine(Paths.PluginPath, meshPath);
			if (!File.Exists(text))
			{
				return null;
			}
			return ObjImporter.ImportFile(text);
		}
	}
}
namespace JotunnLib.Patches
{
	internal class ObjectDBPatches
	{
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class AwakePatch
		{
			public static void Postfix()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name == "main")
				{
					ObjectManager.Instance.Register();
					ObjectManager.Instance.Load();
					PieceManager.Instance.Register();
					PieceManager.Instance.Load();
				}
			}
		}
	}
	internal class ZInputPatches
	{
		[HarmonyPatch(typeof(ZInput), "Initialize")]
		public static class InitializePatch
		{
			public static void Prefix()
			{
				InputManager.Instance.Register();
			}
		}

		[HarmonyPatch(typeof(ZInput), "Reset")]
		public static class ResetPatch
		{
			public static void Postfix(ref ZInput __instance)
			{
				InputManager.Instance.Load(__instance);
			}
		}
	}
	internal class ZoneSystemPatches
	{
		[HarmonyPatch(typeof(ZoneSystem), "Awake")]
		public static class AwakePatch
		{
			public static void Postfix()
			{
			}
		}

		[HarmonyPatch(typeof(ZoneSystem), "SpawnZone")]
		public static class SpawnZonePatch
		{
			public static void Prefix(Vector2i zoneID)
			{
			}
		}
	}
	internal class ZNetScenePatches
	{
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		public static class AwakePatch
		{
			public static void Postfix()
			{
				PrefabManager.Instance.Register();
				PrefabManager.Instance.Load();
				ZoneManager.Instance.Register();
				ZoneManager.Instance.Load();
			}
		}
	}
	internal class PlayerPatches
	{
		[HarmonyPatch(typeof(Player), "OnSpawned")]
		public static class OnSpawnedPatch
		{
			public static void Prefix(ref Player __instance, ref bool ___m_firstSpawn)
			{
				EventManager.OnPlayerSpawned(__instance);
			}
		}

		[HarmonyPatch(typeof(Player), "PlacePiece")]
		public static class PlacePiecePatch
		{
			public static void Postfix(ref Player __instance, Piece piece, bool __result, GameObject ___m_placementGhost)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				EventManager.OnPlayerPlacedPiece(new PlayerPlacedPieceEventArgs
				{
					Player = __instance,
					Piece = piece,
					Position = ___m_placementGhost.transform.position,
					Rotation = ___m_placementGhost.transform.rotation,
					Success = __result
				});
			}
		}
	}
	internal class SkillsPatches
	{
		[HarmonyPatch(typeof(Skills), "Awake")]
		public static class AwakePatch
		{
			public static void Postfix(ref Skills __instance)
			{
				foreach (KeyValuePair<SkillType, SkillDef> skill in SkillManager.Instance.Skills)
				{
					SkillDef value = skill.Value;
					__instance.m_skills.Add(value);
					Console.WriteLine("Added extra skill: " + ((object)(SkillType)(ref value.m_skill)).ToString());
				}
			}
		}

		[HarmonyPatch(typeof(Skills), "IsSkillValid")]
		public static class IsSkillValidPatch
		{
			public static bool Prefix(ref bool __result, SkillType type)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				foreach (KeyValuePair<SkillType, SkillDef> skill in SkillManager.Instance.Skills)
				{
					if (skill.Value.m_skill == type)
					{
						__result = true;
						return false;
					}
				}
				return true;
			}
		}
	}
}
namespace JotunnLib.Managers
{
	public class CommandManager : Manager
	{
		private static List<ConsoleCommand> queuedCommands = new List<ConsoleCommand>();

		public static CommandManager Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Debug.LogError((object)("Error, two instances of singleton: " + ((object)this).GetType().Name));
			}
			else
			{
				Instance = this;
			}
		}

		[Obsolete("Please use RegisterConsoleCommand(Terminal.ConsoleCommand cmd) instead", false)]
		public void RegisterConsoleCommand(ConsoleCommand cmd)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			RegisterConsoleCommand(new ConsoleCommand(cmd.Name, cmd.Help, (ConsoleEvent)delegate(ConsoleEventArgs args)
			{
				cmd.Run(args.Args);
			}, false, false, false, false, false, (ConsoleOptionsFetcher)null));
		}

		public void RegisterConsoleCommand(ConsoleCommand cmd)
		{
			if (!ReflectionUtils.GetPrivateStaticField<bool>(typeof(Terminal), "m_terminalInitialized"))
			{
				queuedCommands.Add(cmd);
				return;
			}
			Dictionary<string, ConsoleCommand> privateField = ReflectionUtils.GetPrivateField<Dictionary<string, ConsoleCommand>>(Console.instance, "commands");
			if (queuedCommands.Count > 0)
			{
				foreach (ConsoleCommand queuedCommand in queuedCommands)
				{
					if (privateField.ContainsKey(queuedCommand.Command))
					{
						Debug.LogError((object)("Cannot have two console commands with same name: " + cmd.Command));
						return;
					}
					privateField.Add(queuedCommand.Command, queuedCommand);
				}
				queuedCommands.Clear();
			}
			if (privateField.ContainsKey(cmd.Command))
			{
				Debug.LogError((object)("Cannot have two console commands with same name: " + cmd.Command));
			}
			else
			{
				privateField.Add(cmd.Command, cmd);
			}
		}
	}
	public class EventManager : Manager
	{
		internal static EventManager Instance { get; private set; }

		public static event EventHandler<PlayerEventArgs> PlayerSpawned;

		public static event EventHandler<PlayerPlacedPieceEventArgs> PlayerPlacedPiece;

		private static event EventHandler PlayerDied;

		private static event EventHandler PlayerSentChat;

		private static event EventHandler<PlayerEventArgs> PlayerConnected;

		private static event EventHandler<PlayerEventArgs> PlayerDisconnected;

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Debug.LogError((object)("Error, two instances of singleton: " + ((object)this).GetType().Name));
			}
			else
			{
				Instance = this;
			}
		}

		internal static void OnPlayerSpawned(Player player)
		{
			EventManager.PlayerSpawned?.Invoke(player, new PlayerEventArgs
			{
				Player = player
			});
		}

		internal static void OnPlayerPlacedPiece(PlayerPlacedPieceEventArgs args)
		{
			EventManager.PlayerPlacedPiece?.Invoke(args.Player, args);
		}
	}
	public class InputManager : Manager
	{
		public EventHandler InputRegister;

		internal static Dictionary<string, ButtonConfig> Buttons = new Dictionary<string, ButtonConfig>();

		private bool inputsRegistered;

		public static InputManager Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Debug.LogError((object)("Error, two instances of singleton: " + ((object)this).GetType().Name));
			}
			else
			{
				Instance = this;
			}
		}

		internal void Load(ZInput zinput)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"---- Registering custom inputs ----");
			if (zinput == null)
			{
				Debug.LogError((object)"\t-> ZInput does not exist yet, delaying...");
				return;
			}
			foreach (KeyValuePair<string, ButtonConfig> button in Buttons)
			{
				ButtonConfig value = button.Value;
				if (value.Axis != null && value.Axis.Length > 0)
				{
					zinput.AddButton(value.Name, value.Axis, value.Inverted, value.RepeatDelay, value.RepeatInterval, true, false);
				}
				else
				{
					zinput.AddButton(value.Name, value.Key, value.RepeatDelay, value.RepeatInterval, true, false);
				}
				Debug.Log((object)("Registered input: " + button.Key));
			}
		}

		internal override void Register()
		{
			if (!inputsRegistered)
			{
				InputRegister?.Invoke(null, EventArgs.Empty);
				inputsRegistered = true;
			}
		}

		public void RegisterButton(string name, ButtonConfig button)
		{
			if (Buttons.ContainsKey(name))
			{
				Debug.LogError((object)("Cannot have duplicate button: " + name));
			}
			else
			{
				Buttons.Add(name, button);
			}
		}

		public void RegisterButton(string name, KeyCode key, float repeatDelay = 0f, float repeatInterval = 0f)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (Buttons.ContainsKey(name))
			{
				Debug.LogError((object)("Cannot have duplicate button: " + name));
				return;
			}
			Buttons.Add(name, new ButtonConfig
			{
				Name = name,
				Key = key,
				RepeatDelay = repeatDelay,
				RepeatInterval = repeatInterval
			});
		}

		public void RegisterButton(string name, string axis, bool inverted = false, float repeatDelay = 0f, float repeatInterval = 0f)
		{
			if (Buttons.ContainsKey(name))
			{
				Debug.LogError((object)("Cannot have duplicate button: " + name));
				return;
			}
			Buttons.Add(name, new ButtonConfig
			{
				Name = name,
				Axis = axis,
				Inverted = inverted,
				RepeatDelay = repeatDelay,
				RepeatInterval = repeatInterval
			});
		}
	}
	public class LocalizationManager : Manager
	{
		internal Dictionary<string, List<LocalizationConfig>> Localizations = new Dictionary<string, List<LocalizationConfig>>();

		public static LocalizationManager Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Debug.LogError((object)("Error, two instances of singleton: " + ((object)this).GetType().Name));
			}
			else
			{
				Instance = this;
			}
		}

		public void RegisterTranslation(string key, string text)
		{
			ReflectionUtils.InvokePrivate(Localization.instance, "AddWord", new object[2] { key, text });
		}

		internal void RegisterTranslation(LocalizationConfig localization)
		{
		}
	}
	public class ObjectManager : Manager
	{
		internal List<GameObject> Items = new List<GameObject>();

		internal List<Recipe> Recipes = new List<Recipe>();

		public static ObjectManager Instance { get; private set; }

		public event EventHandler ObjectRegister;

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Debug.LogError((object)("Error, two instances of singleton: " + ((object)this).GetType().Name));
			}
			else
			{
				Instance = this;
			}
		}

		internal override void Register()
		{
			Debug.Log((object)"---- Registering custom objects ----");
			Items.Clear();
			Recipes.Clear();
			this.ObjectRegister?.Invoke(null, EventArgs.Empty);
		}

		internal override void Load()
		{
			Debug.Log((object)"---- Loading custom objects ----");
			foreach (GameObject item in Items)
			{
				try
				{
					ObjectDB.instance.m_items.Add(item);
					Debug.Log((object)("Loaded item: " + ((Object)item).name));
				}
				catch (Exception ex)
				{
					Debug.Log((object)("Error loading item: " + ex));
				}
			}
			foreach (Recipe recipe in Recipes)
			{
				try
				{
					ObjectDB.instance.m_recipes.Add(recipe);
					Debug.Log((object)("Loaded item recipe: " + ((Object)recipe).name));
				}
				catch (Exception ex2)
				{
					Debug.Log((object)("Error loading recipe: " + ex2));
				}
			}
			try
			{
				ReflectionUtils.InvokePrivate(ObjectDB.instance, "UpdateItemHashes");
			}
			catch (Exception ex3)
			{
				Debug.Log((object)("Error updating item hashes: " + ex3));
			}
		}

		public void RegisterItem(string prefabName)
		{
			Items.Add(PrefabManager.Instance.GetPrefab(prefabName));
		}

		public void RegisterItem(GameObject item)
		{
			if (item.layer == 0)
			{
				item.layer = LayerMask.NameToLayer("item");
			}
			Items.Add(item);
		}

		public void RegisterRecipe(RecipeConfig recipeConfig)
		{
			Recipe recipe = recipeConfig.GetRecipe();
			if ((Object)(object)recipe == (Object)null)
			{
				Debug.LogError((object)("Failed to add recipe for item: " + recipeConfig.Item));
			}
			else
			{
				Recipes.Add(recipe);
			}
		}

		public void RegisterRecipe(Recipe recipe)
		{
			if ((Object)(object)recipe == (Object)null)
			{
				Debug.LogError((object)"Failed to add null recipe");
			}
			else
			{
				Recipes.Add(recipe);
			}
		}

		public GameObject GetItemPrefab(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			return ObjectDB.instance.GetItemPrefab(name);
		}

		public ItemDrop GetItemDrop(string name)
		{
			GameObject itemPrefab = GetItemPrefab(name);
			if (itemPrefab == null)
			{
				return null;
			}
			return itemPrefab.GetComponent<ItemDrop>();
		}
	}
	public class PieceManager : Manager
	{
		internal GameObject PieceTableContainer;

		private bool loaded;

		private Dictionary<string, PieceTable> pieceTables = new Dictionary<string, PieceTable>();

		private Dictionary<string, string> pieceTableNameMap = new Dictionary<string, string>
		{
			{ "Cultivator", "_CultivatorPieceTable" },
			{ "Hammer", "_HammerPieceTable" },
			{ "Hoe", "_HoePieceTable" }
		};

		public static PieceManager Instance { get; private set; }

		public event EventHandler PieceTableRegister;

		public event EventHandler PieceRegister;

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Debug.LogError((object)("Error, two instances of singleton: " + ((object)this).GetType().Name));
			}
			else
			{
				Instance = this;
			}
		}

		internal override void Init()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			PieceTableContainer = new GameObject("PieceTables");
			PieceTableContainer.transform.parent = JotunnLib.RootObject.transform;
			Debug.Log((object)"Initialized PieceTableManager");
		}

		internal override void Register()
		{
		}

		internal override void Load()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			if (loaded)
			{
				return;
			}
			pieceTables.Clear();
			foreach (Transform item in PieceTableContainer.transform)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			List<string> list = new List<string>();
			Debug.Log((object)"---- Loading piece tables ----");
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(PieceTable));
			for (int i = 0; i < array.Length; i++)
			{
				PieceTable val = (PieceTable)array[i];
				try
				{
					string name = ((Object)((Component)val).gameObject).name;
					if (!pieceTables.ContainsKey(name))
					{
						pieceTables.Add(name, val);
					}
					if (!list.Contains(name))
					{
						list.Add(name);
						Debug.Log((object)("Loaded existing piece table: " + name));
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)("Error loading piece table: " + ex));
				}
			}
			this.PieceTableRegister?.Invoke(null, EventArgs.Empty);
			foreach (KeyValuePair<string, PieceTable> pieceTable in pieceTables)
			{
				try
				{
					PieceTable value = pieceTable.Value;
					string name2 = ((Object)((Component)value).gameObject).name;
					if (!list.Contains(name2))
					{
						pieceTables.Add(name2, value);
						Debug.Log((object)("Registered piece table: " + name2));
					}
				}
				catch (Exception ex2)
				{
					Debug.Log((object)("Error registering piece table: " + ex2));
				}
			}
			Debug.Log((object)"---- Loading pieces ----");
			this.PieceRegister?.Invoke(null, EventArgs.Empty);
			loaded = true;
		}

		public void RegisterPieceTable(string name)
		{
			//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)
			if (pieceTables.ContainsKey(name))
			{
				Debug.Log((object)("Failed to register piece table with existing name: " + name));
				return;
			}
			GameObject val = new GameObject(name);
			val.transform.parent = PieceTableContainer.transform;
			PieceTable value = val.AddComponent<PieceTable>();
			pieceTables.Add(name, value);
		}

		public void RegisterPiece(string pieceTable, string prefabName)
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab(prefabName);
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				Debug.LogError((object)("Failed to register Piece with invalid prefab: " + prefabName));
			}
			else
			{
				RegisterPiece(pieceTable, prefab);
			}
		}

		internal void RegisterPiece(string pieceTable, GameObject prefab)
		{
			PieceTable pieceTable2 = getPieceTable(pieceTable);
			if (!Object.op_Implicit((Object)(object)pieceTable2))
			{
				Debug.LogError((object)("Failed to register piece, Piece table does not exist: " + pieceTable));
				return;
			}
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				Debug.LogError((object)"Failed to register Piece with null prefab");
				return;
			}
			if (!Object.op_Implicit((Object)(object)prefab.GetComponent<Piece>()))
			{
				Debug.LogError((object)("Failed to register piece, Prefab does not have Piece component: " + ((Object)prefab).name));
				return;
			}
			if (prefab.layer == 0)
			{
				prefab.layer = LayerMask.NameToLayer("piece");
			}
			pieceTable2.m_pieces.Add(prefab);
			Debug.Log((object)("Registered piece: " + ((Object)prefab).name + " to " + pieceTable));
		}

		private PieceTable getPieceTable(string name)
		{
			if (pieceTables.ContainsKey(name))
			{
				return pieceTables[name];
			}
			if (pieceTableNameMap.ContainsKey(name))
			{
				return pieceTables[pieceTableNameMap[name]];
			}
			return null;
		}
	}
	public class PrefabManager : Manager
	{
		internal static GameObject PrefabContainer;

		internal Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>();

		private bool loaded;

		public static PrefabManager Instance { get; private set; }

		public event EventHandler PrefabRegister;

		public event EventHandler PrefabsLoaded;

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Debug.LogError((object)("Error, two instances of singleton: " + ((object)this).GetType().Name));
			}
			else
			{
				Instance = this;
			}
		}

		internal override void Init()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			PrefabContainer = new GameObject("Prefabs");
			PrefabContainer.transform.parent = JotunnLib.RootObject.transform;
			PrefabContainer.SetActive(false);
			Debug.Log((object)"Initialized PrefabManager");
		}

		internal override void Register()
		{
		}

		internal override void Load()
		{
			Debug.Log((object)"---- Registering custom prefabs ----");
			if (!loaded)
			{
				this.PrefabRegister?.Invoke(null, EventArgs.Empty);
			}
			Dictionary<int, GameObject> privateField = ReflectionUtils.GetPrivateField<Dictionary<int, GameObject>>(ZNetScene.instance, "m_namedPrefabs");
			foreach (KeyValuePair<string, GameObject> prefab in Prefabs)
			{
				try
				{
					GameObject value = prefab.Value;
					ZNetScene.instance.m_prefabs.Add(value);
					privateField.Add(StringExtensionMethods.GetStableHashCode(((Object)value).name), value);
					Debug.Log((object)("Registered prefab: " + prefab.Key));
				}
				catch (Exception ex)
				{
					Debug.Log((object)("Error registering prefab: " + ex));
				}
			}
			if (!loaded)
			{
				this.PrefabsLoaded?.Invoke(null, EventArgs.Empty);
			}
			Debug.Log((object)"All prefabs loaded");
			loaded = true;
		}

		public void RegisterPrefab(GameObject prefab, string name = null)
		{
			if (name == null)
			{
				name = ((Object)prefab).name;
			}
			if (Object.op_Implicit((Object)(object)GetPrefab(name)))
			{
				Debug.LogError((object)("Failed to register prefab that already exists: " + name));
				return;
			}
			((Object)prefab).name = name;
			prefab.transform.parent = PrefabContainer.transform;
			prefab.SetActive(true);
			Prefabs.Add(name, prefab);
		}

		public void RegisterPrefab(PrefabConfig prefabConfig)
		{
			if (prefabConfig.BasePrefabName == null || prefabConfig.BasePrefabName == "")
			{
				prefabConfig.Prefab = CreatePrefab(prefabConfig.Name);
			}
			else
			{
				prefabConfig.Prefab = CreatePrefab(prefabConfig.Name, prefabConfig.BasePrefabName);
			}
			if ((Object)(object)prefabConfig.Prefab != (Object)null)
			{
				prefabConfig.Register();
			}
		}

		public GameObject CreatePrefab(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				Debug.LogError((object)("Failed to create prefab with invalid name: " + name));
				return null;
			}
			if (Object.op_Implicit((Object)(object)GetPrefab(name)))
			{
				Debug.LogError((object)("Failed to create prefab, name already exists: " + name));
				return null;
			}
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = name;
			val.transform.parent = PrefabContainer.transform;
			val.AddComponent<ZNetView>().m_persistent = true;
			Prefabs.Add(name, val);
			return val;
		}

		public GameObject CreatePrefab(string name, string baseName)
		{
			if (string.IsNullOrEmpty(name))
			{
				Debug.LogError((object)("Failed to create prefab with invalid name: " + name));
				return null;
			}
			if (Object.op_Implicit((Object)(object)GetPrefab(name)))
			{
				Debug.LogError((object)("Failed to create prefab, name already exists: " + name));
				return null;
			}
			GameObject prefab = GetPrefab(baseName);
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				Debug.LogError((object)("Failed to create prefab, base does not exist: " + baseName));
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(prefab, PrefabContainer.transform);
			((Object)val).name = name;
			val.SetActive(true);
			Prefabs.Add(name, val);
			return val;
		}

		public GameObject GetPrefab(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			if (Prefabs.ContainsKey(name))
			{
				return Prefabs[name];
			}
			if (!Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				Debug.LogError((object)"\t-> ZNetScene instance null for some reason");
				return null;
			}
			Dictionary<int, GameObject> privateField = ReflectionUtils.GetPrivateField<Dictionary<int, GameObject>>(ZNetScene.instance, "m_namedPrefabs");
			int stableHashCode = StringExtensionMethods.GetStableHashCode(name);
			if (privateField.ContainsKey(stableHashCode))
			{
				return privateField[stableHashCode];
			}
			return null;
		}
	}
	internal class ZoneManager : Manager
	{
		internal List<ZoneVegetation> Vegetation = new List<ZoneVegetation>();

		public static ZoneManager Instance { get; private set; }

		public event EventHandler ZoneLoad;

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Debug.LogError((object)("Error, two instances of singleton: " + ((object)this).GetType().Name));
			}
			else
			{
				Instance = this;
			}
		}

		internal override void Register()
		{
			Debug.Log((object)"---- Registering custom zone data ----");
			this.ZoneLoad?.Invoke(null, EventArgs.Empty);
			foreach (ZoneVegetation item in Vegetation)
			{
				ZoneSystem.instance.m_vegetation.Add(item);
				Debug.Log((object)("Added vegetation: " + item.m_name));
			}
		}

		public void RegisterVegetation(ZoneVegetation veg)
		{
			Vegetation.Add(veg);
		}
	}
	public class SkillManager : Manager
	{
		internal Dictionary<SkillType, SkillDef> Skills = new Dictionary<SkillType, SkillDef>();

		private int nextSkillId = 1000;

		public static SkillManager Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Debug.LogError((object)("Error, two instances of singleton: " + ((object)this).GetType().Name));
			}
			else
			{
				Instance = this;
			}
		}

		[Obsolete("Use `RegisterSkill(SkillConfig config)` instead. This method could potentially cause users to lose skill save progress", true)]
		public SkillType RegisterSkill(string name, string description, float increaseStep = 1f, Sprite icon = null)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			LocalizationManager.Instance.RegisterTranslation("skill_" + nextSkillId, name);
			LocalizationManager.Instance.RegisterTranslation("skill_" + nextSkillId + "_description", description);
			SkillDef val = new SkillDef
			{
				m_skill = (SkillType)nextSkillId,
				m_description = "$skill_" + nextSkillId + "_description",
				m_increseStep = increaseStep,
				m_icon = icon
			};
			Skills.Add((SkillType)nextSkillId, val);
			nextSkillId++;
			return val.m_skill;
		}

		public SkillType RegisterSkill(SkillConfig skillConfig, bool registerLocalizations = true)
		{
			//IL_002b: 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_0067: Invalid comparison between Unknown and I4
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected I4, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_013f: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(skillConfig.Identifier))
			{
				Debug.LogError((object)("Failed to register skill with invalid identifier: " + skillConfig.Identifier));
				return (SkillType)0;
			}
			SkillType uID;
			if (Skills.ContainsKey(skillConfig.UID))
			{
				uID = skillConfig.UID;
				Debug.LogError((object)("Failed to register skill with conflicting UID (m_skill): " + ((object)(SkillType)(ref uID)).ToString()));
				return (SkillType)0;
			}
			if ((int)skillConfig.UID < 1000)
			{
				Debug.LogError((object)("Failed to register skill with invalid UID (m_skill), please use a UID >= 1000: " + (int)skillConfig.UID));
				return (SkillType)0;
			}
			if (registerLocalizations)
			{
				LocalizationManager instance = LocalizationManager.Instance;
				uID = skillConfig.UID;
				instance.RegisterTranslation("skill_" + ((object)(SkillType)(ref uID)).ToString(), skillConfig.Name);
				LocalizationManager instance2 = LocalizationManager.Instance;
				uID = skillConfig.UID;
				instance2.RegisterTranslation("skill_" + ((object)(SkillType)(ref uID)).ToString() + "_description", skillConfig.Description);
			}
			SkillDef val = new SkillDef
			{
				m_skill = skillConfig.UID
			};
			uID = skillConfig.UID;
			val.m_description = "$skill_" + ((object)(SkillType)(ref uID)).ToString() + "_description";
			val.m_increseStep = skillConfig.IncreaseStep;
			val.m_icon = skillConfig.Icon;
			SkillDef val2 = val;
			Skills.Add(skillConfig.UID, val2);
			return val2.m_skill;
		}

		public SkillType RegisterSkill(string identifer, string name, string description, float increaseStep = 1f, Sprite icon = null, bool registerLocalizations = true)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			return RegisterSkill(new SkillConfig
			{
				Identifier = identifer,
				Name = name,
				Description = description,
				IncreaseStep = increaseStep,
				Icon = icon
			}, registerLocalizations);
		}

		public SkillDef GetSkill(SkillType skillType)
		{
			//IL_0006: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (Skills.ContainsKey(skillType))
			{
				return Skills[skillType];
			}
			if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)((Character)Player.m_localPlayer).GetSkills() != (Object)null)
			{
				foreach (SkillDef skill in ((Character)Player.m_localPlayer).GetSkills().m_skills)
				{
					if (skill.m_skill == skillType)
					{
						return skill;
					}
				}
			}
			return null;
		}

		public SkillDef GetSkill(string identifier)
		{
			if (string.IsNullOrEmpty(identifier))
			{
				return null;
			}
			return GetSkill((SkillType)StringExtensionMethods.GetStableHashCode(identifier));
		}
	}
}
namespace JotunnLib.Events
{
	public class PlayerEventArgs : EventArgs
	{
		public Player Player { get; set; }
	}
	public class PlayerPlacedPieceEventArgs : PlayerEventArgs
	{
		public Piece Piece { get; set; }

		public Vector3 Position { get; set; }

		public Quaternion Rotation { get; set; }

		public bool Success { get; set; }
	}
}
namespace JotunnLib.Entities
{
	public class ButtonConfig
	{
		public string Name { get; set; }

		public string Axis { get; set; }

		public KeyCode Key { get; set; }

		public bool Inverted { get; set; }

		public float RepeatDelay { get; set; }

		public float RepeatInterval { get; set; }
	}
	internal class LocalizationConfig
	{
		public Dictionary<string, string> Translations = new Dictionary<string, string>();

		public string Language { get; set; } = "English";

	}
	public class PieceConfig
	{
		public string Name { get; set; }

		public string Description { get; set; } = "";


		public PieceRequirementConfig[] Requirements { get; set; } = new PieceRequirementConfig[0];


		public Requirement[] GetRequirements()
		{
			Requirement[] array = (Requirement[])(object)new Requirement[Requirements.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = Requirements[i].GetPieceRequirement();
			}
			return array;
		}
	}
	public class PieceRequirementConfig
	{
		public string Item { get; set; }

		public int Amount { get; set; }

		public int AmountPerLevel { get; set; }

		public bool Recover { get; set; }

		public Requirement GetPieceRequirement()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			return new Requirement
			{
				m_resItem = PrefabManager.Instance.GetPrefab(Item).GetComponent<ItemDrop>(),
				m_amount = Amount,
				m_amountPerLevel = AmountPerLevel,
				m_recover = Recover
			};
		}
	}
	public abstract class PrefabConfig
	{
		public string Name { get; private set; }

		public string BasePrefabName { get; private set; }

		public GameObject Prefab { get; set; }

		public PrefabConfig(string name)
		{
			Name = name;
		}

		public PrefabConfig(string name, string baseName)
		{
			Name = name;
			BasePrefabName = baseName;
		}

		public abstract void Register();

		public Piece AddPiece(PieceConfig pieceConfig)
		{
			Piece obj = Prefab.AddComponent<Piece>();
			obj.m_name = pieceConfig.Name;
			obj.m_description = pieceConfig.Description;
			obj.m_resources = pieceConfig.GetRequirements();
			return obj;
		}
	}
	public class RecipeConfig
	{
		public string Name { get; set; }

		public string Item { get; set; }

		public int Amount { get; set; } = 1;


		public bool Enabled { get; set; } = true;


		public string CraftingStation { get; set; }

		public string RepairStation { get; set; }

		public int MinStationLevel { get; set; }

		public PieceRequirementConfig[] Requirements { get; set; } = new PieceRequirementConfig[0];


		public Recipe GetRecipe()
		{
			Requirement[] array = (Requirement[])(object)new Requirement[Requirements.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = Requirements[i].GetPieceRequirement();
			}
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			GameObject prefab = PrefabManager.Instance.GetPrefab(Item);
			if ((Object)(object)prefab == (Object)null)
			{
				Debug.LogError((object)("Error, recipe contained null item prefab for item: " + Item));
				return null;
			}
			if (string.IsNullOrEmpty(Name))
			{
				Name = "Recipe_" + Item;
			}
			((Object)val).name = Name;
			val.m_item = prefab.GetComponent<ItemDrop>();
			val.m_amount = Amount;
			val.m_enabled = Enabled;
			if (CraftingStation != null)
			{
				GameObject prefab2 = PrefabManager.Instance.GetPrefab(CraftingStation);
				CraftingStation component = prefab2.GetComponent<CraftingStation>();
				if ((Object)(object)prefab2 == (Object)null || (Object)(object)component == (Object)null)
				{
					Debug.LogError((object)("Crafting station is not valid: " + CraftingStation));
					return null;
				}
				val.m_craftingStation = component;
			}
			if (RepairStation != null)
			{
				GameObject prefab3 = PrefabManager.Instance.GetPrefab(RepairStation);
				CraftingStation component2 = prefab3.GetComponent<CraftingStation>();
				if ((Object)(object)prefab3 == (Object)null || (Object)(object)component2 == (Object)null)
				{
					Debug.LogError((object)("Repair station is not valid: " + RepairStation));
					return null;
				}
				val.m_craftingStation = component2;
			}
			val.m_minStationLevel = MinStationLevel;
			val.m_resources = array;
			return val;
		}
	}
	public class SkillConfig
	{
		private string _identifier;

		public string Identifier
		{
			get
			{
				return _identifier;
			}
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					Debug.LogError((object)("Error, SkillConfig cannot have invalid Identifier: " + value));
					return;
				}
				_identifier = value;
				UID = (SkillType)StringExtensionMethods.GetStableHashCode(value);
			}
		}

		public SkillType UID { get; private set; }

		public string Name { get; set; }

		public string Description { get; set; }

		public Sprite Icon { get; set; }

		public float IncreaseStep { get; set; }
	}
	public abstract class ConsoleCommand
	{
		public abstract string Name { get; }

		public abstract string Help { get; }

		public abstract void Run(string[] args);
	}
}