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 OctoPack v1.7.3
plugins/OctoPack/OctoPack.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("OctoPack")] [assembly: AssemblyCompany("Octodad")] [assembly: AssemblyCopyright("Octodad")] [assembly: AssemblyFileVersion("1.7.3.0")] [assembly: AssemblyMetadata("AI_Assisted_Creation", "Created and maintained with assistance from OpenAI Codex.")] [assembly: AssemblyMetadata("AI_Model_Vendor", "OpenAI")] [assembly: AssemblyVersion("1.7.3.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace OctoPack { internal sealed class ApprovedKeepsakePart { internal Mesh Mesh; internal Material Material; } internal sealed class ApprovedKeepsakeModel { internal readonly List<ApprovedKeepsakePart> Parts = new List<ApprovedKeepsakePart>(); internal readonly List<Vector3> SeatPoints = new List<Vector3>(); internal void BuildSeatPoints() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_00cf: 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_00db: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); Vector3 val2 = -val; foreach (ApprovedKeepsakePart part in Parts) { Vector3 val3 = val; Bounds bounds = part.Mesh.bounds; val = Vector3.Min(val3, ((Bounds)(ref bounds)).min); Vector3 val4 = val2; bounds = part.Mesh.bounds; val2 = Vector3.Max(val4, ((Bounds)(ref bounds)).max); } Vector3[] array = (Vector3[])(object)new Vector3[96]; bool[] array2 = new bool[array.Length]; foreach (ApprovedKeepsakePart part2 in Parts) { Vector3[] vertices = part2.Mesh.vertices; foreach (Vector3 val5 in vertices) { int num = Mathf.Clamp((int)(Mathf.InverseLerp(val.x, val2.x, val5.x) * 8f), 0, 7); int num2 = Mathf.Clamp((int)(Mathf.InverseLerp(val.y, val2.y, val5.y) * 12f), 0, 11) * 8 + num; if (!array2[num2] || val5.z > array[num2].z) { array[num2] = val5; array2[num2] = true; } } } for (int j = 0; j < array.Length; j++) { if (array2[j]) { SeatPoints.Add(array[j]); } } } internal void Attach(Transform mount, List<Renderer> renderers, int layer) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) foreach (ApprovedKeepsakePart part in Parts) { GameObject val = new GameObject(((Object)part.Mesh).name) { layer = layer }; val.transform.SetParent(mount, false); val.AddComponent<MeshFilter>().sharedMesh = part.Mesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); ((Renderer)val2).sharedMaterial = part.Material; renderers.Add((Renderer)(object)val2); } } } internal sealed class ApprovedKeepsakeAsset { internal readonly ApprovedKeepsakeModel[] Models = new ApprovedKeepsakeModel[7]; internal static ApprovedKeepsakeAsset Load(Material source) { //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_0102: 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_0112: Expected O, but got Unknown //IL_01b6: 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_01bd: Expected O, but got Unknown //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) ApprovedKeepsakeAsset approvedKeepsakeAsset = new ApprovedKeepsakeAsset(); int num = 0; using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OctoPack.ApprovedKeepsakes"); using BinaryReader binaryReader = new BinaryReader(stream ?? throw new FileNotFoundException("Missing approved keepsakes")); if (binaryReader.ReadInt32() != 1329812562 || binaryReader.ReadInt32() != 1) { throw new InvalidDataException("Invalid approved keepsake data"); } int num2 = Count(binaryReader, 1, 64); Texture2D[] array = (Texture2D[])(object)new Texture2D[num2]; for (int i = 0; i < num2; i++) { int num3 = binaryReader.ReadInt32(); int num4 = binaryReader.ReadInt32(); if (num3 != 128 || num4 != 128) { throw new InvalidDataException("Invalid keepsake texture size"); } byte[] array2 = binaryReader.ReadBytes(num3 * num4 * 4); if (array2.Length != num3 * num4 * 4) { throw new EndOfStreamException(); } int value = BackpackPlugin.Instance.KeepsakeTexturePixelSize.Value; array2 = PixelBlocks.Reduce(array2, num3, num4, value); Texture2D val = new Texture2D(num3 / value, num4 / value, (TextureFormat)4, false) { name = "OctoPack_ApprovedKeepsakeTexture_" + i, filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)0 }; val.LoadRawTextureData(array2); val.Apply(false, true); array[i] = val; } int num5 = Count(binaryReader, 1, 64); Material[] array3 = (Material[])(object)new Material[num5]; bool[] array4 = new bool[num5]; Shader val2 = Shader.Find("Standard"); bool flag = Object.op_Implicit((Object)(object)val2) && val2.isSupported; for (int j = 0; j < num5; j++) { int num6 = Count(binaryReader, 0, num2 - 1); float num7 = Unit(binaryReader); float rough = Unit(binaryReader); bool flag2 = binaryReader.ReadInt32() != 0; Material val3 = (flag ? new Material(val2) : new Material(source)); ((Object)val3).name = "OctoPack_ApprovedKeepsakeMaterial_" + j; Configure(val3, (Texture)(object)array[num6], num7, rough); object profile; if (!(num7 > 0.3f)) { switch (j) { default: profile = "Stone"; break; case 5: profile = "Wood"; break; case 1: case 2: profile = "Bone"; break; case 0: profile = "Leather"; break; } } else { profile = "Metal"; } SurfaceDetail.Bind(val3, (string)profile, roll: false, keepsake: true); if (val3.HasProperty("_Cull")) { val3.SetInt("_Cull", (!flag2) ? 2 : 0); } else { array4[j] = flag2; } array3[j] = val3; } if (Count(binaryReader, 5, 5) != 5) { throw new InvalidDataException(); } for (int k = 0; k < 5; k++) { int num8 = Count(binaryReader, 0, 6); if (num8 == 2 || num8 == 3 || approvedKeepsakeAsset.Models[num8] != null) { throw new InvalidDataException("Unexpected approved boss index"); } ApprovedKeepsakeModel approvedKeepsakeModel = new ApprovedKeepsakeModel(); approvedKeepsakeAsset.Models[num8] = approvedKeepsakeModel; int num9 = Count(binaryReader, 1, 64); for (int l = 0; l < num9; l++) { int num10 = Count(binaryReader, 0, num5 - 1); int num11 = Count(binaryReader, 3, 60000); int num12 = Count(binaryReader, 3, 600000); if (num12 % 3 != 0) { throw new InvalidDataException("Incomplete keepsake triangles"); } Vector3[] array5 = (Vector3[])(object)new Vector3[num11]; Vector3[] array6 = (Vector3[])(object)new Vector3[num11]; Vector2[] array7 = (Vector2[])(object)new Vector2[num11]; int[] array8 = new int[num12]; for (int m = 0; m < num11; m++) { array5[m] = ReadV(binaryReader); array6[m] = ReadV(binaryReader); array7[m] = new Vector2(Finite(binaryReader), Finite(binaryReader)); } for (int n = 0; n < num12; n++) { array8[n] = Count(binaryReader, 0, num11 - 1); } approvedKeepsakeModel.Parts.Add(new ApprovedKeepsakePart { Mesh = BuildMesh(num8, l, array5, array6, array7, array8, back: false), Material = array3[num10] }); if (array4[num10]) { int[] array9 = new int[num12]; for (int num13 = 0; num13 < num12; num13 += 3) { array9[num13] = array8[num13]; array9[num13 + 1] = array8[num13 + 2]; array9[num13 + 2] = array8[num13 + 1]; } Vector3[] array10 = (Vector3[])(object)new Vector3[num11]; for (int num14 = 0; num14 < num11; num14++) { array10[num14] = -array6[num14]; } approvedKeepsakeModel.Parts.Add(new ApprovedKeepsakePart { Mesh = BuildMesh(num8, l, array5, array10, array7, array9, back: true), Material = array3[num10] }); num++; } } approvedKeepsakeModel.BuildSeatPoints(); } if (stream.Position != stream.Length) { throw new InvalidDataException("Unexpected approved keepsake bytes"); } BackpackPlugin.Instance.LogApprovedKeepsakes(((Object)array3[0].shader).name, num5, num); return approvedKeepsakeAsset; } private static void Configure(Material mat, Texture texture, float metal, float rough) { //IL_0012: 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_013f: 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_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_028f: Expected O, but got Unknown //IL_029d: Unknown result type (might be due to invalid IL or missing references) mat.SetTexture("_MainTex", texture); mat.SetTextureScale("_MainTex", Vector2.one); mat.SetTextureOffset("_MainTex", Vector2.zero); string[] array = new string[10] { "_BumpMap", "_NormalMap", "_ParallaxMap", "_DetailAlbedoMap", "_DetailNormalMap", "_OcclusionMap", "_EmissionMap", "_MetallicGlossMap", "_MetalGlossMap", "_MetalTex" }; foreach (string text in array) { if (mat.HasProperty(text)) { mat.SetTexture(text, (Texture)null); } } array = new string[9] { "_NORMALMAP", "_PARALLAXMAP", "_DETAIL_MULX2", "_EMISSION", "_METALLICGLOSSMAP", "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", "_ALPHATEST_ON", "_ALPHABLEND_ON", "_ALPHAPREMULTIPLY_ON" }; foreach (string text2 in array) { mat.DisableKeyword(text2); } mat.renderQueue = 2000; mat.SetOverrideTag("RenderType", "Opaque"); if (mat.HasProperty("_Color")) { mat.SetColor("_Color", Color.white); } if (mat.HasProperty("_EmissionColor")) { mat.SetColor("_EmissionColor", Color.black); } if (mat.HasProperty("_Mode")) { mat.SetFloat("_Mode", 0f); } if (mat.HasProperty("_SrcBlend")) { mat.SetInt("_SrcBlend", 1); } if (mat.HasProperty("_DstBlend")) { mat.SetInt("_DstBlend", 0); } if (mat.HasProperty("_ZWrite")) { mat.SetInt("_ZWrite", 1); } if (mat.HasProperty("_Metallic")) { mat.SetFloat("_Metallic", metal); } if (mat.HasProperty("_Glossiness")) { mat.SetFloat("_Glossiness", 1f - rough); } if (mat.HasProperty("_Smoothness")) { mat.SetFloat("_Smoothness", 1f - rough); } if (mat.HasProperty("_GlossMapScale")) { mat.SetFloat("_GlossMapScale", 1f); } if (mat.HasProperty("_SmoothnessTextureChannel")) { mat.SetFloat("_SmoothnessTextureChannel", 0f); } if (!(((Object)mat.shader).name != "Standard")) { return; } Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false) { name = "OctoPack_ApprovedMetalRoughness" }; val.SetPixel(0, 0, new Color(metal, metal, metal, 1f - rough)); val.Apply(false, true); bool flag = false; array = new string[3] { "_MetallicGlossMap", "_MetalGlossMap", "_MetalTex" }; foreach (string text3 in array) { if (mat.HasProperty(text3)) { mat.SetTexture(text3, (Texture)(object)val); flag = true; } } if (flag) { mat.EnableKeyword("_METALLICGLOSSMAP"); } } private static Mesh BuildMesh(int boss, int part, Vector3[] v, Vector3[] n, Vector2[] uv, int[] indices, bool back) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh(); ((Object)val).name = "OctoPack_Approved_" + BossProgress.Prefabs[boss] + "_" + part + (back ? "_Back" : ""); Mesh val2 = val; val2.vertices = v; val2.normals = n; val2.uv = uv; Color32[] array = (Color32[])(object)new Color32[v.Length]; for (int i = 0; i < array.Length; i++) { array[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } val2.colors32 = array; val2.triangles = indices; val2.RecalculateTangents(); val2.RecalculateBounds(); return val2; } private static int Count(BinaryReader r, int min, int max) { int num = r.ReadInt32(); if (num < min || num > max) { throw new InvalidDataException("Invalid approved keepsake count/index"); } return num; } private static float Finite(BinaryReader r) { float num = r.ReadSingle(); if (float.IsNaN(num) || float.IsInfinity(num)) { throw new InvalidDataException("Invalid keepsake float"); } return num; } private static float Unit(BinaryReader r) { float num = Finite(r); if (num < 0f || num > 1f) { throw new InvalidDataException("Invalid material factor"); } return num; } private static Vector3 ReadV(BinaryReader r) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(Finite(r), Finite(r), Finite(r)); } } internal sealed class BackpackAsset { internal readonly List<Mesh> Meshes = new List<Mesh>(); internal List<RigidPackPart> RigidParts; internal readonly List<Material> Materials = new List<Material>(); internal Vector3[] BodyVertices; internal PackEnvelope ContactEnvelope; internal PackEnvelope RollEnvelope; internal static readonly Vector3[] BonePositions = (Vector3[])(object)new Vector3[3] { new Vector3(0f, 0.45f, 0.105f), new Vector3(0f, 0.45f, 0.105f), new Vector3(0f, 0.265f, 0f) }; internal string SourceMaterial; internal static BackpackAsset Load(VisEquipment vis) { //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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Expected O, but got Unknown //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) BackpackAsset backpackAsset = new BackpackAsset(); List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); Material val = FindSourceMaterial(vis); backpackAsset.SourceMaterial = "restored vanilla material clone / " + ((Object)val).name + " / " + ((Object)val.shader).name; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OctoPack.Model")) { using BinaryReader binaryReader = new BinaryReader(stream ?? throw new FileNotFoundException("Embedded backpack model missing")); if (binaryReader.ReadInt32() != 1329812560 || binaryReader.ReadInt32() != 1) { throw new InvalidDataException("Wrong backpack model version"); } int num = binaryReader.ReadInt32(); if (num != 6) { throw new InvalidDataException("Expected six model materials"); } for (int i = 0; i < num; i++) { string text = binaryReader.ReadString(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num2 != 128 || num3 != 128) { throw new InvalidDataException("Invalid model texture size"); } byte[] array = binaryReader.ReadBytes(num2 * num3 * 4); if (array.Length != num2 * num3 * 4) { throw new EndOfStreamException(); } int value = BackpackPlugin.Instance.TexturePixelSize.Value; array = PixelBlocks.Reduce(array, num2, num3, value); Texture2D val2 = new Texture2D(num2 / value, num3 / value, (TextureFormat)4, false) { name = "OctoPack_" + text, filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)0 }; val2.LoadRawTextureData(array); val2.Apply(false, true); Material val3 = PackSurface.Create(val, text); BackpackPlugin.Instance.LogPackItem("Surface " + text + ": shader=" + ((Object)val3.shader).name + ", cull=" + (val3.HasProperty("_Cull") ? val3.GetFloat("_Cull").ToString() : "shader-defined") + ", keywords=" + string.Join(",", val3.shaderKeywords)); val3.SetTexture("_MainTex", (Texture)(object)val2); val3.SetTextureScale("_MainTex", Vector2.one); val3.SetTextureOffset("_MainTex", Vector2.zero); if (val3.HasProperty("_Color")) { val3.SetColor("_Color", Color.white); } object profile; switch (text) { default: profile = "Leather"; break; case "Iron": profile = "Metal"; break; case "Bedroll": case "Flax": profile = "Cloth"; break; } SurfaceDetail.Bind(val3, (string)profile, text == "Bedroll"); int num4 = binaryReader.ReadInt32(); if (num4 < 1 || num4 > 60000) { throw new InvalidDataException("Invalid vertex count"); } Vector3[] array2 = (Vector3[])(object)new Vector3[num4]; Vector3[] array3 = (Vector3[])(object)new Vector3[num4]; Vector2[] array4 = (Vector2[])(object)new Vector2[num4]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num4]; for (int j = 0; j < num4; j++) { array2[j] = V(binaryReader); array3[j] = V(binaryReader); array4[j] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); BoneWeight val4 = default(BoneWeight); ((BoneWeight)(ref val4)).boneIndex0 = binaryReader.ReadInt32(); ((BoneWeight)(ref val4)).boneIndex1 = binaryReader.ReadInt32(); ((BoneWeight)(ref val4)).boneIndex2 = binaryReader.ReadInt32(); ((BoneWeight)(ref val4)).boneIndex3 = binaryReader.ReadInt32(); ((BoneWeight)(ref val4)).weight0 = binaryReader.ReadSingle(); ((BoneWeight)(ref val4)).weight1 = binaryReader.ReadSingle(); ((BoneWeight)(ref val4)).weight2 = binaryReader.ReadSingle(); ((BoneWeight)(ref val4)).weight3 = binaryReader.ReadSingle(); BoneWeight val5 = val4; if (((BoneWeight)(ref val5)).boneIndex0 < 0 || ((BoneWeight)(ref val5)).boneIndex0 > 2 || ((BoneWeight)(ref val5)).boneIndex1 < 0 || ((BoneWeight)(ref val5)).boneIndex1 > 2 || ((BoneWeight)(ref val5)).boneIndex2 < 0 || ((BoneWeight)(ref val5)).boneIndex2 > 2 || ((BoneWeight)(ref val5)).boneIndex3 < 0 || ((BoneWeight)(ref val5)).boneIndex3 > 2) { throw new InvalidDataException("Invalid skin bone"); } array5[j] = val5; } int num5 = binaryReader.ReadInt32(); if (num5 < 3 || num5 > 120000 || num5 % 3 != 0) { throw new InvalidDataException("Invalid triangles"); } int[] array6 = new int[num5]; for (int k = 0; k < num5; k++) { array6[k] = binaryReader.ReadInt32(); if (array6[k] < 0 || array6[k] >= num4) { throw new InvalidDataException("Invalid mesh index"); } } Matrix4x4[] array7 = (Matrix4x4[])(object)new Matrix4x4[3]; for (int l = 0; l < 3; l++) { int num6 = l; Matrix4x4 val6 = Matrix4x4.TRS(BonePositions[l], Quaternion.identity, Vector3.one); array7[num6] = ((Matrix4x4)(ref val6)).inverse; } Mesh val7 = new Mesh { name = "OctoPack_" + text }; val7.vertices = array2; val7.normals = array3; val7.uv = array4; val7.boneWeights = array5; val7.bindposes = array7; val7.triangles = array6; Color32[] array8 = (Color32[])(object)new Color32[num4]; for (int m = 0; m < num4; m++) { array8[m] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } val7.colors32 = array8; val7.RecalculateTangents(); val7.RecalculateBounds(); if (text == "Leather") { backpackAsset.BodyVertices = array2; } if (text == "Leather" || text == "Flap") { list.AddRange(array2); } if (text == "Bedroll") { list2.AddRange(array2); } backpackAsset.Meshes.Add(val7); backpackAsset.Materials.Add(val3); } if (stream.Position != stream.Length) { throw new InvalidDataException("Unexpected model bytes"); } } backpackAsset.RigidParts = RigidPackPart.Build(backpackAsset.Meshes); backpackAsset.ContactEnvelope = BuildEnvelope(list.ToArray()); backpackAsset.RollEnvelope = BuildEnvelope(list2.ToArray()); return backpackAsset; } private static PackEnvelope BuildEnvelope(Vector3[] vertices) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0139: Unknown result type (might be due to invalid IL or missing references) float num = float.PositiveInfinity; float num2 = float.NegativeInfinity; Vector3[] array = vertices; foreach (Vector3 val in array) { num = Mathf.Min(num, val.y); num2 = Mathf.Max(num2, val.y); } num2 += 0.0001f; float[] array2 = new float[12]; float[] array3 = new float[12]; float[] array4 = new float[12]; float[] array5 = new float[12]; for (int j = 0; j < 12; j++) { array2[j] = (array4[j] = float.PositiveInfinity); array3[j] = (array5[j] = float.NegativeInfinity); } array = vertices; foreach (Vector3 val2 in array) { if (!(val2.y < num) && !(val2.y > num2)) { int num3 = Mathf.Clamp((int)((val2.y - num) / (num2 - num) * 12f), 0, 11); array2[num3] = Mathf.Min(array2[num3], val2.x); array3[num3] = Mathf.Max(array3[num3], val2.x); array4[num3] = Mathf.Min(array4[num3], val2.z); array5[num3] = Mathf.Max(array5[num3], val2.z); } } for (int k = 0; k < 12; k++) { if (!float.IsPositiveInfinity(array2[k])) { continue; } int num4 = -1; int num5 = 12; for (int l = 0; l < 12; l++) { if (!float.IsPositiveInfinity(array2[l]) && Math.Abs(k - l) < num5) { num4 = l; num5 = Math.Abs(k - l); } } if (num4 >= 0) { array2[k] = array2[num4]; array3[k] = array3[num4]; array4[k] = array4[num4]; array5[k] = array5[num4]; } } return new PackEnvelope(num, num2, array2, array3, array4, array5); } internal float SideSurface(float height, float z, bool right) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0063: 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) float num = (right ? (-0.5f) : 0.5f); bool flag = false; Vector3[] bodyVertices = BodyVertices; foreach (Vector3 val in bodyVertices) { if (Math.Abs(val.y - height) < 0.075f && Math.Abs(val.z - z) < 0.16f) { num = (right ? Mathf.Max(num, val.x) : Mathf.Min(num, val.x)); flag = true; } } if (!flag) { if (!right) { return -0.2f; } return 0.2f; } return num; } private static Material FindSourceMaterial(VisEquipment vis) { if (Object.op_Implicit((Object)(object)ObjectDB.instance)) { string[] array = new string[5] { "Wood", "LeatherScraps", "DeerHide", "Hammer", "Iron" }; foreach (string text in array) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text); if (!Object.op_Implicit((Object)(object)itemPrefab)) { continue; } Renderer[] componentsInChildren = itemPrefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!SolidRenderer(val)) { continue; } Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if (Usable(val2) && string.Equals(((Object)val2.shader).name, "Standard", StringComparison.Ordinal)) { return val2; } } } } } throw new InvalidOperationException("Native item Standard material is not loaded; will retry. Building shaders are excluded from this rendering test."); } private static bool SolidRenderer(Renderer renderer) { if (!(renderer is MeshRenderer)) { return renderer is SkinnedMeshRenderer; } return true; } private static bool Usable(Material material) { if (!Object.op_Implicit((Object)(object)material) || !Object.op_Implicit((Object)(object)material.shader) || !material.HasProperty("_MainTex") || material.renderQueue >= 2500) { return false; } return MaterialPolicy.IsSolid(((Object)material.shader).name, material.renderQueue, material.GetTag("RenderType", false, "")); } private static Vector3 V(BinaryReader r) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } } [DefaultExecutionOrder(3000)] public sealed class BackpackBounce : MonoBehaviour { [SerializeField] private Transform characterRoot; [SerializeField] private Transform springBone; [SerializeField] private Transform bedrollBone; [SerializeField] [Range(0f, 8f)] private float maximumBedrollSwayDegrees = 5f; [SerializeField] [Range(1f, 6f)] private float bedrollSpringFrequencyHz = 3.5f; [SerializeField] [Range(0f, 0.02f)] private float maximumBounceMeters = 0.018f; [SerializeField] [Range(0.5f, 3f)] private float metersPerBounce = 2f; [SerializeField] [Range(1f, 8f)] private float springFrequencyHz = 5f; [SerializeField] [Range(1f, 6f)] private float fullBounceSpeed = 1.8f; private readonly DampedSpring spring = new DampedSpring(); private readonly DampedSpring bedrollSpring = new DampedSpring(); private Vector3 restPosition; private Vector3 lastPosition; private Quaternion restBedrollRotation; private float filteredSpeed; private double phase; private bool initialized; private bool motionLogged; private int ticks; private Player playerComponent; private float sprintBlend; public float SprintBlend => sprintBlend; public float SprintMultiplier => Mathf.Lerp(1f, Object.op_Implicit((Object)(object)BackpackPlugin.Instance) ? BackpackPlugin.Instance.SprintMotionMultiplier.Value : 2.2f, sprintBlend); public void Bind(Transform player, Transform movableBone = null, Transform movableBedroll = null) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) Restore(); characterRoot = player; playerComponent = (Object.op_Implicit((Object)(object)player) ? ((Component)player).GetComponent<Player>() : null); if (Object.op_Implicit((Object)(object)movableBone)) { springBone = movableBone; } if (Object.op_Implicit((Object)(object)movableBedroll)) { bedrollBone = movableBedroll; } if (!Object.op_Implicit((Object)(object)springBone)) { Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "BackpackSpring") { springBone = val; break; } } } if (!Object.op_Implicit((Object)(object)bedrollBone)) { Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { if (((Object)val2).name == "BedrollSwing") { bedrollBone = val2; break; } } } if (Object.op_Implicit((Object)(object)characterRoot) && Object.op_Implicit((Object)(object)springBone) && Object.op_Implicit((Object)(object)springBone.parent)) { restPosition = springBone.localPosition; if (Object.op_Implicit((Object)(object)bedrollBone)) { restBedrollRotation = bedrollBone.localRotation; } lastPosition = characterRoot.position; phase = 0.0; filteredSpeed = 0f; sprintBlend = 0f; spring.Reset(); bedrollSpring.Reset(); initialized = true; } } private void Start() { if (Object.op_Implicit((Object)(object)characterRoot)) { Bind(characterRoot); } } private void OnEnable() { if (Object.op_Implicit((Object)(object)characterRoot) && Object.op_Implicit((Object)(object)springBone)) { Bind(characterRoot, springBone); } } private void OnDisable() { Restore(); } private void Restore() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (initialized && Object.op_Implicit((Object)(object)springBone)) { springBone.localPosition = restPosition; } if (initialized && Object.op_Implicit((Object)(object)bedrollBone)) { bedrollBone.localRotation = restBedrollRotation; } initialized = false; spring.Reset(); bedrollSpring.Reset(); } public void Tick() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00f3: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0252: 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) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: 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_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) if (!initialized || !Object.op_Implicit((Object)(object)characterRoot) || !Object.op_Implicit((Object)(object)springBone) || !Object.op_Implicit((Object)(object)springBone.parent)) { return; } float deltaTime = Time.deltaTime; if (deltaTime <= 0f) { return; } ticks++; Vector3 position = characterRoot.position; Vector3 val = position - lastPosition; lastPosition = position; if (((Vector3)(ref val)).sqrMagnitude > 9f || deltaTime > 0.25f) { spring.Reset(); bedrollSpring.Reset(); phase = 0.0; filteredSpeed = 0f; springBone.localPosition = restPosition; if (Object.op_Implicit((Object)(object)bedrollBone)) { bedrollBone.localRotation = restBedrollRotation; } return; } Vector3 up = characterRoot.up; Vector3 val2 = Vector3.ProjectOnPlane(val, up); float magnitude = ((Vector3)(ref val2)).magnitude; float num = magnitude / deltaTime; filteredSpeed = Mathf.Lerp(filteredSpeed, num, 1f - Mathf.Exp((0f - deltaTime) / 0.1f)); float num2 = magnitude * Mathf.Lerp(1f, Mathf.Min(1f, 4.2f / Mathf.Max(num, 0.01f)), sprintBlend); phase = (phase + (double)(num2 / Mathf.Max(0.5f, metersPerBounce) * 2f) * Math.PI) % (Math.PI * 4.0); sprintBlend = Mathf.Lerp(sprintBlend, (Object.op_Implicit((Object)(object)playerComponent) && ((Character)playerComponent).IsRunning()) ? 1f : 0f, 1f - Mathf.Exp((0f - deltaTime) / 0.18f)); float num3 = Mathf.InverseLerp(0.15f, Mathf.Max(1f, fullBounceSpeed), filteredSpeed); double target = (double)(maximumBounceMeters * num3 * SprintMultiplier) * Math.Sin(phase); float num4 = (float)spring.Step(target, Mathf.Max(1f, springFrequencyHz), deltaTime); Vector3 val3 = springBone.parent.InverseTransformVector(up * num4); springBone.localPosition = restPosition + val3; if (Object.op_Implicit((Object)(object)bedrollBone) && Object.op_Implicit((Object)(object)bedrollBone.parent)) { double target2 = (double)(maximumBedrollSwayDegrees * num3 * SprintMultiplier) * Math.Sin(phase * 0.5 - 0.15); float num5 = (float)bedrollSpring.Step(target2, Mathf.Max(1f, bedrollSpringFrequencyHz), deltaTime); val2 = bedrollBone.parent.InverseTransformDirection(characterRoot.forward); Vector3 normalized = ((Vector3)(ref val2)).normalized; bedrollBone.localRotation = Quaternion.AngleAxis(num5, normalized) * restBedrollRotation; if (!motionLogged && ticks > 30 && num > 0.3f && Math.Abs(num4) > 0.001f && Math.Abs(num5) > 0.3f) { motionLogged = true; BackpackPlugin.Instance?.LogMotion(num, num4, num5); } } } } public static class BackpackCapacity { public static int ExtraSlots(int mask) { int num = 0; for (int i = 0; i < 7; i++) { if ((mask & (1 << i)) != 0) { num++; } } return 4 + 3 * num - ((num > 0) ? 1 : 0); } public static bool Unlocked(int x, int y, int width, int baseHeight, int extra) { if (x >= 0 && x < width && y >= 0) { if (y >= baseHeight) { return (y - baseHeight) * width + x < extra; } return true; } return false; } public static int Height(int width, int baseHeight, int extra, int occupiedLastRow) { return Math.Max(baseHeight + (extra + width - 1) / width, occupiedLastRow + 1); } } internal static class BackpackChestLayout { private sealed class Pose { internal RectTransform Player; internal RectTransform Chest; internal Vector3 PlayerPosition; internal Vector3 ChestPosition; internal Vector3 PlayerScale; internal Vector3 ChestScale; internal Vector3 AppliedPlayerPosition; internal Vector3 AppliedChestPosition; internal Vector3 AppliedPlayerScale; internal Vector3 AppliedChestScale; internal Vector2 PlayerSize; internal Vector2 ChestSize; internal Vector2 PanelSize; internal Vector2 PanelPosition; internal Vector2 ScreenSize; internal RectTransform Panel; internal RectTransform Screen; internal bool Applied; } private static readonly ConditionalWeakTable<InventoryGui, Pose> poses = new ConditionalWeakTable<InventoryGui, Pose>(); internal static void Restore(InventoryGui gui) { //IL_002c: 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_005b: 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) if (poses.TryGetValue(gui, out var value) && value.Applied) { if (Object.op_Implicit((Object)(object)value.Player)) { ((Transform)value.Player).localPosition = value.PlayerPosition; ((Transform)value.Player).localScale = value.PlayerScale; } if (Object.op_Implicit((Object)(object)value.Chest)) { ((Transform)value.Chest).localPosition = value.ChestPosition; ((Transform)value.Chest).localScale = value.ChestScale; } value.Applied = false; } } private static void Bounds(RectTransform rect, Transform space, out Vector2 low, out Vector2 high) { //IL_0019: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[4]; rect.GetWorldCorners(array); low = new Vector2(float.PositiveInfinity, float.PositiveInfinity); high = new Vector2(float.NegativeInfinity, float.NegativeInfinity); Vector3[] array2 = array; foreach (Vector3 val in array2) { Vector2 val2 = Vector2.op_Implicit(space.InverseTransformPoint(val)); low = Vector2.Min(low, val2); high = Vector2.Max(high, val2); } } private static void TopLeft(RectTransform rect, Transform space, Vector2 target) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) Bounds(rect, space, out var low, out var high); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(target.x - low.x, target.y - high.y, 0f); ((Transform)rect).localPosition = ((Transform)rect).localPosition + ((Transform)rect).parent.InverseTransformVector(space.TransformVector(val)); } internal static void Apply(InventoryGui gui) { //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_031f: 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_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: 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_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0457: 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_0477: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_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_0503: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027c: 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_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02df: 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_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: 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_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) if (BackpackPlugin.Instance.BackpackPanelMoved.Value) { Restore(gui); return; } object? value = AccessTools.Field(typeof(InventoryGui), "m_playerGrid").GetValue(gui); RectTransform val = BackpackPanel.VisiblePanel((InventoryGrid)((value is InventoryGrid) ? value : null)); if (!Object.op_Implicit((Object)(object)val)) { val = PackSlot.VisibleTab; } if (!Object.op_Implicit((Object)(object)val)) { Restore(gui); return; } object? value2 = AccessTools.Field(typeof(InventoryGui), "m_player").GetValue(gui); RectTransform val2 = (RectTransform)((value2 is RectTransform) ? value2 : null); object? value3 = AccessTools.Field(typeof(InventoryGui), "m_container").GetValue(gui); RectTransform val3 = (RectTransform)((value3 is RectTransform) ? value3 : null); if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3) || !((Component)val3).gameObject.activeInHierarchy) { Restore(gui); return; } Transform parent = ((Transform)val2).parent; RectTransform val4 = (RectTransform)(object)((parent is RectTransform) ? parent : null); Transform parent2 = parent.parent; Rect rect; while ((Object)(object)parent2 != (Object)null) { RectTransform val5 = (RectTransform)(object)((parent2 is RectTransform) ? parent2 : null); if (val5 != null) { rect = val5.rect; if (((Rect)(ref rect)).height > 0f) { val4 = val5; } } parent2 = parent2.parent; } if (!Object.op_Implicit((Object)(object)val4)) { Restore(gui); return; } if (poses.TryGetValue(gui, out var value4) && value4.Applied) { bool flag = (Object)(object)value4.Player == (Object)(object)val2 && (Object)(object)value4.Chest == (Object)(object)val3 && (Object)(object)value4.Panel == (Object)(object)val && (Object)(object)value4.Screen == (Object)(object)val4; if (flag && Same(((Transform)val2).localPosition, value4.AppliedPlayerPosition) && Same(((Transform)val3).localPosition, value4.AppliedChestPosition) && Same(((Transform)val2).localScale, value4.AppliedPlayerScale) && Same(((Transform)val3).localScale, value4.AppliedChestScale)) { rect = val2.rect; if (Same(((Rect)(ref rect)).size, value4.PlayerSize)) { rect = val3.rect; if (Same(((Rect)(ref rect)).size, value4.ChestSize)) { rect = val.rect; if (Same(((Rect)(ref rect)).size, value4.PanelSize) && Same(val.anchoredPosition, value4.PanelPosition)) { rect = val4.rect; if (Same(((Rect)(ref rect)).size, value4.ScreenSize)) { return; } } } } } if (flag) { if (!Same(((Transform)val2).localPosition, value4.AppliedPlayerPosition)) { value4.PlayerPosition = ((Transform)val2).localPosition; } if (!Same(((Transform)val3).localPosition, value4.AppliedChestPosition)) { value4.ChestPosition = ((Transform)val3).localPosition; } if (!Same(((Transform)val2).localScale, value4.AppliedPlayerScale)) { value4.PlayerScale = ((Transform)val2).localScale; } if (!Same(((Transform)val3).localScale, value4.AppliedChestScale)) { value4.ChestScale = ((Transform)val3).localScale; } } Restore(gui); } Bounds(val2, parent, out var low, out var high); Bounds(val, parent, out var low2, out var _); Bounds(val3, parent, out var low3, out var high3); float num = Math.Min(low.y, low2.y); float num2 = high.y - num; float chestHeight = high3.y - low3.y; if (!(high3.y <= num - 12f)) { Bounds(val4, parent, out var low4, out var _); float num3 = BackpackLayoutFit.Scale(high.y - low4.y - 12f, num2, chestHeight, 12f); Pose value5 = poses.GetValue(gui, (InventoryGui _) => new Pose()); value5.Player = val2; value5.Chest = val3; value5.PlayerPosition = ((Transform)val2).localPosition; value5.ChestPosition = ((Transform)val3).localPosition; value5.PlayerScale = ((Transform)val2).localScale; value5.ChestScale = ((Transform)val3).localScale; value5.Applied = true; ((Transform)val2).localScale = value5.PlayerScale * num3; TopLeft(val2, parent, new Vector2(low.x, high.y)); ((Transform)val3).localScale = value5.ChestScale * num3; TopLeft(val3, parent, new Vector2(low3.x, high.y - (num2 + 12f) * num3)); value5.AppliedPlayerPosition = ((Transform)val2).localPosition; value5.AppliedChestPosition = ((Transform)val3).localPosition; value5.AppliedPlayerScale = ((Transform)val2).localScale; value5.AppliedChestScale = ((Transform)val3).localScale; value5.Panel = val; value5.Screen = val4; rect = val2.rect; value5.PlayerSize = ((Rect)(ref rect)).size; rect = val3.rect; value5.ChestSize = ((Rect)(ref rect)).size; rect = val.rect; value5.PanelSize = ((Rect)(ref rect)).size; value5.PanelPosition = val.anchoredPosition; rect = val4.rect; value5.ScreenSize = ((Rect)(ref rect)).size; } } private static bool Same(Vector3 a, Vector3 b) { //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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Vector3 val = a - b; return ((Vector3)(ref val)).sqrMagnitude < 1E-06f; } private static bool Same(Vector2 a, Vector2 b) { //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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Vector2 val = a - b; return ((Vector2)(ref val)).sqrMagnitude < 1E-06f; } } internal static class BackpackDrag { private static readonly Dictionary<RectTransform, BackpackDragHandle> handles = new Dictionary<RectTransform, BackpackDragHandle>(); private static bool hidden; internal static void Place(RectTransform target, ConfigEntry<bool> moved, ConfigEntry<Vector2> position, Action<Vector2> shift, Func<Vector2, Camera, bool> allow = null, RectTransform hitTarget = null) { //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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)target)) { if (!handles.TryGetValue(target, out var value) || !Object.op_Implicit((Object)(object)value)) { GameObject val = new GameObject(((Object)target).name + "AltDrag", new Type[1] { typeof(RectTransform) }) { layer = ((Component)target).gameObject.layer }; Image obj = val.AddComponent<Image>(); ((Graphic)obj).color = Color.clear; ((Graphic)obj).raycastTarget = true; value = val.AddComponent<BackpackDragHandle>(); handles[target] = value; } hidden = false; value.Target = target; value.HitTarget = (Object.op_Implicit((Object)(object)hitTarget) ? hitTarget : target); value.Moved = moved; value.Position = position; value.Shift = shift; value.Allow = allow; value.Apply(); } } internal static void RefreshPinned() { foreach (KeyValuePair<RectTransform, BackpackDragHandle> handle in handles) { if (Object.op_Implicit((Object)(object)handle.Value)) { handle.Value.Apply(); } } } internal static void Hide() { if (hidden) { return; } hidden = true; foreach (KeyValuePair<RectTransform, BackpackDragHandle> handle in handles) { if (Object.op_Implicit((Object)(object)handle.Value) && ((Component)handle.Value).gameObject.activeSelf) { ((Component)handle.Value).gameObject.SetActive(false); } } } internal static void Shutdown() { foreach (KeyValuePair<RectTransform, BackpackDragHandle> handle in handles) { if (Object.op_Implicit((Object)(object)handle.Value)) { Object.Destroy((Object)(object)((Component)handle.Value).gameObject); } } handles.Clear(); } } internal sealed class BackpackDragHandle : MonoBehaviour, ICanvasRaycastFilter, IPointerDownHandler, IEventSystemHandler, IPointerUpHandler, IBeginDragHandler, IDragHandler, IEndDragHandler { internal RectTransform Target; internal RectTransform HitTarget; internal ConfigEntry<bool> Moved; internal ConfigEntry<Vector2> Position; internal Action<Vector2> Shift; internal Func<Vector2, Camera, bool> Allow; private bool pressed; private bool dragging; private Vector2 grab; private Vector2 dragPosition; private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4]; private RectTransform ScreenRect { get { if (!Object.op_Implicit((Object)(object)Target)) { return null; } Canvas componentInParent = ((Component)Target).GetComponentInParent<Canvas>(); Transform obj = ((componentInParent != null) ? ((Component)componentInParent.rootCanvas).transform : null); return (RectTransform)(object)((obj is RectTransform) ? obj : null); } } private RectTransform Overlay { get { Transform transform = ((Component)this).transform; return (RectTransform)(object)((transform is RectTransform) ? transform : null); } } private static bool Alt { get { if (!Input.GetKey((KeyCode)308)) { return Input.GetKey((KeyCode)307); } return true; } } public bool IsRaycastLocationValid(Vector2 point, Camera camera) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (pressed) { return true; } InventoryGui instance = InventoryGui.instance; if (Object.op_Implicit((Object)(object)Target) && ((Component)Target).gameObject.activeInHierarchy && InventoryGui.IsVisible() && Alt && !Input.GetMouseButton(1) && Object.op_Implicit((Object)(object)instance) && AccessTools.Field(typeof(InventoryGui), "m_dragItem").GetValue(instance) == null) { if (Allow != null) { return Allow(point, camera); } return true; } return false; } internal void Apply() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: 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_0098: 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_00bd: 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_00c7: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_023e: 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_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_019f: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: 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_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0339: 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_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Target)) { ((Component)this).gameObject.SetActive(false); return; } ((Component)this).gameObject.SetActive(((Component)Target).gameObject.activeInHierarchy); if (!((Component)this).gameObject.activeSelf) { return; } RectTransform screenRect = ScreenRect; Rect rect2; if (Moved.Value && Object.op_Implicit((Object)(object)screenRect)) { Rect rect = screenRect.rect; Vector2 val = (dragging ? dragPosition : Position.Value); Vector3 val2 = ((Transform)screenRect).TransformPoint(new Vector3(((Rect)(ref rect)).xMin + ((Rect)(ref rect)).width * val.x, ((Rect)(ref rect)).yMin + ((Rect)(ref rect)).height * val.y, 0f)); RectTransform target = Target; rect2 = Target.rect; Vector3 val3 = ((Transform)target).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect2)).center)); Translate(val2 - val3); Target.GetWorldCorners(corners); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(float.PositiveInfinity, float.PositiveInfinity); Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(float.NegativeInfinity, float.NegativeInfinity); Vector3[] array = corners; foreach (Vector3 val6 in array) { Vector2 val7 = Vector2.op_Implicit(((Transform)screenRect).InverseTransformPoint(val6)); val4 = Vector2.Min(val4, val7); val5 = Vector2.Max(val5, val7); } Vector2 val8 = default(Vector2); ((Vector2)(ref val8))..ctor(PanelDragRules.Correction(val4.x, val5.x, ((Rect)(ref rect)).xMin, ((Rect)(ref rect)).xMax), PanelDragRules.Correction(val4.y, val5.y, ((Rect)(ref rect)).yMin, ((Rect)(ref rect)).yMax)); Translate(((Transform)screenRect).TransformVector(Vector2.op_Implicit(val8))); } RectTransform val9 = (Object.op_Implicit((Object)(object)HitTarget) ? HitTarget : Target); RectTransform overlay = Overlay; if ((Object)(object)((Transform)overlay).parent != (Object)(object)((Transform)val9).parent) { ((Transform)overlay).SetParent(((Transform)val9).parent, false); } Vector2 val10 = overlay.anchorMin - val9.anchorMin; if (((Vector2)(ref val10)).sqrMagnitude > 1E-06f) { overlay.anchorMin = val9.anchorMin; } val10 = overlay.anchorMax - val9.anchorMax; if (((Vector2)(ref val10)).sqrMagnitude > 1E-06f) { overlay.anchorMax = val9.anchorMax; } val10 = overlay.pivot - val9.pivot; if (((Vector2)(ref val10)).sqrMagnitude > 1E-06f) { overlay.pivot = val9.pivot; } Vector2 sizeDelta = overlay.sizeDelta; rect2 = val9.rect; val10 = sizeDelta - ((Rect)(ref rect2)).size; if (((Vector2)(ref val10)).sqrMagnitude > 1E-06f) { rect2 = val9.rect; overlay.sizeDelta = ((Rect)(ref rect2)).size; } Vector3 val11 = ((Transform)overlay).localScale - ((Transform)val9).localScale; if (((Vector3)(ref val11)).sqrMagnitude > 1E-06f) { ((Transform)overlay).localScale = ((Transform)val9).localScale; } if (Quaternion.Angle(((Transform)overlay).localRotation, ((Transform)val9).localRotation) > 0.001f) { ((Transform)overlay).localRotation = ((Transform)val9).localRotation; } val11 = ((Transform)overlay).position - ((Transform)val9).position; if (((Vector3)(ref val11)).sqrMagnitude > 1E-06f) { ((Transform)overlay).position = ((Transform)val9).position; } if (((Transform)overlay).GetSiblingIndex() != ((Transform)overlay).parent.childCount - 1) { ((Transform)overlay).SetAsLastSibling(); } } private void Translate(Vector3 worldDelta) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref worldDelta)).sqrMagnitude > 1E-06f) { Shift(Vector2.op_Implicit(((Transform)Target).parent.InverseTransformVector(worldDelta))); } } public void OnPointerDown(PointerEventData e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if ((int)e.button == 0 && IsRaycastLocationValid(e.position, e.pressEventCamera)) { RectTransform screenRect = ScreenRect; Vector2 val = default(Vector2); if (Object.op_Implicit((Object)(object)screenRect) && RectTransformUtility.ScreenPointToLocalPointInRectangle(screenRect, e.position, e.pressEventCamera, ref val)) { Vector2 val2 = val; RectTransform target = Target; Rect rect = Target.rect; grab = val2 - Vector2.op_Implicit(((Transform)screenRect).InverseTransformPoint(((Transform)target).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)))); pressed = true; } } } public void OnBeginDrag(PointerEventData e) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) dragPosition = Position.Value; dragging = pressed && Alt; } public void OnDrag(PointerEventData e) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if (!dragging || !Alt) { return; } RectTransform screenRect = ScreenRect; Vector2 val = default(Vector2); if (Object.op_Implicit((Object)(object)screenRect) && RectTransformUtility.ScreenPointToLocalPointInRectangle(screenRect, e.position, e.pressEventCamera, ref val)) { Rect rect = screenRect.rect; Vector2 val2 = val - grab; dragPosition = new Vector2((val2.x - ((Rect)(ref rect)).xMin) / Mathf.Max(1f, ((Rect)(ref rect)).width), (val2.y - ((Rect)(ref rect)).yMin) / Mathf.Max(1f, ((Rect)(ref rect)).height)); Moved.Value = true; if (Moved == BackpackPlugin.Instance.BackpackPanelMoved && Object.op_Implicit((Object)(object)InventoryGui.instance)) { BackpackChestLayout.Restore(InventoryGui.instance); } Apply(); } } public void OnPointerUp(PointerEventData e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)e.button == 0) { Finish(); } } public void OnEndDrag(PointerEventData e) { Finish(); } private void OnDisable() { Finish(); } private void Finish() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_00ac: Unknown result type (might be due to invalid IL or missing references) if (dragging && Object.op_Implicit((Object)(object)Target) && Object.op_Implicit((Object)(object)ScreenRect)) { RectTransform screenRect = ScreenRect; Rect rect = screenRect.rect; RectTransform target = Target; Rect rect2 = Target.rect; Vector2 val = Vector2.op_Implicit(((Transform)screenRect).InverseTransformPoint(((Transform)target).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect2)).center)))); Position.Value = new Vector2((val.x - ((Rect)(ref rect)).xMin) / Mathf.Max(1f, ((Rect)(ref rect)).width), (val.y - ((Rect)(ref rect)).yMin) / Mathf.Max(1f, ((Rect)(ref rect)).height)); BackpackPlugin instance = BackpackPlugin.Instance; if (instance != null) { ((BaseUnityPlugin)instance).Config.Save(); } } dragging = false; pressed = false; } } internal static class BackpackInventory { private sealed class State { internal int BaseHeight; internal int Extra; internal int AppliedHeight; internal int EquipmentExtra; internal int ProviderVisible; internal int TalentRows; internal bool Loading; internal bool ProviderPending; internal bool ProviderChanging; internal HashSet<ItemData> EquipmentPending; } private sealed class TalentChange { internal State State; internal readonly Dictionary<ItemData, Vector2Int> Contents = new Dictionary<ItemData, Vector2Int>(); internal readonly HashSet<ItemData> Equipment = new HashSet<ItemData>(); } private static readonly ConditionalWeakTable<Inventory, State> states = new ConditionalWeakTable<Inventory, State>(); private static readonly FieldInfo Height = AccessTools.Field(typeof(Inventory), "m_height"); private static readonly FieldInfo GridInventory = AccessTools.Field(typeof(InventoryGrid), "m_inventory"); private static readonly FieldInfo Elements = AccessTools.Field(typeof(InventoryGrid), "m_elements"); private static readonly Type GridPosType = AccessTools.TypeByName("Vector2i"); private static readonly FieldInfo ItemPos = AccessTools.Field(typeof(ItemData), "m_gridPos"); private static readonly Dictionary<Type, FieldInfo[]> gridFields = new Dictionary<Type, FieldInfo[]>(); private const string HeightKey = "OctoPack.BaseInventoryHeight"; private const string VisibleKey = "OctoPack.VisibleInventoryRows"; private static int protectedEquipmentRows = -1; private static bool resizing; private static float nextRefresh; private static BackpackPlugin Plugin => BackpackPlugin.Instance; private static Vector2Int Pos(object p) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) Type type = p.GetType(); if (!gridFields.TryGetValue(type, out var value)) { value = new FieldInfo[2] { AccessTools.Field(type, "x"), AccessTools.Field(type, "y") }; gridFields.Add(type, value); } return new Vector2Int((int)value[0].GetValue(p), (int)value[1].GetValue(p)); } private static Vector2Int ItemPosition(ItemData item) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return Pos(ItemPos.GetValue(item)); } internal static void Patch(Harmony h) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_01db: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown Add(h, AccessTools.Method(typeof(Player), "Load", new Type[1] { typeof(ZPackage) }, (Type[])null), "BeforePlayerLoad", "AfterPlayerLoad"); Add(h, AccessTools.Method(typeof(Player), "Save", new Type[1] { typeof(ZPackage) }, (Type[])null), "BeforePlayerSave", null); MethodInfo methodInfo = AccessTools.Method(typeof(Player), "SetInventorySize", new Type[1] { typeof(int) }, (Type[])null); HarmonyMethod val = new HarmonyMethod(typeof(BackpackInventory), "SetPlayerRows", (Type[])null); val.priority = 800; val.before = new string[2] { "randyknapp.mods.equipmentandquickslots", "treextr.pathofvalheiman" }; h.Patch((MethodBase)methodInfo, val, Ordered("AfterPlayerRows"), (HarmonyMethod)null, new HarmonyMethod(typeof(BackpackInventory), "FinishPlayerRows", (Type[])null), (HarmonyMethod)null); Add(h, AccessTools.Method(typeof(Inventory), "SetHeight", new Type[1] { typeof(int) }, (Type[])null), "SetInventoryHeight", null); if (EquipmentSlotsBridge.Present) { h.Patch((MethodBase)EquipmentSlotsBridge.LoadResize, new HarmonyMethod(typeof(BackpackInventory), "LoadEquipmentRows", (Type[])null) { priority = 800 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)EquipmentSlotsBridge.RowResize, new HarmonyMethod(typeof(BackpackInventory), "ProtectEquipmentRows", (Type[])null) { priority = 0 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (PathOfValheimanBridge.Present) { h.Patch((MethodBase)PathOfValheimanBridge.TalentResize, new HarmonyMethod(typeof(BackpackInventory), "BeforeTalentRows", (Type[])null) { priority = 800 }, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(BackpackInventory), "FinishTalentRows", (Type[])null), (HarmonyMethod)null); h.Patch((MethodBase)PathOfValheimanBridge.UsedVisible, (HarmonyMethod)null, new HarmonyMethod(typeof(BackpackInventory), "ProviderUsedAfter", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } Add(h, AccessTools.Method(typeof(Player), "GetMaxCarryWeight", (Type[])null, (Type[])null), null, "Carry"); PackHooks.Patch(h); h.Patch((MethodBase)AccessTools.Method(typeof(Inventory), "FindEmptySlot", new Type[1] { typeof(bool) }, (Type[])null), Ordered("FindPrefix"), Ordered("FindAfter"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Add(h, AccessTools.Method(typeof(Inventory), "GetEmptySlots", (Type[])null, (Type[])null), null, "EmptySlotsAfter"); Add(h, AccessTools.Method(typeof(Inventory), "CanAddItem", new Type[2] { typeof(ItemData), typeof(int) }, (Type[])null), "CanAdd", "CanAddAfter"); Add(h, AccessTools.Method(typeof(Inventory), "AddItem", new Type[5] { typeof(ItemData), typeof(int), typeof(int), typeof(int), typeof(bool) }, (Type[])null), "AddAt", null); Add(h, AccessTools.Method(typeof(Inventory), "AddItem", new Type[2] { typeof(ItemData), GridPosType }, (Type[])null), "AddPos", null); Add(h, AccessTools.Method(typeof(Inventory), "Load", new Type[2] { typeof(ZPackage), typeof(bool) }, (Type[])null), null, "LoadedInventory"); Add(h, AccessTools.Method(typeof(InventoryGrid), "UpdateGui", (Type[])null, (Type[])null), null, "Grid"); Add(h, AccessTools.Method(typeof(InventoryGui), "UpdateInventory", new Type[1] { typeof(Player) }, (Type[])null), null, "PanelSize"); Add(h, AccessTools.Method(typeof(InventoryGui), "OnSelectedItem", (Type[])null, (Type[])null), "Selected", null); Add(h, AccessTools.Method(typeof(InventoryGui), "Update", (Type[])null, (Type[])null), null, "AfterGuiUpdate"); } private static void Add(Harmony h, MethodInfo target, string before, string after) { if (target == null) { throw new MissingMethodException("Required backpack inventory hook missing"); } h.Patch((MethodBase)target, (before == null) ? null : Ordered(before), (after == null) ? null : Ordered(after), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static HarmonyMethod Ordered(string name) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(typeof(BackpackInventory), name, (Type[])null); val.priority = 0; val.after = new string[2] { "randyknapp.mods.equipmentandquickslots", "treextr.pathofvalheiman" }; return val; } private static State Track(Player p) { Inventory inventory = ((Humanoid)p).GetInventory(); if (states.TryGetValue(inventory, out var value)) { return value; } value = new State { BaseHeight = (EquipmentSlotsBridge.Present ? (EquipmentSlotsBridge.PrefabRows + EquipmentSlotsBridge.ExtraRows) : PathOfValheimanBridge.Visible(p)), EquipmentExtra = (EquipmentSlotsBridge.Present ? EquipmentSlotsBridge.ExtraRows : 0), TalentRows = PathOfValheimanBridge.TalentRows(p) }; states.Add(inventory, value); return value; } private static void BeforePlayerLoad(Player __instance) { State state = Track(__instance); state.Loading = true; Height.SetValue(((Humanoid)__instance).GetInventory(), BackpackCapacity.Height(((Humanoid)__instance).GetInventory().GetWidth(), state.BaseHeight, 25, -1) + (EquipmentSlotsBridge.Present ? 3 : (PathOfValheimanBridge.Owns(((Humanoid)__instance).GetInventory()) ? 8 : 0))); } private static void LoadEquipmentRows(ref int rows) { //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_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_014e: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) Player currentPlayer = EquipmentSlotsBridge.CurrentPlayer; if (!Object.op_Implicit((Object)(object)currentPlayer) || !states.TryGetValue(((Humanoid)currentPlayer).GetInventory(), out var value) || !value.Loading) { return; } value.BaseHeight = rows + EquipmentSlotsBridge.ExtraRows; int result = 0; int num = 0; int num2 = -1; Inventory inventory = ((Humanoid)currentPlayer).GetInventory(); if (currentPlayer.m_customData.TryGetValue("OctoPack.VisibleInventoryRows", out var value2)) { int.TryParse(value2, out result); } foreach (ItemData allItem in inventory.GetAllItems()) { object obj = EquipmentSlotsBridge.SavedSlot(allItem); if (obj != null) { Vector2Int val = Pos(obj.GetType().GetProperty("GridPosition").GetValue(obj, null)); Vector2Int val2 = ItemPosition(allItem); if (((Vector2Int)(ref val2)).x == ((Vector2Int)(ref val)).x) { int val3 = num; val2 = ItemPosition(allItem); num = Math.Max(val3, ((Vector2Int)(ref val2)).y - (((Vector2Int)(ref val)).y - EquipmentSlotsBridge.VisibleRows)); } } } int num3 = BackpackLoadLayout.VisibleRows(result, value.BaseHeight, Plugin.InventoryBenefits.Value ? 4 : 0, inventory.GetWidth(), -1, num); foreach (ItemData allItem2 in inventory.GetAllItems()) { object obj2 = EquipmentSlotsBridge.SavedSlot(allItem2); Vector2Int val4 = ItemPosition(allItem2); if (obj2 != null) { Vector2Int val5 = Pos(obj2.GetType().GetProperty("GridPosition").GetValue(obj2, null)); if (((Vector2Int)(ref val4)).x == ((Vector2Int)(ref val5)).x && ((Vector2Int)(ref val4)).y == num3 + (((Vector2Int)(ref val5)).y - EquipmentSlotsBridge.VisibleRows)) { continue; } } num2 = Math.Max(num2, ((Vector2Int)(ref val4)).y); } rows = BackpackLoadLayout.VisibleRows(result, value.BaseHeight, Plugin.InventoryBenefits.Value ? 4 : 0, inventory.GetWidth(), num2, num) - EquipmentSlotsBridge.ExtraRows; } private static bool SetPlayerRows(Player __instance, int rows) { if (!states.TryGetValue(((Humanoid)__instance).GetInventory(), out var value) || value.Loading) { return true; } if (PathOfValheimanBridge.Present && !EquipmentSlotsBridge.Present) { return true; } rows = Math.Max(1, rows); Rebase(__instance, rows + (EquipmentSlotsBridge.Present ? EquipmentSlotsBridge.ExtraRows : 0)); __instance.AddUniqueKeyValue("invrows", rows.ToString()); Refresh(__instance); if (EquipmentSlotsBridge.Present) { protectedEquipmentRows = EquipmentSlotsBridge.BaseRows; } return false; } private static void AfterPlayerRows(Player __instance, int rows) { if (PathOfValheimanBridge.Present && !EquipmentSlotsBridge.Present && Active(((Humanoid)__instance).GetInventory(), out var s)) { s.ProviderPending = false; s.TalentRows = PathOfValheimanBridge.TalentRows(__instance); Rebase(__instance, Math.Max(1, Math.Min(9, rows)) + s.TalentRows); s.ProviderVisible = (PathOfValheimanBridge.Owns(((Humanoid)__instance).GetInventory()) ? PathOfValheimanBridge.Visible(__instance) : 0); s.AppliedHeight = ((Humanoid)__instance).GetInventory().GetHeight(); Refresh(__instance); } } private static bool ProtectEquipmentRows(ref int rows) { if (protectedEquipmentRows >= 0) { rows = protectedEquipmentRows; return true; } Player currentPlayer = EquipmentSlotsBridge.CurrentPlayer; if (resizing || !Object.op_Implicit((Object)(object)currentPlayer) || !Active(((Humanoid)currentPlayer).GetInventory(), out var _)) { return true; } currentPlayer.AddUniqueKeyValue("invrows", Math.Max(1, rows).ToString()); Rebase(currentPlayer, Math.Max(1, rows) + EquipmentSlotsBridge.ExtraRows); Refresh(currentPlayer); rows = EquipmentSlotsBridge.BaseRows; return false; } private static bool SetInventoryHeight(Inventory __instance, int height) { if (resizing || EquipmentSlotsBridge.Present || !Active(__instance, out var s)) { return true; } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer) || ((Humanoid)localPlayer).GetInventory() != __instance) { return true; } if (height == s.AppliedHeight) { return false; } localPlayer.AddUniqueKeyValue("invrows", Math.Max(1, height).ToString()); Rebase(localPlayer, Math.Max(1, height)); Refresh(localPlayer); return false; } private static void SetPosition(ItemData item, int x, int y) { ItemPos.SetValue(item, Activator.CreateInstance(GridPosType, x, y)); } private static void Rebase(Player p, int baseline) { //IL_0080: 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_00d1: 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) Inventory inventory = ((Humanoid)p).GetInventory(); State state = Track(p); if (baseline == state.BaseHeight) { return; } HashSet<ItemData> hashSet = new HashSet<ItemData>(); int num = BackpackCapacity.Height(inventory.GetWidth(), state.BaseHeight, state.Extra, -1) - 1; foreach (ItemData allItem in inventory.GetAllItems()) { if ((state.EquipmentPending != null) ? state.EquipmentPending.Contains(allItem) : EquipmentItem(p, allItem)) { hashSet.Add(allItem); continue; } int val = num; Vector2Int val2 = ItemPosition(allItem); num = Math.Max(val, ((Vector2Int)(ref val2)).y); } foreach (ItemData allItem2 in inventory.GetAllItems()) { if (!hashSet.Contains(allItem2)) { Vector2Int val3 = ItemPosition(allItem2); SetPosition(allItem2, ((Vector2Int)(ref val3)).x, BackpackRowLayout.MoveRow(((Vector2Int)(ref val3)).y, state.BaseHeight, baseline, num)); } } state.EquipmentPending = hashSet; state.BaseHeight = baseline; } private static void BeforeTalentRows(Player __0, int __1, out TalentChange __state) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) __state = null; if (EquipmentSlotsBridge.Present || !Object.op_Implicit((Object)(object)__0) || !PathOfValheimanBridge.Owns(((Humanoid)__0).GetInventory()) || !Active(((Humanoid)__0).GetInventory(), out var s) || s.ProviderPending || s.ProviderChanging) { return; } Refresh(__0); if (__1 == PathOfValheimanBridge.TalentRows(__0)) { return; } TalentChange talentChange = new TalentChange { State = s }; foreach (ItemData allItem in ((Humanoid)__0).GetInventory().GetAllItems()) { if (EquipmentItem(__0, allItem)) { talentChange.Equipment.Add(allItem); } else { talentChange.Contents.Add(allItem, ItemPosition(allItem)); } } s.ProviderChanging = true; __state = talentChange; } private static Exception FinishTalentRows(Player __0, TalentChange __state, Exception __exception) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (__state == null) { return __exception; } State state = __state.State; state.ProviderChanging = false; if (__exception != null) { return __exception; } foreach (KeyValuePair<ItemData, Vector2Int> content in __state.Contents) { if (((Humanoid)__0).GetInventory().ContainsItem(content.Key)) { ItemData key = content.Key; Vector2Int value = content.Value; int x = ((Vector2Int)(ref value)).x; value = content.Value; SetPosition(key, x, ((Vector2Int)(ref value)).y); } } state.EquipmentPending = __state.Equipment; int num = PathOfValheimanBridge.TalentRows(__0); Rebase(__0, Math.Max(1, state.BaseHeight + num - state.TalentRows)); state.TalentRows = num; state.ProviderVisible = PathOfValheimanBridge.Visible(__0); Refresh(__0); return null; } private static void FinishPlayerRows() { protectedEquipmentRows = -1; } private static void AfterPlayerLoad(Player __instance) { LegacyMigration.PlayerData(__instance.m_customData); PackItems.DecorateInventory(((Humanoid)__instance).GetInventory()); PackEquipment.Load(__instance); State state = Track(__instance); state.Loadin