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 ValhAllCraft v0.1.4
BepInEx/plugins/ValhAllCraft/ValhAllCraft.dll
Decompiled 6 days 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.Configuration; using BepInEx.Logging; using GUIFramework; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using SoftReferenceableAssets; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("Worldcraft.WorldTests")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("ValhAllCraft")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.4.0")] [assembly: AssemblyInformationalVersion("0.1.4")] [assembly: AssemblyProduct("ValhAllCraft")] [assembly: AssemblyTitle("ValhAllCraft")] [assembly: AssemblyVersion("0.1.4.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Zephyrfit.Worldcraft { internal static class BuildReceipts { [HarmonyPatch(typeof(Player), "PlacePiece")] private static class Placement { private static void Prefix(Player __instance, Piece piece) { selected = piece; placed = null; frame = Time.frameCount; placing = (Object)(object)__instance == (Object)(object)Player.m_localPlayer && Catalogue.ByToken.ContainsKey(piece.m_name); } private static void Finalizer() { placing = false; } } [HarmonyPatch(typeof(Piece), "SetCreator")] private static class NewBuild { private static void Prefix(Piece __instance, out bool __state) { __state = Catalogue.ByToken.ContainsKey(__instance.m_name) && __instance.GetCreator() == 0; } private static void Postfix(Piece __instance, bool __state, ZNetView ___m_nview) { if (__state && Catalogue.ByToken.ContainsKey(__instance.m_name) && Object.op_Implicit((Object)(object)___m_nview) && ___m_nview.IsOwner() && __instance.IsPlacedByPlayer()) { ZDO zDO = ___m_nview.GetZDO(); zDO.Set("zfwc_materials_paid", "-"); if (placing && Object.op_Implicit((Object)(object)selected) && selected.m_name == __instance.m_name && frame == Time.frameCount) { placed = zDO; } } } } [HarmonyPatch(typeof(Player), "ConsumeResources")] private static class Payment { [HarmonyPriority(800)] private static void Prefix(Player __instance, Requirement[] requirements, out int[] __state) { __state = null; if (placed != null && Object.op_Implicit((Object)(object)selected) && frame == Time.frameCount && requirements == selected.m_resources && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { Inventory inv = ((Humanoid)__instance).GetInventory(); __state = requirements.Select((Requirement r) => inv.CountItems(r.m_resItem.m_itemData.m_shared.m_name, -1, true)).ToArray(); } } private static void Postfix(Player __instance, Requirement[] requirements, int[] __state) { if (__state == null || placed == null) { return; } Inventory inventory = ((Humanoid)__instance).GetInventory(); List<string> list = new List<string>(); for (int i = 0; i < requirements.Length; i++) { ItemDrop resItem = requirements[i].m_resItem; int num = __state[i] - inventory.CountItems(resItem.m_itemData.m_shared.m_name, -1, true); if (num > 0) { list.Add(((Object)resItem).name + ":" + num); } } placed.Set("zfwc_materials_paid", (list.Count > 0) ? string.Join(",", list) : "-"); placed = null; } } [HarmonyPatch(typeof(Piece), "DropResources")] private static class Refund { private static bool Prefix(Piece __instance, ZNetView ___m_nview) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) if (!Catalogue.ByToken.TryGetValue(__instance.m_name, out var value) || !__instance.IsPlacedByPlayer()) { return true; } if (!Object.op_Implicit((Object)(object)___m_nview) || !___m_nview.IsOwner()) { return false; } ZDO zDO = ___m_nview.GetZDO(); string value2 = zDO.GetString("zfwc_materials_paid", ""); if (value2.Length == 0) { if (zDO.GetBool("zfwc_free_placement", false)) { return false; } if (!historical.TryGetValue(value.Id, out value2)) { value2 = string.Join(",", value.Cost.Select((KeyValuePair<string, int> c) => c.Key + ":" + c.Value)); } } if (value2 == "-") { return false; } Vector3 val = ((Component)__instance).transform.position + Vector3.up * Mathf.Max(0.6f, __instance.m_returnResourceHeightOffset); val.y = Mathf.Max(val.y, ZoneSystem.instance.GetGroundHeight(val) + 0.35f); string[] array = value2.Split(new char[1] { ',' }); for (int num = 0; num < array.Length; num++) { string[] array2 = array[num].Split(new char[1] { ':' }); ItemDrop component = ObjectDB.instance.GetItemPrefab(array2[0]).GetComponent<ItemDrop>(); int num2 = int.Parse(array2[1]); while (num2 > 0) { ItemData val2 = component.m_itemData.Clone(); val2.m_dropPrefab = ((Component)component).gameObject; val2.m_stack = Mathf.Min(num2, val2.m_shared.m_maxStackSize); val2.m_cheated = Cheated(zDO) && !PlayerProfile.s_bypassCheatChecks; ItemDrop.DropItem(val2, 0, val, Quaternion.identity); num2 -= val2.m_stack; } } zDO.Set("zfwc_materials_paid", "-"); return false; } } internal const string Key = "zfwc_materials_paid"; private const string Empty = "-"; private static readonly Dictionary<string, string> historical = ReadHistorical(); private static readonly Func<ZDO, bool> Cheated = AccessTools.MethodDelegate<Func<ZDO, bool>>(AccessTools.Method(AccessTools.TypeByName("CheatUtils"), "IsCheated", new Type[1] { typeof(ZDO) }, (Type[])null), (object)null, true); private static Piece selected; private static ZDO placed; private static int frame; private static bool placing; private static Dictionary<string, string> ReadHistorical() { using Stream stream = typeof(BuildReceipts).Assembly.GetManifestResourceStream("Worldcraft.LegacyCosts"); using StreamReader streamReader = new StreamReader(stream); Dictionary<string, string> dictionary = new Dictionary<string, string>(); string text; while ((text = streamReader.ReadLine()) != null) { string[] array = text.Split(new char[1] { '\t' }); dictionary.Add(array[0], array[1]); } return dictionary; } } internal sealed class Design { internal string Id; internal string Child; internal string Family; internal string Gate; internal string Station; internal string English; internal string French; internal string Source; internal string NativeExtensionName; internal AssetID Asset; internal UsageTagFlags Tags; internal KeyValuePair<string, int>[] Cost; internal string PrefabName => "ZFWC_" + Id; internal string Token => "zfwc_" + Id; internal static IEnumerable<Design> Read() { using Stream stream = typeof(Design).Assembly.GetManifestResourceStream("Worldcraft.Catalogue"); using StreamReader reader = new StreamReader(stream); reader.ReadLine(); string text; AssetID asset = default(AssetID); while ((text = reader.ReadLine()) != null) { string[] array = text.Split(new char[1] { '\t' }); if (array.Length != 11 || !AssetID.TryParse(array[1], ref asset)) { throw new InvalidDataException(text); } yield return new Design { Id = array[0], Asset = asset, Child = array[2], Family = array[3], Gate = array[4], Tags = (UsageTagFlags)Enum.Parse(typeof(UsageTagFlags), array[5]), Cost = array[6].Split(new char[1] { ',' }).Select(CostEntry).ToArray(), Station = array[7], English = array[8], French = array[9], Source = Path.GetFileNameWithoutExtension(array[10]) }; } } private static KeyValuePair<string, int> CostEntry(string field) { string[] array = field.Split(new char[1] { ':' }); return new KeyValuePair<string, int>(array[0], int.Parse(array[1], CultureInfo.InvariantCulture)); } } internal static class Catalogue { internal static readonly Dictionary<Piece, Design> Pieces = new Dictionary<Piece, Design>(); internal static readonly Dictionary<string, Design> ByToken = new Dictionary<string, Design>(StringComparer.Ordinal); internal static readonly HashSet<Requirement[]> Costs = new HashSet<Requirement[]>(); internal static readonly List<Piece> Entries = new List<Piece>(); internal static PieceTable Hammer; private static readonly Dictionary<string, GameObject> named = new Dictionary<string, GameObject>(StringComparer.Ordinal); private static readonly Dictionary<AssetID, GameObject> models = new Dictionary<AssetID, GameObject>(); private static bool built; internal static GameObject Named(string name) { if (named.TryGetValue(name, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } GameObject val = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab(name) : null); if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)ZNetScene.instance)) { val = ZNetScene.instance.GetPrefab(name); } if (!Object.op_Implicit((Object)(object)val)) { val = PrefabManager.Instance.GetPrefab(name); } if (Object.op_Implicit((Object)(object)val)) { named[name] = val; } return val; } internal static GameObject Source(Design design) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!models.TryGetValue(design.Asset, out var value)) { SoftReference<GameObject> val = default(SoftReference<GameObject>); val..ctor(design.Asset); val.Load(); value = val.Asset; if (!Object.op_Implicit((Object)(object)value)) { value = Named(design.Source); } if (!Object.op_Implicit((Object)(object)value)) { throw new InvalidDataException("Missing source " + design.Source); } models.Add(design.Asset, value); } if (design.Child.Length == 0) { return value; } Transform val2 = value.transform.Find(design.Child); if (!Object.op_Implicit((Object)(object)val2)) { throw new InvalidDataException("Missing child " + design.Child); } return ((Component)val2).gameObject; } internal static void Register(ZNetScene scene) { GameObject obj = Named("Hammer"); ItemDrop val = ((obj != null) ? obj.GetComponent<ItemDrop>() : null); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.m_itemData.m_shared.m_buildPieces)) { throw new InvalidOperationException("Hammer table unavailable"); } Hammer = val.m_itemData.m_shared.m_buildPieces; if (!built) { int num = 0; foreach (Design item in Design.Read()) { GameObject val2 = null; try { GameObject source = Source(item); Requirement[] array = ((IEnumerable<KeyValuePair<string, int>>)item.Cost).Select((Func<KeyValuePair<string, int>, Requirement>)delegate(KeyValuePair<string, int> entry) { //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown Requirement val3 = new Requirement(); GameObject obj3 = Named(entry.Key); val3.m_resItem = ((obj3 != null) ? obj3.GetComponent<ItemDrop>() : null) ?? throw new InvalidDataException(entry.Key); val3.m_amount = entry.Value; val3.m_amountPerLevel = 0; val3.m_recover = true; return val3; }).ToArray(); GameObject obj2 = Named(item.Station); CraftingStation station = ((obj2 != null) ? obj2.GetComponent<CraftingStation>() : null) ?? throw new InvalidDataException(item.Station); val2 = Replica.Create(item, source, array, station); Piece component = val2.GetComponent<Piece>(); Pieces.Add(component, item); Entries.Add(component); ByToken.Add(component.m_name, item); Costs.Add(array); } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val2)) { Object.Destroy((Object)(object)val2); } num++; WorldcraftPlugin.Log.LogWarning((object)("Skipped " + item.Id + ": " + ex.Message)); } } built = true; WorldcraftPlugin.Log.LogInfo((object)$"Catalogue: {Entries.Count} recipes, {num} unavailable."); } HashSet<int> hashSet = new HashSet<int>(from o in scene.m_prefabs.Concat(scene.m_nonNetViewPrefabs) where Object.op_Implicit((Object)(object)o) select StringExtensionMethods.GetStableHashCode(((Object)o).name)); foreach (Piece entry in Entries) { GameObject gameObject = ((Component)entry).gameObject; if (hashSet.Add(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name))) { scene.m_prefabs.Add(gameObject); } if (!Hammer.m_pieces.Contains(gameObject)) { Hammer.m_pieces.Add(gameObject); } } } } internal static class FixtureBuilder { internal static Transform Child(Transform parent, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject(name).transform; transform.SetParent(parent, false); ((Component)transform).gameObject.layer = ((Component)parent).gameObject.layer; return transform; } internal static Bounds ModelBounds(Transform local) { //IL_0002: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) Bounds result = default(Bounds); bool flag = false; MeshFilter[] componentsInChildren = ((Component)local).GetComponentsInChildren<MeshFilter>(true); Vector3 val2 = default(Vector3); foreach (MeshFilter val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val.sharedMesh)) { continue; } Bounds bounds = val.sharedMesh.bounds; for (int j = 0; j < 8; j++) { ((Vector3)(ref val2))..ctor((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1))); Vector3 val3 = local.InverseTransformPoint(((Component)val).transform.TransformPoint(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, val2))); if (flag) { ((Bounds)(ref result)).Encapsulate(val3); continue; } ((Bounds)(ref result))..ctor(val3, Vector3.zero); flag = true; } } return result; } private static string ModelName(Transform t) { return ((Object)t).name.Split(new char[1] { '(' })[0].TrimEnd(Array.Empty<char>()).ToLowerInvariant(); } private static bool SeatName(string n) { if (!n.Contains("workbench")) { if (!n.Contains("bench") && !n.Contains("divan") && !n.Contains("chair")) { return n.Contains("stool"); } return true; } return false; } private static bool FireName(string n) { if (!n.Contains("brazier") && !n.Contains("fire_pit") && !n.Contains("firepit") && !n.Contains("groundtorch") && !n.Contains("railing_torch")) { switch (n) { default: return n == "prop_hearth"; case "bonfire": case "prop_bonfire": case "hearth": break; } } return true; } private static bool IsBed(string n) { switch (n) { default: return n == "morkhalla_bedroll2"; case "bed": case "bed02": case "dvergrprops_bed": case "goblin_bed": case "prop_ashwood_bed": case "prop_bed02": case "morkhalla_bedroll1": return true; } } internal static void Install(GameObject root, GameObject source, Transform visual, Dictionary<Transform, Transform> copies, Design design, Piece piece) { //IL_029b: Unknown result type (might be due to invalid IL or missing references) int fixture = 0; Transform[] componentsInChildren = source.GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!copies.TryGetValue(val, out var value)) { continue; } string text = ModelName(val); bool flag = (Object)(object)val == (Object)(object)source.transform; if (IsBed(text) || Object.op_Implicit((Object)(object)((Component)val).GetComponent<Bed>())) { Beds(val, value, text, piece, ref fixture); } else if (((flag || Object.op_Implicit((Object)(object)((Component)val).GetComponent<ZNetView>())) && FireName(text)) || (Object.op_Implicit((Object)(object)((Component)val).GetComponent<Fireplace>()) && (flag || (!text.Contains("torch") && !text.Contains("candle"))))) { if (design.Id != "piece_walltorch") { Fire(val, value, text, ++fixture, piece); } } else if (text == "prop_piece_cookingstation" || (Object.op_Implicit((Object)(object)((Component)val).GetComponent<CookingStation>()) && !Object.op_Implicit((Object)(object)root.GetComponent<CookingStation>()))) { Grill(root, value, piece, visual); } else if (text == "prop_tankard" || text == "tankard") { Route(value, (MonoBehaviour)(object)((Component)Child(value, "Drink")).gameObject.AddComponent<WorldTankard>()); } else if (!flag && Object.op_Implicit((Object)(object)((Component)val).GetComponent<Door>())) { ReplicaDoor replicaDoor = ((Component)Child(value, "Door control")).gameObject.AddComponent<ReplicaDoor>(); replicaDoor.Configure(value, text); fixture = (replicaDoor.Slot = fixture + 1); Route(value, (MonoBehaviour)(object)replicaDoor); } if (!flag && ((design.Family == "fuling" && Object.op_Implicit((Object)(object)((Component)val).GetComponent<Container>())) || (design.Id.StartsWith("hildir_camp_chest", StringComparison.Ordinal) && text == "hildir_chest" + design.Id.Last()))) { EmbeddedChest(root, value, "piece_chest_wood"); } if (flag && (design.Id == "dvergrprops_barrel" || design.Id.EndsWith("_dvergrprops_barrel", StringComparison.Ordinal))) { Brewing(root, value, piece); } } Seats(source.transform, visual, copies, design, piece); if (design.Id == "hildir_wagon") { Wagon(root, visual, ref fixture); } if (design.Id == "hildir_maptable") { WorldLandmarks.Cartography(root, visual, piece); } if (((Enum)design.Tags).HasFlag((Enum)(object)(UsageTagFlags)2048)) { WorldLandmarks.Portal(root, visual, design.Id); } if (design.Id.StartsWith("runestone_", StringComparison.Ordinal)) { WorldLandmarks.Runestone(source, visual, copies); } BossStone source2 = default(BossStone); if (source.TryGetComponent<BossStone>(ref source2) && design.Id.StartsWith("bossstone_", StringComparison.Ordinal)) { MemorialDisplay.Build(root, visual, copies, source2, piece); } } internal static FixturePort Route(Transform target, MonoBehaviour action, bool always = false) { FixturePort fixturePort = ((Component)target).GetComponent<FixturePort>() ?? ((Component)target).gameObject.AddComponent<FixturePort>(); fixturePort.Choices = (MonoBehaviour[])(object)new MonoBehaviour[1] { action }; fixturePort.Always = always; return fixturePort; } internal static Container Storage(GameObject host, string native, string label) { Container component = Catalogue.Named(native).GetComponent<Container>(); Container obj = host.AddComponent<Container>(); obj.m_name = label; obj.m_checkGuardStone = true; obj.m_width = component.m_width; obj.m_height = component.m_height; obj.m_bkg = component.m_bkg; obj.m_destroyedLootPrefab = component.m_destroyedLootPrefab; return obj; } private static void EmbeddedChest(GameObject root, Transform target, string native) { Container component = Catalogue.Named(native).GetComponent<Container>(); Container val = Storage(((Component)Child(target, "Inventory")).gameObject, native, component.m_name); val.m_rootObjectOverride = root.GetComponent<ZNetView>(); Route(target, (MonoBehaviour)(object)val); } private static void Wagon(GameObject root, Transform visual, ref int fixture) { //IL_001b: 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_0075: 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_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) Transform obj = Child(visual, "Roof over the sleeping compartment"); obj.localPosition = new Vector3(0f, 3.75f, 0.7f); BoxCollider val = ((Component)obj).gameObject.AddComponent<BoxCollider>(); val.size = new Vector3(2.65f, 0.12f, 2.35f); ((Component)obj).gameObject.tag = "roof"; Transform obj2 = Child(visual, "Sleeping compartment floor"); obj2.localPosition = new Vector3(0f, 1.05f, 0.7f); ((Component)obj2).gameObject.AddComponent<BoxCollider>().size = new Vector3(2.65f, 0.15f, 2.35f); for (int i = 0; i < 2; i++) { Transform val2 = Child(visual, "Wagon berth " + (i + 1)); val2.localPosition = new Vector3((i == 0) ? (-0.49f) : 0.49f, 1.42f, 0.72f); WorldBerth worldBerth = ((Component)val2).gameObject.AddComponent<WorldBerth>(); worldBerth.Slot = ++fixture; worldBerth.Roof = (Collider)(object)val; worldBerth.Exit = Child(visual, "Side step " + (i + 1)); worldBerth.Exit.localPosition = new Vector3(-2.42f, 1.55f, (i == 0) ? 0.54f : 1.31f); Bed val3 = ((Component)val2).gameObject.AddComponent<Bed>(); val3.m_spawnPoint = val2; Transform obj3 = Child(visual, "Bed at the door " + (i + 1)); obj3.localPosition = new Vector3(-1.7f, 2.15f, (i == 0) ? 0.53f : 1.28f); ((Component)obj3).gameObject.layer = LayerMask.NameToLayer("piece_nonsolid"); BoxCollider obj4 = ((Component)obj3).gameObject.AddComponent<BoxCollider>(); ((Collider)obj4).isTrigger = true; obj4.size = new Vector3(0.28f, 1.5f, 0.73f); Route(obj3, (MonoBehaviour)(object)val3); } Transform val4 = Child(visual, "Front wardrobe"); val4.localPosition = new Vector3(0f, 2.12f, -3.78f); val4.localRotation = Quaternion.Euler(-17f, 0f, 0f); ((Component)val4).gameObject.layer = LayerMask.NameToLayer("piece_nonsolid"); BoxCollider obj5 = ((Component)val4).gameObject.AddComponent<BoxCollider>(); ((Collider)obj5).isTrigger = true; obj5.size = new Vector3(1.62f, 1.02f, 0.14f); EmbeddedChest(root, val4, "piece_chest_warderobe"); } private static void Beds(Transform src, Transform dst, string n, Piece piece, ref int fixture) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: 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_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) Bounds val = ModelBounds(dst); Bed component = ((Component)src).GetComponent<Bed>(); GameObject obj = Catalogue.Named((n == "prop_bed02") ? "bed02" : ((n == "prop_ashwood_bed") ? "ashwood_bed" : "bed")); Bed val2 = ((obj != null) ? obj.GetComponent<Bed>() : null); Transform val3 = (Object.op_Implicit((Object)(object)component) ? component.m_spawnPoint : (Object.op_Implicit((Object)(object)val2) ? val2.m_spawnPoint : null)); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(((Bounds)(ref val)).center.x, ((Bounds)(ref val)).min.y + Mathf.Min(((Bounds)(ref val)).size.y * 0.6f, 0.55f), ((Bounds)(ref val)).center.z); Quaternion val5 = Quaternion.identity; if (Object.op_Implicit((Object)(object)val3)) { Transform val6 = (Object.op_Implicit((Object)(object)component) ? src : ((Component)val2).transform); if (Object.op_Implicit((Object)(object)component) || n == "prop_bed02" || n == "prop_ashwood_bed") { val4 = val6.InverseTransformPoint(val3.position); } val5 = Quaternion.Inverse(val6.rotation) * val3.rotation; } bool flag = ((Bounds)(ref val)).size.x > ((Bounds)(ref val)).size.z; if (!Object.op_Implicit((Object)(object)component) && flag) { val5 = Quaternion.Euler(0f, 90f, 0f) * val5; } int num; switch (n) { default: num = 1; break; case "prop_bed02": case "prop_ashwood_bed": case "morkhalla_bedroll1": num = 2; break; } int num2 = num; List<MonoBehaviour> list = new List<MonoBehaviour>(); for (int i = 0; i < num2; i++) { Transform val7 = Child(dst, "Berth " + (i + 1)); Vector3 val8 = (flag ? Vector3.forward : Vector3.right); float num3 = (flag ? ((Bounds)(ref val)).size.z : ((Bounds)(ref val)).size.x); val7.localPosition = val4 + val8 * ((num2 == 1) ? 0f : (((i == 0) ? (-0.25f) : 0.25f) * num3)); val7.localRotation = val5; ((Component)val7).gameObject.AddComponent<WorldBerth>().Slot = ++fixture; Bed val9 = ((Component)val7).gameObject.AddComponent<Bed>(); val9.m_spawnPoint = val7; list.Add((MonoBehaviour)(object)val9); } Route(dst, list[0]).Choices = list.ToArray(); if ((Object)(object)dst.parent == (Object)(object)((Component)piece).transform) { piece.m_comfortGroup = (ComfortGroup)2; piece.m_comfort = num2; } } private static void Seats(Transform source, Transform visual, Dictionary<Transform, Transform> copies, Design design, Piece piece) { //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_06ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: 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_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05cc: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) Dictionary<Transform, List<MonoBehaviour>> groups = new Dictionary<Transform, List<MonoBehaviour>>(); Dictionary<Transform, Transform> dictionary = new Dictionary<Transform, Transform>(); Chair[] componentsInChildren = ((Component)source).GetComponentsInChildren<Chair>(true); bool topSeat = SeatName(design.Id); foreach (Transform key in copies.Keys) { string text = ModelName(key); if ((!((Object)(object)key != (Object)(object)source) || Object.op_Implicit((Object)(object)((Component)key).GetComponent<ZNetView>()) || Object.op_Implicit((Object)(object)((Component)key).GetComponent<Chair>())) && (SeatName(text) || ((Object)(object)key == (Object)(object)source && topSeat) || (design.Family == "fuling" && text == "wood_wall_log"))) { dictionary[key] = copies[key]; } } Chair[] array = componentsInChildren; foreach (Chair val in array) { if (!Object.op_Implicit((Object)(object)val.m_attachPoint)) { continue; } Transform transform = ((Component)val).transform; Transform val2 = transform; while (!copies.ContainsKey(val2) && (Object)(object)val2 != (Object)(object)source) { val2 = val2.parent; } if ((Object)(object)val2 != (Object)(object)transform && !ModelName(transform).StartsWith("sitpoint", StringComparison.Ordinal)) { continue; } Transform val3 = val2; while ((Object)(object)val3 != (Object)(object)source && !dictionary.ContainsKey(val3)) { val3 = val3.parent; } int num; Transform obj; if ((Object)(object)val3 == (Object)(object)source && !topSeat) { num = ((!dictionary.ContainsKey(source)) ? 1 : 0); if (num != 0) { obj = copies[val2]; goto IL_01be; } } else { num = 0; } obj = copies[val3]; goto IL_01be; IL_01be: Transform val4 = obj; Vector3 position = copies[val2].TransformPoint(val2.InverseTransformPoint(val.m_attachPoint.position)); Quaternion rotation = copies[val2].rotation * Quaternion.Inverse(val2.rotation) * val.m_attachPoint.rotation; if (num != 0 && ((Object)(object)val2 != (Object)(object)transform || (Object)(object)val4 == (Object)(object)visual)) { val4 = Child(val4, "Built-in seat"); val4.position = position; ((Component)val4).gameObject.AddComponent<BoxCollider>().size = new Vector3(0.65f, 0.28f, 0.65f); } Add(val4, position, rotation, val); } Vector3 val6 = default(Vector3); Vector3 val8 = default(Vector3); foreach (Transform value2 in dictionary.Values) { Bounds val5 = ModelBounds(value2); if (design.Id.StartsWith("hildir_divan", StringComparison.Ordinal)) { ((Vector3)(ref val6))..ctor(-0.36f, 0.52f, ((Bounds)(ref val5)).center.z); Quaternion rotation2 = value2.rotation * Quaternion.Euler(0f, 270f, 0f); if (!groups.ContainsKey(value2)) { GameObject obj2 = Catalogue.Named("hildir_divan1"); Chair val7 = ((obj2 != null) ? obj2.GetComponent<Chair>() : null); if (!Object.op_Implicit((Object)(object)val7)) { val7 = Catalogue.Source(Design.Read().First((Design d) => d.Id == "hildir_divan1")).GetComponent<Chair>(); } Add(value2, value2.TransformPoint(new Vector3(-0.36f, 0.5f, 0.16f)), rotation2, val7); } Add(value2, value2.TransformPoint(val6 - Vector3.forward * 0.65f), rotation2, null, sittingSurface: true); } else if (design.Id == "morkhalla_bench" && (Object)(object)value2 == (Object)(object)visual) { float[] array2 = new float[4] { 0.98f, 0.97f, 0.98f, 0.99f }; for (int num2 = 0; num2 < array2.Length; num2++) { Add(value2, value2.TransformPoint(new Vector3(((float)num2 - 1.5f) * 0.83f, array2[num2], 0.005f)), value2.rotation, null, sittingSurface: true); } } else if (!groups.ContainsKey(value2)) { bool num3 = ModelName(value2) == "wood_wall_log"; bool flag = num3 || ModelName(value2).Contains("bench") || ((Object)(object)value2 == (Object)(object)visual && design.Id.Contains("bench")); bool flag2 = ((Bounds)(ref val5)).size.x >= ((Bounds)(ref val5)).size.z; ((Vector3)(ref val8))..ctor(((Bounds)(ref val5)).center.x, ((Bounds)(ref val5)).min.y + Mathf.Min(((Bounds)(ref val5)).size.y * 0.82f, 0.62f), ((Bounds)(ref val5)).center.z); if (design.Id.Contains("dvergrprops_chair")) { ((Vector3)(ref val8))..ctor(0f, 0.375f, 0.015f); } if (design.Id.Contains("dvergrprops_stool")) { ((Vector3)(ref val8))..ctor(0f, 0.42f, -0.05f); } if (num3) { ((Vector3)(ref val8))..ctor(0f, 0.25f, 0f); } int num4 = ((!flag) ? 1 : Mathf.Clamp(Mathf.RoundToInt(Mathf.Max(((Bounds)(ref val5)).size.x, ((Bounds)(ref val5)).size.z) / 0.9f), 1, 4)); for (int num5 = 0; num5 < num4; num5++) { Add(value2, value2.TransformPoint(val8 + (flag2 ? Vector3.right : Vector3.forward) * (((float)num5 - (float)(num4 - 1) * 0.5f) * 0.83f)), value2.rotation * Quaternion.Euler(0f, (float)((flag && !flag2) ? 270 : 0), 0f), null, sittingSurface: true); } } } foreach (KeyValuePair<Transform, List<MonoBehaviour>> item in groups) { Route(item.Key, item.Value[0], topSeat).Choices = item.Value.ToArray(); } if (topSeat) { piece.m_comfort = 1; piece.m_comfortGroup = (ComfortGroup)4; } void Add(Transform hub, Vector3 val10, Quaternion val12, Chair template, bool sittingSurface = false) { //IL_000d: 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_0023: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) Transform val9 = Child(hub, "Sitting position"); val9.position = val10 - (sittingSurface ? (Vector3.up * 0.5f) : Vector3.zero); Vector3 val11 = Vector3.ProjectOnPlane(val12 * Vector3.forward, Vector3.up); val9.rotation = ((((Vector3)(ref val11)).sqrMagnitude > 0.001f) ? Quaternion.LookRotation(val11) : val12); Chair val13 = ((Component)val9).gameObject.AddComponent<Chair>(); val13.m_attachPoint = val9; val13.m_name = piece.m_name; if (Object.op_Implicit((Object)(object)template)) { val13.m_attachAnimation = template.m_attachAnimation; val13.m_detachOffset = template.m_detachOffset; } if (design.Id.StartsWith("hildir_divan", StringComparison.Ordinal)) { val13.m_name = piece.m_name + " · " + ((val13.m_attachAnimation == "attach_chair") ? "$wc_sit" : "$wc_recline"); } Transform val14 = Child(val9, "Seat target"); Vector3 lossyScale = val14.lossyScale; val14.localScale = new Vector3(1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.x)), 1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.y)), 1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.z))); BoxCollider val15 = ((Component)val14).gameObject.AddComponent<BoxCollider>(); val14.position = val10; BoxCollider val16 = default(BoxCollider); if (Object.op_Implicit((Object)(object)template) && ModelName(hub).StartsWith("sitpoint", StringComparison.Ordinal) && ((Component)hub).TryGetComponent<BoxCollider>(ref val16)) { val14.position = hub.TransformPoint(val16.center); } val15.center = new Vector3(0f, 0.035f, 0f); val15.size = new Vector3(0.5f, 0.12f, 0.44f); Route(val14, (MonoBehaviour)(object)val13, topSeat); if (!groups.TryGetValue(hub, out var value)) { value = (groups[hub] = new List<MonoBehaviour>()); } value.Add((MonoBehaviour)(object)val13); } } private static void Fire(Transform src, Transform dst, string n, int slot, Piece piece) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) WorldFire worldFire = ((Component)Child(dst, "Fuel and fire")).gameObject.AddComponent<WorldFire>(); worldFire.Slot = slot; worldFire.LegacyLights = ((Component)dst).GetComponentsInChildren<Light>(true); Bounds val = ModelBounds(dst); EffectArea val2 = ((IEnumerable<EffectArea>)((Component)src).GetComponentsInChildren<EffectArea>(true)).FirstOrDefault((Func<EffectArea, bool>)((EffectArea a) => (a.m_type & 1) > 0)); ((Component)worldFire).transform.localPosition = (Vector3)(Object.op_Implicit((Object)(object)val2) ? src.InverseTransformPoint(((Component)val2).transform.position) : new Vector3(((Bounds)(ref val)).center.x, ((Bounds)(ref val)).max.y - (n.Contains("brazier") ? 0.04f : 0f), ((Bounds)(ref val)).center.z)); GameObject obj = Catalogue.Named((n.Contains("torch") || n.Contains("brazier")) ? "piece_brazierfloor01" : "fire_pit"); Fireplace val3 = ((obj != null) ? obj.GetComponent<Fireplace>() : null); if (!Object.op_Implicit((Object)(object)val3)) { val3 = Catalogue.Named("fire_pit").GetComponent<Fireplace>(); } worldFire.Fuel = val3.m_fuelItem; worldFire.SecondsPerFuel = Mathf.Max(1f, val3.m_secPerFuel); worldFire.MaxFuel = Mathf.Max(1, Mathf.RoundToInt(val3.m_maxFuel)); Transform burning = Child(((Component)worldFire).transform, "Burning"); worldFire.Burning = ((Component)burning).gameObject; ((Component)burning).gameObject.SetActive(false); object obj2 = Flame(src); if (obj2 == null) { obj2 = Flame(((Component)val3).transform); if (obj2 == null) { ParticleSystem componentInChildren = ((Component)val3).GetComponentInChildren<ParticleSystem>(true); obj2 = ((componentInChildren != null) ? ((Component)componentInChildren).transform : null); } } Transform val4 = (Transform)obj2; if (Object.op_Implicit((Object)(object)val4)) { GameObject obj3 = Object.Instantiate<GameObject>(((Component)val4).gameObject, burning, false); ((Object)obj3).name = "Flame"; obj3.transform.localPosition = Vector3.zero; obj3.SetActive(true); } Light obj4 = ((Component)Child(burning, "Firelight")).gameObject.AddComponent<Light>(); obj4.type = (LightType)2; obj4.range = 9f; obj4.intensity = 1.8f; ((Component)obj4).transform.localPosition = Vector3.up * 0.35f; obj4.color = (Color)((worldFire.LegacyLights.Length != 0) ? worldFire.LegacyLights[0].color : new Color(1f, 0.59f, 0.25f)); Area("Warmth", (Type)1, 4f); Area("Cooking fire", (Type)10, 0.68f); Route(dst, (MonoBehaviour)(object)worldFire); void Area(string name, Type type, float radius) { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_00a6: 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) Transform obj5 = Child(burning, name); Vector3 lossyScale = obj5.lossyScale; obj5.localScale = new Vector3(1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.x)), 1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.y)), 1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.z))); ((Component)obj5).gameObject.layer = LayerMask.NameToLayer("character_trigger"); SphereCollider obj6 = ((Component)obj5).gameObject.AddComponent<SphereCollider>(); ((Collider)obj6).isTrigger = true; obj6.radius = radius; ((Component)obj5).gameObject.AddComponent<EffectArea>().m_type = type; } static Transform Flame(Transform t) { return (from p in ((Component)t).GetComponentsInChildren<ParticleSystem>(true) where ((Object)p).name.IndexOf("flame", StringComparison.OrdinalIgnoreCase) >= 0 orderby ((Component)p).gameObject.activeSelf descending select ((Component)p).transform).FirstOrDefault(); } } private static void Grill(GameObject root, Transform dst, Piece piece, Transform visual) { CookingStation template = Catalogue.Named("piece_cookingstation").GetComponent<CookingStation>(); CookingStation val = root.AddComponent<CookingStation>(); val.m_name = template.m_name; val.m_conversion = template.m_conversion; val.m_incompatibleItems = template.m_incompatibleItems; val.m_overCookedItem = template.m_overCookedItem; val.m_addEffect = template.m_addEffect; val.m_doneEffect = template.m_doneEffect; val.m_overcookedEffect = template.m_overcookedEffect; val.m_pickEffector = template.m_pickEffector; val.m_moveObjectParameters = template.m_moveObjectParameters; val.m_slots = template.m_slots.Select(Clone).ToArray(); val.m_donePS = template.m_donePS.Select((ParticleSystem p) => ((Component)Clone(((Component)p).transform)).GetComponent<ParticleSystem>()).ToArray(); val.m_burntPS = template.m_burntPS.Select((ParticleSystem p) => ((Component)Clone(((Component)p).transform)).GetComponent<ParticleSystem>()).ToArray(); val.m_fireCheckPoints = template.m_fireCheckPoints.Select(Clone).ToArray(); if (Object.op_Implicit((Object)(object)template.m_spawnPoint)) { val.m_spawnPoint = Clone(template.m_spawnPoint); } val.m_requireFire = template.m_requireFire; val.m_fireCheckRadius = template.m_fireCheckRadius; if ((Object)(object)dst != (Object)(object)visual && !Object.op_Implicit((Object)(object)((Component)visual).GetComponent<FixturePort>())) { ((Component)visual).gameObject.AddComponent<FixturePort>(); } Route(dst, (MonoBehaviour)(object)val); Transform Clone(Transform part) { //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_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Transform obj = Object.Instantiate<Transform>(part, dst, false); obj.localPosition = ((Component)template).transform.InverseTransformPoint(part.position); obj.localRotation = Quaternion.Inverse(((Component)template).transform.rotation) * part.rotation; ((Component)obj).gameObject.SetActive(true); return obj; } } private static void Brewing(GameObject root, Transform dst, Piece piece) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_013a: Unknown result type (might be due to invalid IL or missing references) Fermenter component = Catalogue.Named("fermenter").GetComponent<Fermenter>(); Fermenter val = root.AddComponent<Fermenter>(); val.m_name = piece.m_name; val.m_conversion = component.m_conversion; val.m_fermentationDuration = component.m_fermentationDuration / 1.2f; val.m_addedEffects = component.m_addedEffects; val.m_tapEffects = component.m_tapEffects; val.m_spawnEffects = component.m_spawnEffects; val.m_fermentingObject = ((Component)Child(dst, "Fermenting")).gameObject; val.m_readyObject = ((Component)Child(dst, "Ready")).gameObject; val.m_topObject = ((Component)Child(dst, "Lid state")).gameObject; Bounds val2 = ModelBounds(dst); val.m_roofCheckPoint = Child(dst, "Cover check"); val.m_roofCheckPoint.localPosition = new Vector3(((Bounds)(ref val2)).center.x, ((Bounds)(ref val2)).max.y + 0.08f, ((Bounds)(ref val2)).center.z); val.m_outputPoint = Child(dst, "Tap"); val.m_outputPoint.localPosition = new Vector3(((Bounds)(ref val2)).center.x, ((Bounds)(ref val2)).center.y, ((Bounds)(ref val2)).max.z + 0.27f); Route(dst, (MonoBehaviour)(object)val).LegacyCask = root.AddComponent<CaskContents>(); } } public sealed class FixturePort : MonoBehaviour, Interactable, Hoverable { [SerializeField] internal MonoBehaviour[] Choices = Array.Empty<MonoBehaviour>(); [SerializeField] internal CaskContents LegacyCask; [SerializeField] internal bool Always; private MonoBehaviour Target() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (!Always && !WorldcraftPlugin.FunctionalProps.Value) { return null; } if (Choices.Length <= 1) { if (Choices.Length != 0) { return Choices[0]; } return null; } GameCamera instance = GameCamera.instance; if (!Object.op_Implicit((Object)(object)instance)) { return Choices[0]; } Vector3 position = ((Component)instance).transform.position; Vector3 forward = ((Component)instance).transform.forward; MonoBehaviour result = Choices[0]; float num = float.PositiveInfinity; MonoBehaviour[] choices = Choices; foreach (MonoBehaviour val in choices) { Vector3 val2 = ((Component)val).transform.position - position; Vector3 val3 = val2 - forward * Mathf.Max(0f, Vector3.Dot(val2, forward)); float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val; } } return result; } public bool Interact(Humanoid user, bool hold, bool alt) { if (!hold && alt && Object.op_Implicit((Object)(object)LegacyCask) && LegacyCask.HasLegacyItems) { return LegacyCask.Recover(); } MonoBehaviour obj = Target(); Interactable val = (Interactable)(object)((obj is Interactable) ? obj : null); if (val != null) { return val.Interact(user, hold, alt); } return false; } public bool UseItem(Humanoid user, ItemData item) { MonoBehaviour obj = Target(); MonoBehaviour obj2 = ((obj is Interactable) ? obj : null); if (obj2 == null) { return false; } return ((Interactable)obj2).UseItem(user, item); } public string GetHoverName() { MonoBehaviour obj = Target(); MonoBehaviour obj2 = ((obj is Hoverable) ? obj : null); return ((obj2 != null) ? ((Hoverable)obj2).GetHoverName() : null) ?? ""; } public string GetHoverText() { MonoBehaviour obj = Target(); MonoBehaviour obj2 = ((obj is Hoverable) ? obj : null); string text = ((obj2 != null) ? ((Hoverable)obj2).GetHoverText() : null) ?? ""; if (!Object.op_Implicit((Object)(object)LegacyCask) || !LegacyCask.HasLegacyItems) { return text; } return text + "\n" + Words.Local("[<color=yellow><b>$KEY_AltPlace + $KEY_Use</b></color>] $wc_cask_recover"); } public float GetHoverOffset() { MonoBehaviour obj = Target(); MonoBehaviour obj2 = ((obj is Hoverable) ? obj : null); if (obj2 == null) { return 0f; } return ((Hoverable)obj2).GetHoverOffset(); } } public sealed class WorldTankard : MonoBehaviour, Interactable, Hoverable { private static bool IsDrink(ItemData item) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)item?.m_dropPrefab) && (int)item.m_shared.m_itemType == 2) { if (!((Object)item.m_dropPrefab).name.StartsWith("Mead", StringComparison.OrdinalIgnoreCase)) { return Catalogue.Named("fermenter").GetComponent<Fermenter>().m_conversion.Any((ItemConversion c) => c.m_to.m_itemData.m_shared.m_name == item.m_shared.m_name); } return true; } return false; } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold || !WorldcraftPlugin.FunctionalProps.Value) { return false; } ItemData val = ((IEnumerable<ItemData>)user.GetInventory().GetAllItems()).FirstOrDefault((Func<ItemData, bool>)IsDrink); if (val != null) { return UseItem(user, val); } ((Character)user).Message((MessageType)2, "$wc_need_drink", 0, (Sprite)null, false); return false; } public bool UseItem(Humanoid user, ItemData item) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!WorldcraftPlugin.FunctionalProps.Value || !IsDrink(item) || !user.GetInventory().ContainsItem(item) || !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return false; } return user.ConsumeItem(user.GetInventory(), item, true); } public string GetHoverName() { return Words.Local("$item_tankard"); } public string GetHoverText() { return GetHoverName() + "\n" + Words.Local("[<color=yellow><b>$KEY_Use</b></color>] $wc_drink"); } public float GetHoverOffset() { return 0f; } } public sealed class WorldFire : MonoBehaviour, Interactable, Hoverable { [SerializeField] internal int Slot; [SerializeField] internal int MaxFuel; [SerializeField] internal float SecondsPerFuel; [SerializeField] internal Light[] LegacyLights; [SerializeField] internal GameObject Burning; [SerializeField] internal ItemDrop Fuel; private ZNetView view; private GameObject flames; private string rpc; private string receipt; private readonly HashSet<int> payments = new HashSet<int>(); private int nextPayment; private int untilKey; private int bankKey; private long Now => ZNet.instance.GetTime().Ticks; private float Remaining { get { ZDO zDO = view.GetZDO(); long num = zDO.GetLong(untilKey, 0L); if (num != 0L) { return Mathf.Max(0f, (float)TimeSpan.FromTicks(num - Now).TotalSeconds); } return zDO.GetFloat(bankKey, 0f); } } internal bool Lit { get { if (WorldcraftPlugin.FunctionalProps.Value && Object.op_Implicit((Object)(object)view) && view.IsValid()) { return view.GetZDO().GetLong(untilKey, 0L) > Now; } return false; } } private void Start() { view = ((Component)this).GetComponentInParent<ZNetView>(); if (Object.op_Implicit((Object)(object)view) && view.IsValid()) { rpc = "WC_Fire" + Slot; receipt = rpc + "_paid"; untilKey = StringExtensionMethods.GetStableHashCode(rpc + "_until"); bankKey = StringExtensionMethods.GetStableHashCode(rpc + "_fuel"); view.Register<int>(rpc, (Action<long, int>)Change); view.Register<int, bool>(receipt, (Action<long, int, bool>)PaymentResult); RefreshLight(); ((MonoBehaviour)this).InvokeRepeating("RefreshLight", 0.2f, 0.25f); } } private void RefreshLight() { if (!Object.op_Implicit((Object)(object)view) || !view.IsValid()) { return; } bool lit = Lit; if (lit && !Object.op_Implicit((Object)(object)flames)) { flames = Object.Instantiate<GameObject>(Burning, Burning.transform.parent, false); flames.SetActive(true); } else if (!lit && Object.op_Implicit((Object)(object)flames)) { flames.SetActive(false); Object.Destroy((Object)(object)flames); flames = null; } Light[] legacyLights = LegacyLights; foreach (Light val in legacyLights) { if (Object.op_Implicit((Object)(object)val)) { ((Behaviour)val).enabled = !WorldcraftPlugin.FunctionalProps.Value; } } } private void Change(long sender, int payment) { if (!view.IsOwner()) { return; } bool flag = payment != 0; float num = Remaining; if (!WorldcraftPlugin.FunctionalProps.Value || (flag && Mathf.CeilToInt(num / SecondsPerFuel) >= MaxFuel)) { if (flag) { view.InvokeRPC(sender, receipt, new object[2] { payment, false }); } return; } ZDO zDO = view.GetZDO(); bool flag2 = flag || !Lit; if (flag) { num = Mathf.Min((float)MaxFuel * SecondsPerFuel, num + SecondsPerFuel); } zDO.Set(bankKey, flag2 ? 0f : num); zDO.Set(untilKey, (flag2 && num > 0f) ? (Now + TimeSpan.FromSeconds(num).Ticks) : 0); if (flag) { view.InvokeRPC(sender, receipt, new object[2] { payment, true }); } RefreshLight(); } private void PaymentResult(long sender, int payment, bool accepted) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!(!Object.op_Implicit((Object)(object)localPlayer) || !view.IsValid() || sender != view.GetZDO().GetOwner() || !payments.Remove(payment) || accepted) && !((Humanoid)localPlayer).GetInventory().AddItem(((Component)Fuel).gameObject, 1)) { ItemDrop.OnCreateNew(Object.Instantiate<ItemDrop>(Fuel, ((Component)localPlayer).transform.position + Vector3.up, Quaternion.identity), false); } } public bool Interact(Humanoid user, bool hold, bool alt) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (hold || !WorldcraftPlugin.FunctionalProps.Value || !Object.op_Implicit((Object)(object)view) || !view.IsValid() || !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return false; } if (!view.HasOwner()) { view.ClaimOwnership(); } if (Remaining > 0f && !alt) { view.InvokeRPC(rpc, new object[1] { 0 }); return true; } ItemData item = user.GetInventory().GetItem(Fuel.m_itemData.m_shared.m_name, -1, false); if (item != null) { return UseItem(user, item); } ((Character)user).Message((MessageType)2, "$msg_outof " + Fuel.m_itemData.m_shared.m_name, 0, (Sprite)null, false); return false; } public bool UseItem(Humanoid user, ItemData item) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!WorldcraftPlugin.FunctionalProps.Value || !Object.op_Implicit((Object)(object)view) || !view.IsValid() || !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false) || item?.m_shared.m_name != Fuel.m_itemData.m_shared.m_name || !user.GetInventory().ContainsItem(item)) { return false; } if (Mathf.CeilToInt(Remaining / SecondsPerFuel) >= MaxFuel) { ((Character)user).Message((MessageType)2, "$msg_cantaddmore", 0, (Sprite)null, false); return false; } if (!user.GetInventory().RemoveOneItem(item)) { return false; } if (!view.HasOwner()) { view.ClaimOwnership(); } int num = ++nextPayment; payments.Add(num); view.InvokeRPC(rpc, new object[1] { num }); return true; } public string GetHoverName() { return Words.Local(((Component)this).GetComponentInParent<Piece>().m_name); } public string GetHoverText() { if (!Object.op_Implicit((Object)(object)view) || !view.IsValid()) { return ""; } string text = (Lit ? "$wc_extinguish" : "$wc_light_fire"); return Words.Local(((Component)this).GetComponentInParent<Piece>().m_name + "\n[$KEY_Use] " + text + "\n[$KEY_AltPlace + $KEY_Use] " + Fuel.m_itemData.m_shared.m_name) + " (" + Mathf.CeilToInt(Remaining / SecondsPerFuel) + "/" + MaxFuel + ")"; } public float GetHoverOffset() { return 0f; } } public sealed class CaskContents : MonoBehaviour { private static readonly Action<Fermenter> Drop = AccessTools.MethodDelegate<Action<Fermenter>>(AccessTools.Method(typeof(Fermenter), "DropAllItems", (Type[])null, (Type[])null), (object)null, true); private static readonly Action<Fermenter> Pour = AccessTools.MethodDelegate<Action<Fermenter>>(AccessTools.Method(typeof(Fermenter), "DelayedTap", (Type[])null, (Type[])null), (object)null, true); private ZNetView view; private const string Recovered = "zfwc_cask_recovered"; private const string RecoverRpc = "WorldcraftRecoverCask"; internal bool HasLegacyItems { get { if (!Object.op_Implicit((Object)(object)view) || !view.IsValid()) { return false; } ZDO zDO = view.GetZDO(); byte[] byteArray = zDO.GetByteArray(ZDOVars.s_items, (byte[])null); if (!zDO.GetBool("zfwc_cask_recovered", false) && byteArray != null && byteArray.Length >= 6) { return BitConverter.ToUInt16(byteArray, 4) > 0; } return false; } } internal bool Recover() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!HasLegacyItems || !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return false; } if (!view.HasOwner()) { view.ClaimOwnership(); } view.InvokeRPC("WorldcraftRecoverCask", Array.Empty<object>()); return true; } private void DropLegacy() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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) if (!view.IsOwner() || !HasLegacyItems) { return; } ZDO zDO = view.GetZDO(); Inventory val = new Inventory("", (Sprite)null, 3, 2); val.Load(new ZPackage(zDO.GetByteArray(ZDOVars.s_items, (byte[])null))); foreach (ItemData allItem in val.GetAllItems()) { ItemDrop.DropItem(allItem, 0, ((Component)this).transform.position + Vector3.up + ((Component)this).transform.forward, Quaternion.identity); } zDO.Set("zfwc_cask_recovered", true); } private void Start() { view = ((Component)this).GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)view) || !view.IsValid()) { return; } view.Register("WorldcraftRecoverCask", (Action<long>)delegate { DropLegacy(); }); Fermenter f = ((Component)this).GetComponent<Fermenter>(); WearNTear component = ((Component)this).GetComponent<WearNTear>(); component.m_onDestroyed = (Action)Delegate.Combine(component.m_onDestroyed, (Action)delegate { if (view.IsOwner()) { DropLegacy(); if (((MonoBehaviour)f).IsInvoking("DelayedTap")) { ((MonoBehaviour)f).CancelInvoke("DelayedTap"); Pour(f); } Drop(f); } }); } } public sealed class HammerMenu : MonoBehaviour { private static readonly FieldRef<BuildUi, List<BuildUiPieceButton>> Buttons = AccessTools.FieldRefAccess<BuildUi, List<BuildUiPieceButton>>("m_pieceButtons"); private static readonly Action<BuildUi> Navigation = AccessTools.MethodDelegate<Action<BuildUi>>(AccessTools.Method(typeof(BuildUi), "ConfigureButtonNavigation", (Type[])null, (Type[])null), (object)null, true); private static readonly Dictionary<Piece, string> index = new Dictionary<Piece, string>(); private static string language; private static HammerMenu current; private BuildUi menu; private RectTransform panel; private RectTransform header; private RectTransform viewport; private Canvas canvas; private Vector2 originalPosition; private Vector3 originalScale; private ScrollRect scroll; private TMP_Text toggleText; private TMP_Text scaleText; private HammerScale slider; private readonly Dictionary<long, float> positions = new Dictionary<long, float>(); private long currentCategory = long.MinValue; private bool restoreScroll; private Vector2Int screen; private float wantedPosition; private static readonly Color Background = new Color(0.115f, 0.1f, 0.085f, 0.97f); private static readonly Color Gold = new Color(0.88f, 0.69f, 0.4f, 1f); private static readonly Color Track = new Color(0.3f, 0.26f, 0.21f, 0.96f); private static readonly FieldRef<BuildUiPieceButton, Image> Icon = AccessTools.FieldRefAccess<BuildUiPieceButton, Image>("m_icon"); internal static bool IsHammer { get { if (Object.op_Implicit((Object)(object)Catalogue.Hammer) && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return (Object)(object)Player.m_localPlayer.GetBuildTool() == (Object)(object)Catalogue.Hammer; } return false; } } internal static void Open(BuildUi ui, ScrollRect grid, RectTransform tabs) { HammerMenu hammerMenu = ((Component)ui).GetComponent<HammerMenu>(); if (!Object.op_Implicit((Object)(object)hammerMenu)) { hammerMenu = ((Component)ui).gameObject.AddComponent<HammerMenu>(); } if (!Object.op_Implicit((Object)(object)hammerMenu.header)) { hammerMenu.Create(ui, grid, tabs); } ((Component)hammerMenu.header).gameObject.SetActive(IsHammer); current = hammerMenu; if (!hammerMenu.slider.Dragging) { hammerMenu.ApplyLayout(); } hammerMenu.Labels(); } private void Create(BuildUi ui, ScrollRect grid, RectTransform tabs) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) menu = ui; scroll = grid; canvas = ((Component)ui).GetComponentInParent<Canvas>().rootCanvas; viewport = (RectTransform)((Component)ui).transform; panel = tabs; while (Object.op_Implicit((Object)(object)panel) && !((Component)grid).transform.IsChildOf((Transform)(object)panel)) { ref RectTransform reference = ref panel; Transform parent = ((Transform)panel).parent; reference = (RectTransform)(object)((parent is RectTransform) ? parent : null); } if (!Object.op_Implicit((Object)(object)panel)) { panel = viewport; } originalPosition = panel.anchoredPosition; originalScale = ((Transform)panel).localScale; header = Rect("Worldcraft title bar", (Transform)(object)panel); header.anchorMin = new Vector2(0f, 1f); header.anchorMax = Vector2.one; header.pivot = new Vector2(0.5f, 0f); header.sizeDelta = new Vector2(0f, 34f); header.anchoredPosition = Vector2.zero; Image(header, Background); ((Component)header).gameObject.AddComponent<HammerDrag>().Owner = this; Label("ValhAllCraft", header, 0f, 0.25f).alignment = (TextAlignmentOptions)4097; RectTransform val = Rect("Catalogue toggle", (Transform)(object)header); Span(val, 0.25f, 0.69f, 2f); Image targetGraphic = Image(val, Track); Button obj = ((Component)val).gameObject.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)targetGraphic; toggleText = Label("", val, 0f, 1f); ((UnityEvent)obj.onClick).AddListener((UnityAction)delegate { WorldcraftPlugin.ShowAll.Value = !WorldcraftPlugin.ShowAll.Value; Labels(); }); scaleText = Label("", header, 0.69f, 0.82f); RectTransform val2 = Rect("Scale", (Transform)(object)header); Span(val2, 0.82f, 0.995f, 3f); RectTransform obj2 = Rect("Track", (Transform)(object)val2); obj2.anchorMin = new Vector2(0f, 0.4f); obj2.anchorMax = new Vector2(1f, 0.6f); obj2.offsetMin = Vector2.zero; obj2.offsetMax = Vector2.zero; Image(obj2, Track); RectTransform val3 = Rect("Handle", (Transform)(object)val2); val3.sizeDelta = new Vector2(12f, 0f); Image targetGraphic2 = Image(val3, Gold); slider = ((Component)val2).gameObject.AddComponent<HammerScale>(); ((Slider)slider).handleRect = val3; ((Selectable)slider).targetGraphic = (Graphic)(object)targetGraphic2; ((Slider)slider).minValue = 0.6f; ((Slider)slider).maxValue = 1.5f; slider.Owner = this; ((Slider)slider).SetValueWithoutNotify(WorldcraftPlugin.Scale.Value); ((UnityEvent<float>)(object)((Slider)slider).onValueChanged).AddListener((UnityAction<float>)delegate { if (slider.Dragging) { Labels(); } else { CommitScale(); } }); if (!Object.op_Implicit((Object)(object)grid.verticalScrollbar)) { RectTransform val4 = Rect("Worldcraft scroll", ((Component)grid).transform); val4.anchorMin = new Vector2(1f, 0f); val4.anchorMax = Vector2.one; val4.pivot = new Vector2(1f, 0.5f); val4.offsetMin = new Vector2(-15f, 1f); val4.offsetMax = new Vector2(0f, -1f); Image(val4, Background); RectTransform val5 = Rect("Handle", (Transform)(object)val4); Image targetGraphic3 = Image(val5, Gold); Scrollbar val6 = ((Component)val4).gameObject.AddComponent<Scrollbar>(); ((Selectable)val6).targetGraphic = (Graphic)(object)targetGraphic3; val6.handleRect = val5; val6.direction = (Direction)2; grid.verticalScrollbar = val6; if (Object.op_Implicit((Object)(object)grid.viewport) && (Object)(object)grid.viewport != (Object)(object)((Component)grid).transform) { RectTransform obj3 = grid.viewport; obj3.offsetMax -= new Vector2(16f, 0f); } } grid.vertical = true; grid.verticalScrollbarVisibility = (ScrollbarVisibility)0; } private static RectTransform Rect(string name, Transform parent) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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 RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }).transform; ((Transform)val).SetParent(parent, false); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; Vector2 offsetMin = (val.offsetMax = Vector2.zero); val.offsetMin = offsetMin; return val; } private static Image Image(RectTransform rect, Color color) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) Image obj = ((Component)rect).gameObject.AddComponent<Image>(); ((Graphic)obj).color = color; return obj; } private static void Span(RectTransform rect, float left, float right, float margin) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = new Vector2(left, 0f); rect.anchorMax = new Vector2(right, 1f); rect.offsetMin = new Vector2(margin, 2f); rect.offsetMax = new Vector2(0f - margin, -2f); } private static TMP_Text Label(string text, RectTransform parent, float left, float right) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = Rect("Label", (Transform)(object)parent); Span(obj, left, right, 4f); TextMeshProUGUI obj2 = ((Component)obj).gameObject.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj2).font = Hud.instance.m_pieceDescription.font; ((TMP_Text)obj2).fontSize = 15f; ((TMP_Text)obj2).enableAutoSizing = true; ((TMP_Text)obj2).fontSizeMin = 9f; ((TMP_Text)obj2).fontSizeMax = 15f; ((TMP_Text)obj2).alignment = (TextAlignmentOptions)514; ((Graphic)obj2).color = Color.white; ((Graphic)obj2).raycastTarget = false; ((TMP_Text)obj2).text = text; return (TMP_Text)(object)obj2; } private void Labels() { if (Object.op_Implicit((Object)(object)toggleText)) { toggleText.text = (WorldcraftPlugin.ShowAll.Value ? "[×] " : "[ ] ") + Words.Local("$wc_all"); scaleText.text = Words.Local("$wc_scale") + " " + Mathf.RoundToInt(((Slider)slider).value * 100f) + "%"; } } internal void CommitScale() { if (Object.op_Implicit((Object)(object)slider) && !Mathf.Approximately(WorldcraftPlugin.Scale.Value, ((Slider)slider).value)) { WorldcraftPlugin.Scale.Value = ((Slider)slider).value; ApplyLayout(); Labels(); } } private void ApplyLayout() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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_0083: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)panel)) { bool isHammer = IsHammer; ((Transform)panel).localScale = originalScale; panel.anchoredPosition = originalPosition; if (isHammer) { Rect rect = viewport.rect; float width = ((Rect)(ref rect)).width; rect = panel.rect; float num = width / Mathf.Max(1f, ((Rect)(ref rect)).width * Mathf.Abs(originalScale.x)); rect = viewport.rect; float height = ((Rect)(ref rect)).height; rect = panel.rect; float num2 = height / Mathf.Max(1f, (((Rect)(ref rect)).height + 36f) * Mathf.Abs(originalScale.y)); float num3 = Mathf.Min(new float[3] { WorldcraftPlugin.Scale.Value, num, num2 }); ((Transform)panel).localScale = originalScale * num3; panel.anchoredPosition = originalPosition + WorldcraftPlugin.Offset.Value; Vector3[] array = (Vector3[])(object)new Vector3[4]; panel.GetWorldCorners(array); Vector3 val = ((Transform)viewport).InverseTransformPoint(array[0]); Vector3 val2 = ((Transform)viewport).InverseTransformPoint(array[2]); header.GetWorldCorners(array); val2.y = Mathf.Max(val2.y, ((Transform)viewport).InverseTransformPoint(array[2]).y); rect = viewport.rect; float num4 = Mathf.Max(0f, ((Rect)(ref rect)).xMin - val.x); rect = viewport.rect; float num5 = num4 + Mathf.Min(0f, ((Rect)(ref rect)).xMax - val2.x); rect = viewport.rect; float num6 = Mathf.Max(0f, ((Rect)(ref rect)).yMin - val.y); rect = viewport.rect; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(num5, num6 + Mathf.Min(0f, ((Rect)(ref rect)).yMax - val2.y)); RectTransform obj = panel; ((Transform)obj).position = ((Transform)obj).position + ((Transform)viewport).TransformVector(Vector2.op_Implicit(val3)); screen = new Vector2Int(Screen.width, Screen.height); } } } internal void Drag(Vector2 delta) { //IL_0017: 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_003e: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Transform)panel).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); Camera val2 = (((int)canvas.renderMode == 0) ? null : canvas.worldCamera); Vector2 val3 = default(Vector2); Vector2 val4 = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(val, Vector2.zero, val2, ref val3) && RectTransformUtility.ScreenPointToLocalPointInRectangle(val, delta, val2, ref val4)) { WorldcraftPlugin.Offset.Value = panel.anchoredPosition - originalPosition + val4 - val3; ApplyLayout(); } } private void LateUpdate() { if (Object.op_Implicit((Object)(object)header) && ((Component)header).gameObject.activeSelf) { if (!slider.Dragging && (((Vector2Int)(ref screen)).x != Screen.width || ((Vector2Int)(ref screen)).y != Screen.height)) { ApplyLayout(); } if (restoreScroll) { Canvas.ForceUpdateCanvases(); scroll.StopMovement(); scroll.verticalNormalizedPosition = wantedPosition; restoreScroll = false; } } } internal static void Category(int tab, int tag) { if (!IsHammer || !Object.op_Implicit((Object)(object)current) || !Object.op_Implicit((Object)(object)current.scroll)) { return; } long num = ((long)tab << 32) | (uint)tag; if (current.currentCategory != num) { if (current.currentCategory != long.MinValue) { current.positions[current.currentCategory] = current.scroll.verticalNormalizedPosition; } current.currentCategory = num; current.restoreScroll = true; current.wantedPosition = (current.positions.TryGetValue(num, out var value) ? value : 1f); } } internal static void Search(BuildUi ui, string text) { string selectedLanguage = Localization.instance.GetSelectedLanguage(); if (language != selectedLanguage) { language = selectedLanguage; index.Clear(); if (Object.op_Implicit((Object)(object)current)) { current.Labels(); } } string[] array = Words.Fold(text ?? "").Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (BuildUiPieceButton button in Buttons.Invoke(ui)) { Piece piece = button.Piece; if (!Object.op_Implicit((Object)(object)piece)) { continue; } if (!index.TryGetValue(piece, out var words)) { index[piece] = (words = Words.Index(piece)); } bool flag = array.All((string t) => words.Contains(t) || button.LocalizedSearchTerms.Any((string s) => s.Contains(t))); if (flag && array.Length != 0) { WorldcraftPlugin.RequestIcon(piece, prioritize: true); } if (((Component)button).gameObject.activeSelf != flag) { ((Component)button).gameObject.SetActive(flag); } } Navigation(ui); } internal static void RefreshIcon(Piece p) { if (!Object.op_Implicit((Object)(object)current) || !Object.op_Implicit((Object)(object)current.menu)) { return; } foreach (BuildUiPieceButton item in Buttons.Invoke(current.menu)) { if ((Object)(object)item.Piece == (Object)(object)p) { Icon.Invoke(item).sprite = p.m_icon; } } } internal static void Mark(BuildUiPieceButton button) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) Piece piece = button.Piece; Transform val = ((Component)button).transform.Find("Worldcraft lock"); bool flag = Catalogue.Pieces.ContainsKey(piece) && !Knowledge.CanSelect(Player.m_localPlayer, piece); if (flag && !Object.op_Implicit((Object)(object)val)) { RectTransform val2 = Rect("Worldcraft lock", ((Component)button).transform); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(1f, 1f); val2.pivot = val3; Vector2 anchorMin = (val2.anchorMax = val3); val2.anchorMin = anchorMin; val2.sizeDelta = new Vector2(17f, 17f); ((Graphic)Image(val2, Background)).raycastTarget = false; ((Graphic)Label("×", val2, 0f, 1f)).color = Gold; val = (Transform)(object)val2; } if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.SetActive(flag); } WorldcraftPlugin.RequestIcon(piece); } } public sealed class HammerDrag : MonoBehaviour, IDragHandler, IEventSystemHandler { internal HammerMenu Owner; public void OnDrag(PointerEventData eventData) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Owner)) { Owner.Drag(eventData.delta); } } } public sealed class HammerScale : Slider { internal HammerMenu Owner; internal bool Dragging { get; private set; } public override void OnPointerDown(PointerEventData data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)data.button == 0) { Dragging = true; } ((Slider)this).OnPointerDown(data); } public override void OnPointerUp(PointerEventData data) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) ((Selectable)this).OnPointerUp(data); if ((int)data.button == 0) { Finish(); } } protected override void OnDisable() { Finish(); ((Slider)this).OnDisable(); } private void Finish() { if (Dragging) { Dragging = false; if (Object.op_Implicit((Object)(object)Owner)) { Owner.CommitScale(); } } } } [HarmonyPatch(typeof(BuildUi), "OpenBuildMenu")] internal static class HammerOpen { private static void Postfix(BuildUi __instance, ScrollRect ___m_pieceScrollRect, RectTransform ___m_tabContainer, int ___m_currentPieceList, int ___m_currentTagId) { if (HammerMenu.IsHammer || Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<HammerMenu>())) { HammerMenu.Open(__instance, ___m_pieceScrollRect, ___m_tabContainer); } HammerMenu.Category(___m_currentPieceList, ___m_currentTagId); } } [HarmonyPatch(typeof(BuildUi), "UpdateSearch")] internal static class HammerSearch { private static bool Prefix(BuildUi __instance, string term) { if (!HammerMenu.IsHammer) { return true; } HammerMenu.Search(__instance, term); return false; } } [HarmonyPatch(typeof(BuildUi), "SetCurrentTag")] internal static class HammerTag { private static void Prefix(GuiInputField ___m_searchField, out string __state) { __state = (HammerMenu.IsHammer ? ((TMP_InputField)___m_searchField).text : null); } private static void Postfix(string __state, GuiInputField ___m_searchField, int ___m_currentPieceList, int ___m_currentTagId) { if (__state != null) { if (__state != ((TMP_InputField)___m_searchField).text) { ((TMP_InputField)___m_searchField).SetTextWithoutNotify(__state); } HammerMenu.Category(___m_currentPieceList, ___m_currentTagId); } } } [HarmonyPatch(typeof(BuildUiPieceButton), "UpdateRequirements")] internal static class HammerBadge { private static void Postfix(BuildUiPieceButton __instance) { if (Object.op_Implicit((Object)(object)__instance.Piece) && HammerMenu.IsHammer) { HammerMenu.Mark(__instance); } } } [HarmonyPatch(typeof(BuildUi), "OnSelectPiece")] internal static class HammerSelection { private static bool Prefix(Piece piece) { Player localPlayer = Player.m_localPlayer; if (Knowledge.CanSelect(localPlayer, piece)) { return true; } ((Character)localPlayer).Message((MessageType)2, Knowledge.LockText(localPlayer, piece, Catalogue.Pieces[piece]), 0, (Sprite)null, false); return false; } } [HarmonyPatch(typeof(Hud), "SetupPieceInfo")] internal static class HammerDetails { private static void Postfix(Hud __instance, Piece piece) { if (Object.op_Implicit((Object)(object)piece) && Catalogue.Pieces.TryGetValue(piece, out var value) && !Knowledge.CanSelect(Player.m_localPlayer, piece)) { TMP_Text pieceDescription = __instance.m_pieceDescription; pieceDescription.text = pieceDescription.text + "\n<color=#e6bb73>" + Words.Local("$wc_locked") + " · " + Knowledge.LockText(Player.m_localPlayer, piece, value) + "</color>"; } } } internal static class Knowledge { private static readonly string[] bossGates = new string[9] { "", "eikthyr", "elder", "bonemass", "moder", "yagluth", "queen", "fader", "frozenking" }; private static readonly string[] bossKeys = new string[9] { "", "defeated_eikthyr", "defeated_gdking", "defeated_bonemass", "defeated_dragon", "defeated_goblinking", "defeated_queen", "defeated_fader", "defeated_frozenking" }; private static readonly string[] bossNames = new string[9] { "", "$enemy_eikthyr", "$enemy_gdking", "$enemy_bonemass", "$enemy_dragon", "$enemy_goblinking", "$enemy_seekerqueen", "$enemy_fader", "$enemy_frozenking" }; private static readonly List<Piece> nearby = new List<Piece>(); private static Player previous; private static bool previousNoCost; private static readonly Dictionary<string, string> sites = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "StoneCircle", "circle" }, { "StoneHenge", "henge" }, { "Dolmen", "dolmen" }, { "GoblinCamp", "village" }, { "FulingVillage", "village" }, { "WoodFarm", "homestead" }, { "WoodVillage", "homestead" }, { "WoodHouse", "homestead" } }; private static string Key(string milestone) { return "zfwc.discovered." + milestone; } internal static bool Record(Player p, string gate) { if (!Object.op_Implicit((Object)(object)p) || string.IsNullOrEmpty(gate) || p.m_customData.ContainsKey(Key(gate))) { return false; } p.m_customData[Key(gate)] = "1"; return true; } internal static bool IsDvergr(string name) { if (name != null) { if (!name.StartsWith("$enemy_dvergr", StringComparison.OrdinalIgnoreCase)) { return name.StartsWith("$enemy_dverger", StringComparison.OrdinalIgnoreCase); } return true; } return false; } internal static void Credit(int order, string enemy) { string gate = ((order > 0 && order < bossGates.Length) ? bossGates[order] : (IsDvergr(enemy) ? "dvergr" : null)); if (Record(Player.m_localPlayer, gate)) { WorldcraftPlugin.Refresh(); } } private static bool ImportPastVictories(Player p) { Game instance = Game.instance; object obj; if (instance == null) { obj = null; } else { PlayerProfile playerProfile = instance.GetPlayerProfile(); obj = ((playerProfile != null) ? playerProfile.