Decompiled source of SnowtimeToybox v1.0.0

plugins/SnowtimeSkins.dll

Decompiled 13 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using MonoMod.RuntimeDetour;
using MonoMod.RuntimeDetour.HookGen;
using RoR2;
using RuneFoxMods.DynamicSkins;
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 SnowtimeSkins
{
	[BepInPlugin("com.winterwonderland.SnowtimeSkins", "Snowtime Skins", "1.0.0")]
	public class SnowtimeSkinsPlugin : BaseUnityPlugin
	{
		public class DynamicSkinExtension
		{
			private Modification SnowtimeSkinsVRCSnowtime01snowtime_snowflakeModification;

			private Modification SnowtimeSkinsVRCSnowtime01snowtime_weaponModification;

			private Modification SnowtimeSkinsVRCSnowtime01outfit_extendedModification;

			private Modification SnowtimeSkinsVRCSnowtime01neko_hair_updModification;

			private Modification SnowtimeSkinsVRCSnowtime01neko_ears_updModification;

			private Modification SnowtimeSkinsVRCSnowtime01neko_tail_updModification;

			internal void BeforeStart()
			{
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				_DynamicSkinManager.InstanceLogger = ((BaseUnityPlugin)Instance).Logger;
				new Hook((MethodBase)typeof(SkinDef).GetMethod("Apply"), (Delegate)new Action<Action<SkinDef, GameObject>, SkinDef, GameObject>(_DynamicSkinManager.SkinDefApply)).Apply();
			}

			internal void AfterStart()
			{
				InitializeModifications();
				InitializeDynamicBones();
				AddModificationsToList();
			}

			internal void BeforeBodyCatalogInit()
			{
				DroneTechBodySnowtimeSkinsVRCSnowtime01SkinAddedEvent += onSkinAdded;
			}

			internal void AfterBodyCatalogInit()
			{
			}

			private void InitializeModifications()
			{
				SnowtimeSkinsVRCSnowtime01snowtime_snowflakeModification = new Modification("snowtime_snowflake.prefab", "head", "DroneTechBody", "WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -1, AffectsBaseModel: false, assetBundle);
				SnowtimeSkinsVRCSnowtime01snowtime_weaponModification = new Modification("snowtime_weapon.prefab", "weapon_M", "DroneTechBody", "WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -2, AffectsBaseModel: false, assetBundle);
				SnowtimeSkinsVRCSnowtime01outfit_extendedModification = new Modification("outfit_extended.prefab", "pelvis", "DroneTechBody", "WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -3, AffectsBaseModel: false, assetBundle);
				SnowtimeSkinsVRCSnowtime01neko_hair_updModification = new Modification("neko_hair_upd.prefab", "head", "DroneTechBody", "WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -4, AffectsBaseModel: false, assetBundle);
				SnowtimeSkinsVRCSnowtime01neko_ears_updModification = new Modification("neko_ears_upd.prefab", "head", "DroneTechBody", "WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -5, AffectsBaseModel: false, assetBundle);
				SnowtimeSkinsVRCSnowtime01neko_tail_updModification = new Modification("neko_tail_upd.prefab", "pelvis", "DroneTechBody", "WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -6, AffectsBaseModel: false, assetBundle);
			}

			private void InitializeDynamicBones()
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: 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)
				//IL_00e4: 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)
				//IL_014f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_025a: Unknown result type (might be due to invalid IL or missing references)
				//IL_026e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0282: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_030c: Unknown result type (might be due to invalid IL or missing references)
				SnowtimeSkinsVRCSnowtime01snowtime_snowflakeModification.dynamicBoneData = new DynamicBoneData("dynamicboneroot", 0.2f, null, 0.05f, null, 0.5f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				SnowtimeSkinsVRCSnowtime01snowtime_weaponModification.dynamicBoneData = new DynamicBoneData("db_one", 0.1f, null, 0.1f, null, 0.1f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				SnowtimeSkinsVRCSnowtime01outfit_extendedModification.dynamicBoneData = new DynamicBoneData("coat_root01", 0.35f, null, 0.1f, null, 0.4f, null, 0.15f, null, 0f, null, 1.7f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string> { "coat_root01", "coat_woah" }, (FreezeAxis)0);
				SnowtimeSkinsVRCSnowtime01neko_hair_updModification.dynamicBoneData = new DynamicBoneData("ponytail_root", 0.35f, null, 0.1f, null, 0.3f, null, 0.05f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string> { "ponytail_root" }, (FreezeAxis)0);
				SnowtimeSkinsVRCSnowtime01neko_ears_updModification.dynamicBoneData = new DynamicBoneData("neko_root", 0.35f, null, 0.1f, null, 0.8f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string> { "neko_root" }, (FreezeAxis)0);
				SnowtimeSkinsVRCSnowtime01neko_tail_updModification.dynamicBoneData = new DynamicBoneData("tail_root", 0.35f, null, 0.1f, null, 0.3f, null, 0.1f, null, 0f, null, 1f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
			}

			private void AddModificationsToList()
			{
				_DynamicSkinManager.AddModification("WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -1, SnowtimeSkinsVRCSnowtime01snowtime_snowflakeModification);
				_DynamicSkinManager.AddModification("WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -2, SnowtimeSkinsVRCSnowtime01snowtime_weaponModification);
				_DynamicSkinManager.AddModification("WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -3, SnowtimeSkinsVRCSnowtime01outfit_extendedModification);
				_DynamicSkinManager.AddModification("WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -4, SnowtimeSkinsVRCSnowtime01neko_hair_updModification);
				_DynamicSkinManager.AddModification("WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -5, SnowtimeSkinsVRCSnowtime01neko_ears_updModification);
				_DynamicSkinManager.AddModification("WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", -6, SnowtimeSkinsVRCSnowtime01neko_tail_updModification);
			}

			private static void onSkinAdded(object sender, SkinAddedArgs e)
			{
				_DynamicSkinManager.AddSkinDef(e.skinDef);
			}
		}

		public delegate void VoidDelegate();

		public class SkinAddedArgs : EventArgs
		{
			public SkinDef skinDef { get; }

			public GameObject bodyPrefab { get; }

			public SkinAddedArgs(SkinDef newSkinDef, GameObject newGameObject)
			{
				skinDef = newSkinDef;
				bodyPrefab = newGameObject;
			}
		}

		private class FieldException : Exception
		{
			public FieldException(string message, Exception innerException)
				: base(message, innerException)
			{
			}
		}

		private class ElementException : Exception
		{
			public int Index { get; }

			public ElementException(int index, string message)
				: base(message)
			{
				Index = index;
			}
		}

		private static DynamicSkinExtension _DynamicSkinExtension = new DynamicSkinExtension();

		private static DynamicSkinManager _DynamicSkinManager = new DynamicSkinManager();

		private static VoidDelegate BeforeStartDelegate;

		private static VoidDelegate AfterStartDelegate;

		private static VoidDelegate BeforeBodyCatalogDelegate;

		private static VoidDelegate AfterBodyCatalogDelegate;

		private static AssetBundle assetBundle;

		internal static SnowtimeSkinsPlugin Instance { get; private set; }

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

		private static event EventHandler<SkinAddedArgs> DTGunnerDroneBodySnowtimeSkinsVRCSnowtime02SkinAddedEvent;

		private static event EventHandler<SkinAddedArgs> DroneTechBodySnowtimeSkinsVRCSnowtime01SkinAddedEvent;

		private void Start()
		{
			Instance = this;
			BeforeStart();
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SnowtimeSkins.winterwonderlandsnowtimeskins"))
			{
				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));
			AfterStart();
		}

		private void BeforeStart()
		{
			BeforeStartDelegate = (VoidDelegate)Delegate.Combine(BeforeStartDelegate, new VoidDelegate(_DynamicSkinExtension.BeforeStart));
			BeforeStartDelegate?.Invoke();
		}

		private void AfterStart()
		{
			AfterStartDelegate = (VoidDelegate)Delegate.Combine(AfterStartDelegate, new VoidDelegate(_DynamicSkinExtension.AfterStart));
			AfterStartDelegate?.Invoke();
		}

		private static void BeforeBodyCatalogInit()
		{
			BeforeBodyCatalogDelegate = (VoidDelegate)Delegate.Combine(BeforeBodyCatalogDelegate, new VoidDelegate(_DynamicSkinExtension.BeforeBodyCatalogInit));
			BeforeBodyCatalogDelegate?.Invoke();
		}

		private static void AfterBodyCatalogInit()
		{
			AfterBodyCatalogDelegate = (VoidDelegate)Delegate.Combine(AfterBodyCatalogDelegate, new VoidDelegate(_DynamicSkinExtension.AfterBodyCatalogInit));
			AfterBodyCatalogDelegate?.Invoke();
		}

		private static void LanguageLoadStrings(Action<Language> orig, Language self)
		{
			orig(self);
			self.SetStringByToken("WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME02_NAME", "B4NSH33");
			self.SetStringByToken("WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME02_GENERIC_NAME", "B4NSH33");
			self.SetStringByToken("WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME03_NAME", "B4NSH33");
			self.SetStringByToken("WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME", "Anastasia Winters (Alt)");
		}

		private static void BodyCatalogInit()
		{
			BeforeBodyCatalogInit();
			AddDTGunnerDroneBodySnowtimeSkinsVRCSnowtime02Skin();
			AddDrone1BodySnowtimeSkinsVRCSnowtime02_genericSkin();
			AddMissileDroneBodySnowtimeSkinsVRCSnowtime03Skin();
			AddDroneTechBodySnowtimeSkinsVRCSnowtime01Skin();
			AfterBodyCatalogInit();
		}

		private static void DTGunnerDroneBodySnowtimeSkinsVRCSnowtime02SkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			SnowtimeSkinsPlugin.DTGunnerDroneBodySnowtimeSkinsVRCSnowtime02SkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddDTGunnerDroneBodySnowtimeSkinsVRCSnowtime02Skin()
		{
			string text = "DTGunnerDroneBody";
			string text2 = "SnowtimeSkinsVRCSnowtime02";
			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 val2 = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<ModelSkinController>() : null);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component"));
					return;
				}
				Renderer[] renderers = gameObject.GetComponentsInChildren<Renderer>(true);
				gameObject.GetComponentsInChildren<Light>(true);
				SkinDef skin = ScriptableObject.CreateInstance<SkinDef>();
				SkinDefParams skinParams = ScriptableObject.CreateInstance<SkinDefParams>();
				skin.skinDefParams = skinParams;
				TryCatchThrow("Icon", delegate
				{
					skin.icon = assetBundle.LoadAsset<Sprite>("Assets/snowtime/halo/hunkevolved/Icons/HaloCESpartan_SnowtimeIcon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME02_NAME";
				skin.rootObject = gameObject;
				TryCatchThrow("Base Skins", delegate
				{
					skin.baseSkins = Array.Empty<SkinDef>();
				});
				TryCatchThrow("Unlockable Name", delegate
				{
					skin.unlockableDef = null;
				});
				TryCatchThrow("Game Object Activations", delegate
				{
					//IL_0010: 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_0093: Unknown result type (might be due to invalid IL or missing references)
					//IL_0098: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
					//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
					//IL_012f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0130: Unknown result type (might be due to invalid IL or missing references)
					skinParams.gameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[2]
					{
						new GameObjectActivation
						{
							gameObject = ((Component)ThrowIfNull<Renderer>(0, "There is no renderer with the name \"Drone1Mesh\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Drone1Mesh")))).gameObject,
							shouldActivate = false,
							spawnPrefabOnModelObject = true,
							localPosition = new Vector3(0.5f, -1.3f, -4f),
							localRotation = new Vector3(0f, 0f, 20f),
							localScale = new Vector3(1f, 1f, 1f),
							prefab = assetBundle.LoadAsset<GameObject>("Assets/snowtime/halo/hunkevolved/prefab/banshee_fx_ce.prefab")
						},
						new GameObjectActivation
						{
							gameObject = ((Component)ThrowIfNull<Renderer>(1, "There is no renderer with the name \"Drone1BladeActive\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Drone1BladeActive")))).gameObject,
							shouldActivate = false,
							spawnPrefabOnModelObject = false
						}
					};
				});
				TryCatchThrow("Renderer Infos", delegate
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_002f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
					skinParams.rendererInfos = (RendererInfo[])(object)new RendererInfo[1]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/snowtime/templatematerial/banshee/banshee.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)2,
							ignoreOverlays = false,
							renderer = ThrowIfNull<Renderer>(0, "There is no renderer with the name \"Drone1Mesh\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Drone1Mesh")))
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0068: Unknown result type (might be due to invalid IL or missing references)
					//IL_0069: Unknown result type (might be due to invalid IL or missing references)
					skinParams.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\SnowtimeSkins\\Meshes\\unnamed base superhigh.mesh"),
							renderer = ThrowIfNull<Renderer>(0, "There is no renderer with the name \"Drone1Mesh\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Drone1Mesh")))
						}
					};
				});
				TryCatchThrow("Light Infos", delegate
				{
					skinParams.lightReplacements = (LightInfo[])(object)new LightInfo[0];
				});
				TryCatchThrow("Minion Skin Replacements", delegate
				{
					skinParams.minionSkinReplacements = Array.Empty<MinionSkinReplacement>();
				});
				TryCatchThrow("Projectile Ghost Replacements", delegate
				{
					skinParams.projectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
				});
				Array.Resize(ref val2.skins, val2.skins.Length + 1);
				val2.skins[val2.skins.Length - 1] = skin;
				DTGunnerDroneBodySnowtimeSkinsVRCSnowtime02SkinAdded(skin, val);
			}
			catch (FieldException ex)
			{
				if (ex.InnerException is ElementException ex2)
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
					InstanceLogger.LogWarning((object)$"Field causing issue: {ex.Message}, element: {ex2.Index}");
					InstanceLogger.LogWarning((object)ex2.Message);
					InstanceLogger.LogError((object)ex.InnerException);
				}
				else
				{
					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 ex3)
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
				InstanceLogger.LogError((object)ex3);
			}
		}

		private static void AddDrone1BodySnowtimeSkinsVRCSnowtime02_genericSkin()
		{
			string text = "Drone1Body";
			string text2 = "SnowtimeSkinsVRCSnowtime02_generic";
			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 val2 = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<ModelSkinController>() : null);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component"));
					return;
				}
				Renderer[] renderers = gameObject.GetComponentsInChildren<Renderer>(true);
				gameObject.GetComponentsInChildren<Light>(true);
				SkinDef skin = ScriptableObject.CreateInstance<SkinDef>();
				SkinDefParams skinParams = ScriptableObject.CreateInstance<SkinDefParams>();
				skin.skinDefParams = skinParams;
				TryCatchThrow("Icon", delegate
				{
					skin.icon = assetBundle.LoadAsset<Sprite>("Assets/snowtime/halo/hunkevolved/Icons/HaloCESpartan_SnowtimeIcon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME02_GENERIC_NAME";
				skin.rootObject = gameObject;
				TryCatchThrow("Base Skins", delegate
				{
					skin.baseSkins = Array.Empty<SkinDef>();
				});
				TryCatchThrow("Unlockable Name", delegate
				{
					skin.unlockableDef = null;
				});
				TryCatchThrow("Game Object Activations", delegate
				{
					//IL_0010: 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_0093: Unknown result type (might be due to invalid IL or missing references)
					//IL_0098: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
					//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
					//IL_012f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0130: Unknown result type (might be due to invalid IL or missing references)
					skinParams.gameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[2]
					{
						new GameObjectActivation
						{
							gameObject = ((Component)ThrowIfNull<Renderer>(0, "There is no renderer with the name \"Drone1Mesh\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Drone1Mesh")))).gameObject,
							shouldActivate = false,
							spawnPrefabOnModelObject = true,
							localPosition = new Vector3(0.5f, -1.3f, -4f),
							localRotation = new Vector3(0f, 0f, 20f),
							localScale = new Vector3(1f, 1f, 1f),
							prefab = assetBundle.LoadAsset<GameObject>("Assets/snowtime/halo/hunkevolved/prefab/banshee_fx_h2.prefab")
						},
						new GameObjectActivation
						{
							gameObject = ((Component)ThrowIfNull<Renderer>(1, "There is no renderer with the name \"Drone1BladeActive\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Drone1BladeActive")))).gameObject,
							shouldActivate = false,
							spawnPrefabOnModelObject = false
						}
					};
				});
				TryCatchThrow("Renderer Infos", delegate
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_002f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
					skinParams.rendererInfos = (RendererInfo[])(object)new RendererInfo[1]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/snowtime/templatematerial/banshee/banshee_heretic.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)2,
							ignoreOverlays = false,
							renderer = ThrowIfNull<Renderer>(0, "There is no renderer with the name \"Drone1Mesh\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Drone1Mesh")))
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0068: Unknown result type (might be due to invalid IL or missing references)
					//IL_0069: Unknown result type (might be due to invalid IL or missing references)
					skinParams.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\SnowtimeSkins\\Meshes\\unnamed base superhigh.mesh"),
							renderer = ThrowIfNull<Renderer>(0, "There is no renderer with the name \"Drone1Mesh\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Drone1Mesh")))
						}
					};
				});
				TryCatchThrow("Light Infos", delegate
				{
					skinParams.lightReplacements = (LightInfo[])(object)new LightInfo[0];
				});
				TryCatchThrow("Minion Skin Replacements", delegate
				{
					skinParams.minionSkinReplacements = Array.Empty<MinionSkinReplacement>();
				});
				TryCatchThrow("Projectile Ghost Replacements", delegate
				{
					skinParams.projectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
				});
				Array.Resize(ref val2.skins, val2.skins.Length + 1);
				val2.skins[val2.skins.Length - 1] = skin;
			}
			catch (FieldException ex)
			{
				if (ex.InnerException is ElementException ex2)
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
					InstanceLogger.LogWarning((object)$"Field causing issue: {ex.Message}, element: {ex2.Index}");
					InstanceLogger.LogWarning((object)ex2.Message);
					InstanceLogger.LogError((object)ex.InnerException);
				}
				else
				{
					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 ex3)
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
				InstanceLogger.LogError((object)ex3);
			}
		}

		private static void AddMissileDroneBodySnowtimeSkinsVRCSnowtime03Skin()
		{
			string text = "MissileDroneBody";
			string text2 = "SnowtimeSkinsVRCSnowtime03";
			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 val2 = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<ModelSkinController>() : null);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component"));
					return;
				}
				Renderer[] renderers = gameObject.GetComponentsInChildren<Renderer>(true);
				gameObject.GetComponentsInChildren<Light>(true);
				SkinDef skin = ScriptableObject.CreateInstance<SkinDef>();
				SkinDefParams skinParams = ScriptableObject.CreateInstance<SkinDefParams>();
				skin.skinDefParams = skinParams;
				TryCatchThrow("Icon", delegate
				{
					skin.icon = assetBundle.LoadAsset<Sprite>("Assets/snowtime/halo/hunkevolved/Icons/HaloCESpartan_SnowtimeIcon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME03_NAME";
				skin.rootObject = gameObject;
				TryCatchThrow("Base Skins", delegate
				{
					skin.baseSkins = Array.Empty<SkinDef>();
				});
				TryCatchThrow("Unlockable Name", delegate
				{
					skin.unlockableDef = null;
				});
				TryCatchThrow("Game Object Activations", delegate
				{
					//IL_0010: 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_0068: Unknown result type (might be due to invalid IL or missing references)
					//IL_0071: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
					//IL_0129: Unknown result type (might be due to invalid IL or missing references)
					//IL_012a: Unknown result type (might be due to invalid IL or missing references)
					skinParams.gameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[3]
					{
						new GameObjectActivation
						{
							gameObject = ((Component)ThrowIfNull<Renderer>(0, "There is no renderer with the name \"MissileDroneBladeMesh\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "MissileDroneBladeMesh")))).gameObject,
							shouldActivate = false,
							spawnPrefabOnModelObject = false
						},
						new GameObjectActivation
						{
							gameObject = ((Component)ThrowIfNull<Renderer>(1, "There is no renderer with the name \"Blades\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Blades")))).gameObject,
							shouldActivate = false,
							spawnPrefabOnModelObject = false
						},
						new GameObjectActivation
						{
							gameObject = ((Component)ThrowIfNull<Renderer>(2, "There is no renderer with the name \"Blades2\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Blades2")))).gameObject,
							shouldActivate = false,
							spawnPrefabOnModelObject = false
						}
					};
				});
				TryCatchThrow("Renderer Infos", delegate
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_002f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
					skinParams.rendererInfos = (RendererInfo[])(object)new RendererInfo[1]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/snowtime/templatematerial/hornet/hornet.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)2,
							ignoreOverlays = false,
							renderer = ThrowIfNull<Renderer>(0, "There is no renderer with the name \"MissileDroneMesh\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "MissileDroneMesh")))
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0068: Unknown result type (might be due to invalid IL or missing references)
					//IL_0069: Unknown result type (might be due to invalid IL or missing references)
					skinParams.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\SnowtimeSkins\\Meshes\\hornet.mesh"),
							renderer = ThrowIfNull<Renderer>(0, "There is no renderer with the name \"MissileDroneMesh\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "MissileDroneMesh")))
						}
					};
				});
				TryCatchThrow("Light Infos", delegate
				{
					skinParams.lightReplacements = (LightInfo[])(object)new LightInfo[0];
				});
				TryCatchThrow("Minion Skin Replacements", delegate
				{
					skinParams.minionSkinReplacements = Array.Empty<MinionSkinReplacement>();
				});
				TryCatchThrow("Projectile Ghost Replacements", delegate
				{
					skinParams.projectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
				});
				Array.Resize(ref val2.skins, val2.skins.Length + 1);
				val2.skins[val2.skins.Length - 1] = skin;
			}
			catch (FieldException ex)
			{
				if (ex.InnerException is ElementException ex2)
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
					InstanceLogger.LogWarning((object)$"Field causing issue: {ex.Message}, element: {ex2.Index}");
					InstanceLogger.LogWarning((object)ex2.Message);
					InstanceLogger.LogError((object)ex.InnerException);
				}
				else
				{
					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 ex3)
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
				InstanceLogger.LogError((object)ex3);
			}
		}

		private static void DroneTechBodySnowtimeSkinsVRCSnowtime01SkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			SnowtimeSkinsPlugin.DroneTechBodySnowtimeSkinsVRCSnowtime01SkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddDroneTechBodySnowtimeSkinsVRCSnowtime01Skin()
		{
			string text = "DroneTechBody";
			string text2 = "SnowtimeSkinsVRCSnowtime01";
			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 val2 = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<ModelSkinController>() : null);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component"));
					return;
				}
				Renderer[] renderers = gameObject.GetComponentsInChildren<Renderer>(true);
				gameObject.GetComponentsInChildren<Light>(true);
				SkinDef skin = ScriptableObject.CreateInstance<SkinDef>();
				SkinDefParams skinParams = ScriptableObject.CreateInstance<SkinDefParams>();
				skin.skinDefParams = skinParams;
				TryCatchThrow("Icon", delegate
				{
					skin.icon = assetBundle.LoadAsset<Sprite>("Assets/snowtime/halo/hunkevolved/Icons/HaloCESpartan_SnowtimeIcon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "WINTERWONDERLAND_SKIN_SNOWTIMESKINSVRCSNOWTIME01_NAME";
				skin.rootObject = gameObject;
				TryCatchThrow("Base Skins", delegate
				{
					skin.baseSkins = Array.Empty<SkinDef>();
				});
				TryCatchThrow("Unlockable Name", delegate
				{
					skin.unlockableDef = null;
				});
				TryCatchThrow("Game Object Activations", delegate
				{
					//IL_0010: 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_0068: Unknown result type (might be due to invalid IL or missing references)
					skinParams.gameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[1]
					{
						new GameObjectActivation
						{
							gameObject = ((Component)ThrowIfNull<Renderer>(0, "There is no renderer with the name \"Operator_Glow_04\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Operator_Glow_04")))).gameObject,
							shouldActivate = false,
							spawnPrefabOnModelObject = false
						}
					};
				});
				TryCatchThrow("Renderer Infos", delegate
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_002f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
					//IL_0082: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
					//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
					//IL_0113: Unknown result type (might be due to invalid IL or missing references)
					//IL_015c: Unknown result type (might be due to invalid IL or missing references)
					//IL_015d: 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_0185: Unknown result type (might be due to invalid IL or missing references)
					//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
					//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
					//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
					//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
					//IL_0240: 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_024a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0269: Unknown result type (might be due to invalid IL or missing references)
					//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
					//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
					skinParams.rendererInfos = (RendererInfo[])(object)new RendererInfo[6]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/snowtime/templatematerial/dronetechthing.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)2,
							ignoreOverlays = true,
							renderer = ThrowIfNull<Renderer>(0, "There is no renderer with the name \"DroneTech_Body\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "DroneTech_Body")))
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/DOLOSart/1.Milltina/Material/Milltina_Body_Poi.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)2,
							ignoreOverlays = true,
							renderer = ThrowIfNull<Renderer>(1, "There is no renderer with the name \"DroneTech_Gun\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "DroneTech_Gun")))
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/snowtime/Milltina_Eyes.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)2,
							ignoreOverlays = true,
							renderer = ThrowIfNull<Renderer>(2, "There is no renderer with the name \"Operator_Glow_01\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Operator_Glow_01")))
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Vellie/Urban Grace/MaterialPack/Top_Pants_Belt/Basics/Blue_Black.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)2,
							ignoreOverlays = true,
							renderer = ThrowIfNull<Renderer>(3, "There is no renderer with the name \"Operator_Glow_02\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Operator_Glow_02")))
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Vellie/Urban Grace/MaterialPack/Top_Pants_Belt/Basics/HaloMetallic.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)2,
							ignoreOverlays = true,
							renderer = ThrowIfNull<Renderer>(4, "There is no renderer with the name \"Operator_Glow_03\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Operator_Glow_03")))
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Vellie/Urban Grace/MaterialPack/Top_Pants_Belt/Basics/HaloMetallic.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)2,
							ignoreOverlays = true,
							renderer = ThrowIfNull<Renderer>(5, "There is no renderer with the name \"Operator_Glow_04\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Operator_Glow_04")))
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0068: Unknown result type (might be due to invalid IL or missing references)
					//IL_0069: Unknown result type (might be due to invalid IL or missing references)
					//IL_0072: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
					//IL_012c: Unknown result type (might be due to invalid IL or missing references)
					//IL_012d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0136: Unknown result type (might be due to invalid IL or missing references)
					//IL_018e: Unknown result type (might be due to invalid IL or missing references)
					//IL_018f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0198: Unknown result type (might be due to invalid IL or missing references)
					//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
					//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
					skinParams.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[5]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\SnowtimeSkins\\Meshes\\_dronetech.mesh"),
							renderer = ThrowIfNull<Renderer>(0, "There is no renderer with the name \"DroneTech_Body\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "DroneTech_Body")))
						},
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\SnowtimeSkins\\Meshes\\_face.mesh"),
							renderer = ThrowIfNull<Renderer>(1, "There is no renderer with the name \"DroneTech_Gun\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "DroneTech_Gun")))
						},
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\SnowtimeSkins\\Meshes\\_eyes.mesh"),
							renderer = ThrowIfNull<Renderer>(2, "There is no renderer with the name \"Operator_Glow_01\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Operator_Glow_01")))
						},
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\SnowtimeSkins\\Meshes\\_outfitfix.mesh"),
							renderer = ThrowIfNull<Renderer>(3, "There is no renderer with the name \"Operator_Glow_02\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Operator_Glow_02")))
						},
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\SnowtimeSkins\\Meshes\\_metalfix.mesh"),
							renderer = ThrowIfNull<Renderer>(4, "There is no renderer with the name \"Operator_Glow_03\"", ((IEnumerable<Renderer>)renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => ((Object)r).name == "Operator_Glow_03")))
						}
					};
				});
				TryCatchThrow("Light Infos", delegate
				{
					skinParams.lightReplacements = (LightInfo[])(object)new LightInfo[0];
				});
				TryCatchThrow("Minion Skin Replacements", delegate
				{
					//IL_0010: 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_0040: 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_0079: Unknown result type (might be due to invalid IL or missing references)
					//IL_0082: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
					//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
					//IL_011e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0124: Unknown result type (might be due to invalid IL or missing references)
					//IL_015c: Unknown result type (might be due to invalid IL or missing references)
					//IL_015d: Unknown result type (might be due to invalid IL or missing references)
					skinParams.minionSkinReplacements = (MinionSkinReplacement[])(object)new MinionSkinReplacement[3]
					{
						new MinionSkinReplacement
						{
							minionBodyPrefab = BodyCatalog.FindBodyPrefab("DTGunnerDroneBody"),
							minionSkin = ThrowIfNull<SkinDef>(0, "There is no skin with the name \"SnowtimeSkinsVRCSnowtime02\" for body \"DTGunnerDroneBody\"", ((IEnumerable<SkinDef>)SkinCatalog.FindSkinsForBody(ThrowIfEquals<BodyIndex>(0, "Body \"DTGunnerDroneBody\" doesn't exist", BodyCatalog.FindBodyIndex("DTGunnerDroneBody"), (BodyIndex)(-1)))).FirstOrDefault((Func<SkinDef, bool>)((SkinDef s) => ((Object)s).name == "SnowtimeSkinsVRCSnowtime02")))
						},
						new MinionSkinReplacement
						{
							minionBodyPrefab = BodyCatalog.FindBodyPrefab("Drone1Body"),
							minionSkin = ThrowIfNull<SkinDef>(1, "There is no skin with the name \"SnowtimeSkinsVRCSnowtime02_generic\" for body \"Drone1Body\"", ((IEnumerable<SkinDef>)SkinCatalog.FindSkinsForBody(ThrowIfEquals<BodyIndex>(1, "Body \"Drone1Body\" doesn't exist", BodyCatalog.FindBodyIndex("Drone1Body"), (BodyIndex)(-1)))).FirstOrDefault((Func<SkinDef, bool>)((SkinDef s) => ((Object)s).name == "SnowtimeSkinsVRCSnowtime02_generic")))
						},
						new MinionSkinReplacement
						{
							minionBodyPrefab = BodyCatalog.FindBodyPrefab("MissileDroneBody"),
							minionSkin = ThrowIfNull<SkinDef>(2, "There is no skin with the name \"SnowtimeSkinsVRCSnowtime03\" for body \"MissileDroneBody\"", ((IEnumerable<SkinDef>)SkinCatalog.FindSkinsForBody(ThrowIfEquals<BodyIndex>(2, "Body \"MissileDroneBody\" doesn't exist", BodyCatalog.FindBodyIndex("MissileDroneBody"), (BodyIndex)(-1)))).FirstOrDefault((Func<SkinDef, bool>)((SkinDef s) => ((Object)s).name == "SnowtimeSkinsVRCSnowtime03")))
						}
					};
				});
				TryCatchThrow("Projectile Ghost Replacements", delegate
				{
					skinParams.projectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
				});
				Array.Resize(ref val2.skins, val2.skins.Length + 1);
				val2.skins[val2.skins.Length - 1] = skin;
				DroneTechBodySnowtimeSkinsVRCSnowtime01SkinAdded(skin, val);
			}
			catch (FieldException ex)
			{
				if (ex.InnerException is ElementException ex2)
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
					InstanceLogger.LogWarning((object)$"Field causing issue: {ex.Message}, element: {ex2.Index}");
					InstanceLogger.LogWarning((object)ex2.Message);
					InstanceLogger.LogError((object)ex.InnerException);
				}
				else
				{
					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 ex3)
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
				InstanceLogger.LogError((object)ex3);
			}
		}

		private static T ThrowIfEquals<T>(int index, string message, T value, T expected) where T : Enum
		{
			if (value.Equals(expected))
			{
				throw new ElementException(index, message);
			}
			return value;
		}

		private static T ThrowIfOutOfBounds<T>(int index, string message, T[] array, int elementIndex) where T : class
		{
			if (array == null || array.Length <= elementIndex)
			{
				throw new ElementException(index, message);
			}
			return array[elementIndex];
		}

		private static T ThrowIfNull<T>(int index, string message, T value) where T : class
		{
			if (value == null)
			{
				throw new ElementException(index, message);
			}
			return value;
		}

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

		private static void TryAddComponent<T>(GameObject obj) where T : Component
		{
			if (Object.op_Implicit((Object)(object)obj) && !Object.op_Implicit((Object)(object)obj.GetComponent<T>()))
			{
				obj.AddComponent<T>();
			}
		}
	}
}
namespace RuneFoxMods
{
	internal class Utils
	{
		public static void PrintBodyCatalog()
		{
			Debug.Log((object)"\nBodyCatalog");
			foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs)
			{
				Debug.Log((object)((Object)allBodyPrefab).name);
			}
			Debug.Log((object)"\n");
		}

		public static void ReadChildren(GameObject parent, int tabs, bool includecomponents = true)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			for (int i = 0; i < tabs; i++)
			{
				text += "  ";
			}
			for (int j = 0; j < parent.transform.childCount; j++)
			{
				Transform child = parent.transform.GetChild(j);
				if ((Object)(object)child == (Object)null)
				{
					break;
				}
				string text2 = ((Component)child).gameObject.activeInHierarchy.ToString();
				string[] obj = new string[6]
				{
					text,
					((Object)child).name,
					" ",
					text2,
					" ",
					null
				};
				Vector3 position = ((Component)child).transform.position;
				obj[5] = ((object)(Vector3)(ref position)).ToString();
				Debug.Log((object)string.Concat(obj));
				if (includecomponents)
				{
					ReadComponents(((Component)child).gameObject, tabs + 1);
					Debug.Log((object)"");
				}
				ReadChildren(((Component)child).gameObject, tabs + 1, includecomponents);
			}
		}

		public static void readheiarchy(GameObject parent, bool includeComponents = true)
		{
			Debug.Log((object)((Object)parent).name);
			if (includeComponents)
			{
				ReadComponents(parent, 1);
				Debug.Log((object)"");
			}
			ReadChildren(parent, 1, includeComponents);
		}

		public static void ReadComponents(GameObject obj, int tabs)
		{
			string text = "";
			for (int i = 0; i < tabs; i++)
			{
				text += "  ";
			}
			Component[] components = obj.GetComponents(typeof(Component));
			foreach (Component val in components)
			{
				string text2 = "";
				Debug.Log((object)(text + "Comp: " + ((object)val).GetType().ToString() + "  " + text2));
			}
		}

		public static void PrintAllPaths(GameObject parent)
		{
			Debug.Log((object)((Object)parent).name);
			PrintAllPathsInner(parent, ((Object)parent).name);
		}

		private static void PrintAllPathsInner(GameObject parent, string parent_string)
		{
			int childCount = parent.transform.childCount;
			for (int i = 0; i < childCount; i++)
			{
				Transform child = parent.transform.GetChild(i);
				if (!((Object)child).name.EndsWith("_end"))
				{
					string text = parent_string + "/" + ((Object)child).name;
					Debug.Log((object)("  " + ((Object)child).name + "\t\t" + text));
					PrintAllPathsInner(((Component)child).gameObject, text);
					continue;
				}
				break;
			}
		}

		public static void PrintDynamicBone(DynamicBone DB)
		{
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)("Root: " + (object)DB.m_Root));
			Debug.Log((object)("Damping: " + DB.m_Damping));
			Debug.Log((object)("Damping Dist: " + (object)DB.m_DampingDistrib));
			Debug.Log((object)("Elasticity: " + DB.m_Elasticity));
			Debug.Log((object)("Elasticity Dist: " + (object)DB.m_ElasticityDistrib));
			Debug.Log((object)("Stiffness: " + DB.m_Stiffness));
			Debug.Log((object)("Stiffness Dist: " + (object)DB.m_StiffnessDistrib));
			Debug.Log((object)("Inert: " + DB.m_Inert));
			Debug.Log((object)("Inert Dist: " + (object)DB.m_InertDistrib));
			Debug.Log((object)("Radius: " + DB.m_Radius));
			Debug.Log((object)("Radius Dist: " + (object)DB.m_RadiusDistrib));
			Debug.Log((object)("End Length: " + DB.m_EndLength));
			Vector3 val = DB.m_EndOffset;
			Debug.Log((object)("End Offset: " + ((object)(Vector3)(ref val)).ToString()));
			val = DB.m_Gravity;
			Debug.Log((object)("Gravity: " + ((object)(Vector3)(ref val)).ToString()));
			val = DB.m_Force;
			Debug.Log((object)("Force: " + ((object)(Vector3)(ref val)).ToString()));
			Debug.Log((object)("FreezeAxis: " + ((object)(FreezeAxis)(ref DB.m_FreezeAxis)).ToString()));
			Debug.Log((object)("Colliders: " + DB.m_Colliders.Count));
			foreach (DynamicBoneCollider collider in DB.m_Colliders)
			{
				Debug.Log((object)("\t Parent: " + ((Object)((Component)collider).transform).name));
				Debug.Log((object)("\t Direction: " + ((object)(Direction)(ref collider.m_Direction)).ToString()));
				val = collider.m_Center;
				Debug.Log((object)("\t Center " + ((object)(Vector3)(ref val)).ToString()));
				Debug.Log((object)("\t Bound " + ((object)(Bound)(ref collider.m_Bound)).ToString()));
				Debug.Log((object)("\t Radius " + collider.m_Radius));
				Debug.Log((object)("\t Height " + collider.m_Height));
			}
			Debug.Log((object)("Exclusions: " + DB.m_Exclusions.Count));
			foreach (Transform exclusion in DB.m_Exclusions)
			{
				Debug.Log((object)("\t Transform: " + ((Object)exclusion).name));
			}
		}

		public static ChildLocator GetChildLocator(GameObject body)
		{
			ChildLocator val = null;
			Transform child = body.transform.GetChild(0);
			if (Object.op_Implicit((Object)(object)child))
			{
				Transform child2 = child.GetChild(0);
				if (Object.op_Implicit((Object)(object)child2))
				{
					val = ((Component)child2).GetComponent<ChildLocator>();
					if (Object.op_Implicit((Object)(object)val))
					{
						Debug.Log((object)"Locator Found");
					}
				}
			}
			return val;
		}

		public static Transform FindChildInTree(Transform Root, string name)
		{
			Queue<Transform> queue = new Queue<Transform>();
			queue.Enqueue(Root);
			while (queue.Count != 0)
			{
				Transform val = queue.Dequeue();
				if (((Object)val).name == name)
				{
					return val;
				}
				for (int i = 0; i < val.childCount; i++)
				{
					Transform child = val.GetChild(i);
					queue.Enqueue(child);
				}
			}
			return null;
		}

		public static string RemoveCloneNaming(string str)
		{
			return str.Remove(str.Length - 7);
		}
	}
}
namespace RuneFoxMods.DynamicSkins
{
	public static class DynamicSkinHelpers
	{
		public static SkinnedMeshRenderer[] GetBaseSkinRenderers(GameObject modelObject)
		{
			SkinnedMeshRenderer[] componentsInChildren = modelObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>();
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val in array)
			{
				if ((Object)(object)((Component)val).transform.parent == (Object)(object)modelObject.transform)
				{
					list.Add(val);
				}
			}
			return list.ToArray();
		}

		public static Transform[] BoneArrayBuilder(Transform NewBoneRoot)
		{
			List<Transform> list = new List<Transform>();
			BoneArrayBuilderHelper(NewBoneRoot, list);
			return list.ToArray();
		}

		public static void BoneArrayBuilderHelper(Transform parent, List<Transform> list)
		{
			if (!((Object)parent).name.EndsWith("_end"))
			{
				list.Add(parent);
			}
			for (int i = 0; i < parent.childCount; i++)
			{
				BoneArrayBuilderHelper(parent.GetChild(i), list);
			}
		}

		public static Transform GetArmature(GameObject obj)
		{
			return GetArmatureHelper(obj);
		}

		public static Transform GetArmatureHelper(GameObject obj)
		{
			if (((Object)obj).name.ToLower().Contains("armature"))
			{
				return obj.transform;
			}
			for (int i = 0; i < obj.transform.childCount; i++)
			{
				Transform armatureHelper = GetArmatureHelper(((Component)obj.transform.GetChild(i)).gameObject);
				if (Object.op_Implicit((Object)(object)armatureHelper))
				{
					return armatureHelper;
				}
			}
			return null;
		}

		public static Transform GetTopParent(Transform obj)
		{
			Transform val = obj;
			while ((Object)(object)val.parent != (Object)null)
			{
				val = val.parent;
			}
			return val;
		}

		public static string GetPrevBoneInList(Transform targetBone, SkinnedMeshRenderer meshRenderer)
		{
			Transform[] bones = meshRenderer.bones;
			for (int i = 0; i <= bones.Length - 1; i++)
			{
				if (((Object)bones[i + 1]).name == ((Object)targetBone).name)
				{
					return ((Object)bones[i]).name;
				}
			}
			return null;
		}

		public static int GetBoneIndexInList(Transform targetBone, SkinnedMeshRenderer meshRenderer)
		{
			Transform[] bones = meshRenderer.bones;
			for (int i = 0; i <= bones.Length; i++)
			{
				if (((Object)bones[i]).name == ((Object)targetBone).name)
				{
					return i;
				}
			}
			return -1;
		}

		public static int GetPrevBoneIndexInList(Transform targetBone, SkinnedMeshRenderer meshRenderer)
		{
			Transform[] bones = meshRenderer.bones;
			for (int i = 0; i <= bones.Length - 1; i++)
			{
				if (((Object)bones[i + 1]).name == ((Object)targetBone).name)
				{
					return i;
				}
			}
			return -1;
		}
	}
	internal class DynamicSkinManager
	{
		internal Dictionary<string, SkinDef> SkinDefs = new Dictionary<string, SkinDef>();

		private GameObject LastModelObject;

		internal Dictionary<string, SortedList<int, Modification>> ModificationList = new Dictionary<string, SortedList<int, Modification>>();

		private Dictionary<GameObject, AppliedModifications> ModifiedObjects = new Dictionary<GameObject, AppliedModifications>();

		internal ManualLogSource InstanceLogger;

		internal void AddModification(string skinNameToken, int boneIndex, Modification modification)
		{
			if (!ModificationList.TryGetValue(skinNameToken, out var value))
			{
				value = new SortedList<int, Modification>();
				ModificationList.Add(skinNameToken, value);
			}
			value.Add(boneIndex, modification);
		}

		internal void AddSkinDef(SkinDef skinDef)
		{
			SkinDefs.Add(skinDef.nameToken, skinDef);
		}

		internal void SkinDefApply(Action<SkinDef, GameObject> orig, SkinDef self, GameObject modelObject)
		{
			orig(self, modelObject);
			RemoveInvalidModelObjects();
			ModifiedObjects.TryGetValue(modelObject, out var value);
			try
			{
				if (!SkinDefs.TryGetValue(self.nameToken, out var _))
				{
					if (value != null)
					{
						ClearSkinModifications(LastModelObject, value);
					}
				}
				else if (value == null)
				{
					AppliedModifications appliedModifications = new AppliedModifications();
					ModifiedObjects.Add(modelObject, appliedModifications);
					ApplySkinModifications(self, modelObject, appliedModifications);
				}
			}
			catch (Exception ex)
			{
				InstanceLogger.LogWarning((object)"An error occured while adding accessories to a skin");
				InstanceLogger.LogError((object)ex);
			}
		}

		private void RemoveInvalidModelObjects()
		{
			foreach (GameObject item in ModifiedObjects.Keys.Where((GameObject el) => !Object.op_Implicit((Object)(object)el)).ToList())
			{
				ModifiedObjects.Remove(item);
			}
		}

		private void ClearSkinModifications(GameObject modelObject, AppliedModifications modifications)
		{
			while (modifications.BaseModelModifications.Count != 0)
			{
				Modification modification = modifications.BaseModelModifications.Pop();
				clearModification(modification, modelObject, modifications);
			}
			while (modifications.OtherModifications.Count != 0)
			{
				clearModification(modifications.OtherModifications[0], modelObject, modifications);
			}
			ModifiedObjects.Remove(modelObject);
		}

		private void ApplySkinModifications(SkinDef skindef, GameObject modelObject, AppliedModifications modifications)
		{
			CharacterModel component = modelObject.GetComponent<CharacterModel>();
			LastModelObject = modelObject;
			if (!ModificationList.TryGetValue(skindef.nameToken, out var value))
			{
				return;
			}
			foreach (KeyValuePair<int, Modification> item in value)
			{
				ApplyModification(modelObject, component, item.Value, modifications);
			}
		}

		private static void ApplyModification(GameObject modelObject, CharacterModel characterModel, Modification modification, AppliedModifications modifications)
		{
			_ = modification.bodyname;
			string parentname = modification.parentname;
			Transform val = Utils.FindChildInTree(modelObject.transform, parentname);
			GameObject val2;
			if (modification.affectsbasemodel)
			{
				val2 = Object.Instantiate<GameObject>(modification.prefab, val, false);
				((Object)val2).name = Utils.RemoveCloneNaming(((Object)val2).name);
				modification.instance = val2;
				modification.inst_armature = val2;
				ModificationApplyBones(modelObject, modification, modifications);
			}
			else
			{
				val2 = Object.Instantiate<GameObject>(modification.prefab, modelObject.transform, false);
				((Object)val2).name = Utils.RemoveCloneNaming(((Object)val2).name);
				modification.instance = val2;
				Transform armature = DynamicSkinHelpers.GetArmature(val2);
				((Component)armature).transform.SetParent(val, false);
				modification.inst_armature = ((Component)armature).gameObject;
			}
			modification.instance = val2;
			if (modification.dynamicBoneData != null)
			{
				ModificationApplyDynamicBones(modelObject, modification);
			}
			ModificationAddRenderers(val2, characterModel);
			modifications.OtherModifications.Add(modification);
		}

		private static void ModificationApplyBones(GameObject modelObject, Modification modification, AppliedModifications modifications)
		{
			SkinnedMeshRenderer[] baseSkinRenderers = DynamicSkinHelpers.GetBaseSkinRenderers(modelObject);
			List<Transform> list = baseSkinRenderers[0].bones.ToList();
			Transform[] array = DynamicSkinHelpers.BoneArrayBuilder(modification.instance.transform);
			list.InsertRange(modification.boneIndex, array);
			modification.boneCount = array.Length;
			SkinnedMeshRenderer[] array2 = baseSkinRenderers;
			for (int i = 0; i < array2.Length; i++)
			{
				array2[i].bones = list.ToArray();
			}
			modifications.BaseModelModifications.Push(modification);
		}

		private static void ModificationApplyDynamicBones(GameObject modelObject, Modification modification)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			DynamicBone val = (modification.inst_dynamicBone = modification.instance.AddComponent<DynamicBone>());
			List<DynamicBoneCollider> list = new List<DynamicBoneCollider>();
			foreach (DynamicBoneColliderData collider in modification.dynamicBoneData.m_Colliders)
			{
				DynamicBoneCollider val2 = ((Component)Utils.FindChildInTree(modelObject.transform, collider.m_parent_name)).gameObject.AddComponent<DynamicBoneCollider>();
				val2.m_Direction = collider.m_Direction;
				val2.m_Center = collider.m_Center;
				val2.m_Bound = collider.m_Bound;
				val2.m_Radius = collider.m_Radius;
				val2.m_Height = collider.m_Height;
				list.Add(val2);
			}
			modification.inst_DB_colliders = list;
			Transform root = (val.m_Root = Utils.FindChildInTree(modification.inst_armature.transform, modification.dynamicBoneData.m_Root));
			val.m_Damping = modification.dynamicBoneData.m_Damping;
			val.m_DampingDistrib = modification.dynamicBoneData.m_DampingDistrib;
			val.m_Elasticity = modification.dynamicBoneData.m_Elasticity;
			val.m_ElasticityDistrib = modification.dynamicBoneData.m_ElasticityDistrib;
			val.m_Stiffness = modification.dynamicBoneData.m_Stiffness;
			val.m_StiffnessDistrib = modification.dynamicBoneData.m_StiffnessDistrib;
			val.m_Inert = modification.dynamicBoneData.m_Inert;
			val.m_InertDistrib = modification.dynamicBoneData.m_InertDistrib;
			val.m_Radius = modification.dynamicBoneData.m_Radius;
			val.m_RadiusDistrib = modification.dynamicBoneData.m_RadiusDistrib;
			val.m_EndLength = modification.dynamicBoneData.m_EndLength;
			val.m_EndOffset = modification.dynamicBoneData.m_EndOffset;
			val.m_Gravity = modification.dynamicBoneData.m_Gravity;
			val.m_Force = modification.dynamicBoneData.m_Force;
			val.m_Colliders = list;
			val.m_Exclusions = new List<Transform>();
			foreach (string exclusion in modification.dynamicBoneData.m_Exclusions)
			{
				Transform val3 = Utils.FindChildInTree(root, exclusion);
				if ((Object)(object)val3 != (Object)null)
				{
					val.m_Exclusions.Add(val3);
				}
				else
				{
					Debug.LogWarning((object)"Tried to exclude a transform that could not be found");
				}
			}
			val.m_FreezeAxis = modification.dynamicBoneData.m_FreezeAxis;
		}

		private static void ModificationAddRenderers(GameObject newPart, CharacterModel characterModel)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			SkinnedMeshRenderer[] componentsInChildren = newPart.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			Array.Resize(ref characterModel.baseRendererInfos, characterModel.baseRendererInfos.Length + componentsInChildren.Length);
			if (componentsInChildren.Length != 0)
			{
				int num = componentsInChildren.Length;
				SkinnedMeshRenderer[] array = componentsInChildren;
				foreach (SkinnedMeshRenderer val in array)
				{
					characterModel.baseRendererInfos[characterModel.baseRendererInfos.Length - num] = new RendererInfo
					{
						renderer = (Renderer)(object)componentsInChildren[^num],
						ignoreOverlays = false,
						defaultShadowCastingMode = (ShadowCastingMode)1,
						defaultMaterial = ((Renderer)val).sharedMaterial
					};
					num--;
				}
			}
		}

		private void clearModification(Modification modification, GameObject modelObject, AppliedModifications modifications)
		{
			if (modification.inst_DB_colliders != null)
			{
				foreach (DynamicBoneCollider inst_DB_collider in modification.inst_DB_colliders)
				{
					Object.Destroy((Object)(object)inst_DB_collider);
				}
			}
			if (modification.affectsbasemodel)
			{
				SkinnedMeshRenderer[] baseSkinRenderers = DynamicSkinHelpers.GetBaseSkinRenderers(modelObject);
				List<Transform> list = baseSkinRenderers[0].bones.ToList();
				list.RemoveRange(modification.boneIndex, modification.boneCount);
				SkinnedMeshRenderer[] array = baseSkinRenderers;
				for (int i = 0; i < array.Length; i++)
				{
					array[i].bones = list.ToArray();
				}
			}
			Object.Destroy((Object)(object)modifications.OtherModifications[0].inst_dynamicBone);
			Object.Destroy((Object)(object)modifications.OtherModifications[0].inst_armature);
			Object.Destroy((Object)(object)modifications.OtherModifications[0].instance);
			if (!modifications.OtherModifications.Remove(modification))
			{
				InstanceLogger.LogError((object)"Skin Modification was not removed");
			}
		}
	}
	internal class Modification
	{
		public string prefabpath;

		public string bodyname;

		public string parentname;

		public GameObject prefab;

		public bool affectsbasemodel;

		public DynamicBoneData dynamicBoneData;

		public string parentSkinToken;

		public int boneIndex;

		public int boneCount;

		public GameObject instance;

		public GameObject inst_armature;

		public DynamicBone inst_dynamicBone;

		public List<DynamicBoneCollider> inst_DB_colliders = new List<DynamicBoneCollider>();

		public Modification(string PrefabPath, string ParentName, string BodyName, string ParentSkinToken, int BoneIndex, bool AffectsBaseModel, AssetBundle assetBundle)
		{
			bodyname = BodyName;
			prefabpath = PrefabPath;
			parentname = ParentName;
			parentSkinToken = ParentSkinToken;
			affectsbasemodel = AffectsBaseModel;
			boneIndex = BoneIndex;
			prefab = assetBundle.LoadAsset<GameObject>(prefabpath);
			if ((Object)(object)prefab == (Object)null)
			{
				Debug.LogWarning((object)("Asset at " + PrefabPath + " was not loaded"));
			}
		}
	}
	internal class AppliedModifications
	{
		public Stack<Modification> BaseModelModifications = new Stack<Modification>();

		public List<Modification> OtherModifications = new List<Modification>();
	}
	internal class DynamicBoneData
	{
		public string m_Root;

		public float m_Damping;

		public AnimationCurve m_DampingDistrib;

		public float m_Elasticity;

		public AnimationCurve m_ElasticityDistrib;

		public float m_Stiffness;

		public AnimationCurve m_StiffnessDistrib;

		public float m_Inert;

		public AnimationCurve m_InertDistrib;

		public float m_Radius;

		public AnimationCurve m_RadiusDistrib;

		public float m_EndLength;

		public Vector3 m_EndOffset;

		public Vector3 m_Gravity;

		public Vector3 m_Force;

		public List<DynamicBoneColliderData> m_Colliders;

		public List<string> m_Exclusions;

		public FreezeAxis m_FreezeAxis;

		public DynamicBoneData(string root, float damping, AnimationCurve damping_dist, float elasticity, AnimationCurve elasticity_dist, float stiffness, AnimationCurve stiffness_dist, float inert, AnimationCurve inert_dist, float radius, AnimationCurve radius_dist, float end_length, Vector3 end_offset, Vector3 gravity, Vector3 force, List<DynamicBoneColliderData> colliders, List<string> exclusions, FreezeAxis freeze_axis)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			m_Root = root;
			m_Damping = damping;
			m_DampingDistrib = damping_dist;
			m_Elasticity = elasticity;
			m_ElasticityDistrib = elasticity_dist;
			m_Stiffness = stiffness;
			m_StiffnessDistrib = stiffness_dist;
			m_Inert = inert;
			m_InertDistrib = inert_dist;
			m_Radius = radius;
			m_RadiusDistrib = radius_dist;
			m_EndLength = end_length;
			m_EndOffset = end_offset;
			m_Gravity = gravity;
			m_Force = force;
			m_Colliders = colliders;
			m_Exclusions = exclusions;
			m_FreezeAxis = freeze_axis;
		}
	}
	internal class DynamicBoneColliderData
	{
		public string m_parent_name;

		public Direction m_Direction;

		public Vector3 m_Center;

		public Bound m_Bound;

		public float m_Radius;

		public float m_Height;

		public DynamicBoneColliderData(string parent_name, Direction direction, Vector3 Center, Bound bound, float radius, float heaight)
		{
			//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)
			m_parent_name = parent_name;
			m_Direction = direction;
			m_Center = Center;
			m_Bound = bound;
			m_Radius = radius;
			m_Height = heaight;
		}
	}
}

plugins/SnowtimeToybox.dll

Decompiled 13 hours ago
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.Bootstrap;
using BepInEx.Logging;
using EntityStates;
using EntityStates.SnowtimeToybox_FireHaloWeapon;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPaths.Version_1_39_0;
using ShaderSwapper;
using SnowtimeToybox;
using UnityEngine;
using UnityEngine.AddressableAssets;

[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("SnowtimeToybox")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f93a40505933251ade42c302b6e56c94395e6e5c")]
[assembly: AssemblyProduct("SnowtimeToybox")]
[assembly: AssemblyTitle("SnowtimeToybox")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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 SnowtimeToybox
{
	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);
		}
	}
	[BepInPlugin("SnowySnowtime.SnowtimeToyboxMod", "SnowtimeToyboxMod", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SnowtimeToyboxMod : BaseUnityPlugin
	{
		public const string Author = "SnowySnowtime";

		public const string Name = "SnowtimeToyboxMod";

		public const string Version = "1.0.0";

		public const string GUID = "SnowySnowtime.SnowtimeToyboxMod";

		public static SnowtimeToyboxMod instance;

		public static DifficultyDef SnowtimeLegendaryDiffDef;

		public static DifficultyIndex SnowtimeLegendaryDiffIndex;

		public static SkillDef SnowtimePlasmaRifleSkillDef;

		public static GameObject MuzzleFlashObject;

		public static GameObject TracerObject;

		public static GameObject HitObject;

		public static GameObject OrbObject;

		public static bool Legendary;

		public static string assetDirectory;

		public static AssetBundle _stdifficultyAssetBundle;

		public static AssetBundle _stcharacterAssetBundle;

		internal const string _stdifficultyAssetBundleName = "snowtimetoybox_difficulty";

		internal const string _stcharacterAssetBundleName = "snowtimetoybox_characters";

		public static bool riskierLoaded => ModLoaded("com.RiskOfBrainrot.RiskierRain");

		public static bool ModLoaded(string modGuid)
		{
			return !string.IsNullOrEmpty(modGuid) && Chainloader.PluginInfos.ContainsKey(modGuid);
		}

		public void Awake()
		{
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			Language.collectLanguageRootFolders += CollectLanguageRootFolders;
			Run.onRunStartGlobal += delegate(Run run)
			{
				//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)
				Legendary = false;
				if (run.selectedDifficulty == SnowtimeLegendaryDiffIndex)
				{
					Legendary = true;
					CharacterMaster.onStartGlobal += CharacterMaster_OnStartGlobal;
				}
			};
			Run.onRunDestroyGlobal += delegate
			{
				Legendary = false;
				CharacterMaster.onStartGlobal -= CharacterMaster_OnStartGlobal;
			};
		}

		private void Start()
		{
			instance = this;
			string path = (assetDirectory = Path.Combine(Path.GetDirectoryName(typeof(SnowtimeToyboxMod).Assembly.Location), "assetbundles"));
			Debug.Log((object)"Ran Start!");
			_stcharacterAssetBundle = AssetBundle.LoadFromFile(Path.Combine(path, "snowtimetoybox_characters"));
			((MonoBehaviour)this).StartCoroutine(ShaderSwapper.UpgradeStubbedShadersAsync(_stcharacterAssetBundle));
			_stdifficultyAssetBundle = AssetBundle.LoadFromFile(Path.Combine(path, "snowtimetoybox_difficulty"));
			Debug.Log((object)_stcharacterAssetBundle);
			Debug.Log((object)_stdifficultyAssetBundle);
			AddDifficulty();
			AddCustomSkills();
		}

		private void CharacterMaster_OnStartGlobal(CharacterMaster obj)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			if ((int)obj.teamIndex != 1)
			{
				if (Object.op_Implicit((Object)(object)obj.inventory))
				{
					obj.inventory.GiveItemPermanent(Items.AlienHead, 1);
				}
				if (Object.op_Implicit((Object)(object)obj.inventory))
				{
					obj.inventory.GiveItemPermanent(Items.BoostAttackSpeed, 3);
				}
				if (Object.op_Implicit((Object)(object)obj.inventory))
				{
					obj.inventory.GiveItemPermanent(Items.BoostHp, 4);
				}
				if (Object.op_Implicit((Object)(object)obj.inventory))
				{
					obj.inventory.GiveItemPermanent(Items.PersonalShield, 5);
				}
				if (Object.op_Implicit((Object)(object)obj.inventory))
				{
					obj.inventory.GiveItemPermanent(Items.BoostDamage, 10);
				}
				if (Object.op_Implicit((Object)(object)obj.inventory))
				{
					obj.inventory.GiveItemPermanent(Items.Knurl, 1);
				}
			}
		}

		public void AddDifficulty()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_004e: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			Log.Debug("SnowySnowtime.SnowtimeToyboxMod");
			Log.Debug("Adding SnowtimeToybox Custom Difficulty...");
			if (riskierLoaded)
			{
				Log.Debug("2R4R detected, updating name to LASO and its description to match new gimmicks.");
				SnowtimeLegendaryDiffDef = new DifficultyDef(3.5f, "SNOWTIME_LASO_NAME", "SNOWTIME_LEGENDARY_ICON", "SNOWTIME_LASO_DESC", Color32.op_Implicit(new Color32((byte)168, (byte)50, (byte)50, byte.MaxValue)), "stLeg", false);
			}
			else
			{
				Log.Debug("2R4R not detected, adding Legendary.");
				SnowtimeLegendaryDiffDef = new DifficultyDef(3.5f, "SNOWTIME_LEGENDARY_NAME", "SNOWTIME_LEGENDARY_ICON", "SNOWTIME_LEGENDARY_DESC", Color32.op_Implicit(new Color32((byte)100, (byte)170, byte.MaxValue, byte.MaxValue)), "stLeg", false);
			}
			SnowtimeLegendaryDiffDef.iconSprite = _stdifficultyAssetBundle.LoadAsset<Sprite>("Assets/SnowtimeMod/Assets/_difficulty/texSnowtimeLegendaryPLNK.png");
			SnowtimeLegendaryDiffDef.foundIconSprite = true;
			SnowtimeLegendaryDiffIndex = DifficultyAPI.AddDifficulty(SnowtimeLegendaryDiffDef);
		}

		public void AddEffectDef()
		{
			Log.Debug("SnowySnowtime.SnowtimeToyboxMod");
			Log.Debug("Adding SnowtimeToybox Custom EffectDefs...");
		}

		public void AddCustomSkills()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00d4: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			Log.Debug("SnowySnowtime.SnowtimeToyboxMod");
			Log.Debug("Adding SnowtimeToybox Custom Skills...");
			ContentAddition.AddEffect(FirePlasmaRifle.MuzzleFlashObject);
			ContentAddition.AddEffect(FirePlasmaRifle.TracerObject);
			ContentAddition.AddEffect(FirePlasmaRifle.HitObject);
			ContentAddition.AddEffect(FirePlasmaRifle.OrbObject);
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC3_Drone_Tech.DroneTechBody_prefab).WaitForCompletion();
			SkillLocator component = val.GetComponent<SkillLocator>();
			SkillFamily skillFamily = component.primary.skillFamily;
			SkillDef val2 = _stcharacterAssetBundle.LoadAsset<SkillDef>("Assets/SnowtimeMod/Assets/Characters/DroneTech/PlasmaRifle/entskilldefFirePlasmaRifle.asset");
			val2.activationState = new SerializableEntityStateType(typeof(FirePlasmaRifle));
			Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1);
			Variant[] variants = skillFamily.variants;
			int num = variants.Length - 1;
			Variant val3 = new Variant
			{
				skillDef = val2
			};
			((Variant)(ref val3)).viewableNode = new Node(val2.skillNameToken, false, (Node)null);
			variants[num] = val3;
			bool flag = default(bool);
			ContentAddition.AddEntityState(typeof(FirePlasmaRifle), ref flag);
			ContentAddition.AddSkillDef(val2);
		}

		public void CollectLanguageRootFolders(List<string> folders)
		{
			folders.Add(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Language"));
		}

		private void Destroy()
		{
			Language.collectLanguageRootFolders -= CollectLanguageRootFolders;
		}
	}
}
namespace EntityStates.SnowtimeToybox_FireHaloWeapon
{
	public class FirePlasmaRifle : GenericBulletBaseState
	{
		public class DamageOrb : GenericDamageOrb
		{
			public GameObject effectPrefab;

			public override GameObject GetOrbEffect()
			{
				return effectPrefab;
			}
		}

		public string muzzleName = "NanoPistolOrigin";

		public static GameObject MuzzleFlashObject = SnowtimeToyboxMod._stcharacterAssetBundle.LoadAsset<GameObject>("Assets/SnowtimeMod/Assets/Characters/DroneTech/PlasmaRifle/PlasmaRifleMuzzleFlashVFX.prefab");

		public static GameObject TracerObject = SnowtimeToyboxMod._stcharacterAssetBundle.LoadAsset<GameObject>("Assets/SnowtimeMod/Assets/Characters/DroneTech/PlasmaRifle/TracerPlasmaRifle.prefab");

		public static GameObject HitObject = SnowtimeToyboxMod._stcharacterAssetBundle.LoadAsset<GameObject>("Assets/SnowtimeMod/Assets/Characters/DroneTech/PlasmaRifle/PlasmaRifleImpactVFX.prefab");

		public static GameObject OrbObject = SnowtimeToyboxMod._stcharacterAssetBundle.LoadAsset<GameObject>("Assets/SnowtimeMod/Assets/Characters/DroneTech/PlasmaRifle/PlasmaRifleOrbEffect.prefab");

		public GameObject muzzleFlashPrefab = MuzzleFlashObject;

		public GameObject tracerEffectPrefab = TracerObject;

		public GameObject hitEffectPrefab = HitObject;

		public GameObject orbEffectPrefab = OrbObject;

		public string fireSoundString = "Play_Plasma_Rifle_Fire";

		public float procCoefficient = 0.7f;

		public float damageCoefficient = 0.6f;

		public float bulletRadius = 1.25f;

		public float maxDistance = 128f;

		public float baseDuration = 0.2f;

		public float bounceDamageCoefficient = 0.4f;

		public float RecoilY = 0.8f;

		public float RecoilX = 0.2f;

		public float orbSpeed = 100f;

		public bool shouldBounce = true;

		public bool useSmartCollision = true;

		public Transform muzzleTransform;

		private DroneTechController controller;

		private GameObject currentDrone;

		public override void OnEnter()
		{
			controller = ((EntityState)this).GetComponent<DroneTechController>();
			((GenericBulletBaseState)this).OnEnter();
			base.duration = baseDuration / (((BaseState)this).attackSpeedStat / 1f);
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)1;
		}

		public override void PlayFireAnimation()
		{
			Animator modelAnimator = ((EntityState)this).GetModelAnimator();
			if (Object.op_Implicit((Object)(object)modelAnimator))
			{
				if (!modelAnimator.GetBool("isCarried") && !modelAnimator.GetBool("inLeap"))
				{
					goto IL_0036;
				}
			}
			else if (0 == 0)
			{
				goto IL_0036;
			}
			object obj = "FullBody, Override";
			goto IL_0042;
			IL_0036:
			obj = "Gesture, Override";
			goto IL_0042;
			IL_0042:
			string text = (string)obj;
			((EntityState)this).PlayAnimation(text, "FireNanoPistol");
		}

		public override void DoFireEffects()
		{
			string text = fireSoundString;
			int num = (int)Util.PlaySound(text, ((EntityState)this).gameObject);
			EffectManager.SimpleMuzzleFlash(muzzleFlashPrefab, ((EntityState)this).gameObject, muzzleName, false);
		}

		public override void FireBullet(Ray aimRay)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			TrajectoryAimAssist.ApplyTrajectoryAimAssist(ref aimRay, maxDistance, ((EntityState)this).gameObject, 1f);
			if (Object.op_Implicit((Object)(object)controller) && Object.op_Implicit((Object)(object)controller.CurrentDrone?.characterBody))
			{
				currentDrone = ((Component)controller.CurrentDrone.characterBody).gameObject;
			}
			base.recoilAmplitudeY = RecoilY;
			base.recoilAmplitudeX = RecoilX;
			((GenericBulletBaseState)this).FireBullet(aimRay);
		}

		public override void ModifyBullet(BulletAttack bulletAttack)
		{
			//IL_0027: 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_0033: 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_0087: Expected O, but got Unknown
			//IL_0089: 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_00b0: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			((GenericBulletBaseState)this).ModifyBullet(bulletAttack);
			bulletAttack.damage = damageCoefficient * ((EntityState)this).characterBody.damage;
			bulletAttack.damageType = new DamageTypeCombo(DamageTypeCombo.op_Implicit((DamageType)128), (DamageTypeExtended)0, (DamageSource)1);
			bulletAttack.muzzleName = muzzleName;
			bulletAttack.tracerEffectPrefab = tracerEffectPrefab;
			bulletAttack.hitEffectPrefab = hitEffectPrefab;
			bulletAttack.weapon = ((EntityState)this).gameObject;
			bulletAttack.maxDistance = maxDistance;
			bulletAttack.filterCallback = new FilterCallback(IgnoreAlliesAndCurrentDrone);
			bulletAttack.falloffModel = (FalloffModel)1;
			if (shouldBounce)
			{
				bulletAttack.hitCallback = (HitCallback)Delegate.Combine((Delegate?)(object)bulletAttack.hitCallback, (Delegate?)new HitCallback(FireOrb));
			}
		}

		private bool FireOrb(BulletAttack bullet, ref BulletHit hit)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)hit.hitHurtBox) || ((EntityState)this).teamComponent.teamIndex == hit.hitHurtBox.teamIndex)
			{
				return false;
			}
			BullseyeSearch val = new BullseyeSearch();
			val.searchOrigin = hit.point;
			val.searchDirection = Vector3.zero;
			TeamMask unprotectedTeams = TeamMask.GetUnprotectedTeams(((EntityState)this).teamComponent.teamIndex);
			((TeamMask)(ref unprotectedTeams)).RemoveTeam(((EntityState)this).teamComponent.teamIndex);
			val.teamMaskFilter = unprotectedTeams;
			val.filterByLoS = true;
			val.sortMode = (SortMode)1;
			val.maxAngleFilter = 180f;
			val.maxDistanceFilter = 27f;
			val.filterByDistinctEntity = true;
			val.RefreshCandidates();
			val.FilterOutGameObject(((Component)hit.hitHurtBox.healthComponent).gameObject);
			HurtBox val2 = null;
			foreach (HurtBox result in val.GetResults())
			{
				if (Object.op_Implicit((Object)(object)result) && Object.op_Implicit((Object)(object)result.healthComponent) && result.healthComponent.alive)
				{
					val2 = result;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)val2))
			{
				DamageOrb damageOrb = new DamageOrb();
				damageOrb.effectPrefab = orbEffectPrefab;
				((GenericDamageOrb)damageOrb).speed = orbSpeed;
				((Orb)damageOrb).origin = hit.point;
				((GenericDamageOrb)damageOrb).damageValue = bullet.damage * bounceDamageCoefficient;
				((GenericDamageOrb)damageOrb).isCrit = bullet.isCrit;
				((GenericDamageOrb)damageOrb).teamIndex = ((EntityState)this).teamComponent.teamIndex;
				((GenericDamageOrb)damageOrb).attacker = bullet.owner;
				((GenericDamageOrb)damageOrb).procChainMask = bullet.procChainMask;
				((GenericDamageOrb)damageOrb).procCoefficient = bullet.procCoefficient / 3f;
				((GenericDamageOrb)damageOrb).damageType = bullet.damageType;
				((GenericDamageOrb)damageOrb).damageType.damageSource = (DamageSource)1;
				((GenericDamageOrb)damageOrb).damageColorIndex = (DamageColorIndex)0;
				((Orb)damageOrb).target = val2;
				OrbManager.instance.AddOrb((Orb)(object)damageOrb);
			}
			return false;
		}

		private bool IgnoreAlliesAndCurrentDrone(BulletAttack bullet, ref BulletHit hit)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			HurtBox component = ((Component)hit.collider).GetComponent<HurtBox>();
			if ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.healthComponent) && ((Object)(object)((Component)component.healthComponent).gameObject == (Object)(object)bullet.weapon || (Object)(object)((Component)component.healthComponent).gameObject == (Object)(object)currentDrone)) || (Object)(object)hit.entityObject == (Object)(object)((EntityState)this).gameObject || (Object)(object)hit.entityObject == (Object)(object)bullet.weapon)
			{
				return false;
			}
			return !Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.healthComponent) || FriendlyFireManager.ShouldDirectHitProceed(component.healthComponent, ((EntityState)this).teamComponent.teamIndex);
		}
	}
}
namespace EntityStates.Snowtime_Error
{
	internal class FireMissingProjectile : BaseState
	{
		public static GameObject projectilePrefab;

		public static GameObject effectPrefab;

		public static float baseDuration = 1f;

		public static float damageCoefficient = 1f;

		public static float force = 20f;

		public static string attackString;

		private float duration;

		private static int FireMissingProjectileStateHash = Animator.StringToHash("FireMissingProjectile");

		private static int FireMissingProjectileParamHash = Animator.StringToHash("FireMissingProjectile.playbackRate");

		public override void OnEnter()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			duration = baseDuration / base.attackSpeedStat;
			Ray aimRay = ((BaseState)this).GetAimRay();
			string text = "MuzzleMouth";
			if (Object.op_Implicit((Object)(object)effectPrefab))
			{
				EffectManager.SimpleMuzzleFlash(effectPrefab, ((EntityState)this).gameObject, text, false);
			}
			if (((EntityState)this).isAuthority)
			{
				ProjectileManager.instance.FireProjectileWithoutDamageType(projectilePrefab, ((Ray)(ref aimRay)).origin, Util.QuaternionSafeLookRotation(((Ray)(ref aimRay)).direction), ((EntityState)this).gameObject, base.damageStat * damageCoefficient, force, Util.CheckRoll(base.critStat, ((EntityState)this).characterBody.master), (DamageColorIndex)0, (GameObject)null, -1f);
			}
		}

		public override void OnExit()
		{
			((EntityState)this).OnExit();
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).fixedAge >= duration && ((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: 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)
			return (InterruptPriority)1;
		}
	}
}