Decompiled source of LinkPaladin v1.0.0

LinkPaladin.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 EntityStates;
using LinkPaladinSkins;
using Microsoft.CodeAnalysis;
using On.EntityStates;
using On.RoR2;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LinkPaladin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LinkPaladin")]
[assembly: AssemblyTitle("LinkPaladin")]
[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 LinkPaladin
{
	[BepInPlugin("prodzpod.LinkPaladin", "LinkPaladin", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<string, Material> <>9__17_0;

			public static hook_ProcessJump <>9__17_2;

			public static hook_OnCharacterHitGroundSFX <>9__17_3;

			public static Action<DamageReport> <>9__17_4;

			public static hook_OnExecute <>9__17_5;

			public static hook_OnLevelUp <>9__17_6;

			public static Action<Run> <>9__17_7;

			public static hook_OnInteractionBegin <>9__17_8;

			public static hook_AddShrineStack <>9__17_9;

			public static hook_AttemptGrant <>9__17_10;

			public static hook_ClientSetReady <>9__17_11;

			public static Action<Run, RunReport> <>9__17_12;

			internal Material <Init>b__17_0(string x)
			{
				return LinkPaladinSkinsPlugin.assetBundle.LoadAsset<Material>("Assets/Resources/" + x + ".mat");
			}

			internal void <Init>b__17_2(orig_ProcessJump orig, GenericCharacterMain self)
			{
				if (((BaseCharacterMain)self).hasCharacterMotor && self.jumpInputReceived && Object.op_Implicit((Object)(object)((EntityState)self).characterBody) && ((EntityState)self).characterMotor.jumpCount < ((EntityState)self).characterBody.maxJumpCount && IsLink(((EntityState)self).characterBody))
				{
					Util.PlaySound("Play_OOT_AdultLink_Jump", ((Component)((EntityState)self).characterBody).gameObject);
				}
				orig.Invoke(self);
			}

			internal void <Init>b__17_3(orig_OnCharacterHitGroundSFX orig, GlobalEventManager self, CharacterBody body, HitGroundInfo info, bool damage)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self, body, info, damage);
				if (damage && IsLink(body))
				{
					Util.PlaySound("Play_OOT_Link_FallDown_Dirt", ((Component)body).gameObject);
					Util.PlaySound("Play_OOT_AdultLink_FallDown", ((Component)body).gameObject);
				}
			}

			internal void <Init>b__17_4(DamageReport report)
			{
				if (IsLink(report.victimBody))
				{
					Util.PlaySound("Play_OOT_AdultLink_Hurt", ((Component)report.victimBody).gameObject);
				}
				if (IsLink(report.attackerBody) && Object.op_Implicit((Object)(object)report.victimBody) && ((DamageTypeCombo)(ref report.damageInfo.damageType)).IsDamageSourceSkillBased)
				{
					Util.PlaySound("Play_OOT_Enemy_Hit", ((Component)report.victimBody).gameObject);
				}
			}

			internal void <Init>b__17_5(orig_OnExecute orig, GenericSkill self)
			{
				orig.Invoke(self);
				if (IsLink(self.characterBody))
				{
					if ((Object)(object)self == (Object)(object)self.characterBody.skillLocator.primary)
					{
						Util.PlaySound("Play_OOT_AdultLink_Attack", ((Component)self.characterBody).gameObject);
						Util.PlaySound("Play_OOT_Sword", ((Component)self.characterBody).gameObject);
					}
					if ((Object)(object)self == (Object)(object)self.characterBody.skillLocator.secondary)
					{
						Util.PlaySound("Play_OOT_AdultLink_StrongAttack", ((Component)self.characterBody).gameObject);
						Util.PlaySound("Play_OOT_Sword_Spin", ((Component)self.characterBody).gameObject);
					}
					if ((Object)(object)self == (Object)(object)self.characterBody.skillLocator.special)
					{
						Util.PlaySound("Play_OOT_AdultLink_DinsFire", ((Component)self.characterBody).gameObject);
						Util.PlaySound("Play_OOT_Sword_Spin_Magic", ((Component)self.characterBody).gameObject);
					}
					if ((Object)(object)self == (Object)(object)self.characterBody.skillLocator.utility)
					{
						Util.PlaySound("Play_OOT_AdultLink_Grunt", ((Component)self.characterBody).gameObject);
						Util.PlaySound("Play_OOT_Sword_Rock", ((Component)self.characterBody).gameObject);
					}
				}
			}

			internal void <Init>b__17_6(orig_OnLevelUp orig, CharacterBody self)
			{
				orig.Invoke(self);
				if (IsLink(self))
				{
					Util.PlaySound("Play_OOT_Get_Heart", ((Component)self).gameObject);
				}
			}

			internal void <Init>b__17_7(Run self)
			{
				if (IsLink(LocalUserManager.GetFirstLocalUser().cachedBody))
				{
					Util.PlaySound("Play_MM_Clocktower_Bell", ((Component)LocalUserManager.GetFirstLocalUser().cachedBody).gameObject);
				}
			}

			internal void <Init>b__17_8(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor i)
			{
				orig.Invoke(self, i);
				if (IsLink(LocalUserManager.GetFirstLocalUser().cachedBody))
				{
					if (((Object)((Component)self).gameObject).name.StartsWith("Chest1") || ((Object)((Component)self).gameObject).name.StartsWith("CategoryChest") || ((Object)((Component)self).gameObject).name.StartsWith("EquipmentBarrel"))
					{
						Util.PlaySound("Play_OOT_Chest_Small", ((Component)self).gameObject);
					}
					else if (((Object)((Component)self).gameObject).name.StartsWith("Chest2") || ((Object)((Component)self).gameObject).name.StartsWith("GoldChest") || ((Object)((Component)self).gameObject).name.StartsWith("CommandChest"))
					{
						Util.PlaySound("Play_OOT_Chest_Big", ((Component)self).gameObject);
					}
					if (((Object)((Component)self).gameObject).name.StartsWith("MultiShop"))
					{
						Util.PlaySound("Play_OOT_Get_Rupee", ((Component)self).gameObject);
					}
					if (((Object)((Component)self).gameObject).name.StartsWith("ShrineRestack") || ((Object)((Component)self).gameObject).name.StartsWith("ShrineCleanse"))
					{
						Util.PlaySound("Play_OOT_Secret", ((Component)self).gameObject);
					}
					if (((Object)((Component)self).gameObject).name.StartsWith("ShrineBoss") || ((Object)((Component)self).gameObject).name.StartsWith("ShrineCombat"))
					{
						Util.PlaySound("Play_OOT_Switch", ((Component)self).gameObject);
					}
					if (((Object)((Component)self).gameObject).name.StartsWith("ShrineHealing"))
					{
						Util.PlaySound("Play_OOT_Fairy", ((Component)self).gameObject);
					}
					if (((Object)((Component)self).gameObject).name.Contains("Drone"))
					{
						Util.PlaySound("Play_OOT_Navi_In", ((Component)self).gameObject);
					}
				}
			}

			internal void <Init>b__17_9(orig_AddShrineStack orig, ShrineChanceBehavior self, Interactor i)
			{
				int successfulPurchaseCount = self.successfulPurchaseCount;
				orig.Invoke(self, i);
				if (self.successfulPurchaseCount > successfulPurchaseCount)
				{
					Util.PlaySound("Play_OOT_Secret", ((Component)self).gameObject);
				}
				else
				{
					Util.PlaySound("Play_OOT_Error", ((Component)self).gameObject);
				}
			}

			internal void <Init>b__17_10(orig_AttemptGrant orig, GenericPickupController self, CharacterBody body)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Invalid comparison between Unknown and I4
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Invalid comparison between Unknown and I4
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: 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_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Expected I4, but got Unknown
				if (IsLink(body))
				{
					PickupDef pickupDef = PickupCatalog.GetPickupDef(self.pickupIndex);
					if (pickupDef == null)
					{
						orig.Invoke(self, body);
						return;
					}
					if ((int)pickupDef.equipmentIndex != -1)
					{
						Util.PlaySound("Play_OOT_HandTriforce", ((Component)body).gameObject);
					}
					else if ((int)pickupDef.itemIndex != -1)
					{
						ItemTier tier = ItemCatalog.GetItemDef(pickupDef.itemIndex).tier;
						ItemTier val = tier;
						switch ((int)val)
						{
						case 0:
							Util.PlaySound("Play_OOT_Get_SmallItem", ((Component)body).gameObject);
							break;
						case 3:
						case 6:
							Util.PlaySound("Play_OOT_GoldSkulltula_Token", ((Component)body).gameObject);
							break;
						case 1:
						case 7:
							Util.PlaySound("Play_OOT_Fanfare_SmallItem", ((Component)body).gameObject);
							break;
						case 2:
						case 8:
							Util.PlaySound("Play_OOT_Fanfare_Item", ((Component)body).gameObject);
							break;
						default:
							Util.PlaySound("Play_OOT_Fanfare_HeartContainer", ((Component)body).gameObject);
							break;
						}
					}
				}
				orig.Invoke(self, body);
			}

			internal void <Init>b__17_11(orig_ClientSetReady orig, CharacterSelectController self)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: 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)
				orig.Invoke(self);
				BodyIndex val = BodyCatalog.FindBodyIndex("RobPaladinBody");
				if (self.currentSurvivorDef.survivorIndex == SurvivorCatalog.FindSurvivorIndex("RobPaladin") && ((Object)SkinCatalog.GetBodySkinDef(val, (int)LocalUserManager.GetFirstLocalUser().userProfile.loadout.bodyLoadoutManager.GetSkinIndex(val))).name.StartsWith("Link"))
				{
					Util.PlaySound("Play_OOT_PressStart", ((Component)self).gameObject);
				}
			}

			internal void <Init>b__17_12(Run run, RunReport report)
			{
				CharacterBody cachedBody = LocalUserManager.GetFirstLocalUser().cachedBody;
				if (IsLink(cachedBody))
				{
					if (report.gameEnding.isWin)
					{
						Util.PlaySound("Play_OOT_Fanfare_Item", ((Component)cachedBody).gameObject);
					}
					else
					{
						Util.PlaySound("Play_OOT_GameOver", ((Component)cachedBody).gameObject);
					}
				}
			}
		}

		public const string PluginGUID = "prodzpod.LinkPaladin";

		public const string PluginAuthor = "prodzpod";

		public const string PluginName = "LinkPaladin";

		public const string PluginVersion = "1.0.0";

		public static ManualLogSource Log;

		public static PluginInfo pluginInfo;

		public static ConfigFile Config;

		public static ConfigEntry<bool> EnableJumpFall;

		public static ConfigEntry<bool> EnableHitHurt;

		public static ConfigEntry<bool> EnableSkill;

		public static ConfigEntry<bool> EnableLevel;

		public static ConfigEntry<bool> EnableDifficulty;

		public static ConfigEntry<bool> EnableChest;

		public static ConfigEntry<bool> EnableItem;

		public static ConfigEntry<bool> EnableMisc;

		public static Material[] materials;

		public void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			pluginInfo = ((BaseUnityPlugin)this).Info;
			Log = ((BaseUnityPlugin)this).Logger;
			Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "prodzpod.LinkPaladin.cfg"), true);
			EnableJumpFall = Config.Bind<bool>("Soundpack", "Enable Jump/Fall", true, "");
			EnableHitHurt = Config.Bind<bool>("Soundpack", "Enable Hit/Hurt", true, "");
			EnableSkill = Config.Bind<bool>("Soundpack", "Enable Skill Usage", true, "");
			EnableLevel = Config.Bind<bool>("Soundpack", "Enable Level Up", true, "");
			EnableDifficulty = Config.Bind<bool>("Soundpack", "Enable Difficulty Up", true, "note: MM sound");
			EnableChest = Config.Bind<bool>("Soundpack", "Enable Chest Open", true, "");
			EnableItem = Config.Bind<bool>("Soundpack", "Enable Item Get", true, "");
			EnableMisc = Config.Bind<bool>("Soundpack", "Enable Miscellaneous", true, "");
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(Init));
		}

		public void Init()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00ce: 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_00d9: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Expected O, but got Unknown
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Expected O, but got Unknown
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Expected O, but got Unknown
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Expected O, but got Unknown
			string[] strings = new string[10] { "link_01g_png.001", "p_tex02_png.001", "p_tex01_png.001", "p_tex09_png.001", "p_tex09_3", "link_00_png.001", "link_m00_png.001", "link_f00_png.001", "link_f01_png.001", "link_e00_png.001" };
			materials = strings.Select((string x) => LinkPaladinSkinsPlugin.assetBundle.LoadAsset<Material>("Assets/Resources/" + x + ".mat")).ToArray();
			CharacterModel.UpdateRendererMaterials += (hook_UpdateRendererMaterials)delegate(orig_UpdateRendererMaterials orig, CharacterModel self, Renderer renderer, Material mat, bool a)
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self, renderer, mat, a);
				if (strings.Contains(((Object)mat).name))
				{
					renderer.materials = materials;
					GameObject val11 = GameObject.Find("SwordStuff");
					if (Object.op_Implicit((Object)(object)val11))
					{
						val11.SetActive(false);
					}
					GameObject val12 = GameObject.Find("meshPaladinDefault");
					if (Object.op_Implicit((Object)(object)val12))
					{
						if (val12.transform.localScale.x > 0f)
						{
							val12.transform.localScale = new Vector3(0f - val12.transform.localScale.x, val12.transform.localScale.y, val12.transform.localScale.z);
						}
						Transform val13 = val12.transform.parent.Find("Armature");
						if (((Component)val13).transform.localScale.x > 0f)
						{
							((Component)val13).transform.localScale = new Vector3(0f - ((Component)val13).transform.localScale.x, ((Component)val13).transform.localScale.y, ((Component)val13).transform.localScale.z);
						}
					}
				}
			};
			if (EnableJumpFall.Value)
			{
				object obj = <>c.<>9__17_2;
				if (obj == null)
				{
					hook_ProcessJump val = delegate(orig_ProcessJump orig, GenericCharacterMain self)
					{
						if (((BaseCharacterMain)self).hasCharacterMotor && self.jumpInputReceived && Object.op_Implicit((Object)(object)((EntityState)self).characterBody) && ((EntityState)self).characterMotor.jumpCount < ((EntityState)self).characterBody.maxJumpCount && IsLink(((EntityState)self).characterBody))
						{
							Util.PlaySound("Play_OOT_AdultLink_Jump", ((Component)((EntityState)self).characterBody).gameObject);
						}
						orig.Invoke(self);
					};
					<>c.<>9__17_2 = val;
					obj = (object)val;
				}
				GenericCharacterMain.ProcessJump += (hook_ProcessJump)obj;
				object obj2 = <>c.<>9__17_3;
				if (obj2 == null)
				{
					hook_OnCharacterHitGroundSFX val2 = delegate(orig_OnCharacterHitGroundSFX orig, GlobalEventManager self, CharacterBody body, HitGroundInfo info, bool damage)
					{
						//IL_0004: Unknown result type (might be due to invalid IL or missing references)
						orig.Invoke(self, body, info, damage);
						if (damage && IsLink(body))
						{
							Util.PlaySound("Play_OOT_Link_FallDown_Dirt", ((Component)body).gameObject);
							Util.PlaySound("Play_OOT_AdultLink_FallDown", ((Component)body).gameObject);
						}
					};
					<>c.<>9__17_3 = val2;
					obj2 = (object)val2;
				}
				GlobalEventManager.OnCharacterHitGroundSFX += (hook_OnCharacterHitGroundSFX)obj2;
			}
			if (EnableHitHurt.Value)
			{
				GlobalEventManager.onServerDamageDealt += delegate(DamageReport report)
				{
					if (IsLink(report.victimBody))
					{
						Util.PlaySound("Play_OOT_AdultLink_Hurt", ((Component)report.victimBody).gameObject);
					}
					if (IsLink(report.attackerBody) && Object.op_Implicit((Object)(object)report.victimBody) && ((DamageTypeCombo)(ref report.damageInfo.damageType)).IsDamageSourceSkillBased)
					{
						Util.PlaySound("Play_OOT_Enemy_Hit", ((Component)report.victimBody).gameObject);
					}
				};
			}
			if (EnableSkill.Value)
			{
				object obj3 = <>c.<>9__17_5;
				if (obj3 == null)
				{
					hook_OnExecute val3 = delegate(orig_OnExecute orig, GenericSkill self)
					{
						orig.Invoke(self);
						if (IsLink(self.characterBody))
						{
							if ((Object)(object)self == (Object)(object)self.characterBody.skillLocator.primary)
							{
								Util.PlaySound("Play_OOT_AdultLink_Attack", ((Component)self.characterBody).gameObject);
								Util.PlaySound("Play_OOT_Sword", ((Component)self.characterBody).gameObject);
							}
							if ((Object)(object)self == (Object)(object)self.characterBody.skillLocator.secondary)
							{
								Util.PlaySound("Play_OOT_AdultLink_StrongAttack", ((Component)self.characterBody).gameObject);
								Util.PlaySound("Play_OOT_Sword_Spin", ((Component)self.characterBody).gameObject);
							}
							if ((Object)(object)self == (Object)(object)self.characterBody.skillLocator.special)
							{
								Util.PlaySound("Play_OOT_AdultLink_DinsFire", ((Component)self.characterBody).gameObject);
								Util.PlaySound("Play_OOT_Sword_Spin_Magic", ((Component)self.characterBody).gameObject);
							}
							if ((Object)(object)self == (Object)(object)self.characterBody.skillLocator.utility)
							{
								Util.PlaySound("Play_OOT_AdultLink_Grunt", ((Component)self.characterBody).gameObject);
								Util.PlaySound("Play_OOT_Sword_Rock", ((Component)self.characterBody).gameObject);
							}
						}
					};
					<>c.<>9__17_5 = val3;
					obj3 = (object)val3;
				}
				GenericSkill.OnExecute += (hook_OnExecute)obj3;
			}
			if (EnableLevel.Value)
			{
				object obj4 = <>c.<>9__17_6;
				if (obj4 == null)
				{
					hook_OnLevelUp val4 = delegate(orig_OnLevelUp orig, CharacterBody self)
					{
						orig.Invoke(self);
						if (IsLink(self))
						{
							Util.PlaySound("Play_OOT_Get_Heart", ((Component)self).gameObject);
						}
					};
					<>c.<>9__17_6 = val4;
					obj4 = (object)val4;
				}
				CharacterBody.OnLevelUp += (hook_OnLevelUp)obj4;
			}
			if (EnableDifficulty.Value)
			{
				Run.onRunAmbientLevelUp += delegate
				{
					if (IsLink(LocalUserManager.GetFirstLocalUser().cachedBody))
					{
						Util.PlaySound("Play_MM_Clocktower_Bell", ((Component)LocalUserManager.GetFirstLocalUser().cachedBody).gameObject);
					}
				};
			}
			if (EnableChest.Value)
			{
				object obj5 = <>c.<>9__17_8;
				if (obj5 == null)
				{
					hook_OnInteractionBegin val5 = delegate(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor i)
					{
						orig.Invoke(self, i);
						if (IsLink(LocalUserManager.GetFirstLocalUser().cachedBody))
						{
							if (((Object)((Component)self).gameObject).name.StartsWith("Chest1") || ((Object)((Component)self).gameObject).name.StartsWith("CategoryChest") || ((Object)((Component)self).gameObject).name.StartsWith("EquipmentBarrel"))
							{
								Util.PlaySound("Play_OOT_Chest_Small", ((Component)self).gameObject);
							}
							else if (((Object)((Component)self).gameObject).name.StartsWith("Chest2") || ((Object)((Component)self).gameObject).name.StartsWith("GoldChest") || ((Object)((Component)self).gameObject).name.StartsWith("CommandChest"))
							{
								Util.PlaySound("Play_OOT_Chest_Big", ((Component)self).gameObject);
							}
							if (((Object)((Component)self).gameObject).name.StartsWith("MultiShop"))
							{
								Util.PlaySound("Play_OOT_Get_Rupee", ((Component)self).gameObject);
							}
							if (((Object)((Component)self).gameObject).name.StartsWith("ShrineRestack") || ((Object)((Component)self).gameObject).name.StartsWith("ShrineCleanse"))
							{
								Util.PlaySound("Play_OOT_Secret", ((Component)self).gameObject);
							}
							if (((Object)((Component)self).gameObject).name.StartsWith("ShrineBoss") || ((Object)((Component)self).gameObject).name.StartsWith("ShrineCombat"))
							{
								Util.PlaySound("Play_OOT_Switch", ((Component)self).gameObject);
							}
							if (((Object)((Component)self).gameObject).name.StartsWith("ShrineHealing"))
							{
								Util.PlaySound("Play_OOT_Fairy", ((Component)self).gameObject);
							}
							if (((Object)((Component)self).gameObject).name.Contains("Drone"))
							{
								Util.PlaySound("Play_OOT_Navi_In", ((Component)self).gameObject);
							}
						}
					};
					<>c.<>9__17_8 = val5;
					obj5 = (object)val5;
				}
				PurchaseInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj5;
				object obj6 = <>c.<>9__17_9;
				if (obj6 == null)
				{
					hook_AddShrineStack val6 = delegate(orig_AddShrineStack orig, ShrineChanceBehavior self, Interactor i)
					{
						int successfulPurchaseCount = self.successfulPurchaseCount;
						orig.Invoke(self, i);
						if (self.successfulPurchaseCount > successfulPurchaseCount)
						{
							Util.PlaySound("Play_OOT_Secret", ((Component)self).gameObject);
						}
						else
						{
							Util.PlaySound("Play_OOT_Error", ((Component)self).gameObject);
						}
					};
					<>c.<>9__17_9 = val6;
					obj6 = (object)val6;
				}
				ShrineChanceBehavior.AddShrineStack += (hook_AddShrineStack)obj6;
			}
			if (EnableItem.Value)
			{
				object obj7 = <>c.<>9__17_10;
				if (obj7 == null)
				{
					hook_AttemptGrant val7 = delegate(orig_AttemptGrant orig, GenericPickupController self, CharacterBody body)
					{
						//IL_0010: Unknown result type (might be due to invalid IL or missing references)
						//IL_0033: Unknown result type (might be due to invalid IL or missing references)
						//IL_0039: Invalid comparison between Unknown and I4
						//IL_0059: Unknown result type (might be due to invalid IL or missing references)
						//IL_005f: Invalid comparison between Unknown and I4
						//IL_006e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0078: Unknown result type (might be due to invalid IL or missing references)
						//IL_007d: Unknown result type (might be due to invalid IL or missing references)
						//IL_007f: 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_0083: Unknown result type (might be due to invalid IL or missing references)
						//IL_00ae: Expected I4, but got Unknown
						if (IsLink(body))
						{
							PickupDef pickupDef = PickupCatalog.GetPickupDef(self.pickupIndex);
							if (pickupDef == null)
							{
								orig.Invoke(self, body);
								return;
							}
							if ((int)pickupDef.equipmentIndex != -1)
							{
								Util.PlaySound("Play_OOT_HandTriforce", ((Component)body).gameObject);
							}
							else if ((int)pickupDef.itemIndex != -1)
							{
								ItemTier tier = ItemCatalog.GetItemDef(pickupDef.itemIndex).tier;
								ItemTier val10 = tier;
								switch ((int)val10)
								{
								case 0:
									Util.PlaySound("Play_OOT_Get_SmallItem", ((Component)body).gameObject);
									break;
								case 3:
								case 6:
									Util.PlaySound("Play_OOT_GoldSkulltula_Token", ((Component)body).gameObject);
									break;
								case 1:
								case 7:
									Util.PlaySound("Play_OOT_Fanfare_SmallItem", ((Component)body).gameObject);
									break;
								case 2:
								case 8:
									Util.PlaySound("Play_OOT_Fanfare_Item", ((Component)body).gameObject);
									break;
								default:
									Util.PlaySound("Play_OOT_Fanfare_HeartContainer", ((Component)body).gameObject);
									break;
								}
							}
						}
						orig.Invoke(self, body);
					};
					<>c.<>9__17_10 = val7;
					obj7 = (object)val7;
				}
				GenericPickupController.AttemptGrant += (hook_AttemptGrant)obj7;
			}
			if (!EnableMisc.Value)
			{
				return;
			}
			object obj8 = <>c.<>9__17_11;
			if (obj8 == null)
			{
				hook_ClientSetReady val8 = delegate(orig_ClientSetReady orig, CharacterSelectController self)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0013: Unknown result type (might be due to invalid IL or missing references)
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0024: Unknown result type (might be due to invalid IL or missing references)
					//IL_002b: 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)
					orig.Invoke(self);
					BodyIndex val9 = BodyCatalog.FindBodyIndex("RobPaladinBody");
					if (self.currentSurvivorDef.survivorIndex == SurvivorCatalog.FindSurvivorIndex("RobPaladin") && ((Object)SkinCatalog.GetBodySkinDef(val9, (int)LocalUserManager.GetFirstLocalUser().userProfile.loadout.bodyLoadoutManager.GetSkinIndex(val9))).name.StartsWith("Link"))
					{
						Util.PlaySound("Play_OOT_PressStart", ((Component)self).gameObject);
					}
				};
				<>c.<>9__17_11 = val8;
				obj8 = (object)val8;
			}
			CharacterSelectController.ClientSetReady += (hook_ClientSetReady)obj8;
			Run.onClientGameOverGlobal += delegate(Run run, RunReport report)
			{
				CharacterBody cachedBody = LocalUserManager.GetFirstLocalUser().cachedBody;
				if (IsLink(cachedBody))
				{
					if (report.gameEnding.isWin)
					{
						Util.PlaySound("Play_OOT_Fanfare_Item", ((Component)cachedBody).gameObject);
					}
					else
					{
						Util.PlaySound("Play_OOT_GameOver", ((Component)cachedBody).gameObject);
					}
				}
			};
		}

		public static bool IsLink(CharacterBody body)
		{
			//IL_000a: 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)
			return Object.op_Implicit((Object)(object)body) && body.bodyIndex == BodyCatalog.FindBodyIndex("RobPaladinBody") && ((Object)SkinCatalog.GetBodySkinDef(body.bodyIndex, (int)body.skinIndex)).name.StartsWith("Link");
		}
	}
}

LinkPaladinSkins.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using MonoMod.RuntimeDetour.HookGen;
using RoR2;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace LinkPaladinSkins;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.prodzpod.LinkPaladinSkins", "LinkPaladinSkins", "1.0.0")]
public class LinkPaladinSkinsPlugin : BaseUnityPlugin
{
	private class FieldException : Exception
	{
		public FieldException(string message, Exception innerException)
			: base(message, innerException)
		{
		}
	}

	private static AssetBundle assetBundle;

	internal static LinkPaladinSkinsPlugin Instance { get; private set; }

	internal static ManualLogSource InstanceLogger
	{
		get
		{
			LinkPaladinSkinsPlugin instance = Instance;
			if (instance == null)
			{
				return null;
			}
			return ((BaseUnityPlugin)instance).Logger;
		}
	}

	private void Start()
	{
		Instance = this;
		using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LinkPaladinSkins.prodzpodlinkpaladinskins"))
		{
			assetBundle = AssetBundle.LoadFromStream(stream);
		}
		((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)BodyCatalogInit);
		HookEndpointManager.Add((MethodBase)typeof(Language).GetMethod("LoadStrings"), (Delegate)new Action<Action<Language>, Language>(LanguageLoadStrings));
	}

	private static void LanguageLoadStrings(Action<Language> orig, Language self)
	{
		orig(self);
		self.SetStringByToken("PRODZPOD_SKIN_LINK_NAME", "Link");
		self.SetStringByToken("PRODZPOD_SKIN_LINKSHIELDLESS_NAME", "Link (Shieldless)");
	}

	private static void Nothing(Action<SkinDef> orig, SkinDef self)
	{
	}

	private static void BodyCatalogInit()
	{
		MethodInfo? method = typeof(SkinDef).GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic);
		HookEndpointManager.Add((MethodBase)method, (Delegate)new Action<Action<SkinDef>, SkinDef>(Nothing));
		AddRobPaladinBodyLinkSkin();
		AddRobPaladinBodyLinkShieldlessSkin();
		HookEndpointManager.Remove((MethodBase)method, (Delegate)new Action<Action<SkinDef>, SkinDef>(Nothing));
	}

	private static void AddRobPaladinBodyLinkSkin()
	{
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		string text = "RobPaladinBody";
		string text2 = "Link";
		try
		{
			GameObject val = BodyCatalog.FindBodyPrefab(text);
			if (!Object.op_Implicit((Object)(object)val))
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin because \"" + text + "\" doesn't exist"));
				return;
			}
			ModelLocator component = val.GetComponent<ModelLocator>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelLocator\" component"));
				return;
			}
			GameObject gameObject = ((Component)component.modelTransform).gameObject;
			ModelSkinController skinController = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<ModelSkinController>() : null);
			if (!Object.op_Implicit((Object)(object)skinController))
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component"));
				return;
			}
			Renderer[] renderers = gameObject.GetComponentsInChildren<Renderer>(true);
			SkinDef skin = ScriptableObject.CreateInstance<SkinDef>();
			TryCatchThrow("Icon", delegate
			{
				skin.icon = assetBundle.LoadAsset<Sprite>("Assets\\SkinMods\\LinkPaladinSkins\\Icons\\LinkIcon.png");
			});
			((Object)skin).name = text2;
			skin.nameToken = "PRODZPOD_SKIN_LINK_NAME";
			skin.rootObject = gameObject;
			TryCatchThrow("Base Skins", delegate
			{
				skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { skinController.skins[0] };
			});
			TryCatchThrow("Unlockable Name", delegate
			{
				skin.unlockableDef = null;
			});
			TryCatchThrow("Game Object Activations", delegate
			{
				skin.gameObjectActivations = Array.Empty<GameObjectActivation>();
			});
			TryCatchThrow("Renderer Infos", delegate
			{
				//IL_0011: 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_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_0165: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_020a: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0214: Unknown result type (might be due to invalid IL or missing references)
				//IL_0233: Unknown result type (might be due to invalid IL or missing references)
				//IL_0271: Unknown result type (might be due to invalid IL or missing references)
				//IL_0272: Unknown result type (might be due to invalid IL or missing references)
				//IL_027b: Unknown result type (might be due to invalid IL or missing references)
				//IL_029a: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0301: Unknown result type (might be due to invalid IL or missing references)
				//IL_033f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0340: Unknown result type (might be due to invalid IL or missing references)
				//IL_0349: Unknown result type (might be due to invalid IL or missing references)
				//IL_0368: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_040e: Unknown result type (might be due to invalid IL or missing references)
				//IL_040f: Unknown result type (might be due to invalid IL or missing references)
				skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[10]
				{
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_00_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_01g_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_e00_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_f00_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_f01_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_m00_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/p_tex01_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/p_tex02_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/p_tex09_3.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/p_tex09_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					}
				};
			});
			TryCatchThrow("Mesh Replacements", delegate
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[3]
				{
					new MeshReplacement
					{
						mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\LinkPaladinSkins\\Meshes\\link.001.mesh"),
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new MeshReplacement
					{
						mesh = null,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault_Cape")
					},
					new MeshReplacement
					{
						mesh = null,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault_Sword")
					}
				};
			});
			TryCatchThrow("Minion Skin Replacements", delegate
			{
				skin.minionSkinReplacements = Array.Empty<MinionSkinReplacement>();
			});
			TryCatchThrow("Projectile Ghost Replacements", delegate
			{
				skin.projectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
			});
			Array.Resize(ref skinController.skins, skinController.skins.Length + 1);
			skinController.skins[skinController.skins.Length - 1] = skin;
			BodyCatalog.skins[BodyCatalog.FindBodyIndex(val)] = skinController.skins;
		}
		catch (FieldException ex)
		{
			InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
			InstanceLogger.LogWarning((object)("Field causing issue: " + ex.Message));
			InstanceLogger.LogError((object)ex.InnerException);
		}
		catch (Exception ex2)
		{
			InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
			InstanceLogger.LogError((object)ex2);
		}
	}

	private static void AddRobPaladinBodyLinkShieldlessSkin()
	{
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		string text = "RobPaladinBody";
		string text2 = "LinkShieldless";
		try
		{
			GameObject val = BodyCatalog.FindBodyPrefab(text);
			if (!Object.op_Implicit((Object)(object)val))
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin because \"" + text + "\" doesn't exist"));
				return;
			}
			ModelLocator component = val.GetComponent<ModelLocator>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelLocator\" component"));
				return;
			}
			GameObject gameObject = ((Component)component.modelTransform).gameObject;
			ModelSkinController skinController = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<ModelSkinController>() : null);
			if (!Object.op_Implicit((Object)(object)skinController))
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component"));
				return;
			}
			Renderer[] renderers = gameObject.GetComponentsInChildren<Renderer>(true);
			SkinDef skin = ScriptableObject.CreateInstance<SkinDef>();
			TryCatchThrow("Icon", delegate
			{
				skin.icon = assetBundle.LoadAsset<Sprite>("Assets\\SkinMods\\LinkPaladinSkins\\Icons\\LinkShieldlessIcon.png");
			});
			((Object)skin).name = text2;
			skin.nameToken = "PRODZPOD_SKIN_LINKSHIELDLESS_NAME";
			skin.rootObject = gameObject;
			TryCatchThrow("Base Skins", delegate
			{
				skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { skinController.skins[0] };
			});
			TryCatchThrow("Unlockable Name", delegate
			{
				skin.unlockableDef = null;
			});
			TryCatchThrow("Game Object Activations", delegate
			{
				skin.gameObjectActivations = Array.Empty<GameObjectActivation>();
			});
			TryCatchThrow("Renderer Infos", delegate
			{
				//IL_0011: 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_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_0165: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_020a: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0214: Unknown result type (might be due to invalid IL or missing references)
				//IL_0233: Unknown result type (might be due to invalid IL or missing references)
				//IL_0271: Unknown result type (might be due to invalid IL or missing references)
				//IL_0272: Unknown result type (might be due to invalid IL or missing references)
				//IL_027b: Unknown result type (might be due to invalid IL or missing references)
				//IL_029a: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0301: Unknown result type (might be due to invalid IL or missing references)
				//IL_033f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0340: Unknown result type (might be due to invalid IL or missing references)
				//IL_0349: Unknown result type (might be due to invalid IL or missing references)
				//IL_0368: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_040e: Unknown result type (might be due to invalid IL or missing references)
				//IL_040f: Unknown result type (might be due to invalid IL or missing references)
				skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[10]
				{
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_00_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_01g_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_e00_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_f00_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_f01_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/link_m00_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/p_tex01_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/p_tex02_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/p_tex09_3.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/p_tex09_png.001.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					}
				};
			});
			TryCatchThrow("Mesh Replacements", delegate
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[3]
				{
					new MeshReplacement
					{
						mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\LinkPaladinSkins\\Meshes\\link.002.mesh"),
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault")
					},
					new MeshReplacement
					{
						mesh = null,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault_Cape")
					},
					new MeshReplacement
					{
						mesh = null,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "meshPaladinDefault_Sword")
					}
				};
			});
			TryCatchThrow("Minion Skin Replacements", delegate
			{
				skin.minionSkinReplacements = Array.Empty<MinionSkinReplacement>();
			});
			TryCatchThrow("Projectile Ghost Replacements", delegate
			{
				skin.projectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
			});
			Array.Resize(ref skinController.skins, skinController.skins.Length + 1);
			skinController.skins[skinController.skins.Length - 1] = skin;
			BodyCatalog.skins[BodyCatalog.FindBodyIndex(val)] = skinController.skins;
		}
		catch (FieldException ex)
		{
			InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
			InstanceLogger.LogWarning((object)("Field causing issue: " + ex.Message));
			InstanceLogger.LogError((object)ex.InnerException);
		}
		catch (Exception ex2)
		{
			InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
			InstanceLogger.LogError((object)ex2);
		}
	}

	private static void TryCatchThrow(string message, Action action)
	{
		try
		{
			action?.Invoke();
		}
		catch (Exception innerException)
		{
			throw new FieldException(message, innerException);
		}
	}
}