Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Huntress Skin Pack v0.1.0
BepInEx/plugins/Local-Eclipse_Huntress_Skins_Playtest/Local-Huntress_Liquid_Assets_Playtest/HuntressLiquidAssetsPlaytest.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using EclipseSkinRuntimeFix; using HG.Reflection; using R2API; using R2API.Utils; using RoR2; using RoR2.UI.MainMenu; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: AssemblyVersion("0.0.0.0")] namespace EclipseSkinRuntimeFix { internal static class NativeRenderers { private static readonly HashSet<string> NativePaths = new HashSet<string>(StringComparer.Ordinal) { "mdlLoader/PilotFemaleMesh", "mdlLoader/LoaderMechMesh", "mdlLoader/PilotFemaleFoldedOverJumpsuit", "mdlFalseSon/FalseSon_Body", "mdlFalseSon/FalseSon_Cloth", "mdlFalseSon/L_FalseSon_Weapon", "mdlSeeker/meshSeekerBody", "mdlSeeker/meshSeekerCloth", "mdlSeeker/meshSeekerGlass", "mdlChef/meshChef", "mdlChef/meshChefPizzaCutter", "mdlChef/meshlChefCleaver", "mdlChef/meshChefOven", "mdlChef/meshChefIceBox", "mdlCroco/CrocoMesh", "mdlCroco/CrocoSpineMesh", "mdlHuntress/HuntressMesh", "mdlHuntress/BowMesh", "mdlHuntress/HuntressScarfMesh", "mdlHuntress (1)/HuntressMesh", "mdlHuntress (1)/BowMesh", "mdlHuntress (1)/HuntressScarfMesh", "mdlMerc/MercMesh", "mdlMerc/MercSwordMesh", "mdlTreebot/TreebotBotMesh", "mdlTreebot/TreebotRootMesh", "mdlTreebot/TreebotLeafletMesh", "mdlTreebot/TreebotFlowerMesh", "mdlVoidSurvivor/mdlVoidSurvivorBody", "mdlVoidSurvivor/mdlVoidSurvivorHead", "mdlVoidSurvivor/mdlVoidSurvivorMetal", "mdlVoidSurvivor/metalcollar.001", "mdlBandit2/BanditArmature/ROOT/base/MainWeapon/BanditShotgunMesh", "mdlBandit2/BanditArmature/SideWeapon/SideWeaponSpinner/BanditPistolMesh", "mdlBandit2/Bandit2AccessoriesMesh" }; public static T[] GetSkinRenderers<T>(this Component owner, bool inactive = false, SkinDefParams parameters = null) where T : Renderer { return owner.gameObject.GetSkinRenderers<T>(inactive, parameters); } public static T[] GetSkinRenderers<T>(this GameObject owner, bool inactive = false, SkinDefParams parameters = null) where T : Renderer { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) T[] componentsInChildren = owner.GetComponentsInChildren<T>(inactive); CharacterModel val = owner.GetComponent<CharacterModel>() ?? owner.GetComponentInParent<CharacterModel>(); ModelSkinController val2 = owner.GetComponent<ModelSkinController>() ?? (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<ModelSkinController>() : null); HashSet<Renderer> skinRefs = new HashSet<Renderer>(); SkinDefParams val3 = parameters; if (!Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val2) && val2.skins != null && val2.skins.Length != 0 && Object.op_Implicit((Object)(object)val2.skins[0])) { val3 = val2.skins[0].skinDefParams; } if (Object.op_Implicit((Object)(object)val3)) { if (val3.rendererInfos != null) { RendererInfo[] rendererInfos = val3.rendererInfos; foreach (RendererInfo val4 in rendererInfos) { if (Object.op_Implicit((Object)(object)val4.renderer)) { skinRefs.Add(val4.renderer); } } } if (val3.meshReplacements != null) { MeshReplacement[] meshReplacements = val3.meshReplacements; foreach (MeshReplacement val5 in meshReplacements) { if (Object.op_Implicit((Object)(object)val5.renderer)) { skinRefs.Add(val5.renderer); } } } } HashSet<Renderer> modelRefs = new HashSet<Renderer>(); if (Object.op_Implicit((Object)(object)val) && val.baseRendererInfos != null) { RendererInfo[] rendererInfos = val.baseRendererInfos; foreach (RendererInfo val6 in rendererInfos) { if (Object.op_Implicit((Object)(object)val6.renderer)) { modelRefs.Add(val6.renderer); } } } return Select(componentsInChildren, (T x) => ((Object)(object)x).name, (T x) => skinRefs.Contains((Renderer)(object)x), (T x) => modelRefs.Contains((Renderer)(object)x), (T x) => Path(((Component)(object)x).transform, owner.transform), (T x) => IsKnownNativePath(Path(((Component)(object)x).transform, owner.transform))); } internal static T[] Select<T>(T[] found, Func<T, string> name, Func<T, bool> skin, Func<T, bool> model, Func<T, string> path, Func<T, bool> contract = null) { HashSet<T> hashSet = new HashSet<T>(); if (contract == null) { contract = (T x) => false; } bool flag = found.Any(skin) || found.Any(model) || found.Any(contract); foreach (IGrouping<string, T> item in found.GroupBy(name)) { T[] array = item.ToArray(); if (array.Length == 1) { if (!flag || skin(array[0]) || model(array[0]) || contract(array[0])) { hashSet.Add(array[0]); } continue; } T[] array2 = array.Where(skin).ToArray(); T[] array3 = array.Where(model).ToArray(); T[] array4 = ((array2.Length == 1) ? ((array3.Length == 0 || array3.Contains(array2[0])) ? array2 : new T[0]) : ((array2.Length <= 1) ? array3 : array2.Where(((IEnumerable<T>)array3).Contains<T>).ToArray())); if (array2.Length == 0 && array3.Length == 0) { T[] array5 = array.Where(contract).ToArray(); if (array5.Length != 0) { if (array5.Length != 1) { throw new InvalidOperationException("ECLIPSE_RENDERER_PATH_AMBIGUOUS " + string.Join(";", array.Select(path))); } hashSet.Add(array5[0]); Debug.Log((object)("ECLIPSE_RENDERER_NATIVE_PATH name=" + item.Key + " native=" + path(array5[0]))); continue; } } if (array2.Length == 0 && array3.Length == 0 && flag) { Debug.Log((object)("ECLIPSE_RENDERER_FOREIGN_DUPLICATES name=" + item.Key + " ignored=" + array.Length)); continue; } if (array4.Length != 1) { throw new InvalidOperationException("ECLIPSE_RENDERER_AMBIGUOUS name=" + item.Key + " candidates=" + string.Join(";", array.Select(path)) + " skinRefs=" + array2.Length + " modelRefs=" + array3.Length); } hashSet.Add(array4[0]); Debug.Log((object)("ECLIPSE_RENDERER_RESOLVED name=" + item.Key + " native=" + path(array4[0]) + " ignoredDuplicates=" + (array.Length - 1))); } return found.Where(hashSet.Contains).ToArray(); } internal static bool IsKnownNativePath(string path) { if (path == null) { return false; } int num = path.IndexOf('/'); if (num < 0) { return false; } string text = path.Substring(0, num); if (text.EndsWith("(Clone)", StringComparison.Ordinal)) { text = text.Substring(0, text.Length - 7); } return NativePaths.Contains(text + path.Substring(num)); } private static string Path(Transform t, Transform root) { List<string> list = new List<string>(); Transform val = t; while (Object.op_Implicit((Object)(object)val)) { list.Add(((Object)val).name); if ((Object)(object)val == (Object)(object)root) { break; } val = val.parent; } list.Reverse(); return string.Join("/", list); } } internal sealed class HuntressMaterialProbe : MonoBehaviour { private SkinnedMeshRenderer target; private string previous; public static void Attach(SkinnedMeshRenderer renderer) { if (Object.op_Implicit((Object)(object)renderer)) { (((Component)renderer).GetComponent<HuntressMaterialProbe>() ?? ((Component)renderer).gameObject.AddComponent<HuntressMaterialProbe>()).target = renderer; } } private void Awake() { target = ((Component)this).GetComponent<SkinnedMeshRenderer>(); } private void LateUpdate() { if (!Object.op_Implicit((Object)(object)target)) { target = ((Component)this).GetComponent<SkinnedMeshRenderer>(); } if (Object.op_Implicit((Object)(object)target) && Object.op_Implicit((Object)(object)target.sharedMesh)) { Material sharedMaterial = ((Renderer)target).sharedMaterial; Texture val = ((Object.op_Implicit((Object)(object)sharedMaterial) && sharedMaterial.HasProperty("_MainTex")) ? sharedMaterial.GetTexture("_MainTex") : null); string text = ((Object)target.sharedMesh).name + "#" + ((Object)target.sharedMesh).GetInstanceID() + " material=" + (Object.op_Implicit((Object)(object)sharedMaterial) ? (((Object)sharedMaterial).name + "#" + ((Object)sharedMaterial).GetInstanceID()) : "null") + " shader=" + ((Object.op_Implicit((Object)(object)sharedMaterial) && Object.op_Implicit((Object)(object)sharedMaterial.shader)) ? ((Object)sharedMaterial.shader).name : "null") + " albedo=" + (Object.op_Implicit((Object)(object)val) ? (((Object)val).name + "#" + ((Object)val).GetInstanceID()) : "null"); if (!(text == previous)) { previous = text; Debug.Log((object)("ECLIPSE_HUNTRESS_APPLIED mesh=" + text + " renderer=" + ((Object)target).name)); } } } private void OnDisable() { previous = null; } } } namespace HuntressBananaHuntressStandalone { [BepInPlugin("eclipseplaytest.huntress.e6", "Huntress Banana Huntress Playtest", "0.2.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class HuntressLiquidAssetsPlaytest : BaseUnityPlugin { private sealed class Design { public string Slug; public string Name; public Color32[] Colors; public Design(string slug, string name, Color32[] colors) { Slug = slug; Name = name; Colors = colors; } } public const string Guid = "eclipseplaytest.huntress.e6"; public const string Version = "0.2.4"; private static HuntressLiquidAssetsPlaytest instance; private readonly List<AsyncOperationHandle> retainedAssets = new List<AsyncOperationHandle>(); private float registrationDeadline; private string folder; private SkinDef skin; private Mesh mesh; private Material material; private GameObject modelPrefab; private int rendererIndex; private bool registered; private static readonly Design[] Designs = new Design[1] { new Design("banana-huntress", "Huntress - Banana Huntress (Playtest)", (Color32[])(object)new Color32[4] { new Color32((byte)86, (byte)91, (byte)78, byte.MaxValue), new Color32((byte)42, (byte)47, (byte)51, byte.MaxValue), new Color32((byte)151, (byte)160, (byte)160, byte.MaxValue), new Color32((byte)60, (byte)153, (byte)146, byte.MaxValue) }) }; private void Awake() { folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); instance = this; SystemInitializerInjector.InjectDependency(typeof(SkinCatalog), typeof(HuntressLiquidAssetsPlaytest)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SyncDisplaySkins)); MainMenuController.OnMainMenuInitialised += SyncDisplaySkins; } [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static IEnumerator InitializeSkin() { if (!Object.op_Implicit((Object)(object)instance)) { yield break; } instance.registrationDeadline = Time.realtimeSinceStartup + 45f; IEnumerator routine = instance.RegisterAsync(); while (true) { bool flag; try { flag = routine.MoveNext(); } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogError((object)("ECLIPSEPLAYTEST_HUNTRESS_E6_REGISTRATION_FAILED: " + ex)); break; } if (!flag) { break; } yield return null; } (routine as IDisposable)?.Dispose(); } private IEnumerator RegisterAsync() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_HUNTRESS_E6_REGISTRATION_BEGIN async loader 0.2.4"); GameObject val = BodyCatalog.FindBodyPrefab("HuntressBody"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("HuntressBody is missing."); } modelPrefab = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController controller = modelPrefab.GetComponent<ModelSkinController>(); if (controller.skins.Any((SkinDef s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name == "skinHuntressLiquidAssetsPlaytest_liquid-assets")) { yield break; } SkinDef baseSkin = controller.skins[0]; SkinDefParams baseParams = baseSkin.skinDefParams; if (!Object.op_Implicit((Object)(object)baseParams) && baseSkin.skinDefParamsAddress != null && ((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKeyIsValid()) { AsyncOperationHandle<SkinDefParams> load = Addressables.LoadAssetAsync<SkinDefParams>(((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<SkinDefParams>.op_Implicit(load)); while (!load.IsDone) { CheckLoadDeadline("skin parameters"); yield return null; } baseParams = load.Result; } if (!Object.op_Implicit((Object)(object)baseParams)) { throw new InvalidOperationException("Huntress's base skin parameters are unavailable."); } SkinnedMeshRenderer[] renderers = modelPrefab.GetSkinRenderers<SkinnedMeshRenderer>(inactive: true, baseParams); SkinnedMeshRenderer target = renderers.First((SkinnedMeshRenderer r) => ((Object)r).name == "HuntressMesh" && r.bones.Length == 69 && r.bones.Any((Transform b) => Object.op_Implicit((Object)(object)b) && ((Object)b).name == "head")); HuntressMaterialProbe.Attach(target); rendererIndex = Array.IndexOf(renderers, target); Mesh referenceMesh = target.sharedMesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { MeshReplacement val2 = baseParams.meshReplacements.First((MeshReplacement r) => (Object)(object)r.renderer == (Object)(object)target); referenceMesh = val2.mesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { AsyncOperationHandle<Mesh> load2 = Addressables.LoadAssetAsync<Mesh>(((AssetReference)val2.meshAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Mesh>.op_Implicit(load2)); while (!load2.IsDone) { CheckLoadDeadline("reference mesh"); yield return null; } referenceMesh = load2.Result; } } if (!Object.op_Implicit((Object)(object)referenceMesh) || referenceMesh.bindposes.Length != target.bones.Length) { throw new InvalidOperationException("The installed Huntress bind pose does not match the renderer."); } RendererInfo originalInfo = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)target); Material val3 = originalInfo.defaultMaterial; if (!Object.op_Implicit((Object)(object)val3) && originalInfo.defaultMaterialAddress != null) { AsyncOperationHandle<Material> load3 = Addressables.LoadAssetAsync<Material>(((AssetReference)originalInfo.defaultMaterialAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Material>.op_Implicit(load3)); while (!load3.IsDone) { CheckLoadDeadline("material"); yield return null; } val3 = load3.Result; } if (!Object.op_Implicit((Object)(object)val3)) { val3 = ((Renderer)target).sharedMaterial; } if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.shader)) { throw new InvalidOperationException("Huntress's game shader is unavailable."); } AsyncOperationHandle<Shader> shaderLoad = Addressables.LoadAssetAsync<Shader>((object)"RoR2/Base/Shaders/HGStandard.shader"); retainedAssets.Add(AsyncOperationHandle<Shader>.op_Implicit(shaderLoad)); while (!shaderLoad.IsDone) { CheckLoadDeadline("HGStandard shader"); yield return null; } if ((int)shaderLoad.Status != 1 || !Object.op_Implicit((Object)(object)shaderLoad.Result)) { throw new InvalidOperationException("ECLIPSE_HUNTRESS_SHADER_LOAD_FAILED HGStandard"); } Shader authoredShader = shaderLoad.Result; List<SkinDef> additions = new List<SkinDef>(); Design[] designs = Designs; foreach (Design design in designs) { string path = Path.Combine(folder, "skins", design.Slug); mesh = ReadMesh(Path.Combine(path, "model.meshbin"), target, referenceMesh); ((Object)mesh).name = "HuntressLiquidAssetsPlaytest_" + design.Slug; material = new Material(authoredShader) { name = "matHuntressLiquidAssetsPlaytest_" + design.Slug }; material.SetTexture("_MainTex", (Texture)(object)ReadTexture(Path.Combine("skins", design.Slug, "albedo-spec.png"), linear: false)); material.SetTexture("_NormalTex", (Texture)(object)ReadTexture(Path.Combine("skins", design.Slug, "normal.png"), linear: true)); if (!material.HasProperty("_MainTex") || !Object.op_Implicit((Object)(object)material.GetTexture("_MainTex"))) { throw new InvalidOperationException("ECLIPSE_HUNTRESS_ALBEDO_BINDING_FAILED " + design.Slug); } material.SetTextureScale("_MainTex", Vector2.one); material.SetTextureOffset("_MainTex", Vector2.zero); material.SetColor("_EmColor", Color.white); material.SetFloat("_Cull", 2f); material.SetFloat("_ZWrite", 1f); material.SetFloat("_DitherOn", 1f); material.EnableKeyword("DITHER"); material.SetColor("_Color", Color.white); material.SetFloat("_NormalStrength", 0f); material.SetFloat("_Smoothness", 0.15f); material.SetFloat("_SpecularStrength", 0.2f); material.SetFloat("_SpecularExponent", 4f); material.SetFloat("_EmPower", 1f); material.SetTexture("_EmTex", (Texture)(object)ReadTexture(Path.Combine("skins", design.Slug, "emission.png"), linear: false)); material.DisableKeyword("LIMBREMOVAL"); material.SetFloat("_LimbRemovalOn", 0f); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSE_HUNTRESS_MATERIAL_READY skin=" + design.Slug + " shader=" + ((Object)material.shader).name + " albedo=" + ((Object)material.GetTexture("_MainTex")).name)); RendererInfo val4 = originalInfo; val4.defaultMaterial = material; val4.defaultMaterialAddress = new AssetReferenceT<Material>(""); SkinDefParams val5 = ScriptableObject.CreateInstance<SkinDefParams>(); val5.rendererInfos = (RendererInfo[])(object)new RendererInfo[1] { val4 }; List<MeshReplacement> list = new List<MeshReplacement> { new MeshReplacement { renderer = (Renderer)(object)target, mesh = mesh, meshAddress = new AssetReferenceT<Mesh>("") } }; foreach (SkinnedMeshRenderer item in renderers.Where((SkinnedMeshRenderer r) => ((Object)r).name == "BowMesh" || ((Object)r).name == "HuntressScarfMesh")) { Mesh val6 = new Mesh { name = "HuntressLiquidAssetsPlaytest_hidden_" + ((Object)item).name }; val6.vertices = (Vector3[])(object)new Vector3[0]; val6.triangles = new int[0]; list.Add(new MeshReplacement { renderer = (Renderer)(object)item, mesh = val6, meshAddress = new AssetReferenceT<Mesh>("") }); } val5.meshReplacements = list.ToArray(); skin = ScriptableObject.CreateInstance<SkinDef>(); ((Object)skin).name = "skinHuntressLiquidAssetsPlaytest_liquid-assets"; skin.nameToken = "ECLIPSEPLAYTEST_HUNTRESS_E6_" + design.Slug.ToUpperInvariant().Replace('-', '_'); LanguageAPI.Add(skin.nameToken, design.Name); skin.icon = CreateIcon(design.Colors); skin.unlockableDef = null; skin.rootObject = modelPrefab; skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { baseSkin }; skin.skinDefParams = val5; additions.Add(skin); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSEPLAYTEST_HUNTRESS_E6_PREPARED name=" + design.Name + " vertices=" + mesh.vertexCount + " triangles=" + mesh.triangles.Length / 3 + " unlocked=true")); yield return null; } controller.skins = controller.skins.Concat(additions).ToArray(); registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSEPLAYTEST_HUNTRESS_E6_REGISTERED count=" + additions.Count + " version=0.2.4")); } private static Sprite CreateIcon(Color32[] colors) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = ((i > j) ? ((i <= 63 - j) ? 1 : 0) : ((i > 63 - j) ? 2 : 3)); array[i * 64 + j] = (Color32)((j < 2 || j > 61 || i < 2 || i > 61 || Math.Abs(i - j) < 2 || Math.Abs(i - (63 - j)) < 2) ? new Color32((byte)48, (byte)48, (byte)48, byte.MaxValue) : colors[num]); } } val.SetPixels32(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); } private void CheckLoadDeadline(string asset) { if (Time.realtimeSinceStartup > registrationDeadline) { throw new TimeoutException("Stopped loading " + asset + "; continuing startup without the skin."); } } private void SyncDisplaySkins() { if (!registered) { return; } SurvivorDef val = SurvivorCatalog.allSurvivorDefs.FirstOrDefault((Func<SurvivorDef, bool>)((SurvivorDef s) => Object.op_Implicit((Object)(object)s) && Object.op_Implicit((Object)(object)s.bodyPrefab) && ((Object)s.bodyPrefab).name == "HuntressBody")); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.displayPrefab)) { return; } CharacterModel componentInChildren = val.displayPrefab.GetComponentInChildren<CharacterModel>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { HuntressMaterialProbe.Attach(((IEnumerable<SkinnedMeshRenderer>)((Component)(object)componentInChildren).GetSkinRenderers<SkinnedMeshRenderer>(inactive: true, (SkinDefParams)null)).FirstOrDefault((Func<SkinnedMeshRenderer, bool>)((SkinnedMeshRenderer r) => ((Object)r).name == "HuntressMesh"))); ModelSkinController val2 = ((Component)componentInChildren).GetComponent<ModelSkinController>() ?? ((Component)componentInChildren).gameObject.AddComponent<ModelSkinController>(); val2.skins = (SkinDef[])modelPrefab.GetComponent<ModelSkinController>().skins.Clone(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSEPLAYTEST_HUNTRESS_E6_DISPLAY_READY skins=" + val2.skins.Length)); } } private Texture2D ReadTexture(string name, bool linear) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, anisoLevel = 4, filterMode = (FilterMode)2 }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(folder, name)), false)) { throw new InvalidDataException("Cannot decode " + name); } return val; } private Mesh ReadMesh(string path, SkinnedMeshRenderer renderer, Mesh reference) { //IL_014a: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (new string(binaryReader.ReadChars(4)) != "HEP1") { throw new InvalidDataException("Invalid mesh signature."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 200000 || num2 < 3 || num2 > 1200000 || num2 % 3 != 0 || num3 != 69) { throw new InvalidDataException("Invalid mesh dimensions."); } int[] array = new int[num3]; for (int i = 0; i < num3; i++) { int num4 = binaryReader.ReadInt32(); if (num4 < 1 || num4 > 128) { throw new InvalidDataException("Invalid bone name."); } string name = Encoding.UTF8.GetString(binaryReader.ReadBytes(num4)); array[i] = Array.FindIndex(renderer.bones, (Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == name); if (array[i] < 0) { throw new InvalidDataException("Missing reference bone: " + name); } } Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector3[] array3 = (Vector3[])(object)new Vector3[num]; Vector2[] array4 = (Vector2[])(object)new Vector2[num]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num]; for (int num5 = 0; num5 < num; num5++) { array2[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int[] array6 = new int[4]; for (int num6 = 0; num6 < 4; num6++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num3) { throw new InvalidDataException("Bone out of range."); } array6[num6] = array[num7]; } float[] array7 = new float[4]; for (int num8 = 0; num8 < 4; num8++) { array7[num8] = binaryReader.ReadSingle(); } if (array7.Any((float n) => float.IsNaN(n) || float.IsInfinity(n) || n < 0f) || Math.Abs(array7.Sum() - 1f) > 0.002f) { throw new InvalidDataException("Invalid skin weight."); } if (!Finite(array2[num5]) || !Finite(array3[num5])) { throw new InvalidDataException("Non-finite vertex."); } int num9 = num5; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = array6[0]; ((BoneWeight)(ref val)).boneIndex1 = array6[1]; ((BoneWeight)(ref val)).boneIndex2 = array6[2]; ((BoneWeight)(ref val)).boneIndex3 = array6[3]; ((BoneWeight)(ref val)).weight0 = array7[0]; ((BoneWeight)(ref val)).weight1 = array7[1]; ((BoneWeight)(ref val)).weight2 = array7[2]; ((BoneWeight)(ref val)).weight3 = array7[3]; array5[num9] = val; } int[] array8 = new int[num2]; for (int num10 = 0; num10 < num2; num10++) { array8[num10] = binaryReader.ReadInt32(); if (array8[num10] < 0 || array8[num10] >= num) { throw new InvalidDataException("Triangle out of range."); } } if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { throw new InvalidDataException("Unexpected trailing mesh data."); } Mesh val2 = new Mesh { name = "CommandoHuntressLiquidAssetsPlaytest", indexFormat = (IndexFormat)(num > 65535), vertices = array2, normals = array3, uv = array4, boneWeights = array5, bindposes = reference.bindposes, triangles = array8 }; val2.RecalculateBounds(); val2.RecalculateTangents(); return val2; } private static bool Finite(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(v.x + v.y + v.z)) { return !float.IsInfinity(v.x + v.y + v.z); } return false; } } }