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 TameableAnimals v1.2.0
TameableAnimals.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TameableAnimals")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+76450019fa9e00de8a7d6e45fcd62f2a0c0e6189")] [assembly: AssemblyProduct("TameableAnimals")] [assembly: AssemblyTitle("TameableAnimals")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TameableAnimals { internal static class BearSaddle { internal const string ItemPrefabName = "SaddleBjorn"; private const string SaddleObjectName = "TA_BearSaddle"; private const string AttachObjectName = "TA_BearSaddleAttach"; private static GameObject s_itemPrefab; private static Vector3 s_basePosition; private static Vector3 s_baseScale; private static Vector3 s_baseAttach; private static bool s_haveLayout; private const string BoneName = "Spine_01"; private static Matrix4x4 s_boneRestInVisual; private static bool s_haveBone; private static Sprite s_mountIcon; private static GameObject s_loxSaddleSource; private static Mesh s_bakedMesh; private static Vector3 s_colliderCenter; private static Vector3 s_colliderSize; internal static bool Enabled => TameableAnimalsPlugin.BearSaddleEnabled.Value; internal static GameObject GetOrCreateItem(GameObject loxSaddleItem) { if ((Object)(object)s_itemPrefab != (Object)null || (Object)(object)loxSaddleItem == (Object)null) { return s_itemPrefab; } GameObject obj = Object.Instantiate<GameObject>(loxSaddleItem, CreatureSetup.GetPrefabHolder().transform, false); ((Object)obj).name = "SaddleBjorn"; SharedData shared = obj.GetComponent<ItemDrop>().m_itemData.m_shared; shared.m_name = "$ta_item_saddlebjorn"; shared.m_description = "$ta_item_saddlebjorn_desc"; s_itemPrefab = obj; return obj; } internal static void EnsureItemRegistered(List<GameObject> prefabs) { if (Enabled && (Object)(object)s_itemPrefab != (Object)null && !prefabs.Contains(s_itemPrefab)) { prefabs.Add(s_itemPrefab); } } internal static void RegisterInObjectDB(ObjectDB db) { if (!Enabled) { return; } GameObject orCreateItem = GetOrCreateItem(db.GetItemPrefab("SaddleLox")); if (!((Object)(object)orCreateItem == (Object)null)) { if (!db.m_items.Contains(orCreateItem)) { db.m_items.Add(orCreateItem); } AddRecipe(db, orCreateItem.GetComponent<ItemDrop>()); db.UpdateRegisters(); } } private static void AddRecipe(ObjectDB db, ItemDrop item) { //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown foreach (Recipe recipe in db.m_recipes) { if ((Object)(object)recipe != (Object)null && (Object)(object)recipe.m_item == (Object)(object)item) { return; } } string text = TameableAnimalsPlugin.BearSaddleStation.Value.Trim(); CraftingStation val = null; foreach (Recipe recipe2 in db.m_recipes) { if ((Object)(object)recipe2 != (Object)null && (Object)(object)recipe2.m_craftingStation != (Object)null && ((Object)recipe2.m_craftingStation).name == text) { val = recipe2.m_craftingStation; break; } } if ((Object)(object)val == (Object)null) { return; } List<Requirement> list = new List<Requirement>(); string[] array = (TameableAnimalsPlugin.BearSaddleRecipe.Value ?? "").Split(','); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(':'); if (array2.Length == 2 && int.TryParse(array2[1].Trim(), out var result)) { GameObject itemPrefab = db.GetItemPrefab(array2[0].Trim()); ItemDrop val2 = (Object.op_Implicit((Object)(object)itemPrefab) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 == (Object)null) { TameableAnimalsPlugin.Log.LogWarning((object)("Unknown bear saddle ingredient: " + array2[0].Trim())); continue; } list.Add(new Requirement { m_resItem = val2, m_amount = result, m_amountPerLevel = 0, m_recover = true }); } } Recipe val3 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val3).name = "Recipe_SaddleBjorn"; val3.m_item = item; val3.m_amount = 1; val3.m_craftingStation = val; val3.m_repairStation = val; val3.m_minStationLevel = Mathf.Max(1, TameableAnimalsPlugin.BearSaddleStationLevel.Value); val3.m_resources = list.ToArray(); db.m_recipes.Add(val3); } internal static void AttachToBear(GameObject bear, Dictionary<string, GameObject> byName, List<GameObject> prefabs) { if (!Enabled || ((Object)(object)bear.GetComponent<BearSaddleMarker>() != (Object)null && (Object)(object)s_loxSaddleSource != (Object)null)) { return; } if ((Object)(object)s_itemPrefab == (Object)null && byName.TryGetValue("SaddleBjorn", out var value)) { s_itemPrefab = value; } byName.TryGetValue("Lox", out var value2); byName.TryGetValue("SaddleLox", out var value3); Tameable val = (Object.op_Implicit((Object)(object)value2) ? value2.GetComponent<Tameable>() : null); Tameable component = bear.GetComponent<Tameable>(); GameObject orCreateItem = GetOrCreateItem(value3); if ((Object)(object)val == (Object)null || (Object)(object)val.m_saddle == (Object)null || (Object)(object)component == (Object)null || (Object)(object)orCreateItem == (Object)null || !ComputeLayout(value2, val.m_saddle, bear)) { TameableAnimalsPlugin.Log.LogWarning((object)"Could not create the bear saddle."); return; } if (!prefabs.Contains(orCreateItem)) { prefabs.Add(orCreateItem); } s_loxSaddleSource = ((Component)val.m_saddle).gameObject; byName.TryGetValue("TrophyBjorn", out var value4); ItemDrop val2 = (Object.op_Implicit((Object)(object)value4) ? value4.GetComponent<ItemDrop>() : null); s_mountIcon = (((Object)(object)val2 != (Object)null && val2.m_itemData.m_shared.m_icons.Length != 0) ? val2.m_itemData.m_shared.m_icons[0] : orCreateItem.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0]); component.m_saddleItem = orCreateItem.GetComponent<ItemDrop>(); component.m_dropSaddleOnDeath = true; if ((Object)(object)bear.GetComponent<BearSaddleMarker>() == (Object)null) { bear.AddComponent<BearSaddleMarker>(); } } internal static void BuildOnInstance(Tameable bearTameable) { //IL_00f0: 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_0110: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)s_loxSaddleSource == (Object)null) && !((Object)(object)s_bakedMesh == (Object)null) && !((Object)(object)bearTameable.m_saddle != (Object)null)) { Transform val = ((Component)bearTameable).transform.Find("Visual") ?? ((Component)bearTameable).transform; Transform val2 = (s_haveBone ? FindDeep(val, "Spine_01") : null) ?? val; GameObject val3 = Object.Instantiate<GameObject>(s_loxSaddleSource, val2, false); ((Object)val3).name = "TA_BearSaddle"; val3.SetActive(false); Material[] array = null; SkinnedMeshRenderer component = val3.GetComponent<SkinnedMeshRenderer>(); if ((Object)(object)component != (Object)null) { array = ((Renderer)component).sharedMaterials; Object.DestroyImmediate((Object)(object)component); } val3.AddComponent<MeshFilter>().sharedMesh = s_bakedMesh; MeshRenderer val4 = val3.AddComponent<MeshRenderer>(); if (array != null) { ((Renderer)val4).sharedMaterials = array; } Collider[] components = val3.GetComponents<Collider>(); for (int i = 0; i < components.Length; i++) { Object.DestroyImmediate((Object)(object)components[i]); } BoxCollider obj = val3.AddComponent<BoxCollider>(); obj.center = s_colliderCenter; obj.size = s_colliderSize; ((Collider)obj).isTrigger = true; Transform transform = new GameObject("TA_BearSaddleAttach").transform; transform.SetParent(val2, false); ApplyLayout(val3.transform, transform); Sadle component2 = val3.GetComponent<Sadle>(); component2.m_attachPoint = transform; if ((Object)(object)s_mountIcon != (Object)null) { component2.m_mountIcon = s_mountIcon; } component2.m_hoverText = "$ta_item_saddlebjorn"; bearTameable.m_saddle = component2; } } internal static Transform FindDeep(Transform root, string name) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (((Object)root).name == name) { return root; } foreach (Transform item in root) { Transform val = FindDeep(item, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private unsafe static bool ComputeLayout(GameObject lox, Sadle loxSaddle, GameObject bear) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: 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_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: 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_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: 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_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: 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_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) if (s_haveLayout) { return true; } Transform val = lox.transform.Find("Visual") ?? lox.transform; Transform val2 = bear.transform.Find("Visual") ?? bear.transform; SkinnedMeshRenderer component = ((Component)loxSaddle).GetComponent<SkinnedMeshRenderer>(); if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null) { return false; } Mesh val3 = SkinToSpace(component, val, new HashSet<string> { "Mount", "Mount.001" }); if ((Object)(object)val3 == (Object)null) { return false; } Vector3[] vertices = val3.vertices; Vector3[] normals = val3.normals; Bounds val4 = default(Bounds); ((Bounds)(ref val4))..ctor(vertices[0], Vector3.zero); Vector3[] array = vertices; foreach (Vector3 val5 in array) { ((Bounds)(ref val4)).Encapsulate(val5); } Vector3 val6 = (Vector3)(((Object)(object)loxSaddle.m_attachPoint != (Object)null) ? val.InverseTransformPoint(loxSaddle.m_attachPoint.position) : new Vector3(((Bounds)(ref val4)).center.x, ((Bounds)(ref val4)).max.y, ((Bounds)(ref val4)).center.z)); Vector3 center = ((Bounds)(ref val4)).center; for (int j = 0; j < vertices.Length; j++) { ref Vector3 reference = ref vertices[j]; reference -= center; } val3.vertices = vertices; if (normals.Length == vertices.Length) { val3.normals = normals; } val3.RecalculateBounds(); ((Object)val3).name = "TA_BearSaddle_Mesh"; s_bakedMesh = val3; Bounds bodyBounds = GetBodyBounds(val, component); Bounds bodyBounds2 = GetBodyBounds(val2, null); float num = ((Bounds)(ref val4)).size.x / Mathf.Max(0.01f, ((Bounds)(ref bodyBounds)).size.x); float num2 = ((Bounds)(ref bodyBounds2)).size.x * num / Mathf.Max(0.01f, ((Bounds)(ref val4)).size.x); float num3 = ((Bounds)(ref val4)).size.y * num2; float num4 = ((Bounds)(ref bodyBounds2)).max.y - 0.05f * ((Bounds)(ref bodyBounds2)).size.y; s_basePosition = new Vector3(0f, num4 - num3 * 0.5f, ((Bounds)(ref bodyBounds2)).center.z - 0.1f * ((Bounds)(ref bodyBounds2)).size.z); s_baseScale = Vector3.one * num2; s_baseAttach = s_basePosition + (val6 - center) * num2; float num5 = s_basePosition.y + num3 * 0.5f + 0.1f; float num6 = ((Bounds)(ref bodyBounds2)).max.y - 0.45f * ((Bounds)(ref bodyBounds2)).size.y; Vector3 val7 = default(Vector3); ((Vector3)(ref val7))..ctor(0f, (num5 + num6) * 0.5f, s_basePosition.z); Vector3 val8 = new Vector3(((Bounds)(ref bodyBounds2)).size.x * 0.9f, Mathf.Max(0.3f, num5 - num6), ((Bounds)(ref val4)).size.z * num2 * 1.2f); s_colliderCenter = (val7 - s_basePosition) / num2; s_colliderSize = val8 / num2; Transform val9 = FindDeep(val2, "Spine_01"); if ((Object)(object)val9 != (Object)null) { s_boneRestInVisual = val2.worldToLocalMatrix * val9.localToWorldMatrix; s_haveBone = true; } else { TameableAnimalsPlugin.Log.LogWarning((object)"Bear saddle: bone Spine_01 not found; the saddle will not follow the body animation."); } s_haveLayout = true; ManualLogSource log = TameableAnimalsPlugin.Log; string[] obj = new string[12] { "Bear saddle layout: loxBody=", null, null, null, null, null, null, null, null, null, null, null }; Bounds val10 = bodyBounds; obj[1] = ((object)(*(Bounds*)(&val10))/*cast due to .constrained prefix*/).ToString(); obj[2] = " saddle="; val10 = val4; obj[3] = ((object)(*(Bounds*)(&val10))/*cast due to .constrained prefix*/).ToString(); obj[4] = " bearBody="; val10 = bodyBounds2; obj[5] = ((object)(*(Bounds*)(&val10))/*cast due to .constrained prefix*/).ToString(); obj[6] = " scale="; obj[7] = num2.ToString("0.###"); obj[8] = " position="; Vector3 val11 = s_basePosition; obj[9] = ((object)(*(Vector3*)(&val11))/*cast due to .constrained prefix*/).ToString(); obj[10] = " attach="; val11 = s_baseAttach; obj[11] = ((object)(*(Vector3*)(&val11))/*cast due to .constrained prefix*/).ToString(); log.LogInfo((object)string.Concat(obj)); return true; } private static Mesh SkinToSpace(SkinnedMeshRenderer skinned, Transform space, HashSet<string> keepBones) { //IL_007a: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0121: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_015d: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: 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_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Expected O, but got Unknown //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) Mesh sharedMesh = skinned.sharedMesh; if ((Object)(object)sharedMesh == (Object)null || !sharedMesh.isReadable) { TameableAnimalsPlugin.Log.LogWarning((object)"Bear saddle: the lox saddle mesh is not readable."); return null; } Transform[] bones = skinned.bones; Matrix4x4[] bindposes = sharedMesh.bindposes; BoneWeight[] boneWeights = sharedMesh.boneWeights; Vector3[] vertices = sharedMesh.vertices; Vector3[] normals = sharedMesh.normals; Vector4[] tangents = sharedMesh.tangents; if (vertices.Length == 0 || boneWeights.Length != vertices.Length || bones.Length == 0) { TameableAnimalsPlugin.Log.LogWarning((object)"Bear saddle: unexpected lox saddle mesh (no bone weights)."); return null; } Matrix4x4 worldToLocalMatrix = space.worldToLocalMatrix; Matrix4x4[] array = (Matrix4x4[])(object)new Matrix4x4[bones.Length]; for (int i = 0; i < bones.Length; i++) { array[i] = (((Object)(object)bones[i] != (Object)null && i < bindposes.Length) ? (worldToLocalMatrix * bones[i].localToWorldMatrix * bindposes[i]) : (worldToLocalMatrix * ((Component)skinned).transform.localToWorldMatrix)); } Vector3[] array2 = (Vector3[])(object)new Vector3[vertices.Length]; Vector3[] array3 = (Vector3[])(object)new Vector3[normals.Length]; Vector4[] array4 = (Vector4[])(object)new Vector4[tangents.Length]; for (int j = 0; j < vertices.Length; j++) { BoneWeight w = boneWeights[j]; Matrix4x4 val = Blend(array, w); array2[j] = ((Matrix4x4)(ref val)).MultiplyPoint3x4(vertices[j]); Vector3 val2; if (j < normals.Length) { int num = j; val2 = ((Matrix4x4)(ref val)).MultiplyVector(normals[j]); array3[num] = ((Vector3)(ref val2)).normalized; } if (j < tangents.Length) { val2 = ((Matrix4x4)(ref val)).MultiplyVector(new Vector3(tangents[j].x, tangents[j].y, tangents[j].z)); Vector3 normalized = ((Vector3)(ref val2)).normalized; array4[j] = new Vector4(normalized.x, normalized.y, normalized.z, tangents[j].w); } } bool[] array5 = new bool[vertices.Length]; for (int k = 0; k < vertices.Length; k++) { BoneWeight val3 = boneWeights[k]; int num2 = ((BoneWeight)(ref val3)).boneIndex0; float num3 = ((BoneWeight)(ref val3)).weight0; if (((BoneWeight)(ref val3)).weight1 > num3) { num3 = ((BoneWeight)(ref val3)).weight1; num2 = ((BoneWeight)(ref val3)).boneIndex1; } if (((BoneWeight)(ref val3)).weight2 > num3) { num3 = ((BoneWeight)(ref val3)).weight2; num2 = ((BoneWeight)(ref val3)).boneIndex2; } if (((BoneWeight)(ref val3)).weight3 > num3) { num2 = ((BoneWeight)(ref val3)).boneIndex3; } Transform val4 = ((num2 < bones.Length) ? bones[num2] : null); array5[k] = keepBones == null || ((Object)(object)val4 != (Object)null && keepBones.Contains(((Object)val4).name)); } int[] array6 = new int[vertices.Length]; for (int l = 0; l < array6.Length; l++) { array6[l] = -1; } List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector4> list3 = new List<Vector4>(); List<Vector2> list4 = new List<Vector2>(); List<Color32> list5 = new List<Color32>(); Vector2[] uv = sharedMesh.uv; Color32[] colors = sharedMesh.colors32; List<int>[] array7 = new List<int>[sharedMesh.subMeshCount]; for (int m = 0; m < sharedMesh.subMeshCount; m++) { array7[m] = new List<int>(); int[] triangles = sharedMesh.GetTriangles(m); for (int n = 0; n + 2 < triangles.Length; n += 3) { if (!array5[triangles[n]] || !array5[triangles[n + 1]] || !array5[triangles[n + 2]]) { continue; } for (int num4 = 0; num4 < 3; num4++) { int num5 = triangles[n + num4]; if (array6[num5] < 0) { array6[num5] = list.Count; list.Add(array2[num5]); if (array3.Length == vertices.Length) { list2.Add(array3[num5]); } if (array4.Length == vertices.Length) { list3.Add(array4[num5]); } if (uv.Length == vertices.Length) { list4.Add(uv[num5]); } if (colors.Length == vertices.Length) { list5.Add(colors[num5]); } } array7[m].Add(array6[num5]); } } } if (list.Count == 0) { TameableAnimalsPlugin.Log.LogWarning((object)"Bear saddle: no saddle triangles found in the lox saddle mesh."); return null; } Mesh val5 = new Mesh { name = "TA_BearSaddle_Mesh" }; val5.indexFormat = (IndexFormat)(list.Count > 65000); val5.SetVertices(list); if (list2.Count == list.Count) { val5.SetNormals(list2); } if (list3.Count == list.Count) { val5.SetTangents(list3); } if (list4.Count == list.Count) { val5.SetUVs(0, list4); } if (list5.Count == list.Count) { val5.SetColors(list5); } val5.subMeshCount = sharedMesh.subMeshCount; for (int num6 = 0; num6 < sharedMesh.subMeshCount; num6++) { val5.SetTriangles(array7[num6], num6); } return val5; } private static Matrix4x4 Blend(Matrix4x4[] m, BoneWeight w) { //IL_0002: 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_003b: 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_009e: 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) Matrix4x4 r = default(Matrix4x4); AddScaled(ref r, m[((BoneWeight)(ref w)).boneIndex0], ((BoneWeight)(ref w)).weight0); if (((BoneWeight)(ref w)).weight1 > 0f) { AddScaled(ref r, m[((BoneWeight)(ref w)).boneIndex1], ((BoneWeight)(ref w)).weight1); } if (((BoneWeight)(ref w)).weight2 > 0f) { AddScaled(ref r, m[((BoneWeight)(ref w)).boneIndex2], ((BoneWeight)(ref w)).weight2); } if (((BoneWeight)(ref w)).weight3 > 0f) { AddScaled(ref r, m[((BoneWeight)(ref w)).boneIndex3], ((BoneWeight)(ref w)).weight3); } return r; } private static void AddScaled(ref Matrix4x4 r, Matrix4x4 m, float f) { for (int i = 0; i < 16; i++) { int num = i; ((Matrix4x4)(ref r))[num] = ((Matrix4x4)(ref r))[num] + ((Matrix4x4)(ref m))[i] * f; } } internal static void ApplyLayout(Transform saddle, Transform attach) { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_006e: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if (s_haveLayout) { float num = Mathf.Max(0.05f, TameableAnimalsPlugin.BearSaddleScale.Value); Vector3 val = TameableAnimalsPlugin.ParseVector3(TameableAnimalsPlugin.BearSaddleOffset.Value); Matrix4x4 val2 = Matrix4x4.TRS(s_basePosition + val, Quaternion.identity, s_baseScale * num); Matrix4x4 val3 = Matrix4x4.TRS(s_basePosition + val + (s_baseAttach - s_basePosition) * num + TameableAnimalsPlugin.ParseVector3(TameableAnimalsPlugin.BearSaddleAttachOffset.Value), Quaternion.identity, Vector3.one); if (s_haveBone && (Object)(object)saddle.parent != (Object)null && ((Object)saddle.parent).name == "Spine_01") { Matrix4x4 inverse = ((Matrix4x4)(ref s_boneRestInVisual)).inverse; val2 = inverse * val2; val3 = inverse * val3; } SetLocalPose(saddle, val2); SetLocalPose(attach, val3); } } private static void SetLocalPose(Transform t, Matrix4x4 m) { //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_0016: 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) t.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(3)); t.localRotation = ((Matrix4x4)(ref m)).rotation; t.localScale = ((Matrix4x4)(ref m)).lossyScale; } private static Bounds GetBodyBounds(Transform visual, SkinnedMeshRenderer exclude) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_0164: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(new Vector3(0f, 1f, 0f), new Vector3(1f, 1f, 1.5f)); float num = 0f; SkinnedMeshRenderer[] componentsInChildren = ((Component)visual).GetComponentsInChildren<SkinnedMeshRenderer>(true); Bounds val3 = default(Bounds); foreach (SkinnedMeshRenderer val in componentsInChildren) { if (!((Object)(object)val == (Object)(object)exclude) && !((Object)(object)val.sharedMesh == (Object)null) && ((Component)val).gameObject.activeSelf) { Transform val2 = (((Object)(object)val.rootBone != (Object)null) ? val.rootBone : ((Component)val).transform); Bounds localBounds = ((Renderer)val).localBounds; Vector3 center = ((Bounds)(ref localBounds)).center; Vector3 extents = ((Bounds)(ref localBounds)).extents; ((Bounds)(ref val3))..ctor(visual.InverseTransformPoint(val2.TransformPoint(center)), Vector3.zero); for (int j = 0; j < 8; j++) { Vector3 val4 = center + new Vector3(((j & 1) == 0) ? (0f - extents.x) : extents.x, ((j & 2) == 0) ? (0f - extents.y) : extents.y, ((j & 4) == 0) ? (0f - extents.z) : extents.z); ((Bounds)(ref val3)).Encapsulate(visual.InverseTransformPoint(val2.TransformPoint(val4))); } float num2 = ((Bounds)(ref val3)).size.x * ((Bounds)(ref val3)).size.y * ((Bounds)(ref val3)).size.z; if (num2 > num) { result = val3; num = num2; } } } return result; } internal static int ReapplyLayoutEverywhere() { int num = 0; List<Transform> list = new List<Transform>(); foreach (Character allCharacter in Character.GetAllCharacters()) { if (Utils.GetPrefabName(((Component)allCharacter).gameObject) == "Bjorn") { list.Add(((Component)allCharacter).transform); } } foreach (Transform item in list) { Transform val = FindDeep(item, "TA_BearSaddle"); Transform val2 = FindDeep(item, "TA_BearSaddleAttach"); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { ApplyLayout(val, val2); num++; } } return num; } } public class BearSaddleMarker : MonoBehaviour { } [HarmonyPatch(typeof(Tameable), "Awake")] internal static class Tameable_Awake_Patch { private static void Prefix(Tameable __instance) { if ((Object)(object)__instance.m_saddle == (Object)null && (Object)(object)((Component)__instance).GetComponent<BearSaddleMarker>() != (Object)null) { BearSaddle.BuildOnInstance(__instance); } } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] internal static class Terminal_InitTerminal_Patch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; internal void <Postfix>b__0_0(ConsoleEventArgs args) { //IL_0072: 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) CultureInfo invariantCulture = CultureInfo.InvariantCulture; if (args.Length >= 5) { if (float.TryParse(args[1], NumberStyles.Float, invariantCulture, out var result) && float.TryParse(args[2], NumberStyles.Float, invariantCulture, out var result2) && float.TryParse(args[3], NumberStyles.Float, invariantCulture, out var result3) && float.TryParse(args[4], NumberStyles.Float, invariantCulture, out var result4)) { TameableAnimalsPlugin.BearSaddleOffset.Value = TameableAnimalsPlugin.FormatVector3(new Vector3(result, result2, result3)); TameableAnimalsPlugin.BearSaddleScale.Value = result4; } if (args.Length >= 8 && float.TryParse(args[5], NumberStyles.Float, invariantCulture, out var result5) && float.TryParse(args[6], NumberStyles.Float, invariantCulture, out var result6) && float.TryParse(args[7], NumberStyles.Float, invariantCulture, out var result7)) { TameableAnimalsPlugin.BearSaddleAttachOffset.Value = TameableAnimalsPlugin.FormatVector3(new Vector3(result5, result6, result7)); } TameableAnimalsPlugin.MainConfig.Save(); int num = BearSaddle.ReapplyLayoutEverywhere(); args.Context.AddString("Bear saddle updated on " + num + " bear(s) and saved to the config."); } args.Context.AddString("Offset=" + TameableAnimalsPlugin.BearSaddleOffset.Value + " Scale=" + TameableAnimalsPlugin.BearSaddleScale.Value.ToString(invariantCulture) + " AttachOffset=" + TameableAnimalsPlugin.BearSaddleAttachOffset.Value); args.Context.AddString("Usage: ta_bearsaddle <offsetX> <offsetY> <offsetZ> <scale> [attachX attachY attachZ] e.g. ta_bearsaddle 0 0.1 -0.2 1.1"); } } private static void Postfix() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_0072: 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) CultureInfo invariantCulture = CultureInfo.InvariantCulture; if (args.Length >= 5) { if (float.TryParse(args[1], NumberStyles.Float, invariantCulture, out var result) && float.TryParse(args[2], NumberStyles.Float, invariantCulture, out var result2) && float.TryParse(args[3], NumberStyles.Float, invariantCulture, out var result3) && float.TryParse(args[4], NumberStyles.Float, invariantCulture, out var result4)) { TameableAnimalsPlugin.BearSaddleOffset.Value = TameableAnimalsPlugin.FormatVector3(new Vector3(result, result2, result3)); TameableAnimalsPlugin.BearSaddleScale.Value = result4; } if (args.Length >= 8 && float.TryParse(args[5], NumberStyles.Float, invariantCulture, out var result5) && float.TryParse(args[6], NumberStyles.Float, invariantCulture, out var result6) && float.TryParse(args[7], NumberStyles.Float, invariantCulture, out var result7)) { TameableAnimalsPlugin.BearSaddleAttachOffset.Value = TameableAnimalsPlugin.FormatVector3(new Vector3(result5, result6, result7)); } TameableAnimalsPlugin.MainConfig.Save(); int num = BearSaddle.ReapplyLayoutEverywhere(); args.Context.AddString("Bear saddle updated on " + num + " bear(s) and saved to the config."); } args.Context.AddString("Offset=" + TameableAnimalsPlugin.BearSaddleOffset.Value + " Scale=" + TameableAnimalsPlugin.BearSaddleScale.Value.ToString(invariantCulture) + " AttachOffset=" + TameableAnimalsPlugin.BearSaddleAttachOffset.Value); args.Context.AddString("Usage: ta_bearsaddle <offsetX> <offsetY> <offsetZ> <scale> [attachX attachY attachZ] e.g. ta_bearsaddle 0 0.1 -0.2 1.1"); }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("ta_bearsaddle", "[offsetX offsetY offsetZ scale [attachX attachY attachZ]] - TameableAnimals: move the saddle on bears live and save it to the config", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } internal static class CreatureSetup { private enum CreatureKind { Ignored, VanillaTame, Compatible } internal const string BabySuffix = "_TA_Baby"; private static GameObject s_prefabHolder; private static readonly Dictionary<string, GameObject> s_babies = new Dictionary<string, GameObject>(); private static readonly string[] s_colorProperties = new string[4] { "_Color", "_BaseColor", "_MainColor", "_TintColor" }; internal static void Setup(List<GameObject> prefabs) { Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>(); foreach (GameObject prefab in prefabs) { if ((Object)(object)prefab != (Object)null && !dictionary.ContainsKey(((Object)prefab).name)) { dictionary[((Object)prefab).name] = prefab; } } HotReload.RemoveStaleComponents(dictionary.Values); dictionary.TryGetValue("Boar", out var value); Tameable reference = (Object.op_Implicit((Object)(object)value) ? value.GetComponent<Tameable>() : null); Procreation reference2 = (Object.op_Implicit((Object)(object)value) ? value.GetComponent<Procreation>() : null); HashSet<string> hashSet = TameableAnimalsPlugin.ParseList(TameableAnimalsPlugin.ExtraCreatures.Value); List<GameObject> list = new List<GameObject>(); List<string> list2 = new List<string>(); List<string> list3 = new List<string>(); foreach (GameObject value3 in dictionary.Values) { switch (Classify(value3)) { case CreatureKind.VanillaTame: list2.Add(((Object)value3).name); if (hashSet.Contains(((Object)value3).name)) { TameableAnimalsPlugin.Log.LogInfo((object)(((Object)value3).name + " is already tameable in vanilla; ignored in ExtraCreatures.")); } break; case CreatureKind.Compatible: if (IsCandidate(value3, hashSet)) { list.Add(value3); } else { list3.Add(((Object)value3).name); } break; default: if (hashSet.Contains(((Object)value3).name) || TameableAnimalsPlugin.IsKnownAnimal(((Object)value3).name)) { TameableAnimalsPlugin.Log.LogWarning((object)(((Object)value3).name + " cannot be made tameable (boss, blocked or incompatible AI).")); } break; } } List<string> list4 = new List<string>(); foreach (GameObject item in list) { if ((Object)(object)item.GetComponent<TameableAnimal>() != (Object)null) { if (!s_babies.TryGetValue(((Object)item).name, out var value2) || (Object)(object)value2 == (Object)null) { value2 = item.GetComponent<Procreation>()?.m_offspring; } if ((Object)(object)value2 != (Object)null && !prefabs.Contains(value2)) { prefabs.Add(value2); } if (((Object)item).name == "Bjorn") { BearSaddle.AttachToBear(item, dictionary, prefabs); } RefreshPartnerRange(item); list4.Add(((Object)item).name); continue; } SpeciesSettings species = TameableAnimalsPlugin.GetSpecies(((Object)item).name); if (!species.Enabled.Value) { list3.Add(((Object)item).name + " (disabled with Enabled = false)"); continue; } list4.Add(((Object)item).name); MakeTameable(item, species, dictionary, reference); GameObject val = CreateBaby(item, species, dictionary); AddProcreation(item, val, reference2); if (((Object)item).name == "Bjorn") { BearSaddle.AttachToBear(item, dictionary, prefabs); } s_babies[((Object)item).name] = val; prefabs.Add(val); TameableAnimalsPlugin.Log.LogInfo((object)("Now tameable and breedable: " + ((Object)item).name + " (offspring: " + ((Object)val).name + ", partner range " + PartnerRange(item).ToString("0.0") + " m)")); } BearSaddle.EnsureItemRegistered(prefabs); AddSaddleColors(dictionary.Values); WriteCreatureReport(list4, list2, list3); } private static void AddSaddleColors(IEnumerable<GameObject> prefabs) { if (!SaddleColors.Enabled) { return; } foreach (GameObject prefab in prefabs) { Tameable component = prefab.GetComponent<Tameable>(); if ((Object)(object)component != (Object)null && ((Object)(object)component.m_saddle != (Object)null || (Object)(object)prefab.GetComponent<BearSaddleMarker>() != (Object)null) && (Object)(object)component.m_saddleItem != (Object)null && SaddleColors.GetSpec(((Object)component.m_saddleItem).name) != null && (Object)(object)prefab.GetComponent<SaddleColor>() == (Object)null) { prefab.AddComponent<SaddleColor>(); } } } private static CreatureKind Classify(GameObject prefab) { if (((Object)prefab).name.EndsWith("_TA_Baby") || TameableAnimalsPlugin.IsBlocked(((Object)prefab).name) || TameableAnimalsPlugin.IsBabyModel(((Object)prefab).name)) { return CreatureKind.Ignored; } Character component = prefab.GetComponent<Character>(); if ((Object)(object)component == (Object)null || component is Player || component.m_boss) { return CreatureKind.Ignored; } if ((Object)(object)prefab.GetComponent<TameableAnimal>() != (Object)null) { return CreatureKind.Compatible; } if ((Object)(object)prefab.GetComponent<Growup>() != (Object)null) { return CreatureKind.Ignored; } if ((Object)(object)prefab.GetComponent<Tameable>() != (Object)null) { return CreatureKind.VanillaTame; } if (!((Object)(object)prefab.GetComponent<AnimalAI>() != (Object)null) && (!((Object)(object)prefab.GetComponent<MonsterAI>() != (Object)null) || !(component is Humanoid))) { return CreatureKind.Ignored; } return CreatureKind.Compatible; } private static bool IsCandidate(GameObject prefab, HashSet<string> extra) { if ((Object)(object)prefab.GetComponent<TameableAnimal>() != (Object)null) { return true; } string name = ((Object)prefab).name; if (TameableAnimalsPlugin.IsKnownAnimal(name) || extra.Contains(name)) { return true; } if (TameableAnimalsPlugin.AutoDetectAnimals.Value) { return (Object)(object)prefab.GetComponent<AnimalAI>() != (Object)null; } return false; } private static void WriteCreatureReport(List<string> modTames, List<string> vanillaTames, List<string> available) { modTames.Sort(); vanillaTames.Sort(); available.Sort(); StringBuilder text = new StringBuilder(); text.AppendLine("# Generated automatically by TameableAnimals when entering a world. No need to edit it."); text.AppendLine("# To make a creature from the last list tameable, add its name to ExtraCreatures"); text.AppendLine("# in TameableAnimals.adrirf7.Animals.cfg (comma-separated) and restart the game."); text.AppendLine(); text.AppendLine("== Tameable thanks to this mod =="); modTames.ForEach(delegate(string name) { text.AppendLine(name); }); text.AppendLine(); text.AppendLine("== Tameable in vanilla (not modified by this mod) =="); vanillaTames.ForEach(delegate(string name) { text.AppendLine(name); }); text.AppendLine(); text.AppendLine("== Other compatible creatures (add to ExtraCreatures) =="); available.ForEach(delegate(string name) { text.AppendLine(name); }); string text2 = Path.Combine(Paths.ConfigPath, "TameableAnimals.adrirf7.AvailableCreatures.txt"); try { File.WriteAllText(text2, text.ToString()); } catch (Exception ex) { TameableAnimalsPlugin.Log.LogWarning((object)("Could not write " + text2 + ": " + ex.Message)); } } private static void MakeTameable(GameObject adult, SpeciesSettings settings, Dictionary<string, GameObject> byName, Tameable reference) { Tameable val = adult.AddComponent<Tameable>(); val.m_tamingTime = TameableAnimalsPlugin.TamingTime.Value; val.m_fedDuration = TameableAnimalsPlugin.FedDuration.Value; val.m_commandable = false; if ((Object)(object)reference != (Object)null) { val.m_tamedEffect = reference.m_tamedEffect; val.m_sootheEffect = reference.m_sootheEffect; val.m_petEffect = reference.m_petEffect; } adult.AddComponent<TameableAnimal>(); MonsterAI component = adult.GetComponent<MonsterAI>(); if (!((Object)(object)component != (Object)null)) { return; } List<ItemDrop> list = new List<ItemDrop>(); foreach (string item in TameableAnimalsPlugin.ParseList(settings.Foods.Value)) { if (byName.TryGetValue(item, out var value) && (Object)(object)value.GetComponent<ItemDrop>() != (Object)null) { list.Add(value.GetComponent<ItemDrop>()); } else { TameableAnimalsPlugin.Log.LogWarning((object)("Unknown food for " + ((Object)adult).name + ": " + item)); } } component.m_consumeItems = list; } private static void AddProcreation(GameObject adult, GameObject baby, Procreation reference) { Procreation val = adult.AddComponent<Procreation>(); val.m_offspring = baby; val.m_pregnancyDuration = TameableAnimalsPlugin.PregnancyDuration.Value; val.m_pregnancyChance = TameableAnimalsPlugin.PregnancyChance.Value; val.m_requiredLovePoints = TameableAnimalsPlugin.RequiredLovePoints.Value; val.m_maxCreatures = TameableAnimalsPlugin.MaxCreatures.Value; val.m_totalCheckRange = TameableAnimalsPlugin.TotalCheckRange.Value; val.m_partnerCheckRange = PartnerRange(adult); val.m_spawnOffset = 1f; if ((Object)(object)reference != (Object)null) { val.m_loveEffects = reference.m_loveEffects; val.m_birthEffects = reference.m_birthEffects; } } internal static float PartnerRange(GameObject animal) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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) float num = 0f; CapsuleCollider component = animal.GetComponent<CapsuleCollider>(); if ((Object)(object)component != (Object)null) { Vector3 localScale = animal.transform.localScale; float num2 = Mathf.Max(Mathf.Abs(localScale.x), Mathf.Abs(localScale.z)); num = ((component.direction == 1) ? (component.radius * 2f) : component.height) * num2; } return TameableAnimalsPlugin.PartnerCheckRange.Value + num; } internal static void RefreshPartnerRange(GameObject animal) { Procreation component = animal.GetComponent<Procreation>(); if ((Object)(object)component != (Object)null && (Object)(object)animal.GetComponent<TameableAnimal>() != (Object)null && (Object)(object)animal.GetComponent<Growup>() == (Object)null) { component.m_partnerCheckRange = PartnerRange(animal); } } private static GameObject CreateBaby(GameObject adult, SpeciesSettings settings, Dictionary<string, GameObject> byName) { //IL_00a3: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) GameObject val = adult; string text = settings.BabyModel.Value.Trim(); if (text.Length > 0) { if (byName.TryGetValue(text, out var value) && (Object)(object)value.GetComponent<Character>() != (Object)null) { val = value; } else { TameableAnimalsPlugin.Log.LogWarning((object)("BabyModel '" + text + "' not found for " + ((Object)adult).name + "; using the scaled-down adult.")); } } GameObject val2 = Object.Instantiate<GameObject>(val, GetPrefabHolder().transform, false); ((Object)val2).name = ((Object)adult).name + "_TA_Baby"; val2.transform.localPosition = Vector3.zero; val2.transform.localScale = (((Object)(object)val == (Object)(object)adult) ? (adult.transform.localScale * TameableAnimalsPlugin.BabyScale.Value) : val.transform.localScale); if ((Object)(object)val != (Object)(object)adult) { Procreation[] components = val2.GetComponents<Procreation>(); for (int i = 0; i < components.Length; i++) { Object.DestroyImmediate((Object)(object)components[i]); } if ((Object)(object)val2.GetComponent<Tameable>() == (Object)null) { Tameable component = adult.GetComponent<Tameable>(); Tameable obj = val2.AddComponent<Tameable>(); obj.m_tamingTime = component.m_tamingTime; obj.m_fedDuration = component.m_fedDuration; obj.m_commandable = false; obj.m_tamedEffect = component.m_tamedEffect; obj.m_sootheEffect = component.m_sootheEffect; obj.m_petEffect = component.m_petEffect; } if ((Object)(object)val2.GetComponent<TameableAnimal>() == (Object)null) { val2.AddComponent<TameableAnimal>(); } } Character component2 = val2.GetComponent<Character>(); string text2 = settings.BabyName.Value.Trim(); component2.m_name = ((text2.Length > 0) ? text2 : Translations.GetBabyNameToken(((Object)adult).name, adult.GetComponent<Character>().m_name)); component2.m_health = Mathf.Max(1f, component2.m_health * TameableAnimalsPlugin.BabyHealthFactor.Value); CharacterDrop component3 = val2.GetComponent<CharacterDrop>(); if ((Object)(object)component3 != (Object)null) { Object.DestroyImmediate((Object)(object)component3); } Growup val3 = val2.GetComponent<Growup>(); if ((Object)(object)val3 == (Object)null) { val3 = val2.AddComponent<Growup>(); } val3.m_grownPrefab = adult; val3.m_growTime = TameableAnimalsPlugin.GrowTime.Value; val3.m_inheritTame = true; TintRenderers(val2, TameableAnimalsPlugin.ParseTint(settings.BabyTint.Value)); return val2; } private static void TintRenderers(GameObject baby, Color tint) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (tint == Color.white) { return; } Dictionary<Material, Material> dictionary = new Dictionary<Material, Material>(); Renderer[] componentsInChildren = baby.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!(val is SkinnedMeshRenderer) && !(val is MeshRenderer)) { continue; } Material[] sharedMaterials = val.sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if ((Object)(object)val2 == (Object)null) { continue; } if (!dictionary.TryGetValue(val2, out var value)) { value = new Material(val2) { name = ((Object)val2).name + "_TA_Baby" }; string[] array = s_colorProperties; foreach (string text in array) { if (value.HasProperty(text)) { value.SetColor(text, value.GetColor(text) * tint); } } dictionary[val2] = value; } sharedMaterials[j] = value; } val.sharedMaterials = sharedMaterials; } } internal static GameObject GetPrefabHolder() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)s_prefabHolder == (Object)null) { s_prefabHolder = new GameObject("TameableAnimals_Prefabs"); s_prefabHolder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)s_prefabHolder); } return s_prefabHolder; } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ZNetScene_Awake_Patch { [HarmonyPriority(0)] private static void Prefix(ZNetScene __instance) { CreatureSetup.Setup(__instance.m_prefabs); FeedBowlSetup.Register(__instance.m_prefabs); } } internal class DebugProfiler : MonoBehaviour { private const float SlowFrameSeconds = 0.05f; private const double SlowCallMs = 2.0; private static readonly (Type type, string method)[] s_watched = new(Type, string)[10] { (typeof(Container), "Interact"), (typeof(Container), "RPC_RequestOpen"), (typeof(Container), "RPC_OpenResponse"), (typeof(Container), "CheckForChanges"), (typeof(InventoryGui), "Show"), (typeof(InventoryGui), "UpdateContainer"), (typeof(InventoryGui), "Update"), (typeof(InventoryGui), "UpdateCraftingPanel"), (typeof(InventoryGrid), "UpdateInventory"), (typeof(FeedBowl), "RefreshFood") }; internal static void Install(Harmony harmony, GameObject host) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(typeof(DebugProfiler), "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(DebugProfiler), "Postfix", (Type[])null); (Type, string)[] array = s_watched; for (int i = 0; i < array.Length; i++) { var (type, text) = array[i]; foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { if (declaredMethod.Name == text && !declaredMethod.IsAbstract && !declaredMethod.ContainsGenericParameters) { harmony.Patch((MethodBase)declaredMethod, val, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } string[] array2 = new string[4] { "UpdateCraftingPanel", "UpdateRecipeList", "SetupRequirementList", "UpdateRecipe" }; foreach (string text2 in array2) { foreach (MethodInfo declaredMethod2 in AccessTools.GetDeclaredMethods(typeof(InventoryGui))) { if (!(declaredMethod2.Name != text2)) { Patches patchInfo = Harmony.GetPatchInfo((MethodBase)declaredMethod2); if (patchInfo != null) { TameableAnimalsPlugin.Log.LogInfo((object)("[Profiler] Patches on InventoryGui." + text2 + ": " + string.Join(", ", patchInfo.Owners))); } } } } foreach (MethodInfo declaredMethod3 in AccessTools.GetDeclaredMethods(typeof(Player))) { if (declaredMethod3.Name == "HaveRequirements" || declaredMethod3.Name == "GetAvailableRecipes" || declaredMethod3.Name == "UpdateKnownRecipesList") { Patches patchInfo2 = Harmony.GetPatchInfo((MethodBase)declaredMethod3); if (patchInfo2 != null) { TameableAnimalsPlugin.Log.LogInfo((object)("[Profiler] Patches on Player." + declaredMethod3.Name + ": " + string.Join(", ", patchInfo2.Owners))); } harmony.Patch((MethodBase)declaredMethod3, val, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } harmony.Patch((MethodBase)AccessTools.Method(typeof(Procreation), "Procreate", (Type[])null, (Type[])null), new HarmonyMethod(typeof(DebugProfiler), "ProcreatePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); host.AddComponent<DebugProfiler>(); TameableAnimalsPlugin.Log.LogInfo((object)("[Profiler] Logging slow frames (> " + 50f + " ms) and slow calls (> " + 2.0 + " ms).")); } internal static void LogProcreation(Procreation procreation) { //IL_00d6: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((Component)procreation).GetComponent<TameableAnimal>() == (Object)null) && procreation.m_nview.IsValid() && procreation.m_nview.IsOwner()) { GameObject prefab = ZNetScene.instance.GetPrefab(procreation.m_nview.GetZDO().GetPrefab()); GameObject prefab2 = ZNetScene.instance.GetPrefab(Utils.GetPrefabName(procreation.m_offspring)); if ((Object)(object)prefab == (Object)null || (Object)(object)prefab2 == (Object)null) { TameableAnimalsPlugin.Log.LogInfo((object)("[Breeding] " + ((Object)procreation).name + ": prefab or offspring not found (self=" + ((object)prefab)?.ToString() + ", offspring=" + ((object)procreation.m_offspring)?.ToString() + ")")); return; } Vector3 position = ((Component)procreation).transform.position; int nrOfInstances = SpawnSystem.GetNrOfInstances(prefab, position, procreation.m_totalCheckRange, false, false); int nrOfInstances2 = SpawnSystem.GetNrOfInstances(prefab2, position, procreation.m_totalCheckRange, false, false); int nrOfInstances3 = SpawnSystem.GetNrOfInstances(prefab, position, procreation.m_partnerCheckRange, false, false); int nrOfInstances4 = SpawnSystem.GetNrOfInstances(prefab, position, procreation.m_partnerCheckRange, false, true); TameableAnimalsPlugin.Log.LogInfo((object)("[Breeding] " + ((Object)prefab).name + " tamed=" + procreation.m_tameable.IsTamed() + " hungry=" + procreation.m_tameable.IsHungry() + " alerted=" + ((Object)(object)procreation.m_baseAI != (Object)null && procreation.m_baseAI.IsAlerted()) + " pregnant=" + procreation.IsPregnant() + " love=" + procreation.GetLovePoints() + "/" + procreation.m_requiredLovePoints + " population=" + (nrOfInstances + nrOfInstances2) + "/" + procreation.m_maxCreatures + " (in " + procreation.m_totalCheckRange + "m) partners: " + nrOfInstances3 + " within " + procreation.m_partnerCheckRange + "m, " + nrOfInstances4 + " ready (needs 2 incl. itself)")); } } private static void ProcreatePrefix(Procreation __instance) { LogProcreation(__instance); } private static void Prefix(out long __state) { __state = Stopwatch.GetTimestamp(); } private static void Postfix(long __state, MethodBase __originalMethod) { double num = (double)(Stopwatch.GetTimestamp() - __state) * 1000.0 / (double)Stopwatch.Frequency; if (num > 2.0) { TameableAnimalsPlugin.Log.LogInfo((object)("[Profiler] " + __originalMethod.DeclaringType?.Name + "." + __originalMethod.Name + " took " + num.ToString("0.0") + " ms (frame " + Time.frameCount + ")")); } } private void Update() { float unscaledDeltaTime = Time.unscaledDeltaTime; if (unscaledDeltaTime > 0.05f && Time.frameCount > 10) { string text = (((Object)(object)InventoryGui.instance != (Object)null && (Object)(object)InventoryGui.instance.m_currentContainer != (Object)null) ? ((Object)InventoryGui.instance.m_currentContainer).name : "-"); TameableAnimalsPlugin.Log.LogInfo((object)("[Profiler] Slow frame " + (Time.frameCount - 1) + ": " + (unscaledDeltaTime * 1000f).ToString("0") + " ms, open container: " + text)); } } } internal class FeedBowlType { public string PrefabName; public string NameToken; public string DescriptionToken; public int Width; public int Height; public ConfigEntry<float> Scale; public ConfigEntry<string> Recipe; public float BaseRimHeight; public string SampleFood; public Color WoodTint = Color.white; public bool BronzeBand; public float IconFrame = 1f; public float IconFill = 0.4f; public Material[] Materials; public Material[] BandMaterials; public GameObject Prefab; public Vector3 ModelPosition; public Vector3 ModelScale; public Bounds ModelBounds; public float Diameter = 2f; public float MinWidth = 2f; public float RimHeight = 0.5f; public float FloorHeight = 0.1f; public float InnerRadius = 0.7f; public float ItemSize = 0.3f; public List<FeedBowl.Slot> Slots; public int Capacity => Width * Height; } internal static class FeedBowlSetup { private const string SourceLocation = "Hildir_camp"; private const string SourceObject = "fi_vil_container_bucket01"; private const string ChestPrefab = "piece_chest_wood"; private const float ItemSizeFactor = 0.08f; private const float MinItemSize = 0.15f; private const float BandHeight = 0.4f; private static FeedBowlType[] s_types; private static Mesh s_mesh; private static Material[] s_materials; private static HashSet<string> s_allowedFoods; private static Quaternion s_sourceRotation = Quaternion.identity; private static Vector3 s_sourceScale = Vector3.one; private static float s_floorFraction = 0.3f; private static float s_innerRadiusFraction = 0.8f; private static bool s_measured; private static Mesh s_bandMesh; private static bool s_bandMeshTried; private static readonly Color BronzeColor = new Color(0.72f, 0.45f, 0.2f); private static readonly string[] s_colorProperties = new string[4] { "_Color", "_BaseColor", "_MainColor", "_TintColor" }; internal static bool Enabled => TameableAnimalsPlugin.FeedBowlEnabled.Value; internal static FeedBowlType[] Types { get { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) if (s_types == null) { s_types = new FeedBowlType[2] { new FeedBowlType { PrefabName = "TA_FeedBowlSmall", NameToken = "$ta_piece_feedbowl_small", DescriptionToken = "$ta_piece_feedbowl_desc", Width = 1, Height = 1, Scale = TameableAnimalsPlugin.SmallBowlScale, Recipe = TameableAnimalsPlugin.SmallBowlRecipe, BaseRimHeight = 0.55f, SampleFood = "Carrot", IconFrame = 0.7f, IconFill = 0.15f }, new FeedBowlType { PrefabName = "TA_FeedBowl", NameToken = "$ta_piece_feedbowl_large", DescriptionToken = "$ta_piece_feedbowl_desc", Width = 3, Height = 1, Scale = TameableAnimalsPlugin.LargeBowlScale, Recipe = TameableAnimalsPlugin.LargeBowlRecipe, BaseRimHeight = 0.55f, SampleFood = "Turnip", IconFrame = 1f, IconFill = 0.8f, WoodTint = new Color(0.72f, 0.5f, 0.38f), BronzeBand = true } }; } return s_types; } } internal static FeedBowlType GetType(string prefabName) { FeedBowlType[] types = Types; foreach (FeedBowlType feedBowlType in types) { if (feedBowlType.PrefabName == prefabName) { return feedBowlType; } } return null; } internal static void Register(List<GameObject> prefabs) { s_allowedFoods = null; if (!Enabled) { return; } FeedBowlType[] types = Types; for (int i = 0; i < types.Length; i++) { GameObject orCreatePrefab = GetOrCreatePrefab(types[i], prefabs); if (!((Object)(object)orCreatePrefab == (Object)null)) { if (!prefabs.Contains(orCreatePrefab)) { prefabs.Add(orCreatePrefab); } AddToHammer(prefabs, orCreatePrefab); } } } internal static void RegisterLate(ZNetScene scene) { Register(scene.m_prefabs); FeedBowlType[] types = Types; foreach (FeedBowlType feedBowlType in types) { if ((Object)(object)feedBowlType.Prefab != (Object)null) { scene.m_namedPrefabs[StringExtensionMethods.GetStableHashCode(feedBowlType.PrefabName)] = feedBowlType.Prefab; } } } private static GameObject GetOrCreatePrefab(FeedBowlType type, List<GameObject> prefabs) { //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)type.Prefab != (Object)null) { return type.Prefab; } GameObject val = prefabs.Find((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == "piece_chest_wood"); Container val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponentInChildren<Container>(true) : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val.GetComponent<Piece>() == (Object)null || (Object)(object)val.GetComponent<WearNTear>() == (Object)null) { TameableAnimalsPlugin.Log.LogWarning((object)"Could not create the feeding bowl: piece_chest_wood not found."); return null; } GameObject val3 = Object.Instantiate<GameObject>(val, CreatureSetup.GetPrefabHolder().transform, false); ((Object)val3).name = type.PrefabName; for (int num = val3.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)val3.transform.GetChild(num)).gameObject); } Collider[] components = val3.GetComponents<Collider>(); for (int num2 = 0; num2 < components.Length; num2++) { Object.DestroyImmediate((Object)(object)components[num2]); } LODGroup component = val3.GetComponent<LODGroup>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } int layer = val.layer; GameObject val4 = NewChild(val3.transform, "model", layer); val4.AddComponent<MeshFilter>(); val4.AddComponent<MeshRenderer>(); NewChild(val3.transform, "collider", layer).AddComponent<BoxCollider>(); NewChild(val3.transform, "food", layer); if (type.BronzeBand) { GameObject obj = NewChild(val3.transform, "band", layer); obj.AddComponent<MeshFilter>(); obj.AddComponent<MeshRenderer>(); } Container val5 = val3.GetComponent<Container>(); if ((Object)(object)val5 == (Object)null) { val5 = val3.AddComponent<Container>(); val5.m_bkg = val2.m_bkg; val5.m_openEffects = val2.m_openEffects; val5.m_closeEffects = val2.m_closeEffects; } val5.m_name = type.NameToken; val5.m_width = type.Width; val5.m_height = type.Height; val5.m_open = null; val5.m_closed = null; val5.m_defaultItems = new DropTable(); val5.m_autoDestroyEmpty = false; val5.m_privacy = (PrivacySetting)2; WearNTear component2 = val3.GetComponent<WearNTear>(); component2.m_new = val4; component2.m_worn = val4; component2.m_broken = val4; component2.m_wet = null; component2.m_snow = null; component2.m_snowWorn = null; component2.m_snowBroken = null; component2.m_fragmentRoots = null; component2.m_autoCreateFragments = false; component2.m_nonSolidRenderers = new List<Renderer>(); Piece component3 = val3.GetComponent<Piece>(); component3.m_name = type.NameToken; component3.m_description = type.DescriptionToken; component3.m_category = (PieceCategory)4; component3.m_comfort = 0; component3.m_comfortGroup = (ComfortGroup)0; component3.m_comfortObject = null; component3.m_resources = ParseRecipe(type, prefabs); GameObject val6 = prefabs.Find((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == type.SampleFood); ItemDrop val7 = (Object.op_Implicit((Object)(object)val6) ? val6.GetComponent<ItemDrop>() : null); if ((Object)(object)val7 != (Object)null && val7.m_itemData.m_shared.m_icons.Length != 0) { component3.m_icon = val7.m_itemData.m_shared.m_icons[0]; } val3.AddComponent<FeedBowl>(); type.Prefab = val3; if ((Object)(object)s_mesh != (Object)null) { ComputeLayout(type); ApplyModel(type, val3); } return val3; } private static GameObject NewChild(Transform parent, string name, int layer) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown GameObject val = new GameObject(name) { layer = layer }; val.transform.SetParent(parent, false); return val; } private static Requirement[] ParseRecipe(FeedBowlType type, List<GameObject> prefabs) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown List<Requirement> list = new List<Requirement>(); string[] array = (type.Recipe.Value ?? "").Split(','); foreach (string obj in array) { string[] array2 = obj.Split(':'); if (array2.Length == 2 && int.TryParse(array2[1].Trim(), out var result)) { string name = array2[0].Trim(); GameObject val = prefabs.Find((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == name); ItemDrop val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 == (Object)null) { TameableAnimalsPlugin.Log.LogWarning((object)("Unknown feeding bowl ingredient: " + name)); continue; } list.Add(new Requirement { m_resItem = val2, m_amount = result, m_amountPerLevel = 0, m_recover = true }); } } return list.ToArray(); } private static void AddToHammer(List<GameObject> prefabs, GameObject bowl) { GameObject val = prefabs.Find((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == "Hammer"); PieceTable val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : val.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_buildPieces); if ((Object)(object)val2 == (Object)null) { TameableAnimalsPlugin.Log.LogWarning((object)"Could not add the feeding bowl to the hammer."); return; } val2.m_pieces.RemoveAll((GameObject p) => (Object)(object)p == (Object)null || (((Object)p).name == ((Object)bowl).name && (Object)(object)p != (Object)(object)bowl)); if (!val2.m_pieces.Contains(bowl)) { val2.m_pieces.Add(bowl); } } internal static void LoadModel(List<ZoneLocation> locations) { if ((Object)(object)s_mesh == (Object)null && !FindSourceModel(locations)) { TameableAnimalsPlugin.Log.LogWarning((object)"Could not find the bowl model (fi_vil_container_bucket01 in Hildir_camp)."); } else { Reapply(); } } private static bool FindSourceModel(List<ZoneLocation> locations) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00e5: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) foreach (ZoneLocation location in locations) { if (!(location.m_prefabName != "Hildir_camp")) { location.m_prefab.Load(); GameObject asset = location.m_prefab.Asset; Transform val = (Object.op_Implicit((Object)(object)asset) ? BearSaddle.FindDeep(asset.transform, "fi_vil_container_bucket01") : null); MeshFilter val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<MeshFilter>() : null); MeshRenderer val3 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<MeshRenderer>() : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null || (Object)(object)val3 == (Object)null) { return false; } s_mesh = val2.sharedMesh; s_materials = ((Renderer)val3).sharedMaterials; Quaternion val4 = Quaternion.Inverse(asset.transform.rotation) * val.rotation; Vector3 eulerAngles = ((Quaternion)(ref val4)).eulerAngles; s_sourceRotation = Quaternion.Euler(Mathf.Round(eulerAngles.x / 90f) * 90f, 0f, Mathf.Round(eulerAngles.z / 90f) * 90f); s_sourceScale = Abs(val.lossyScale); MeasureMesh(); return true; } } return false; } private static void MeasureMesh() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0052: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_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_00bd: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0121: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_013d: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: 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_017a: 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) s_measured = false; if (!s_mesh.isReadable) { return; } Matrix4x4 matrix = Matrix4x4.TRS(Vector3.zero, s_sourceRotation, s_sourceScale); Vector3[] vertices = s_mesh.vertices; Bounds bounds = GetBounds(s_mesh.bounds, matrix); float num = Mathf.Min(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z) * 0.5f; float y = ((Bounds)(ref bounds)).size.y; if (vertices.Length == 0 || y <= 0.0001f || num <= 0.0001f) { return; } float num2 = float.MinValue; Vector3[] array = vertices; Vector2 val3; foreach (Vector3 val in array) { Vector3 val2 = ((Matrix4x4)(ref matrix)).MultiplyPoint3x4(val) - ((Bounds)(ref bounds)).center; val3 = new Vector2(val2.x, val2.z); if (((Vector2)(ref val3)).magnitude < num * 0.45f && val2.y < 0f) { num2 = Mathf.Max(num2, val2.y); } } float num3 = float.MaxValue; array = vertices; foreach (Vector3 val4 in array) { Vector3 val5 = ((Matrix4x4)(ref matrix)).MultiplyPoint3x4(val4) - ((Bounds)(ref bounds)).center; if (val5.y > num2 + y * 0.15f && val5.y < ((Bounds)(ref bounds)).extents.y - y * 0.1f) { float num4 = num3; val3 = new Vector2(val5.x, val5.z); num3 = Mathf.Min(num4, ((Vector2)(ref val3)).magnitude); } } if (num2 > float.MinValue) { s_floorFraction = Mathf.Clamp01((num2 + ((Bounds)(ref bounds)).extents.y) / y); } if (num3 < float.MaxValue && num3 > num * 0.3f) { s_innerRadiusFraction = Mathf.Clamp01(num3 / num); } s_measured = true; } private static void ComputeLayout(FeedBowlType type) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0058: 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_0084: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00eb: 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_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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(type.Scale.Value, 0.2f, 5f); Bounds bounds = GetBounds(s_mesh.bounds, Matrix4x4.TRS(Vector3.zero, s_sourceRotation, s_sourceScale)); float num2 = type.BaseRimHeight * Mathf.Sqrt(num); Vector3 val = s_sourceScale * num; val.y = s_sourceScale.y * num2 / Mathf.Max(0.0001f, ((Bounds)(ref bounds)).size.y); type.ModelScale = val; Bounds bounds2 = GetBounds(s_mesh.bounds, Matrix4x4.TRS(Vector3.zero, s_sourceRotation, val)); type.ModelPosition = new Vector3(0f - ((Bounds)(ref bounds2)).center.x, 0f - ((Bounds)(ref bounds2)).min.y, 0f - ((Bounds)(ref bounds2)).center.z); type.ModelBounds = new Bounds(((Bounds)(ref bounds2)).center + type.ModelPosition, ((Bounds)(ref bounds2)).size); type.Diameter = Mathf.Max(((Bounds)(ref bounds2)).size.x, ((Bounds)(ref bounds2)).size.z); type.MinWidth = Mathf.Min(((Bounds)(ref bounds2)).size.x, ((Bounds)(ref bounds2)).size.z); type.RimHeight = ((Bounds)(ref bounds2)).size.y; type.FloorHeight = type.RimHeight * s_floorFraction; type.InnerRadius = type.MinWidth * 0.5f * s_innerRadiusFraction; type.ItemSize = 0.15f + type.MinWidth * 0.08f; type.Slots = null; type.Materials = TintMaterials(s_materials, type.WoodTint, type.PrefabName); type.BandMaterials = (type.BronzeBand ? TintMaterials(s_materials, BronzeColor, type.PrefabName + "_band", metallic: true) : null); } private static Mesh GetBandMesh() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a0: 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_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_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: 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_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0518: 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_0524: Expected O, but got Unknown //IL_0525: Expected O, but got Unknown //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: 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_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: 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) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) if (s_bandMeshTried) { return s_bandMesh; } s_bandMeshTried = true; if ((Object)(object)s_mesh == (Object)null || !s_mesh.isReadable) { return null; } Vector3[] vertices = s_mesh.vertices; Vector3[] normals = s_mesh.normals; Vector2[] uv = s_mesh.uv; bool flag = normals.Length == vertices.Length; bool flag2 = uv.Length == vertices.Length; int[] triangles = s_mesh.triangles; Dictionary<Vector3Int, int> dictionary = new Dictionary<Vector3Int, int>(); int[] array = new int[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { Vector3Int key = Vector3Int.RoundToInt(vertices[i] * 10000f); if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = dictionary.Count); } array[i] = value; } int[] parent = new int[dictionary.Count]; for (int j = 0; j < parent.Length; j++) { parent[j] = j; } for (int k = 0; k < triangles.Length; k += 3) { int num = Find(array[triangles[k]]); parent[Find(array[triangles[k + 1]])] = num; parent[Find(array[triangles[k + 2]])] = num; } Dictionary<int, int> dictionary2 = new Dictionary<int, int>(); for (int l = 0; l < triangles.Length; l += 3) { int key2 = Find(array[triangles[l]]); dictionary2.TryGetValue(key2, out var value2); dictionary2[key2] = value2 + 1; } int num2 = -1; int num3 = 0; foreach (KeyValuePair<int, int> item6 in dictionary2) { if (item6.Value > num3) { num2 = item6.Key; num3 = item6.Value; } } Matrix4x4 upright = Matrix4x4.TRS(Vector3.zero, s_sourceRotation, s_sourceScale); float num4 = float.MaxValue; float num5 = float.MinValue; Vector3[] array2 = vertices; foreach (Vector3 val in array2) { float y = ((Matrix4x4)(ref upright)).MultiplyPoint3x4(val).y; num4 = Mathf.Min(num4, y); num5 = Mathf.Max(num5, y); } float num6 = num4 + (num5 - num4) * 0.4f; List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<int> list4 = new List<int>(); new List<int>(3); List<(Vector3, Vector3, Vector2)> list5 = new List<(Vector3, Vector3, Vector2)>(4); for (int n = 0; n < triangles.Length; n += 3) { if (Find(array[triangles[n]]) != num2 || !IsOuterWall(upright, vertices[triangles[n]], vertices[triangles[n + 1]], vertices[triangles[n + 2]])) { continue; } list5.Clear(); for (int num7 = 0; num7 < 3; num7++) { int num8 = triangles[n + num7]; int num9 = triangles[n + (num7 + 1) % 3]; float y2 = ((Matrix4x4)(ref upright)).MultiplyPoint3x4(vertices[num8]).y; float y3 = ((Matrix4x4)(ref upright)).MultiplyPoint3x4(vertices[num9]).y; bool num10 = y2 <= num6; bool flag3 = y3 <= num6; if (num10) { list5.Add((vertices[num8], flag ? normals[num8] : Vector3.up, flag2 ? uv[num8] : Vector2.zero)); } if (num10 != flag3) { float num11 = (num6 - y2) / (y3 - y2); Vector3 item = Vector3.Lerp(vertices[num8], vertices[num9], num11); Vector3 item2; if (!flag) { item2 = Vector3.up; } else { Vector3 val2 = Vector3.Lerp(normals[num8], normals[num9], num11); item2 = ((Vector3)(ref val2)).normalized; } list5.Add((item, item2, flag2 ? Vector2.Lerp(uv[num8], uv[num9], num11) : Vector2.zero)); } } if (list5.Count < 3) { continue; } int count2 = list.Count; foreach (var (item3, item4, item5) in list5) { list.Add(item3); list2.Add(item4); list3.Add(item5); } for (int num12 = 1; num12 < list5.Count - 1; num12++) { list4.Add(count2); list4.Add(count2 + num12); list4.Add(count2 + num12 + 1); } } if (list4.Count == 0) { return null; } Mesh val3 = new Mesh { name = "TA_FeedBowlBand" }; val3.SetVertices(list); val3.SetNormals(list2); val3.SetUVs(0, list3); val3.SetTriangles(list4, 0); val3.RecalculateBounds(); s_bandMesh = val3; return val3; int Find(int x) { while (parent[x] != x) { parent[x] = parent[parent[x]]; x = parent[x]; } return x; } } private static bool IsOuterWall(Matrix4x4 upright, Vector3 a, Vector3 b, Vector3 c) { //IL_0002: Unknown result type (might be