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 Lord Of Thunder v1.1.0
BepInEx/plugins/Yoroshiro_ThorArmor/Yoroshiro.ThorArmor.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Yoroshiro")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.2.0")] [assembly: AssemblyInformationalVersion("0.3.2")] [assembly: AssemblyProduct("Yoroshiro.ThorArmor")] [assembly: AssemblyTitle("Yoroshiro.ThorArmor")] [assembly: AssemblyVersion("0.3.2.0")] namespace Yoroshiro.ThorArmor; [BepInPlugin("com.yoroshiro.thorarmor", "Peitoral de Thor — Yoroshiro", "0.3.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class ThorArmorPlugin : BaseUnityPlugin { public const string ItemId = "YoroshiroThorChest"; internal static ManualLogSource Log; private Mesh chest; private Mesh left; private Mesh right; private Texture2D chestTexture; private Texture2D gloveTexture; private Texture2D underlayer; private Sprite icon; private string[] boneNames; private bool registered; private void Awake() { //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ThunderSet.Start(); Dictionary<string, string> dictionary = new Dictionary<string, string> { { "yoroshiro_thorchest_name", "Peitoral de Thor" }, { "yoroshiro_thorchest_description", "Peitoral e manoplas de ferro escuro com detalhes dourados.\n\nSenhor do Trovão (3 peças): +6 de armadura total com capacete, peitoral e saia com botas equipados e com durabilidade.\n\nCriado por Yoroshiro." } }; CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, dictionary); CustomLocalization localization2 = LocalizationManager.Instance.GetLocalization(); text = "Portuguese"; localization2.AddTranslation(ref text, dictionary); try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); boneNames = File.ReadAllLines(Path.Combine(directoryName, "ThorArmor_Bones.txt")); chest = LoadMesh(Path.Combine(directoryName, "ThorChest.skinbin")); left = LoadMesh(Path.Combine(directoryName, "ThorGloveLeft.skinbin")); right = LoadMesh(Path.Combine(directoryName, "ThorGloveRight.skinbin")); if (chest.bindposes.Length != boneNames.Length || left.bindposes.Length != boneNames.Length || right.bindposes.Length != boneNames.Length) { throw new InvalidDataException("Lista de ossos incompatível."); } chestTexture = LoadTexture(Path.Combine(directoryName, "ThorChest_BaseColor.png")); gloveTexture = LoadTexture(Path.Combine(directoryName, "ThorGloves_BaseColor.png")); underlayer = LoadTexture(Path.Combine(directoryName, "ThorArmor_Underlayer.png")); Texture2D val = LoadTexture(Path.Combine(directoryName, "ThorArmor_Icon.png")); icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); PrefabManager.OnVanillaPrefabsAvailable += Register; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Peitoral e luvas preparados; aguardando registro nativo."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Falha ao preparar o Peitoral de Thor: " + ex)); } } private void Register() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Expected O, but got Unknown if (registered) { return; } GameObject val = null; try { ItemConfig val2 = new ItemConfig(); val2.Name = "$yoroshiro_thorchest_name"; val2.Description = "$yoroshiro_thorchest_description"; val2.Icon = icon; val2.Enabled = true; val2.Amount = 1; val2.CraftingStation = "forge"; val2.RepairStation = "forge"; val2.MinStationLevel = 3; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("BlackMetal", 24, 8, true), new RequirementConfig("Silver", 12, 4, true), new RequirementConfig("Thunderstone", 2, 0, true), new RequirementConfig("YmirRemains", 4, 1, true) }; CustomItem val3 = new CustomItem("YoroshiroThorChest", "ArmorIronChest", val2); val = val3.ItemPrefab; if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("ArmorIronChest indisponível."); } Transform val4 = val.transform.Find("attach_skin"); if (!Object.op_Implicit((Object)(object)val4)) { throw new InvalidOperationException("Encaixe animado nativo indisponível."); } SkinnedMeshRenderer val5 = ((IEnumerable<SkinnedMeshRenderer>)((Component)val4).GetComponentsInChildren<SkinnedMeshRenderer>(true)).FirstOrDefault((Func<SkinnedMeshRenderer, bool>)((SkinnedMeshRenderer r) => Object.op_Implicit((Object)(object)((Renderer)r).sharedMaterial) && Object.op_Implicit((Object)(object)((Renderer)r).sharedMaterial.shader))); if (!Object.op_Implicit((Object)(object)val5)) { throw new InvalidOperationException("Material da armadura de ferro indisponível."); } Transform[] bones = ResolveBones(boneNames, val5.bones); Transform rootBone = val5.rootBone; if (!Object.op_Implicit((Object)(object)rootBone)) { throw new InvalidOperationException("Raiz do esqueleto nativo indisponível."); } Material val6 = MakeMaterial(((Renderer)val5).sharedMaterial, chestTexture, "ThorChest_DarkIronGold"); Material material = MakeMaterial(((Renderer)val5).sharedMaterial, gloveTexture, "ThorGloves_DarkIronGold"); LODGroup[] componentsInChildren = ((Component)val4).GetComponentsInChildren<LODGroup>(true); for (int num = 0; num < componentsInChildren.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren[num]); } Renderer[] componentsInChildren2 = ((Component)val4).GetComponentsInChildren<Renderer>(true); for (int num = 0; num < componentsInChildren2.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[num]); } val4.localPosition = Vector3.zero; val4.localRotation = Quaternion.identity; val4.localScale = Vector3.one; AddPart(val4, "ThorChest_Skinned", chest, val6, bones, rootBone); AddPart(val4, "ThorGlove_Left", left, material, bones, rootBone); AddPart(val4, "ThorGlove_Right", right, material, bones, rootBone); ((Component)val4).gameObject.AddComponent<ArmorRigCheck>().BoneNames = boneNames; SharedData shared = val3.ItemDrop.m_itemData.m_shared; shared.m_name = "$yoroshiro_thorchest_name"; shared.m_description = "$yoroshiro_thorchest_description"; shared.m_icons = (Sprite[])(object)new Sprite[1] { icon }; if (!Object.op_Implicit((Object)(object)shared.m_armorMaterial)) { throw new InvalidOperationException("Material de cobertura do corpo indisponível."); } Material val7 = new Material(shared.m_armorMaterial) { name = "ThorChest_NativeUnderlayer" }; val7.SetTexture("_ChestTex", (Texture)(object)underlayer); if (val7.HasProperty("_ChestMetal")) { val7.SetTexture("_ChestMetal", (Texture)(object)Texture2D.blackTexture); } shared.m_armorMaterial = val7; if (!ItemManager.Instance.AddItem(val3)) { throw new InvalidOperationException("Jötunn recusou o item."); } registered = true; PrefabManager.OnVanillaPrefabsAvailable -= Register; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Registrado YoroshiroThorChest. Malhas animadas, " + boneNames.Length + " ossos; shader " + ((Object)val6.shader).name + ". Requer teste visual no jogo.")); } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val) && !registered) { Object.Destroy((Object)(object)val); } PrefabManager.OnVanillaPrefabsAvailable -= Register; ((BaseUnityPlugin)this).Logger.LogError((object)("Falha ao registrar Peitoral de Thor: " + ex)); } } private static Material MakeMaterial(Material source, Texture2D texture, string name) { //IL_0006: 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_001a: Expected O, but got Unknown //IL_001b: 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_005c: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(source.shader) { name = name, mainTexture = (Texture)(object)texture }; val.mainTextureScale = Vector2.one; val.mainTextureOffset = Vector2.zero; if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)texture); } if (val.HasProperty("_Color")) { val.SetColor("_Color", Color.white); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0.35f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.24f); } if (val.HasProperty("_Cull")) { val.SetFloat("_Cull", 2f); } if (val.HasProperty("_TwoSidedNormals")) { val.SetFloat("_TwoSidedNormals", 0f); } if (val.HasProperty("_MetalGloss")) { val.SetFloat("_MetalGloss", 0.24f); } if (val.HasProperty("_UseGlossmap")) { val.SetFloat("_UseGlossmap", 0f); } if (val.HasProperty("_BumpScale")) { val.SetFloat("_BumpScale", 0f); } if (val.HasProperty("_UseStyles")) { val.SetFloat("_UseStyles", 0f); } if (val.HasProperty("_Style")) { val.SetFloat("_Style", 0f); } if (val.HasProperty("_UseStyleTex")) { val.SetFloat("_UseStyleTex", 0f); } string[] array = new string[5] { "_NORMALMAP", "_METALLICGLOSSMAP", "_ALPHATEST_ON", "_ALPHABLEND_ON", "_ALPHAPREMULTIPLY_ON" }; foreach (string text in array) { val.DisableKeyword(text); } val.SetOverrideTag("RenderType", "Opaque"); val.renderQueue = 2000; if (val.HasProperty("_Mode")) { val.SetFloat("_Mode", 0f); } if (val.HasProperty("_ZWrite")) { val.SetFloat("_ZWrite", 1f); } return val; } private static void AddPart(Transform root, string name, Mesh mesh, Material material, Transform[] bones, Transform rootBone) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if (bones == null || bones.Length != mesh.bindposes.Length || bones.Any((Transform b) => !Object.op_Implicit((Object)(object)b)) || !Object.op_Implicit((Object)(object)rootBone)) { throw new InvalidOperationException("Ossos incompatíveis: " + name); } GameObject val = new GameObject(name); val.SetActive(false); val.layer = ((Component)root).gameObject.layer; val.transform.SetParent(root, false); SkinnedMeshRenderer obj = val.AddComponent<SkinnedMeshRenderer>(); ((Renderer)obj).enabled = false; obj.rootBone = rootBone; obj.bones = bones; obj.sharedMesh = mesh; ((Renderer)obj).sharedMaterial = material; obj.quality = (SkinQuality)4; obj.updateWhenOffscreen = true; ((Renderer)obj).localBounds = new Bounds(new Vector3(0f, 1.25f, 0f), new Vector3(3f, 3f, 3f)); ((Renderer)obj).enabled = true; val.SetActive(true); } internal static Transform[] ResolveBones(string[] names, Transform[] source) { if (source == null) { throw new InvalidOperationException("Esqueleto nativo ausente."); } Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(StringComparer.Ordinal); foreach (Transform val in source) { if (Object.op_Implicit((Object)(object)val)) { dictionary[((Object)val).name] = val; } } Transform[] array = (Transform[])(object)new Transform[names.Length]; for (int j = 0; j < names.Length; j++) { if (!dictionary.TryGetValue(names[j], out array[j])) { throw new InvalidOperationException("Osso nativo ausente: " + names[j]); } } return array; } private static Texture2D LoadTexture(string path) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0021: Expected O, but got Unknown //IL_0035: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = Path.GetFileNameWithoutExtension(path) }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path))) { throw new InvalidDataException("Textura inválida: " + path); } return val; } private static Mesh LoadMesh(string path) { //IL_007e: 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_0084: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00cd: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0106: 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_012e: 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_0131: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Expected O, but got Unknown SkinData skinData = SkinData.Read(File.ReadAllBytes(path)); int count = skinData.Count; Vector3[] array = (Vector3[])(object)new Vector3[count * 2]; Vector3[] array2 = (Vector3[])(object)new Vector3[count * 2]; Vector2[] array3 = (Vector2[])(object)new Vector2[count * 2]; Color32[] array4 = (Color32[])(object)new Color32[count * 2]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[count * 2]; for (int i = 0; i < count; i++) { int num = i * 8; int num2 = i * 4; array[i] = (array[i + count] = new Vector3(skinData.Vertices[num], skinData.Vertices[num + 1], skinData.Vertices[num + 2])); array2[i] = new Vector3(skinData.Vertices[num + 3], skinData.Vertices[num + 4], skinData.Vertices[num + 5]); array2[i + count] = -array2[i]; array3[i] = (array3[i + count] = new Vector2(skinData.Vertices[num + 6], skinData.Vertices[num + 7])); array4[i] = (array4[i + count] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue)); int num3 = i; int num4 = i + count; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = skinData.BoneIndices[num2]; ((BoneWeight)(ref val)).boneIndex1 = skinData.BoneIndices[num2 + 1]; ((BoneWeight)(ref val)).boneIndex2 = skinData.BoneIndices[num2 + 2]; ((BoneWeight)(ref val)).boneIndex3 = skinData.BoneIndices[num2 + 3]; ((BoneWeight)(ref val)).weight0 = skinData.Weights[num2]; ((BoneWeight)(ref val)).weight1 = skinData.Weights[num2 + 1]; ((BoneWeight)(ref val)).weight2 = skinData.Weights[num2 + 2]; ((BoneWeight)(ref val)).weight3 = skinData.Weights[num2 + 3]; val = (array5[num3] = (array5[num4] = val)); } int[] array6 = new int[skinData.Indices.Length * 2]; Array.Copy(skinData.Indices, array6, skinData.Indices.Length); for (int j = 0; j < skinData.Indices.Length; j += 3) { int num5 = skinData.Indices.Length + j; array6[num5] = skinData.Indices[j] + count; array6[num5 + 1] = skinData.Indices[j + 2] + count; array6[num5 + 2] = skinData.Indices[j + 1] + count; } Matrix4x4[] array7 = (Matrix4x4[])(object)new Matrix4x4[skinData.BoneCount]; for (int k = 0; k < array7.Length; k++) { for (int l = 0; l < 4; l++) { for (int m = 0; m < 4; m++) { ((Matrix4x4)(ref array7[k]))[l, m] = skinData.Bindposes[k * 16 + l * 4 + m]; } } } Mesh val2 = new Mesh { name = Path.GetFileNameWithoutExtension(path), vertices = array, normals = array2, uv = array3, colors32 = array4, boneWeights = array5, bindposes = array7, triangles = array6 }; val2.RecalculateBounds(); val2.RecalculateTangents(); val2.UploadMeshData(false); return val2; } private void OnDestroy() { ThunderSet.Stop(); PrefabManager.OnVanillaPrefabsAvailable -= Register; } } public sealed class ArmorRigCheck : MonoBehaviour { public string[] BoneNames; private void Start() { if (!Object.op_Implicit((Object)(object)((Component)this).GetComponentInParent<VisEquipment>()) || BoneNames == null) { return; } SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val in componentsInChildren) { Transform[] bones = val.bones; if (bones == null || bones.Length == 0) { ((Renderer)val).enabled = false; ThorArmorPlugin.Log.LogError((object)("Armadura sem esqueleto: " + ((Object)val).name)); continue; } Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(); Transform[] array = bones; foreach (Transform val2 in array) { if (Object.op_Implicit((Object)(object)val2)) { dictionary[((Object)val2).name] = val2; } } Transform[] array2 = (Transform[])(object)new Transform[BoneNames.Length]; bool flag = true; for (int k = 0; k < array2.Length; k++) { if (!dictionary.TryGetValue(BoneNames[k], out array2[k])) { flag = false; ThorArmorPlugin.Log.LogError((object)("Osso ausente: " + BoneNames[k])); } } if (flag) { val.bones = array2; } else { ((Renderer)val).enabled = false; } } } } public sealed class SkinData { public int Count; public int BoneCount; public float[] Vertices; public int[] BoneIndices; public float[] Weights; public int[] Indices; public float[] Bindposes; public static SkinData Read(byte[] bytes) { if (bytes == null || bytes.Length < 16 || bytes.Length > 16000000) { throw new InvalidDataException("Tamanho de malha inválido."); } using MemoryStream input = new MemoryStream(bytes); using BinaryReader binaryReader = new BinaryReader(input); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "TSK1") { throw new InvalidDataException("Cabeçalho inválido."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 60000 || num2 < 3 || num2 > 180000 || num2 % 3 != 0 || num3 < 1 || num3 > 256 || bytes.Length != 16 + (long)num * 64L + (long)num2 * 4L + (long)num3 * 64L) { throw new InvalidDataException("Contagens de malha inválidas."); } SkinData skinData = new SkinData { Count = num, BoneCount = num3, Vertices = new float[num * 8], BoneIndices = new int[num * 4], Weights = new float[num * 4], Indices = new int[num2], Bindposes = new float[num3 * 16] }; for (int i = 0; i < num; i++) { for (int j = 0; j < 8; j++) { skinData.Vertices[i * 8 + j] = Float(binaryReader, 100f); } for (int k = 0; k < 4; k++) { int num4 = binaryReader.ReadInt32(); if (num4 < 0 || num4 >= num3) { throw new InvalidDataException("Osso inválido."); } skinData.BoneIndices[i * 4 + k] = num4; } float num5 = 0f; for (int l = 0; l < 4; l++) { float num6 = Float(binaryReader, 1f); if (num6 < 0f) { throw new InvalidDataException("Peso negativo."); } skinData.Weights[i * 4 + l] = num6; num5 += num6; } if (Math.Abs(num5 - 1f) > 0.001f) { throw new InvalidDataException("Pesos sem normalização."); } } for (int m = 0; m < num2; m++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num) { throw new InvalidDataException("Índice inválido."); } skinData.Indices[m] = num7; } for (int n = 0; n < skinData.Bindposes.Length; n++) { skinData.Bindposes[n] = Float(binaryReader, 10000f); } return skinData; } private static float Float(BinaryReader r, float max) { float num = r.ReadSingle(); if (float.IsNaN(num) || float.IsInfinity(num) || Math.Abs(num) > max) { throw new InvalidDataException("Valor numérico inválido."); } return num; } } internal static class ThunderSet { private static readonly Harmony Patch = new Harmony("com.yoroshiro.thorarmor.thunderset"); internal static void Start() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown Patch.Patch((MethodBase)AccessTools.Method(typeof(Player), "GetBodyArmor", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ThunderSet), "AddArmor", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void AddArmor(Player __instance, ref float __result) { if (Object.op_Implicit((Object)(object)__instance) && !((Character)__instance).IsDead() && Wearing(__instance, "m_helmetItem", "YoroshiroThorHelmet") && Wearing(__instance, "m_chestItem", "YoroshiroThorChest") && Wearing(__instance, "m_legItem", "YoroshiroThorLegwear")) { __result += 6f; } } private static bool Wearing(Player player, string slot, string prefab) { object? obj = AccessTools.Field(typeof(Humanoid), slot)?.GetValue(player); ItemData val = (ItemData)((obj is ItemData) ? obj : null); if (val != null && Object.op_Implicit((Object)(object)val.m_dropPrefab) && ((Object)val.m_dropPrefab).name == prefab) { if (val.m_shared.m_useDurability) { return val.m_durability > 0f; } return true; } return false; } internal static void Stop() { Patch.UnpatchSelf(); } }
BepInEx/plugins/Yoroshiro_ThorCape/Yoroshiro.ThorCape.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.Runtime.Versioning; using System.Text; using BepInEx; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; using Yoroshiro.ThorLegwear; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Yoroshiro")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.6.0")] [assembly: AssemblyInformationalVersion("0.1.6")] [assembly: AssemblyProduct("Yoroshiro.ThorCape")] [assembly: AssemblyTitle("Yoroshiro.ThorCape")] [assembly: AssemblyVersion("0.1.6.0")] namespace Yoroshiro.ThorLegwear { public sealed class SkinData { public int Count; public int BoneCount; public float[] Vertices; public int[] BoneIndices; public float[] Weights; public int[] Indices; public float[] Bindposes; public static SkinData Read(byte[] bytes) { if (bytes == null || bytes.Length < 16 || bytes.Length > 16000000) { throw new InvalidDataException("Tamanho de malha inválido."); } using MemoryStream input = new MemoryStream(bytes); using BinaryReader binaryReader = new BinaryReader(input); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "TSK1") { throw new InvalidDataException("Cabeçalho inválido."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 60000 || num2 < 3 || num2 > 180000 || num2 % 3 != 0 || num3 < 1 || num3 > 256 || bytes.Length != 16 + (long)num * 64L + (long)num2 * 4L + (long)num3 * 64L) { throw new InvalidDataException("Contagens de malha inválidas."); } SkinData skinData = new SkinData { Count = num, BoneCount = num3, Vertices = new float[num * 8], BoneIndices = new int[num * 4], Weights = new float[num * 4], Indices = new int[num2], Bindposes = new float[num3 * 16] }; for (int i = 0; i < num; i++) { for (int j = 0; j < 8; j++) { skinData.Vertices[i * 8 + j] = Float(binaryReader, 100f); } for (int k = 0; k < 4; k++) { int num4 = binaryReader.ReadInt32(); if (num4 < 0 || num4 >= num3) { throw new InvalidDataException("Osso inválido."); } skinData.BoneIndices[i * 4 + k] = num4; } float num5 = 0f; for (int l = 0; l < 4; l++) { float num6 = Float(binaryReader, 1f); if (num6 < 0f) { throw new InvalidDataException("Peso negativo."); } skinData.Weights[i * 4 + l] = num6; num5 += num6; } if (Math.Abs(num5 - 1f) > 0.001f) { throw new InvalidDataException("Pesos sem normalização."); } } for (int m = 0; m < num2; m++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num) { throw new InvalidDataException("Índice inválido."); } skinData.Indices[m] = num7; } for (int n = 0; n < skinData.Bindposes.Length; n++) { skinData.Bindposes[n] = Float(binaryReader, 10000f); } return skinData; } private static float Float(BinaryReader r, float max) { float num = r.ReadSingle(); if (float.IsNaN(num) || float.IsInfinity(num) || Math.Abs(num) > max) { throw new InvalidDataException("Valor numérico inválido."); } return num; } } } namespace Yoroshiro.ThorCape { [BepInPlugin("com.yoroshiro.thorcape", "Capa de Thor", "0.1.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class ThorCapePlugin : BaseUnityPlugin { private const string ItemId = "YoroshiroThorCape"; private void Awake() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { ["yoroshiro_thorcape_name"] = "Thor's Cape", ["yoroshiro_thorcape_description"] = "Midnight-blue cloth with aged gold and a fur collar. Created by Yoroshiro." }); text = "Portuguese"; localization.AddTranslation(ref text, new Dictionary<string, string> { ["yoroshiro_thorcape_name"] = "Capa de Thor", ["yoroshiro_thorcape_description"] = "Tecido azul noturno com ouro envelhecido e gola de pele. Criado por Yoroshiro." }); PrefabManager.OnVanillaPrefabsAvailable += Register; } private void Register() { //IL_007b: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: 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) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Invalid comparison between Unknown and I4 PrefabManager.OnVanillaPrefabsAvailable -= Register; GameObject val = null; try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Mesh mesh = LoadMesh(Path.Combine(directoryName, "ThorCape.skinbin")); Texture2D texture = LoadTexture(Path.Combine(directoryName, "ThorCape_BaseColor.jpg")); Texture2D val2 = LoadTexture(Path.Combine(directoryName, "ThorCape_Icon.png")); Sprite icon = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f)); string[] names = File.ReadAllLines(Path.Combine(directoryName, "ThorArmor_Bones.txt")); GameObject prefab = PrefabManager.Instance.GetPrefab("ArmorIronChest"); SkinnedMeshRenderer val3 = (Object.op_Implicit((Object)(object)prefab) ? ((IEnumerable<SkinnedMeshRenderer>)prefab.GetComponentsInChildren<SkinnedMeshRenderer>(true)).FirstOrDefault((Func<SkinnedMeshRenderer, bool>)((SkinnedMeshRenderer r) => Object.op_Implicit((Object)(object)r.rootBone) && Object.op_Implicit((Object)(object)((Renderer)r).sharedMaterial) && r.bones.Length == names.Length)) : null); if (!Object.op_Implicit((Object)(object)val3)) { throw new InvalidOperationException("Esqueleto de referência indisponível."); } Transform[] bones = ResolveBones(names, val3.bones); Material material = MakeMaterial(((Renderer)val3).sharedMaterial, texture, "ThorCape_Fabric"); ItemConfig val4 = new ItemConfig(); val4.Name = "$yoroshiro_thorcape_name"; val4.Description = "$yoroshiro_thorcape_description"; val4.Icon = icon; val4.Enabled = true; val4.Amount = 1; val4.CraftingStation = "forge"; val4.RepairStation = "forge"; val4.MinStationLevel = 3; val4.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("TrollHide", 10, 4, true), new RequirementConfig("Silver", 6, 2, true), new RequirementConfig("Thunderstone", 1, 0, true) }; CustomItem val5 = new CustomItem("YoroshiroThorCape", "CapeDeerHide", val4); val = val5.ItemPrefab; if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("CapeDeerHide indisponível."); } Transform[] array = (from Transform t in (IEnumerable)val.transform where ((Object)t).name.StartsWith("attach_", StringComparison.Ordinal) select t).ToArray(); for (int num = 0; num < array.Length; num++) { Object.DestroyImmediate((Object)(object)((Component)array[num]).gameObject); } GameObject val6 = new GameObject("attach_skin") { layer = val.layer }; val6.transform.SetParent(val.transform, false); AddPart(val6.transform, "ThorCape_Skinned", mesh, material, bones, val3.rootBone); val6.AddComponent<CapeMotion>(); val6.SetActive(false); SharedData shared = val5.ItemDrop.m_itemData.m_shared; if ((int)shared.m_itemType != 17) { throw new InvalidOperationException("O prefab de referência não usa o slot de capa."); } shared.m_setName = ""; shared.m_setSize = 0; shared.m_setStatusEffect = null; if (!ItemManager.Instance.AddItem(val5)) { throw new InvalidOperationException("Jötunn recusou a capa."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Capa de Thor registrada no slot de capa."); } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } ((BaseUnityPlugin)this).Logger.LogError((object)("Falha ao registrar a Capa de Thor: " + ex)); } } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= Register; } private static Material MakeMaterial(Material source, Texture2D texture, string name) { //IL_0006: 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_001a: Expected O, but got Unknown //IL_001b: 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_005c: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(source.shader) { name = name, mainTexture = (Texture)(object)texture }; val.mainTextureScale = Vector2.one; val.mainTextureOffset = Vector2.zero; if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)texture); } if (val.HasProperty("_Color")) { val.SetColor("_Color", Color.white); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0.04f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.1f); } if (val.HasProperty("_Cull")) { val.SetFloat("_Cull", 2f); } if (val.HasProperty("_TwoSidedNormals")) { val.SetFloat("_TwoSidedNormals", 0f); } if (val.HasProperty("_MetalGloss")) { val.SetFloat("_MetalGloss", 0.1f); } if (val.HasProperty("_UseGlossmap")) { val.SetFloat("_UseGlossmap", 0f); } if (val.HasProperty("_BumpScale")) { val.SetFloat("_BumpScale", 0f); } if (val.HasProperty("_UseStyles")) { val.SetFloat("_UseStyles", 0f); } if (val.HasProperty("_Style")) { val.SetFloat("_Style", 0f); } if (val.HasProperty("_UseStyleTex")) { val.SetFloat("_UseStyleTex", 0f); } string[] array = new string[5] { "_NORMALMAP", "_METALLICGLOSSMAP", "_ALPHATEST_ON", "_ALPHABLEND_ON", "_ALPHAPREMULTIPLY_ON" }; foreach (string text in array) { val.DisableKeyword(text); } val.SetOverrideTag("RenderType", "Opaque"); val.renderQueue = 2000; if (val.HasProperty("_Mode")) { val.SetFloat("_Mode", 0f); } if (val.HasProperty("_ZWrite")) { val.SetFloat("_ZWrite", 1f); } return val; } private static void AddPart(Transform root, string name, Mesh mesh, Material material, Transform[] bones, Transform rootBone) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if (bones == null || bones.Length != mesh.bindposes.Length || bones.Any((Transform b) => !Object.op_Implicit((Object)(object)b)) || !Object.op_Implicit((Object)(object)rootBone)) { throw new InvalidOperationException("Ossos incompatíveis: " + name); } GameObject val = new GameObject(name); val.SetActive(false); val.layer = ((Component)root).gameObject.layer; val.transform.SetParent(root, false); SkinnedMeshRenderer obj = val.AddComponent<SkinnedMeshRenderer>(); ((Renderer)obj).enabled = false; obj.rootBone = rootBone; obj.bones = bones; obj.sharedMesh = mesh; ((Renderer)obj).sharedMaterial = material; obj.quality = (SkinQuality)4; obj.updateWhenOffscreen = true; ((Renderer)obj).localBounds = new Bounds(new Vector3(0f, 1.25f, 0f), new Vector3(3f, 3f, 3f)); ((Renderer)obj).enabled = true; val.SetActive(true); } internal static Transform[] ResolveBones(string[] names, Transform[] source) { if (source == null) { throw new InvalidOperationException("Esqueleto nativo ausente."); } Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(StringComparer.Ordinal); foreach (Transform val in source) { if (Object.op_Implicit((Object)(object)val)) { dictionary[((Object)val).name] = val; } } Transform[] array = (Transform[])(object)new Transform[names.Length]; for (int j = 0; j < names.Length; j++) { if (!dictionary.TryGetValue(names[j], out array[j])) { throw new InvalidOperationException("Osso nativo ausente: " + names[j]); } } return array; } private static Texture2D LoadTexture(string path) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0021: Expected O, but got Unknown //IL_0035: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = Path.GetFileNameWithoutExtension(path) }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path))) { throw new InvalidDataException("Textura inválida: " + path); } return val; } private static Mesh LoadMesh(string path) { //IL_007e: 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_0084: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00cd: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0106: 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_012e: 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_0131: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Expected O, but got Unknown SkinData skinData = SkinData.Read(File.ReadAllBytes(path)); int count = skinData.Count; Vector3[] array = (Vector3[])(object)new Vector3[count * 2]; Vector3[] array2 = (Vector3[])(object)new Vector3[count * 2]; Vector2[] array3 = (Vector2[])(object)new Vector2[count * 2]; Color32[] array4 = (Color32[])(object)new Color32[count * 2]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[count * 2]; for (int i = 0; i < count; i++) { int num = i * 8; int num2 = i * 4; array[i] = (array[i + count] = new Vector3(skinData.Vertices[num], skinData.Vertices[num + 1], skinData.Vertices[num + 2])); array2[i] = new Vector3(skinData.Vertices[num + 3], skinData.Vertices[num + 4], skinData.Vertices[num + 5]); array2[i + count] = -array2[i]; array3[i] = (array3[i + count] = new Vector2(skinData.Vertices[num + 6], skinData.Vertices[num + 7])); array4[i] = (array4[i + count] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue)); int num3 = i; int num4 = i + count; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = skinData.BoneIndices[num2]; ((BoneWeight)(ref val)).boneIndex1 = skinData.BoneIndices[num2 + 1]; ((BoneWeight)(ref val)).boneIndex2 = skinData.BoneIndices[num2 + 2]; ((BoneWeight)(ref val)).boneIndex3 = skinData.BoneIndices[num2 + 3]; ((BoneWeight)(ref val)).weight0 = skinData.Weights[num2]; ((BoneWeight)(ref val)).weight1 = skinData.Weights[num2 + 1]; ((BoneWeight)(ref val)).weight2 = skinData.Weights[num2 + 2]; ((BoneWeight)(ref val)).weight3 = skinData.Weights[num2 + 3]; val = (array5[num3] = (array5[num4] = val)); } int[] array6 = new int[skinData.Indices.Length * 2]; Array.Copy(skinData.Indices, array6, skinData.Indices.Length); for (int j = 0; j < skinData.Indices.Length; j += 3) { int num5 = skinData.Indices.Length + j; array6[num5] = skinData.Indices[j] + count; array6[num5 + 1] = skinData.Indices[j + 2] + count; array6[num5 + 2] = skinData.Indices[j + 1] + count; } Matrix4x4[] array7 = (Matrix4x4[])(object)new Matrix4x4[skinData.BoneCount]; for (int k = 0; k < array7.Length; k++) { for (int l = 0; l < 4; l++) { for (int m = 0; m < 4; m++) { ((Matrix4x4)(ref array7[k]))[l, m] = skinData.Bindposes[k * 16 + l * 4 + m]; } } } Mesh val2 = new Mesh { name = Path.GetFileNameWithoutExtension(path), vertices = array, normals = array2, uv = array3, colors32 = array4, boneWeights = array5, bindposes = array7, triangles = array6 }; val2.RecalculateBounds(); val2.RecalculateTangents(); val2.UploadMeshData(false); return val2; } } public sealed class CapeMotion : MonoBehaviour { private SkinnedMeshRenderer cape; private Mesh animatedMesh; private Vector3[] rest; private Vector3[] vertices; private float[] freedom; private Vector3 lastPosition; private Vector3 lastForward; private float speed; private float turn; private float phase; private float hemTurn; private float hemPace; private float turnVelocity; private float paceVelocity; private void Start() { //IL_00e2: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) cape = ((Component)this).GetComponentInChildren<SkinnedMeshRenderer>(); if (!Object.op_Implicit((Object)(object)cape) || !Object.op_Implicit((Object)(object)cape.sharedMesh)) { ((Behaviour)this).enabled = false; return; } animatedMesh = Object.Instantiate<Mesh>(cape.sharedMesh); animatedMesh.MarkDynamic(); rest = animatedMesh.vertices; vertices = (Vector3[])(object)new Vector3[rest.Length]; freedom = new float[rest.Length]; for (int i = 0; i < rest.Length; i++) { freedom[i] = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.53f, 1.6f, rest[i].y)); } lastPosition = ((Component)this).transform.position; lastForward = ((Component)this).transform.forward; cape.sharedMesh = animatedMesh; } private void LateUpdate() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0195: 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_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)animatedMesh)) { return; } float deltaTime = Time.deltaTime; if (!(deltaTime <= 0f)) { Vector3 val = ((Component)this).transform.position - lastPosition; val.y = 0f; Vector3 forward = ((Component)this).transform.forward; float num = 1f - Mathf.Exp(-6f * deltaTime); float num2 = ((((Vector3)(ref val)).sqrMagnitude < 4f) ? Mathf.Clamp(((Vector3)(ref val)).magnitude / deltaTime, 0f, 8f) : 0f); speed = Mathf.Lerp(speed, num2, num); float num3 = Vector3.SignedAngle(lastForward, forward, Vector3.up) / deltaTime; turn = Mathf.Lerp(turn, Mathf.Clamp(num3 / 240f, -1f, 1f), num); lastPosition = ((Component)this).transform.position; lastForward = forward; float num4 = Mathf.InverseLerp(0f, 6f, speed); hemTurn = Mathf.SmoothDamp(hemTurn, turn, ref turnVelocity, 0.22f, 8f, deltaTime); hemPace = Mathf.SmoothDamp(hemPace, num4, ref paceVelocity, 0.26f, 8f, deltaTime); phase = Mathf.Repeat(phase + deltaTime * Mathf.Lerp(2.5f, 10f, num4), MathF.PI * 2f); for (int i = 0; i < rest.Length; i++) { Vector3 val2 = rest[i]; float num5 = freedom[i]; float num6 = Mathf.Lerp(turn, hemTurn, num5); float num7 = Mathf.Lerp(num4, hemPace, num5); float num8 = phase - 5.8f * num5 + 5.5f * val2.x; float num9 = Mathf.Sin(num8); float num10 = 0.5f + 0.5f * Mathf.Cos(num8 + 1.3f); float num11 = num5 * num5; val2.x += num5 * (0.016f + 0.027f * num7) * num9 - num11 * 0.15f * num6; float num12 = Mathf.Clamp01(0.5f + 1.4f * val2.x * num6); val2.z -= num5 * (0.004f + 0.029f * num7 + (0.01f + 0.052f * num7) * num10) + num11 * 0.065f * Mathf.Abs(num6) * num12; val2.y += num11 * (0.019f * num9 + 0.043f * num7 + 0.035f * Mathf.Abs(num6) * num12); vertices[i] = val2; } animatedMesh.vertices = vertices; } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)animatedMesh)) { Object.Destroy((Object)(object)animatedMesh); } } } }
BepInEx/plugins/Yoroshiro_ThorHelmet/Yoroshiro.ThorHelmet.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Yoroshiro")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.9.0")] [assembly: AssemblyInformationalVersion("1.2.9")] [assembly: AssemblyProduct("Yoroshiro.ThorHelmet")] [assembly: AssemblyTitle("Yoroshiro.ThorHelmet")] [assembly: AssemblyVersion("1.2.9.0")] namespace Yoroshiro.ThorHelmet; [BepInPlugin("com.yoroshiro.thorhelmet", "Capacete de Thor — Yoroshiro", "1.2.9")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class ThorHelmetPlugin : BaseUnityPlugin { [Serializable] public sealed class FitMetadata { public Vector3 center; public Vector3 size; } public const string ItemId = "YoroshiroThorHelmet"; private Mesh bodyMesh; private Mesh eyeMesh; private Mesh wingMesh; private Mesh goldTrimMesh; private Texture2D texture; private Sprite icon; private FitMetadata fit; private ConfigEntry<Vector3> offset; private ConfigEntry<Vector3> rotation; private ConfigEntry<Vector3> scale; private bool registered; private ConfigEntry<bool> showHair; private ConfigEntry<bool> showBeard; private void Awake() { //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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_01d3: 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_01a3: 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_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: 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_01fd: 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_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) offset = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Visual", "Offset", new Vector3(0f, -0.027f, 0.035f), "Ajuste de posição no encaixe nativo, em metros. Reinicie após alterar."); rotation = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Visual", "Rotation", Vector3.zero, "Ajuste de rotação XYZ, em graus. Reinicie após alterar."); scale = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Visual", "Scale", new Vector3(1.1664f, 1.1664f, 1.3392f), "Escala XYZ relativa ao corpo do capacete de ferro. As asas ficam fora dessa medida. Reinicie após alterar."); ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("Visual", "FitRevision", 0, "Migração dos valores padrão do encaixe; preserva ajustes personalizados."); Vector3 val2; if (val.Value < 1) { val2 = scale.Value - new Vector3(1.03f, 1.08f, 1.05f); if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f) { scale.Value = new Vector3(1.08f, 1.08f, 1.24f); } val2 = offset.Value; if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f) { offset.Value = new Vector3(0f, 0f, 0.035f); } val.Value = 1; ((BaseUnityPlugin)this).Config.Save(); } if (val.Value < 2) { val2 = scale.Value - new Vector3(1.08f, 1.08f, 1.24f); if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f) { scale.Value = new Vector3(1.1664f, 1.1664f, 1.3392f); } val.Value = 2; ((BaseUnityPlugin)this).Config.Save(); } if (val.Value < 3) { Vector3 value = offset.Value; if (Mathf.Abs(value.y) < 0.0001f) { offset.Value = new Vector3(value.x, -0.012f, value.z); } val.Value = 3; ((BaseUnityPlugin)this).Config.Save(); } if (val.Value < 4) { Vector3 value2 = offset.Value; if (Mathf.Abs(value2.y + 0.012f) < 0.0001f) { offset.Value = new Vector3(value2.x, -0.027f, value2.z); } val.Value = 4; ((BaseUnityPlugin)this).Config.Save(); } showHair = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual", "ShowHair", true, "Mantém o penteado original, visível onde fica para fora do casco. False oculta o cabelo inteiro. Reinicie após alterar."); showBeard = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual", "ShowBeard", true, "Mantém a barba original do personagem. False oculta a barba. Reinicie após alterar."); HelmetEyes.Configure(this); Dictionary<string, string> dictionary = new Dictionary<string, string> { { "yoroshiro_thorhelmet_name", "Capacete de Thor" }, { "yoroshiro_thorhelmet_description", "Um capacete alado com olhos ciano.\n\nSenhor do Trovão (3 peças): +6 de armadura total com capacete, peitoral e saia com botas equipados e com durabilidade.\n\nCriado por Yoroshiro." } }; CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, dictionary); CustomLocalization localization2 = LocalizationManager.Instance.GetLocalization(); text = "Portuguese"; localization2.AddTranslation(ref text, dictionary); try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); bodyMesh = LoadMesh(Path.Combine(directoryName, "ThorHelmet.meshbin"), doubleSided: true); eyeMesh = LoadMesh(Path.Combine(directoryName, "ThorHelmet_Eyes.meshbin"), doubleSided: false); wingMesh = LoadMesh(Path.Combine(directoryName, "ThorHelmet_Wings.meshbin"), doubleSided: true); goldTrimMesh = LoadMesh(Path.Combine(directoryName, "ThorHelmet_GoldTrim.meshbin"), doubleSided: true); fit = JsonUtility.FromJson<FitMetadata>(File.ReadAllText(Path.Combine(directoryName, "ThorHelmet_Fit.json"))); if (fit == null || !ValidSize(fit.size) || !Finite(fit.center)) { throw new InvalidDataException("Medidas do encaixe inválidas."); } texture = LoadTexture(Path.Combine(directoryName, "ThorHelmet_BaseColor.jpg"), mipmaps: true); Texture2D val3 = LoadTexture(Path.Combine(directoryName, "ThorHelmet_Icon.png"), mipmaps: false); icon = Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f), 100f); HelmetEyes.SetMesh(eyeMesh); PrefabManager.OnVanillaPrefabsAvailable += Register; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Capacete de Thor 1.2.8 preparado. Bônus de regeneração +25%; armadura equilibrada para as Planícies."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Falha ao preparar o Capacete de Thor: " + ex)); } } private unsafe void Register() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Expected O, but got Unknown //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: 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_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Expected O, but got Unknown //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Expected O, but got Unknown //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0618: Unknown result type (might be due to invalid IL or missing references) //IL_062b: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_064f: Unknown result type (might be due to invalid IL or missing references) //IL_065a: Unknown result type (might be due to invalid IL or missing references) //IL_0667: Expected O, but got Unknown //IL_06af: Unknown result type (might be due to invalid IL or missing references) //IL_07be: Unknown result type (might be due to invalid IL or missing references) //IL_07d6: Unknown result type (might be due to invalid IL or missing references) //IL_0839: Unknown result type (might be due to invalid IL or missing references) //IL_083b: Unknown result type (might be due to invalid IL or missing references) //IL_0855: Unknown result type (might be due to invalid IL or missing references) //IL_0857: Unknown result type (might be due to invalid IL or missing references) if (registered) { return; } GameObject val = null; try { ItemConfig val2 = new ItemConfig(); val2.Name = "$yoroshiro_thorhelmet_name"; val2.Description = "$yoroshiro_thorhelmet_description"; val2.Icon = icon; val2.Enabled = true; val2.Amount = 1; val2.CraftingStation = "forge"; val2.RepairStation = "forge"; val2.MinStationLevel = 3; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("BlackMetal", 20, 8, true), new RequirementConfig("Silver", 12, 4, true), new RequirementConfig("Thunderstone", 2, 0, true), new RequirementConfig("YmirRemains", 4, 1, true) }; CustomItem val3 = new CustomItem("YoroshiroThorHelmet", "HelmetIron", val2); val = val3.ItemPrefab; if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("HelmetIron indisponível."); } Transform val4 = val.transform.Find("attach"); if (!Object.op_Implicit((Object)(object)val4)) { throw new InvalidOperationException("Encaixe rígido attach do HelmetIron não encontrado."); } Renderer[] componentsInChildren = ((Component)val4).GetComponentsInChildren<Renderer>(true); List<Renderer> list = new List<Renderer>(); Shader val5 = null; Renderer[] array = componentsInChildren; foreach (Renderer val6 in array) { if (!(val6 is MeshRenderer) && !(val6 is SkinnedMeshRenderer)) { continue; } list.Add(val6); Material[] sharedMaterials = val6.sharedMaterials; foreach (Material val7 in sharedMaterials) { if (!Object.op_Implicit((Object)(object)val5) && Object.op_Implicit((Object)(object)val7) && Object.op_Implicit((Object)(object)val7.shader)) { val5 = val7.shader; } } } if (!Object.op_Implicit((Object)(object)val5) || list.Count == 0) { throw new InvalidOperationException("Material ou geometria nativa indisponível."); } Bounds val8 = LocalBounds(val4, list); Bounds val9; if (!ValidSize(((Bounds)(ref val8)).size)) { val9 = val8; throw new InvalidOperationException("Medidas nativas inválidas: " + ((object)(*(Bounds*)(&val9))/*cast due to .constrained prefix*/).ToString()); } Material val10 = new Material(val5) { name = "ThorHelmet_Metal", mainTexture = (Texture)(object)texture }; val10.mainTextureScale = Vector2.one; val10.mainTextureOffset = Vector2.zero; if (val10.HasProperty("_MainTex")) { val10.SetTexture("_MainTex", (Texture)(object)texture); } if (val10.HasProperty("_Color")) { val10.SetColor("_Color", new Color(0.64f, 0.69f, 0.72f, 1f)); } if (val10.HasProperty("_Metallic")) { val10.SetFloat("_Metallic", 0.55f); } if (val10.HasProperty("_Glossiness")) { val10.SetFloat("_Glossiness", 0.15f); } if (val10.HasProperty("_Style")) { val10.SetFloat("_Style", 0f); } if (val10.HasProperty("_UseStyleTex")) { val10.SetFloat("_UseStyleTex", 0f); } val10.DisableKeyword("_NORMALMAP"); val10.DisableKeyword("_METALLICGLOSSMAP"); val10.DisableKeyword("_ALPHATEST_ON"); val10.DisableKeyword("_ALPHABLEND_ON"); val10.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val10.SetOverrideTag("RenderType", "Opaque"); val10.renderQueue = 2000; if (val10.HasProperty("_Cutoff")) { val10.SetFloat("_Cutoff", 0f); } if (val10.HasProperty("_Mode")) { val10.SetFloat("_Mode", 0f); } if (val10.HasProperty("_ZWrite")) { val10.SetFloat("_ZWrite", 1f); } if (val10.HasProperty("_SrcBlend")) { val10.SetFloat("_SrcBlend", 1f); } if (val10.HasProperty("_DstBlend")) { val10.SetFloat("_DstBlend", 0f); } LODGroup[] componentsInChildren2 = ((Component)val4).GetComponentsInChildren<LODGroup>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } array = componentsInChildren; for (int i = 0; i < array.Length; i++) { Object.DestroyImmediate((Object)(object)array[i]); } GameObject val11 = new GameObject("YoroshiroThorHelmetVisual"); val11.layer = ((Component)val4).gameObject.layer; val11.transform.SetParent(val4, false); val11.AddComponent<MeshFilter>().sharedMesh = bodyMesh; ((Renderer)val11.AddComponent<MeshRenderer>()).sharedMaterial = val10; Vector3 val12 = SafeScale(scale.Value); Vector3 val13 = default(Vector3); ((Vector3)(ref val13))..ctor(((Bounds)(ref val8)).size.x / fit.size.x, ((Bounds)(ref val8)).size.y / fit.size.y, ((Bounds)(ref val8)).size.z / fit.size.z); val13 = Vector3.Scale(val13, val12); Quaternion val14 = Quaternion.Euler(Finite(rotation.Value) ? rotation.Value : Vector3.zero); val11.transform.localScale = val13; val11.transform.localRotation = val14; val11.transform.localPosition = ((Bounds)(ref val8)).center - val14 * Vector3.Scale(fit.center, val13) + (Finite(offset.Value) ? offset.Value : Vector3.zero); Material val15 = new Material(val10) { name = "ThorHelmet_AgedBronze" }; if (val15.HasProperty("_Color")) { val15.SetColor("_Color", new Color(0.95f, 0.78f, 0.46f, 1f)); } if (val15.HasProperty("_Glossiness")) { val15.SetFloat("_Glossiness", 0.32f); } GameObject val16 = new GameObject("ThorHelmet_VikingWings") { layer = val11.layer }; val16.transform.SetParent(val11.transform, false); val16.AddComponent<MeshFilter>().sharedMesh = wingMesh; ((Renderer)val16.AddComponent<MeshRenderer>()).sharedMaterial = val15; Material val17 = new Material(val10) { name = "ThorHelmet_AgedGoldTrim", mainTexture = (Texture)(object)Texture2D.whiteTexture }; if (val17.HasProperty("_MainTex")) { val17.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture); } if (val17.HasProperty("_Color")) { val17.SetColor("_Color", new Color(0.65f, 0.43f, 0.12f, 1f)); } if (val17.HasProperty("_Metallic")) { val17.SetFloat("_Metallic", 0.8f); } if (val17.HasProperty("_Glossiness")) { val17.SetFloat("_Glossiness", 0.32f); } AddPart(val11, "ThorHelmet_GoldTrim", goldTrimMesh, val17); val11.AddComponent<HelmetEyes>(); SharedData shared = val3.ItemDrop.m_itemData.m_shared; shared.m_name = "$yoroshiro_thorhelmet_name"; shared.m_description = "$yoroshiro_thorhelmet_description"; shared.m_icons = (Sprite[])(object)new Sprite[1] { icon }; shared.m_armor = 26f; shared.m_armorPerLevel = 2f; shared.m_maxQuality = 4; shared.m_weight = 3f; shared.m_movementModifier = 0f; shared.m_useDurability = true; shared.m_maxDurability = 1200f; shared.m_durabilityPerLevel = 200f; shared.m_helmetHideHair = (HelmetHairType)(!showHair.Value); shared.m_helmetHideBeard = (HelmetHairType)(!showBeard.Value); shared.m_helmetHairSettings = new List<HelmetHairSettings>(); shared.m_helmetBeardSettings = new List<HelmetHairSettings>(); if (!ItemManager.Instance.AddItem(val3)) { throw new InvalidOperationException("Jötunn recusou o item."); } registered = true; PrefabManager.OnVanillaPrefabsAvailable -= Register; ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[7] { "Registrado YoroshiroThorHelmet | encaixe HelmetIron: ", null, null, null, null, null, null }; val9 = val8; obj[1] = ((object)(*(Bounds*)(&val9))/*cast due to .constrained prefix*/).ToString(); obj[2] = " | escala: "; Vector3 val18 = val13; obj[3] = ((object)(*(Vector3*)(&val18))/*cast due to .constrained prefix*/).ToString(); obj[4] = " | shader: "; obj[5] = ((Object)val5).name; obj[6] = ". Validação visual no personagem ainda necessária."; logger.LogInfo((object)string.Concat(obj)); } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val) && !registered) { Object.Destroy((Object)(object)val); } PrefabManager.OnVanillaPrefabsAvailable -= Register; ((BaseUnityPlugin)this).Logger.LogError((object)("Falha ao registrar o Capacete de Thor: " + ex)); } } private static void AddPart(GameObject root, string name, Mesh mesh, Material material) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name) { layer = root.layer }; val.transform.SetParent(root.transform, false); val.AddComponent<MeshFilter>().sharedMesh = mesh; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material; } private static Texture2D LoadTexture(string path, bool mipmaps) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0021: Expected O, but got Unknown //IL_0035: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, mipmaps) { name = Path.GetFileNameWithoutExtension(path) }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path))) { throw new InvalidDataException("Textura inválida: " + path); } return val; } private static Mesh LoadMesh(string path, bool doubleSided) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00cd: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown HelmetMeshData helmetMeshData = HelmetMeshData.Read(File.ReadAllBytes(path)); if (doubleSided) { helmetMeshData = helmetMeshData.WithBackFaces(); } Vector3[] array = (Vector3[])(object)new Vector3[helmetMeshData.Count]; Vector3[] array2 = (Vector3[])(object)new Vector3[helmetMeshData.Count]; Vector2[] array3 = (Vector2[])(object)new Vector2[helmetMeshData.Count]; Color32[] array4 = (Color32[])(object)new Color32[helmetMeshData.Count]; for (int i = 0; i < helmetMeshData.Count; i++) { int num = i * 8; array[i] = new Vector3(helmetMeshData.Vertices[num], helmetMeshData.Vertices[num + 1], helmetMeshData.Vertices[num + 2]); array2[i] = new Vector3(helmetMeshData.Vertices[num + 3], helmetMeshData.Vertices[num + 4], helmetMeshData.Vertices[num + 5]); array3[i] = new Vector2(helmetMeshData.Vertices[num + 6], helmetMeshData.Vertices[num + 7]); array4[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } Mesh val = new Mesh { name = Path.GetFileNameWithoutExtension(path), vertices = array, normals = array2, uv = array3, colors32 = array4, triangles = helmetMeshData.Indices }; val.RecalculateBounds(); val.RecalculateTangents(); val.UploadMeshData(true); return val; } private static bool Finite(Vector3 v) { //IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references) if (Finite(v.x) && Finite(v.y)) { return Finite(v.z); } return false; } private static bool Finite(float v) { if (!float.IsNaN(v)) { return !float.IsInfinity(v); } return false; } private static bool ValidSize(Vector3 v) { //IL_0000: 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) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_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) if (Finite(v) && v.x > 0.01f && v.y > 0.01f && v.z > 0.01f && v.x < 2f && v.y < 2f) { return v.z < 2f; } return false; } private static Vector3 SafeScale(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0038: 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_0008: Unknown result type (might be due to invalid IL or missing references) if (!Finite(v)) { return Vector3.one; } return new Vector3(Mathf.Clamp(v.x, 0.5f, 2f), Mathf.Clamp(v.y, 0.5f, 2f), Mathf.Clamp(v.z, 0.5f, 2f)); } private static Bounds LocalBounds(Transform root, List<Renderer> renderers) { //IL_0004: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) //IL_0064: 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_0074: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_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_008f: Unknown result type (might be due to invalid IL or missing references) bool flag = true; Bounds result = default(Bounds); foreach (Renderer renderer in renderers) { Bounds localBounds = renderer.localBounds; for (int i = 0; i < 8; i++) { Vector3 val = ((Bounds)(ref localBounds)).center + Vector3.Scale(((Bounds)(ref localBounds)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1)))); val = root.InverseTransformPoint(((Component)renderer).transform.TransformPoint(val)); if (flag) { result = new Bounds(val, Vector3.zero); flag = false; } else { ((Bounds)(ref result)).Encapsulate(val); } } } return result; } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= Register; } } public sealed class HelmetEyes : MonoBehaviour { private static Mesh mesh; private static ConfigEntry<bool> enabledEyes; private static ConfigEntry<float> intensity; private Texture2D colorTexture; private Material glow; private Player owner; private float nextRead; private float matchedIntensity = 5f; private float charge; private int quality = 1; private bool powerActive; internal static void Configure(ThorHelmetPlugin plugin) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown enabledEyes = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Effects", "PulsingEyes", true, "Olhos ciano pulsantes. Reinicie após alterar."); intensity = ((BaseUnityPlugin)plugin).Config.Bind<float>("Effects", "RuneIntensity", 5f, new ConfigDescription("Intensidade usada sem os outros mods. Com Mjölnir, acompanha Effects.RuneIntensity dele; sem Mjölnir, acompanha o escudo quando disponível.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 5f), Array.Empty<object>())); } internal static void SetMesh(Mesh value) { mesh = value; } private void Start() { //IL_0051: 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_0066: Expected O, but got Unknown //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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00fc: Unknown result type (might be due to invalid IL or missing references) if (enabledEyes == null || !enabledEyes.Value || !Object.op_Implicit((Object)(object)mesh)) { ((Behaviour)this).enabled = false; return; } Shader val = Shader.Find("Sprites/Default"); if (!Object.op_Implicit((Object)(object)val)) { Debug.LogWarning((object)"[ThorHelmet] Shader dos olhos indisponível. O capacete continua funcional."); ((Behaviour)this).enabled = false; return; } colorTexture = new Texture2D(1, 1, (TextureFormat)4, false) { name = "ThorHelmet_RuneCyan" }; colorTexture.SetPixels32((Color32[])(object)new Color32[1] { new Color32((byte)56, (byte)224, byte.MaxValue, byte.MaxValue) }); colorTexture.Apply(false, true); glow = new Material(val) { name = "ThorHelmet_PulsingEyes", mainTexture = (Texture)(object)colorTexture, renderQueue = 3001 }; GameObject val2 = new GameObject("ThorHelmet_EyeGlow") { layer = ((Component)this).gameObject.layer }; val2.transform.SetParent(((Component)this).transform, false); val2.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer obj = val2.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = glow; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; owner = ((Component)this).GetComponentInParent<Player>(); } private static bool Flag(object value, string name) { object obj = RuneMemberReader.Read(value, name); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } private void ReadRunes() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown matchedIntensity = intensity.Value; charge = 0f; quality = 1; powerActive = false; try { ConfigEntry<float> val = default(ConfigEntry<float>); if (Chainloader.PluginInfos.TryGetValue("com.yoroshiro.thorshield", out var value) && Object.op_Implicit((Object)(object)value.Instance) && value.Instance.Config.TryGetEntry<float>(new ConfigDefinition("Effects", "RuneIntensity"), ref val)) { matchedIntensity = val.Value; } Type type = RuneMemberReader.FindType("MyValheimMod.MjolnirPlugin"); object obj = ((type == null) ? null : RuneMemberReader.Read(type, "Active")); if (obj == null) { return; } object obj2 = RuneMemberReader.Read(obj, "Config"); ConfigFile val2 = (ConfigFile)((obj2 is ConfigFile) ? obj2 : null); ConfigEntry<float> val3 = default(ConfigEntry<float>); if (val2 != null && val2.TryGetEntry<float>(new ConfigDefinition("Effects", "RuneIntensity"), ref val3)) { matchedIntensity = val3.Value; } if (!Object.op_Implicit((Object)(object)owner)) { owner = ((Component)this).GetComponentInParent<Player>(); } if (Object.op_Implicit((Object)(object)owner) && !((Object)(object)owner != (Object)(object)Player.m_localPlayer)) { object obj3 = RuneMemberReader.Read(RuneMemberReader.Read(RuneMemberReader.Read(obj, "Storm"), "Meter"), "Fraction"); if (obj3 != null) { charge = Convert.ToSingle(obj3); } powerActive = Flag(obj, "Flight") || Flag(RuneMemberReader.Read(obj, "Wings"), "Active") || Flag(RuneMemberReader.Read(obj, "Strike"), "Casting"); ItemData currentWeapon = ((Humanoid)owner).GetCurrentWeapon(); MethodInfo method = type.GetMethod("IsMjolnir", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (currentWeapon != null && method != null && (bool)method.Invoke(null, new object[1] { currentWeapon })) { quality = currentWeapon.m_quality; } } } catch { charge = 0f; quality = 1; powerActive = false; } } private void LateUpdate() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)glow)) { if (Time.time >= nextRead) { ReadRunes(); nextRead = Time.time + 0.1f; } float num = HelmetPulseRules.Gain(Time.time, matchedIntensity, charge, quality, powerActive); glow.SetColor("_Color", new Color(num, num, num, 1f)); } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)glow)) { Object.Destroy((Object)(object)glow); } if (Object.op_Implicit((Object)(object)colorTexture)) { Object.Destroy((Object)(object)colorTexture); } } } public static class HelmetPulseRules { public static float Gain(float time, float intensity, float charge, int quality, bool active) { if (float.IsNaN(time) || float.IsInfinity(time)) { time = 0f; } if (float.IsNaN(intensity) || float.IsInfinity(intensity)) { intensity = 2f; } if (float.IsNaN(charge) || float.IsInfinity(charge)) { charge = 0f; } float num = (float)(0.5 + 0.5 * Math.Sin((double)time * 4.5)); return (0.12f + 2.88f * num * num) * Math.Max(0.5f, Math.Min(5f, intensity)) * (1f + Math.Max(0f, Math.Min(1f, charge)) * 0.2f) * (1f + 0.12f * (float)(Math.Max(1, Math.Min(4, quality)) - 1)) * (active ? 1.2f : 1f); } } internal static class RuneMemberReader { private static readonly Dictionary<Type, Dictionary<string, MemberInfo>> cache = new Dictionary<Type, Dictionary<string, MemberInfo>>(); internal static object Read(object value, string name) { if (value == null) { return null; } Type type = (value as Type) ?? value.GetType(); object obj = ((value is Type) ? null : value); if (!cache.TryGetValue(type, out var value2)) { value2 = new Dictionary<string, MemberInfo>(); cache[type] = value2; } if (!value2.TryGetValue(name, out var value3)) { Type type2 = type; while (type2 != null && value3 == null) { PropertyInfo property = type2.GetProperty(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); value3 = ((!(property != null) || property.GetIndexParameters().Length != 0 || !(property.GetGetMethod(nonPublic: true) != null)) ? ((MemberInfo)type2.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) : ((MemberInfo)property)); type2 = type2.BaseType; } value2[name] = value3; } if (value3 is PropertyInfo propertyInfo) { return propertyInfo.GetValue(obj, null); } if (value3 is FieldInfo fieldInfo) { return fieldInfo.GetValue(obj); } return null; } internal static Type FindType(string name) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType(name, throwOnError: false); if (type != null) { return type; } } return null; } } public sealed class HelmetMeshData { public readonly float[] Vertices; public readonly int[] Indices; public int Count => Vertices.Length / 8; private HelmetMeshData(float[] v, int[] i) { Vertices = v; Indices = i; } public HelmetMeshData WithBackFaces() { float[] array = new float[Vertices.Length * 2]; Array.Copy(Vertices, array, Vertices.Length); Array.Copy(Vertices, 0, array, Vertices.Length, Vertices.Length); for (int i = Vertices.Length; i < array.Length; i += 8) { array[i + 3] = 0f - array[i + 3]; array[i + 4] = 0f - array[i + 4]; array[i + 5] = 0f - array[i + 5]; } int[] array2 = new int[Indices.Length * 2]; Array.Copy(Indices, array2, Indices.Length); for (int j = 0; j < Indices.Length; j += 3) { array2[Indices.Length + j] = Indices[j] + Count; array2[Indices.Length + j + 1] = Indices[j + 2] + Count; array2[Indices.Length + j + 2] = Indices[j + 1] + Count; } return new HelmetMeshData(array, array2); } public static HelmetMeshData Read(byte[] bytes) { if (bytes == null || bytes.Length < 16 || bytes.Length > 4000000) { throw new InvalidDataException("Invalid helmet mesh size"); } using MemoryStream input = new MemoryStream(bytes); using BinaryReader binaryReader = new BinaryReader(input); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(8)) != "YTHM1\0\0\0") { throw new InvalidDataException("Invalid helmet mesh header"); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); if (num < 3 || num > 50000 || num2 < 3 || num2 > 150000 || num2 % 3 != 0 || bytes.Length != 16 + (long)num * 32L + (long)num2 * 4L) { throw new InvalidDataException("Invalid helmet mesh counts"); } float[] array = new float[num * 8]; for (int i = 0; i < array.Length; i++) { float num3 = binaryReader.ReadSingle(); if (float.IsNaN(num3) || float.IsInfinity(num3) || Math.Abs(num3) > 100f) { throw new InvalidDataException("Invalid vertex"); } array[i] = num3; } int[] array2 = new int[num2]; for (int j = 0; j < array2.Length; j++) { array2[j] = binaryReader.ReadInt32(); if (array2[j] < 0 || array2[j] >= num) { throw new InvalidDataException("Invalid mesh index"); } } return new HelmetMeshData(array, array2); } }
BepInEx/plugins/Yoroshiro_ThorLegwear/Yoroshiro.ThorLegwear.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Yoroshiro")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.5.0")] [assembly: AssemblyInformationalVersion("0.1.5")] [assembly: AssemblyProduct("Yoroshiro.ThorLegwear")] [assembly: AssemblyTitle("Yoroshiro.ThorLegwear")] [assembly: AssemblyVersion("0.1.5.0")] namespace Yoroshiro.ThorLegwear; [BepInPlugin("com.yoroshiro.thorlegwear", "Saia e Botas de Thor — Yoroshiro", "0.1.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class ThorLegwearPlugin : BaseUnityPlugin { public const string ItemId = "YoroshiroThorLegwear"; internal static ManualLogSource Log; private Mesh skirt; private Mesh boots; private Texture2D skirtTexture; private Texture2D bootTexture; private Texture2D underlayer; private Sprite icon; private string[] boneNames; private bool registered; private void Awake() { //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Dictionary<string, string> dictionary = new Dictionary<string, string> { { "yoroshiro_thorlegwear_name", "Saia e Botas de Thor" }, { "yoroshiro_thorlegwear_description", "Saia e botas de ferro escuro com detalhes dourados.\n\nSenhor do Trovão (3 peças): +6 de armadura total com capacete, peitoral e saia com botas equipados e com durabilidade.\n\nCriado por Yoroshiro." } }; CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, dictionary); CustomLocalization localization2 = LocalizationManager.Instance.GetLocalization(); text = "Portuguese"; localization2.AddTranslation(ref text, dictionary); try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); boneNames = File.ReadAllLines(Path.Combine(directoryName, "ThorArmor_Bones.txt")); skirt = LoadMesh(Path.Combine(directoryName, "ThorSkirt.skinbin")); boots = LoadMesh(Path.Combine(directoryName, "ThorBoots.skinbin")); if (skirt.bindposes.Length != boneNames.Length || boots.bindposes.Length != boneNames.Length) { throw new InvalidDataException("Lista de ossos incompatível."); } skirtTexture = LoadTexture(Path.Combine(directoryName, "ThorSkirt_BaseColor.jpg")); bootTexture = LoadTexture(Path.Combine(directoryName, "ThorBoots_BaseColor.jpg")); underlayer = LoadTexture(Path.Combine(directoryName, "ThorLegwear_Underlayer.png")); Texture2D val = LoadTexture(Path.Combine(directoryName, "ThorLegwear_Icon.png")); icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); PrefabManager.OnVanillaPrefabsAvailable += Register; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Saia e botas preparadas; aguardando registro nativo."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Falha ao preparar o Saia e Botas de Thor: " + ex)); } } private void Register() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown if (registered) { return; } GameObject val = null; try { ItemConfig val2 = new ItemConfig(); val2.Name = "$yoroshiro_thorlegwear_name"; val2.Description = "$yoroshiro_thorlegwear_description"; val2.Icon = icon; val2.Enabled = true; val2.Amount = 1; val2.CraftingStation = "forge"; val2.RepairStation = "forge"; val2.MinStationLevel = 3; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("BlackMetal", 20, 8, true), new RequirementConfig("Silver", 12, 4, true), new RequirementConfig("Thunderstone", 2, 0, true), new RequirementConfig("YmirRemains", 4, 1, true) }; CustomItem val3 = new CustomItem("YoroshiroThorLegwear", "ArmorIronLegs", val2); val = val3.ItemPrefab; if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("ArmorIronLegs indisponível."); } Transform val4 = val.transform.Find("attach_skin"); if (!Object.op_Implicit((Object)(object)val4)) { throw new InvalidOperationException("Encaixe animado nativo indisponível."); } SkinnedMeshRenderer val5 = ((IEnumerable<SkinnedMeshRenderer>)((Component)val4).GetComponentsInChildren<SkinnedMeshRenderer>(true)).FirstOrDefault((Func<SkinnedMeshRenderer, bool>)((SkinnedMeshRenderer r) => Object.op_Implicit((Object)(object)((Renderer)r).sharedMaterial) && Object.op_Implicit((Object)(object)((Renderer)r).sharedMaterial.shader))); if (!Object.op_Implicit((Object)(object)val5)) { throw new InvalidOperationException("Material da armadura de ferro indisponível."); } Transform[] bones = ResolveBones(boneNames, val5.bones); Transform rootBone = val5.rootBone; if (!Object.op_Implicit((Object)(object)rootBone)) { throw new InvalidOperationException("Raiz do esqueleto nativo indisponível."); } Material val6 = MakeMaterial(((Renderer)val5).sharedMaterial, skirtTexture, "ThorSkirt_DarkIronGold"); Material material = MakeMaterial(((Renderer)val5).sharedMaterial, bootTexture, "ThorBoots_DarkIronGold"); LODGroup[] componentsInChildren = ((Component)val4).GetComponentsInChildren<LODGroup>(true); for (int num = 0; num < componentsInChildren.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren[num]); } Renderer[] componentsInChildren2 = ((Component)val4).GetComponentsInChildren<Renderer>(true); for (int num = 0; num < componentsInChildren2.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[num]); } val4.localPosition = Vector3.zero; val4.localRotation = Quaternion.identity; val4.localScale = Vector3.one; AddPart(val4, "ThorSkirt_Skinned", skirt, val6, bones, rootBone); AddPart(val4, "ThorBoots_Skinned", boots, material, bones, rootBone); ((Component)val4).gameObject.AddComponent<ArmorRigCheck>().BoneNames = boneNames; SharedData shared = val3.ItemDrop.m_itemData.m_shared; shared.m_name = "$yoroshiro_thorlegwear_name"; shared.m_description = "$yoroshiro_thorlegwear_description"; shared.m_icons = (Sprite[])(object)new Sprite[1] { icon }; if (!Object.op_Implicit((Object)(object)shared.m_armorMaterial)) { throw new InvalidOperationException("Material de cobertura do corpo indisponível."); } Material val7 = new Material(shared.m_armorMaterial) { name = "ThorLegwear_NativeUnderlayer" }; val7.SetTexture("_LegsTex", (Texture)(object)underlayer); if (val7.HasProperty("_LegsMetal")) { val7.SetTexture("_LegsMetal", (Texture)(object)Texture2D.blackTexture); } if (val7.HasProperty("_LegsBumpMap")) { val7.SetTexture("_LegsBumpMap", (Texture)(object)Texture2D.normalTexture); } shared.m_armorMaterial = val7; if (!ItemManager.Instance.AddItem(val3)) { throw new InvalidOperationException("Jötunn recusou o item."); } registered = true; PrefabManager.OnVanillaPrefabsAvailable -= Register; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Registrado YoroshiroThorLegwear. Malhas animadas, " + boneNames.Length + " ossos; shader " + ((Object)val6.shader).name + ". Requer teste visual no jogo.")); } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val) && !registered) { Object.Destroy((Object)(object)val); } PrefabManager.OnVanillaPrefabsAvailable -= Register; ((BaseUnityPlugin)this).Logger.LogError((object)("Falha ao registrar Saia e Botas de Thor: " + ex)); } } private static Material MakeMaterial(Material source, Texture2D texture, string name) { //IL_0006: 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_001a: Expected O, but got Unknown //IL_001b: 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_005c: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(source.shader) { name = name, mainTexture = (Texture)(object)texture }; val.mainTextureScale = Vector2.one; val.mainTextureOffset = Vector2.zero; if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)texture); } if (val.HasProperty("_Color")) { val.SetColor("_Color", Color.white); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0.35f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.24f); } if (val.HasProperty("_Cull")) { val.SetFloat("_Cull", 2f); } if (val.HasProperty("_TwoSidedNormals")) { val.SetFloat("_TwoSidedNormals", 0f); } if (val.HasProperty("_MetalGloss")) { val.SetFloat("_MetalGloss", 0.24f); } if (val.HasProperty("_UseGlossmap")) { val.SetFloat("_UseGlossmap", 0f); } if (val.HasProperty("_BumpScale")) { val.SetFloat("_BumpScale", 0f); } if (val.HasProperty("_UseStyles")) { val.SetFloat("_UseStyles", 0f); } if (val.HasProperty("_Style")) { val.SetFloat("_Style", 0f); } if (val.HasProperty("_UseStyleTex")) { val.SetFloat("_UseStyleTex", 0f); } string[] array = new string[5] { "_NORMALMAP", "_METALLICGLOSSMAP", "_ALPHATEST_ON", "_ALPHABLEND_ON", "_ALPHAPREMULTIPLY_ON" }; foreach (string text in array) { val.DisableKeyword(text); } val.SetOverrideTag("RenderType", "Opaque"); val.renderQueue = 2000; if (val.HasProperty("_Mode")) { val.SetFloat("_Mode", 0f); } if (val.HasProperty("_ZWrite")) { val.SetFloat("_ZWrite", 1f); } return val; } private static void AddPart(Transform root, string name, Mesh mesh, Material material, Transform[] bones, Transform rootBone) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if (bones == null || bones.Length != mesh.bindposes.Length || bones.Any((Transform b) => !Object.op_Implicit((Object)(object)b)) || !Object.op_Implicit((Object)(object)rootBone)) { throw new InvalidOperationException("Ossos incompatíveis: " + name); } GameObject val = new GameObject(name); val.SetActive(false); val.layer = ((Component)root).gameObject.layer; val.transform.SetParent(root, false); SkinnedMeshRenderer obj = val.AddComponent<SkinnedMeshRenderer>(); ((Renderer)obj).enabled = false; obj.rootBone = rootBone; obj.bones = bones; obj.sharedMesh = mesh; ((Renderer)obj).sharedMaterial = material; obj.quality = (SkinQuality)4; obj.updateWhenOffscreen = true; ((Renderer)obj).localBounds = new Bounds(new Vector3(0f, 1.25f, 0f), new Vector3(3f, 3f, 3f)); ((Renderer)obj).enabled = true; val.SetActive(true); } internal static Transform[] ResolveBones(string[] names, Transform[] source) { if (source == null) { throw new InvalidOperationException("Esqueleto nativo ausente."); } Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(StringComparer.Ordinal); foreach (Transform val in source) { if (Object.op_Implicit((Object)(object)val)) { dictionary[((Object)val).name] = val; } } Transform[] array = (Transform[])(object)new Transform[names.Length]; for (int j = 0; j < names.Length; j++) { if (!dictionary.TryGetValue(names[j], out array[j])) { throw new InvalidOperationException("Osso nativo ausente: " + names[j]); } } return array; } private static Texture2D LoadTexture(string path) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0021: Expected O, but got Unknown //IL_0035: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = Path.GetFileNameWithoutExtension(path) }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path))) { throw new InvalidDataException("Textura inválida: " + path); } return val; } private static Mesh LoadMesh(string path) { //IL_007e: 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_0084: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00cd: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0106: 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_012e: 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_0131: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Expected O, but got Unknown SkinData skinData = SkinData.Read(File.ReadAllBytes(path)); int count = skinData.Count; Vector3[] array = (Vector3[])(object)new Vector3[count * 2]; Vector3[] array2 = (Vector3[])(object)new Vector3[count * 2]; Vector2[] array3 = (Vector2[])(object)new Vector2[count * 2]; Color32[] array4 = (Color32[])(object)new Color32[count * 2]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[count * 2]; for (int i = 0; i < count; i++) { int num = i * 8; int num2 = i * 4; array[i] = (array[i + count] = new Vector3(skinData.Vertices[num], skinData.Vertices[num + 1], skinData.Vertices[num + 2])); array2[i] = new Vector3(skinData.Vertices[num + 3], skinData.Vertices[num + 4], skinData.Vertices[num + 5]); array2[i + count] = -array2[i]; array3[i] = (array3[i + count] = new Vector2(skinData.Vertices[num + 6], skinData.Vertices[num + 7])); array4[i] = (array4[i + count] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue)); int num3 = i; int num4 = i + count; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = skinData.BoneIndices[num2]; ((BoneWeight)(ref val)).boneIndex1 = skinData.BoneIndices[num2 + 1]; ((BoneWeight)(ref val)).boneIndex2 = skinData.BoneIndices[num2 + 2]; ((BoneWeight)(ref val)).boneIndex3 = skinData.BoneIndices[num2 + 3]; ((BoneWeight)(ref val)).weight0 = skinData.Weights[num2]; ((BoneWeight)(ref val)).weight1 = skinData.Weights[num2 + 1]; ((BoneWeight)(ref val)).weight2 = skinData.Weights[num2 + 2]; ((BoneWeight)(ref val)).weight3 = skinData.Weights[num2 + 3]; val = (array5[num3] = (array5[num4] = val)); } int[] array6 = new int[skinData.Indices.Length * 2]; Array.Copy(skinData.Indices, array6, skinData.Indices.Length); for (int j = 0; j < skinData.Indices.Length; j += 3) { int num5 = skinData.Indices.Length + j; array6[num5] = skinData.Indices[j] + count; array6[num5 + 1] = skinData.Indices[j + 2] + count; array6[num5 + 2] = skinData.Indices[j + 1] + count; } Matrix4x4[] array7 = (Matrix4x4[])(object)new Matrix4x4[skinData.BoneCount]; for (int k = 0; k < array7.Length; k++) { for (int l = 0; l < 4; l++) { for (int m = 0; m < 4; m++) { ((Matrix4x4)(ref array7[k]))[l, m] = skinData.Bindposes[k * 16 + l * 4 + m]; } } } Mesh val2 = new Mesh { name = Path.GetFileNameWithoutExtension(path), vertices = array, normals = array2, uv = array3, colors32 = array4, boneWeights = array5, bindposes = array7, triangles = array6 }; val2.RecalculateBounds(); val2.RecalculateTangents(); val2.UploadMeshData(false); return val2; } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= Register; } } public sealed class ArmorRigCheck : MonoBehaviour { public string[] BoneNames; private void Start() { if (!Object.op_Implicit((Object)(object)((Component)this).GetComponentInParent<VisEquipment>()) || BoneNames == null) { return; } SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val in componentsInChildren) { Transform[] bones = val.bones; if (bones == null || bones.Length == 0) { ((Renderer)val).enabled = false; ThorLegwearPlugin.Log.LogError((object)("Armadura sem esqueleto: " + ((Object)val).name)); continue; } Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(); Transform[] array = bones; foreach (Transform val2 in array) { if (Object.op_Implicit((Object)(object)val2)) { dictionary[((Object)val2).name] = val2; } } Transform[] array2 = (Transform[])(object)new Transform[BoneNames.Length]; bool flag = true; for (int k = 0; k < array2.Length; k++) { if (!dictionary.TryGetValue(BoneNames[k], out array2[k])) { flag = false; ThorLegwearPlugin.Log.LogError((object)("Osso ausente: " + BoneNames[k])); } } if (flag) { val.bones = array2; } else { ((Renderer)val).enabled = false; } } } } public sealed class SkinData { public int Count; public int BoneCount; public float[] Vertices; public int[] BoneIndices; public float[] Weights; public int[] Indices; public float[] Bindposes; public static SkinData Read(byte[] bytes) { if (bytes == null || bytes.Length < 16 || bytes.Length > 16000000) { throw new InvalidDataException("Tamanho de malha inválido."); } using MemoryStream input = new MemoryStream(bytes); using BinaryReader binaryReader = new BinaryReader(input); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "TSK1") { throw new InvalidDataException("Cabeçalho inválido."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 60000 || num2 < 3 || num2 > 180000 || num2 % 3 != 0 || num3 < 1 || num3 > 256 || bytes.Length != 16 + (long)num * 64L + (long)num2 * 4L + (long)num3 * 64L) { throw new InvalidDataException("Contagens de malha inválidas."); } SkinData skinData = new SkinData { Count = num, BoneCount = num3, Vertices = new float[num * 8], BoneIndices = new int[num * 4], Weights = new float[num * 4], Indices = new int[num2], Bindposes = new float[num3 * 16] }; for (int i = 0; i < num; i++) { for (int j = 0; j < 8; j++) { skinData.Vertices[i * 8 + j] = Float(binaryReader, 100f); } for (int k = 0; k < 4; k++) { int num4 = binaryReader.ReadInt32(); if (num4 < 0 || num4 >= num3) { throw new InvalidDataException("Osso inválido."); } skinData.BoneIndices[i * 4 + k] = num4; } float num5 = 0f; for (int l = 0; l < 4; l++) { float num6 = Float(binaryReader, 1f); if (num6 < 0f) { throw new InvalidDataException("Peso negativo."); } skinData.Weights[i * 4 + l] = num6; num5 += num6; } if (Math.Abs(num5 - 1f) > 0.001f) { throw new InvalidDataException("Pesos sem normalização."); } } for (int m = 0; m < num2; m++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num) { throw new InvalidDataException("Índice inválido."); } skinData.Indices[m] = num7; } for (int n = 0; n < skinData.Bindposes.Length; n++) { skinData.Bindposes[n] = Float(binaryReader, 10000f); } return skinData; } private static float Float(BinaryReader r, float max) { float num = r.ReadSingle(); if (float.IsNaN(num) || float.IsInfinity(num) || Math.Abs(num) > max) { throw new InvalidDataException("Valor numérico inválido."); } return num; } }
BepInEx/plugins/Yoroshiro_ThorShield/Yoroshiro.ThorShield.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Yoroshiro")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.3.5.0")] [assembly: AssemblyInformationalVersion("1.3.5")] [assembly: AssemblyProduct("Yoroshiro.ThorShield")] [assembly: AssemblyTitle("Yoroshiro.ThorShield")] [assembly: AssemblyVersion("1.3.5.0")] namespace Yoroshiro.ThorShield; [BepInPlugin("com.yoroshiro.thorshield", "Escudo de Thor — Yoroshiro", "1.3.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class ThorShieldPlugin : BaseUnityPlugin { private const string ItemId = "YoroshiroThorShield"; private Mesh shieldMesh; private Texture2D shieldTexture; private Sprite icon; private bool registered; private ConfigEntry<float> diameter; private ConfigEntry<float> block; private ConfigEntry<float> perLevel; private ConfigEntry<float> parry; private ConfigEntry<float> clearance; private ConfigEntry<float> upperTilt; private ConfigEntry<Vector3> offset; private ConfigEntry<Vector3> rotation; private ConfigEntry<bool> lowPoly; private ConfigEntry<bool> pixelTexture; private ConfigEntry<int> pixelResolution; private void Awake() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Expected O, but got Unknown //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Expected O, but got Unknown //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Expected O, but got Unknown //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Expected O, but got Unknown //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Expected O, but got Unknown //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_0775: Expected O, but got Unknown //IL_07b6: Unknown result type (might be due to invalid IL or missing references) //IL_07c5: Unknown result type (might be due to invalid IL or missing references) //IL_072d: Unknown result type (might be due to invalid IL or missing references) //IL_0732: Unknown result type (might be due to invalid IL or missing references) //IL_073d: Unknown result type (might be due to invalid IL or missing references) //IL_0749: Expected O, but got Unknown //IL_069b: Unknown result type (might be due to invalid IL or missing references) //IL_06a0: Unknown result type (might be due to invalid IL or missing references) //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06c4: Unknown result type (might be due to invalid IL or missing references) //IL_06dc: Unknown result type (might be due to invalid IL or missing references) //IL_06f9: Unknown result type (might be due to invalid IL or missing references) //IL_06fe: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Unknown result type (might be due to invalid IL or missing references) ShieldRunes.Configure(this); lowPoly = ((BaseUnityPlugin)this).Config.Bind<bool>("Style", "LowPoly", true, "Use the lower-polygon, flat-shaded shield. False restores the original mesh. Restart after changes."); pixelTexture = ((BaseUnityPlugin)this).Config.Bind<bool>("Style", "PixelTexture", true, "Use a pixelated version of the original gold/blue texture. False restores the original texture filtering. Restart after changes."); pixelResolution = ((BaseUnityPlugin)this).Config.Bind<int>("Style", "PixelResolution", 128, new ConfigDescription("Pixelated texture size. Lower values make larger visible pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(32, 512), Array.Empty<object>())); clearance = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "ForearmClearanceMeters", 0.05f, new ConfigDescription("Small outward clearance from the forearm in meters. Restart after changes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.08f), Array.Empty<object>())); upperTilt = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "UpperEdgeTiltDegrees", -25f, new ConfigDescription("Shield pitch correction relative to the native attachment, keeping the visual grip center stable. Restart after changes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-60f, 60f), Array.Empty<object>())); diameter = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "DiameterMeters", 0.76f, new ConfigDescription("Shield diameter in meters. Restart the game after changes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 1.3f), Array.Empty<object>())); offset = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Visual", "GripOffset", Vector3.zero, "Additional offset in the native shield attachment frame. Restart after changes."); rotation = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Visual", "GripRotation", Vector3.zero, "Additional XYZ rotation in degrees. Restart after changes."); ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("Visual", "FitRevision", 0, "One-time migration of old default shield dimensions. Custom values are preserved."); if (val.Value < 1) { if (Mathf.Approximately(diameter.Value, 0.88f)) { diameter.Value = 0.76f; } if (Mathf.Approximately(clearance.Value, 0.015f)) { clearance.Value = 0.05f; } if (Mathf.Approximately(upperTilt.Value, 6f)) { upperTilt.Value = 12f; } val.Value = 1; ((BaseUnityPlugin)this).Config.Save(); } if (val.Value < 2) { if (Mathf.Approximately(upperTilt.Value, 12f)) { upperTilt.Value = -25f; } if (Mathf.Approximately(clearance.Value, 0.05f)) { clearance.Value = 0.08f; } val.Value = 2; ((BaseUnityPlugin)this).Config.Save(); } if (val.Value < 3) { if (Mathf.Approximately(clearance.Value, 0.08f)) { clearance.Value = 0.05f; } val.Value = 3; ((BaseUnityPlugin)this).Config.Save(); } block = ((BaseUnityPlugin)this).Config.Bind<float>("Balance", "BlockArmor", 78f, new ConfigDescription("Base block armor, before the native blocking skill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 130f), Array.Empty<object>())); perLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Balance", "BlockArmorPerQuality", 6f, new ConfigDescription("Block armor gained per quality level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>())); parry = ((BaseUnityPlugin)this).Config.Bind<float>("Balance", "ParryMultiplier", 1.5f, new ConfigDescription("Native timed-block multiplier. This mod adds no automatic parry or invulnerability.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2.5f), Array.Empty<object>())); CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "yoroshiro_thorshield_name", "Escudo de Thor" }, { "yoroshiro_thorshield_description", "Um escudo dourado com o emblema do deus do trovão.\n\nCriado por Yoroshiro." } }); CustomLocalization localization2 = LocalizationManager.Instance.GetLocalization(); text = "Portuguese"; localization2.AddTranslation(ref text, new Dictionary<string, string> { { "yoroshiro_thorshield_name", "Escudo de Thor" }, { "yoroshiro_thorshield_description", "Um escudo dourado com o emblema do deus do trovão.\n\nCriado por Yoroshiro." } }); try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); ShieldRunes.Prepare(Path.Combine(directoryName, lowPoly.Value ? "ThorShield_LowPoly.meshbin" : "ThorShield.meshbin")); ShieldMeshData shieldMeshData = ShieldMeshData.Read(File.ReadAllBytes(Path.Combine(directoryName, lowPoly.Value ? "ThorShield_LowPoly.meshbin" : "ThorShield.meshbin"))).WithBackFaces(); shieldMesh = new Mesh { name = "Yoroshiro_ThorShield" }; Vector3[] array = (Vector3[])(object)new Vector3[shieldMeshData.Count]; Vector3[] array2 = (Vector3[])(object)new Vector3[shieldMeshData.Count]; Vector2[] array3 = (Vector2[])(object)new Vector2[shieldMeshData.Count]; Color32[] array4 = (Color32[])(object)new Color32[shieldMeshData.Count]; for (int i = 0; i < shieldMeshData.Count; i++) { int num = i * 8; array[i] = new Vector3(shieldMeshData.Vertices[num], shieldMeshData.Vertices[num + 1], shieldMeshData.Vertices[num + 2]); array2[i] = new Vector3(shieldMeshData.Vertices[num + 3], shieldMeshData.Vertices[num + 4], shieldMeshData.Vertices[num + 5]); array3[i] = new Vector2(shieldMeshData.Vertices[num + 6], shieldMeshData.Vertices[num + 7]); array4[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } shieldMesh.vertices = array; shieldMesh.normals = array2; shieldMesh.uv = array3; shieldMesh.colors32 = array4; shieldMesh.triangles = shieldMeshData.Indices; shieldMesh.RecalculateBounds(); shieldMesh.RecalculateTangents(); shieldMesh.UploadMeshData(true); shieldTexture = new Texture2D(2, 2, (TextureFormat)4, true); if (!ImageConversion.LoadImage(shieldTexture, File.ReadAllBytes(Path.Combine(directoryName, "ThorShield_BaseColor.jpg")))) { throw new Exception("Invalid shield texture"); } ((Object)shieldTexture).name = "Yoroshiro_ThorShield_BaseColor"; if (pixelTexture.Value) { Texture2D val2 = shieldTexture; int num2 = Mathf.Clamp(pixelResolution.Value, 32, 512); Color32[] array5 = (Color32[])(object)new Color32[num2 * num2]; for (int j = 0; j < num2; j++) { for (int k = 0; k < num2; k++) { Color pixelBilinear = val2.GetPixelBilinear(((float)k + 0.5f) / (float)num2, ((float)j + 0.5f) / (float)num2); array5[j * num2 + k] = Color32.op_Implicit(new Color(Mathf.Round(pixelBilinear.r * 31f) / 31f, Mathf.Round(pixelBilinear.g * 31f) / 31f, Mathf.Round(pixelBilinear.b * 31f) / 31f, 1f)); } } shieldTexture = new Texture2D(num2, num2, (TextureFormat)4, false) { name = "Yoroshiro_ThorShield_Pixels", filterMode = (FilterMode)0 }; shieldTexture.SetPixels32(array5); shieldTexture.Apply(false, true); Object.Destroy((Object)(object)val2); } Texture2D val3 = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val3, File.ReadAllBytes(Path.Combine(directoryName, "ThorShield_Icon.png")))) { throw new Exception("Invalid inventory icon"); } icon = Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f), 100f); PrefabManager.OnVanillaPrefabsAvailable += Register; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Escudo de Thor 1.3.4 — Yoroshiro. Independent from Mjolnir."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not prepare Thor's Shield: " + ex)); } } private unsafe void Register() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Expected O, but got Unknown //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Expected O, but got Unknown //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0513: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Expected O, but got Unknown //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Expected O, but got Unknown //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_06d5: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_06f4: Unknown result type (might be due to invalid IL or missing references) //IL_06f9: Unknown result type (might be due to invalid IL or missing references) //IL_06fd: Unknown result type (might be due to invalid IL or missing references) //IL_0874: Unknown result type (might be due to invalid IL or missing references) //IL_0876: Unknown result type (might be due to invalid IL or missing references) //IL_0890: Unknown result type (might be due to invalid IL or missing references) //IL_0892: Unknown result type (might be due to invalid IL or missing references) if (registered) { return; } try { ItemConfig val = new ItemConfig(); val.Name = "$yoroshiro_thorshield_name"; val.Description = "$yoroshiro_thorshield_description"; val.Enabled = true; val.Amount = 1; val.CraftingStation = "blackforge"; val.RepairStation = "blackforge"; val.MinStationLevel = 2; val.Icon = icon; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("BlackMetal", 25, 6, true), new RequirementConfig("Silver", 10, 3, true), new RequirementConfig("Thunderstone", 3, 1, true) }; ItemConfig val2 = val; CustomItem val3 = new CustomItem("YoroshiroThorShield", "ShieldBlackmetal", val2); GameObject itemPrefab = val3.ItemPrefab; if (!Object.op_Implicit((Object)(object)itemPrefab)) { throw new Exception("Native ShieldBlackmetal clone unavailable"); } Transform val4 = itemPrefab.transform.Find("attach"); if (!Object.op_Implicit((Object)(object)val4)) { throw new Exception("Native shield attachment missing"); } Renderer[] componentsInChildren = ((Component)val4).GetComponentsInChildren<Renderer>(true); if (componentsInChildren.Length == 0) { throw new Exception("Native attachment has no reference renderer"); } List<Renderer> list = new List<Renderer>(); Renderer[] array = componentsInChildren; foreach (Renderer val5 in array) { if (val5 is MeshRenderer || val5 is SkinnedMeshRenderer) { list.Add(val5); } } if (list.Count == 0) { throw new Exception("Native shield has no mesh renderer"); } Bounds val6 = LocalBounds(val4, list.ToArray()); int num = ((!(((Bounds)(ref val6)).size.x < ((Bounds)(ref val6)).size.y)) ? ((((Bounds)(ref val6)).size.y < ((Bounds)(ref val6)).size.z) ? 1 : 2) : ((!(((Bounds)(ref val6)).size.x < ((Bounds)(ref val6)).size.z)) ? 2 : 0)); Vector3 val7 = Axis(num); Vector3 val8 = ((num == 1) ? Vector3.right : Vector3.up); if (Vector3.Dot(((Bounds)(ref val6)).center, val7) < -0.01f) { val7 = -val7; } Shader val9 = null; foreach (Renderer item in list) { Material[] sharedMaterials = item.sharedMaterials; foreach (Material val10 in sharedMaterials) { if (Object.op_Implicit((Object)(object)val10) && Object.op_Implicit((Object)(object)val10.shader)) { val9 = val10.shader; break; } } if (Object.op_Implicit((Object)(object)val9)) { break; } } if (!Object.op_Implicit((Object)(object)val9)) { throw new Exception("Native ShieldBlackmetal has no supported material shader"); } Material val11 = new Material(val9) { name = "Yoroshiro_ThorShield_GoldBlue" }; val11.mainTexture = (Texture)(object)shieldTexture; val11.mainTextureScale = Vector2.one; val11.mainTextureOffset = Vector2.zero; if (val11.HasProperty("_MainTex")) { val11.SetTexture("_MainTex", (Texture)(object)shieldTexture); } if (val11.HasProperty("_Color")) { val11.SetColor("_Color", Color.white); } if (val11.HasProperty("_Metallic")) { val11.SetFloat("_Metallic", 0.55f); } if (val11.HasProperty("_Glossiness")) { val11.SetFloat("_Glossiness", 0.35f); } if (val11.HasProperty("_Style")) { val11.SetFloat("_Style", 0f); } if (val11.HasProperty("_UseStyleTex")) { val11.SetFloat("_UseStyleTex", 0f); } val11.DisableKeyword("_NORMALMAP"); val11.DisableKeyword("_METALLICGLOSSMAP"); val11.DisableKeyword("_ALPHATEST_ON"); val11.DisableKeyword("_ALPHABLEND_ON"); val11.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val11.SetOverrideTag("RenderType", "Opaque"); val11.renderQueue = 2000; if (val11.HasProperty("_Cutoff")) { val11.SetFloat("_Cutoff", 0f); } if (val11.HasProperty("_Mode")) { val11.SetFloat("_Mode", 0f); } if (val11.HasProperty("_ZWrite")) { val11.SetFloat("_ZWrite", 1f); } if (val11.HasProperty("_SrcBlend")) { val11.SetFloat("_SrcBlend", 1f); } if (val11.HasProperty("_DstBlend")) { val11.SetFloat("_DstBlend", 0f); } LODGroup[] componentsInChildren2 = ((Component)val4).GetComponentsInChildren<LODGroup>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } array = componentsInChildren; for (int i = 0; i < array.Length; i++) { Object.DestroyImmediate((Object)(object)array[i]); } GameObject val12 = new GameObject("YoroshiroThorShieldVisual"); val12.layer = ((Component)val4).gameObject.layer; val12.transform.SetParent(val4, false); val12.AddComponent<MeshFilter>().sharedMesh = shieldMesh; ((Renderer)val12.AddComponent<MeshRenderer>()).sharedMaterial = val11; val12.transform.localPosition = ((Bounds)(ref val6)).center + val7 * Safe(clearance.Value, 0f, 0.08f, 0.05f) + offset.Value; val12.transform.localRotation = Quaternion.LookRotation(val7, val8) * Quaternion.Euler(Safe(upperTilt.Value, -60f, 60f, -25f), 0f, 0f) * Quaternion.Euler(rotation.Value); Transform transform = val12.transform; Vector3 one = Vector3.one; float num2 = Safe(diameter.Value, 0.5f, 1.3f, 0.76f); Bounds val13 = shieldMesh.bounds; transform.localScale = one * (num2 / Mathf.Max(0.01f, ((Bounds)(ref val13)).size.y)); val12.AddComponent<ShieldRunes>(); Texture2D val14 = new Texture2D(1, 1, (TextureFormat)4, false); val14.SetPixel(0, 0, new Color(0.055f, 0.085f, 0.12f, 1f)); val14.Apply(false, true); Material val15 = new Material(val11) { name = "Yoroshiro_ThorShield_BackPlate" }; val15.mainTexture = (Texture)(object)val14; if (val15.HasProperty("_MainTex")) { val15.SetTexture("_MainTex", (Texture)(object)val14); } if (val15.HasProperty("_Metallic")) { val15.SetFloat("_Metallic", 0.3f); } GameObject val16 = new GameObject("SolidBackPlate") { layer = val12.layer }; val16.transform.SetParent(val12.transform, false); MeshFilter obj = val16.AddComponent<MeshFilter>(); val13 = shieldMesh.bounds; float radiusX = ((Bounds)(ref val13)).extents.x * 0.94f; val13 = shieldMesh.bounds; obj.sharedMesh = ShieldBacking.Create(radiusX, ((Bounds)(ref val13)).extents.y * 0.94f); ((Renderer)val16.AddComponent<MeshRenderer>()).sharedMaterial = val15; SharedData shared = val3.ItemDrop.m_itemData.m_shared; shared.m_name = "$yoroshiro_thorshield_name"; shared.m_description = "$yoroshiro_thorshield_description"; shared.m_icons = (Sprite[])(object)new Sprite[1] { icon }; shared.m_maxQuality = 3; shared.m_weight = 5f; shared.m_blockPower = Safe(block.Value, 1f, 130f, 78f); shared.m_blockPowerPerLevel = Safe(perLevel.Value, 0f, 20f, 6f); shared.m_timedBlockBonus = Safe(parry.Value, 1f, 2.5f, 1.5f); shared.m_deflectionForce = 50f; shared.m_deflectionForcePerLevel = 0f; shared.m_movementModifier = -0.05f; shared.m_useDurability = true; shared.m_maxDurability = 200f; shared.m_durabilityPerLevel = 50f; if (!ItemManager.Instance.AddItem(val3)) { throw new Exception("Jotunn rejected the shield item"); } registered = true; PrefabManager.OnVanillaPrefabsAvailable -= Register; ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj2 = new string[12] { "Registered YoroshiroThorShield | native grip bounds: ", null, null, null, null, null, null, null, null, null, null, null }; val13 = val6; obj2[1] = ((object)(*(Bounds*)(&val13))/*cast due to .constrained prefix*/).ToString(); obj2[2] = " | outward normal: "; Vector3 val17 = val7; obj2[3] = ((object)(*(Vector3*)(&val17))/*cast due to .constrained prefix*/).ToString(); obj2[4] = " | shader: "; obj2[5] = ((Object)val9).name; obj2[6] = " | texture: "; obj2[7] = ((Texture)shieldTexture).width.ToString(); obj2[8] = "x"; obj2[9] = ((Texture)shieldTexture).height.ToString(); obj2[10] = " | diameter: "; obj2[11] = diameter.Value.ToString(); logger.LogInfo((object)string.Concat(obj2)); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Thor's Shield registration failed: " + ex)); } } private static float Safe(float v, float lo, float hi, float fallback) { if (!float.IsNaN(v) && !float.IsInfinity(v)) { return Mathf.Clamp(v, lo, hi); } return fallback; } private static Vector3 Axis(int n) { //IL_0013: 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_0007: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(n switch { 1 => Vector3.up, 0 => Vector3.right, _ => Vector3.forward, }); } private static Bounds LocalBounds(Transform root, Renderer[] renderers) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0028: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) //IL_0064: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) bool flag = true; Bounds result = default(Bounds); foreach (Renderer val in renderers) { Bounds localBounds = val.localBounds; for (int j = 0; j < 8; j++) { Vector3 val2 = ((Bounds)(ref localBounds)).center + Vector3.Scale(((Bounds)(ref localBounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1)))); val2 = root.InverseTransformPoint(((Component)val).transform.TransformPoint(val2)); if (flag) { ((Bounds)(ref result))..ctor(val2, Vector3.zero); flag = false; } else { ((Bounds)(ref result)).Encapsulate(val2); } } } return result; } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= Register; } } public sealed class ShieldRunes : MonoBehaviour { private static Mesh runeMesh; private static ConfigEntry<bool> enabledRunes; private static ConfigEntry<float> intensity; private Texture2D runeColor; private Material glow; private MeshRenderer overlay; private Player owner; private float nextCharge; private float matchedIntensity = 5f; private float charge; private int quality = 1; private bool powerActive; internal static void Configure(ThorShieldPlugin plugin) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown enabledRunes = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Effects", "PulsingRunes", true, "Blue pulsing runes on the shield border. Restart after changes."); intensity = ((BaseUnityPlugin)plugin).Config.Bind<float>("Effects", "RuneIntensity", 5f, new ConfigDescription("Fallback rune intensity when Mjolnir is unavailable. With Mjolnir installed, uses its RuneIntensity setting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 5f), Array.Empty<object>())); ConfigEntry<int> val = ((BaseUnityPlugin)plugin).Config.Bind<int>("Effects", "RuneRevision", 0, "Rune intensity default migration."); if (val.Value < 1) { if (Mathf.Approximately(intensity.Value, 1f)) { intensity.Value = 5f; } val.Value = 1; ((BaseUnityPlugin)plugin).Config.Save(); } } internal static void Prepare(string path) { //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_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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00f9: 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_0118: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Expected O, but got Unknown //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) ShieldMeshData shieldMeshData = ShieldMeshData.Read(File.ReadAllBytes(path)); List<Vector3> list = new List<Vector3>(); List<int> list2 = new List<int>(); float num = 0f; float num2 = 0f; for (int i = 0; i < shieldMeshData.Count; i++) { num = Mathf.Max(num, Mathf.Abs(shieldMeshData.Vertices[i * 8])); num2 = Mathf.Max(num2, Mathf.Abs(shieldMeshData.Vertices[i * 8 + 1])); } Vector2[][] array = new Vector2[4][] { (Vector2[])(object)new Vector2[6] { new Vector2(0f, -1f), new Vector2(0f, 1f), new Vector2(0f, 0.9f), new Vector2(0.65f, 0.35f), new Vector2(0f, 0.05f), new Vector2(0.65f, -0.45f) }, (Vector2[])(object)new Vector2[6] { new Vector2(0f, -1f), new Vector2(0f, 1f), new Vector2(-0.65f, 0.2f), new Vector2(0f, 0.85f), new Vector2(0f, 0.85f), new Vector2(0.65f, 0.2f) }, (Vector2[])(object)new Vector2[4] { new Vector2(-0.6f, -1f), new Vector2(0.6f, 1f), new Vector2(-0.6f, 1f), new Vector2(0.6f, -1f) }, (Vector2[])(object)new Vector2[6] { new Vector2(0f, -1f), new Vector2(0f, 1f), new Vector2(0f, 0.8f), new Vector2(0.65f, 0.3f), new Vector2(0.65f, 0.3f), new Vector2(0f, -0.1f) } }; Vector2 val = default(Vector2); for (int j = 0; j < 16; j++) { float num3 = (float)j * MathF.PI * 2f / 16f; ((Vector2)(ref val))..ctor(Mathf.Sin(num3) * num * 0.84f, Mathf.Cos(num3) * num2 * 0.84f); Vector2[] array2 = array[j % array.Length]; for (int k = 0; k < array2.Length; k += 2) { Vector2 val2 = val + array2[k] * 0.025f; Vector2 val3 = val + array2[k + 1] * 0.025f; Vector2 val4 = new Vector2(0f - (val3 - val2).y, (val3 - val2).x); Vector2 val5 = ((Vector2)(ref val4)).normalized * 0.0024f; Vector2[] array3 = (Vector2[])(object)new Vector2[4] { val2 - val5, val2 + val5, val3 + val5, val3 - val5 }; float num4 = -1f; Vector2[] array4 = array3; foreach (Vector2 p in array4) { num4 = Mathf.Max(num4, Surface(shieldMeshData, p)); } num4 += 0.004f; int count = list.Count; array4 = array3; foreach (Vector2 val6 in array4) { list.Add(new Vector3(val6.x, val6.y, num4)); } list2.AddRange(new int[12] { count, count + 1, count + 2, count, count + 2, count + 3, count + 2, count + 1, count, count + 3, count + 2, count }); } } runeMesh = new Mesh { name = "ThorShield_BorderRunes" }; runeMesh.SetVertices(list); runeMesh.SetTriangles(list2, 0); Color32[] array5 = (Color32[])(object)new Color32[list.Count]; for (int m = 0; m < array5.Length; m++) { array5[m] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } runeMesh.colors32 = array5; runeMesh.RecalculateNormals(); runeMesh.RecalculateBounds(); runeMesh.UploadMeshData(true); } private static float Surface(ShieldMeshData data, Vector2 p) { //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_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_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_003f: 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_0053: 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_0063: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_009b: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) float num = -1f; for (int i = 0; i < data.Indices.Length; i += 3) { Vector3 val = Vertex(data, data.Indices[i]); Vector3 val2 = Vertex(data, data.Indices[i + 1]); Vector3 val3 = Vertex(data, data.Indices[i + 2]); float num2 = (val2.y - val3.y) * (val.x - val3.x) + (val3.x - val2.x) * (val.y - val3.y); if (!(Mathf.Abs(num2) < 1E-07f)) { float num3 = ((val2.y - val3.y) * (p.x - val3.x) + (val3.x - val2.x) * (p.y - val3.y)) / num2; float num4 = ((val3.y - val.y) * (p.x - val3.x) + (val.x - val3.x) * (p.y - val3.y)) / num2; float num5 = 1f - num3 - num4; if (num3 >= 0f && num4 >= 0f && num5 >= 0f) { num = Mathf.Max(num, num3 * val.z + num4 * val2.z + num5 * val3.z); } } } if (!(num < -0.5f)) { return num; } return 0.084f; } private static Vector3 Vertex(ShieldMeshData d, int i) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) int num = i * 8; return new Vector3(d.Vertices[num], d.Vertices[num + 1], d.Vertices[num + 2]); } private void Start() { //IL_004a: 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_005f: Expected O, but got Unknown //IL_007e: 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_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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown if (!enabledRunes.Value || !Object.op_Implicit((Object)(object)runeMesh)) { ((Behaviour)this).enabled = false; return; } Shader val = Shader.Find("Sprites/Default"); if (!Object.op_Implicit((Object)(object)val)) { Debug.LogWarning((object)"[ThorShield] Rune overlay shader unavailable."); ((Behaviour)this).enabled = false; return; } runeColor = new Texture2D(1, 1, (TextureFormat)4, false) { name = "ThorShield_MjolnirRuneCyan" }; runeColor.SetPixels32((Color32[])(object)new Color32[1] { new Color32((byte)56, (byte)224, byte.MaxValue, byte.MaxValue) }); runeColor.Apply(false, true); glow = new Material(val) { name = "ThorShield_PulsingBlueRunes", renderQueue = 3001, mainTexture = (Texture)(object)runeColor }; GameObject val2 = new GameObject("ThorShield_RuneGlow"); val2.layer = ((Component)this).gameObject.layer; val2.transform.SetParent(((Component)this).transform, false); val2.AddComponent<MeshFilter>().sharedMesh = runeMesh; overlay = val2.AddComponent<MeshRenderer>(); ((Renderer)overlay).sharedMaterial = glow; ((Renderer)overlay).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)overlay).receiveShadows = false; owner = ((Component)this).GetComponentInParent<Player>(); } private static bool Flag(object value, string name) { object obj = RuneMemberReader.Read(value, name); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } private void ReadHammerRunes() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown matchedIntensity = intensity.Value; charge = 0f; quality = 1; powerActive = false; try { Type type = RuneMemberReader.FindType("MyValheimMod.MjolnirPlugin"); object obj = ((type == null) ? null : RuneMemberReader.Read(type, "Active")); if (obj == null) { return; } object obj2 = RuneMemberReader.Read(obj, "Config"); ConfigFile val = (ConfigFile)((obj2 is ConfigFile) ? obj2 : null); ConfigEntry<float> val2 = default(ConfigEntry<float>); if (val != null && val.TryGetEntry<float>(new ConfigDefinition("Effects", "RuneIntensity"), ref val2)) { matchedIntensity = val2.Value; } if (Object.op_Implicit((Object)(object)owner) && !((Object)(object)owner != (Object)(object)Player.m_localPlayer)) { object obj3 = RuneMemberReader.Read(RuneMemberReader.Read(RuneMemberReader.Read(obj, "Storm"), "Meter"), "Fraction"); if (obj3 != null) { charge = Convert.ToSingle(obj3); } powerActive = Flag(obj, "Flight") || Flag(RuneMemberReader.Read(obj, "Wings"), "Active") || Flag(RuneMemberReader.Read(obj, "Strike"), "Casting"); ItemData currentWeapon = ((Humanoid)owner).GetCurrentWeapon(); MethodInfo method = type.GetMethod("IsMjolnir", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (currentWeapon != null && method != null && (bool)method.Invoke(null, new object[1] { currentWeapon })) { quality = currentWeapon.m_quality; } } } catch { charge = 0f; quality = 1; powerActive = false; } } private void LateUpdate() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)glow)) { if (Time.time >= nextCharge) { ReadHammerRunes(); nextCharge = Time.time + 0.1f; } float num = ShieldRunePulseRules.Gain(Time.time, matchedIntensity, charge, quality, powerActive); glow.SetColor("_Color", new Color(num, num, num, 1f)); } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)glow)) { Object.Destroy((Object)(object)glow); } if (Object.op_Implicit((Object)(object)runeColor)) { Object.Destroy((Object)(object)runeColor); } } } public static class ShieldRunePulseRules { public static float Gain(float time, float intensity, float charge, int quality, bool active) { if (float.IsNaN(time) || float.IsInfinity(time)) { time = 0f; } if (float.IsNaN(intensity) || float.IsInfinity(intensity)) { intensity = 2f; } if (float.IsNaN(charge) || float.IsInfinity(charge)) { charge = 0f; } float num = (float)(0.5 + 0.5 * Math.Sin((double)time * 4.5)); return (0.12f + 2.88f * num * num) * Math.Max(0.5f, Math.Min(5f, intensity)) * (1f + Math.Max(0f, Math.Min(1f, charge)) * 0.2f) * (1f + 0.12f * (float)(Math.Max(1, Math.Min(4, quality)) - 1)) * (active ? 1.2f : 1f); } } internal static class RuneMemberReader { private static readonly Dictionary<Type, Dictionary<string, MemberInfo>> cache = new Dictionary<Type, Dictionary<string, MemberInfo>>(); internal static object Read(object value, string name) { if (value == null) { return null; } Type type = (value as Type) ?? value.GetType(); object obj = ((value is Type) ? null : value); if (!cache.TryGetValue(type, out var value2)) { value2 = new Dictionary<string, MemberInfo>(); cache[type] = value2; } if (!value2.TryGetValue(name, out var value3)) { Type type2 = type; while (type2 != null && value3 == null) { PropertyInfo property = type2.GetProperty(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); value3 = ((!(property != null) || property.GetIndexParameters().Length != 0 || !(property.GetGetMethod(nonPublic: true) != null)) ? ((MemberInfo)type2.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) : ((MemberInfo)property)); type2 = type2.BaseType; } value2[name] = value3; } if (value3 is PropertyInfo propertyInfo) { return propertyInfo.GetValue(obj, null); } if (value3 is FieldInfo fieldInfo) { return fieldInfo.GetValue(obj); } return null; } internal static Type FindType(string name) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType(name, throwOnError: false); if (type != null) { return type; } } return null; } } public sealed class ShieldMeshData { public readonly float[] Vertices; public readonly int[] Indices; public int Count => Vertices.Length / 8; private ShieldMeshData(float[] v, int[] i) { Vertices = v; Indices = i; } public ShieldMeshData WithBackFaces() { float[] array = new float[Vertices.Length * 2]; Array.Copy(Vertices, array, Vertices.Length); Array.Copy(Vertices, 0, array, Vertices.Length, Vertices.Length); for (int i = Vertices.Length; i < array.Length; i += 8) { array[i + 3] = 0f - array[i + 3]; array[i + 4] = 0f - array[i + 4]; array[i + 5] = 0f - array[i + 5]; } int[] array2 = new int[Indices.Length * 2]; Array.Copy(Indices, array2, Indices.Length); for (int j = 0; j < Indices.Length; j += 3) { array2[Indices.Length + j] = Indices[j] + Count; array2[Indices.Length + j + 1] = Indices[j + 2] + Count; array2[Indices.Length + j + 2] = Indices[j + 1] + Count; } return new ShieldMeshData(array, array2); } public static ShieldMeshData Read(byte[] bytes) { if (bytes == null || bytes.Length < 16 || bytes.Length > 4000000) { throw new InvalidDataException("Invalid shield mesh size"); } using MemoryStream input = new MemoryStream(bytes); using BinaryReader binaryReader = new BinaryReader(input); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(8)) != "YTSH1\0\0\0") { throw new InvalidDataException("Invalid shield mesh header"); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); if (num < 3 || num > 50000 || num2 < 3 || num2 > 150000 || num2 % 3 != 0 || bytes.Length != 16 + (long)num * 32L + (long)num2 * 4L) { throw new InvalidDataException("Invalid shield mesh counts"); } float[] array = new float[num * 8]; for (int i = 0; i < array.Length; i++) { float num3 = binaryReader.ReadSingle(); if (float.IsNaN(num3) || float.IsInfinity(num3) || Math.Abs(num3) > 100f) { throw new InvalidDataException("Invalid vertex"); } array[i] = num3; } int[] array2 = new int[num2]; for (int j = 0; j < array2.Length; j++) { array2[j] = binaryReader.ReadInt32(); if (array2[j] < 0 || array2[j] >= num) { throw new InvalidDataException("Invalid mesh index"); } } return new ShieldMeshData(array, array2); } } public static class ShieldBacking { public static Mesh Create(float radiusX, float radiusY) { //IL_0043: 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_004f: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: 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_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Expected O, but got Unknown Vector3[] array = (Vector3[])(object)new Vector3[130]; Vector3[] array2 = (Vector3[])(object)new Vector3[array.Length]; Vector2[] array3 = (Vector2[])(object)new Vector2[array.Length]; Color32[] array4 = (Color32[])(object)new Color32[array.Length]; int[] array5 = new int[384]; array[0] = new Vector3(0f, 0f, -0.006f); array2[0] = Vector3.forward; array[33] = new Vector3(0f, 0f, -0.065f); array2[33] = Vector3.back; for (int i = 0; i < 32; i++) { float num = (float)i * MathF.PI * 2f / 32f; float num2 = Mathf.Cos(num); float num3 = Mathf.Sin(num); int num4 = 1 + i; int num5 = 34 + i; int num6 = 66 + i * 2; array[num4] = new Vector3(num2 * radiusX, num3 * radiusY, -0.006f); array2[num4] = Vector3.forward; array[num5] = new Vector3(num2 * radiusX, num3 * radiusY, -0.065f); array2[num5] = Vector3.back; array[num6] = array[num4]; array[num6 + 1] = array[num5]; int num7 = num6 + 1; Vector3 val = new Vector3(num2 / radiusX, num3 / radiusY, 0f); val = (array2[num6] = (array2[num7] = ((Vector3)(ref val)).normalized)); int num8 = (i + 1) % 32; int num9 = i * 12; int num10 = 66 + num8 * 2; array5[num9] = 0; array5[num9 + 1] = 1 + i; array5[num9 + 2] = 1 + num8; array5[num9 + 3] = 33; array5[num9 + 4] = 34 + num8; array5[num9 + 5] = 34 + i; array5[num9 + 6] = num6; array5[num9 + 7] = num6 + 1; array5[num9 + 8] = num10; array5[num9 + 9] = num10; array5[num9 + 10] = num6 + 1; array5[num9 + 11] = num10 + 1; } for (int j = 0; j < array.Length; j++) { array3[j] = new Vector2(0.5f + array[j].x / (radiusX * 2f), 0.5f + array[j].y / (radiusY * 2f)); array4[j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } Mesh val2 = new Mesh { name = "Yoroshiro_ThorShield_ClosedBacking", vertices = array, normals = array2, uv = array3, colors32 = array4, triangles = array5 }; val2.RecalculateBounds(); val2.UploadMeshData(true); return val2; } }