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 Beedles Traveling Shop v0.32.0
BepInEx/plugins/BeedlesTravelingShop/TravelingMerchant.dll
Decompiled 13 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using TMPro; using TravelingMerchant.WindGear; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("TravelingMerchant.RuntimeTests")] [assembly: InternalsVisibleTo("TravelingMerchant.MultiplayerTests")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("TravelingMerchant")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.32.0.0")] [assembly: AssemblyInformationalVersion("0.32.0")] [assembly: AssemblyProduct("TravelingMerchant")] [assembly: AssemblyTitle("TravelingMerchant")] [assembly: AssemblyVersion("0.32.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TravelingMerchant { internal static class Server { private static readonly Dictionary<long, float> conversationLeases = new Dictionary<long, float>(); private static readonly Dictionary<long, int> crafts = new Dictionary<long, int>(); internal static ZDO? Progress; internal static ZDO? Active; private static float nextTick; private static int scanIndex; private static readonly List<ZDO> records = new List<ZDO>(); private static readonly Dictionary<long, float> throttle = new Dictionary<long, float>(); private static readonly HashSet<string> collected = new HashSet<string>(); private static readonly Dictionary<ZDOID, int> emotes = new Dictionary<ZDOID, int>(); private static bool skippingTime; internal static double Now { get { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return 0.0; } return ZNet.instance.GetTimeSeconds(); } } internal static bool OldEnough { get { if (Object.op_Implicit((Object)(object)EnvMan.instance)) { return Now >= (double)(5 * EnvMan.instance.m_dayLengthSec); } return false; } } private unsafe static void BeetleCamp(long sender, ZPackage pkg) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_0157: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0234: 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_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_056b: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_0599: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: 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_062b: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0658: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_067d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer() || Progress == null || Active != null || (throttle.TryGetValue(sender, out var value) && Time.time - value < 2f)) { return; } throttle[sender] = Time.time; try { ZDO zDO = ZDOMan.instance.GetZDO(pkg.ReadZDOID()); pkg.ReadZDOID(); Vector3 val = pkg.ReadVector3(); int num = pkg.ReadInt(); ZDO val2 = PlayerFor(sender); Vector3 val3; if (Plugin.Diagnostics.Value) { Plugin instance = Plugin.Instance; string[] obj = new string[8] { "Beetle invitation: player=", (val2 != null).ToString(), " sign=", (zDO != null).ToString(), " count=", num.ToString(), " requested=", null }; val3 = val; obj[7] = ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString(); instance.LoggerForServer(string.Concat(obj)); } if (zDO == null || val2 == null || num < 2 || num > 128 || zDO.GetPrefab() != StringExtensionMethods.GetStableHashCode("BeedleBeetleSign") || Vector3.Distance(val2.GetPosition(), zDO.GetPosition()) > 64f) { return; } List<Vector3> list = new List<Vector3>(); for (int i = 0; i < num; i++) { Vector3 val4 = pkg.ReadVector3(); if (!Finite(val4) || Vector3.Distance(val4, zDO.GetPosition()) > 90f) { return; } list.Add(val4); } if (!Finite(val) || Vector3.Distance(val, zDO.GetPosition()) > 5f || Vector3.Distance(val, zDO.GetPosition()) < 1.8f) { return; } Quaternion facing = BeedleGround.Facing(val, zDO.GetPosition(), zDO.GetRotation()); float spread2; if (Plugin.Diagnostics.Value) { Plugin instance2 = Plugin.Instance; Vector3 grounded; float spread; string[] obj2 = new string[10] { "Beetle site: flat=", BeedleGround.Flat(val, facing, out grounded, out spread).ToString(), " spread=", spread.ToString(), " end=", null, null, null, null, null }; val3 = list.Last(); obj2[5] = ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString(); obj2[6] = " ground="; val3 = grounded; obj2[7] = ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString(); obj2[8] = " distance="; spread2 = Vector3.Distance(val, zDO.GetPosition()); obj2[9] = spread2.ToString(); instance2.LoggerForServer(string.Concat(obj2)); } if (Plugin.Diagnostics.Value && Mathf.Abs(list.Last().y - val.y) > 0.4f) { RaycastHit[] array = Physics.RaycastAll(list.Last() + Vector3.up * 2f, Vector3.down, 8f, -1, (QueryTriggerInteraction)1); for (int j = 0; j < array.Length; j++) { RaycastHit val5 = array[j]; Plugin instance3 = Plugin.Instance; string[] obj3 = new string[10] { "Floor probe: ", ((Object)((RaycastHit)(ref val5)).collider).name, " y=", null, null, null, null, null, null, null }; val3 = ((RaycastHit)(ref val5)).point; obj3[3] = val3.y.ToString(); obj3[4] = " layer="; obj3[5] = LayerMask.LayerToName(((Component)((RaycastHit)(ref val5)).collider).gameObject.layer); obj3[6] = " character="; obj3[7] = (Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val5)).collider).GetComponentInParent<Character>()) ? ((Object)((Component)((RaycastHit)(ref val5)).collider).GetComponentInParent<Character>()).name : ""); obj3[8] = " piece="; obj3[9] = (Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val5)).collider).GetComponentInParent<Piece>()) ? ((Object)((Component)((RaycastHit)(ref val5)).collider).GetComponentInParent<Piece>()).name : ""); instance3.LoggerForServer(string.Concat(obj3)); } } if (!BeedleGround.Flat(val, facing, out var grounded2, out spread2)) { return; } val3 = Vector3.ProjectOnPlane(list.Last() - grounded2, Vector3.up); if (((Vector3)(ref val3)).magnitude > 0.35f || Mathf.Abs(list.Last().y - grounded2.y) > 0.4f) { return; } float num2 = MerchantNavigation.Length(list); if (Plugin.Diagnostics.Value) { Plugin.Instance.LoggerForServer("Beetle route: length=" + num2 + " start=" + Vector3.Distance(list[0], grounded2) + " clear=" + MerchantNavigation.ClearRoute(list)); } if (num2 < 5f || num2 > 140f || Vector3.Distance(list[0], grounded2) < Plugin.SpawnDistance.Value - 5f || !MerchantNavigation.ClearRoute(list)) { return; } for (int k = 1; k < list.Count; k++) { if (Vector3.Distance(list[k], list[k - 1]) > 8f || Mathf.Abs(list[k].y - list[k - 1].y) > 3f) { return; } } Vector3 val6 = Vector3.ProjectOnPlane(zDO.GetPosition() - grounded2, Vector3.up); Quaternion val7 = ((((Vector3)(ref val6)).sqrMagnitude > 0.01f) ? Quaternion.LookRotation(val6) : zDO.GetRotation()); Active = ZDOMan.instance.CreateNewZDO(list[0], StringExtensionMethods.GetStableHashCode("TravelingMerchantNPC")); Active.SetPrefab(StringExtensionMethods.GetStableHashCode("TravelingMerchantNPC")); Active.Persistent = true; Active.Distant = true; Active.SetOwner(ZDOMan.GetSessionID()); Active.Set("tm.beedle", true); Active.Set("tm.sign", zDO.m_uid); Active.Set("tm.fire", ZDOID.None); Active.Set("tm.inviter", val2.m_uid); Active.Set("tm.home", list[0]); Active.Set("tm.seat", grounded2); Active.Set("tm.rotation", val7); Active.Set("tm.flatSite", true); Active.Set("tm.speed", 0.85f); Active.Set("tm.start", (float)Now); Active.Set("tm.idleSeed", (int)Now); ReplaceRoute(Active, list); Active.Set("tm.musicAt", (float)Now); MerchantVisit.Initialize(Active, Progress); Active.Set("tm.stockDay", MerchantVisit.Evening(Now, EnvMan.instance.m_dayLengthSec)); } catch (Exception ex) { Plugin.Instance.LoggerForServer("Rejected beetle-sign request: " + ex.Message); } } private static void TickBeedle() { //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_063d: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_0658: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) ZDO active = Active; double num = active.GetFloat("tm.leave", 0f); float num2 = MerchantMotion.SpeedFor(active); List<Vector3> list = ReadPath(active); if (list.Count < 2) { ZDOMan.instance.DestroyZDO(active); Active = null; return; } float num3 = active.GetFloat("tm.walk", 0f); float num4 = active.GetFloat("tm.pause", 0f); float num5 = (float)(Now - (double)active.GetFloat("tm.start", 0f)) - num4; float num6 = (float)Now; float num7 = Mathf.Clamp(num6 - active.GetFloat("tm.tickAt", num6 - 0.2f), 0f, 1f); active.Set("tm.tickAt", num6); if (num == 0.0 && !active.GetBool("tm.flatSite", false) && !active.GetBool("tm.interact", false) && Now >= (double)active.GetFloat("tm.flatRetry", 0f)) { active.Set("tm.flatRetry", num6 + 5f); ZDO zDO = ZDOMan.instance.GetZDO(active.GetZDOID("tm.sign")); if (zDO != null && Object.op_Implicit((Object)(object)Pathfinding.instance)) { foreach (Vector3 item in BeedleGround.Seats(zDO, zDO.GetPosition())) { Vector3 position = active.GetPosition(); position.y = BeedleGround.Height(position, position.y); if (MerchantNavigation.Find(position, item, out List<Vector3> path)) { ReplaceRoute(active, path); active.Set("tm.start", num6); active.Set("tm.pause", 0f); active.Set("tm.paused", false); active.Set("tm.seat", item); active.Set("tm.rotation", BeedleGround.Facing(item, zDO.GetPosition(), zDO.GetRotation())); active.Set("tm.flatSite", true); return; } } } } if (num == 0.0 && ZDOMan.instance.GetZDO(active.GetZDOID("tm.sign")) == null) { if (num5 < num3) { Retreat(list, Mathf.Max(0f, num5) * num2); return; } if (MerchantNavigation.Find(active.GetPosition(), active.GetVec3("tm.home", list[0]), out List<Vector3> path2)) { path2.Reverse(); ReplaceRoute(active, path2); list = path2; num3 = active.GetFloat("tm.walk", 0f); } active.Set("tm.leave", (float)Now); active.Set("tm.pause", 0f); active.Set("tm.paused", false); num = Now; num4 = 0f; } if (HoldConversation(active, num7)) { return; } int num8 = MerchantVisit.Evening(Now, EnvMan.instance.m_dayLengthSec); if (num == 0.0 && num8 != active.GetInt("tm.stockDay", 0)) { foreach (string item2 in MerchantEconomy.Stock.Where(MerchantEconomy.IsRefinedMetal)) { active.Set("tm.stock." + item2, Plugin.MetalStock.Value); } active.Set("tm.stockDay", num8); } float num9 = (float)(Now - num) - num4; float num10 = (active.GetBool("tm.abort", false) ? active.GetFloat("tm.returnDelay", 2.4f) : MerchantMotion.DepartureFor(active)); if (num > 0.0 && num9 > num10 + num3 + 2f) { ZDOMan.instance.DestroyZDO(active); Active = null; return; } bool flag = ((num > 0.0) ? (num9 >= num10) : (num5 < num3)); List<Vector3> list2 = new List<Vector3>(list); if (num > 0.0) { list2.Reverse(); } float distance = ((num > 0.0) ? (Mathf.Max(0f, num9 - num10) * num2) : (Mathf.Max(0f, num5) * num2)); Vector3 forward; Vector3 val = Along(list2, distance, out forward); if (!flag && num == 0.0) { val = active.GetVec3("tm.seat", list.Last()); } val.y = BeedleGround.Height(val, val.y); if (flag && !MerchantNavigation.Clear(active.GetPosition(), val)) { if (!active.GetBool("tm.paused", false)) { active.Set("tm.paused", true); active.Set("tm.waitStart", num6); active.Set("tm.pausePosition", active.GetPosition()); } active.Set("tm.pause", num4 + num7); if (num > 0.0 && Now - (double)active.GetFloat("tm.waitStart", 0f) >= 8.0) { ZDOMan.instance.DestroyZDO(active); Active = null; } else { if (!(Now >= (double)active.GetFloat("tm.repathAt", 0f))) { return; } active.Set("tm.repathAt", num6 + 2f); Vector3 end = ((num > 0.0) ? active.GetVec3("tm.home", list[0]) : active.GetVec3("tm.seat", list.Last())); if (MerchantNavigation.Find(active.GetPosition(), end, out List<Vector3> path3)) { if (num > 0.0) { path3.Reverse(); active.Set("tm.abort", true); active.Set("tm.returnDelay", 0f); active.Set("tm.leave", num6); } else { active.Set("tm.start", num6); } ReplaceRoute(active, path3); active.Set("tm.pause", 0f); active.Set("tm.paused", false); } } } else { active.Set("tm.paused", false); active.SetPosition(val); if (!flag) { forward = active.GetQuaternion("tm.rotation", Quaternion.identity) * Vector3.forward; } if (((Vector3)(ref forward)).sqrMagnitude > 0.001f) { active.SetRotation(Quaternion.LookRotation(forward)); } if (num == 0.0 && active.GetFloat("tm.musicAt", 0f) == 0f && Vector3.Distance(val, list.Last()) < 4f) { active.Set("tm.musicAt", num6); } } } private static void Conversation(long sender, ZPackage packet) { //IL_0021: 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_0075: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer() || Active == null) { return; } ZDOID val = packet.ReadZDOID(); bool flag = packet.ReadBool(); if (val != Active.m_uid) { return; } if (!flag) { conversationLeases.Remove(sender); return; } ZDO val2 = PlayerFor(sender); if (val2 == null || Active.GetFloat("tm.leave", 0f) > 0f || Vector3.Distance(val2.GetPosition(), Active.GetPosition()) > 2.3f) { return; } if (conversationLeases.Count == 0 && !Active.GetBool("tm.interact", false)) { float num = (float)(Now - (double)Active.GetFloat("tm.start", 0f)) - Active.GetFloat("tm.pause", 0f); Active.Set("tm.tradeStanding", num < Active.GetFloat("tm.walk", 0f) + 4.8f); Active.Set("tm.interactAt", (float)Now); Active.Set("tm.tradeSpot", Active.GetPosition()); Active.Set("tm.tradeFace", Active.GetRotation()); Active.Set("tm.interact", true); Active.Set("tm.resumeAt", 0f); if (Active.GetFloat("tm.musicAt", 0f) <= 0f) { Active.Set("tm.musicAt", Active.GetFloat("tm.start", 0f)); } } conversationLeases[sender] = Time.realtimeSinceStartup + 2f; } private static bool HoldConversation(ZDO data, float delta) { //IL_0035: 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_014a: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) long[] array = conversationLeases.Keys.ToArray(); foreach (long num in array) { ZDO val = PlayerFor(num); if (conversationLeases[num] < Time.realtimeSinceStartup || val == null || Vector3.Distance(val.GetPosition(), data.GetPosition()) > 3f) { conversationLeases.Remove(num); } } if (data.GetFloat("tm.leave", 0f) > 0f) { conversationLeases.Clear(); data.Set("tm.interact", false); return false; } if (conversationLeases.Count == 0 && data.GetBool("tm.interact", false)) { data.Set("tm.interact", false); if (data.GetBool("tm.tradeStanding", false)) { data.Set("tm.resumeAt", (float)Now); } } if (data.GetBool("tm.interact", false) || (data.GetFloat("tm.resumeAt", 0f) > 0f && Now - (double)data.GetFloat("tm.resumeAt", 0f) < 2.200000047683716)) { data.Set("tm.pause", data.GetFloat("tm.pause", 0f) + delta); data.SetPosition(data.GetVec3("tm.tradeSpot", data.GetPosition())); data.SetRotation(data.GetQuaternion("tm.tradeFace", data.GetRotation())); return true; } if (data.GetFloat("tm.resumeAt", 0f) > 0f) { data.Set("tm.resumeAt", 0f); data.Set("tm.tradeStanding", false); } return false; } private static void Crafted(long sender, ZPackage packet) { if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer() || Progress == null || PlayerFor(sender) == null) { return; } try { int num = packet.ReadInt(); string name = packet.ReadString(); int num2 = packet.ReadInt(); if (num >= 1 && (!crafts.TryGetValue(sender, out var value) || num > value) && MerchantEconomy.Tracked(name) && num2 >= 1 && num2 <= 1000 && !MerchantEconomy.IsRefinedMetal(name) && ObjectDB.instance.m_recipes.Any((Recipe r) => Object.op_Implicit((Object)(object)r) && Object.op_Implicit((Object)(object)r.m_item) && ((Object)r.m_item).name == name)) { crafts[sender] = num; int num3 = MerchantEconomy.Required(name); int num4 = Math.Min(num3, Progress.GetInt("tm.harvest.count." + name, 0) + num2); Progress.Set("tm.harvest.count." + name, num4); if (num4 >= num3) { ZoneSystem.instance.SetGlobalKey(MerchantEconomy.Key(name)); } } } catch (Exception ex) { Plugin.Instance.LoggerForServer("Rejected crafting discovery: " + ex.Message); } } internal static bool IsOutdoorBonfire(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) float num = default(float); bool flag = default(bool); Cover.GetCoverForPoint(position + Vector3.up, ref num, ref flag, 0.5f); return !flag; } internal static void Reset() { Progress = (Active = null); nextTick = 0f; scanIndex = 0; records.Clear(); throttle.Clear(); collected.Clear(); emotes.Clear(); crafts.Clear(); conversationLeases.Clear(); MerchantConversation.Reset(); skippingTime = false; MerchantTrade.Reset(); MerchantLegacyProgress.Reset(); MerchantCatalogMigration.Reset(); } internal static void Register(ZRoutedRpc rpc) { rpc.Register<ZPackage>("TM.Conversation", (Action<long, ZPackage>)Conversation); rpc.Register<ZPackage>("TM.Crafted", (Action<long, ZPackage>)Crafted); rpc.Register<ZPackage>("TM.BeetleCamp", (Action<long, ZPackage>)BeetleCamp); rpc.Register<ZPackage>("TM.Camp", (Action<long, ZPackage>)Camp); rpc.Register<ZPackage>("TM.Found", (Action<long, ZPackage>)Found); MerchantTrade.Register(rpc); } private static ZDO? PlayerFor(long sender) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0064: Unknown result type (might be due to invalid IL or missing references) ZDOID val = ((sender == ZDOMan.GetSessionID()) ? ZNet.instance.LocalPlayerCharacterID : (((IEnumerable<ZNetPeer>)ZNet.instance.GetPeers()).FirstOrDefault((Func<ZNetPeer, bool>)((ZNetPeer p) => p.m_uid == sender))?.m_characterID ?? ZDOID.None)); if (!(val == ZDOID.None)) { return ZDOMan.instance.GetZDO(val); } return null; } internal static void Tick() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_0a72: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_0a8c: Unknown result type (might be due to invalid IL or missing references) //IL_0a8e: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_06c0: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_0a39: Unknown result type (might be due to invalid IL or missing references) //IL_0a45: Unknown result type (might be due to invalid IL or missing references) //IL_0a47: Unknown result type (might be due to invalid IL or missing references) //IL_07ad: Unknown result type (might be due to invalid IL or missing references) //IL_07b2: Unknown result type (might be due to invalid IL or missing references) //IL_079a: Unknown result type (might be due to invalid IL or missing references) //IL_07b7: Unknown result type (might be due to invalid IL or missing references) //IL_07be: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer() || ZDOMan.instance == null || !Object.op_Implicit((Object)(object)EnvMan.instance) || Time.time < nextTick) { return; } nextTick = Time.time + 0.2f; if (Progress == null) { if (!ZDOMan.instance.GetAllZDOsWithPrefabIterative("TravelingMerchantProgress", records, ref scanIndex)) { return; } Progress = records.FirstOrDefault(); if (Progress == null) { Progress = ZDOMan.instance.CreateNewZDO(Vector3.zero, StringExtensionMethods.GetStableHashCode("TravelingMerchantProgress")); Progress.SetPrefab(StringExtensionMethods.GetStableHashCode("TravelingMerchantProgress")); Progress.Persistent = true; } collected.UnionWith(Progress.GetString("tm.seen", "").Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries)); List<ZDO> list = new List<ZDO>(); int num = 0; while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative("TravelingMerchantNPC", list, ref num)) { } Active = ((IEnumerable<ZDO>)list).FirstOrDefault((Func<ZDO, bool>)((ZDO z) => z.GetBool("tm.beedle", false))); foreach (ZDO item in list.Where((ZDO z) => z != Active)) { ZDOMan.instance.DestroyZDO(item); } ReconcileProgress(Progress); Progress.Set("tm.legacyImported", true); Progress.Set("tm.legacySeedsImported", true); MerchantLegacyProgress.Begin(Progress); } Progress.SetOwner(ZDOMan.GetSessionID()); MerchantCatalogMigration.Tick(Progress); if (!Progress.GetBool("tm.legacyImported", false) || !Progress.GetBool("tm.legacySeedsImported", false)) { MerchantLegacyProgress.Tick(Progress); } bool flag = EnvMan.instance.IsTimeSkipping(); if (Active == null) { skippingTime = flag; return; } Active.SetOwner(ZDOMan.GetSessionID()); if (Active.GetBool("tm.beedle", false)) { TickBeedle(); return; } float num2 = MerchantMotion.SpeedFor(Active); if (!OldEnough) { ZDOMan.instance.DestroyZDO(Active); Active = null; return; } if (flag || skippingTime) { ZDOMan.instance.DestroyZDO(Active); Active = null; skippingTime = flag; return; } skippingTime = false; double num3 = Active.GetFloat("tm.leave", 0f); if (num3 == 0.0 && (Now >= (double)Active.GetFloat("tm.sitUntil", float.MaxValue) || ZDOMan.instance.GetZDO(Active.GetZDOID("tm.chair")) == null)) { float num4 = (float)(Now - (double)Active.GetFloat("tm.start", 0f)) - Active.GetFloat("tm.pause", 0f); if (num4 < Active.GetFloat("tm.walk", 0f)) { Retreat(ReadPath(Active), Mathf.Max(0f, num4) * num2); return; } Active.Set("tm.pause", 0f); Active.Set("tm.paused", false); Active.Set("tm.leave", (float)Now); num3 = Now; } if (num3 == 0.0) { CheckToasts(); } if (num3 == 0.0) { Active.Set("tm.cold", EnvMan.IsCold()); } List<Vector3> list2 = ReadPath(Active); if (list2.Count < 2) { ZDOMan.instance.DestroyZDO(Active); Active = null; return; } float num5 = Active.GetFloat("tm.walk", 0f); float num6 = (Active.GetBool("tm.abort", false) ? Active.GetFloat("tm.returnDelay", 2.4f) : MerchantMotion.DepartureFor(Active)); float num7 = Active.GetFloat("tm.pause", 0f); float num8 = (float)(Now - (double)Active.GetFloat("tm.start", 0f)) - num7; float num9 = (float)(Now - num3) - num7; if (num3 > 0.0 && num9 > num6 + num5 + 2f) { ZDOMan.instance.DestroyZDO(Active); Active = null; return; } bool flag2 = ((num3 > 0.0) ? (num9 >= num6) : (num8 < num5)); float distance = ((num3 > 0.0) ? (Mathf.Max(0f, num9 - num6) * num2) : (Mathf.Max(0f, num8) * num2)); List<Vector3> list3 = new List<Vector3>(list2); if (num3 > 0.0) { list3.Reverse(); } Vector3 forward; Vector3 val = Along(list3, distance, out forward); if (num3 == 0.0 && num8 > num5 + MerchantMotion.SetupFor(Active)) { val = Active.GetVec3("tm.seat", val); } float num10 = (float)Now; float num11 = Mathf.Clamp(num10 - Active.GetFloat("tm.tickAt", num10 - 0.2f), 0f, 1f); Active.Set("tm.tickAt", num10); if (!flag2 && num3 == 0.0 && num8 >= num5 && !MerchantNavigation.Clear(list2.Last(), Active.GetVec3("tm.seat", list2.Last()))) { Retreat(list2, num5 * num2); } else if (flag2 && (!MerchantNavigation.Clear(Active.GetPosition(), val) || (num3 == 0.0 && !MerchantNavigation.Clear(list2.Last(), Active.GetVec3("tm.seat", list2.Last()))))) { if (!Active.GetBool("tm.paused", false)) { if (Plugin.Diagnostics.Value) { Plugin.Instance.LoggerForServer($"Blocked: from={Active.GetPosition()} to={val} age={num8} departure={num9} walk={num5} route={list2.Count} blocker={MerchantNavigation.Blocker(Active.GetPosition(), val)}"); } Active.Set("tm.paused", true); Active.Set("tm.waitStart", num10); Active.Set("tm.pausePosition", Active.GetPosition()); } Active.Set("tm.pause", num7 + num11); if (num3 == 0.0) { Active.Set("tm.sitUntil", Active.GetFloat("tm.sitUntil", 0f) + num11); } if (Now >= (double)Active.GetFloat("tm.repathAt", 0f)) { Active.Set("tm.repathAt", num10 + 1f); Vector3 end = ((num3 > 0.0) ? Active.GetVec3("tm.home", list2[0]) : list2.Last()); if (MerchantNavigation.Find(Active.GetPosition(), end, out List<Vector3> path)) { float num12 = ((num3 > 0.0) ? (num9 - num11 - (Active.GetBool("tm.abort", false) ? num6 : (12.4f + 2f * Active.GetFloat("tm.transfer", 0f)))) : Mathf.Max(0f, num8 - num11)); Active.Set("tm.gaitOffset", Mathf.Repeat(num12 + Active.GetFloat("tm.gaitOffset", 0f), 1.8f)); if (num3 == 0.0) { List<Vector3> list4 = ReadPoints(Active, "tm.trail"); List<Vector3> source = MerchantNavigation.Traversed(list2, Mathf.Max(0f, num8 - num11) * num2); list4.AddRange(source.Skip((list4.Count > 0) ? 1 : 0)); WritePoints(Active, "tm.trail", list4); Active.Set("tm.start", num10); Active.Set("tm.sitUntil", num10 + MerchantNavigation.Length(path) / num2 + MerchantMotion.SetupFor(Active) + VisitLength()); } else { path.Reverse(); Active.Set("tm.abort", true); Active.Set("tm.returnDelay", 0f); Active.Set("tm.leave", num10); } ReplaceRoute(Active, path); Active.Set("tm.pause", 0f); Active.Set("tm.paused", false); return; } } if (Now - (double)Active.GetFloat("tm.waitStart", 0f) >= 4.0) { if (num3 > 0.0) { ZDOMan.instance.DestroyZDO(Active); Active = null; } else { Retreat(list2, Mathf.Max(0f, num8 - num11) * num2); } } } else { if (Active.GetBool("tm.paused", false)) { Active.Set("tm.paused", false); Active.Set("tm.waitStart", 0f); } if (num3 == 0.0 && !Active.GetBool("tm.abort", false) && Active.GetFloat("tm.musicAt", 0f) == 0f && Vector3.Distance(val, Active.GetVec3("tm.seat", val)) <= 4f) { Active.Set("tm.musicAt", (float)Now); } Active.SetPosition(val); if (((Vector3)(ref forward)).sqrMagnitude > 0.001f) { Active.SetRotation(Quaternion.LookRotation(forward)); } } } internal static void ReconcileProgress(ZDO progress) { foreach (string item in MerchantEconomy.Stock.Select(MerchantEconomy.Resource).Distinct()) { if (item != "Bronze" && MerchantEconomy.Key(item) != "" && progress.GetInt("tm.harvest.count." + item, 0) >= MerchantEconomy.Required(item)) { ZoneSystem.instance.SetGlobalKey(MerchantEconomy.Key(item)); } } if (MerchantEconomy.Unlocked("Copper") && MerchantEconomy.Unlocked("Tin")) { ZoneSystem.instance.SetGlobalKey(MerchantEconomy.Key("Bronze")); } } private static float VisitLength() { return Plugin.VisitDuration.Value; } private static void WritePoints(ZDO data, string key, List<Vector3> points) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); val.Write(points.Count); foreach (Vector3 point in points) { val.Write(point); } data.Set(key, val.GetArray()); } private static List<Vector3> ReadPoints(ZDO data, string key) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); byte[] byteArray = data.GetByteArray(key, (byte[])null); if (byteArray == null) { return list; } ZPackage val = new ZPackage(byteArray); int num = val.ReadInt(); if (num < 1 || num > 128) { return list; } for (int i = 0; i < num; i++) { list.Add(val.ReadVector3()); } return list; } private static void ReplaceRoute(ZDO data, List<Vector3> route) { WritePoints(data, "tm.path", route); data.Set("tm.walk", MerchantNavigation.Length(route) / MerchantMotion.SpeedFor(data)); data.Set("tm.routeRevision", data.GetInt("tm.routeRevision", 0) + 1); } private static void Retreat(List<Vector3> path, float travelled) { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if (Active != null) { if (Plugin.Diagnostics.Value) { Plugin.Instance.LoggerForServer($"Retreat: travelled={travelled} position={Active.GetPosition()}"); } Vector3 position = Active.GetPosition(); List<Vector3> list = ReadPoints(Active, "tm.trail"); List<Vector3> source = MerchantNavigation.Traversed(path, travelled); list.AddRange(source.Skip((list.Count > 0) ? 1 : 0)); if (list.Count == 0) { list.Add(position); } if (Vector3.Distance(list.Last(), position) > 0.01f) { list.Add(position); } if (MerchantNavigation.Find(position, Active.GetVec3("tm.home", list[0]), out List<Vector3> path2)) { path2.Reverse(); list = path2; } if (list.Count < 2) { ZDOMan.instance.DestroyZDO(Active); Active = null; return; } ReplaceRoute(Active, list); Active.Set("tm.abort", true); Active.Set("tm.returnDelay", 2.4f); Active.Set("tm.leave", (float)Now); Active.Set("tm.pause", 0f); Active.Set("tm.paused", false); Active.Set("tm.waitStart", 0f); } } private static void Camp(long sender, ZPackage pkg) { } private static void CheckToasts() { //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_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) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0151: Unknown result type (might be due to invalid IL or missing references) if (Active == null) { return; } bool flag = Now - (double)Active.GetFloat("tm.start", 0f) >= (double)(Active.GetFloat("tm.walk", 0f) + MerchantMotion.SetupFor(Active)); foreach (PlayerInfo player in ZNet.instance.GetPlayerList()) { ZDO zDO = ZDOMan.instance.GetZDO(player.m_characterID); if (zDO == null) { continue; } int num = zDO.GetInt(ZDOVars.s_emoteID, 0); if (!emotes.TryGetValue(zDO.m_uid, out var value) || value != num) { int num2 = zDO.GetInt(ZDOVars.s_rightItem, 0); if (flag && !(zDO.GetString(ZDOVars.s_emote, "") != "toast") && (num2 == StringExtensionMethods.GetStableHashCode("Tankard") || num2 == StringExtensionMethods.GetStableHashCode("TankardAnniversary")) && !(Vector3.Distance(zDO.GetPosition(), Active.GetVec3("tm.seat", Active.GetPosition())) > 8f) && !(Now - (double)Active.GetFloat("tm.toast", -100f) < 5.0)) { emotes[zDO.m_uid] = num; Active.Set("tm.toast", (float)(Now + 0.3)); } } } } internal static List<Vector3> ReadPath(ZDO z) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); byte[] byteArray = z.GetByteArray("tm.path", (byte[])null); if (byteArray == null) { return list; } ZPackage val = new ZPackage(byteArray); int num = val.ReadInt(); if (num < 2 || num > 128) { return list; } for (int i = 0; i < num; i++) { list.Add(val.ReadVector3()); } return list; } internal static Vector3 Along(List<Vector3> path, float distance, out Vector3 forward) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_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_009b: 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_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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) Vector3 val2; for (int i = 1; i < path.Count; i++) { Vector3 val = path[i] - path[i - 1]; float magnitude = ((Vector3)(ref val)).magnitude; if (distance <= magnitude) { val2 = Vector3.ProjectOnPlane(val, Vector3.up); forward = ((Vector3)(ref val2)).normalized; return Vector3.Lerp(path[i - 1], path[i], (magnitude > 0.001f) ? (distance / magnitude) : 1f); } distance -= magnitude; } val2 = Vector3.ProjectOnPlane(path[path.Count - 1] - path[path.Count - 2], Vector3.up); forward = ((Vector3)(ref val2)).normalized; return path.Last(); } private static bool Finite(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) if (!float.IsNaN(v.x) && !float.IsNaN(v.y) && !float.IsNaN(v.z) && !float.IsInfinity(v.x) && !float.IsInfinity(v.y)) { return !float.IsInfinity(v.z); } return false; } private unsafe static void Found(long sender, ZPackage pkg) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer() || Progress == null) { return; } try { ZDO val = PlayerFor(sender); ZDOID val2 = pkg.ReadZDOID(); string text = pkg.ReadString(); int num = pkg.ReadInt(); Vector3 val3 = pkg.ReadVector3(); bool flag = pkg.ReadBool(); if (val == null || !MerchantEconomy.Tracked(text) || num < 1 || num > 10000 || !Finite(val3) || Vector3.Distance(val.GetPosition(), val3) > 8f || MerchantEconomy.IsRefinedMetal(text) || (MerchantEconomy.NeedsMining(text) && !flag)) { return; } text = MerchantEconomy.Resource(text); int num2 = MerchantEconomy.Required(text); if (MerchantEconomy.Key(text) == "" || Progress.GetInt("tm.harvest.count." + text, 0) >= num2) { return; } string item = ((object)(*(ZDOID*)(&val2))/*cast due to .constrained prefix*/).ToString(); if (!(val2 == ZDOID.None) && collected.Add(item)) { int num3 = Math.Min(num2, Progress.GetInt("tm.harvest.count." + text, 0) + num); Progress.Set("tm.harvest.count." + text, num3); if (num3 >= num2) { ZoneSystem.instance.SetGlobalKey(MerchantEconomy.Key(text)); } if (MerchantEconomy.Unlocked("Copper") && MerchantEconomy.Unlocked("Tin")) { ZoneSystem.instance.SetGlobalKey(MerchantEconomy.Key("Bronze")); } Progress.Set("tm.seen", string.Join("|", collected)); } } catch (Exception ex) { Plugin.Instance.LoggerForServer("Rejected collection request: " + ex.Message); } } } internal static class BeedleGround { private static readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[48]; private static int Mask => LayerMask.GetMask(new string[5] { "terrain", "piece", "Default", "static_solid", "Default_small" }); internal static bool Surface(Vector3 point, float reference, out float height, out Vector3 normal) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) height = float.NegativeInfinity; normal = Vector3.up; int num = Physics.RaycastNonAlloc(new Vector3(point.x, reference + 2f, point.z), Vector3.down, hits, 7f, Mask, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { RaycastHit val = hits[i]; Collider collider = ((RaycastHit)(ref val)).collider; if (Object.op_Implicit((Object)(object)collider) && !(((RaycastHit)(ref val)).normal.y < 0.65f) && !(((RaycastHit)(ref val)).point.y < reference - 4f) && (((Component)collider).gameObject.layer == LayerMask.NameToLayer("terrain") || !(((RaycastHit)(ref val)).point.y > reference + 0.45f)) && !Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<MerchantBody>()) && !Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<Character>()) && !Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<ItemDrop>()) && !Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<Fireplace>()) && ((RaycastHit)(ref val)).point.y > height) { height = ((RaycastHit)(ref val)).point.y; normal = ((RaycastHit)(ref val)).normal; } } if (!float.IsNegativeInfinity(height)) { return true; } float num2 = default(float); if (Object.op_Implicit((Object)(object)ZoneSystem.instance) && ZoneSystem.instance.GetGroundHeight(point, ref num2) && num2 <= reference + 0.45f && num2 >= reference - 4f) { height = num2; return true; } height = reference; return false; } internal static float Height(Vector3 point, float reference) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (!Surface(point, reference, out var height, out var _)) { return reference; } return height; } internal static Quaternion Facing(Vector3 seat, Vector3 fire, Quaternion fallback) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.ProjectOnPlane(fire - seat, Vector3.up); if (!(((Vector3)(ref val)).sqrMagnitude > 0.01f)) { return fallback; } return Quaternion.LookRotation(val); } internal static bool Flat(Vector3 seat, Quaternion facing, out Vector3 grounded, out float spread) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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) grounded = seat; spread = 100f; if (!Surface(seat, seat.y, out var height, out var normal) || normal.y < 0.97f) { return false; } float num = height; float num2 = height; Vector3[] array = (Vector3[])(object)new Vector3[6] { new Vector3(-0.8f, 0f, -0.9f), new Vector3(0.8f, 0f, -0.9f), new Vector3(-0.8f, 0f, 0.45f), new Vector3(0.8f, 0f, 0.45f), new Vector3(0f, 0f, -0.9f), new Vector3(0f, 0f, 0.45f) }; foreach (Vector3 val in array) { if (!Surface(seat + facing * val, height, out var height2, out normal) || normal.y < 0.95f) { return false; } num = Mathf.Min(num, height2); num2 = Mathf.Max(num2, height2); } spread = num2 - num; grounded.y = height; return spread <= 0.16f; } internal static List<Vector3> Seats(ZDO sign, Vector3 anchor) { //IL_0025: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00a1: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) List<(Vector3, float)> list = new List<(Vector3, float)>(); Fireplace[] source = Object.FindObjectsByType<Fireplace>((FindObjectsSortMode)0); for (int i = 0; i < 3; i++) { for (int j = 0; j < 8; j++) { Vector3 point = sign.GetPosition() + sign.GetRotation() * Quaternion.Euler(0f, (float)(j * 45), 0f) * Vector3.forward * (2.5f + (float)i); if (!(Vector3.Distance(point, anchor) < 2.2f) && !source.Any((Fireplace f) => Vector3.Distance(point, ((Component)f).transform.position) < 2.2f)) { Quaternion facing = Facing(point, anchor, sign.GetRotation()); if (Flat(point, facing, out var grounded, out var spread) && MerchantNavigation.Clear(grounded, grounded)) { list.Add((grounded, spread * 20f + (float)i * 0.2f + (float)j * 0.003f)); } } } } return (from c in list orderby c.score select c.point).ToList(); } } public struct BeedlePoseFrame { public float Sitting; public float Tray; public float Reach; public float Distance; public float Time; public float Delta; public float Blink; public float Speech; public bool Walking; } public sealed class BeedlePose { private sealed class ContactPoint { private readonly Transform[] bones; private readonly Vector3[] local; private readonly float[] weights; public Vector3 World { get { //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_004e: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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) Vector3 val = Vector3.zero; for (int i = 0; i < 4; i++) { if (weights[i] > 0f) { val += bones[i].TransformPoint(local[i]) * weights[i]; } } return val; } } public ContactPoint(SkinnedMeshRenderer skin, Vector3 vertex, BoneWeight w, Matrix4x4[] bind) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) int[] array = new int[4] { ((BoneWeight)(ref w)).boneIndex0, ((BoneWeight)(ref w)).boneIndex1, ((BoneWeight)(ref w)).boneIndex2, ((BoneWeight)(ref w)).boneIndex3 }; weights = new float[4] { ((BoneWeight)(ref w)).weight0, ((BoneWeight)(ref w)).weight1, ((BoneWeight)(ref w)).weight2, ((BoneWeight)(ref w)).weight3 }; bones = (Transform[])(object)new Transform[4]; local = (Vector3[])(object)new Vector3[4]; for (int i = 0; i < 4; i++) { bones[i] = skin.bones[array[i]]; local[i] = ((Matrix4x4)(ref bind[array[i]])).MultiplyPoint3x4(vertex); } } } private readonly Transform host; private readonly Transform model; private readonly Transform[] bones; private readonly Vector3[] positions; private readonly Quaternion[] rotations; private readonly Dictionary<string, Transform> rig; private readonly Quaternion tableFrame; private readonly Vector3 tableSurfaceOffset; private readonly Vector3 tableNormalLocal; private readonly Vector3[] palmLocal = (Vector3[])(object)new Vector3[2]; private readonly float tableHalfWidth; private readonly float tableDepth; private readonly Quaternion[] footFrames = (Quaternion[])(object)new Quaternion[2]; private readonly Quaternion[] handFrames = (Quaternion[])(object)new Quaternion[2]; private readonly Quaternion[] toeFrames = (Quaternion[])(object)new Quaternion[2]; private readonly ContactPoint[][] soles = new ContactPoint[2][]; private readonly ContactPoint[] packBottom; private readonly float[] ankleAboveSole = new float[2]; private readonly Vector3[] planted = (Vector3[])(object)new Vector3[2]; private readonly Vector3[] swingStart = (Vector3[])(object)new Vector3[2]; private readonly bool[] wasStance = new bool[2]; private bool walkingLast; private float walkBlend; private readonly SkinnedMeshRenderer cloth; private readonly SkinnedMeshRenderer tableWood; private readonly Mesh bodyRenderMesh; private readonly Mesh trayRenderMesh; public float HandContactError { get; private set; } public float TableSlope { get; private set; } public float BlinkAmount { get; private set; } public float SpeechAmount { get; private set; } public float LeftSole { get; private set; } public float RightSole { get; private set; } public float TableGap { get; private set; } public void Dispose() { Object.Destroy((Object)(object)bodyRenderMesh); Object.Destroy((Object)(object)trayRenderMesh); } public Transform Bone(string name) { return rig[name]; } private ContactPoint[] Bottom(SkinnedMeshRenderer skin, Func<string, bool> group) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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) BoneWeight[] boneWeights = skin.sharedMesh.boneWeights; Vector3[] vertices = skin.sharedMesh.vertices; Matrix4x4[] bindposes = skin.sharedMesh.bindposes; List<ContactPoint> list = new List<ContactPoint>(); for (int i = 0; i < boneWeights.Length; i++) { BoneWeight w = boneWeights[i]; float num = 0f; if (group(((Object)skin.bones[((BoneWeight)(ref w)).boneIndex0]).name)) { num += ((BoneWeight)(ref w)).weight0; } if (group(((Object)skin.bones[((BoneWeight)(ref w)).boneIndex1]).name)) { num += ((BoneWeight)(ref w)).weight1; } if (group(((Object)skin.bones[((BoneWeight)(ref w)).boneIndex2]).name)) { num += ((BoneWeight)(ref w)).weight2; } if (group(((Object)skin.bones[((BoneWeight)(ref w)).boneIndex3]).name)) { num += ((BoneWeight)(ref w)).weight3; } if (num > 0.65f) { list.Add(new ContactPoint(skin, vertices[i], w, bindposes)); } } if (list.Count == 0) { throw new InvalidOperationException("Missing contact vertices: " + ((Object)skin).name); } float min = list.Min((ContactPoint p) => p.World.y); ContactPoint[] low = (from p in list where p.World.y < min + 0.008f orderby p.World.z select p).ToArray(); if (low.Length <= 16) { return low; } return (from num2 in Enumerable.Range(0, 16) select low[num2 * (low.Length - 1) / 15]).ToArray(); } public BeedlePose(Transform host, Transform model) { //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0372: 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_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_06e5: Expected O, but got Unknown //IL_077c: Unknown result type (might be due to invalid IL or missing references) //IL_080a: Unknown result type (might be due to invalid IL or missing references) //IL_0851: Unknown result type (might be due to invalid IL or missing references) //IL_0856: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_0862: Unknown result type (might be due to invalid IL or missing references) //IL_0867: Unknown result type (might be due to invalid IL or missing references) //IL_087a: Unknown result type (might be due to invalid IL or missing references) //IL_087f: Unknown result type (might be due to invalid IL or missing references) //IL_08a0: Unknown result type (might be due to invalid IL or missing references) //IL_08a5: Unknown result type (might be due to invalid IL or missing references) //IL_08aa: Unknown result type (might be due to invalid IL or missing references) //IL_08f3: Unknown result type (might be due to invalid IL or missing references) //IL_08f8: Unknown result type (might be due to invalid IL or missing references) //IL_0902: Unknown result type (might be due to invalid IL or missing references) //IL_0907: Unknown result type (might be due to invalid IL or missing references) //IL_0928: Unknown result type (might be due to invalid IL or missing references) //IL_092f: Unknown result type (might be due to invalid IL or missing references) //IL_0934: Unknown result type (might be due to invalid IL or missing references) //IL_0939: Unknown result type (might be due to invalid IL or missing references) //IL_093d: Unknown result type (might be due to invalid IL or missing references) //IL_0942: Unknown result type (might be due to invalid IL or missing references) //IL_0960: Unknown result type (might be due to invalid IL or missing references) //IL_0981: Unknown result type (might be due to invalid IL or missing references) //IL_0986: Unknown result type (might be due to invalid IL or missing references) //IL_098b: Unknown result type (might be due to invalid IL or missing references) //IL_098d: Unknown result type (might be due to invalid IL or missing references) //IL_098f: Unknown result type (might be due to invalid IL or missing references) //IL_0991: Unknown result type (might be due to invalid IL or missing references) //IL_0996: Unknown result type (might be due to invalid IL or missing references) //IL_099a: Unknown result type (might be due to invalid IL or missing references) //IL_09a8: Unknown result type (might be due to invalid IL or missing references) //IL_09ad: Unknown result type (might be due to invalid IL or missing references) //IL_09b9: Unknown result type (might be due to invalid IL or missing references) //IL_09bb: Unknown result type (might be due to invalid IL or missing references) //IL_09c2: Unknown result type (might be due to invalid IL or missing references) //IL_09c4: Unknown result type (might be due to invalid IL or missing references) //IL_09c9: Unknown result type (might be due to invalid IL or missing references) //IL_09ce: Unknown result type (might be due to invalid IL or missing references) BeedlePose beedlePose = this; this.host = host; this.model = model; bones = ((Component)model).GetComponentsInChildren<Transform>(); positions = bones.Select((Transform t) => t.localPosition).ToArray(); rotations = bones.Select((Transform t) => t.localRotation).ToArray(); rig = (from t in bones group t by ((Object)t).name).ToDictionary((IGrouping<string, Transform> g) => g.Key, (IGrouping<string, Transform> g) => g.First()); SkinnedMeshRenderer val = ((Component)model).GetComponentsInChildren<SkinnedMeshRenderer>().First((SkinnedMeshRenderer x) => ((Object)x).name == "Flyer__Mt_BackPack_02"); Mesh sharedMesh = val.sharedMesh; BoneWeight[] boneWeights = sharedMesh.boneWeights; Vector3[] vertices = sharedMesh.vertices; Matrix4x4[] bindposes = sharedMesh.bindposes; List<ContactPoint> list = new List<ContactPoint>(); for (int num = 0; num < boneWeights.Length; num++) { if (((Object)val.bones[((BoneWeight)(ref boneWeights[num])).boneIndex0]).name == "TableTop" && ((BoneWeight)(ref boneWeights[num])).weight0 > 0.6f) { list.Add(new ContactPoint(val, vertices[num], boneWeights[num], bindposes)); } } Vector3[] source = list.Select((ContactPoint x) => host.InverseTransformDirection(x.World - beedlePose.rig["TableTop"].position)).ToArray(); float cy = source.Average((Vector3 x) => x.y); float cz = source.Average((Vector3 x) => x.z); float num2 = source.Sum((Vector3 x) => (x.y - cy) * (x.y - cy)); float num3 = source.Sum((Vector3 x) => (x.z - cz) * (x.z - cz)); float num4 = source.Sum((Vector3 x) => (x.y - cy) * (x.z - cz)); float num5 = 0.5f * Mathf.Atan2(2f * num4, num3 - num2) * 57.29578f; Quaternion correction = Quaternion.AngleAxis(num5, Vector3.right); tableNormalLocal = Quaternion.Inverse(rig["TableTop"].rotation) * host.rotation * (Quaternion.AngleAxis(0f - num5, Vector3.right) * Vector3.up); tableFrame = correction * Quaternion.Inverse(host.rotation) * rig["TableTop"].rotation; Vector3[] source2 = source.Select((Vector3 x) => correction * x).ToArray(); tableHalfWidth = (source2.Max((Vector3 x) => x.x) - source2.Min((Vector3 x) => x.x)) * 0.5f; tableDepth = source2.Max((Vector3 x) => x.z) - source2.Min((Vector3 x) => x.z); tableSurfaceOffset = new Vector3(0f, source2.Max((Vector3 x) => x.y), (source2.Min((Vector3 x) => x.z) + source2.Max((Vector3 x) => x.z)) * 0.5f); SkinnedMeshRenderer[] componentsInChildren = ((Component)model).GetComponentsInChildren<SkinnedMeshRenderer>(); SkinnedMeshRenderer[] array = componentsInChildren; for (int num6 = 0; num6 < array.Length; num6++) { array[num6].quality = (SkinQuality)4; } SkinnedMeshRenderer skin = componentsInChildren.First((SkinnedMeshRenderer s) => ((Object)s).name == "Belt__Mt_Body"); cloth = componentsInChildren.First((SkinnedMeshRenderer s) => ((Object)s).name == "Flyer__Mt_BackPack_02"); packBottom = Bottom(componentsInChildren.First((SkinnedMeshRenderer s) => ((Object)s).name == "Base_1__Mt_BackPack"), (string n) => n.StartsWith("BackPack", StringComparison.Ordinal)); SkinnedMeshRenderer packSkin = componentsInChildren.First((SkinnedMeshRenderer x) => ((Object)x).name == "Base_1__Mt_BackPack"); Mesh sharedMesh2 = packSkin.sharedMesh; BoneWeight[] weights = sharedMesh2.boneWeights; int[] triangles = sharedMesh2.triangles; List<int> list2 = new List<int>(); List<int> list3 = new List<int>(); for (int num7 = 0; num7 < triangles.Length; num7 += 3) { List<int> obj = ((OnTray(triangles[num7]) || OnTray(triangles[num7 + 1]) || OnTray(triangles[num7 + 2])) ? list3 : list2); obj.Add(triangles[num7]); obj.Add(triangles[num7 + 1]); obj.Add(triangles[num7 + 2]); } Mesh val2 = Object.Instantiate<Mesh>(sharedMesh2); val2.triangles = list2.ToArray(); packSkin.sharedMesh = val2; bodyRenderMesh = val2; Mesh val3 = Object.Instantiate<Mesh>(sharedMesh2); val3.triangles = list3.ToArray(); trayRenderMesh = val3; GameObject val4 = new GameObject("BeedleTrayFrame"); val4.layer = ((Component)packSkin).gameObject.layer; val4.transform.SetParent(((Component)packSkin).transform, false); tableWood = val4.AddComponent<SkinnedMeshRenderer>(); tableWood.sharedMesh = val3; tableWood.bones = packSkin.bones; tableWood.rootBone = packSkin.rootBone; ((Renderer)tableWood).sharedMaterials = ((Renderer)packSkin).sharedMaterials; ((Renderer)tableWood).localBounds = ((Renderer)packSkin).localBounds; tableWood.quality = (SkinQuality)4; tableWood.updateWhenOffscreen = true; for (int num8 = 0; num8 < 2; num8++) { string suffix = ((num8 == 0) ? "L" : "R"); soles[num8] = Bottom(skin, (string n) => n == "Ankle_" + suffix || n == "Toe_" + suffix); Transform val5 = rig["Ankle_" + suffix]; ankleAboveSole[num8] = val5.position.y - soles[num8].Min((ContactPoint p) => p.World.y); footFrames[num8] = Quaternion.Inverse(host.rotation) * val5.rotation; toeFrames[num8] = Quaternion.Inverse(host.rotation) * rig["Toe_" + suffix].rotation; Transform val6 = rig["Wrist_" + suffix]; palmLocal[num8] = val6.InverseTransformPoint(rig["Finger_C_1_" + suffix].position) * 0.65f; Vector3 val7 = rig["Finger_C_1_" + suffix].position - val6.position; Vector3 normalized = ((Vector3)(ref val7)).normalized; Vector3 val8 = rig["Finger_B_1_" + suffix].position - rig["Finger_E_1_" + suffix].position; val7 = Vector3.Cross(normalized, val8); Vector3 val9 = ((Vector3)(ref val7)).normalized * (float)((num8 == 0) ? 1 : (-1)); handFrames[num8] = Quaternion.LookRotation(val6.InverseTransformDirection(normalized), val6.InverseTransformDirection(val9)); } bool OnTray(int index) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) BoneWeight val10 = weights[index]; if ((!(((BoneWeight)(ref val10)).weight0 > 0.02f) || !(((Object)packSkin.bones[((BoneWeight)(ref val10)).boneIndex0]).name == "TableTop")) && (!(((BoneWeight)(ref val10)).weight1 > 0.02f) || !(((Object)packSkin.bones[((BoneWeight)(ref val10)).boneIndex1]).name == "TableTop")) && (!(((BoneWeight)(ref val10)).weight2 > 0.02f) || !(((Object)packSkin.bones[((BoneWeight)(ref val10)).boneIndex2]).name == "TableTop"))) { if (((BoneWeight)(ref val10)).weight3 > 0.02f) { return ((Object)packSkin.bones[((BoneWeight)(ref val10)).boneIndex3]).name == "TableTop"; } return false; } return true; } } private static float Ease(float value) { return Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(value)); } public void Apply(BeedlePoseFrame frame, Func<Vector3, float, float> floor) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0702: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_0730: Unknown result type (might be due to invalid IL or missing references) //IL_0735: Unknown result type (might be due to invalid IL or missing references) //IL_073c: Unknown result type (might be due to invalid IL or missing references) //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_076d: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_0787: Unknown result type (might be due to invalid IL or missing references) //IL_0792: Unknown result type (might be due to invalid IL or missing references) //IL_079c: Unknown result type (might be due to invalid IL or missing references) //IL_07a1: Unknown result type (might be due to invalid IL or missing references) //IL_07a6: Unknown result type (might be due to invalid IL or missing references) //IL_07b8: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: Unknown result type (might be due to invalid IL or missing references) //IL_07cd: Unknown result type (might be due to invalid IL or missing references) //IL_07d2: Unknown result type (might be due to invalid IL or missing references) //IL_07dd: Unknown result type (might be due to invalid IL or missing references) //IL_07f4: Unknown result type (might be due to invalid IL or missing references) //IL_07f9: Unknown result type (might be due to invalid IL or missing references) //IL_0804: Unknown result type (might be due to invalid IL or missing references) //IL_080a: Unknown result type (might be due to invalid IL or missing references) //IL_080f: Unknown result type (might be due to invalid IL or missing references) //IL_0814: Unknown result type (might be due to invalid IL or missing references) //IL_0819: Unknown result type (might be due to invalid IL or missing references) //IL_081d: Unknown result type (might be due to invalid IL or missing references) //IL_081f: Unknown result type (might be due to invalid IL or missing references) //IL_0822: Unknown result type (might be due to invalid IL or missing references) //IL_082d: Unknown result type (might be due to invalid IL or missing references) //IL_0844: Unknown result type (might be due to invalid IL or missing references) //IL_0849: Unknown result type (might be due to invalid IL or missing references) //IL_085b: Unknown result type (might be due to invalid IL or missing references) //IL_0861: Unknown result type (might be due to invalid IL or missing references) //IL_0866: Unknown result type (might be due to invalid IL or missing references) //IL_089b: Unknown result type (might be due to invalid IL or missing references) //IL_08a6: Unknown result type (might be due to invalid IL or missing references) //IL_08ac: Unknown result type (might be due to invalid IL or missing references) //IL_08b1: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Unknown result type (might be due to invalid IL or missing references) //IL_08bb: Unknown result type (might be due to invalid IL or missing references) //IL_08be: Unknown result type (might be due to invalid IL or missing references) //IL_08c6: Unknown result type (might be due to invalid IL or missing references) //IL_08d7: Unknown result type (might be due to invalid IL or missing references) //IL_08dc: Unknown result type (might be due to invalid IL or missing references) //IL_08f1: Unknown result type (might be due to invalid IL or missing references) //IL_08f6: Unknown result type (might be due to invalid IL or missing references) //IL_0901: Unknown result type (might be due to invalid IL or missing references) //IL_091d: Unknown result type (might be due to invalid IL or missing references) //IL_0924: Unknown result type (might be due to invalid IL or missing references) //IL_092a: Unknown result type (might be due to invalid IL or missing references) //IL_092f: Unknown result type (might be due to invalid IL or missing references) //IL_0640: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Unknown result type (might be due to invalid IL or missing references) //IL_065a: Unknown result type (might be due to invalid IL or missing references) //IL_0665: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Unknown result type (might be due to invalid IL or missing references) //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06d5: Unknown result type (might be due to invalid IL or missing references) //IL_0ebb: Unknown result type (might be due to invalid IL or missing references) //IL_0ec0: Unknown result type (might be due to invalid IL or missing references) //IL_0ec7: Unknown result type (might be due to invalid IL or missing references) //IL_0ecc: Unknown result type (might be due to invalid IL or missing references) //IL_0ee7: Unknown result type (might be due to invalid IL or missing references) //IL_0ef2: Unknown result type (might be due to invalid IL or missing references) //IL_0f03: Unknown result type (might be due to invalid IL or missing references) //IL_0f08: Unknown result type (might be due to invalid IL or missing references) //IL_0f90: Unknown result type (might be due to invalid IL or missing references) //IL_0f95: Unknown result type (might be due to invalid IL or missing references) //IL_0f9c: Unknown result type (might be due to invalid IL or missing references) //IL_0fa1: Unknown result type (might be due to invalid IL or missing references) //IL_0fc0: Unknown result type (might be due to invalid IL or missing references) //IL_0fc5: Unknown result type (might be due to invalid IL or missing references) //IL_0fcc: Unknown result type (might be due to invalid IL or missing references) //IL_0fd1: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0270: 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_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_098d: Unknown result type (might be due to invalid IL or missing references) //IL_0997: Unknown result type (might be due to invalid IL or missing references) //IL_09a2: Unknown result type (might be due to invalid IL or missing references) //IL_09a9: Unknown result type (might be due to invalid IL or missing references) //IL_09ae: Unknown result type (might be due to invalid IL or missing references) //IL_09b3: Unknown result type (might be due to invalid IL or missing references) //IL_09b7: Unknown result type (might be due to invalid IL or missing references) //IL_09be: Unknown result type (might be due to invalid IL or missing references) //IL_09c9: Unknown result type (might be due to invalid IL or missing references) //IL_09d3: Unknown result type (might be due to invalid IL or missing references) //IL_09d8: Unknown result type (might be due to invalid IL or missing references) //IL_09e3: Unknown result type (might be due to invalid IL or missing references) //IL_09ed: Unknown result type (might be due to invalid IL or missing references) //IL_09f2: Unknown result type (might be due to invalid IL or missing references) //IL_09fd: Unknown result type (might be due to invalid IL or missing references) //IL_0a0a: Unknown result type (might be due to invalid IL or missing references) //IL_0a0f: Unknown result type (might be due to invalid IL or missing references) //IL_0a14: Unknown result type (might be due to invalid IL or missing references) //IL_0a16: Unknown result type (might be due to invalid IL or missing references) //IL_0a1e: Unknown result type (might be due to invalid IL or missing references) //IL_0a32: Unknown result type (might be due to invalid IL or missing references) //IL_0a37: Unknown result type (might be due to invalid IL or missing references) //IL_0a42: Unknown result type (might be due to invalid IL or missing references) //IL_0a5c: Unknown result type (might be due to invalid IL or missing references) //IL_0a61: Unknown result type (might be due to invalid IL or missing references) //IL_0a6c: Unknown result type (might be due to invalid IL or missing references) //IL_0a76: Unknown result type (might be due to invalid IL or missing references) //IL_0a7b: Unknown result type (might be due to invalid IL or missing references) //IL_0a80: Unknown result type (might be due to invalid IL or missing references) //IL_0a88: Unknown result type (might be due to invalid IL or missing references) //IL_0a92: Unknown result type (might be due to invalid IL or missing references) //IL_0a9d: Unknown result type (might be due to invalid IL or missing references) //IL_0aa2: Unknown result type (might be due to invalid IL or missing references) //IL_0aa7: Unknown result type (might be due to invalid IL or missing references) //IL_0aab: Unknown result type (might be due to invalid IL or missing references) //IL_0ab1: Unknown result type (might be due to invalid IL or missing references) //IL_0ab6: Unknown result type (might be due to invalid IL or missing references) //IL_0aba: Unknown result type (might be due to invalid IL or missing references) //IL_0abf: Unknown result type (might be due to invalid IL or missing references) //IL_0ac7: Unknown result type (might be due to invalid IL or missing references) //IL_0acc: Unknown result type (might be due to invalid IL or missing references) //IL_0ad7: Unknown result type (might be due to invalid IL or missing references) //IL_0adc: Unknown result type (might be due to invalid IL or missing references) //IL_0ae3: Unknown result type (might be due to invalid IL or missing references) //IL_0ae9: Unknown result type (might be due to invalid IL or missing references) //IL_0aee: Unknown result type (might be due to invalid IL or missing references) //IL_0af2: Unknown result type (might be due to invalid IL or missing references) //IL_0af7: Unknown result type (might be due to invalid IL or missing references) //IL_0af9: Unknown result type (might be due to invalid IL or missing references) //IL_0afb: Unknown result type (might be due to invalid IL or missing references) //IL_0afd: Unknown result type (might be due to invalid IL or missing references) //IL_0b02: Unknown result type (might be due to invalid IL or missing references) //IL_0b06: Unknown result type (might be due to invalid IL or missing references) //IL_0b0b: Unknown result type (might be due to invalid IL or missing references) //IL_0b0d: Unknown result type (might be due to invalid IL or missing references) //IL_0b0f: Unknown result type (might be due to invalid IL or missing references) //IL_0b11: Unknown result type (might be due to invalid IL or missing references) //IL_0b1e: Unknown result type (might be due to invalid IL or missing references) //IL_0b23: Unknown result type (might be due to invalid IL or missing references) //IL_0b28: Unknown result type (might be due to invalid IL or missing references) //IL_0b2d: Unknown result type (might be due to invalid IL or missing references) //IL_0b2f: Unknown result type (might be due to invalid IL or missing references) //IL_0b31: Unknown result type (might be due to invalid IL or missing references) //IL_0b34: Unknown result type (might be due to invalid IL or missing references) //IL_0b39: Unknown result type (might be due to invalid IL or missing references) //IL_0b54: Unknown result type (might be due to invalid IL or missing references) //IL_0b56: Unknown result type (might be due to invalid IL or missing references) //IL_0b60: Unknown result type (might be due to invalid IL or missing references) //IL_0b67: Unknown result type (might be due to invalid IL or missing references) //IL_0b6c: Unknown result type (might be due to invalid IL or missing references) //IL_0b71: Unknown result type (might be due to invalid IL or missing references) //IL_0b76: Unknown result type (might be due to invalid IL or missing references) //IL_0b7b: Unknown result type (might be due to invalid IL or missing references) //IL_0b98: Unknown result type (might be due to invalid IL or missing references) //IL_0b9c: Unknown result type (might be due to invalid IL or missing references) //IL_0ba7: Unknown result type (might be due to invalid IL or missing references) //IL_0bb4: Unknown result type (might be due to invalid IL or missing references) //IL_0bb9: Unknown result type (might be due to invalid IL or missing references) //IL_0bc4: Unknown result type (might be due to invalid IL or missing references) //IL_0bce: Unknown result type (might be due to invalid IL or missing references) //IL_0bd3: Unknown result type (might be due to invalid IL or missing references) //IL_0bde: Unknown result type (might be due to invalid IL or missing references) //IL_0be8: Unknown result type (might be due to invalid IL or missing references) //IL_0bed: Unknown result type (might be due to invalid IL or missing references) //IL_0bf9: Unknown result type (might be due to invalid IL or missing references) //IL_0c11: Unknown result type (might be due to invalid IL or missing references) //IL_0c16: Unknown result type (might be due to invalid IL or missing references) //IL_0c1b: Unknown result type (might be due to invalid IL or missing references) //IL_0c2c: Unknown result type (might be due to invalid IL or missing references) //IL_0c2e: Unknown result type (might be due to invalid IL or missing references) //IL_0c30: Unknown result type (might be due to invalid IL or missing references) //IL_0c35: Unknown result type (might be due to invalid IL or missing references) //IL_0c39: Unknown result type (might be due to invalid IL or missing references) //IL_0c3e: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing ref