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 Chancla de Baba v1.0.4
BepInEx/plugins/ChanclaDeBaba/ChanclaBaba.dll
Decompiled 2 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 ChanclaBaba { [BepInPlugin("es.extremaproducciones.valheim.chancladebaba", "Chancla de Baba", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal sealed class ChanclaBabaPlugin : BaseUnityPlugin { public const string ModGuid = "es.extremaproducciones.valheim.chancladebaba"; public const string ModName = "Chancla de Baba"; public const string ModVersion = "1.0.4"; public const string ItemPrefabName = "Extrema_ChanclaDeBaba"; private const float ModelScale = 0.2f; private void Awake() { AddLocalization(); PrefabManager.OnVanillaPrefabsAvailable += RegisterWeapon; } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterWeapon; } private static void AddLocalization() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "Spanish"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "item_chancla_baba", "Chancla de Baba" }, { "item_chancla_baba_desc", "NOOOO! With the chancla no!" } }); text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "item_chancla_baba", "Grandma's Chancla" }, { "item_chancla_baba_desc", "NOOOO! With the chancla no!" } }); } private void RegisterWeapon() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) try { Sprite val = LoadEmbeddedIcon("ChanclaBaba.Assets.chancla.png", "ChanclaBabaIcon"); ItemConfig val2 = new ItemConfig { Name = "$item_chancla_baba", Description = "$item_chancla_baba_desc", CraftingStation = CraftingStations.Workbench, RepairStation = CraftingStations.Workbench, MinStationLevel = 1, Amount = 1, StackSize = 1, Icon = val }; val2.AddRequirement("Wood", 20, 0); val2.AddRequirement("Resin", 10, 0); val2.AddRequirement("Raspberry", 5, 0); val2.AddRequirement("Honey", 5, 0); CustomItem val3 = new CustomItem("Extrema_ChanclaDeBaba", "SpearFlint", val2); if ((Object)(object)val3.ItemPrefab == (Object)null || (Object)(object)val3.ItemDrop == (Object)null) { throw new InvalidOperationException("Jötunn no pudo clonar la lanza SpearFlint."); } SharedData shared = val3.ItemDrop.m_itemData.m_shared; shared.m_icons = (Sprite[])(object)new Sprite[1] { val }; shared.m_maxQuality = 1; ConfigureDamage(shared.m_damages); ClearDamage(shared.m_damagesPerLevel); if (!TryCopyLightningEffects(shared)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No se encontró el arma eléctrica nórdica; el daño de rayo seguirá activo sin su VFX."); } if (!CreateChanclaProjectile(shared)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No se pudo sustituir el proyectil; el lanzamiento conservará temporalmente la malla de lanza."); } try { if (!ReplaceVisualWithChancla(val3.ItemPrefab)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No se encontró la malla del garrote; se conservará el modelo base."); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Falló el modelo 3D de chancla; se conservará el garrote: " + ex.Message)); } ItemManager.Instance.AddItem(val3); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Chancla de Baba registrada en banco nivel 1 con un punto de cada tipo de daño."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)string.Format("No se pudo registrar {0}: {1}", "Chancla de Baba", arg)); } finally { PrefabManager.OnVanillaPrefabsAvailable -= RegisterWeapon; } } private static bool CreateChanclaProjectile(SharedData shared) { Attack secondaryAttack = shared.m_secondaryAttack; GameObject val = secondaryAttack?.m_attackProjectile; if ((Object)(object)val == (Object)null) { return false; } GameObject val2 = PrefabManager.Instance.CreateClonedPrefab("Extrema_ChanclaDeBaba_Projectile", val); if ((Object)(object)val2 == (Object)null) { return false; } if (!ReplaceVisualWithChancla(val2)) { return false; } PrefabManager.Instance.AddPrefab(val2); secondaryAttack.m_attackProjectile = val2; return true; } private static void ConfigureDamage(DamageTypes damage) { damage.m_damage = 0f; damage.m_blunt = 1f; damage.m_slash = 1f; damage.m_pierce = 1f; damage.m_chop = 1f; damage.m_pickaxe = 1f; damage.m_fire = 1f; damage.m_frost = 1f; damage.m_lightning = 1f; damage.m_poison = 1f; damage.m_spirit = 1f; } private static void ClearDamage(DamageTypes damage) { damage.m_damage = 0f; damage.m_blunt = 0f; damage.m_slash = 0f; damage.m_pierce = 0f; damage.m_chop = 0f; damage.m_pickaxe = 0f; damage.m_fire = 0f; damage.m_frost = 0f; damage.m_lightning = 0f; damage.m_poison = 0f; damage.m_spirit = 0f; } private static bool ReplaceVisualWithChancla(GameObject itemPrefab) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //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) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_01cf: Unknown result type (might be due to invalid IL or missing references) MeshFilter val = FindLargestMesh(itemPrefab); if ((Object)(object)val == (Object)null || (Object)(object)val.sharedMesh == (Object)null) { return false; } Bounds bounds = val.sharedMesh.bounds; int axis = LongestAxis(((Bounds)(ref bounds)).size); float num = Component(((Bounds)(ref bounds)).size, axis); if (num < 0.01f) { return false; } Transform val2 = FindGripAnchor(((Component)val).transform, itemPrefab.transform); Vector3 val3 = ((Component)val).transform.InverseTransformPoint(val2.position); float num2 = Component(val3, axis); float num3 = Mathf.Abs(num2 - Component(((Bounds)(ref bounds)).min, axis)); float num4 = Mathf.Abs(Component(((Bounds)(ref bounds)).max, axis) - num2); float direction = ((num4 >= num3) ? 1f : (-1f)); Vector3 center = CenterOnGrip(((Bounds)(ref bounds)).center, val3, axis); MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>(); if ((Object)(object)component == (Object)null) { return false; } Material sharedMaterial = ((Renderer)component).sharedMaterial; val.sharedMesh = CreateSoleMesh(bounds, axis, center, num2, direction); ((Renderer)component).sharedMaterial = CreateMaterial(sharedMaterial, "ChanclaBaba_Sole", new Color(0.94f, 0.61f, 0.17f, 1f), 0.08f, 0.35f); MeshRenderer[] componentsInChildren = itemPrefab.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val4 in componentsInChildren) { if ((Object)(object)val4 != (Object)(object)component) { ((Renderer)val4).enabled = false; } } SkinnedMeshRenderer[] componentsInChildren2 = itemPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val5 in componentsInChildren2) { ((Renderer)val5).enabled = false; } AddStraps(val, bounds, axis, center, num2, direction, sharedMaterial); return true; } private static Transform FindGripAnchor(Transform meshTransform, Transform prefabRoot) { Transform val = meshTransform; while ((Object)(object)val != (Object)null) { if (((Object)val).name.StartsWith("attach", StringComparison.OrdinalIgnoreCase)) { return val; } if ((Object)(object)val == (Object)(object)prefabRoot) { break; } val = val.parent; } return prefabRoot; } private static MeshFilter FindLargestMesh(GameObject itemPrefab) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0054: 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) MeshFilter val = null; float num = 0f; MeshFilter[] componentsInChildren = itemPrefab.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val2 in componentsInChildren) { if (!((Object)(object)val2.sharedMesh == (Object)null)) { Bounds bounds = val2.sharedMesh.bounds; Vector3 size = ((Bounds)(ref bounds)).size; float num2 = Mathf.Max(0.0001f, size.x * size.y * size.z); if ((Object)(object)val == (Object)null || num2 > num) { val = val2; num = num2; } } } return val; } private static Mesh CreateSoleMesh(Bounds bounds, int axis, Vector3 center, float origin, float direction) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0062: 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_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_008e: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_0193: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown List<Vector3> list = new List<Vector3>(); List<int> list2 = new List<int>(); Vector2[] outline = (Vector2[])(object)new Vector2[16] { new Vector2(0f, -0.105f), new Vector2(0.04f, -0.145f), new Vector2(0.18f, -0.165f), new Vector2(0.46f, -0.18f), new Vector2(0.72f, -0.225f), new Vector2(0.91f, -0.245f), new Vector2(0.985f, -0.19f), new Vector2(1f, -0.085f), new Vector2(1f, 0.085f), new Vector2(0.985f, 0.19f), new Vector2(0.91f, 0.245f), new Vector2(0.72f, 0.225f), new Vector2(0.46f, 0.18f), new Vector2(0.18f, 0.165f), new Vector2(0.04f, 0.145f), new Vector2(0f, 0.105f) }; float num = Component(((Bounds)(ref bounds)).size, axis) * 0.2f; AddPrism(list, list2, axis, center, origin, direction, num, outline, 0f, num * 0.038f); Mesh val = new Mesh { name = "Extrema_ChanclaDeBaba_Sole" }; val.vertices = list.ToArray(); val.triangles = list2.ToArray(); val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static void AddStraps(MeshFilter parent, Bounds bounds, int axis, Vector3 center, float origin, float direction, Material fallback) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_003c: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0183: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Extrema_ChanclaDeBaba_Straps"); val.transform.SetParent(((Component)parent).transform, false); MeshFilter val2 = val.AddComponent<MeshFilter>(); MeshRenderer val3 = val.AddComponent<MeshRenderer>(); List<Vector3> list = new List<Vector3>(); List<int> list2 = new List<int>(); float num = Component(((Bounds)(ref bounds)).size, axis) * 0.2f; float num2 = num * 0.038f; float num3 = num * 0.016f; float depthCenter = num2 + num3 * 0.7f; AddBand(list, list2, axis, center, origin, direction, num, new Vector2(0.31f, -0.155f), new Vector2(0.69f, -0.025f), 0.03f, depthCenter, num3); AddBand(list, list2, axis, center, origin, direction, num, new Vector2(0.31f, 0.155f), new Vector2(0.69f, 0.025f), 0.03f, depthCenter, num3); AddBand(list, list2, axis, center, origin, direction, num, new Vector2(0.655f, -0.025f), new Vector2(0.78f, 0f), 0.032f, depthCenter, num3 * 1.1f); Mesh val4 = new Mesh { name = "Extrema_ChanclaDeBaba_RedStraps" }; val4.vertices = list.ToArray(); val4.triangles = list2.ToArray(); val4.RecalculateNormals(); val4.RecalculateBounds(); val2.sharedMesh = val4; ((Renderer)val3).sharedMaterial = CreateMaterial(fallback, "ChanclaBaba_Straps", new Color(0.91f, 0.055f, 0.035f, 1f), 0.02f, 0.42f); } private static bool TryCopyLightningEffects(SharedData target) { string[] array = new string[2] { "BattleaxeGold_BloodLightning", "BattleaxeGold" }; string[] array2 = array; foreach (string text in array2) { GameObject prefab = PrefabManager.Instance.GetPrefab(text); SharedData val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null)?.m_itemData?.m_shared; if (val != null) { CopyAttackEffects(val.m_attack, target.m_attack); CopyAttackEffects(val.m_secondaryAttack, target.m_secondaryAttack); target.m_spawnOnHit = val.m_spawnOnHit; target.m_spawnOnHitTerrain = val.m_spawnOnHitTerrain; return true; } } return false; } private static void CopyAttackEffects(Attack source, Attack target) { if (source != null && target != null) { target.m_hitEffect = source.m_hitEffect; target.m_hitTerrainEffect = source.m_hitTerrainEffect; target.m_startEffect = source.m_startEffect; target.m_triggerEffect = source.m_triggerEffect; target.m_trailStartEffect = source.m_trailStartEffect; target.m_burstEffect = source.m_burstEffect; } } private static void AddBand(List<Vector3> vertices, List<int> triangles, int axis, Vector3 center, float origin, float direction, float length, Vector2 start, Vector2 end, float halfWidth, float depthCenter, float halfDepth) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_001d: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) Vector2 val = end - start; Vector2 val2 = new Vector2(0f - val.y, val.x); Vector2 val3 = ((Vector2)(ref val2)).normalized * halfWidth; Vector2[] outline = (Vector2[])(object)new Vector2[4] { start - val3, end - val3, end + val3, start + val3 }; AddPrism(vertices, triangles, axis, center, origin, direction, length, outline, depthCenter, halfDepth); } private static void AddPrism(List<Vector3> vertices, List<int> triangles, int axis, Vector3 center, float origin, float direction, float length, Vector2[] outline, float depthCenter, float halfDepth) { //IL_0027: 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) int count = vertices.Count; int num = outline.Length; for (int i = 0; i < 2; i++) { float depth = depthCenter + ((i == 0) ? (0f - halfDepth) : halfDepth); for (int j = 0; j < num; j++) { vertices.Add(Point(axis, center, origin + direction * length * outline[j].x, length * outline[j].y, depth)); } } for (int k = 1; k < num - 1; k++) { triangles.Add(count); triangles.Add(count + k + 1); triangles.Add(count + k); triangles.Add(count + num); triangles.Add(count + num + k); triangles.Add(count + num + k + 1); } for (int l = 0; l < num; l++) { int num2 = (l + 1) % num; int item = count + l; int item2 = count + num2; int item3 = count + num + l; int item4 = count + num + num2; triangles.Add(item); triangles.Add(item2); triangles.Add(item3); triangles.Add(item2); triangles.Add(item4); triangles.Add(item3); } } private static Material CreateMaterial(Material fallback, string name, Color color, float metallic, float glossiness) { //IL_001e: 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_0024: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Standard"); Material val2 = (((Object)(object)val != (Object)null) ? new Material(val) : new Material(fallback)); ((Object)val2).name = name; val2.color = color; if (val2.HasProperty("_Metallic")) { val2.SetFloat("_Metallic", metallic); } if (val2.HasProperty("_Glossiness")) { val2.SetFloat("_Glossiness", glossiness); } return val2; } private static Sprite LoadEmbeddedIcon(string resourceName, string textureName) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); if (stream == null) { throw new InvalidOperationException("No se encontró " + resourceName + "."); } byte[] array = new byte[stream.Length]; int num; for (int i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { break; } } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); Assembly assembly = Assembly.Load("UnityEngine.ImageConversionModule"); MethodInfo methodInfo = assembly.GetType("UnityEngine.ImageConversion")?.GetMethod("LoadImage", BindingFlags.Static | BindingFlags.Public, null, new Type[3] { typeof(Texture2D), typeof(byte[]), typeof(bool) }, null); if (methodInfo == null || !(bool)methodInfo.Invoke(null, new object[3] { val, array, false })) { throw new InvalidOperationException("No se pudo decodificar el icono PNG."); } ((Object)val).name = textureName; ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } private static int LongestAxis(Vector3 size) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (size.x >= size.y && size.x >= size.z) { return 0; } return (size.y >= size.z) ? 1 : 2; } private static float Component(Vector3 value, int axis) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return axis switch { 1 => value.y, 0 => value.x, _ => value.z, }; } private static Vector3 CenterOnGrip(Vector3 sourceCenter, Vector3 grip, int axis) { //IL_0009: 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_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_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_0051: Unknown result type (might be due to invalid IL or missing references) //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(axis switch { 0 => new Vector3(sourceCenter.x, grip.y, grip.z), 1 => new Vector3(grip.x, sourceCenter.y, grip.z), _ => new Vector3(grip.x, grip.y, sourceCenter.z), }); } private static Vector3 AlongAxis(int axis, float coordinate, Vector3 center) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0038: 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) return (Vector3)(axis switch { 0 => new Vector3(coordinate, center.y, center.z), 1 => new Vector3(center.x, coordinate, center.z), _ => new Vector3(center.x, center.y, coordinate), }); } private static Vector3 Point(int axis, Vector3 center, float along, float width, float depth) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //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_0045: 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_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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(axis switch { 0 => new Vector3(along, center.y + width, center.z + depth), 1 => new Vector3(center.x + width, along, center.z + depth), _ => new Vector3(center.x + width, center.y + depth, along), }); } } }