Decompiled source of Magrider v1.0.11

plugins/Magrider.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dolso;
using Dolso.RiskofOptions;
using EntityStates;
using EntityStates.Bandit2.Weapon;
using EntityStates.Headstompers;
using EntityStates.VagrantNovaItem;
using HG.BlendableTypes;
using HG.Reflection;
using IL.EntityStates;
using IL.RoR2;
using IL.RoR2.UI;
using ItemStatistics;
using Magrider.Magrider;
using Magrider.Magrider.SkillStates;
using Magrider.Magrider.SkillStates.Weapon;
using Magrider.Modules;
using Magrider.Modules.Characters;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On.EntityStates.VagrantNovaItem;
using On.RoR2;
using On.RoR2.Networking;
using R2API;
using R2API.Utils;
using Rewired;
using RiskOfOptions;
using RiskOfOptions.Components.Options;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.CameraModes;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.HudOverlay;
using RoR2.Networking;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Magrider")]
[assembly: OptIn]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Magrider")]
[assembly: AssemblyProduct("Magrider")]
[assembly: AssemblyInformationalVersion("1.0.0+31c36978e6139176956020da2c78725e9db677ea")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Dolso
{
	internal static class log
	{
		private static ManualLogSource logger;

		internal static void start(ManualLogSource logSource)
		{
			logger = logSource;
		}

		internal static void start(string name)
		{
			logger = Logger.CreateLogSource(name);
		}

		internal static void debug(object data)
		{
			logger.LogDebug(data);
		}

		internal static void info(object data)
		{
			logger.LogInfo(data);
		}

		internal static void message(object data)
		{
			logger.LogMessage(data);
		}

		internal static void warning(object data)
		{
			logger.LogWarning(data);
		}

		internal static void error(object data)
		{
			logger.LogError(data);
		}

		internal static void fatal(object data)
		{
			logger.LogFatal(data);
		}

		internal static void LogError(this ILCursor c, object data)
		{
			logger.LogError((object)string.Format($"ILCursor failure, skipping: {data}\n{c}"));
		}

		internal static void LogErrorCaller(this ILCursor c, object data, [CallerMemberName] string callerName = "")
		{
			logger.LogError((object)string.Format($"ILCursor failure in {callerName}, skipping: {data}\n{c}"));
		}
	}
	internal static class HookManager
	{
		internal delegate bool ConfigEnabled<T>(ConfigEntry<T> configEntry);

		internal const BindingFlags allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private static ILHookConfig ilHookConfig = new ILHookConfig
		{
			ManualApply = true
		};

		private static HookConfig onHookConfig = new HookConfig
		{
			ManualApply = true
		};

		private static readonly ConfigEnabled<bool> boolConfigEnabled = (ConfigEntry<bool> configEntry) => configEntry.Value;

		internal static void Hook(Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			HookInternal(GetMethod(typeFrom, methodFrom), ilHook);
		}

		internal static void Hook(MethodBase methodFrom, Manipulator ilHook)
		{
			HookInternal(methodFrom, ilHook);
		}

		internal static void Hook(Delegate from, Manipulator ilHook)
		{
			HookInternal(from.Method, ilHook);
		}

		internal static void Hook<T>(Expression<Action<T>> from, Manipulator ilHook)
		{
			HookInternal(((MethodCallExpression)from.Body).Method, ilHook);
		}

		internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook)
		{
			HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
		}

		internal static void Hook(MethodBase methodFrom, MethodInfo onHook)
		{
			HookInternal(methodFrom, onHook, null);
		}

		internal static void Hook(MethodBase methodFrom, Delegate onHook)
		{
			HookInternal(methodFrom, onHook.Method, onHook.Target);
		}

		internal static void Hook(Delegate from, Delegate onHook)
		{
			HookInternal(from.Method, onHook.Method, onHook.Target);
		}

		internal static void Hook<T>(Expression<Action<T>> from, Delegate onHook)
		{
			HookInternal(((MethodCallExpression)from.Body).Method, onHook.Method, onHook.Target);
		}

		internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook, object instance)
		{
			HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, instance);
		}

		internal static void Hook(MethodBase methodFrom, MethodInfo onHook, object target)
		{
			HookInternal(methodFrom, onHook, target);
		}

		private static void HookInternal(MethodBase methodFrom, Manipulator ilHook)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (methodFrom == null)
			{
				log.error("null MethodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name);
				return;
			}
			try
			{
				new ILHook(methodFrom, ilHook, ref ilHookConfig).Apply();
			}
			catch (Exception ex)
			{
				log.error($"Failed to apply ILHook: {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
			}
		}

		private static void HookInternal(MethodBase methodFrom, MethodInfo onHook, object target)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (methodFrom == null)
			{
				log.error("null methodFrom for hook: " + onHook.Name);
				return;
			}
			try
			{
				new Hook(methodFrom, onHook, target, ref onHookConfig).Apply();
			}
			catch (Exception ex)
			{
				log.error($"Failed to apply onHook: {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}");
			}
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			configEntry.AddHookConfig(enabled, GetMethod(typeFrom, methodFrom), ilHook);
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook)
		{
			configEntry.AddHookConfig(enabled, methodFrom, ilHook);
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Delegate onHook)
		{
			configEntry.AddHookConfig(enabled, GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate onHook)
		{
			configEntry.AddHookConfig(enabled, methodFrom, onHook.Method, onHook.Target);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			configEntry.AddHookConfig(boolConfigEnabled, GetMethod(typeFrom, methodFrom), ilHook);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook)
		{
			configEntry.AddHookConfig(boolConfigEnabled, methodFrom, ilHook);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook)
		{
			configEntry.AddHookConfig(boolConfigEnabled, GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook)
		{
			configEntry.AddHookConfig(boolConfigEnabled, methodFrom, onHook.Method, onHook.Target);
		}

		private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			if (methodFrom == null)
			{
				log.error("null MethodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name);
				return;
			}
			try
			{
				configEntry.AddHookConfig(enabled, (IDetour)new ILHook(methodFrom, ilHook, ref ilHookConfig));
			}
			catch (Exception ex)
			{
				log.error($"Failed to ilHook {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
			}
		}

		private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, MethodInfo onHook, object target)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			if (methodFrom == null)
			{
				log.error("null MethodFrom for hook: " + onHook.Name);
				return;
			}
			try
			{
				configEntry.AddHookConfig(enabled, (IDetour)new Hook(methodFrom, onHook, target, ref onHookConfig));
			}
			catch (Exception ex)
			{
				log.error($"Failed to onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}");
			}
		}

		private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, IDetour detour)
		{
			configEntry.SettingChanged += delegate(object sender, EventArgs args)
			{
				UpdateHook(detour, enabled(sender as ConfigEntry<T>));
			};
			if (enabled(configEntry))
			{
				detour.Apply();
			}
		}

		private static void UpdateHook(IDetour hook, bool enabled)
		{
			if (enabled)
			{
				if (!hook.IsApplied)
				{
					hook.Apply();
				}
			}
			else if (hook.IsApplied)
			{
				hook.Undo();
			}
		}

		internal static void PriorityFirst()
		{
			ilHookConfig.Before = new string[1] { "*" };
			onHookConfig.Before = new string[1] { "*" };
		}

		internal static void PriorityLast()
		{
			ilHookConfig.After = new string[1] { "*" };
			onHookConfig.After = new string[1] { "*" };
		}

		internal static void PriorityNormal()
		{
			ilHookConfig.Before = null;
			onHookConfig.Before = null;
			ilHookConfig.After = null;
			onHookConfig.After = null;
		}

		internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate onHook)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			try
			{
				return (IDetour)new Hook((MethodBase)GetMethod(typeFrom, methodFrom), onHook, ref onHookConfig);
			}
			catch (Exception ex)
			{
				log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}");
			}
			return null;
		}

		internal static MethodInfo GetMethod(Type typeFrom, string methodFrom)
		{
			if (typeFrom == null || methodFrom == null)
			{
				return null;
			}
			IEnumerable<MethodInfo> enumerable = from predicate in typeFrom.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
				where predicate.Name == methodFrom
				select predicate;
			if (enumerable.Count() == 1)
			{
				return enumerable.First();
			}
			if (enumerable.Count() == 0)
			{
				log.error($"Failed to find method: {typeFrom}.{methodFrom}");
			}
			else
			{
				log.error($"{enumerable.Count()} ambiguous matches found for: {typeFrom}.{methodFrom}");
				foreach (MethodInfo item in enumerable)
				{
					log.error(item);
				}
			}
			return null;
		}

		internal static MethodInfo GetMethod(Type typeFrom, string methodFrom, params Type[] parameters)
		{
			if (typeFrom == null || methodFrom == null)
			{
				return null;
			}
			MethodInfo? method = typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, parameters, null);
			if (method == null)
			{
				log.error($"Failed to find method: {typeFrom}.{methodFrom}_{parameters.Length}");
			}
			return method;
		}
	}
	public class TextHud
	{
		public static HUD hud;

		private static bool hudVisibility;

		private static Queue<TextHud> hudsToUpdate;

		private GameObject objhud;

		private readonly string hudName;

		private HGTextMeshProUGUI textMesh;

		private string textToUpdate;

		private ConfigEntry<int> fontsizeEntry;

		private ConfigEntry<Vector2> positionEntry;

		public ConfigEntry<bool> toggleEntry { get; private set; }

		public bool resetOnTargetChanged
		{
			set
			{
				if (value)
				{
					HUD.onHudTargetChangedGlobal += OnHudTargetChanged_DoReset;
				}
				else
				{
					HUD.onHudTargetChangedGlobal -= OnHudTargetChanged_DoReset;
				}
			}
		}

		public bool enabled
		{
			get
			{
				if (toggleEntry == null)
				{
					return true;
				}
				return toggleEntry.Value;
			}
		}

		public int fontSize
		{
			get
			{
				if (fontsizeEntry == null)
				{
					return -1;
				}
				return fontsizeEntry.Value;
			}
		}

		public Vector2 position
		{
			get
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (positionEntry == null)
				{
					return new Vector2(1776.5f, 173f);
				}
				return positionEntry.Value;
			}
		}

		public static event Action onAwake;

		public static event Action onOnDisable;

		public static event Action<bool> onVisibilityChanged;

		static TextHud()
		{
			hudVisibility = true;
			hudsToUpdate = new Queue<TextHud>();
			HookManager.Hook(typeof(HUD), "Awake", (Delegate)new Action<Action<HUD>, HUD>(On_HUD_Awake));
			HookManager.Hook(typeof(HUD), "OnDisable", (Delegate)new Action<Action<HUD>, HUD>(On_HUD_OnDisable));
			RoR2Application.onLateUpdate += LateUpdate;
		}

		private TextHud(string name, ConfigFile configFile, Vector2? defaultPosition, bool? defaultToggle, int? defaultFontSize)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			hudName = name;
			if (defaultPosition.HasValue)
			{
				positionEntry = configFile.Bind<Vector2>(name, "Position", defaultPosition.Value, "Position of " + name + ", starting from bottom left corner");
			}
			if (defaultToggle.HasValue)
			{
				toggleEntry = configFile.Bind<bool>(name, "Toggle", defaultToggle.Value, "Toggles " + name);
			}
			if (defaultFontSize.HasValue)
			{
				fontsizeEntry = configFile.Bind<int>(name, "Font size", defaultFontSize.Value, "Font size of " + name);
			}
			DoHooks(configFile);
		}

		public TextHud(ConfigFile configFile, string name)
			: this(name, configFile, null, null, null)
		{
		}

		public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition)
			: this(name, configFile, defaultPosition, null, null)
		{
		}//IL_0003: Unknown result type (might be due to invalid IL or missing references)


		public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, bool defaultToggle)
			: this(name, configFile, defaultPosition, defaultToggle, null)
		{
		}//IL_0003: Unknown result type (might be due to invalid IL or missing references)


		public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, int defaultFontSize)
			: this(name, configFile, defaultPosition, null, defaultFontSize)
		{
		}//IL_0003: Unknown result type (might be due to invalid IL or missing references)


		public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, bool defaultToggle, int defaultFontSize)
			: this(name, configFile, defaultPosition, defaultToggle, defaultFontSize)
		{
		}//IL_0003: Unknown result type (might be due to invalid IL or missing references)


		public void UpdateText(string text)
		{
			if (!hudsToUpdate.Contains(this))
			{
				hudsToUpdate.Enqueue(this);
			}
			textToUpdate = text;
		}

		public void UpdateText(StringBuilder text)
		{
			if (!hudsToUpdate.Contains(this))
			{
				hudsToUpdate.Enqueue(this);
			}
			textToUpdate = text.ToString();
		}

		public void ClearText()
		{
			if (Object.op_Implicit((Object)(object)objhud) && !string.IsNullOrEmpty(((TMP_Text)textMesh).text))
			{
				UpdateText("");
			}
		}

		private static void LateUpdate()
		{
			while (hudsToUpdate.Count > 0)
			{
				TextHud textHud = hudsToUpdate.Dequeue();
				if (textHud.enabled)
				{
					if ((Object)(object)textHud.objhud == (Object)null)
					{
						textHud.InitHud();
					}
					((TMP_Text)textHud.textMesh).SetText(textHud.textToUpdate, true);
				}
				textHud.textToUpdate = null;
			}
			if (Object.op_Implicit((Object)(object)hud) && hud.mainUIPanel.activeInHierarchy != hudVisibility)
			{
				hudVisibility = hud.mainUIPanel.activeInHierarchy;
				TextHud.onVisibilityChanged?.Invoke(hudVisibility);
			}
		}

		public void DestroyHUD()
		{
			Object.Destroy((Object)(object)objhud);
		}

		private void InitHud()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0049: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			objhud = new GameObject(hudName);
			if (Object.op_Implicit((Object)(object)hud))
			{
				objhud.transform.SetParent(hud.mainContainer.transform, false);
			}
			RectTransform obj = objhud.AddComponent<RectTransform>();
			obj.anchorMin = Vector2.zero;
			obj.anchorMax = Vector2.zero;
			obj.sizeDelta = Vector2.zero;
			obj.pivot = new Vector2(0.5f, 0.5f);
			obj.anchoredPosition = position;
			textMesh = objhud.AddComponent<HGTextMeshProUGUI>();
			((TMP_Text)textMesh).fontSizeMin = 6f;
			if (fontSize >= 0)
			{
				((TMP_Text)textMesh).fontSize = fontSize;
			}
			((TMP_Text)textMesh).outlineColor = Color32.op_Implicit(Color.black);
			((TMP_Text)textMesh).outlineWidth = 0.1f;
			((TMP_Text)textMesh).enableWordWrapping = false;
		}

		private void DoHooks(ConfigFile configFile)
		{
			onAwake += HUDAwakened;
			HUD.onHudTargetChangedGlobal += OnHudTargetChanged_DoReset;
			onVisibilityChanged += OnHudVisibilityChanged;
			if (toggleEntry != null)
			{
				toggleEntry.SettingChanged += EntryToggle_Changed;
			}
			if (positionEntry != null)
			{
				positionEntry.SettingChanged += EntryPosition_Changed;
			}
			if (fontsizeEntry != null)
			{
				fontsizeEntry.SettingChanged += EntryFontSize_Changed;
			}
		}

		private void HUDAwakened()
		{
			if (Object.op_Implicit((Object)(object)objhud))
			{
				objhud.transform.SetParent(hud.mainContainer.transform, false);
			}
		}

		private void OnHudTargetChanged_DoReset(HUD obj)
		{
			if (Object.op_Implicit((Object)(object)objhud))
			{
				UpdateText("");
			}
		}

		private void OnHudVisibilityChanged(bool visibility)
		{
			if (Object.op_Implicit((Object)(object)objhud))
			{
				objhud.SetActive(visibility);
			}
		}

		private void EntryToggle_Changed(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)objhud) && !enabled)
			{
				Object.Destroy((Object)(object)objhud);
			}
		}

		private void EntryPosition_Changed(object sender, EventArgs e)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)objhud))
			{
				objhud.GetComponent<RectTransform>().anchoredPosition = position;
			}
		}

		private void EntryFontSize_Changed(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)objhud) && fontSize > 0)
			{
				((TMP_Text)textMesh).fontSize = fontSize;
			}
		}

		private static void On_HUD_Awake(Action<HUD> orig, HUD self)
		{
			orig(self);
			hud = self;
			TextHud.onAwake?.Invoke();
		}

		private static void On_HUD_OnDisable(Action<HUD> orig, HUD self)
		{
			orig(self);
			hud = null;
			TextHud.onOnDisable?.Invoke();
		}

		public void AddRoOVector2Option()
		{
			AddRoOVector2Option(hudName);
		}

		public void AddRoOVector2Option(string category)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			new Vector2ScreenOption(positionEntry, hudName + " text", category, new Vector2ScreenOption.DotInfo(new Vector2(0f, 1f), new Vector2(0f, 0f), new Vector2(0.5f, 0.5f), Vector2.op_Implicit(Vector3.zero)), toggleEntry, fontsizeEntry);
		}
	}
}
namespace Dolso.RiskofOptions
{
	internal static class RiskofOptions
	{
		internal const string rooGuid = "com.rune580.riskofoptions";

		internal static bool enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		internal static void SetSprite(Sprite sprite)
		{
			ModSettingsManager.SetModIcon(sprite);
		}

		internal static void SetSpriteDefaultIcon()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
			string path = ((!(directoryInfo.Name == "plugins")) ? directoryInfo.FullName : directoryInfo.Parent.FullName);
			try
			{
				Texture2D val = new Texture2D(256, 256);
				if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(path, "icon.png"))))
				{
					ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)));
				}
				else
				{
					log.error("Failed to load icon.png");
				}
			}
			catch (Exception ex)
			{
				log.error("Failed to load icon.png\n" + ex);
			}
		}

		internal static void AddBool(ConfigEntry<bool> entry)
		{
			//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_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddBool(ConfigEntry<bool> entry, string categoryName, string name)
		{
			//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_000d: 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_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
			{
				category = categoryName,
				name = name,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddBool(ConfigEntry<bool> entry, string categoryName)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
			{
				category = categoryName,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddEnum<T>(ConfigEntry<T> entry) where T : Enum
		{
			//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_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, new ChoiceConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddColor(ConfigEntry<Color> entry)
		{
			//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_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new ColorOption(entry, new ColorOptionConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddKey(ConfigEntry<KeyboardShortcut> entry)
		{
			//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_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry, new KeyBindConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddFloat(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}")
		{
			//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_000d: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
			{
				min = min,
				max = max,
				FormatString = format,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault(format)
			}));
		}

		internal static void AddFloat(ConfigEntry<float> entry, string categoryName, float min, float max, string format = "{0:f2}")
		{
			//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_000d: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
			{
				min = min,
				max = max,
				FormatString = format,
				category = categoryName,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault(format)
			}));
		}

		internal static void AddFloatField(ConfigEntry<float> entry, float min = float.MinValue, float max = float.MaxValue, string format = "{0:f2}")
		{
			//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_000d: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			FloatFieldConfig val = new FloatFieldConfig();
			((NumericFieldConfig<float>)val).Min = min;
			((NumericFieldConfig<float>)val).Max = max;
			((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault(format);
			ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(entry, val));
		}

		internal static void AddInt(ConfigEntry<int> entry, int min = int.MinValue, int max = int.MaxValue)
		{
			//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_000d: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			IntFieldConfig val = new IntFieldConfig();
			((NumericFieldConfig<int>)val).Min = min;
			((NumericFieldConfig<int>)val).Max = max;
			((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault();
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(entry, val));
		}

		internal static void AddIntSlider(ConfigEntry<int> entry, int min, int max)
		{
			//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_000d: 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_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
			{
				min = min,
				max = max,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddIntSlider(ConfigEntry<int> entry, string categoryName, int min, int max)
		{
			//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_000d: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
			{
				min = min,
				max = max,
				category = categoryName,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddString(ConfigEntry<string> entry)
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(entry, new InputFieldConfig
			{
				submitOn = (SubmitEnum)6,
				lineType = (LineType)0,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddOption(ConfigEntry<bool> entry)
		{
			AddBool(entry);
		}

		internal static void AddOption(ConfigEntry<bool> entry, string categoryName, string name)
		{
			AddBool(entry, categoryName, name);
		}

		internal static void AddOption(ConfigEntry<bool> entry, string categoryName)
		{
			AddBool(entry, categoryName);
		}

		internal static void AddOption<T>(ConfigEntry<T> entry) where T : Enum
		{
			AddEnum<T>(entry);
		}

		internal static void AddOption(ConfigEntry<Color> entry)
		{
			AddColor(entry);
		}

		internal static void AddOption(ConfigEntry<KeyboardShortcut> entry)
		{
			AddKey(entry);
		}

		internal static void AddOption(ConfigEntry<int> entry)
		{
			AddInt(entry);
		}

		internal static void AddOption(ConfigEntry<string> entry)
		{
			AddString(entry);
		}

		private static string DescWithDefault(this ConfigEntryBase entry)
		{
			return $"{entry.Description.Description}\n[Default: {entry.DefaultValue}]";
		}

		private static string DescWithDefault(this ConfigEntryBase entry, string format)
		{
			return string.Format("{1}\n[Default: " + format + "]", entry.DefaultValue, entry.Description.Description);
		}
	}
	public class RooSliderInput2 : MonoBehaviour
	{
		[Serializable]
		public class SliderInputEvent : UnityEvent<float>
		{
		}

		public Slider slider;

		public TMP_InputField inputField;

		public string formatString = "{0}";

		public float sliderMin;

		public float sliderMax;

		public float valueMin;

		public float valueMax;

		public SliderInputEvent onValueChanged = new SliderInputEvent();

		private float _value;

		public float Value
		{
			get
			{
				return _value;
			}
			set
			{
				if (_value != value)
				{
					_value = value;
					((UnityEvent<float>)onValueChanged).Invoke(_value);
				}
				UpdateControls();
			}
		}

		public void SetUnmappedValue(float value)
		{
			Value = value;
		}

		public void Setup(float min, float max)
		{
			valueMin = min;
			sliderMin = min;
			slider.minValue = min;
			valueMax = max;
			sliderMax = max;
			slider.maxValue = max;
			((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)SliderChanged);
			((UnityEvent<string>)(object)inputField.onEndEdit).AddListener((UnityAction<string>)OnTextEdited);
			((UnityEvent<string>)(object)inputField.onSubmit).AddListener((UnityAction<string>)OnTextEdited);
		}

		private void UpdateControls()
		{
			if (formatString.StartsWith("F"))
			{
				slider.value = Value;
				inputField.text = Value.ToString(formatString, CultureInfo.InvariantCulture);
			}
			else
			{
				int num = (int)Value;
				slider.value = num;
				inputField.text = string.Format(CultureInfo.InvariantCulture, formatString, num);
			}
		}

		private void SliderChanged(float newValue)
		{
			Value = newValue;
		}

		private void OnTextEdited(string newText)
		{
			if (float.TryParse(newText, out var result))
			{
				result = Mathf.Clamp(result, slider.minValue, slider.maxValue);
				Value = result;
			}
			else
			{
				Value = _value;
			}
		}
	}
	public class Vector2ScreenBehaviour : MonoBehaviour
	{
		public static GameObject prefab;

		private static Sprite checkOn;

		private static Sprite checkOff;

		private ChildLocator childLocator;

		private RectTransform positionDot;

		private RectTransform positionRect;

		private Vector2ScreenOption option;

		private RooSliderInput2 sliderX;

		private RooSliderInput2 sliderY;

		private RooSliderInput2 sliderSize;

		private Image checkBox;

		private bool boxState;

		private ConfigEntry<Vector2> positionEntry => option.positionEntry;

		private Vector2ScreenOption.DotInfo dotinfo => option.dotInfo;

		private ConfigEntry<bool> toggleEntry => option.toggleEntry;

		private ConfigEntry<int> fontSizeEntry => option.fontSizeEntry;

		private ConfigEntry<float> scaleEntry => option.scaleEntry;

		public static void LoadAssets(string assetFolder)
		{
			AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), assetFolder, "dolso"));
			prefab = obj.LoadAsset<GameObject>("TextHud Screen");
			obj.Unload(false);
			LoadImages();
		}

		public static void LoadAssets(GameObject vector2WindowPrefab)
		{
			prefab = vector2WindowPrefab;
			LoadImages();
		}

		private static void LoadImages()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			CarouselController component = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/SettingsEntryButton, Bool.prefab").WaitForCompletion().GetComponent<CarouselController>();
			checkOn = component.choices[1].customSprite;
			checkOff = component.choices[0].customSprite;
		}

		internal void SetStartingValues(Vector2ScreenOption option)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Expected O, but got Unknown
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			this.option = option;
			positionDot.anchorMin = dotinfo.dotAnchor;
			positionDot.anchorMax = dotinfo.dotAnchor;
			positionDot.pivot = dotinfo.dotAnchor;
			positionRect.anchorMin = dotinfo.rectAnchor;
			positionRect.anchorMax = dotinfo.rectAnchor;
			positionRect.pivot = dotinfo.rectPivot;
			positionRect.sizeDelta = dotinfo.rectSize;
			sliderX = BuildSlider("PositionX");
			CalcAndSetSliderMinMax(sliderX, 1920f, 0);
			sliderX.formatString = "F0";
			((UnityEvent<float>)sliderX.onValueChanged).AddListener((UnityAction<float>)XChanged);
			sliderY = BuildSlider("PositionY");
			CalcAndSetSliderMinMax(sliderY, 1080f, 1);
			sliderY.formatString = "F0";
			((UnityEvent<float>)sliderY.onValueChanged).AddListener((UnityAction<float>)YChanged);
			sliderX.Value = positionEntry.Value.x;
			sliderY.Value = positionEntry.Value.y;
			if (toggleEntry != null)
			{
				boxState = toggleEntry.Value;
				((UnityEvent)((Button)((Component)childLocator.FindChild("Toggle")).GetComponent<HGButton>()).onClick).AddListener(new UnityAction(ToggleChanged));
				checkBox = ((Component)childLocator.FindChild("ToggleBox")).GetComponent<Image>();
				checkBox.sprite = (boxState ? checkOn : checkOff);
			}
			else
			{
				((Component)childLocator.FindChild("ToggleParent")).gameObject.SetActive(false);
				((Component)childLocator.FindChild("ToggleText")).gameObject.SetActive(false);
				RectTransform component = ((Component)childLocator.FindChild("Size")).GetComponent<RectTransform>();
				component.anchoredPosition += new Vector2(0f, 66f);
			}
			if (fontSizeEntry != null)
			{
				sliderSize = BuildSlider("Size");
				sliderSize.Setup(5f, option.maxScale);
				sliderSize.formatString = "{0}";
				((UnityEvent<float>)sliderSize.onValueChanged).AddListener((UnityAction<float>)FontSizeChanged);
				sliderSize.Value = fontSizeEntry.Value;
			}
			else if (scaleEntry != null)
			{
				sliderSize = BuildSlider("Size");
				sliderSize.Setup(0f, option.maxScale);
				sliderSize.formatString = "F1";
				((UnityEvent<float>)sliderSize.onValueChanged).AddListener((UnityAction<float>)ScaleChanged);
				sliderSize.slider.wholeNumbers = false;
				sliderSize.Value = scaleEntry.Value;
			}
			else
			{
				((Component)childLocator.FindChild("Size")).gameObject.SetActive(false);
				SetSize(option.maxScale * Vector2.one);
			}
		}

		private void Awake()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			childLocator = ((Component)this).GetComponent<ChildLocator>();
			positionDot = ((Component)childLocator.FindChild("PositionDot")).GetComponent<RectTransform>();
			positionRect = ((Component)childLocator.FindChild("PositionRect")).GetComponent<RectTransform>();
			((UnityEvent)((Button)((Component)childLocator.FindChild("Apply")).GetComponent<HGButton>()).onClick).AddListener(new UnityAction(Apply));
			((UnityEvent)((Button)((Component)childLocator.FindChild("Cancel")).GetComponent<HGButton>()).onClick).AddListener(new UnityAction(Close));
			((UnityEvent)((Button)((Component)childLocator.FindChild("Default")).GetComponent<HGButton>()).onClick).AddListener(new UnityAction(SetToDefault));
			((Component)this).GetComponent<RooEscapeRouter>().escapePressed.AddListener(new UnityAction(Close));
		}

		private RooSliderInput2 BuildSlider(string childName)
		{
			Transform val = childLocator.FindChild(childName);
			RooSliderInput2 rooSliderInput = ((Component)val).gameObject.AddComponent<RooSliderInput2>();
			rooSliderInput.slider = ((Component)val).GetComponentInChildren<Slider>();
			rooSliderInput.inputField = ((Component)val).GetComponentInChildren<TMP_InputField>();
			return rooSliderInput;
		}

		private void CalcAndSetSliderMinMax(RooSliderInput2 slider, float length, int index)
		{
			float num = (0f - ((Vector2)(ref dotinfo.rectSize))[index]) * (((Vector2)(ref dotinfo.dotAnchor))[index] - ((Vector2)(ref dotinfo.rectPivot))[index]);
			float min = (0f - length) * ((Vector2)(ref dotinfo.rectAnchor))[index] + num;
			float max = length * (1f - ((Vector2)(ref dotinfo.rectAnchor))[index]) + num;
			slider.Setup(min, max);
		}

		private void XChanged(float newValue)
		{
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			Vector2 anchoredPosition = positionRect.anchoredPosition;
			anchoredPosition.x = newValue;
			positionRect.anchoredPosition = anchoredPosition;
		}

		private void YChanged(float newValue)
		{
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			Vector2 anchoredPosition = positionRect.anchoredPosition;
			anchoredPosition.y = newValue;
			positionRect.anchoredPosition = anchoredPosition;
		}

		private void ToggleChanged()
		{
			boxState = !boxState;
			checkBox.sprite = (boxState ? checkOn : checkOff);
		}

		private void FontSizeChanged(float newValue)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			SetSize(newValue * Vector2.one);
		}

		private void ScaleChanged(float newValue)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			SetSize(newValue * dotinfo.rectSize);
		}

		private void SetToDefault()
		{
			//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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = (Vector2)((ConfigEntryBase)positionEntry).DefaultValue;
			sliderX.Value = val.x;
			sliderY.Value = val.y;
			if (toggleEntry != null)
			{
				boxState = (bool)((ConfigEntryBase)toggleEntry).DefaultValue;
				checkBox.sprite = (boxState ? checkOn : checkOff);
			}
			if (fontSizeEntry != null)
			{
				sliderSize.Value = (int)((ConfigEntryBase)fontSizeEntry).DefaultValue;
			}
			else if (scaleEntry != null)
			{
				sliderSize.Value = (float)((ConfigEntryBase)scaleEntry).DefaultValue;
			}
		}

		private void SetSize(Vector2 size)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (((Vector2)(ref size)).sqrMagnitude < 16f)
			{
				positionDot.sizeDelta = ((Vector2)(ref size)).normalized * 4f;
			}
			else
			{
				positionDot.sizeDelta = size;
			}
		}

		private void Apply()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			positionEntry.Value = new Vector2((float)Math.Round(sliderX.Value, 2), (float)Math.Round(sliderY.Value, 2));
			if (toggleEntry != null)
			{
				toggleEntry.Value = boxState;
			}
			if (fontSizeEntry != null)
			{
				fontSizeEntry.Value = Mathf.RoundToInt(sliderSize.Value);
			}
			else if (scaleEntry != null)
			{
				scaleEntry.Value = sliderSize.Value;
			}
			Close();
		}

		private void Close()
		{
			Object.DestroyImmediate((Object)(object)((Component)this).gameObject);
		}
	}
	public class Vector2ScreenOption
	{
		public class DotInfo
		{
			internal Vector2 dotAnchor;

			internal Vector2 rectAnchor;

			internal Vector2 rectPivot;

			internal Vector2 rectSize;

			public DotInfo(Vector2 dotAnchor, Vector2 rectAnchor, Vector2 rectPivot, Vector2 rectSize)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: 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_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: 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)
				this.dotAnchor = dotAnchor;
				this.rectAnchor = rectAnchor;
				this.rectPivot = rectPivot;
				this.rectSize = rectSize;
			}
		}

		internal ConfigEntry<Vector2> positionEntry;

		internal ConfigEntry<bool> toggleEntry;

		internal ConfigEntry<int> fontSizeEntry;

		internal ConfigEntry<float> scaleEntry;

		internal DotInfo dotInfo;

		internal float maxScale;

		public Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, DotInfo dotInfo, float dotSize = 16f)
			: this(positionEntry, ((ConfigEntryBase)positionEntry).Definition.Key, ((ConfigEntryBase)positionEntry).Definition.Section, dotInfo, null, null, null, dotSize)
		{
		}

		public Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, string name, string category, DotInfo dotInfo, float dotSize = 16f)
			: this(positionEntry, name, category, dotInfo, null, null, null, dotSize)
		{
		}

		public Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, DotInfo dotInfo, ConfigEntry<float> scaleEntry, float maxScale = 3f)
			: this(positionEntry, ((ConfigEntryBase)positionEntry).Definition.Key, ((ConfigEntryBase)positionEntry).Definition.Section, dotInfo, null, null, scaleEntry, maxScale)
		{
		}

		public Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, string name, string category, DotInfo dotInfo, ConfigEntry<float> scaleEntry, float maxScale = 3f)
			: this(positionEntry, name, category, dotInfo, null, null, scaleEntry, maxScale)
		{
		}

		public Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, string name, string category, DotInfo dotInfo, ConfigEntry<bool> toggleEntry = null, ConfigEntry<int> fontSizeEntry = null)
			: this(positionEntry, name, category, dotInfo, toggleEntry, fontSizeEntry, null, (fontSizeEntry == null) ? 16 : 36)
		{
		}

		private Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, string name, string category, DotInfo dotInfo, ConfigEntry<bool> toggleEntry, ConfigEntry<int> fontSizeEntry, ConfigEntry<float> scaleEntry, float maxScale)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			this.positionEntry = positionEntry;
			this.dotInfo = dotInfo;
			this.maxScale = maxScale;
			this.toggleEntry = toggleEntry;
			this.fontSizeEntry = fontSizeEntry;
			this.scaleEntry = scaleEntry;
			ModSettingsManager.AddOption((BaseOption)new GenericButtonOption(name, category, "Position of " + name, "Open", new UnityAction(CreateOptionWindow)));
		}

		private void CreateOptionWindow()
		{
			Object.Instantiate<GameObject>(Vector2ScreenBehaviour.prefab).AddComponent<Vector2ScreenBehaviour>().SetStartingValues(this);
		}
	}
}
namespace Magrider
{
	internal static class Config
	{
		public static ConfigFile configFile;

		public static ConfigEntry<string> prevVersion;

		private const string WEAPONS = "Weapons";

		public static ConfigEntry<float> blasterDamage;

		public static ConfigEntry<float> blasterReload;

		public static ConfigEntry<float> cannonDamage;

		public static ConfigEntry<float> cannonReload;

		private const string MAGBURNER = "Magburner";

		public static ConfigEntry<float> magburnerDuration;

		public static ConfigEntry<float> magburnerRecharge;

		public static ConfigEntry<float> magburnerCost;

		public static ConfigEntry<float> jumpDuration;

		public static ConfigEntry<float> jumpStrength;

		public static ConfigEntry<float> jumpTorque;

		public static ConfigEntry<bool> tpCameraRotate;

		public static ConfigEntry<bool> scopeToggle;

		private const string STATS = "Stats";

		public static ConfigEntry<float> acceleration;

		public static ConfigEntry<float> stickStrength;

		public static ConfigEntry<float> collisionDamage;

		public static ConfigEntry<float> collisionCooldown;

		public static ConfigEntry<float> flatArmorPerLevel;

		private const string HORN = "Horn";

		public static ConfigEntry<MagriderHorn.HornName> hornName;

		public static ConfigEntry<KeyboardShortcut> hornKey;

		public static void DoConfig(ConfigFile bepConfigFile)
		{
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			configFile = bepConfigFile;
			prevVersion = configFile.Bind<string>("", "last saved version", "1.0.11", "If this is different from current mod version, overwrite config exluding camera settings");
			blasterDamage = configFile.Bind<float>("Weapons", "Blaster damage", 6.5f, "Blaster's damage coefficient");
			blasterReload = configFile.Bind<float>("Weapons", "Blaster reload time", 0.66f, "Time to reload a blaster shot in seconds");
			cannonDamage = configFile.Bind<float>("Weapons", "Cannon damage", 11f, "Cannon's damage coefficient");
			cannonReload = configFile.Bind<float>("Weapons", "Cannon reload time", 1.5f, "Time to reload a cannon shot in seconds");
			magburnerDuration = configFile.Bind<float>("Magburner", "Magburner Capacity", 1.5f, "The duration capacity of Magburner in seconds");
			magburnerCost = configFile.Bind<float>("Magburner", "Magburner Activation Cost", 0.3f, "The activation cost of Magburner in seconds");
			magburnerRecharge = configFile.Bind<float>("Magburner", "Magburner Recharge", 10f, "How long it takes to recharge Magburner in seconds");
			jumpDuration = configFile.Bind<float>("Jump", "Jump Duration", 3f, "The duration capacity of Jump in seconds");
			jumpStrength = configFile.Bind<float>("Jump", "Jump Strength", 1f, "Vertical acceleration multiplier of Jump");
			jumpTorque = configFile.Bind<float>("Jump", "Jump Torque", 2f, "Torque multiplier of Jump");
			tpCameraRotate = configFile.Bind<bool>("Camera", "Third Person Camera Roll", true, "If the third person camera should be affected by the Magrider's roll");
			scopeToggle = configFile.Bind<bool>("Camera", "Scope Toggle", true, "If scope should be a toggle instead of a hold");
			acceleration = configFile.Bind<float>("Stats", "Acceleration", 22f, "Base acceleration of the Magrider. Can not be reloaded ingame");
			stickStrength = configFile.Bind<float>("Stats", "Stick Strength", 10f, "How much the magrider will try to stick to walls");
			collisionDamage = configFile.Bind<float>("Stats", "Collision Damage", 0.7f, "Damage multiplier for collisions against enemies");
			collisionCooldown = configFile.Bind<float>("Stats", "Collision Cooldown", 0.2f, "Repeated collisions against the same enemy will have this cooldown in seconds");
			flatArmorPerLevel = configFile.Bind<float>("Stats", "Flat Armor Per Level", 0.4f, "How much flat armor (same mechanic as Repulsion Plate) to gain per level");
			hornKey = configFile.Bind<KeyboardShortcut>("Horn", "Horn Key", new KeyboardShortcut((KeyCode)120, Array.Empty<KeyCode>()), "Key to activate horn");
			hornName = configFile.Bind<MagriderHorn.HornName>("Horn", "Horn Name", MagriderHorn.HornName.Colossus, "Which horn to use");
			MagriderMotor.texthud = new TextHud(configFile, "Magrider Text", new Vector2(600f, 500f), defaultToggle: true, 16);
			if (prevVersion.Value != "1.0.11")
			{
				ResetConfig();
			}
			else if (RiskofOptions.enabled)
			{
				DoRiskOfOptions();
			}
		}

		internal static void DoRiskOfOptions()
		{
			RiskofOptions.SetSprite(Assets.mainAssetBundle.LoadAsset<Sprite>("spriteMagriderIcon"));
			Vector2ScreenBehaviour.LoadAssets("Assets");
			RiskofOptions.AddBool(tpCameraRotate);
			RiskofOptions.AddBool(scopeToggle);
			RiskofOptions.AddOption(hornKey);
			RiskofOptions.AddOption<MagriderHorn.HornName>(hornName);
			MagriderMotor.texthud.AddRoOVector2Option("Stats");
			RiskofOptions.AddFloat(collisionDamage, 0f, 2f);
			RiskofOptions.AddFloat(collisionCooldown, 0f, 0.6f, "{0:0.00}s");
			RiskofOptions.AddFloat(stickStrength, 0f, 30f);
			RiskofOptions.AddFloat(flatArmorPerLevel, 0f, 1f);
			RiskofOptions.AddFloat(blasterDamage, 0f, 20f);
			RiskofOptions.AddFloat(blasterReload, 0f, 3f, "{0:0.00}s");
			RiskofOptions.AddFloat(cannonDamage, 0f, 30f);
			RiskofOptions.AddFloat(cannonReload, 0f, 5f, "{0:0.00}s");
			RiskofOptions.AddFloat(magburnerDuration, 0f, 5f, "{0:0.00}s");
			RiskofOptions.AddFloat(magburnerCost, 0f, 5f, "{0:0.00}s");
			RiskofOptions.AddFloat(magburnerRecharge, 0f, 30f, "{0:0.00}s");
			RiskofOptions.AddFloat(jumpDuration, "Magburner", 0f, 30f, "{0:0.00}s");
			RiskofOptions.AddFloat(jumpStrength, "Magburner", 0f, 50f);
			RiskofOptions.AddFloat(jumpTorque, "Magburner", 0f, 20f);
		}

		private static void ResetConfig()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			log.info("Overwriting config");
			bool value = tpCameraRotate.Value;
			bool value2 = scopeToggle.Value;
			KeyboardShortcut value3 = hornKey.Value;
			MagriderHorn.HornName value4 = hornName.Value;
			configFile.Clear();
			DoConfig(configFile);
			tpCameraRotate.Value = value;
			scopeToggle.Value = value2;
			hornKey.Value = value3;
			hornName.Value = value4;
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void ReloadConfig(ConCommandArgs args)
		{
			configFile.Reload();
			Debug.Log((object)"Reloaded Magrider config");
		}
	}
	internal class ItemStatisticsCompatibility
	{
		internal static readonly bool enabled = Chainloader.PluginInfos.ContainsKey("dolso.ItemStatistics");

		internal static GameObject collisionInflictor => ItemStatisticsAPI.CreateNewInflictor(Index.op_Implicit((SkillSlot)2), (GameObject)null);

		internal static void DoSetup()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ItemStatisticsAPI.AddTrackerToPrefab(Blaster.projectilePrefab, Index.op_Implicit((SkillSlot)0));
				ItemStatisticsAPI.AddTrackerToPrefab(Cannon.projectilePrefab, Index.op_Implicit((SkillSlot)0));
				ItemStatisticsAPI.WrapAttackWithIndex(typeof(MagriderCollision).GetMethod("ApplyHit", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), Index.op_Implicit((SkillSlot)2));
			}
			catch (Exception ex)
			{
				log.error("failed ItemStatistics setup\n" + ex);
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("dolso.magrdier", "Magrider", "1.0.11")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		public const string MODUID = "dolso.magrdier";

		public const string MODNAME = "Magrider";

		public const string MODVERSION = "1.0.11";

		public const string DEVELOPER_PREFIX = "DOL";

		public static PluginInfo pluginInfo;

		private void Awake()
		{
			log.start(((BaseUnityPlugin)this).Logger);
			pluginInfo = ((BaseUnityPlugin)this).Info;
			Assets.AssetsLoad();
			Config.DoConfig(((BaseUnityPlugin)this).Config);
			Buffs.RegisterBuffs();
			Projectiles.RegisterProjectiles();
			Tokens.AddTokens();
			new MagriderCharacter().Initialize();
			new ContentPacks().Initialize();
			MagriderHooks.Hook();
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				Assets.SoundbankLoad(enable: true);
			});
			if (ItemStatisticsCompatibility.enabled)
			{
				ItemStatisticsCompatibility.DoSetup();
			}
			log.info("Magrider Loaded");
		}
	}
}
namespace Magrider.Modules
{
	internal static class Assets
	{
		internal static AssetBundle mainAssetBundle;

		private const string folderName = "Assets";

		private const string assetbundleName = "maassets";

		private const string soundbankName = "MagriderSoundBank.bnk";

		private static bool soundDirAdded;

		private static bool soundbankLoaded;

		private static uint bankID;

		private static string assetDirectory => Path.Combine(Path.GetDirectoryName(Main.pluginInfo.Location), "Assets");

		internal static void AssetsLoad()
		{
			try
			{
				mainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(assetDirectory, "maassets"));
			}
			catch (Exception ex)
			{
				log.error("Failed to load assetbundle\n" + ex);
			}
		}

		internal static void AssetsUnload()
		{
			mainAssetBundle.Unload(false);
		}

		internal static AssetBundle LoadAsset(string bundleName)
		{
			try
			{
				return AssetBundle.LoadFromFile(Path.Combine(assetDirectory, bundleName));
			}
			catch (Exception ex)
			{
				log.error("Failed to load assetbundle\n" + ex);
				return null;
			}
		}

		internal static void UnloadAsset(AssetBundle assetBundle)
		{
			assetBundle.Unload(false);
		}

		internal static void SoundbankLoad(bool enable)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (!soundDirAdded)
			{
				if (!enable)
				{
					return;
				}
				SoundDirectoryLoad();
			}
			if (enable && !soundbankLoaded)
			{
				AKRESULT val = AkSoundEngine.LoadBank("MagriderSoundBank.bnk", ref bankID);
				if ((int)val == 1)
				{
					log.info("Added bank : MagriderSoundBank.bnk");
					soundbankLoaded = true;
				}
				else
				{
					log.error(string.Format("Error loading bank : {0} Error code : {1}", "MagriderSoundBank.bnk", val));
				}
			}
		}

		private static void SoundDirectoryLoad()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			AKRESULT val = AkSoundEngine.AddBasePath(assetDirectory);
			if ((int)val != 1)
			{
				log.error($"Error adding base path : {assetDirectory} Error code : {val}");
			}
			else
			{
				soundDirAdded = true;
			}
		}

		internal static void CreateNewEffectDef(GameObject effectPrefab)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Content.AddEffectDef(new EffectDef
			{
				prefab = effectPrefab
			});
		}

		private static GameObject CreateTracer(string originalTracerName, string newTracerName)
		{
			if ((Object)(object)LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/Tracers/" + originalTracerName) == (Object)null)
			{
				return null;
			}
			GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/Tracers/" + originalTracerName), newTracerName, true);
			if (!Object.op_Implicit((Object)(object)val.GetComponent<EffectComponent>()))
			{
				val.AddComponent<EffectComponent>();
			}
			if (!Object.op_Implicit((Object)(object)val.GetComponent<VFXAttributes>()))
			{
				val.AddComponent<VFXAttributes>();
			}
			if (!Object.op_Implicit((Object)(object)val.GetComponent<NetworkIdentity>()))
			{
				val.AddComponent<NetworkIdentity>();
			}
			val.GetComponent<Tracer>().speed = 250f;
			val.GetComponent<Tracer>().length = 50f;
			AddNewEffectDef(val);
			return val;
		}

		internal static NetworkSoundEventDef CreateNetworkSoundEventDef(string eventName)
		{
			NetworkSoundEventDef obj = ScriptableObject.CreateInstance<NetworkSoundEventDef>();
			obj.akId = AkSoundEngine.GetIDFromString(eventName);
			obj.eventName = eventName;
			Content.AddNetworkSoundEventDef(obj);
			return obj;
		}

		internal static void ConvertAllRenderersToHopooShader(GameObject objectToConvert)
		{
			if (!Object.op_Implicit((Object)(object)objectToConvert))
			{
				return;
			}
			Renderer[] componentsInChildren = objectToConvert.GetComponentsInChildren<Renderer>();
			foreach (Renderer obj in componentsInChildren)
			{
				if (obj != null)
				{
					obj.material?.SetHopooMaterial();
				}
			}
		}

		internal static RendererInfo[] SetupRendererInfos(GameObject obj)
		{
			//IL_0018: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer[] componentsInChildren = obj.GetComponentsInChildren<MeshRenderer>();
			RendererInfo[] array = (RendererInfo[])(object)new RendererInfo[componentsInChildren.Length];
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				array[i] = new RendererInfo
				{
					defaultMaterial = ((Renderer)componentsInChildren[i]).material,
					renderer = (Renderer)(object)componentsInChildren[i],
					defaultShadowCastingMode = (ShadowCastingMode)1,
					ignoreOverlays = false
				};
			}
			return array;
		}

		public static GameObject LoadSurvivorBody(string bodyName)
		{
			GameObject val = mainAssetBundle.LoadAsset<GameObject>(bodyName);
			if ((Object)(object)val == (Object)null)
			{
				log.error("Trying to load a null body- check to see if the BodyName in your code matches the prefab name of the object in Unity\nFor Example, if your prefab in unity is 'mdlHenry', then your BodyName must be 'Henry'");
				return null;
			}
			return PrefabAPI.InstantiateClone(val, ((Object)val).name, true);
		}

		public static GameObject LoadSurvivorModel(string modelName)
		{
			GameObject val = mainAssetBundle.LoadAsset<GameObject>(modelName);
			if ((Object)(object)val == (Object)null)
			{
				log.error("Trying to load a null model- check to see if the BodyName in your code matches the prefab name of the object in Unity\nFor Example, if your prefab in unity is 'mdlHenry', then your BodyName must be 'Henry'");
				return null;
			}
			return PrefabAPI.InstantiateClone(val, ((Object)val).name, false);
		}

		internal static GameObject LoadCrosshair(string crosshairName)
		{
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/Crosshair/" + crosshairName + "Crosshair");
			if (Object.op_Implicit((Object)(object)val))
			{
				return val;
			}
			return LegacyResourcesAPI.Load<GameObject>("Prefabs/Crosshair/StandardCrosshair");
		}

		private static GameObject LoadEffect(string resourceName)
		{
			return LoadEffect(resourceName, "", parentToTransform: false);
		}

		private static GameObject LoadEffect(string resourceName, string soundName)
		{
			return LoadEffect(resourceName, soundName, parentToTransform: false);
		}

		private static GameObject LoadEffect(string resourceName, bool parentToTransform)
		{
			return LoadEffect(resourceName, "", parentToTransform);
		}

		private static GameObject LoadEffect(string resourceName, string soundName, bool parentToTransform)
		{
			//IL_0049: 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)
			GameObject val = mainAssetBundle.LoadAsset<GameObject>(resourceName);
			if (!Object.op_Implicit((Object)(object)val))
			{
				log.error("Failed to load effect: " + resourceName + " because it does not exist in the AssetBundle");
				return null;
			}
			val.AddComponent<DestroyOnTimer>().duration = 12f;
			val.AddComponent<NetworkIdentity>();
			val.AddComponent<VFXAttributes>().vfxPriority = (VFXPriority)2;
			EffectComponent obj = val.AddComponent<EffectComponent>();
			obj.applyScale = false;
			obj.effectIndex = (EffectIndex)(-1);
			obj.parentToReferencedTransform = parentToTransform;
			obj.positionAtReferencedTransform = true;
			obj.soundName = soundName;
			AddNewEffectDef(val, soundName);
			return val;
		}

		private static void AddNewEffectDef(GameObject effectPrefab)
		{
			AddNewEffectDef(effectPrefab, "");
		}

		private static void AddNewEffectDef(GameObject effectPrefab, string soundName)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Content.AddEffectDef(new EffectDef
			{
				prefab = effectPrefab,
				prefabEffectComponent = effectPrefab.GetComponent<EffectComponent>(),
				prefabName = ((Object)effectPrefab).name,
				prefabVfxAttributes = effectPrefab.GetComponent<VFXAttributes>(),
				spawnSoundEventName = soundName
			});
		}
	}
	public static class Buffs
	{
		public static BuffDef phasedBuff;

		public static BuffDef ventingBuff;

		internal static void RegisterBuffs()
		{
		}

		internal static BuffDef AddNewBuff(string buffName, Sprite buffIcon, Color buffColor, bool canStack, bool isDebuff)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			BuffDef obj = ScriptableObject.CreateInstance<BuffDef>();
			((Object)obj).name = buffName;
			obj.buffColor = buffColor;
			obj.canStack = canStack;
			obj.isDebuff = isDebuff;
			obj.eliteDef = null;
			obj.iconSprite = buffIcon;
			Content.AddBuffDef(obj);
			return obj;
		}
	}
	internal class ContentPacks : IContentPackProvider
	{
		internal ContentPack contentPack = new ContentPack();

		public static List<GameObject> bodyPrefabs = new List<GameObject>();

		public static List<GameObject> masterPrefabs = new List<GameObject>();

		public static List<GameObject> projectilePrefabs = new List<GameObject>();

		public static List<SurvivorDef> survivorDefs = new List<SurvivorDef>();

		public static List<UnlockableDef> unlockableDefs = new List<UnlockableDef>();

		public static List<SkillFamily> skillFamilies = new List<SkillFamily>();

		public static List<SkillDef> skillDefs = new List<SkillDef>();

		public static List<Type> entityStates = new List<Type>();

		public static List<BuffDef> buffDefs = new List<BuffDef>();

		public static List<EffectDef> effectDefs = new List<EffectDef>();

		public static List<NetworkSoundEventDef> networkSoundEventDefs = new List<NetworkSoundEventDef>();

		public string identifier => "dolso.magrdier";

		public void Initialize()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders);
		}

		private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
		{
			addContentPackProvider.Invoke((IContentPackProvider)(object)this);
		}

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			contentPack.identifier = identifier;
			contentPack.bodyPrefabs.Add(bodyPrefabs.ToArray());
			contentPack.masterPrefabs.Add(masterPrefabs.ToArray());
			contentPack.projectilePrefabs.Add(projectilePrefabs.ToArray());
			contentPack.survivorDefs.Add(survivorDefs.ToArray());
			contentPack.unlockableDefs.Add(unlockableDefs.ToArray());
			contentPack.skillDefs.Add(skillDefs.ToArray());
			contentPack.skillFamilies.Add(skillFamilies.ToArray());
			contentPack.entityStateTypes.Add(entityStates.ToArray());
			contentPack.buffDefs.Add(buffDefs.ToArray());
			contentPack.effectDefs.Add(effectDefs.ToArray());
			contentPack.networkSoundEventDefs.Add(networkSoundEventDefs.ToArray());
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			ContentPack.Copy(contentPack, args.output);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}
	}
	internal class Content
	{
		public static void AddCharacterBodyPrefab(GameObject bprefab)
		{
			ContentPacks.bodyPrefabs.Add(bprefab);
		}

		public static void AddMasterPrefab(GameObject prefab)
		{
			ContentPacks.masterPrefabs.Add(prefab);
		}

		public static void AddProjectilePrefab(GameObject prefab)
		{
			ContentPacks.projectilePrefabs.Add(prefab);
		}

		public static void AddSurvivorDef(SurvivorDef survivorDef)
		{
			ContentPacks.survivorDefs.Add(survivorDef);
		}

		public static void AddUnlockableDef(UnlockableDef unlockableDef)
		{
			ContentPacks.unlockableDefs.Add(unlockableDef);
		}

		public static void AddSkillDef(SkillDef skillDef)
		{
			ContentPacks.skillDefs.Add(skillDef);
		}

		public static void AddSkillFamily(SkillFamily skillFamily)
		{
			ContentPacks.skillFamilies.Add(skillFamily);
		}

		public static void AddEntityState(Type entityState)
		{
			ContentPacks.entityStates.Add(entityState);
		}

		public static void AddBuffDef(BuffDef buffDef)
		{
			ContentPacks.buffDefs.Add(buffDef);
		}

		public static void AddEffectDef(EffectDef effectDef)
		{
			ContentPacks.effectDefs.Add(effectDef);
		}

		public static void AddNetworkSoundEventDef(NetworkSoundEventDef networkSoundEventDef)
		{
			ContentPacks.networkSoundEventDefs.Add(networkSoundEventDef);
		}
	}
	internal static class Helpers
	{
		internal const string agilePrefix = "<style=cIsUtility>Agile.</style> ";

		internal static string ScepterDescription(string desc)
		{
			return "\n<color=#d299ff>SCEPTER: " + desc + "</color>";
		}

		public static T[] Append<T>(ref T[] array, List<T> list)
		{
			int num = array.Length;
			int count = list.Count;
			Array.Resize(ref array, num + count);
			list.CopyTo(array, num);
			return array;
		}

		public static Func<T[], T[]> AppendDel<T>(List<T> list)
		{
			return (T[] r) => Append(ref r, list);
		}
	}
	internal static class Materials
	{
		private static List<Material> cachedMaterials = new List<Material>();

		internal static Shader hotpoo = LegacyResourcesAPI.Load<Shader>("Shaders/Deferred/HGStandard");

		public static Material CreateHopooMaterial(string materialName)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			Material val = cachedMaterials.Find(delegate(Material mat)
			{
				materialName.Replace(" (Instance)", "");
				return ((Object)mat).name.Contains(materialName);
			});
			if (Object.op_Implicit((Object)(object)val))
			{
				return val;
			}
			val = Assets.mainAssetBundle.LoadAsset<Material>(materialName);
			if (!Object.op_Implicit((Object)(object)val))
			{
				log.error("Failed to load material: " + materialName + " - Check to see that the material in your Unity project matches this name");
				return new Material(hotpoo);
			}
			return val.SetHopooMaterial();
		}

		public static Material SetHopooMaterial(this Material tempMat)
		{
			//IL_0074: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			if (cachedMaterials.Contains(tempMat))
			{
				return tempMat;
			}
			float? num = null;
			Color? val = null;
			if (tempMat.IsKeywordEnabled("_NORMALMAP"))
			{
				num = tempMat.GetFloat("_BumpScale");
			}
			if (tempMat.IsKeywordEnabled("_EMISSION"))
			{
				val = tempMat.GetColor("_EmissionColor");
			}
			tempMat.shader = hotpoo;
			tempMat.SetColor("_Color", tempMat.GetColor("_Color"));
			tempMat.SetTexture("_MainTex", tempMat.GetTexture("_MainTex"));
			tempMat.SetTexture("_EmTex", tempMat.GetTexture("_EmissionMap"));
			tempMat.EnableKeyword("DITHER");
			if (num.HasValue)
			{
				tempMat.SetFloat("_NormalStrength", num.Value);
			}
			if (val.HasValue)
			{
				tempMat.SetColor("_EmColor", val.Value);
				tempMat.SetFloat("_EmPower", 1f);
			}
			if (tempMat.IsKeywordEnabled("NOCULL"))
			{
				tempMat.SetInt("_Cull", 0);
			}
			if (tempMat.IsKeywordEnabled("LIMBREMOVAL"))
			{
				tempMat.SetInt("_LimbRemovalOn", 1);
			}
			cachedMaterials.Add(tempMat);
			return tempMat;
		}

		public static Material MakeUnique(this Material material)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			if (cachedMaterials.Contains(material))
			{
				return new Material(material);
			}
			return material;
		}

		public static Material SetColor(this Material material, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			material.SetColor("_Color", color);
			return material;
		}

		public static Material SetNormal(this Material material, float normalStrength = 1f)
		{
			material.SetFloat("_NormalStrength", normalStrength);
			return material;
		}

		public static Material SetEmission(this Material material)
		{
			return material.SetEmission(1f);
		}

		public static Material SetEmission(this Material material, float emission)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return material.SetEmission(emission, Color.white);
		}

		public static Material SetEmission(this Material material, float emission, Color emissionColor)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			material.SetFloat("_EmPower", emission);
			material.SetColor("_EmColor", emissionColor);
			return material;
		}

		public static Material SetCull(this Material material, bool cull = false)
		{
			material.SetInt("_Cull", cull ? 1 : 0);
			return material;
		}
	}
	internal static class Prefabs
	{
		private static PhysicMaterial ragdollMaterial;

		public static GameObject CreateDisplayPrefab(string displayModelName, GameObject prefab, BodyInfo bodyInfo)
		{
			GameObject val = Assets.LoadSurvivorModel(displayModelName);
			CharacterModel val2 = val.GetComponent<CharacterModel>();
			if (!Object.op_Implicit((Object)(object)val2))
			{
				val2 = val.AddComponent<CharacterModel>();
			}
			val2.baseRendererInfos = prefab.GetComponentInChildren<CharacterModel>().baseRendererInfos;
			Assets.ConvertAllRenderersToHopooShader(val);
			return val.gameObject;
		}

		public static GameObject CreateBodyPrefab(string bodyName, string modelName, BodyInfo bodyInfo, GameObject bodyPrefab)
		{
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)bodyPrefab))
			{
				log.error(bodyInfo.bodyNameToClone + "Body is not a valid body, character creation failed");
				return null;
			}
			Transform val = null;
			GameObject val2 = null;
			if (modelName != "mdl")
			{
				val2 = Assets.LoadSurvivorModel(modelName);
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = ((Component)bodyPrefab.GetComponentInChildren<CharacterModel>()).gameObject;
				}
				val = AddCharacterModelToSurvivorBody(bodyPrefab, val2.transform, bodyInfo);
			}
			CharacterBody component = bodyPrefab.GetComponent<CharacterBody>();
			((Object)component).name = bodyInfo.bodyName;
			component.baseNameToken = bodyInfo.bodyNameToken;
			component.subtitleNameToken = bodyInfo.subtitleNameToken;
			component.portraitIcon = bodyInfo.characterPortrait;
			component._defaultCrosshairPrefab = bodyInfo.crosshair;
			component.hideCrosshair = false;
			component.preferredPodPrefab = bodyInfo.podPrefab;
			component.baseMaxHealth = bodyInfo.maxHealth;
			component.baseRegen = bodyInfo.healthRegen;
			component.baseArmor = bodyInfo.armor;
			component.baseMaxShield = bodyInfo.shield;
			component.baseDamage = bodyInfo.damage;
			component.baseAttackSpeed = bodyInfo.attackSpeed;
			component.baseCrit = bodyInfo.crit;
			component.baseMoveSpeed = bodyInfo.moveSpeed;
			component.baseJumpPower = bodyInfo.jumpPower;
			component.autoCalculateLevelStats = bodyInfo.autoCalculateLevelStats;
			if (bodyInfo.autoCalculateLevelStats)
			{
				component.levelMaxHealth = Mathf.Round(component.baseMaxHealth * 0.3f);
				component.levelMaxShield = Mathf.Round(component.baseMaxShield * 0.3f);
				component.levelRegen = component.baseRegen * 0.2f;
				component.levelMoveSpeed = 0f;
				component.levelJumpPower = 0f;
				component.levelDamage = component.baseDamage * 0.2f;
				component.levelAttackSpeed = 0f;
				component.levelCrit = 0f;
				component.levelArmor = 0f;
			}
			else
			{
				component.levelMaxHealth = bodyInfo.healthGrowth;
				component.levelMaxShield = bodyInfo.shieldGrowth;
				component.levelRegen = bodyInfo.regenGrowth;
				component.levelMoveSpeed = bodyInfo.moveSpeedGrowth;
				component.levelJumpPower = bodyInfo.jumpPowerGrowth;
				component.levelDamage = bodyInfo.damageGrowth;
				component.levelAttackSpeed = bodyInfo.attackSpeedGrowth;
				component.levelCrit = bodyInfo.critGrowth;
				component.levelArmor = bodyInfo.armorGrowth;
			}
			component.baseAcceleration = bodyInfo.acceleration;
			component.baseJumpCount = bodyInfo.jumpCount;
			component.sprintingSpeedMultiplier = bodyInfo.sprintMultiplier;
			component.rootMotionInMainState = false;
			component.hullClassification = (HullClassification)0;
			component.isChampion = false;
			SetupCameraTargetParams(bodyPrefab, bodyInfo);
			SetupModelLocator(bodyPrefab, val, val2.transform);
			SetupMainHurtbox(bodyPrefab, val2);
			SetupAimAnimator(bodyPrefab, val2);
			if ((Object)(object)val != (Object)null)
			{
				SetupCharacterDirection(bodyPrefab, val, val2.transform);
			}
			SetupRagdoll(val2);
			Content.AddCharacterBodyPrefab(bodyPrefab);
			return bodyPrefab;
		}

		public static GameObject CreateBlankMasterPrefab(GameObject bodyPrefab, string masterName)
		{
			GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/CommandoMonsterMaster"), masterName, true);
			ContentPacks.masterPrefabs.Add(val);
			val.GetComponent<CharacterMaster>().bodyPrefab = bodyPrefab;
			AISkillDriver[] components = val.GetComponents<AISkillDriver>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.Destroy((Object)(object)components[i]);
			}
			return val;
		}

		public static void CreateGenericDoppelganger(GameObject bodyPrefab, string masterName, string masterToCopy)
		{
			GameObject obj = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/" + masterToCopy + "MonsterMaster"), masterName, true);
			obj.GetComponent<CharacterMaster>().bodyPrefab = bodyPrefab;
			Content.AddMasterPrefab(obj);
		}

		private static Transform AddCharacterModelToSurvivorBody(GameObject bodyPrefab, Transform modelTransform, BodyInfo bodyInfo)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = new GameObject("ModelBase").transform;
			transform.parent = bodyPrefab.transform;
			transform.localPosition = bodyInfo.modelBasePosition;
			transform.localRotation = Quaternion.identity;
			modelTransform.parent = ((Component)transform).transform;
			modelTransform.localPosition = Vector3.zero;
			modelTransform.localRotation = Quaternion.identity;
			GameObject val = new GameObject("CameraPivot");
			val.transform.parent = bodyPrefab.transform;
			val.transform.localPosition = bodyInfo.cameraPivotPosition;
			val.transform.localRotation = Quaternion.identity;
			GameObject val2 = new GameObject("AimOrigin");
			val2.transform.parent = bodyPrefab.transform;
			val2.transform.localPosition = bodyInfo.aimOriginPosition;
			val2.transform.localRotation = Quaternion.identity;
			bodyPrefab.GetComponent<CharacterBody>().aimOriginTransform = val2.transform;
			return ((Component)transform).transform;
		}

		public static CharacterModel SetupCharacterModel(GameObject prefab)
		{
			return SetupCharacterModel(prefab, null);
		}

		public static CharacterModel SetupCharacterModel(GameObject prefab, CustomRendererInfo[] customInfos)
		{
			CharacterModel val = ((Component)prefab.GetComponent<ModelLocator>().modelTransform).gameObject.GetComponent<CharacterModel>();
			bool num = (Object)(object)val != (Object)null;
			if (!num)
			{
				val = ((Component)prefab.GetComponent<ModelLocator>().modelTransform).gameObject.AddComponent<CharacterModel>();
			}
			val.body = prefab.GetComponent<CharacterBody>();
			val.autoPopulateLightInfos = true;
			val.invisibilityCount = 0;
			val.temporaryOverlays = new List<TemporaryOverlayInstance>();
			if (!num)
			{
				SetupCustomRendererInfos(val, customInfos);
			}
			else
			{
				SetupPreAttachedRendererInfos(val);
			}
			return val;
		}

		public static void SetupPreAttachedRendererInfos(CharacterModel characterModel)
		{
			for (int i = 0; i < characterModel.baseRendererInfos.Length; i++)
			{
				if ((Object)(object)characterModel.baseRendererInfos[i].defaultMaterial == (Object)null)
				{
					characterModel.baseRendererInfos[i].defaultMaterial = characterModel.baseRendererInfos[i].renderer.sharedMaterial;
				}
				characterModel.baseRendererInfos[i].defaultMaterial.SetHopooMaterial();
			}
		}

		public static void SetupCustomRendererInfos(CharacterModel characterModel, CustomRendererInfo[] customInfos)
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			ChildLocator component = ((Component)characterModel).GetComponent<ChildLocator>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				log.error("Failed CharacterModel setup: ChildLocator component does not exist on the model");
				return;
			}
			List<RendererInfo> list = new List<RendererInfo>();
			for (int i = 0; i < customInfos.Length; i++)
			{
				if (!Object.op_Implicit((Object)(object)component.FindChild(customInfos[i].childName)))
				{
					log.error("Trying to add a RendererInfo for a renderer that does not exist: " + customInfos[i].childName);
					continue;
				}
				Renderer component2 = ((Component)component.FindChild(customInfos[i].childName)).GetComponent<Renderer>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					Material val = customInfos[i].material;
					if ((Object)(object)val == (Object)null)
					{
						val = ((!customInfos[i].dontHotpoo) ? component2.material.SetHopooMaterial() : component2.material);
					}
					list.Add(new RendererInfo
					{
						renderer = component2,
						defaultMaterial = val,
						ignoreOverlays = customInfos[i].ignoreOverlays,
						defaultShadowCastingMode = (ShadowCastingMode)1
					});
				}
			}
			characterModel.baseRendererInfos = list.ToArray();
		}

		private static void SetupCharacterDirection(GameObject prefab, Transform modelBaseTransform, Transform modelTransform)
		{
			if (Object.op_Implicit((Object)(object)prefab.GetComponent<CharacterDirection>()))
			{
				CharacterDirection component = prefab.GetComponent<CharacterDirection>();
				component.targetTransform = modelBaseTransform;
				component.overrideAnimatorForwardTransform = null;
				component.rootMotionAccumulator = null;
				component.modelAnimator = ((Component)modelTransform).GetComponent<Animator>();
				component.driveFromRootRotation = false;
				component.turnSpeed = 720f;
			}
		}

		private static void SetupCameraTargetParams(GameObject prefab, BodyInfo bodyInfo)
		{
			CameraTargetParams component = prefab.GetComponent<CameraTargetParams>();
			component.cameraParams = bodyInfo.cameraParams;
			component.cameraPivotTransform = prefab.transform.Find("CameraPivot");
		}

		private static void SetupModelLocator(GameObject prefab, Transform modelBaseTransform, Transform modelTransform)
		{
			ModelLocator component = prefab.GetComponent<ModelLocator>();
			component.modelTransform = modelTransform;
			component.modelBaseTransform = modelBaseTransform;
		}

		private static void SetupMainHurtbox(GameObject prefab, GameObject model)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)prefab.GetComponentInChildren<HurtBoxGroup>()))
			{
				ChildLocator component = model.GetComponent<ChildLocator>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					log.warning("no child locator");
					return;
				}
				if (!Object.op_Implicit((Object)(object)component.FindChild("MainHurtBox")))
				{
					Debug.LogWarning((object)"Could not set up main hurtbox: make sure you have a transform pair in your prefab's ChildLocator component called 'MainHurtBox'");
					return;
				}
				HurtBoxGroup val = model.AddComponent<HurtBoxGroup>();
				HurtBox val2 = ((Component)component.FindChild("MainHurtBox")).gameObject.AddComponent<HurtBox>();
				((Component)val2).gameObject.layer = LayerIndex.entityPrecise.intVal;
				val2.healthComponent = prefab.GetComponent<HealthComponent>();
				val2.isBullseye = true;
				val2.damageModifier = (DamageModifier)0;
				val2.hurtBoxGroup = val;
				val2.indexInGroup = 0;
				val.hurtBoxes = (HurtBox[])(object)new HurtBox[1] { val2 };
				val.mainHurtBox = val2;
				val.bullseyeCount = 1;
			}
		}

		public static void SetupHurtBoxes(GameObject bodyPrefab)
		{
			HealthComponent component = bodyPrefab.GetComponent<HealthComponent>();
			HurtBoxGroup[] componentsInChildren = bodyPrefab.GetComponentsInChildren<HurtBoxGroup>();
			foreach (HurtBoxGroup val in componentsInChildren)
			{
				val.mainHurtBox.healthComponent = component;
				for (int j = 0; j < val.hurtBoxes.Length; j++)
				{
					val.hurtBoxes[j].healthComponent = component;
				}
			}
		}

		private static void SetupFootstepController(GameObject model)
		{
			FootstepHandler obj = model.AddComponent<FootstepHandler>();
			obj.baseFootstepString = "Play_player_footstep";
			obj.sprintFootstepOverrideString = "";
			obj.enableFootstepDust = true;
			obj.footstepDustPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/GenericFootstepDust");
		}

		private static void SetupRagdoll(GameObject model)
		{
			RagdollController component = model.GetComponent<RagdollController>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			if ((Object)(object)ragdollMaterial == (Object)null)
			{
				ragdollMaterial = ((Component)LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponentInChildren<RagdollController>().bones[1]).GetComponent<Collider>().material;
			}
			Transform[] bones = component.bones;
			foreach (Transform val in bones)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					((Component)val).gameObject.layer = LayerIndex.ragdoll.intVal;
					Collider component2 = ((Component)val).GetComponent<Collider>();
					if (Object.op_Implicit((Object)(object)component2))
					{
						component2.material = ragdollMaterial;
						component2.sharedMaterial = ragdollMaterial;
					}
				}
			}
		}

		private static void SetupAimAnimator(GameObject prefab, GameObject model)
		{
			AimAnimator obj = model.AddComponent<AimAnimator>();
			obj.directionComponent = prefab.GetComponent<CharacterDirection>();
			obj.pitchRangeMax = 60f;
			obj.pitchRangeMin = -60f;
			obj.yawRangeMin = -80f;
			obj.yawRangeMax = 80f;
			obj.pitchGiveupRange = 30f;
			obj.yawGiveupRange = 10f;
			obj.giveupDuration = 3f;
			obj.inputBank = prefab.GetComponent<InputBankTest>();
		}

		public static void SetupHitbox(GameObject prefab, Transform hitboxTransform, string hitboxName)
		{
			HitBoxGroup val = prefab.AddComponent<HitBoxGroup>();
			HitBox val2 = ((Component)hitboxTransform).gameObject.AddComponent<HitBox>();
			((Component)hitboxTransform).gameObject.layer = LayerIndex.projectile.intVal;
			val.hitBoxes = (HitBox[])(object)new HitBox[1] { val2 };
			val.groupName = hitboxName;
		}

		public static void SetupHitbox(GameObject prefab, string hitboxName, params Transform[] hitboxTransforms)
		{
			HitBoxGroup val = prefab.AddComponent<HitBoxGroup>();
			List<HitBox> list = new List<HitBox>();
			foreach (Transform obj in hitboxTransforms)
			{
				HitBox item = ((Component)obj).gameObject.AddComponent<HitBox>();
				((Component)obj).gameObject.layer = LayerIndex.projectile.intVal;
				list.Add(item);
			}
			val.hitBoxes = list.ToArray();
			val.groupName = hitboxName;
		}
	}
	public class CustomRendererInfo
	{
		public string childName;

		public Material material;

		public bool dontHotpoo;

		public bool ignoreOverlays;
	}
	internal static class Projectiles
	{
		internal static void RegisterProjectiles()
		{
		}

		internal static void AddProjectile(GameObject projectileToAdd)
		{
			Content.AddProjectilePrefab(projectileToAdd);
		}

		private static void InitializeImpactExplosion(ProjectileImpactExplosion projectileImpactExplosion)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			((ProjectileExplosion)projectileImpactExplosion).blastDamageCoefficient = 1f;
			((ProjectileExplosion)projectileImpactExplosion).blastProcCoefficient = 1f;
			((ProjectileExplosion)projectileImpactExplosion).blastRadius = 1f;
			((ProjectileExplosion)projectileImpactExplosion).bonusBlastForce = Vector3.zero;
			((ProjectileExplosion)projectileImpactExplosion).childrenCount = 0;
			((ProjectileExplosion)projectileImpactExplosion).childrenDamageCoefficient = 0f;
			((ProjectileExplosion)projectileImpactExplosion).childrenProjectilePrefab = null;
			projectileImpactExplosion.destroyOnEnemy = false;
			projectileImpactExplosion.destroyOnWorld = false;
			((ProjectileExplosion)projectileImpactExplosion).falloffModel = (FalloffModel)0;
			((ProjectileExplosion)projectileImpactExplosion).fireChildren = false;
			projectileImpactExplosion.impactEffect = null;
			projectileImpactExplosion.lifetime = 0f;
			projectileImpactExplosion.lifetimeAfterImpact = 0f;
			projectileImpactExplosion.lifetimeRandomOffset = 0f;
			projectileImpactExplosion.offsetForLifetimeExpiredSound = 0f;
			projectileImpactExplosion.timerAfterImpact = false;
			((Component)projectileImpactExplosion).GetComponent<ProjectileDamage>().damageType = DamageTypeCombo.op_Implicit((DamageType)0);
		}

		private static GameObject CreateGhostPrefab(string ghostName)
		{
			GameObject val = Assets.mainAssetBundle.LoadAsset<GameObject>(ghostName);
			if (!Object.op_Implicit((Object)(object)val.GetComponent<NetworkIdentity>()))
			{
				val.AddComponent<NetworkIdentity>();
			}
			if (!Object.op_Implicit((Object)(object)val.GetComponent<ProjectileGhostController>()))
			{
				val.AddComponent<ProjectileGhostController>();
			}
			Assets.ConvertAllRenderersToHopooShader(val);
			return val;
		}

		private static GameObject CloneProjectilePrefab(string prefabName, string newPrefabName)
		{
			return PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/Projectiles/" + prefabName), newPrefabName);
		}
	}
	internal static class Skills
	{
		public static void CreateSkillFamilies(GameObject targetPrefab, bool destroyExisting = true)
		{
			if (destroyExisting)
			{
				GenericSkill[] componentsInChildren = targetPrefab.GetComponentsInChildren<GenericSkill>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
				}
			}
			SkillLocator component = targetPrefab.GetComponent<SkillLocator>();
			component.primary = CreateGenericSkillWithSkillFamily(targetPrefab, "Primary");
			component.secondary = CreateGenericSkillWithSkillFamily(targetPrefab, "Secondary");
			component.utility = CreateGenericSkillWithSkillFamily(targetPrefab, "Utility");
			component.special = CreateGenericSkillWithSkillFamily(targetPrefab, "Special");
		}

		public static GenericSkill CreateGenericSkillWithSkillFamily(GameObject targetPrefab, string familyName, bool hidden = false)
		{
			GenericSkill obj = targetPrefab.AddComponent<GenericSkill>();
			obj.skillName = familyName;
			obj.hideInCharacterSelect = hidden;
			SkillFamily val = ScriptableObject.CreateInstance<SkillFamily>();
			((Object)val).name = ((Object)targetPrefab).name + familyName + "Family";
			val.variants = (Variant[])(object)new Variant[0];
			obj._skillFamily = val;
			Content.AddSkillFamily(val);
			return obj;
		}

		public static void AddSkillToFamily(SkillFamily skillFamily, SkillDef skillDef, UnlockableDef unlockableDef = null)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0051: 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)
			Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1);
			Variant[] variants = skillFamily.variants;
			int num = skillFamily.variants.Length - 1;
			Variant val = new Variant
			{
				skillDef = skillDef,
				unlockableDef = unlockableDef
			};
			((Variant)(ref val)).viewableNode = new Node(skillDef.skillNameToken, false, (Node)null);
			variants[num] = val;
		}

		public static void AddSkillsToFamily(SkillFamily skillFamily, params SkillDef[] skillDefs)
		{
			foreach (SkillDef skillDef in skillDefs)
			{
				AddSkillToFamily(skillFamily, skillDef);
			}
		}

		public static void AddPrimarySkills(GameObject targetPrefab, params SkillDef[] skillDefs)
		{
			AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().primary.skillFamily, skillDefs);
		}

		public static void AddSecondarySkills(GameObject targetPrefab, params SkillDef[] skillDefs)
		{
			AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().secondary.skillFamily, skillDefs);
		}

		public static void AddUtilitySkills(GameObject targetPrefab, params SkillDef[] skillDefs)
		{
			AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().utility.skillFamily, skillDefs);
		}

		public static void AddSpecialSkills(GameObject targetPrefab, params SkillDef[] skillDefs)
		{
			AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().special.skillFamily, skillDefs);
		}

		public static void AddPassive(GameObject targetPrefab, PassiveSkill passiveskill)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			targetPrefab.GetComponent<SkillLocator>().passiveSkill = passiveskill;
		}

		public static void AddUnlockablesToFamily(SkillFamily skillFamily, params UnlockableDef[] unlockableDefs)
		{
			//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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < unlockableDefs.Length; i++)
			{
				Variant val = skillFamily.variants[i];
				val.unlockableDef = unlockableDefs[i];
				skillFamily.variants[i] = val;
			}
		}

		public static SkillDef CreateSkillDef(SkillDefInfo skillDefInfo)
		{
			return Skills.CreateSkillDef<SkillDef>(skillDefInfo);
		}

		public static T Creat