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 Quartermaster v0.1.53
BepInEx/plugins/Quartermaster/Quartermaster.dll
Decompiled 7 hours 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.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Quartermaster.Cosmetics; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; using VikingGull; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")] [assembly: AssemblyCompany("Quartermaster")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.53.0")] [assembly: AssemblyInformationalVersion("0.1.53+0be81cba4979cff72f737d8adc010ccdbcb50630")] [assembly: AssemblyProduct("Quartermaster")] [assembly: AssemblyTitle("Quartermaster")] [assembly: AssemblyVersion("0.1.53.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 VikingBirds { internal sealed class PerchedBird : IDisposable { internal readonly GameObject Root; private readonly Transform body; private readonly Transform head; private readonly Transform leftWing; private readonly Transform rightWing; private readonly List<Object> assets = new List<Object>(); private readonly Dictionary<string, Material> palette = new Dictionary<string, Material>(); private readonly Material source; private Texture2D? surface; private readonly bool owl; private readonly bool pelican; private readonly float bodyHeight; private readonly List<Transform> eyes = new List<Transform>(); private float rest; private readonly GameObject hammer; private readonly GameObject chisel; private readonly GameObject needle; private readonly GameObject sailcloth; private GameObject? fishingPole; private readonly Vector3 headRest = new Vector3(0f, 0.47f, 0.035f); internal Vector3 BeakWorld => head.TransformPoint(new Vector3(0f, 0.1f, owl ? 0.27f : (pelican ? 0.73f : 0.38f))); internal PerchedBird(Transform parent, Material worldMaterial, bool burrowingOwl, bool fishingPelican = false) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: 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_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_0402: 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_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0461: 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_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: 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_0822: Unknown result type (might be due to invalid IL or missing references) //IL_0872: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: 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_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_085c: Unknown result type (might be due to invalid IL or missing references) //IL_0846: Unknown result type (might be due to invalid IL or missing references) //IL_0891: Unknown result type (might be due to invalid IL or missing references) //IL_087f: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_08be: Unknown result type (might be due to invalid IL or missing references) //IL_08d2: Unknown result type (might be due to invalid IL or missing references) //IL_08e6: Unknown result type (might be due to invalid IL or missing references) //IL_091f: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Unknown result type (might be due to invalid IL or missing references) //IL_0947: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0c65: Unknown result type (might be due to invalid IL or missing references) //IL_0c9b: Unknown result type (might be due to invalid IL or missing references) //IL_0caf: Unknown result type (might be due to invalid IL or missing references) //IL_0cb4: Unknown result type (might be due to invalid IL or missing references) //IL_0cbb: Unknown result type (might be due to invalid IL or missing references) //IL_0ce6: Unknown result type (might be due to invalid IL or missing references) //IL_0cfd: Unknown result type (might be due to invalid IL or missing references) //IL_0d16: Unknown result type (might be due to invalid IL or missing references) //IL_0d3b: Unknown result type (might be due to invalid IL or missing references) //IL_0d4f: Unknown result type (might be due to invalid IL or missing references) //IL_0d54: Unknown result type (might be due to invalid IL or missing references) //IL_0d7a: Unknown result type (might be due to invalid IL or missing references) //IL_0d8e: Unknown result type (might be due to invalid IL or missing references) //IL_0d93: Unknown result type (might be due to invalid IL or missing references) //IL_0d9a: Unknown result type (might be due to invalid IL or missing references) //IL_0dc3: Unknown result type (might be due to invalid IL or missing references) //IL_0dd7: Unknown result type (might be due to invalid IL or missing references) //IL_0ddc: Unknown result type (might be due to invalid IL or missing references) //IL_0be1: Unknown result type (might be due to invalid IL or missing references) //IL_0c03: Unknown result type (might be due to invalid IL or missing references) //IL_0c17: Unknown result type (might be due to invalid IL or missing references) //IL_0c21: Unknown result type (might be due to invalid IL or missing references) //IL_0ea3: Unknown result type (might be due to invalid IL or missing references) //IL_0eb7: Unknown result type (might be due to invalid IL or missing references) //IL_0ed0: Unknown result type (might be due to invalid IL or missing references) //IL_0efa: Unknown result type (might be due to invalid IL or missing references) //IL_0f0e: Unknown result type (might be due to invalid IL or missing references) //IL_0f13: Unknown result type (might be due to invalid IL or missing references) //IL_0f2d: Unknown result type (might be due to invalid IL or missing references) //IL_0f41: Unknown result type (might be due to invalid IL or missing references) //IL_0f4b: Unknown result type (might be due to invalid IL or missing references) //IL_0f71: Unknown result type (might be due to invalid IL or missing references) //IL_0f85: Unknown result type (might be due to invalid IL or missing references) //IL_0f9e: Unknown result type (might be due to invalid IL or missing references) //IL_0fb9: Unknown result type (might be due to invalid IL or missing references) //IL_0fcd: Unknown result type (might be due to invalid IL or missing references) //IL_0fe6: Unknown result type (might be due to invalid IL or missing references) //IL_0ff6: Unknown result type (might be due to invalid IL or missing references) //IL_1000: Expected O, but got Unknown //IL_1037: Unknown result type (might be due to invalid IL or missing references) //IL_104b: Unknown result type (might be due to invalid IL or missing references) //IL_1050: Unknown result type (might be due to invalid IL or missing references) //IL_0985: Unknown result type (might be due to invalid IL or missing references) //IL_0e0a: Unknown result type (might be due to invalid IL or missing references) //IL_0e22: Unknown result type (might be due to invalid IL or missing references) //IL_0e2c: Unknown result type (might be due to invalid IL or missing references) //IL_106a: Unknown result type (might be due to invalid IL or missing references) //IL_1074: Expected O, but got Unknown //IL_10a5: Unknown result type (might be due to invalid IL or missing references) //IL_10c0: Unknown result type (might be due to invalid IL or missing references) //IL_10d4: Unknown result type (might be due to invalid IL or missing references) //IL_10de: Unknown result type (might be due to invalid IL or missing references) //IL_1104: Unknown result type (might be due to invalid IL or missing references) //IL_1118: Unknown result type (might be due to invalid IL or missing references) //IL_1122: Unknown result type (might be due to invalid IL or missing references) //IL_1148: Unknown result type (might be due to invalid IL or missing references) //IL_115c: Unknown result type (might be due to invalid IL or missing references) //IL_1166: Unknown result type (might be due to invalid IL or missing references) //IL_118c: Unknown result type (might be due to invalid IL or missing references) //IL_11a0: Unknown result type (might be due to invalid IL or missing references) //IL_11a5: Unknown result type (might be due to invalid IL or missing references) //IL_09d2: Unknown result type (might be due to invalid IL or missing references) //IL_09e6: Unknown result type (might be due to invalid IL or missing references) //IL_09eb: Unknown result type (might be due to invalid IL or missing references) //IL_0a2f: Unknown result type (might be due to invalid IL or missing references) //IL_0a4c: Unknown result type (might be due to invalid IL or missing references) //IL_0a5e: Unknown result type (might be due to invalid IL or missing references) //IL_0a72: Unknown result type (might be due to invalid IL or missing references) //IL_0a77: Unknown result type (might be due to invalid IL or missing references) //IL_0a99: Unknown result type (might be due to invalid IL or missing references) //IL_0aad: Unknown result type (might be due to invalid IL or missing references) //IL_0ab2: Unknown result type (might be due to invalid IL or missing references) //IL_0ad8: Unknown result type (might be due to invalid IL or missing references) //IL_0af6: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Unknown result type (might be due to invalid IL or missing references) //IL_0667: Unknown result type (might be due to invalid IL or missing references) //IL_0b34: Unknown result type (might be due to invalid IL or missing references) //IL_0b36: Unknown result type (might be due to invalid IL or missing references) //IL_0b47: Unknown result type (might be due to invalid IL or missing references) //IL_0b4c: Unknown result type (might be due to invalid IL or missing references) //IL_0b56: Unknown result type (might be due to invalid IL or missing references) //IL_0b68: Unknown result type (might be due to invalid IL or missing references) //IL_0b79: Unknown result type (might be due to invalid IL or missing references) //IL_0b7e: Unknown result type (might be due to invalid IL or missing references) //IL_0b83: Unknown result type (might be due to invalid IL or missing references) //IL_0b94: Unknown result type (might be due to invalid IL or missing references) //IL_0b99: Unknown result type (might be due to invalid IL or missing references) //IL_0ba3: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_06cb: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_0722: Unknown result type (might be due to invalid IL or missing references) //IL_0727: Unknown result type (might be due to invalid IL or missing references) //IL_075a: Unknown result type (might be due to invalid IL or missing references) //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Unknown result type (might be due to invalid IL or missing references) //IL_078c: Unknown result type (might be due to invalid IL or missing references) //IL_07cc: Unknown result type (might be due to invalid IL or missing references) //IL_07e0: Unknown result type (might be due to invalid IL or missing references) //IL_07e5: Unknown result type (might be due to invalid IL or missing references) source = worldMaterial; owl = burrowingOwl; pelican = fishingPelican; bodyHeight = (owl ? 0.29f : (pelican ? 0.26f : 0.18f)); if (pelican) { headRest = new Vector3(0f, 0.68f, 0.035f); } Root = new GameObject(owl ? "Quartermaster burrowing owl" : (pelican ? "Pelican fisherman" : "Puffin shipwright")); Root.transform.SetParent(parent, false); try { body = Node("Body pivot", Root.transform, new Vector3(0f, bodyHeight, 0f)); head = Node("Neck pivot", body, headRest); leftWing = Node("Left wing", body, new Vector3(-0.22f, 0.34f, -0.02f)); rightWing = Node("Right wing", body, new Vector3(0.22f, 0.34f, -0.02f)); Color val = default(Color); ((Color)(ref val))..ctor(0.28f, 0.2f, 0.12f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.68f, 0.63f, 0.48f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.085f, 0.09f, 0.095f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.64f, 0.25f, 0.07f); Color val5 = (owl ? val : (pelican ? val2 : val3)); Color color = (Color)(owl ? new Color(0.52f, 0.43f, 0.29f) : val4); for (int i = -1; i <= 1; i += 2) { if (pelican && i < 0) { Rod("Wooden peg leg", Root.transform, new Vector3(-0.105f, 0.01f, 0f), new Vector3(-0.105f, 0.32f, 0f), 0.033f, val); continue; } float num = (owl ? 0.18f : (pelican ? 0.16f : 0.115f)); Ellipsoid("Leg", Root.transform, new Vector3((float)i * 0.105f, num, 0f), new Vector3(0.027f, num, 0.026f), color, 6, 3); for (int j = -1; j <= 1; j++) { Rod("Toe", Root.transform, new Vector3((float)i * 0.105f, 0.02f, 0f), new Vector3((float)i * 0.105f + (float)j * 0.047f, 0.015f, 0.145f - (float)Math.Abs(j) * 0.03f), 0.014f, color); } Rod("Back toe", Root.transform, new Vector3((float)i * 0.105f, 0.02f, 0f), new Vector3((float)i * 0.13f, 0.012f, -0.07f), 0.012f, val3); } Ellipsoid("Body", body, new Vector3(0f, 0.29f, -0.035f), new Vector3(0.245f, 0.34f, 0.195f), val5, 12, 7); Ellipsoid("Breast", body, new Vector3(0f, 0.3f, 0.09f), new Vector3(0.19f, 0.3f, 0.12f), val2, 10, 6); if (pelican) { Ellipsoid("Long white neck", body, new Vector3(0f, 0.56f, 0.015f), new Vector3(0.075f, 0.25f, 0.08f), val2, 9, 6); } Ellipsoid("Head", head, new Vector3(0f, 0.105f, 0f), new Vector3(0.24f, 0.215f, 0.19f), val5, 12, 7); for (int k = -1; k <= 1; k += 2) { Transform parent2 = ((k < 0) ? leftWing : rightWing); Ellipsoid("Folded wing", parent2, new Vector3((float)k * 0.012f, -0.12f, -0.045f), new Vector3(0.066f, 0.22f, 0.105f), val5, 8, 5); for (int l = 0; l < 4; l++) { Ellipsoid("Flight feather", parent2, new Vector3((float)k * 0.005f, -0.2f + (float)l * 0.017f, -0.105f + (float)l * 0.035f), new Vector3(0.035f, 0.135f, 0.029f), val5 * 0.82f, 6, 3); } Ellipsoid("Face", head, new Vector3((float)k * 0.113f, 0.12f, 0.11f), new Vector3(0.118f, 0.142f, 0.086f), val2, 8, 5); Transform val6 = Node("Blink", head, new Vector3((float)k * (owl ? 0.125f : 0.16f), 0.15f, owl ? 0.19f : 0.18f)); eyes.Add(val6); Ellipsoid("Eye surround", val6, Vector3.zero, new Vector3(owl ? 0.072f : 0.043f, owl ? 0.077f : 0.049f, 0.028f), val3, 10, 3); Ellipsoid("Eye", val6, new Vector3(0f, 0f, 0.024f), new Vector3(owl ? 0.053f : 0.028f, owl ? 0.055f : 0.032f, 0.014f), owl ? new Color(0.63f, 0.55f, 0.1f) : new Color(0.24f, 0.12f, 0.045f), 10, 3); Ellipsoid("Pupil", val6, new Vector3(0f, 0f, 0.037f), new Vector3(owl ? 0.024f : 0.021f, owl ? 0.032f : 0.028f, 0.009f), val3, 8, 3); if (owl) { Ellipsoid("Cream eyebrow", head, new Vector3((float)k * 0.115f, 0.232f, 0.16f), new Vector3(0.13f, 0.025f, 0.032f), val2, 6, 3).localRotation = Quaternion.Euler(0f, 0f, (float)(-k * 13)); for (int m = 0; m < 7; m++) { Ellipsoid("Mottled wing spot", parent2, new Vector3((float)k * 0.068f, -0.02f - (float)m * 0.034f, -0.085f + (float)(m % 2) * 0.07f), new Vector3(0.007f, 0.012f, 0.021f), val2, 5, 2); } } } Wedge("Beak", head, new Vector3(0f, 0.065f, 0.18f), owl ? new Vector3(0.09f, 0.11f, 0.12f) : (pelican ? new Vector3(0.13f, 0.1f, 0.55f) : new Vector3(0.13f, 0.22f, 0.24f)), (Color)(owl ? new Color(0.4f, 0.36f, 0.23f) : val4)); if (pelican) { Ellipsoid("Bill pouch", head, new Vector3(0f, -0.015f, 0.37f), new Vector3(0.07f, 0.095f, 0.23f), new Color(0.65f, 0.43f, 0.21f), 9, 5); } if (!owl && !pelican) { Wedge("Beak stripe", head, new Vector3(0f, 0.065f, 0.2f), new Vector3(0.132f, 0.18f, 0.075f), new Color(0.41f, 0.36f, 0.22f)); } if (owl) { Color color2 = default(Color); ((Color)(ref color2))..ctor(0.23f, 0.27f, 0.16f); for (int n = -1; n <= 1; n += 2) { ClothPanel("Fitted cloth waistcoat", body, n, color2); } for (int num2 = 0; num2 < 3; num2++) { float num3 = 0.3f - (float)num2 * 0.075f; Ellipsoid("Wooden button", body, new Vector3(0.008f, num3, ChestSurface(0.008f, num3) + 0.025f), new Vector3(0.009f, 0.009f, 0.004f), val, 6, 2); } Color color3 = default(Color); ((Color)(ref color3))..ctor(0.22f, 0.13f, 0.065f); Transform val7 = Node("Crooked leather cap", head, new Vector3(0f, 0.28f, 0f)); val7.localRotation = Quaternion.Euler(0f, 0f, -9f); Ellipsoid("Cap crown", val7, Vector3.zero, new Vector3(0.248f, 0.09f, 0.2f), color3, 12, 4); Ellipsoid("Short brim", val7, new Vector3(0f, -0.031f, 0.16f), new Vector3(0.25f, 0.025f, 0.14f), color3, 10, 3); Ring("Keyring", body, new Vector3(0.19f, 0.15f, 0.17f), 0.045f, 0.006f, new Color(0.21f, 0.21f, 0.18f)); Vector3 val8 = default(Vector3); for (int num4 = 0; num4 < 3; num4++) { ((Vector3)(ref val8))..ctor(0.16f + (float)num4 * 0.025f, 0.12f, 0.18f); Rod("Key shaft", body, val8, val8 + new Vector3(0.01f, -0.085f, 0f), 0.007f, val3); Rod("Key bit", body, val8 + new Vector3(0.01f, -0.075f, 0f), val8 + new Vector3(0.035f, -0.075f, 0f), 0.01f, val3); } } else if (pelican) { Color color4 = default(Color); ((Color)(ref color4))..ctor(0.32f, 0.3f, 0.16f); FisherHat(head, color4); Rod("Hat cord", head, new Vector3(-0.19f, 0.18f, 0.1f), new Vector3(-0.1f, -0.075f, 0.14f), 0.009f, val); } else { Color val9 = default(Color); ((Color)(ref val9))..ctor(0.31f, 0.2f, 0.1f); Color val10 = default(Color); ((Color)(ref val10))..ctor(0.12f, 0.17f, 0.22f); ClothPanel("Fitted leather apron", body, 0, val9); float num5 = ChestSurface(0.06f, 0.19f) + 0.025f; Ellipsoid("Apron pocket", body, new Vector3(0.06f, 0.19f, num5), new Vector3(0.047f, 0.037f, 0.005f), val9 * 0.8f, 4, 3); Rod("Carpenter pencil", body, new Vector3(0.075f, 0.2f, num5 + 0.006f), new Vector3(0.083f, 0.3f, num5 - 0.014f), 0.009f, new Color(0.63f, 0.43f, 0.15f)); Ellipsoid("Knit cap", head, new Vector3(-0.02f, 0.29f, -0.02f), new Vector3(0.244f, 0.14f, 0.2f), val10, 12, 6); Ellipsoid("Folded wool brim", head, new Vector3(0f, 0.25f, 0f), new Vector3(0.252f, 0.047f, 0.2f), val10 * 1.2f, 12, 3); Ellipsoid("Fuzzy pompom", head, new Vector3(-0.045f, 0.435f, -0.045f), new Vector3(0.079f, 0.072f, 0.077f), val2, 9, 5); for (int num6 = -1; num6 <= 1; num6 += 2) { Rod("Apron strap", body, new Vector3((float)num6 * 0.16f, 0.38f, 0.16f), new Vector3((float)num6 * 0.1f, 0.52f, 0.08f), 0.018f, val9); } } hammer = Tool("Wooden hammer", head); chisel = Tool("Chisel", head); needle = Tool("Sail needle", head); Rod("Handle", hammer.transform, new Vector3(0f, 0f, 0f), new Vector3(0.23f, 0f, 0f), 0.018f, new Color(0.36f, 0.23f, 0.1f)); Ellipsoid("Hammer head", hammer.transform, new Vector3(0.24f, 0f, 0f), new Vector3(0.043f, 0.09f, 0.042f), val, 4, 3); Rod("Chisel handle", chisel.transform, Vector3.zero, new Vector3(0f, -0.085f, 0.02f), 0.024f, val); Rod("Chisel blade", chisel.transform, new Vector3(0f, -0.07f, 0.02f), new Vector3(0f, -0.2f, 0.045f), 0.011f, new Color(0.27f, 0.28f, 0.27f)); Rod("Needle", needle.transform, Vector3.zero, new Vector3(0.16f, 0f, 0.06f), 0.005f, new Color(0.35f, 0.36f, 0.33f)); sailcloth = new GameObject("Sailcloth sample"); sailcloth.transform.SetParent(leftWing, false); Ellipsoid("Linen", sailcloth.transform, new Vector3(-0.025f, -0.05f, 0.2f), new Vector3(0.11f, 0.025f, 0.15f), val2, 6, 3); if (pelican) { fishingPole = new GameObject("Fishing pole"); fishingPole.transform.SetParent(leftWing, false); fishingPole.transform.localPosition = new Vector3(0.08f, -0.09f, 0.15f); Rod("Ash rod", fishingPole.transform, Vector3.zero, new Vector3(0f, 0.6f, 0.85f), 0.012f, val); Rod("Flexible rod tip", fishingPole.transform, new Vector3(0f, 0.6f, 0.85f), new Vector3(0f, 0.55f, 1.1f), 0.006f, val); Rod("Fishing line", fishingPole.transform, new Vector3(0f, 0.55f, 1.1f), new Vector3(0f, -0.65f, 1.35f), 0.0025f, val2); Ellipsoid("Cork float", fishingPole.transform, new Vector3(0f, -0.63f, 1.35f), new Vector3(0.018f, 0.036f, 0.018f), val4, 6, 3); } SetTool(0); MergeStaticParts(); } catch { Dispose(); throw; } } private void FisherHat(Transform parent, Color color) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) float[] array = new float[6] { 0.18f, 0.192f, 0.215f, 0.3f, 0.365f, 0.385f }; float[] array2 = new float[6] { 0.3f, 0.32f, 0.235f, 0.218f, 0.16f, 0f }; List<Vector3> list = new List<Vector3>(); List<int> list2 = new List<int>(); for (int i = 0; i < array.Length; i++) { for (int j = 0; j < 32; j++) { float num = (float)(j * 2) * (float)Math.PI / 32f; list.Add(new Vector3(array2[i] * Mathf.Cos(num), array[i], array2[i] * 0.82f * Mathf.Sin(num))); } } for (int k = 0; k < array.Length - 1; k++) { for (int l = 0; l < 32; l++) { int num2 = k * 32 + l; int num3 = k * 32 + (l + 1) % 32; int num4 = num2 + 32; int num5 = num3 + 32; list2.AddRange(new int[6] { num2, num3, num4, num3, num5, num4 }); } } MeshPart("Fisherman's cloth hat", parent, Vector3.zero, list, list2, color); } private static float ChestSurface(float x, float y) { return Math.Max(Surface(0.245f, 0.34f, 0.29f, -0.035f, 0.195f), Surface(0.19f, 0.3f, 0.3f, 0.09f, 0.12f)); float Surface(float rx, float ry, float cy, float cz, float rz) { return cz + rz * (float)Math.Sqrt(Math.Max(0f, 1f - x * x / (rx * rx) - (y - cy) * (y - cy) / (ry * ry))); } } private void ClothPanel(string name, Transform parent, int side, Color color) { //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); List<int> list2 = new List<int>(); float[] array = new float[9] { 0.045f, 0.09f, 0.14f, 0.2f, 0.26f, 0.32f, 0.38f, 0.425f, 0.47f }; float[] array2 = new float[9] { 0.115f, 0.15f, 0.177f, 0.188f, 0.19f, 0.184f, 0.17f, 0.15f, 0.12f }; float[] array3 = new float[9] { 0.012f, 0.01f, 0.008f, 0.008f, 0.008f, 0.02f, 0.035f, 0.067f, 0.103f }; for (int i = 0; i < array.Length; i++) { for (int j = 0; j <= 20; j++) { float num = (float)j / 20f; float num2 = ((side == 0) ? (0f - array2[i] + 2f * array2[i] * num) : ((float)side * (array3[i] + (array2[i] - array3[i]) * num))); float num3 = array[i]; list.Add(new Vector3(num2, num3, ChestSurface(num2, num3) + 0.018f)); } } for (int k = 0; k < array.Length - 1; k++) { for (int l = 0; l < 20; l++) { int num4 = k * 21 + l; int num5 = num4 + 1; int num6 = num4 + 20 + 1; int num7 = num6 + 1; if (side < 0) { list2.AddRange(new int[6] { num4, num5, num6, num5, num7, num6 }); } else { list2.AddRange(new int[6] { num4, num6, num5, num5, num6, num7 }); } } } MeshPart(name, parent, Vector3.zero, list, list2, color); } private void MergeStaticParts() { //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) HashSet<Transform> pivots = new HashSet<Transform> { Root.transform, body, head, leftWing, rightWing, hammer.transform, chisel.transform, needle.transform, sailcloth.transform }; foreach (Transform eye in eyes) { pivots.Add(eye); } if (Object.op_Implicit((Object)(object)fishingPole)) { pivots.Add(fishingPole.transform); } IGrouping<(Transform, Material), MeshRenderer>[] array = Root.GetComponentsInChildren<MeshRenderer>(true).GroupBy(delegate(MeshRenderer r) { Transform parent2 = ((Component)r).transform.parent; while (Object.op_Implicit((Object)(object)parent2) && !pivots.Contains(parent2)) { parent2 = parent2.parent; } return (Pivot: parent2, Material: ((Renderer)r).sharedMaterial); }).ToArray(); foreach (IGrouping<(Transform, Material), MeshRenderer> grouping in array) { MeshRenderer[] array2 = grouping.ToArray(); if (array2.Length >= 2 && Object.op_Implicit((Object)(object)grouping.Key.Item1)) { Transform parent = grouping.Key.Item1; Mesh val = new Mesh { name = "Bird combined surface" }; val.CombineMeshes(array2.Select(delegate(MeshRenderer r) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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) CombineInstance result = default(CombineInstance); ((CombineInstance)(ref result)).mesh = ((Component)r).GetComponent<MeshFilter>().sharedMesh; ((CombineInstance)(ref result)).transform = parent.worldToLocalMatrix * ((Component)r).transform.localToWorldMatrix; return result; }).ToArray(), true, true); assets.Add((Object)(object)val); Transform obj = Node("Combined bird surface", parent, Vector3.zero); ((Component)obj).gameObject.AddComponent<MeshFilter>().sharedMesh = val; MeshRenderer obj2 = ((Component)obj).gameObject.AddComponent<MeshRenderer>(); ((Renderer)obj2).sharedMaterial = grouping.Key.Item2; ((Renderer)obj2).receiveShadows = true; ((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)1; MeshRenderer[] array3 = array2; foreach (MeshRenderer obj3 in array3) { MeshFilter component = ((Component)obj3).GetComponent<MeshFilter>(); Mesh sharedMesh = component.sharedMesh; Object.DestroyImmediate((Object)(object)obj3); Object.DestroyImmediate((Object)(object)component); assets.Remove((Object)(object)sharedMesh); Object.DestroyImmediate((Object)(object)sharedMesh); } } } } private static Transform Node(string name, Transform parent, Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject(name).transform; transform.SetParent(parent, false); transform.localPosition = position; return transform; } private GameObject Tool(string name, Transform parent) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) return ((Component)Node(name, parent, new Vector3(0f, 0.07f, 0.3f))).gameObject; } internal void Fishing(bool active) { if (Object.op_Implicit((Object)(object)fishingPole)) { fishingPole.SetActive(active); } } internal void SetTool(int tool) { hammer.SetActive(tool == 1); chisel.SetActive(tool == 2); needle.SetActive(tool == 3); sailcloth.SetActive(tool == 3); } internal void Pose(float pitch, float yaw, float roll, float bodyPitch, float crouch, float wing = 0f) { //IL_0028: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) body.localPosition = new Vector3(0f, bodyHeight - Mathf.Clamp(crouch, 0f, 0.13f), 0f); body.localRotation = Quaternion.Euler(bodyPitch, 0f, 0f); head.localPosition = headRest; head.localRotation = Quaternion.Euler(pitch, yaw, roll); leftWing.localRotation = Quaternion.Euler(0f - wing, 0f, wing * 0.4f); rightWing.localRotation = Quaternion.Euler(wing * 0.3f, 0f, (0f - wing) * 0.4f); } internal void CloseEyes(float amount) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) foreach (Transform eye in eyes) { eye.localScale = new Vector3(1f, 1f - 0.97f * Mathf.Clamp(amount, 0f, 1f), 1f); } } internal void Rest(bool sleeping, float time, float delta) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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) rest = Mathf.MoveTowards(rest, (float)(sleeping ? 1 : 0), delta * (sleeping ? 0.7f : 5f)); float num = ((time % 5.3f > 5.12f) ? Mathf.Sin((time % 5.3f - 5.12f) / 0.18f * (float)Math.PI) : 0f); CloseEyes(Mathf.Max(rest, num)); if (!(rest <= 0f)) { head.localRotation = Quaternion.Slerp(head.localRotation, Quaternion.Euler(34f, (float)(owl ? 85 : 115), -12f), rest); Transform obj = body; obj.localPosition += Vector3.up * (-0.055f + 0.004f * Mathf.Sin(time * 1.5f)) * rest; } } internal void Probes(Transform anchor) { Renderer[] componentsInChildren = Root.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].probeAnchor = anchor; } } private Texture2D Surface() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)surface)) { return surface; } using Stream stream = typeof(PerchedBird).Assembly.GetManifestResourceStream("VikingBirds.surface.png"); if (stream == null) { return Texture2D.whiteTexture; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, memoryStream.ToArray())) { Object.Destroy((Object)(object)val); return Texture2D.whiteTexture; } Color32[] pixels = val.GetPixels32(); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { array[i * 64 + j] = pixels[i * ((Texture)val).height / 64 * ((Texture)val).width + j * ((Texture)val).width / 64]; } } surface = new Texture2D(64, 64, (TextureFormat)4, true) { name = "Bird coarse surface", filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)0 }; surface.SetPixels32(array); surface.Apply(); Object.Destroy((Object)(object)val); assets.Add((Object)(object)surface); return surface; } private Material Paint(Color color, bool garment = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) string text = ColorUtility.ToHtmlStringRGB(color) + (garment ? " cloth" : " feathers"); if (palette.TryGetValue(text, out Material value)) { return value; } Material val = new Material(source.shader) { name = "Bird matte " + text, color = color }; if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(garment ? ((object)Texture2D.whiteTexture) : ((object)Surface()))); } string[] array = new string[3] { "_EmissionColor", "_EmissiveColor", "_NoiseGlowColor" }; foreach (string text2 in array) { if (val.HasProperty(text2)) { val.SetColor(text2, Color.black); } } array = new string[9] { "_NoiseGlowEnabled", "_Glossiness", "_Metallic", "_MetalGloss", "_TriplanarMap", "_ValueNoise", "_ValueNoiseVertex", "_AddRain", "_AddSnow" }; foreach (string text3 in array) { if (val.HasProperty(text3)) { val.SetFloat(text3, 0f); } } if (val.HasProperty("_MoveableObject")) { val.SetFloat("_MoveableObject", 1f); } val.DisableKeyword("_EMISSION"); val.DisableKeyword("NOISEGLOW"); val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)4; assets.Add((Object)(object)val); palette[text] = val; return val; } private Transform MeshPart(string name, Transform parent, Vector3 position, List<Vector3> vertices, List<int> triangles, Color color) { //IL_0035: 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) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_011e: 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) Vector3[] array = (Vector3[])(object)new Vector3[triangles.Count]; int[] array2 = new int[array.Length]; Vector2[] array3 = (Vector2[])(object)new Vector2[array.Length]; for (int i = 0; i < array.Length; i++) { array[i] = vertices[triangles[i]]; array2[i] = i; array3[i] = new Vector2(array[i].x * 3f + array[i].z * 1.7f + 0.5f, array[i].y * 3f + array[i].z * 0.3f + 0.5f); } for (int j = 0; j < array2.Length; j += 3) { array2[j + 1] = j + 2; array2[j + 2] = j + 1; } Mesh val = new Mesh { name = name, vertices = array, triangles = array2, uv = array3 }; val.RecalculateNormals(); val.RecalculateBounds(); assets.Add((Object)(object)val); Transform obj = Node(name, parent, position); ((Component)obj).gameObject.AddComponent<MeshFilter>().sharedMesh = val; MeshRenderer obj2 = ((Component)obj).gameObject.AddComponent<MeshRenderer>(); ((Renderer)obj2).sharedMaterial = Paint(color, name.IndexOf("cloth", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("apron", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("cap", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("brim", StringComparison.OrdinalIgnoreCase) >= 0); ((Renderer)obj2).receiveShadows = true; ((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)1; return obj; } private Transform Ellipsoid(string name, Transform parent, Vector3 position, Vector3 size, Color color, int sides, int rings) { //IL_0039: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) sides *= 2; List<Vector3> list = new List<Vector3>(); List<int> list2 = new List<int>(); for (int i = 0; i <= rings; i++) { for (int j = 0; j < sides; j++) { float num = (float)(j * 2) * (float)Math.PI / (float)sides; float num2 = (float)i * (float)Math.PI / (float)rings; list.Add(Vector3.Scale(size, new Vector3(Mathf.Sin(num2) * Mathf.Cos(num), Mathf.Cos(num2), Mathf.Sin(num2) * Mathf.Sin(num)))); } } for (int k = 0; k < rings; k++) { for (int l = 0; l < sides; l++) { int num3 = k * sides + l; int num4 = k * sides + (l + 1) % sides; int num5 = num3 + sides; int num6 = num4 + sides; list2.AddRange(new int[6] { num3, num5, num4, num4, num5, num6 }); } } return MeshPart(name, parent, position, list, list2, color); } private void Rod(string name, Transform parent, Vector3 a, Vector3 b, float radius, Color color) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_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_0044: 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) Vector3 position = (a + b) * 0.5f; Vector3 val = b - a; Ellipsoid(name, parent, position, new Vector3(radius, ((Vector3)(ref val)).magnitude * 0.5f, radius), color, 6, 3).localRotation = Quaternion.FromToRotation(Vector3.up, b - a); } private void Wedge(string name, Transform parent, Vector3 position, Vector3 size, Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3> { new Vector3((0f - size.x) * 0.5f, size.y * 0.5f, 0f), new Vector3(size.x * 0.5f, size.y * 0.5f, 0f), new Vector3((0f - size.x) * 0.5f, (0f - size.y) * 0.5f, 0f), new Vector3(size.x * 0.5f, (0f - size.y) * 0.5f, 0f), new Vector3(0f, (0f - size.y) * 0.3f, size.z) }; List<int> list2 = new List<int>(); int[] array = new int[18] { 0, 1, 4, 1, 3, 4, 3, 2, 4, 2, 0, 4, 0, 2, 1, 1, 2, 3 }; for (int i = 0; i < array.Length; i += 3) { int num = array[i]; int num2 = array[i + 1]; int num3 = array[i + 2]; int count = list.Count; list.Add((list[num] + list[num2]) * 0.5f); list2.AddRange(new int[6] { num, count, num3, count, num2, num3 }); } MeshPart(name, parent, position, list, list2, color); } private void Ring(string name, Transform parent, Vector3 center, float radius, float wire, Color color) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0073: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 10; i++) { float num = (float)(i * 2) * (float)Math.PI / 10f; float num2 = (float)((i + 1) * 2) * (float)Math.PI / 10f; Rod(name, parent, center + new Vector3(Mathf.Cos(num), Mathf.Sin(num), 0f) * radius, center + new Vector3(Mathf.Cos(num2), Mathf.Sin(num2), 0f) * radius, wire, color); } } public void Dispose() { if (Object.op_Implicit((Object)(object)Root)) { Object.Destroy((Object)(object)Root); } foreach (Object asset in assets) { if (Object.op_Implicit(asset)) { Object.Destroy(asset); } } assets.Clear(); palette.Clear(); } } } namespace VikingGull { public sealed class GullHelmet : MonoBehaviour { private Material template; private readonly List<Mesh> meshes = new List<Mesh>(); private readonly List<Material> materials = new List<Material>(); internal static readonly Vector3 Crown = new Vector3(0f, 1.216f, -0.345f); internal static GullHelmet Create(Transform parent, Vector3 position, Material template = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0062: 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_00a2: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Viking gull helmet"); val.transform.SetParent(parent, false); val.transform.localPosition = position; GullHelmet gullHelmet = val.AddComponent<GullHelmet>(); Renderer component = ((Component)parent).GetComponent<Renderer>(); gullHelmet.template = (Object.op_Implicit((Object)(object)template) ? template : (Object.op_Implicit((Object)(object)component) ? component.sharedMaterial : null)); Material material = gullHelmet.Material(new Color(0.27f, 0.3f, 0.32f), 0.65f); Material material2 = gullHelmet.Material(new Color(0.57f, 0.35f, 0.13f), 0.55f); Material material3 = gullHelmet.Material(new Color(0.82f, 0.75f, 0.54f), 0.05f); gullHelmet.Surface("Iron cap", material, 12, 4, delegate(float u, float v) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) float num2 = u * (float)Math.PI * 2f; float num3 = v * (float)Math.PI * 0.5f; return new Vector3(Mathf.Cos(num2) * 0.079f * Mathf.Cos(num3), 0.094f * Mathf.Sin(num3), Mathf.Sin(num2) * 0.103f * Mathf.Cos(num3)); }); gullHelmet.Surface("Bronze brow band", material2, 12, 1, delegate(float u, float v) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) float num2 = u * (float)Math.PI * 2f; return new Vector3(Mathf.Cos(num2) * 0.082f, -0.006f + v * 0.024f, Mathf.Sin(num2) * 0.106f); }); for (int num = -1; num <= 1; num += 2) { int s = num; gullHelmet.Surface("Curved horn", material3, 7, 6, delegate(float u, float v) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) float num2 = u * (float)Math.PI * 2f; float num3 = 0.031f * (1f - v); return new Vector3((float)s * (0.067f + 0.143f * v) + num3 * Mathf.Cos(num2) * 0.5f, 0.046f + 0.032f * v + 0.135f * v * v + num3 * Mathf.Sin(num2), 0.008f + 0.042f * v + num3 * Mathf.Cos(num2)); }); } return gullHelmet; } private Material Material(Color color, float metallic) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Material val = GullMaterials.Create(template, color, metallic); if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture); } materials.Add(val); return val; } private void Surface(string label, Material material, int sides, int rings, Func<float, float, Vector3> point) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) List<Vector3> vertices = new List<Vector3>(); List<int> triangles = new List<int>(); for (int i = 0; i < rings; i++) { for (int j = 0; j < sides; j++) { Vector3 val = point((float)j / (float)sides, (float)i / (float)rings); Vector3 val2 = point((float)(j + 1) / (float)sides, (float)i / (float)rings); Vector3 b = point((float)j / (float)sides, (float)(i + 1) / (float)rings); Vector3 val3 = point((float)(j + 1) / (float)sides, (float)(i + 1) / (float)rings); Triangle(val, b, val2); Triangle(val2, b, val3); Triangle(val2, b, val); Triangle(val3, b, val2); } } Mesh val4 = new Mesh { name = label }; val4.SetVertices(vertices); val4.SetTriangles(triangles, 0); val4.RecalculateNormals(); val4.RecalculateBounds(); meshes.Add(val4); GameObject val5 = new GameObject(label); val5.transform.SetParent(((Component)this).transform, false); val5.AddComponent<MeshFilter>().sharedMesh = val4; ((Renderer)val5.AddComponent<MeshRenderer>()).sharedMaterial = material; void Triangle(Vector3 a, Vector3 item, Vector3 c) { //IL_0012: 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_002a: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; vertices.Add(a); vertices.Add(item); vertices.Add(c); triangles.Add(count); triangles.Add(count + 1); triangles.Add(count + 2); } } internal void FollowStanding(Quaternion head, Quaternion body, Vector3 neck, Vector3 hips, float crouch) { //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) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_004f: 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) Vector3 val = neck + head * (Crown - neck); ((Component)this).transform.localPosition = hips + body * (val - hips) - Vector3.up * crouch; ((Component)this).transform.localRotation = body * head; } internal static void FitFlying(GameObject model, Transform actor) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) SkinnedMeshRenderer componentInChildren = model.GetComponentInChildren<SkinnedMeshRenderer>(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { return; } Transform val = ((Component)componentInChildren).transform; bool flag = false; Transform[] bones = componentInChildren.bones; foreach (Transform val2 in bones) { if (Object.op_Implicit((Object)(object)val2) && ((Object)val2).name == "Bone") { val = val2; flag = true; break; } } if (!flag) { return; } Mesh val3 = new Mesh(); try { componentInChildren.BakeMesh(val3); Vector3[] vertices = val3.vertices; float num = float.NegativeInfinity; float num2 = float.PositiveInfinity; for (int j = 0; j < vertices.Length; j++) { vertices[j] = actor.InverseTransformPoint(((Component)componentInChildren).transform.TransformPoint(vertices[j])); num = Mathf.Max(num, vertices[j].z); num2 = Mathf.Min(num2, vertices[j].z); } Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(0f, float.NegativeInfinity, 0f); Vector3[] array = vertices; foreach (Vector3 val5 in array) { if (Mathf.Abs(val5.x) < 0.09f && val5.z > Mathf.Lerp(num2, num, 0.68f) && val5.y > val4.y) { val4 = val5; } } if (!float.IsInfinity(val4.y)) { GullHelmet gullHelmet = Create(actor, new Vector3(0f, val4.y - 0.02f * model.transform.localScale.y, val4.z), ((Renderer)componentInChildren).sharedMaterial); ((Component)gullHelmet).transform.localScale = model.transform.localScale; ((Component)gullHelmet).transform.localRotation = Quaternion.Euler(0f, 180f, 0f); ((Component)gullHelmet).transform.SetParent(val, true); } } finally { Object.Destroy((Object)(object)val3); } } private void OnDestroy() { foreach (Mesh mesh in meshes) { if (Object.op_Implicit((Object)(object)mesh)) { Object.Destroy((Object)(object)mesh); } } foreach (Material material in materials) { if (Object.op_Implicit((Object)(object)material)) { Object.Destroy((Object)(object)material); } } } } } namespace Quartermaster { internal enum CabinetMount { Floor, Wall, Ceiling, Corner, Slope } internal sealed class ApothecaryDefinition { internal string Prefab; internal string Name; internal string Model; internal string Jar; internal string Category = "ingredients,reagents"; internal FurnitureHandling Handling; internal int Columns; internal int Rows = 2; internal int Wood = 20; internal int FineWood = 5; internal int Bronze; internal int CoreWood; internal string Station = "piece_workbench"; internal float Width; internal float Height; internal float Depth = 0.55f; internal float DrawDistance = 0.23f; internal bool Glass; internal float DisplayWidth; internal float DisplayHeight; internal float DisplayDepth; internal bool HorizontalDisplay; internal bool PlayerLid; internal float LidHeight; internal float LidBack; internal int Doors; internal float DoorHingeX; internal float DoorFront; internal CabinetMount Mount; internal int Capacity => Columns * Rows; } internal static class Apothecary { internal const string Unfired = "Quartermaster_UnfiredJar"; internal const string Jar = "Quartermaster_ClayJar"; internal const string Blank = "Quartermaster_CrystalFlaskBlank"; internal const string Flask = "Quartermaster_CrystalFlask"; internal const string Kiln = "Quartermaster_PotteryKiln"; internal static readonly ApothecaryDefinition[] Cabinets = new ApothecaryDefinition[7] { new ApothecaryDefinition { Prefab = "Quartermaster_ClayCabinet", Name = "Clay Jar Cabinet", Model = "modular_clay", Jar = "Quartermaster_ClayJar", Columns = 4, Rows = 3, Width = 2f, Height = 2f, Depth = 0.6f }, new ApothecaryDefinition { Prefab = "Quartermaster_CrystalCabinet", Name = "Crystal Flask Cabinet", Model = "modular_crystal", Jar = "Quartermaster_CrystalFlask", Columns = 4, Rows = 3, Width = 2f, Height = 2f, Depth = 0.6f, Glass = true }, new ApothecaryDefinition { Prefab = "Quartermaster_ClayCabinetNarrow", Name = "Narrow Clay Cabinet", Model = "clay_narrow", Jar = "Quartermaster_ClayJar", Columns = 2, Rows = 3, Width = 0.94f, Height = 2.05f, Wood = 16, FineWood = 4 }, new ApothecaryDefinition { Prefab = "Quartermaster_ClayCabinetLow", Name = "Low Clay Cabinet", Model = "clay_low", Jar = "Quartermaster_ClayJar", Columns = 4, Rows = 1, Width = 1.7f, Height = 0.93f, Wood = 12, FineWood = 3 }, new ApothecaryDefinition { Prefab = "Quartermaster_CrystalCabinetWall", Name = "Wall Flask Cabinet", Model = "crystal_wall", Jar = "Quartermaster_CrystalFlask", Columns = 3, Rows = 1, Width = 1.36f, Height = 0.73f, Depth = 0.46f, Glass = true, Mount = CabinetMount.Wall, Wood = 8, FineWood = 4 }, new ApothecaryDefinition { Prefab = "Quartermaster_ClayCabinetCorner", Name = "Corner Clay Cabinet", Model = "clay_corner", Jar = "Quartermaster_ClayJar", Columns = 2, Rows = 2, Width = 1.38f, Height = 1.5f, Depth = 0.8f, Mount = CabinetMount.Corner, Wood = 14, FineWood = 4 }, new ApothecaryDefinition { Prefab = "Quartermaster_CrystalCabinetRafter", Name = "Rafter Flask Rack", Model = "crystal_rafter", Jar = "Quartermaster_CrystalFlask", Columns = 4, Rows = 1, Width = 1.8f, Height = 1.15f, Glass = true, Mount = CabinetMount.Ceiling, Wood = 14, FineWood = 4 } }; internal static readonly ApothecaryDefinition[] MeadShelves = new ApothecaryDefinition[1] { new ApothecaryDefinition { Prefab = "Quartermaster_MeadCabinet", Name = "Mead Cabinet", Model = "mead_cabinet", Columns = 6, Rows = 4, Width = 2f, Height = 2f, Depth = 0.6f, Wood = 10, FineWood = 4, CoreWood = 2, Category = "meads", Handling = FurnitureHandling.Mead, DisplayWidth = 0.13f, DisplayHeight = 0.2f, DisplayDepth = 0.12f } }; private static bool registered; internal static IEnumerable<ApothecaryDefinition> All => Cabinets.Concat(MeadShelves).Concat(BulkStorage.Pieces).Concat(SoftStorage.Pieces) .Concat(MasonryStorage.Pieces) .Concat(PantryStorage.Pieces) .Concat(ArmoryStorage.Pieces) .Concat(WardrobeStorage.Pieces) .Concat(DisplayStorage.Enabled ? ((IEnumerable<ApothecaryDefinition>)DisplayStorage.Pieces) : ((IEnumerable<ApothecaryDefinition>)Array.Empty<ApothecaryDefinition>())); internal static ApothecaryDefinition Definition(string name) { if (!(name == "Quartermaster_apothecary_chest_drawer")) { return All.FirstOrDefault((ApothecaryDefinition d) => d.Prefab == name); } return DrawerFurniture.Definition; } internal static void Initialize() { PrefabManager.OnVanillaPrefabsAvailable += Register; } internal static void Shutdown() { PrefabManager.OnVanillaPrefabsAvailable -= Register; } private static void Register() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Expected O, but got Unknown //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: 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_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Expected O, but got Unknown if (registered) { return; } try { ApothecaryArt.Initialize(PrefabManager.Instance.GetPrefab("piece_chest_wood")); Item("Quartermaster_UnfiredJar", "Unfired Jar", "Soft clay shaped at a workbench. Fire in a Pottery Kiln.", "unfired_jar", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Quartermaster_RawClay", 3, 0, true) }); Item("Quartermaster_ClayJar", "Clay Jar", "A fired, lidded jar for an apothecary cabinet.", "clay_jar", null); Item("Quartermaster_CrystalFlaskBlank", "Crystal Flask Blank", "Prepared crystal for a flask. Melt and form in a Pottery Kiln.", "flask_blank", (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Crystal", 2, 0, true) }); Item("Quartermaster_CrystalFlask", "Crystal Flask", "A stoppered crystal flask for an apothecary cabinet.", "crystal_flask", null); GameObject obj = PrefabManager.Instance.CreateClonedPrefab("Quartermaster_PotteryKiln", "smelter"); Smelter component = obj.GetComponent<Smelter>(); component.m_name = "Pottery Kiln"; component.m_addOreTooltip = "Add jar or flask blank"; component.m_maxOre = 10; component.m_maxFuel = 10; component.m_fuelPerProduct = 2; component.m_secPerProduct = 45f; component.m_conversion = new List<ItemConversion> { Conversion("Quartermaster_UnfiredJar", "Quartermaster_ClayJar"), Conversion("Quartermaster_CrystalFlaskBlank", "Quartermaster_CrystalFlask") }; PieceConfig val = new PieceConfig(); val.Name = "Pottery Kiln"; val.Description = "Fire clay jars and crystal flasks with coal. Uses the native smelter body."; val.PieceTable = "Hammer"; val.Category = "Quartermaster"; val.CraftingStation = "piece_workbench"; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Stone", 20, 0, true), new RequirementConfig("SurtlingCore", 2, 0, true), new RequirementConfig("Quartermaster_RawClay", 10, 0, true) }; AddPiece(obj, val); foreach (ApothecaryDefinition item in All) { GameObject obj2 = PrefabManager.Instance.CreateClonedPrefab(item.Prefab, "piece_chest_wood"); ConfigurePlacement(obj2.GetComponent<Piece>(), item); ApothecaryArt.Cabinet(obj2, item); Container component2 = obj2.GetComponent<Container>(); component2.m_name = item.Name; component2.m_width = item.Columns; component2.m_height = item.Rows; component2.m_defaultItems = new DropTable(); obj2.AddComponent<ApothecaryDisplay>(); AddPiece(obj2, new PieceConfig { Enabled = true, Name = item.Name, Description = ((item.Category == "meads") ? "Stores finished meads only. 24 inventory slots; displays stored bottles on the shelves." : ("Automatically stores " + item.Category.Replace(",", " and ") + ". Configure exceptions in Chest Config.")), Icon = ApothecaryArt.Icon(item.Model), PieceTable = "Hammer", Category = "Quartermaster", CraftingStation = item.Station, Requirements = Requirements(item) }); } registered = true; Shutdown(); Plugin.Log.LogInfo((object)("Registered pottery chain, native-body Pottery Kiln and " + All.Count() + " buildable storage furniture pieces.")); } catch (Exception ex) { Plugin.Log.LogError((object)("Quartermaster apothecary registration failed: " + ex)); } } internal static RequirementConfig[] Requirements(ApothecaryDefinition def) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown List<RequirementConfig> list = new List<RequirementConfig>(); if (def.CoreWood > 0) { list.Add(new RequirementConfig("RoundLog", def.CoreWood, 0, true)); } if (def.Wood > 0) { list.Add(new RequirementConfig("Wood", def.Wood, 0, true)); } if (def.Bronze > 0) { list.Add(new RequirementConfig("Bronze", def.Bronze, 0, true)); } if (def.FineWood > 0) { list.Add(new RequirementConfig("FineWood", def.FineWood, 0, true)); } if (!string.IsNullOrEmpty(def.Jar)) { list.Add(new RequirementConfig(def.Jar, def.Capacity, 0, true)); } return list.ToArray(); } internal static void ConfigurePlacement(Piece piece, ApothecaryDefinition def) { if (def.Mount == CabinetMount.Wall || def.Mount == CabinetMount.Ceiling) { piece.m_groundPiece = false; piece.m_groundOnly = false; piece.m_cultivatedGroundOnly = false; piece.m_waterPiece = false; piece.m_notOnWood = false; piece.m_notOnTiltingSurface = false; piece.m_inCeilingOnly = def.Mount == CabinetMount.Ceiling; piece.m_notOnFloor = true; } } private static void Item(string id, string name, string description, string art, RequirementConfig[] requirements) { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown GameObject val = PrefabManager.Instance.CreateClonedPrefab(id, "Flint"); ApothecaryArt.Item(val, art); ItemData itemData = val.GetComponent<ItemDrop>().m_itemData; itemData.m_dropPrefab = val; itemData.m_stack = 1; itemData.m_shared.m_name = name; itemData.m_shared.m_description = description; itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { ApothecaryArt.Icon(art) }; itemData.m_shared.m_maxStackSize = 20; itemData.m_shared.m_weight = 0.5f; itemData.m_shared.m_value = 0; CustomItem val2 = ((requirements == null) ? new CustomItem(val, false) : new CustomItem(val, false, new ItemConfig { Name = name, Description = description, CraftingStation = "piece_workbench", MinStationLevel = 1, Amount = 1, Requirements = requirements })); if (!ItemManager.Instance.AddItem(val2)) { throw new InvalidOperationException("Cannot register " + id); } ItemStacks.Apply(itemData.m_shared); } private static ItemConversion Conversion(string from, string to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown return new ItemConversion { m_from = PrefabManager.Instance.GetPrefab(from).GetComponent<ItemDrop>(), m_to = PrefabManager.Instance.GetPrefab(to).GetComponent<ItemDrop>() }; } private static void AddPiece(GameObject prefab, PieceConfig config) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown if (!PieceManager.Instance.AddPiece(new CustomPiece(prefab, false, config))) { throw new InvalidOperationException("Cannot register " + ((Object)prefab).name); } if (config.Enabled) { BuildMenuCategory.Register(((Object)prefab).name); } } } internal static class ApothecaryArt { private sealed class Part { internal string Name; internal int Material; internal Mesh Mesh; } private static readonly Dictionary<string, List<Part>> models = new Dictionary<string, List<Part>>(); private static readonly Dictionary<string, Vector3[]> slots = new Dictionary<string, Vector3[]>(); private static readonly Dictionary<string, Vector3[]> anchors = new Dictionary<string, Vector3[]>(); private static readonly List<Object> assets = new List<Object>(); private static Material wood; private static Material glass; private static Material metal; private static Material soft; private static Material stone; private static Material food; private static Material bronze; private static bool initialized; private static readonly Dictionary<string, Sprite> icons = new Dictionary<string, Sprite>(); private static int Count(BinaryReader r, int max) { int num = r.ReadInt32(); if (num < 0 || num > max) { throw new InvalidDataException("Invalid apothecary asset count"); } return num; } private static string ReadName(BinaryReader r) { return Encoding.UTF8.GetString(r.ReadBytes(Count(r, 80))); } private static Texture2D Texture(string key) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown using Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream("Quartermaster.Apothecary." + key); using MemoryStream memoryStream = new MemoryStream(); if (stream == null) { throw new InvalidDataException("Missing apothecary " + key); } stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, key.EndsWith("albedo", StringComparison.Ordinal)); assets.Add((Object)(object)val); if (!ImageConversion.LoadImage(val, memoryStream.ToArray())) { throw new InvalidDataException("Invalid apothecary texture"); } ((Texture)val).filterMode = (FilterMode)(!key.EndsWith("albedo", StringComparison.Ordinal)); ((Texture)val).wrapMode = (TextureWrapMode)1; return val; } internal static Sprite Icon(string key) { //IL_0031: 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) if (icons.TryGetValue(key, out var value)) { return value; } Texture2D val = Texture(key); value = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); assets.Add((Object)(object)value); icons[key] = value; return value; } internal static void Initialize(GameObject native) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Expected O, but got Unknown if (initialized) { return; } try { wood = StorageMaterials.Opaque(native, "Quartermaster apothecary timber and pottery", (Texture)(object)Texture("albedo")); assets.Add((Object)(object)wood); soft = new Material(wood) { name = "Quartermaster hides cloth and bone", mainTexture = (Texture)(object)Texture("soft_albedo") }; assets.Add((Object)(object)soft); stone = new Material(wood) { name = "Quartermaster rough masonry", mainTexture = (Texture)(object)Texture("stone_albedo") }; assets.Add((Object)(object)stone); food = new Material(wood) { name = "Quartermaster pantry provisions", mainTexture = (Texture)(object)Texture("food_albedo") }; assets.Add((Object)(object)food); metal = StorageMaterials.Opaque(native, "Quartermaster worn ingots", (Texture)(object)Texture("bulk_albedo"), 0.55f); assets.Add((Object)(object)metal); bronze = new Material(metal) { name = "Quartermaster forged bronze", color = new Color(0.78f, 0.57f, 0.3f) }; assets.Add((Object)(object)bronze); glass = StorageMaterials.Crystal(wood); assets.Add((Object)(object)glass); using (Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream("Quartermaster.Apothecary.model")) { using BinaryReader binaryReader = new BinaryReader(stream ?? throw new InvalidDataException("Missing apothecary mesh")); if (new string(binaryReader.ReadChars(4)) != "QMA2") { throw new InvalidDataException("Invalid apothecary format"); } int num = Count(binaryReader, 192); for (int i = 0; i < num; i++) { string text = ReadName(binaryReader); int num2 = Count(binaryReader, 16); List<Part> list = new List<Part>(); for (int j = 0; j < num2; j++) { Part part = new Part { Name = ReadName(binaryReader), Material = Count(binaryReader, 7) }; int num3 = Count(binaryReader, 16000); Vector3[] array = (Vector3[])(object)new Vector3[num3]; Vector2[] array2 = (Vector2[])(object)new Vector2[num3]; for (int k = 0; k < num3; k++) { array[k] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array2[k] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int num4 = Count(binaryReader, 48000); if (num4 % 3 != 0) { throw new InvalidDataException("Invalid apothecary triangles"); } int[] array3 = new int[num4]; for (int l = 0; l < num4; l++) { array3[l] = binaryReader.ReadInt32(); if (array3[l] < 0 || array3[l] >= num3) { throw new InvalidDataException("Invalid apothecary index"); } } Mesh val = new Mesh { name = "Quartermaster " + text + " " + part.Name, vertices = array, uv = array2, triangles = array3 }; val.RecalculateNormals(); val.RecalculateBounds(); assets.Add((Object)(object)val); part.Mesh = val; list.Add(part); } models.Add(text, list); int num5 = Count(binaryReader, 12); Vector3[] array4 = (Vector3[])(object)new Vector3[num5]; for (int m = 0; m < num5; m++) { array4[m] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } slots.Add(text, array4); num5 = Count(binaryReader, 16); Vector3[] array5 = (Vector3[])(object)new Vector3[num5]; for (int n = 0; n < num5; n++) { array5[n] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } anchors.Add(text, array5); } if (stream.Position != stream.Length) { throw new InvalidDataException("Trailing apothecary asset data"); } } initialized = true; } catch { Release(); throw; } } internal static Vector3[] Slots(string model) { if (!(model == "mead_cabinet")) { if (!model.StartsWith("modular_", StringComparison.Ordinal)) { return slots[model]; } return ModularShelfArt.Slots(model); } return MeadCabinetArt.Slots(); } internal static GameObject Create(Transform parent, string model, string name = null) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0094: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name ?? model); val.layer = ((Component)parent).gameObject.layer; val.transform.SetParent(parent, false); foreach (Part item in models[model].Where((Part p) => p.Material != 2)) { GameObject val2 = new GameObject(item.Name) { layer = val.layer }; val2.transform.SetParent(val.transform, false); val2.AddComponent<MeshFilter>().sharedMesh = item.Mesh; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = ((item.Material == 1) ? glass : ((item.Material == 3) ? metal : ((item.Material == 4) ? soft : ((item.Material == 5) ? stone : ((item.Material == 6) ? food : ((item.Material == 7) ? bronze : wood)))))); } return val; } internal static void Item(GameObject prefab, string model) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) Transform[] array = ((IEnumerable)prefab.transform).Cast<Transform>().ToArray(); for (int i = 0; i < array.Length; i++) { Object.DestroyImmediate((Object)(object)((Component)array[i]).gameObject); } Collider[] components = prefab.GetComponents<Collider>(); for (int i = 0; i < components.Length; i++) { Object.DestroyImmediate((Object)(object)components[i]); } BoxCollider obj = Create(prefab.transform, model, "attach").AddComponent<BoxCollider>(); obj.center = new Vector3(0f, 0.185f, 0f); obj.size = new Vector3(0.28f, 0.38f, 0.28f); } internal static void Cabinet(GameObject prefab, ApothecaryDefinition def) { //IL_01fc: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_0258: 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_028b: Unknown result type (might be due to invalid IL or missing references) if (def.Model.StartsWith("modular_", StringComparison.Ordinal)) { ModularShelfArt.Build(prefab, def); return; } if (def.Model == "mead_cabinet") { MeadCabinetArt.Build(prefab); return; } Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer obj in componentsInChildren) { obj.enabled = false; obj.forceRenderingOff = true; } Collider[] componentsInChildren2 = prefab.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } Transform[] componentsInChildren3 = prefab.GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren3) { if (((Component)val).CompareTag("snappoint")) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } } GameObject val2 = Create(prefab.transform, def.Model, "Quartermaster furniture"); int num = 0; while (def.Handling == FurnitureHandling.Jar && num < slots[def.Model].Length) { GameObject obj2 = Create(val2.transform, def.Glass ? "crystal_flask" : "clay_jar", "jar_" + num); obj2.transform.localPosition = slots[def.Model][num]; obj2.transform.localRotation = Quaternion.Euler(0f, (float)(num % 3 - 1) * 3f, 0f); StyleJar(obj2.transform, def.Glass, num); num++; } Part part = models[def.Model].FirstOrDefault((Part p) => p.Material == 2); if (part != null) { MeshCollider obj3 = val2.AddComponent<MeshCollider>(); obj3.sharedMesh = part.Mesh; obj3.convex = true; } else { BoxCollider val3 = val2.AddComponent<BoxCollider>(); Bounds bounds = models[def.Model][0].Mesh.bounds; foreach (Part item in from p in models[def.Model].Skip(1) where p.Material != 2 select p) { ((Bounds)(ref bounds)).Encapsulate(item.Mesh.bounds); } val3.center = ((Bounds)(ref bounds)).center; val3.size = ((Bounds)(ref bounds)).size; } Vector3[] array = anchors[def.Model]; foreach (Vector3 localPosition in array) { GameObject val4 = new GameObject("snappoint") { tag = "snappoint" }; val4.transform.SetParent(prefab.transform, false); val4.transform.localPosition = localPosition; } Container component = prefab.GetComponent<Container>(); component.m_open = null; component.m_closed = null; } internal static void SetModel(GameObject target, string model) { Part part = models[model][0]; target.GetComponent<MeshFilter>().sharedMesh = part.Mesh; ((Renderer)target.GetComponent<MeshRenderer>()).sharedMaterial = ((part.Material == 3) ? metal : ((part.Material == 4) ? soft : ((part.Material == 5) ? stone : ((part.Material == 6) ? food : ((part.Material == 7) ? bronze : wood))))); } internal static void StyleJar(Transform jar, bool glassJar, int i) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) float num = (new float[4] { 1f, 0.93f, 1.04f, 0.97f })[i % 4]; float num2 = (new float[4] { 1f, 0.94f, 1.03f, 0.97f })[i % 4]; jar.localScale = new Vector3(num, num2, num); if (!glassJar) { Color val = (new Color[4] { new Color(1.24f, 1.16f, 1.02f), new Color(0.87f, 0.95f, 0.71f), new Color(1.02f, 0.82f, 0.65f), Color.white })[i % 4]; MaterialPropertyBlock val2 = new MaterialPropertyBlock(); val2.SetColor("_Color", val); string[] array = new string[2] { "body", "lid" }; foreach (string text in array) { ((Renderer)((Component)jar.Find(text)).GetComponent<MeshRenderer>()).SetPropertyBlock(val2); } } } internal static void Release() { foreach (Object asset in assets) { if (Object.op_Implicit(asset)) { Object.Destroy(asset); } } assets.Clear(); models.Clear(); slots.Clear(); anchors.Clear(); icons.Clear(); wood = (glass = (metal = (soft = (stone = (food = (bronze = null)))))); initialized = false; } } internal sealed class ApothecaryDisplay : MonoBehaviour { private Container chest; private ApothecaryDefinition definition; private Transform[] jars; private Transform[] lids; private Transform coverHinge; private Transform[] doorHinges; private FurnitureDoors doors; private bool inventoryOpen; private int coverSounds; private Vector3[] positions; private TextMeshPro[] labels; private GameObject[] fills; private MeshRenderer[] loads; private NativeHangingItem[] hanging; private int[] variants; private MaterialPropertyBlock properties; private string[] ids; private string[] assigned; private int[] counts; private int[] limits; private bool initialized; private bool visible; private OwlWork pending; private float expires; private float animationUntil; private float nextSound; private int activeSlot = -1; private bool FittedNativeItems { get { if (!FurnitureMotion.IsRack(Handling) && Handling != FurnitureHandling.Wardrobe) { return FurnitureMotion.IsDisplay(Handling); } return true; } } private bool NativeItems { get { if (Handling != FurnitureHandling.Hanging) { return FittedNativeItems; } return true; } } private bool InteriorVisible { get { if (doors != null) { return doors.Amount > 0.12f; } return true; } } internal FurnitureHandling Handling => definition?.Handling ?? FurnitureHandling.Jar; internal float ContactTime => FurnitureMotion.Contact(Handling); internal float Duration => FurnitureMotion.Duration(Handling); internal string DisplayName => definition?.Name ?? "Apothecary cabinet"; private void Start() { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Expected O, but got Unknown //IL_037a: 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_0521: Expected O, but got Unknown //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: 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) chest = ((Component)this).GetComponent<Container>(); definition = Apothecary.Definition(ContainerRegistry.PrefabName((Component)(object)chest)); if (definition == null || !Object.op_Implicit((Object)(object)chest)) { ((Behaviour)this).enabled = false; return; } positions = ApothecaryArt.Slots(definition.Model); int num = positions.Length; jars = (Transform[])(object)new Transform[num]; lids = (Transform[])(object)new Transform[num]; labels = (TextMeshPro[])(object)new TextMeshPro[num]; fills = (GameObject[])(object)new GameObject[num]; ids = new string[num]; counts = new int[num]; hanging = new NativeHangingItem[num]; variants = new int[num]; loads = (MeshRenderer[])(object)new MeshRenderer[num]; assigned = new string[num]; limits = new int[num]; properties = new MaterialPropertyBlock(); Transform art = ((Component)this).transform.Find("Quartermaster furniture"); Transform val = art.Find("lid"); if (Object.op_Implicit((Object)(object)val) && definition.LidHeight > 0f) { coverHinge = new GameObject("Furniture cover hinge").transform; coverHinge.SetParent(art, false); coverHinge.localPosition = new Vector3(0f, definition.LidHeight, definition.LidBack); val.SetParent(coverHinge, false); val.localPosition = -coverHinge.localPosition; if (definition.PlayerLid) { doors = new FurnitureDoors(); } } if (definition.Doors > 0) { doors = new FurnitureDoors(