using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using R2API;
using RoR2;
using RobomandoMod.Survivors.Robomando;
using RobomandoMod.Survivors.Robomando.SkillStates;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RefurbishedRoboMando")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5045d29026917eb41afc25ab811ec6bfb09c646c")]
[assembly: AssemblyProduct("RefurbishedRoboMando")]
[assembly: AssemblyTitle("RefurbishedRoboMando")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;
		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RefurbishedRoboMando
{
	public static class ColorCode
	{
		public enum FontColor
		{
			cStack,
			cIsDamage,
			cIsHealth,
			cIsUtility,
			cIsHealing,
			cDeath,
			cSub,
			cKeywordName,
			cIsVoid
		}
		public static string Style(this string self, FontColor style)
		{
			return "<style=" + style.ToString() + ">" + self + "</style>";
		}
	}
	public static class RefurbishConfigEntry
	{
		public static ConfigEntry<bool> Replace_Icon;
		public static ConfigEntry<Configs.IconDirection> Icon_Direction;
		public static ConfigEntry<Configs.SkinOrder> Skin_Order;
		public static ConfigEntry<bool> Disable_Skins;
		public static ConfigEntry<bool> Replace_Tokens;
		public static ConfigEntry<bool> Replace_Logbook_Model;
		public static ConfigEntry<bool> Replace_Logbook_Lore;
		public static ConfigEntry<bool> Replace_Skill_Stats;
		public static ConfigEntry<bool> Replace_Body_Stats;
		public static ConfigEntry<int> Health_Convert;
		public static ConfigEntry<bool> Jury_Rework;
	}
	public static class PresetSkillStats
	{
		public static float Shoot_Damage = 75f;
		public static float Shoot_Coefficient = 1f;
		public static float Zap_Damage = 220f;
		public static float Zap_Coefficient = 2f;
		public static float Zap_Cooldown = 3f;
		public static float Dive_Splat_Duration = 0.5f;
		public static float Dive_Cooldown = 4f;
		public static float Hack_Duration = 3f;
		public static float Hack_Cooldown = 5f;
		public static float Hack_NoTarget_Cooldown = 0.5f;
	}
	public class Configs
	{
		public enum IconDirection
		{
			LEFT,
			RIGHT
		}
		public enum SkinOrder
		{
			FIRST,
			LAST
		}
		public Configs()
		{
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			string text = "Icon";
			RefurbishConfigEntry.Replace_Icon = AssetStatics.plugin.Config.Bind<bool>(text, "Enable Replacement", true, "[ True = Replace | False = Original ]\nChanges ROBOMANDO's icon");
			RefurbishConfigEntry.Icon_Direction = AssetStatics.plugin.Config.Bind<IconDirection>(text, "Icon Direction", IconDirection.LEFT, "[ Left = Risk of Rain Returns | Right = Normal ]\nChanges ROBOMANDO's icon direction");
			string text2 = "Skins";
			RefurbishConfigEntry.Skin_Order = AssetStatics.plugin.Config.Bind<SkinOrder>(text2, "Enable Replacement", SkinOrder.FIRST, "[ First = Modded Skins First | Last = Modded Skins Last ]\nChanges REFURBISHED skin order");
			RefurbishConfigEntry.Disable_Skins = AssetStatics.plugin.Config.Bind<bool>(text2, "Disable Other Skins", false, "[ True = Disables | False = Keeps ]\nToggles non Refurbished ROBOMANDO skins");
			string text3 = "Logbook";
			RefurbishConfigEntry.Replace_Logbook_Model = AssetStatics.plugin.Config.Bind<bool>(text3, "Enable Model Replacement", true, "[ True = Replace | False = Original ]\nChanges ROBOMANDO's Logbook model");
			RefurbishConfigEntry.Replace_Logbook_Lore = AssetStatics.plugin.Config.Bind<bool>(text3, "Enable Lore Replacement", true, "[ True = Replace | False = Original ]\nChanges ROBOMANDO's Logbook lore");
			string text4 = "Rewrites";
			RefurbishConfigEntry.Replace_Tokens = AssetStatics.plugin.Config.Bind<bool>(text4, "Enable Rewrite", true, "[ True = Rewrite | False = Original ]\nChanges ROBOMANDO's rewrite text");
			string text5 = "Stats";
			RefurbishConfigEntry.Replace_Skill_Stats = AssetStatics.plugin.Config.Bind<bool>(text5, "Enable Skill Stat Replacement", true, "[ True = Replace | False = Original ]\nChanges ROBOMANDO's skill stats to be closer to Risk of Rain Returns");
			RefurbishConfigEntry.Replace_Body_Stats = AssetStatics.plugin.Config.Bind<bool>(text5, "Enable Body Stat Replacement", true, "[ True = Replace | False = Original ]\nChanges ROBOMANDO's body stats to be closer to Risk of Rain Returns");
			RefurbishConfigEntry.Health_Convert = AssetStatics.plugin.Config.Bind<int>(text5, "Health to Shield Conversion", 0, new ConfigDescription("[ 0.0 = 0% Conversion ]\nBase health to shield percent", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			string text6 = "Reworks";
			RefurbishConfigEntry.Jury_Rework = AssetStatics.plugin.Config.Bind<bool>(text6, "Re-Wire - Jury Rework", true, "[ True = Rework | False = Original ]\nChanges Jury into Sabotage, taking the actual item from a Printer");
		}
	}
	public class HiddenSkin
	{
		public HiddenSkin()
		{
			LanguageAPI.Add("SECURED_TRANSFORM_2P", "... You've fallen to the influence of the Void.".Style(ColorCode.FontColor.cIsVoid));
			LanguageAPI.Add("SECURED_TRANSFORM", "... {0} has fallen to the influence of the Void.".Style(ColorCode.FontColor.cIsVoid));
			CharacterBody.onBodyInventoryChangedGlobal += ChangeSkin;
		}
		private static void ChangeSkin(CharacterBody self)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)self.inventory))
			{
				return;
			}
			ModelLocator component = ((Component)self).GetComponent<ModelLocator>();
			ReplaceCurrentSkin replaceCurrentSkin = (Object.op_Implicit((Object)(object)component) ? ((Component)component.modelTransform).gameObject.GetComponent<ReplaceCurrentSkin>() : null);
			if (!Object.op_Implicit((Object)(object)replaceCurrentSkin))
			{
				return;
			}
			int itemCount = self.inventory.GetItemCount(Items.BearVoid);
			SkinDef val = BodyCatalog.GetBodySkins(self.bodyIndex)[self.skinIndex];
			if (val.nameToken.Equals(AssetStatics.skinTokens[1]) && itemCount > 0)
			{
				replaceCurrentSkin.ChangeSkin(AssetStatics.skinTokens[2]);
				if (!replaceCurrentSkin.infested)
				{
					replaceCurrentSkin.infested = true;
					Chat.SendBroadcastChat((ChatMessageBase)new SubjectFormatChatMessage
					{
						subjectAsCharacterBody = self,
						baseToken = "SECURED_TRANSFORM"
					});
				}
			}
			else if (val.nameToken.Equals(AssetStatics.skinTokens[1]) && itemCount <= 0)
			{
				replaceCurrentSkin.infested = false;
				replaceCurrentSkin.ChangeSkin(AssetStatics.skinTokens[1]);
			}
		}
	}
	public class JuryRework
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__StealItem;
		}
		public JuryRework()
		{
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			LanguageAPI.AddOverlay(AssetStatics.tokenPrefix + "KEYWORD_JURY_RIG", "Sabotage".Style(ColorCode.FontColor.cKeywordName) + "Used on a Printer will ".Style(ColorCode.FontColor.cSub) + "activate it for free".Style(ColorCode.FontColor.cIsUtility) + ", but ".Style(ColorCode.FontColor.cSub) + "break it".Style(ColorCode.FontColor.cIsHealth) + ". Costs ".Style(ColorCode.FontColor.cSub) + "X% ".Style(ColorCode.FontColor.cIsHealth) + "(".Style(ColorCode.FontColor.cSub) + "50%" + "/".Style(ColorCode.FontColor.cSub) + "75%".Style(ColorCode.FontColor.cIsHealing) + "/" + "90%".Style(ColorCode.FontColor.cIsHealth) + "/" + "95%".Style(ColorCode.FontColor.cIsDamage) + ") ".Style(ColorCode.FontColor.cSub) + "of your current health".Style(ColorCode.FontColor.cIsHealth) + ".".Style(ColorCode.FontColor.cSub));
			if (!RefurbishConfigEntry.Replace_Tokens.Value)
			{
				LanguageAPI.AddOverlay(AssetStatics.tokenPrefix + "SPECIAL_HACK_DESCRIPTION", "Jury-Rig".Style(ColorCode.FontColor.cIsUtility) + ". Re-wire a nearby mechanical object, " + "activating it for free".Style(ColorCode.FontColor.cIsUtility) + ".");
			}
			MethodInfo? method = typeof(Hack).GetMethod("HackDevice");
			object obj = <>O.<0>__StealItem;
			if (obj == null)
			{
				Manipulator val = StealItem;
				<>O.<0>__StealItem = val;
				obj = (object)val;
			}
			new ILHook((MethodBase)method, (Manipulator)obj);
		}
		private static void StealItem(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int pickupIndex = -1;
			int num9 = default(int);
			int num8 = default(int);
			int num7 = default(int);
			int num6 = default(int);
			ILLabel[] array2 = default(ILLabel[]);
			if (!val.TryGotoNext(new Func<Instruction, bool>[7]
			{
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref pickupIndex),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 2),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num9),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num8),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num7),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num6),
				(Instruction x) => ILPatternMatchingExt.MatchSwitch(x, ref array2)
			}))
			{
				Log.Warning("Failed to hook item index");
			}
			int num5 = default(int);
			int num4 = default(int);
			int num3 = default(int);
			int num2 = default(int);
			ILLabel[] array = default(ILLabel[]);
			if (val.TryGotoNext(new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 2),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num5),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num4),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num3),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num2),
				(Instruction x) => ILPatternMatchingExt.MatchSwitch(x, ref array)
			}))
			{
				val.Emit(OpCodes.Ldloc, pickupIndex);
				val.Emit(OpCodes.Ldarg, 0);
				val.Emit(OpCodes.Ldarg, 1);
				val.Emit(OpCodes.Ldarg, 2);
				val.EmitDelegate<Func<PickupIndex, GameObject, GameObject, PrinterItemType, PickupIndex>>((Func<PickupIndex, GameObject, GameObject, PrinterItemType, PickupIndex>)delegate(PickupIndex self, GameObject robo, GameObject interact, PrinterItemType type)
				{
					//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_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_000a: Invalid comparison between Unknown and I4
					//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ca: 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_0028: Unknown result type (might be due to invalid IL or missing references)
					//IL_0029: Unknown result type (might be due to invalid IL or missing references)
					//IL_002e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					//IL_0035: Unknown result type (might be due to invalid IL or missing references)
					//IL_003a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Expected O, but got Unknown
					//IL_0047: Unknown result type (might be due to invalid IL or missing references)
					//IL_004a: Invalid comparison between Unknown and I4
					//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
					//IL_0065: Unknown result type (might be due to invalid IL or missing references)
					//IL_0068: Invalid comparison between Unknown and I4
					//IL_0083: Unknown result type (might be due to invalid IL or missing references)
					//IL_0086: Invalid comparison between Unknown and I4
					//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a4: Invalid comparison between Unknown and I4
					PickupIndex result = PickupIndex.none;
					if ((int)type > 0)
					{
						HealthComponent component = robo.GetComponent<HealthComponent>();
						ShopTerminalBehavior component2 = interact.GetComponent<ShopTerminalBehavior>();
						result = component2.pickupIndex;
						DamageInfo val3 = new DamageInfo
						{
							damageType = DamageTypeCombo.op_Implicit((DamageType)3),
							procCoefficient = 0f
						};
						if ((int)type == 1)
						{
							val3.damage = component.fullCombinedHealth * 0.5f;
						}
						if ((int)type == 2)
						{
							val3.damage = component.fullCombinedHealth * 0.75f;
						}
						if ((int)type == 3)
						{
							val3.damage = component.fullCombinedHealth * 0.9f;
						}
						if ((int)type == 4)
						{
							val3.damage = component.fullCombinedHealth * 0.95f;
						}
						component.TakeDamage(val3);
					}
					return result;
				});
				val.Emit(OpCodes.Stloc, pickupIndex);
				int index = val.Index;
				int num = default(int);
				if (val.TryGotoNext(new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Vector3>(x, "get_zero"),
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num)
				}))
				{
					ILLabel val2 = val.MarkLabel();
					val.Goto(index, (MoveType)0, false);
					val.Emit(OpCodes.Br, val2.Target);
				}
			}
			else
			{
				Log.Warning("Failed to hook scrap replacement");
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;
		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}
		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}
		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}
		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}
		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}
		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}
		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("noodlegemo.ROBOMANDO_Refurbished", "ROBOMANDO_Refurbished", "1.2.3")]
	public class RefurbishedRoboMando : BaseUnityPlugin
	{
		public const string PluginGUID = "noodlegemo.ROBOMANDO_Refurbished";
		public const string PluginAuthor = "noodlegemo";
		public const string PluginName = "ROBOMANDO_Refurbished";
		public const string PluginVersion = "1.2.3";
		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			new AssetStatics((BaseUnityPlugin)(object)this);
			new Configs();
			((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)SetUpOnBodyLoad);
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SetUpLast));
		}
		private static void SetUpOnBodyLoad()
		{
			if (Object.op_Implicit((Object)(object)AssetStatics.bodyComponent))
			{
				if (RefurbishConfigEntry.Icon_Direction.Value == Configs.IconDirection.LEFT)
				{
					AssetStatics.bodyComponent.portraitIcon = (Texture)(object)AssetStatics.bundle.LoadAsset<Sprite>("RobomandoIcon").texture;
				}
				else
				{
					AssetStatics.bodyComponent.portraitIcon = (Texture)(object)AssetStatics.bundle.LoadAsset<Sprite>("RobomandoIconAlt").texture;
				}
			}
		}
		private static void SetUpLast()
		{
			SkinOrder();
			new HiddenSkin();
			if (AssetStatics.modSkins != null)
			{
				SkinDef val = AssetStatics.modSkins.Find((SkinDef self) => self.nameToken.Equals(AssetStatics.skinTokens[1]));
				val.unlockableDef = RobomandoUnlockables.masterySkinUnlockableDef;
			}
			if (RefurbishConfigEntry.Replace_Logbook_Model.Value)
			{
				GameObject gameObject = ((Component)AssetStatics.bodyPrefab.GetComponent<ModelLocator>().modelTransform).gameObject;
				gameObject.AddComponent<ReplaceCurrentSkin>();
			}
			if (RefurbishConfigEntry.Replace_Logbook_Lore.Value)
			{
				LanguageAPI.AddOverlay(AssetStatics.tokenPrefix + "LORE", "Order: ROBOMANDO Model-7\r\nTracking Number: 45133554F44495351454" + "\r\n\r\nT  H  A  N  K    Y  O  U    F  O  R    P  U  R  C  H  A  S  I  N  G    T  H  I  S    R  O  B  O  M  A  N  D  O    M  O  D  E  L   -  7  .".Style(ColorCode.FontColor.cStack) + "\r\nI  N  S  T  R  U  C  T  I  O  N  S    A  R  E    I  N  C  L  U  D  E  D     I  N    A    S  E  P  E  R  A  T  E    P  A  C  K  A  G  E  .".Style(ColorCode.FontColor.cStack) + "\r\n\r\n... Damn.");
			}
			if (RefurbishConfigEntry.Replace_Tokens.Value)
			{
				if (!RefurbishConfigEntry.Replace_Skill_Stats.Value)
				{
					PresetSkillStats.Shoot_Damage = 100f * RobomandoStaticValues.shootDamageCoefficient;
					PresetSkillStats.Zap_Damage = 100f * RobomandoStaticValues.zapDamageCoefficient;
				}
				LanguageAPI.AddOverlay(AssetStatics.tokenPrefix + "NAME", "ROBOMANDO");
				LanguageAPI.AddOverlay(AssetStatics.tokenPrefix + "DESCRIPTION", "Your ROBOMANDO Model-7 comes equipped with everything it needs to extract resources from hostile environments.<color=#CCD3E0>\n\n< ! > As weak as Single Fire is, it has no fall-off damage.\n\n< ! > Despite the short range on De-Escalate, you can utilize it to pierce through multiple enemies at once, stunning them all in series.\n\n< ! > Re-Wire allows instant access to any company sanctioned containers or drone utilities - make up your lack of strength and durability through stealing everything!\n\n< ! > Remember that ROBOMANDO's skills aren't the most effective against enemies - use your increased movement speed to maintain distance accordingly.");
				LanguageAPI.AddOverlay(AssetStatics.tokenPrefix + "PRIMARY_SHOT_DESCRIPTION", string.Format("Agile".Style(ColorCode.FontColor.cIsUtility) + ". Shoot once for " + "{0}% damage".Style(ColorCode.FontColor.cIsDamage) + ".", PresetSkillStats.Shoot_Damage));
				LanguageAPI.AddOverlay(AssetStatics.tokenPrefix + "SECONDARY_ZAP_DESCRIPTION", string.Format("Agile".Style(ColorCode.FontColor.cIsUtility) + ". " + "Stunning".Style(ColorCode.FontColor.cIsDamage) + ". Fire a small electrical charge that " + "pierces enemies ".Style(ColorCode.FontColor.cIsDamage) + "for " + "{0}% damage".Style(ColorCode.FontColor.cIsDamage) + ".", PresetSkillStats.Zap_Damage));
				LanguageAPI.AddOverlay(AssetStatics.tokenPrefix + "UTILITY_ROLL_DESCRIPTION", "Attempt to " + "dive forward ".Style(ColorCode.FontColor.cIsUtility) + "a small distance. You " + "cannot be hit ".Style(ColorCode.FontColor.cIsUtility) + "early in the maneuver.");
				string arg = (RefurbishConfigEntry.Jury_Rework.Value ? "Sabotage" : "Jury-Rig");
				LanguageAPI.AddOverlay(AssetStatics.tokenPrefix + "SPECIAL_HACK_DESCRIPTION", string.Format("{0}".Style(ColorCode.FontColor.cIsUtility) + ". Re-wire a mechanical object, " + "activating it for free".Style(ColorCode.FontColor.cIsUtility) + ".", arg));
				SkillLocator val2 = (Object.op_Implicit((Object)(object)AssetStatics.bodyPrefab) ? AssetStatics.bodyPrefab.GetComponent<SkillLocator>() : null);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					return;
				}
				val2.primary.skillFamily.defaultSkillDef.keywordTokens = new string[1] { "KEYWORD_AGILE" };
				val2.secondary.skillFamily.defaultSkillDef.keywordTokens = new string[2] { "KEYWORD_AGILE", "KEYWORD_STUNNING" };
			}
			if (RefurbishConfigEntry.Replace_Skill_Stats.Value)
			{
				StatChanges();
			}
			if (RefurbishConfigEntry.Replace_Body_Stats.Value)
			{
				BodyChanges();
			}
			if (RefurbishConfigEntry.Jury_Rework.Value)
			{
				new JuryRework();
			}
		}
		private static void SkinOrder()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected I4, but got Unknown
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected I4, but got Unknown
			if (!Object.op_Implicit((Object)(object)AssetStatics.bodyComponent))
			{
				return;
			}
			List<SkinDef> list = new List<SkinDef>();
			List<SkinDef> list2 = new List<SkinDef>();
			List<SkinDef> list3 = new List<SkinDef>();
			List<SkinDef> list4 = new List<SkinDef>();
			SkinDef[] bodySkins = BodyCatalog.GetBodySkins(AssetStatics.bodyComponent.bodyIndex);
			foreach (SkinDef val in bodySkins)
			{
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				if (RefurbishConfigEntry.Disable_Skins.Value)
				{
					bool flag = false;
					foreach (string item in AssetStatics.skinPrefixBlacklist)
					{
						if (val.nameToken.StartsWith(item, StringComparison.OrdinalIgnoreCase))
						{
							flag = true;
							break;
						}
					}
					if (flag)
					{
						continue;
					}
				}
				if (AssetStatics.hiddenTokens.Contains(val.nameToken))
				{
					list2.Add(val);
				}
				else if (AssetStatics.skinTokens.Contains(val.nameToken))
				{
					list.Add(val);
				}
				else
				{
					list3.Add(val);
				}
			}
			if (RefurbishConfigEntry.Skin_Order.Value == Configs.SkinOrder.FIRST)
			{
				list4.AddRange(list);
				list4.AddRange(list3);
			}
			else
			{
				list4.AddRange(list3);
				list4.AddRange(list);
			}
			SkinDef[][] skins = BodyCatalog.skins;
			int num = (int)AssetStatics.bodyComponent.bodyIndex;
			List<SkinDef> list5 = list4;
			int num2 = 0;
			SkinDef[] array = (SkinDef[])(object)new SkinDef[list5.Count];
			foreach (SkinDef item2 in list5)
			{
				array[num2] = item2;
				num2++;
			}
			skins[num] = array;
			SkinDef[][] skinsByBody = SkinCatalog.skinsByBody;
			int num3 = (int)AssetStatics.bodyComponent.bodyIndex;
			List<SkinDef> list6 = list4;
			int num4 = 0;
			SkinDef[] array2 = (SkinDef[])(object)new SkinDef[list6.Count];
			foreach (SkinDef item3 in list6)
			{
				array2[num4] = item3;
				num4++;
			}
			skinsByBody[num3] = array2;
			list4.AddRange(list2);
			ModelLocator component = AssetStatics.bodyPrefab.GetComponent<ModelLocator>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			Log.Debug("Has model locator");
			ModelSkinController component2 = ((Component)component.modelTransform).gameObject.GetComponent<ModelSkinController>();
			if (!Object.op_Implicit((Object)(object)component2))
			{
				return;
			}
			ModelSkinController val2 = component2;
			List<SkinDef> list7 = list4;
			int num5 = 0;
			SkinDef[] array3 = (SkinDef[])(object)new SkinDef[list7.Count];
			foreach (SkinDef item4 in list7)
			{
				array3[num5] = item4;
				num5++;
			}
			val2.skins = array3;
		}
		private static void StatChanges()
		{
			SkillLocator val = (Object.op_Implicit((Object)(object)AssetStatics.bodyPrefab) ? AssetStatics.bodyPrefab.GetComponent<SkillLocator>() : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				RobomandoStaticValues.shootDamageCoefficient = PresetSkillStats.Shoot_Damage / 100f;
				RobomandoStaticValues.shootProcCoefficient = PresetSkillStats.Shoot_Coefficient;
				RobomandoStaticValues.zapDamageCoefficient = PresetSkillStats.Zap_Damage / 100f;
				RobomandoStaticValues.zapProcCoefficient = PresetSkillStats.Zap_Coefficient;
				RobomandoStaticValues.zapCooldown = PresetSkillStats.Zap_Cooldown;
				RobomandoStaticValues.diveCrashTime = PresetSkillStats.Dive_Splat_Duration;
				RobomandoStaticValues.diveCooldown = PresetSkillStats.Dive_Cooldown;
				RobomandoStaticValues.hackTime = PresetSkillStats.Hack_Duration;
				RobomandoStaticValues.successfullHackCooldown = PresetSkillStats.Hack_Cooldown;
				RobomandoStaticValues.unsuccessfullHackCooldown = PresetSkillStats.Hack_NoTarget_Cooldown;
				val.special.skillFamily.defaultSkillDef.baseRechargeInterval = PresetSkillStats.Hack_Cooldown;
			}
		}
		private static void BodyChanges()
		{
			if (Object.op_Implicit((Object)(object)AssetStatics.bodyComponent))
			{
				float num = (float)RefurbishConfigEntry.Health_Convert.Value / 100f;
				AssetStatics.bodyComponent.baseMaxHealth = Math.Max(80f * (1f - num), 1f);
				AssetStatics.bodyComponent.levelMaxHealth = 28f * (1f - num);
				AssetStatics.bodyComponent.baseMaxShield = Math.Min(80f * num, 79f);
				AssetStatics.bodyComponent.levelMaxShield = 28f * num;
				AssetStatics.bodyComponent.baseRegen = 3f;
				AssetStatics.bodyComponent.levelRegen = 0.3f;
				AssetStatics.bodyComponent.baseDamage = 15f;
				AssetStatics.bodyComponent.levelDamage = 3.2f;
				AssetStatics.bodyComponent.baseArmor = 0f;
				AssetStatics.bodyComponent.baseMoveSpeed = 9f;
			}
		}
	}
	public class ReplaceCurrentSkin : MonoBehaviour
	{
		private readonly Random random = new Random();
		private ModelSkinController component;
		private CharacterBody body;
		public bool infested;
		private void Awake()
		{
			component = ((Component)this).GetComponent<ModelSkinController>();
			body = component.characterModel.body;
		}
		private void Start()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			if (SceneCatalog.currentSceneDef.cachedName == "logbook")
			{
				int index = (Util.CheckRoll(7.5f, 0f, (CharacterMaster)null) ? random.Next(1, AssetStatics.skinTokens.Count - 1) : 0);
				ChangeSkin(AssetStatics.skinTokens[index]);
			}
			if (!Object.op_Implicit((Object)(object)body))
			{
				return;
			}
			SkinDef val = BodyCatalog.GetBodySkins(body.bodyIndex)[body.skinIndex];
			if (val.nameToken.Equals(AssetStatics.skinTokens[1]))
			{
				SetInfestedBool();
				if (infested)
				{
					ChangeSkin(AssetStatics.skinTokens[2]);
				}
			}
		}
		public void ChangeSkin(string skinToken)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			SkinDef[] bodySkins = BodyCatalog.GetBodySkins(AssetStatics.bodyComponent.bodyIndex);
			foreach (SkinDef val in bodySkins)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					if (val.nameToken.Equals(skinToken))
					{
						break;
					}
					num++;
				}
			}
			component.ApplySkin(num);
		}
		private void SetInfestedBool()
		{
			CharacterBody val = component.characterModel.body;
			int num = (Object.op_Implicit((Object)(object)val.inventory) ? val.inventory.GetItemCount(Items.BearVoid) : 0);
			if (num > 0)
			{
				infested = true;
			}
		}
	}
	public class AssetStatics
	{
		public static readonly string bodyInternal = "RobomandoBody";
		public static readonly string tokenPrefix = "RAT_ROBOMANDO_";
		public static BaseUnityPlugin plugin;
		public static CharacterBody bodyComponent;
		public static GameObject bodyPrefab;
		public static AssetBundle bundle;
		public static List<SkinDef> modSkins;
		public static readonly List<string> skinPrefixBlacklist = new List<string>(2) { "RAT_", "DEFAULT_SKIN" };
		public static readonly List<string> skinTokens = new List<string>(3) { "NOODLEGEMO_SKIN_ROBOMANDO_NAME", "NOODLEGEMO_SKIN_MONSOONROBO_NAME", "NOODLEGEMO_SKIN_INFESTEDROBO_NAME" };
		public static readonly List<string> hiddenTokens = new List<string>(1) { "NOODLEGEMO_SKIN_INFESTEDROBO_NAME" };
		public AssetStatics(BaseUnityPlugin plugin)
		{
			AssetStatics.plugin = plugin;
			((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)SetUpOnBodyLoad);
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SetUpLast));
			bundle = AssetBundle.LoadFromFile(Path.Combine(Directory.GetParent(plugin.Info.Location).ToString(), "robomandoasset"));
		}
		private static void SetUpOnBodyLoad()
		{
			bodyPrefab = BodyCatalog.FindBodyPrefab(bodyInternal);
			bodyComponent = (Object.op_Implicit((Object)(object)bodyPrefab) ? bodyPrefab.GetComponent<CharacterBody>() : null);
		}
		private static void SetUpLast()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)bodyComponent))
			{
				return;
			}
			modSkins = new List<SkinDef>();
			SkinDef[] bodySkins = BodyCatalog.GetBodySkins(bodyComponent.bodyIndex);
			foreach (SkinDef val in bodySkins)
			{
				if (Object.op_Implicit((Object)(object)val) && skinTokens.Contains(val.nameToken))
				{
					modSkins.Add(val);
				}
			}
		}
	}
}