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 DynamicPlatforms Elevators v0.2.0
plugins/DynamicPlatforms/DynamicPlatforms.dll
Decompiled 6 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using DynamicMotionShared; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.TextCore.LowLevel; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("DynamicPlatforms")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0")] [assembly: AssemblyProduct("DynamicPlatforms Elevators")] [assembly: AssemblyTitle("DynamicPlatforms")] [assembly: AssemblyVersion("0.2.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DynamicMotionShared { internal static class ControlFaceOrder { internal static int For(string part) { return part switch { "Text" => 40, "TravelArrow" => 35, "Readout" => 20, "InsetAndFixings" => 12, "BronzeTrim" => 10, "Board" => 0, _ => 30, }; } } internal static class ControlSignBinding { internal static TMP_Text Text(GameObject root) { return ((IEnumerable<TMP_Text>)root.GetComponentsInChildren<TMP_Text>(true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => !Object.op_Implicit((Object)(object)((Component)t).GetComponentInParent<ControlDecoration>()))); } internal static Collider Solid(GameObject root, Transform stale) { return ((IEnumerable<Collider>)root.GetComponentsInChildren<Collider>(true)).FirstOrDefault((Func<Collider, bool>)((Collider c) => !c.isTrigger && (!Object.op_Implicit((Object)(object)stale) || !((Component)c).transform.IsChildOf(stale)))); } } internal static class EditorBranding { internal const string ResourceName = "DynamicPlatforms.EditorIcon.png"; private static Sprite sprite; private static Texture2D texture; private static bool attempted; internal static bool Apply(Image image) { //IL_0173: 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_005d: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)image)) { return false; } if (!attempted) { attempted = true; try { using Stream stream = typeof(EditorBranding).Assembly.GetManifestResourceStream("DynamicPlatforms.EditorIcon.png"); using MemoryStream memoryStream = new MemoryStream(); if (stream == null) { throw new InvalidDataException("Editor icon resource is missing."); } stream.CopyTo(memoryStream); texture = new Texture2D(2, 2, (TextureFormat)4, false); ((Object)texture).name = "DynamicPlatformsEditorIcon"; if (!AssetUtils.LoadImage(texture, memoryStream.ToArray())) { throw new InvalidDataException("Editor icon is not a valid image."); } texture.Apply(false, true); ((Texture)texture).wrapMode = (TextureWrapMode)1; ((Texture)texture).filterMode = (FilterMode)1; sprite = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f)); ((Object)sprite).name = "DynamicPlatformsEditorIcon"; } catch (Exception ex) { if (Object.op_Implicit((Object)(object)texture)) { Object.Destroy((Object)(object)texture); } texture = null; Logger.LogWarning((object)("Could not load editor artwork: " + ex.Message)); } } if (!Object.op_Implicit((Object)(object)sprite)) { return false; } image.sprite = sprite; image.type = (Type)0; image.preserveAspect = true; ((Graphic)image).color = Color.white; ((Graphic)image).raycastTarget = false; return true; } internal static void Release() { if (Object.op_Implicit((Object)(object)sprite)) { Object.Destroy((Object)(object)sprite); } if (Object.op_Implicit((Object)(object)texture)) { Object.Destroy((Object)(object)texture); } sprite = null; texture = null; attempted = false; } } internal sealed class MotionAuthority : MonoBehaviour { private sealed class Route { internal int Prefab; internal Func<ZDO, long, string, ZPackage, string> Validate; } private readonly Dictionary<string, Route> routes = new Dictionary<string, Route>(); private readonly Dictionary<long, float> nextWindow = new Dictionary<long, float>(); private readonly Dictionary<long, int> requests = new Dictionary<long, int>(); private ZRoutedRpc registered; private ZDOMan world; private string requestName; private string noticeName; internal const string PlayerNotReady = "Your character is not ready on the server. Wait until you have spawned, then try again."; internal static MotionAuthority Instance { get; private set; } internal static long ServerId { get { if (!((Object)(object)ZNet.instance == (Object)null)) { if (!ZNet.instance.IsServer()) { return ZNet.instance.GetServerPeer()?.m_uid ?? 0; } return ZDOMan.GetSessionID(); } return 0L; } } internal static bool Finite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } internal static bool Finite(Vector3 value) { //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) if (Finite(value.x) && Finite(value.y)) { return Finite(value.z); } return false; } internal static float ReadFloat(ZPackage body) { float num = body.ReadSingle(); if (!Finite(num)) { throw new InvalidOperationException("A finite number is required."); } return num; } internal static bool StampMembers(string command, ZPackage body, int count) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(command); val.Write(0L); switch (command) { case "build": val.Write(body.ReadBool()); break; case "config": val.Write(body.ReadString()); val.Write(body.ReadString()); break; case "frame": val.Write(body.ReadInt()); val.Write(ReadFloat(body)); val.Write(ReadFloat(body)); break; default: if (command != "measure") { return false; } break; } if (body.Size() != val.Size()) { return false; } body.SetPos(body.Size()); body.Write(count); return true; } internal static bool StampButtonRecovery(ZPackage body, bool missing, bool hasFloor) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown body.SetPos(0); string text = body.ReadString(); long num = body.ReadLong(); ZPackage val = new ZPackage(); val.Write(text); val.Write(num); val.Write(body.ReadString()); if (text == "mode") { val.Write(body.ReadInt()); } else { if (!(text == "link")) { return false; } val.Write(body.ReadString()); if (hasFloor) { val.Write(body.ReadString()); } } if (body.Size() != val.Size()) { return false; } body.SetPos(body.Size()); body.Write(missing); return true; } internal static string MemberSignature(IEnumerable<ZDOID> ids) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); foreach (ZDOID id in ids) { list.Add(((object)id/*cast due to .constrained prefix*/).ToString()); } list.Sort(StringComparer.Ordinal); using SHA256 sHA = SHA256.Create(); return BitConverter.ToString(sHA.ComputeHash(Encoding.UTF8.GetBytes(string.Join("|", list)))).Replace("-", ""); } internal static bool FiniteConfig(string text) { if (string.IsNullOrEmpty(text) || text.Length > 16000) { return false; } HashSet<string> hashSet = new HashSet<string>(); string[] array = text.Split(new char[1] { ';' }); foreach (string text2 in array) { int num = text2.IndexOf('='); if (num <= 0 || !hashSet.Add(text2.Substring(0, num))) { return false; } string text3 = text2.Substring(num + 1); if (text3.Length == 0) { continue; } string[] array2 = text3.Split(new char[1] { ',' }); for (int j = 0; j < array2.Length; j++) { if (!float.TryParse(array2[j], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || !Finite(result)) { return false; } } } return true; } internal void Initialize(string prefix) { Instance = this; requestName = prefix + "_AuthorizedCommand"; noticeName = prefix + "_AuthorityNotice"; } internal void AddRoute(string method, string prefab, Func<ZDO, long, string, ZPackage, string> validate) { routes[method] = new Route { Prefab = StringExtensionMethods.GetStableHashCode(prefab), Validate = validate }; } private void Update() { if (world != ZDOMan.instance) { world = ZDOMan.instance; nextWindow.Clear(); requests.Clear(); } if (registered != ZRoutedRpc.instance && ZRoutedRpc.instance != null && requestName != null) { registered = ZRoutedRpc.instance; registered.Register<ZDOID, string, ZPackage>(requestName, (Action<long, ZDOID, string, ZPackage>)Request); registered.Register<string>(noticeName, (Action<long, string>)Notice); } } internal static void Send(ZNetView view, string method, ZPackage package) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Instance) && Object.op_Implicit((Object)(object)view) && view.IsValid() && ZRoutedRpc.instance != null && ServerId != 0L) { ZRoutedRpc.instance.InvokeRoutedRPC(ServerId, Instance.requestName, new object[3] { view.GetZDO().m_uid, method, package }); } } internal static long PlayerId(long sender) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || ZDOMan.instance == null) { return 0L; } if (sender == ZDOMan.GetSessionID()) { if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return 0L; } return Player.m_localPlayer.GetPlayerID(); } ZNetPeer peer = ZNet.instance.GetPeer(sender); if (peer == null || !peer.IsReady() || peer.m_uid != sender || peer.m_characterID == ZDOID.None) { return 0L; } ZDO zDO = ZDOMan.instance.GetZDO(peer.m_characterID); if (zDO == null || !zDO.IsValid() || zDO.GetOwner() != sender || zDO.GetPrefab() != StringExtensionMethods.GetStableHashCode("Player")) { return 0L; } return zDO.GetLong("playerID", 0L); } private void Request(long sender, ZDOID id, string method, ZPackage body) { //IL_00ee: 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_01a5: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || world == null || body == null || body.Size() > 65536 || !routes.TryGetValue(method, out var value)) { return; } float unscaledTime = Time.unscaledTime; if (!nextWindow.TryGetValue(sender, out var value2) || unscaledTime >= value2) { nextWindow[sender] = unscaledTime + 1f; requests[sender] = 0; } if (++requests[sender] > 60) { return; } long num = PlayerId(sender); if (num == 0L) { ZNetPeer peer = ZNet.instance.GetPeer(sender); if (peer != null && peer.IsReady()) { registered.InvokeRoutedRPC(sender, noticeName, new object[1] { "Your character is not ready on the server. Wait until you have spawned, then try again." }); } return; } ZDO zDO = world.GetZDO(id); if (zDO == null || !zDO.IsValid() || zDO.GetPrefab() != value.Prefab) { return; } try { body.SetPos(0); string arg = body.ReadString(); body.ReadLong(); string text = value.Validate?.Invoke(zDO, num, arg, body); if (!string.IsNullOrEmpty(text)) { registered.InvokeRoutedRPC(sender, noticeName, new object[1] { text }); return; } if (zDO.GetOwner() == 0L) { registered.InvokeRoutedRPC(sender, noticeName, new object[1] { "Visit the structure so its owner can receive this change." }); return; } ZPackage val = new ZPackage(); val.Write(sender); val.Write(num); val.Write(body.GetArray()); registered.InvokeRoutedRPC(zDO.GetOwner(), id, method, new object[1] { val }); } catch (Exception ex) { Logger.LogWarning((object)("Motion command rejected: " + ex.GetBaseException().Message)); } } internal static bool Read(long networkSender, ZPackage envelope, out long caller, out long player, out ZPackage body) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown caller = (player = 0L); body = null; if (networkSender == 0L || networkSender != ServerId || envelope == null || envelope.Size() > 65580) { return false; } try { caller = envelope.ReadLong(); player = envelope.ReadLong(); body = new ZPackage(envelope.ReadByteArray()); return caller != 0L && player != 0; } catch { return false; } } internal static bool DeliverOwner(long caller, long player, ZDO root, string method, ZPackage body) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Instance) || (Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || Instance.registered == null || caller == 0L || player == 0L || root == null || !root.IsValid() || root.GetOwner() == 0L || body == null) { return false; } ZPackage val = new ZPackage(); val.Write(caller); val.Write(player); val.Write(body.GetArray()); Instance.registered.InvokeRoutedRPC(root.GetOwner(), root.m_uid, method, new object[1] { val }); return true; } private void Notice(long sender, string text) { if (sender == ServerId && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ((Character)Player.m_localPlayer).Message((MessageType)2, text, 0, (Sprite)null, false); } } } internal static class SavedMotionWorld { private static readonly FieldInfo Objects = AccessTools.Field(typeof(ZDOMan), "m_objectsByID"); internal static Dictionary<ZDOID, ZDO> ObjectsById { get { if (ZDOMan.instance != null && !(Objects == null)) { return Objects.GetValue(ZDOMan.instance) as Dictionary<ZDOID, ZDO>; } return null; } } internal static bool TryMemberCount(string association, string key, out int count) { count = 0; Dictionary<ZDOID, ZDO> objectsById = ObjectsById; if (objectsById == null || string.IsNullOrEmpty(key) || (Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return false; } foreach (ZDO value in objectsById.Values) { if (value != null && value.IsValid() && value.GetString(association, "") == key) { count++; } } return true; } internal static bool TryMemberIds(string association, string key, out ZDOID[] ids) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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) ids = null; Dictionary<ZDOID, ZDO> objectsById = ObjectsById; if (objectsById == null || string.IsNullOrEmpty(key) || (Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return false; } List<ZDOID> list = new List<ZDOID>(); HashSet<ZDOID> hashSet = new HashSet<ZDOID>(); foreach (ZDO value in objectsById.Values) { if (value != null && value.IsValid() && value.GetString(association, "") == key) { if (value.m_uid == ZDOID.None || !hashSet.Add(value.m_uid)) { return false; } list.Add(value.m_uid); } } ids = list.ToArray(); return true; } internal static ZDO FindRoot(string prefab, string keyName, string key) { Dictionary<ZDOID, ZDO> objectsById = ObjectsById; if (objectsById == null || string.IsNullOrEmpty(key)) { return null; } int stableHashCode = StringExtensionMethods.GetStableHashCode(prefab); ZDO val = null; foreach (ZDO value in objectsById.Values) { if (value != null && value.IsValid() && value.GetPrefab() == stableHashCode && value.GetString(keyName, "") == key) { if (val != null) { return null; } val = value; } } return val; } internal static bool TryPreviousLink(string prefab, string keyName, string key, string locked, string removing, long player, out bool missing) { missing = false; Dictionary<ZDOID, ZDO> objectsById = ObjectsById; if (objectsById == null || (Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return false; } if (string.IsNullOrEmpty(key)) { missing = true; return true; } int stableHashCode = StringExtensionMethods.GetStableHashCode(prefab); ZDO val = null; foreach (ZDO value in objectsById.Values) { if (value != null && value.IsValid() && value.GetPrefab() == stableHashCode && value.GetString(keyName, "") == key) { if (val != null) { return false; } val = value; } } missing = val == null; if (!missing) { if (!val.GetBool(removing, false)) { return Editable(val, locked, player); } return false; } return true; } internal static bool Editable(ZDO root, string locked, long player) { if (root != null) { if (root.GetBool(locked, false) && root.GetLong(ZDOVars.s_creator, 0L) != 0L) { return root.GetLong(ZDOVars.s_creator, 0L) == player; } return true; } return false; } internal static bool WardAllows(Vector3 position, long player) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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) Dictionary<ZDOID, ZDO> objectsById = ObjectsById; if (objectsById == null || !Object.op_Implicit((Object)(object)ZNetScene.instance) || !MotionAuthority.Finite(position)) { return false; } bool flag = false; foreach (ZDO value in objectsById.Values) { if (value == null || !value.IsValid() || !value.GetBool(ZDOVars.s_enabled, false)) { continue; } GameObject prefab = ZNetScene.instance.GetPrefab(value.GetPrefab()); PrivateArea val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<PrivateArea>() : null); if (!Object.op_Implicit((Object)(object)val)) { continue; } Vector3 val2 = value.GetPosition() - position; if (val2.x * val2.x + val2.z * val2.z >= val.m_radius * val.m_radius) { continue; } flag = true; if (value.GetLong(ZDOVars.s_creator, 0L) == player) { return true; } int num = value.GetInt(ZDOVars.s_permitted, 0); if (num < 0 || num > 10000) { return false; } for (int i = 0; i < num; i++) { if (value.GetLong("pu_id" + i, 0L) == player) { return true; } } } return !flag; } } internal sealed class ColliderVisibility { private readonly GameObject root; private readonly Dictionary<Collider, bool> masked = new Dictionary<Collider, bool>(); private readonly List<Renderer> renderers = new List<Renderer>(); private Collider[] colliders = (Collider[])(object)new Collider[0]; private bool hidden; private bool traveling; private bool keepInteractive; private Func<Collider, bool> travelCoverage; private float nextDiscovery; internal ColliderVisibility(GameObject owner) { root = owner; Discover(); } private void Discover() { colliders = (Collider[])(Object.op_Implicit((Object)(object)root) ? ((Array)root.GetComponentsInChildren<Collider>(true)) : ((Array)new Collider[0])); keepInteractive = Object.op_Implicit((Object)(object)root) && (Object.op_Implicit((Object)(object)root.GetComponentInChildren<Container>(true)) || Object.op_Implicit((Object)(object)root.GetComponentInChildren<Door>(true))); if (Object.op_Implicit((Object)(object)root)) { MonoBehaviour[] components = root.GetComponents<MonoBehaviour>(); for (int i = 0; i < components.Length; i++) { if (components[i] is Interactable) { keepInteractive = true; break; } } } nextDiscovery = Time.unscaledTime + 0.5f; } internal void Travel(bool value, Func<Collider, bool> coverage = null) { traveling = value; travelCoverage = (value ? coverage : null); Discover(); Maintain(); } internal void Hide(bool value) { if (hidden == value) { return; } hidden = value; if (hidden) { Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && val.enabled) { renderers.Add(val); val.enabled = false; } } } else { foreach (Renderer renderer in renderers) { if (Object.op_Implicit((Object)(object)renderer)) { renderer.enabled = true; } } renderers.Clear(); } Discover(); Maintain(); } internal void Maintain() { if (!hidden && !traveling) { foreach (KeyValuePair<Collider, bool> item in masked) { if (Object.op_Implicit((Object)(object)item.Key) && item.Value) { item.Key.enabled = true; } } masked.Clear(); return; } if (Time.unscaledTime >= nextDiscovery) { Discover(); } if (!hidden && (!traveling || keepInteractive)) { foreach (KeyValuePair<Collider, bool> item2 in masked) { if (Object.op_Implicit((Object)(object)item2.Key) && item2.Value) { item2.Key.enabled = true; } } masked.Clear(); return; } Collider[] array = colliders; foreach (Collider val in array) { if (!Object.op_Implicit((Object)(object)val) || val.isTrigger) { continue; } bool flag = hidden || travelCoverage == null || travelCoverage(val); bool value; if (flag && val.enabled) { if (!masked.ContainsKey(val)) { masked[val] = true; } val.enabled = false; } else if (!flag && masked.TryGetValue(val, out value)) { if (value) { val.enabled = true; } masked.Remove(val); } } } internal IEnumerable<Collider> Solids() { Discover(); Collider[] array = colliders; foreach (Collider val in array) { if (Object.op_Implicit((Object)(object)val) && !val.isTrigger && ((Component)val).gameObject.activeInHierarchy && (val.enabled || masked.ContainsKey(val))) { yield return val; } } } internal void Restore() { traveling = false; Hide(value: false); Maintain(); } } [Serializable] internal sealed class CollisionProfile { public Vector3 FloorMin; public Vector3 FloorMax; public Vector3[] WallMin = (Vector3[])(object)new Vector3[4]; public Vector3[] WallMax = (Vector3[])(object)new Vector3[4]; public bool[] Walls = new bool[4]; public bool Complete = true; private Vector3 floorBaseMin; private Vector3 floorBaseMax; internal bool Valid { get { //IL_0009: 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) if (Complete && ValidBox(FloorMin, FloorMax) && WallMin != null && WallMin.Length == 4 && WallMax != null && WallMax.Length == 4 && Walls != null && Walls.Length == 4) { return ValidWalls(); } return false; } } private bool ValidWalls() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 4; i++) { if (Walls[i] && !ValidBox(WallMin[i], WallMax[i])) { return false; } } return true; } private static bool ValidBox(Vector3 min, Vector3 max) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_003a: 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_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) if (MotionAuthority.Finite(min) && MotionAuthority.Finite(max) && max.x > min.x && max.y > min.y && max.z > min.z) { Vector3 val = max - min; return ((Vector3)(ref val)).sqrMagnitude < 1000000f; } return false; } internal static CollisionProfile Base(Vector3 min, Vector3 max) { //IL_0006: 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_000d: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) return new CollisionProfile { FloorMin = min, FloorMax = max, floorBaseMin = min, floorBaseMax = max }; } internal void Include(Collider collider, Transform space, float margin, bool endWalls) { //IL_0015: 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_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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) if (!TryLocalBounds(collider, space, out var result)) { Complete = false; return; } Vector3 min = ((Bounds)(ref result)).min; Vector3 max = ((Bounds)(ref result)).max; if (!MotionAuthority.Finite(min) || !MotionAuthority.Finite(max)) { Complete = false; return; } float num = max.y - min.y; if (num <= 1f && max.y <= 0.6f && min.y >= -1f) { FloorMin = new Vector3(Mathf.Max(floorBaseMin.x - margin, Mathf.Min(FloorMin.x, min.x)), Mathf.Min(FloorMin.y, min.y), Mathf.Max(floorBaseMin.z - margin, Mathf.Min(FloorMin.z, min.z))); FloorMax = new Vector3(Mathf.Min(floorBaseMax.x + margin, Mathf.Max(FloorMax.x, max.x)), Mathf.Max(FloorMax.y, max.y), Mathf.Min(floorBaseMax.z + margin, Mathf.Max(FloorMax.z, max.z))); } else { if (num < 1f || max.y <= 0.6f) { return; } Vector3 center = ((Bounds)(ref result)).center; float num2 = Mathf.Max(0.5f, (floorBaseMax.x - floorBaseMin.x) * 0.5f); float num3 = Mathf.Max(0.5f, (floorBaseMax.z - floorBaseMin.z) * 0.5f); float num4 = (floorBaseMax.z + floorBaseMin.z) * 0.5f; float num5 = Mathf.Abs(center.x) / num2; float num6 = Mathf.Abs(center.z - num4) / num3; if (!(Mathf.Max(num5, endWalls ? num6 : 0f) < 0.6f)) { int num7 = ((!endWalls || !(num6 > num5)) ? ((!(center.x < 0f)) ? 1 : 0) : ((center.z < num4) ? 2 : 3)); if (!Walls[num7]) { WallMin[num7] = min; WallMax[num7] = max; Walls[num7] = true; } else { WallMin[num7] = Vector3.Min(WallMin[num7], min); WallMax[num7] = Vector3.Max(WallMax[num7], max); } } } } internal static bool TryLocalBounds(Collider collider, Transform space, out Bounds result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_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_0076: 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_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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: 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_0126: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018b: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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) result = default(Bounds); BoxCollider val = (BoxCollider)(object)((collider is BoxCollider) ? collider : null); Bounds bounds = default(Bounds); if (val != null) { ((Bounds)(ref bounds))..ctor(val.center, val.size); } else { MeshCollider val2 = (MeshCollider)(object)((collider is MeshCollider) ? collider : null); if (val2 != null && Object.op_Implicit((Object)(object)val2.sharedMesh)) { bounds = val2.sharedMesh.bounds; } else { SphereCollider val3 = (SphereCollider)(object)((collider is SphereCollider) ? collider : null); if (val3 != null) { ((Bounds)(ref bounds))..ctor(val3.center, Vector3.one * val3.radius * 2f); } else { CapsuleCollider val4 = (CapsuleCollider)(object)((collider is CapsuleCollider) ? collider : null); if (val4 == null) { return false; } Vector3 val5 = Vector3.one * val4.radius * 2f; ((Vector3)(ref val5))[val4.direction] = Mathf.Max(val4.height, val4.radius * 2f); ((Bounds)(ref bounds))..ctor(val4.center, val5); } } } Matrix4x4 val6 = space.worldToLocalMatrix * ((Component)collider).transform.localToWorldMatrix; Vector3 val7 = Vector3.positiveInfinity; Vector3 val8 = Vector3.negativeInfinity; for (int i = 0; i < 8; i++) { Vector3 val9 = ((Matrix4x4)(ref val6)).MultiplyPoint3x4(new Vector3(((i & 1) == 0) ? ((Bounds)(ref bounds)).min.x : ((Bounds)(ref bounds)).max.x, ((i & 2) == 0) ? ((Bounds)(ref bounds)).min.y : ((Bounds)(ref bounds)).max.y, ((i & 4) == 0) ? ((Bounds)(ref bounds)).min.z : ((Bounds)(ref bounds)).max.z)); val7 = Vector3.Min(val7, val9); val8 = Vector3.Max(val8, val9); } ((Bounds)(ref result)).SetMinMax(val7, val8); return true; } } [Serializable] internal sealed class CollisionProfiles { public int Version = 1; public string Geometry; public int MemberCount; public string InputSignature; public CollisionProfile[] Links; internal bool MatchesCabin(int count, string signature) { if (count > 0 && MemberCount == count && !string.IsNullOrEmpty(InputSignature)) { return InputSignature == signature; } return false; } internal static string Fingerprint(IEnumerable<string> inputs) { string s = string.Join("|", inputs.OrderBy<string, string>((string result) => result, StringComparer.Ordinal)); using SHA256 sHA = SHA256.Create(); return BitConverter.ToString(sHA.ComputeHash(Encoding.UTF8.GetBytes(s))).Replace("-", ""); } internal string Serialize() { return JsonUtility.ToJson((object)this); } internal static CollisionProfiles Read(string text, string geometry, int count) { if (string.IsNullOrEmpty(text) || text.Length > 64000) { return null; } try { CollisionProfiles collisionProfiles = JsonUtility.FromJson<CollisionProfiles>(text); if (collisionProfiles == null || collisionProfiles.Version != 1 || collisionProfiles.Geometry != geometry || collisionProfiles.Links == null || collisionProfiles.Links.Length != count) { return null; } CollisionProfile[] links = collisionProfiles.Links; foreach (CollisionProfile collisionProfile in links) { if (collisionProfile == null || !collisionProfile.Valid) { return null; } } return collisionProfiles; } catch { return null; } } } internal static class MotionContact { internal static bool CanRide(bool grounded, bool ownedGround, bool alreadyRiding) { if (!grounded) { return alreadyRiding; } return ownedGround; } internal static Vector3 PointDelta(Vector3 point, Vector3 oldPosition, Quaternion oldRotation, Vector3 newPosition, Quaternion newRotation) { //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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) return newPosition + newRotation * (Quaternion.Inverse(oldRotation) * (point - oldPosition)) - point; } internal static void Carry(Rigidbody body, Vector3 oldPosition, Quaternion oldRotation, Vector3 newPosition, Quaternion newRotation) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)body) && !body.isKinematic) { Vector3 val = PointDelta(body.position, oldPosition, oldRotation, newPosition, newRotation); if (MotionAuthority.Finite(val) && ((Vector3)(ref val)).sqrMagnitude > 1E-10f) { body.position += val; } } } } internal static class SupportEvaluation { internal struct State { internal bool Active; internal bool Moving; } [ThreadStatic] internal static bool Active; [ThreadStatic] internal static bool MovingAssembly; internal static State Enter(bool moving) { State result = new State { Active = Active, Moving = MovingAssembly }; Active = true; MovingAssembly = moving; return result; } internal static void Exit(State state) { Active = state.Active; MovingAssembly = state.Moving; } } internal static class MotionDismantle { private static readonly FieldInfo Privacy = AccessTools.Field(typeof(Container), "m_privacy"); private static readonly MethodInfo PieceRemoval = AccessTools.Method(typeof(Piece), "CanBeRemoved", (Type[])null, (Type[])null); private static readonly MethodInfo ContainerRemoval = AccessTools.Method(typeof(Container), "CanBeRemoved", (Type[])null, (Type[])null); internal static bool CanRemove(Piece piece) { if (!Object.op_Implicit((Object)(object)piece)) { return false; } if (piece.CanBeRemoved()) { return true; } Container componentInChildren = ((Component)piece).GetComponentInChildren<Container>(); if (!Object.op_Implicit((Object)(object)componentInChildren) || ((object)componentInChildren).GetType() != typeof(Container) || Privacy == null || Convert.ToInt32(Privacy.GetValue(componentInChildren)) != 0 || componentInChildren.GetInventory() == null || componentInChildren.GetInventory().NrOfItems() <= 0) { return false; } if (PieceRemoval != null && ContainerRemoval != null) { Patches patchInfo = Harmony.GetPatchInfo((MethodBase)PieceRemoval); if (patchInfo == null || patchInfo.Owners.Count == 0) { Patches patchInfo2 = Harmony.GetPatchInfo((MethodBase)ContainerRemoval); return patchInfo2 == null || patchInfo2.Owners.Count == 0; } } return false; } } internal static class MotionEditorInput { internal static bool PlatformWindowBusy { get { string[] array = new string[3] { "DynamicPlatforms.LiftEditor", "DynamicPlatforms.LiftPanel", "DynamicBridges.BridgeEditor" }; foreach (string name in array) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int j = 0; j < assemblies.Length; j++) { Type type = assemblies[j].GetType(name, throwOnError: false); if (type == null) { continue; } try { if ((bool?)type.GetProperty("IsOpen", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null, null) == true) { return true; } if ((int?)type.GetField("ClosedFrame", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) == Time.frameCount) { return true; } } catch { } } } return false; } } internal static bool StorageTarget(GameObject hover) { if (!Object.op_Implicit((Object)(object)hover)) { return false; } Piece componentInParent = hover.GetComponentInParent<Piece>(); GameObject val = (Object.op_Implicit((Object)(object)componentInParent) ? ((Component)componentInParent).gameObject : hover); if (Object.op_Implicit((Object)(object)hover.GetComponentInParent<Container>()) || Object.op_Implicit((Object)(object)val.GetComponentInChildren<Container>(true))) { return true; } MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val2 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val2)) { Type type = ((object)val2).GetType(); if ((type.Namespace ?? "").StartsWith("DynamicStorage", StringComparison.Ordinal) || type.Assembly.GetName().Name.StartsWith("DynamicStorage", StringComparison.Ordinal)) { return true; } } } return false; } internal static void CloseConfigurationManager() { foreach (PluginInfo value in Chainloader.PluginInfos.Values) { object instance = value.Instance; if (instance == null || instance.GetType().Name != "ConfigurationManager") { continue; } PropertyInfo property = instance.GetType().GetProperty("DisplayingWindow"); try { if (property != null && property.CanWrite && property.PropertyType == typeof(bool)) { property.SetValue(instance, false, null); } } catch { } } } } internal sealed class EditorMenuAction { private readonly ConfigEntry<bool> entry; private int requested; internal EditorMenuAction(ConfigEntry<bool> setting) { entry = setting; entry.Value = false; entry.SettingChanged += delegate { if (entry.Value) { Interlocked.Exchange(ref requested, 1); } }; } internal bool Consume() { if (Interlocked.Exchange(ref requested, 0) == 0) { return false; } entry.Value = false; return true; } } internal static class MotionPlacement { private static readonly Collider[] hits = (Collider[])(object)new Collider[128]; internal static bool Touches(GameObject placing, Func<Collider, bool> owns) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_008a: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)placing)) { return false; } Collider[] componentsInChildren = placing.GetComponentsInChildren<Collider>(true); Vector3 val5 = default(Vector3); float num2 = default(float); foreach (Collider val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val) || val.isTrigger || !((Component)val).gameObject.activeInHierarchy || !CollisionProfile.TryLocalBounds(val, placing.transform, out var result)) { continue; } Vector3 val2 = placing.transform.TransformPoint(((Bounds)(ref result)).center); Vector3 lossyScale = placing.transform.lossyScale; Vector3 val3 = Vector3.Scale(((Bounds)(ref result)).extents, new Vector3(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z))) + Vector3.one * 0.08f; if (!MotionAuthority.Finite(val2) || !MotionAuthority.Finite(val3)) { continue; } int num = Physics.OverlapBoxNonAlloc(val2, val3, hits, placing.transform.rotation, LayerMask.GetMask(new string[2] { "piece", "piece_nonsolid" }), (QueryTriggerInteraction)1); for (int j = 0; j < num; j++) { Collider val4 = hits[j]; if (!Object.op_Implicit((Object)(object)val4) || !val4.enabled || val4.isTrigger || ((Component)val4).transform.IsChildOf(placing.transform) || !owns(val4)) { continue; } if (Physics.ComputePenetration(val, ((Component)val).transform.position, ((Component)val).transform.rotation, val4, ((Component)val4).transform.position, ((Component)val4).transform.rotation, ref val5, ref num2)) { return true; } for (int k = 0; k < 8; k++) { Vector3 val6 = placing.transform.TransformPoint(new Vector3(((k & 1) == 0) ? ((Bounds)(ref result)).min.x : ((Bounds)(ref result)).max.x, ((k & 2) == 0) ? ((Bounds)(ref result)).min.y : ((Bounds)(ref result)).max.y, ((k & 4) == 0) ? ((Bounds)(ref result)).min.z : ((Bounds)(ref result)).max.z)); Vector3 val7 = val4.ClosestPoint(val6) - val6; if (((Vector3)(ref val7)).sqrMagnitude <= 0.0064f) { return true; } } } } return false; } } internal sealed class MotionRemovalSequence { internal readonly string Token; internal readonly long RootOwner; internal readonly ZDOID Root; private readonly ZDOID[] pieces; internal int Cursor { get; private set; } internal bool Begun { get; private set; } internal bool Waiting { get; private set; } internal bool Stopped { get; private set; } internal long Recipient { get; private set; } internal int Phase { get; private set; } internal bool Finished { get { if (Begun) { return Cursor > pieces.Length; } return false; } } internal ZDOID Current { get { //IL_0023: 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) if (Cursor >= pieces.Length) { return Root; } return pieces[Cursor]; } } internal MotionRemovalSequence(string token, long owner, ZDOID root, IEnumerable<ZDOID> members) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if (!Guid.TryParseExact(token, "N", out var _) || owner == 0L || root == ZDOID.None) { throw new ArgumentException("Invalid removal ticket."); } pieces = members.ToArray(); if (pieces.Any((ZDOID p) => p == ZDOID.None || p == root) || pieces.Distinct().Count() != pieces.Length) { throw new ArgumentException("Invalid removal membership."); } Token = token; RootOwner = owner; Root = root; } internal bool CheckOwner(long owner) { if (owner != RootOwner) { Stopped = true; } return !Stopped; } internal bool Schedule(long recipient) { if (Stopped || Finished || Waiting || recipient == 0L || (!Begun && recipient != RootOwner)) { return false; } Recipient = recipient; Phase = (Begun ? (Cursor + 1) : 0); Waiting = true; return true; } internal bool AcceptReply(long sender, string token, int phase) { if (!Stopped && Waiting && sender == Recipient && token == Token) { return phase == Phase; } return false; } internal bool BeginAcknowledged(long sender, string token, int phase) { if (Begun || phase != 0 || !AcceptReply(sender, token, phase)) { return false; } Begun = true; Waiting = false; return true; } internal bool ObserveRemoved(ZDOID id) { //IL_0020: 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) if (Stopped || !Begun || !Waiting || Finished || id != Current) { return false; } Cursor++; Waiting = false; return true; } internal bool MatchesRemaining(IEnumerable<ZDOID> savedMembers) { ZDOID[] array = savedMembers.ToArray(); ZDOID[] array2 = pieces.Skip(Math.Min(Cursor, pieces.Length)).ToArray(); if (array.Length == array2.Length && array.Distinct().Count() == array.Length) { return new HashSet<ZDOID>(array2).SetEquals(array); } return false; } internal void Stop() { Stopped = true; } } internal static class MotionStreaming { internal const string RootReference = "motion_root_v1"; private static string association; private static string keyName; private static int rootPrefab; private static ZDOMan world; private static float nextIndex; private static readonly Dictionary<string, ZDO> roots = new Dictionary<string, ZDO>(); private static readonly HashSet<ZDOID> requiredIds = new HashSet<ZDOID>(); private static readonly List<ZDO> requiredRoots = new List<ZDO>(); internal static void Install(Harmony harmony, string prefab, string associationKey, string rootKey) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown association = associationKey; keyName = rootKey; rootPrefab = StringExtensionMethods.GetStableHashCode(prefab); MethodInfo methodInfo = AccessTools.Method(typeof(ZDOMan), "CreateSyncList", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ZNetScene), "CreateObjects", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(ZNetScene), "RemoveObjects", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(MotionStreaming), "SyncPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(MotionStreaming), "ScenePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (methodInfo3 != null) { harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(typeof(MotionStreaming), "ScenePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (methodInfo == null || methodInfo2 == null || methodInfo3 == null) { Logger.LogWarning((object)"Moving assembly streaming hooks unavailable; unload/reload testing is required."); } } private static void IndexLegacyRoots() { if (world == ZDOMan.instance && Time.unscaledTime < nextIndex) { return; } world = ZDOMan.instance; nextIndex = Time.unscaledTime + 2f; roots.Clear(); Dictionary<ZDOID, ZDO> objectsById = SavedMotionWorld.ObjectsById; if (objectsById == null) { return; } foreach (ZDO value in objectsById.Values) { if (value == null || !value.IsValid() || value.GetPrefab() != rootPrefab) { continue; } string text = value.GetString(keyName, ""); if (text.Length != 0) { if (roots.ContainsKey(text)) { roots[text] = null; } else { roots[text] = value; } } } } private static ZDO Root(ZDO member) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (member == null || !member.IsValid()) { return null; } string text = member.GetString(association, ""); if (text.Length == 0) { return null; } ZDOMan instance = ZDOMan.instance; ZDO value = ((instance != null) ? instance.GetZDO(member.GetZDOID("motion_root_v1")) : null); if (value != null && value.IsValid() && value.GetPrefab() == rootPrefab && value.GetString(keyName, "") == text) { return value; } IndexLegacyRoots(); if (!roots.TryGetValue(text, out value) || value == null || !value.IsValid()) { return null; } return value; } private static void AddRoots(List<ZDO> relevant, List<ZDO> additional = null) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (relevant == null || ZDOMan.instance == null) { return; } requiredIds.Clear(); requiredRoots.Clear(); int count = relevant.Count; for (int i = 0; i < count; i++) { ZDO val = Root(relevant[i]); if (val != null && requiredIds.Add(val.m_uid)) { requiredRoots.Add(val); } } if (additional != null) { foreach (ZDO item in additional) { ZDO val2 = Root(item); if (val2 != null && requiredIds.Add(val2.m_uid)) { requiredRoots.Add(val2); } } } if (requiredRoots.Count != 0) { relevant.RemoveAll((ZDO zdo) => zdo != null && requiredIds.Contains(zdo.m_uid)); relevant.InsertRange(0, requiredRoots); } } private static void SyncPostfix(List<ZDO> __1) { if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { AddRoots(__1); } } private static void ScenePrefix(List<ZDO> __0, List<ZDO> __1) { AddRoots(__0, __1); } } [Serializable] internal sealed class SurfaceBox { public Vector3 Center; public Vector3 Size; public float Yaw; public int Kind; internal Quaternion Rotation => Quaternion.Euler(0f, Yaw, 0f); internal bool Valid { get { //IL_0001: 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) if (MotionAuthority.Finite(Center) && MotionAuthority.Finite(Size) && !float.IsNaN(Yaw) && !float.IsInfinity(Yaw) && Yaw >= -90f && Yaw <= 90f && (Kind == 0 || Kind == 1) && Size.x > 0f && Size.y > 0f && Size.z > 0f && ((Vector3)(ref Size)).sqrMagnitude < 1000000f) { return ((Vector3)(ref Center)).sqrMagnitude < 1000000f; } return false; } } internal string Signature => Kind + ":" + Number(Yaw) + ":" + Number(Center.x) + ":" + Number(Center.y) + ":" + Number(Center.z) + ":" + Number(Size.x) + ":" + Number(Size.y) + ":" + Number(Size.z); private static string Number(float value) { return Math.Round(value, 3).ToString("0.000", CultureInfo.InvariantCulture); } internal bool Contains(SurfaceBox other) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!Valid || !other.Valid || Kind != other.Kind || Mathf.Abs(Yaw - other.Yaw) > 0.0001f) { return false; } Vector3 val = Quaternion.Inverse(Rotation) * (other.Center - Center); for (int i = 0; i < 3; i++) { if (Mathf.Abs(((Vector3)(ref val))[i]) + ((Vector3)(ref other.Size))[i] * 0.5f > ((Vector3)(ref Size))[i] * 0.5f + 0.0001f) { return false; } } return true; } internal bool Merge(SurfaceBox other) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_0054: 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_0174: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) if (!Valid || !other.Valid || Kind != other.Kind || Mathf.Abs(Yaw - other.Yaw) > 0.0001f) { return false; } if (Contains(other)) { return true; } if (other.Contains(this)) { Center = other.Center; Size = other.Size; return true; } Vector3 val = Quaternion.Inverse(Rotation) * (other.Center - Center); Vector3 val2 = Size * -0.5f; Vector3 val3 = Size * 0.5f; Vector3 val4 = val - other.Size * 0.5f; Vector3 val5 = val + other.Size * 0.5f; for (int i = 0; i < 3; i++) { bool flag = true; for (int j = 0; j < 3; j++) { if (j != i && (Mathf.Abs(((Vector3)(ref val2))[j] - ((Vector3)(ref val4))[j]) > 0.0001f || Mathf.Abs(((Vector3)(ref val3))[j] - ((Vector3)(ref val5))[j]) > 0.0001f)) { flag = false; } } if (flag && !(((Vector3)(ref val4))[i] > ((Vector3)(ref val3))[i] + 0.0001f) && !(((Vector3)(ref val2))[i] > ((Vector3)(ref val5))[i] + 0.0001f)) { Vector3 val6 = Vector3.Min(val2, val4); Vector3 val7 = Vector3.Max(val3, val5); Center += Rotation * ((val6 + val7) * 0.5f); Size = val7 - val6; return true; } } return false; } } [Serializable] internal sealed class SurfaceProfile { internal const int MaxInputs = 512; internal const int MaxBoxes = 128; public int Version = 2; public int MemberCount; public string Geometry; public string InputSignature; public SurfaceBox[] Boxes; internal bool Valid { get { if (Version == 2 && MemberCount >= 0 && !string.IsNullOrEmpty(Geometry) && !string.IsNullOrEmpty(InputSignature) && Boxes != null && Boxes.Length != 0 && Boxes.Length <= 128) { return Boxes.All((SurfaceBox b) => b?.Valid ?? false); } return false; } } internal string Serialize() { return JsonUtility.ToJson((object)this); } internal static SurfaceProfile Read(string text, string geometry) { if (string.IsNullOrEmpty(text) || text.Length > 64000) { return null; } try { SurfaceProfile surfaceProfile = JsonUtility.FromJson<SurfaceProfile>(text); return (surfaceProfile != null && surfaceProfile.Valid && surfaceProfile.Geometry == geometry) ? surfaceProfile : null; } catch { return null; } } internal static string Signature(List<SurfaceBox> inputs) { return string.Join("|", inputs.Select((SurfaceBox b) => b.Signature).OrderBy<string, string>((string s) => s, StringComparer.Ordinal)); } internal static SurfaceProfile Build(string geometry, List<SurfaceBox> inputs) { if (inputs == null || inputs.Count == 0 || inputs.Count > 512 || inputs.Any((SurfaceBox b) => b == null || !b.Valid)) { return null; } List<SurfaceBox> list = (from b in inputs.OrderBy<SurfaceBox, string>((SurfaceBox b) => b.Signature, StringComparer.Ordinal) select new SurfaceBox { Center = b.Center, Size = b.Size, Yaw = b.Yaw, Kind = b.Kind }).ToList(); bool flag; do { flag = false; for (int num = 0; num < list.Count; num++) { for (int num2 = list.Count - 1; num2 > num; num2--) { if (list[num].Merge(list[num2])) { list.RemoveAt(num2); flag = true; } } } } while (flag); if (list.Count > 128) { return null; } SurfaceProfile surfaceProfile = new SurfaceProfile { Geometry = geometry, InputSignature = Signature(inputs), Boxes = list.ToArray() }; if (!surfaceProfile.Valid || surfaceProfile.Serialize().Length > 64000) { return null; } return surfaceProfile; } internal bool Covers(SurfaceBox shape) { if (Boxes != null) { return Boxes.Any((SurfaceBox b) => b.Contains(shape)); } return false; } internal static bool TryBox(Collider collider, Matrix4x4 colliderToLift, out SurfaceBox result) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) result = null; BoxCollider val = (BoxCollider)(object)((collider is BoxCollider) ? collider : null); if (val == null || ((Collider)val).isTrigger) { return false; } Vector3 val2 = ((Matrix4x4)(ref colliderToLift)).MultiplyPoint3x4(val.center); Vector3[] array = (Vector3[])(object)new Vector3[3]; float[] array2 = new float[3]; int num = 0; while (num < 3) { Vector3 zero = Vector3.zero; ((Vector3)(ref zero))[num] = 1f; Vector3 val3 = ((Matrix4x4)(ref colliderToLift)).MultiplyPoint3x4(val.center + zero) - val2; float num2 = (float)Math.Sqrt(((Vector3)(ref val3)).sqrMagnitude); if (!(num2 < 1E-05f) && MotionAuthority.Finite(val3)) { Vector3 size = val.size; if (!(((Vector3)(ref size))[num] <= 0f)) { array[num] = val3 * (1f / num2); int num3 = num; size = val.size; array2[num3] = num2 * ((Vector3)(ref size))[num]; num++; continue; } } return false; } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 3; j++) { if (Mathf.Abs(Dot(array[i], array[j])) > 1E-05f) { return false; } } } int num4 = -1; for (int k = 0; k < 3; k++) { if (Mathf.Abs(array[k].y) > 0.99999f) { num4 = k; } } if (num4 < 0) { return false; } int num5 = (num4 + 1) % 3; int num6 = (num4 + 2) % 3; if (Mathf.Abs(array[num5].y) > 1E-05f || Mathf.Abs(array[num6].y) > 1E-05f) { return false; } bool flag = array2[num4] <= 0.6f && Mathf.Min(array2[num5], array2[num6]) >= 0.6f; bool flag2 = array2[num4] > 0.6f && Mathf.Min(array2[num5], array2[num6]) <= 0.65f && Mathf.Max(array2[num5], array2[num6]) >= 0.65f; if (!flag && !flag2) { return false; } int num7 = (flag ? num5 : ((array2[num5] >= array2[num6]) ? num5 : num6)); float num8; for (num8 = (float)(Math.Atan2(0f - array[num7].z, array[num7].x) * 180.0 / Math.PI); num8 >= 90f; num8 -= 180f) { } for (; num8 < -90f; num8 += 180f) { } if (flag) { if (num8 >= 45f) { num8 -= 90f; } if (num8 < -45f) { num8 += 90f; } } Quaternion val4 = Quaternion.Inverse(Quaternion.Euler(0f, num8, 0f)); Vector3 val5 = Vector3.zero; for (int l = 0; l < 3; l++) { Vector3 val6 = val4 * array[l]; val5 += new Vector3(Mathf.Abs(val6.x), Mathf.Abs(val6.y), Mathf.Abs(val6.z)) * array2[l]; } result = new SurfaceBox { Center = val2, Size = val5, Yaw = num8, Kind = ((!flag) ? 1 : 0) }; if (!result.Valid) { result = null; return false; } return true; } private static float Dot(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) return a.x * b.x + a.y * b.y + a.z * b.z; } } internal sealed class ControlDecoration : MonoBehaviour { } internal sealed class WorldControlText : MonoBehaviour { private TextMeshPro label; private Material material; private TMP_FontAsset fallback; private string signature; private static readonly Dictionary<int, TMP_FontAsset> native = new Dictionary<int, TMP_FontAsset>(); private static readonly Dictionary<int, TMP_FontAsset> owned = new Dictionary<int, TMP_FontAsset>(); internal float ActualHeight { get; private set; } internal float ActualWidth { get; private set; } internal Bounds LocalBounds { get; private set; } internal void Initialize(TMP_FontAsset reference) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown fallback = reference; GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) }); val.layer = ((Component)this).gameObject.layer; val.transform.SetParent(((Component)this).transform, false); label = val.AddComponent<TextMeshPro>(); ((TMP_Text)label).richText = false; ((TMP_Text)label).enableAutoSizing = false; ((TMP_Text)label).extraPadding = true; ((TMP_Text)label).overflowMode = (TextOverflowModes)0; ((TMP_Text)label).textWrappingMode = (TextWrappingModes)1; MeshRenderer component = val.GetComponent<MeshRenderer>(); ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; ((Renderer)component).sortingOrder = ControlFaceOrder.For("Text"); ((Component)this).gameObject.AddComponent<ControlDecoration>(); } private static TMP_FontAsset Font(int choice, TMP_FontAsset fallback, string text) { if (!native.TryGetValue(choice, out var value)) { string token = choice switch { 2 => "averiasans", 1 => "norse", _ => "averiaserif", }; value = (from f in Resources.FindObjectsOfTypeAll<TMP_FontAsset>() where Object.op_Implicit((Object)(object)f) && (int)f.atlasPopulationMode == 0 && Object.op_Implicit((Object)(object)f.atlasTexture) && Object.op_Implicit((Object)(object)((TMP_Asset)f).material) && ((Object)f).name.IndexOf(token, StringComparison.OrdinalIgnoreCase) >= 0 orderby (((Object)f).name.IndexOf("bold", StringComparison.OrdinalIgnoreCase) >= 0) ? 1 : 0 select f).FirstOrDefault(); native[choice] = value; } if (Object.op_Implicit((Object)(object)value) && value.HasCharacters(text)) { return value; } string requested = choice switch { 2 => "averiasans", 1 => "norse", _ => "averiaserif", }; Font val = (Font)(Object.op_Implicit((Object)(object)value) ? ((object)value.sourceFontFile) : ((object)((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font f) => Object.op_Implicit((Object)(object)f) && ((Object)f).name.IndexOf(requested, StringComparison.OrdinalIgnoreCase) >= 0)))); if (!Object.op_Implicit((Object)(object)val) && choice == 1 && Object.op_Implicit((Object)(object)fallback)) { val = fallback.sourceFontFile; } if (!Object.op_Implicit((Object)(object)val) && GUIManager.Instance != null) { val = GUIManager.Instance.AveriaSerif; } if (!Object.op_Implicit((Object)(object)val)) { if (!Object.op_Implicit((Object)(object)value)) { return fallback; } return value; } int instanceID = ((Object)val).GetInstanceID(); if (!owned.TryGetValue(instanceID, out var value2) || !Object.op_Implicit((Object)(object)value2)) { if (owned.Count >= 8) { if (!Object.op_Implicit((Object)(object)value)) { return fallback; } return value; } value2 = TMP_FontAsset.CreateFontAsset(val, 64, 12, (GlyphRenderMode)4165, 2048, 2048, (AtlasPopulationMode)1, false); if (!Object.op_Implicit((Object)(object)value2)) { if (!Object.op_Implicit((Object)(object)value)) { return fallback; } return value; } ((Object)value2).name = "DP_ControlSDF_" + ((Object)val).name; ((Object)value2).hideFlags = (HideFlags)52; owned[instanceID] = value2; } string text2 = default(string); value2.TryAddCharacters(text, ref text2, false); return value2; } internal unsafe void Set(string text, float glyphHeight, float width, int font, int alignment, Color colour, bool readable, bool halo, bool outline, float strength) { //IL_006d: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: 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_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0442: 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_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04da: 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_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)label)) { return; } string[] obj = new string[16] { text, "|", glyphHeight.ToString(), "|", width.ToString(), "|", font.ToString(), "|", alignment.ToString(), "|", null, null, null, null, null, null }; Color val = colour; obj[10] = ((object)(*(Color*)(&val))/*cast due to .constrained prefix*/).ToString(); obj[11] = "|"; obj[12] = readable.ToString(); obj[13] = halo.ToString(); obj[14] = outline.ToString(); obj[15] = strength.ToString(); string text2 = string.Concat(obj); if (text2 == signature) { return; } signature = text2; TMP_FontAsset val2 = Font(font, fallback, text); if (!Object.op_Implicit((Object)(object)val2)) { return; } if ((Object)(object)((TMP_Text)label).font != (Object)(object)val2 || !Object.op_Implicit((Object)(object)material)) { if (Object.op_Implicit((Object)(object)material)) { Object.Destroy((Object)(object)material); } ((TMP_Text)label).font = val2; material = new Material(((TMP_Asset)val2).material) { name = "DP_ControlOwnedSDF", hideFlags = (HideFlags)52 }; ((TMP_Text)label).fontSharedMaterial = material; } Shader val3 = Shader.Find((readable || halo) ? "TextMeshPro/Distance Field" : "TextMeshPro/Distance Field (Surface)"); if (Object.op_Implicit((Object)(object)val3)) { material.shader = val3; } ((Graphic)label).color = colour; ((TMP_Text)label).alignment = (TextAlignmentOptions)(alignment switch { 2 => 4100, 0 => 4097, _ => 4098, }); SetColour("_FaceColor", Color.white); SetColour("_OutlineColor", Color.black); SetFloat("_OutlineWidth", outline ? 0.025f : 0f); SetFloat("_FaceDilate", 0f); SetFloat("_ZTestMode", 4f); if (halo) { material.EnableKeyword("GLOW_ON"); } else { material.DisableKeyword("GLOW_ON"); } if (halo) { material.EnableKeyword("UNDERLAY_ON"); } else { material.DisableKeyword("UNDERLAY_ON"); } material.DisableKeyword("UNDERLAY_INNER"); SetColour("_GlowColor", new Color(colour.r, colour.g, colour.b, halo ? 0.7f : 0f)); SetFloat("_GlowOffset", 0f); SetFloat("_GlowInner", 0.02f); SetFloat("_GlowOuter", Mathf.Lerp(0.1f, 0.25f, strength)); SetFloat("_GlowPower", 0.35f); SetColour("_UnderlayColor", new Color(colour.r, colour.g, colour.b, halo ? 0.65f : 0f)); SetFloat("_UnderlayOffsetX", 0f); SetFloat("_UnderlayOffsetY", 0f); SetFloat("_UnderlayDilate", 0.04f); SetFloat("_UnderlaySoftness", 0.25f); ((TMP_Text)label).UpdateMeshPadding(); label.transform.localScale = Vector3.one; ((TMP_Text)label).fontSize = 24f; ((TMP_Text)label).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)label).rectTransform.sizeDelta = new Vector2(10000f, 10000f); ((TMP_Text)label).text = "H"; ((TMP_Text)label).ForceMeshUpdate(true, true); float num = glyphHeight; Bounds textBounds = ((TMP_Text)label).textBounds; float num2 = num / Mathf.Max(0.001f, ((Bounds)(ref textBounds)).size.y); ((TMP_Text)label).text = text; ((TMP_Text)label).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)label).rectTransform.sizeDelta = new Vector2(Mathf.Max(0.02f, width) / num2, 10000f); ((TMP_Text)label).ForceMeshUpdate(true, true); Bounds textBounds2 = ((TMP_Text)label).textBounds; ActualHeight = ((Bounds)(ref textBounds2)).size.y * num2; ActualWidth = ((Bounds)(ref textBounds2)).size.x * num2; label.transform.localScale = Vector3.one * num2; label.transform.localPosition = new Vector3(0f, (0f - ((Bounds)(ref textBounds2)).center.y) * num2, 0f); LocalBounds = new Bounds(new Vector3(((Bounds)(ref textBounds2)).center.x * num2, 0f, 0f), ((Bounds)(ref textBounds2)).size * num2); } private void SetFloat(string key, float value) { if (material.HasProperty(key)) { material.SetFloat(key, value); } } private void SetColour(string key, Color value) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty(key)) { material.SetColor(key, value); } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)material)) { Object.Destroy((Object)(object)material); } } internal static void Release() { foreach (TMP_FontAsset value in owned.Values) { if (!Object.op_Implicit((Object)(object)value)) { continue; } Texture2D[] atlasTextures = value.atlasTextures; foreach (Texture2D val in atlasTextures) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } if (Object.op_Implicit((Object)(object)((TMP_Asset)value).material)) { Object.Destroy((Object)(object)((TMP_Asset)value).material); } Object.Destroy((Object)(object)value); } owned.Clear(); native.Clear(); } } } namespace DynamicPlatforms { [BepInPlugin("com.muji.DynamicPlatforms", "DynamicPlatforms Elevators", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal sealed class DynamicPlatformsPlugin : BaseUnityPlugin { public const string PluginGuid = "com.muji.DynamicPlatforms"; public const string PluginName = "DynamicPlatforms Elevators"; public const string PluginVersion = "0.2.0"; internal const string BuildCategory = "Dynamic Storage"; private ConfigEntry<KeyCode> editorKey; private ConfigEntry<bool> showGridOverlay; private Harmony harmony; internal static DynamicPlatformsPlugin Current { get; private set; } internal static bool ShowGridOverlay { get { return Current?.showGridOverlay?.Value ?? true; } set { if (Current?.showGridOverlay != null) { Current.showGridOverlay.Value = value; } } } internal static KeyCode EditorKey => (KeyCode)(((??)Current?.editorKey?.Value) ?? 112); internal static string EditorPrompt => EditorPromptText("Lift Editor"); internal static string UseKeyLabel { get { if (Localization.instance == null) { return "Use"; } return Localization.instance.Localize("$KEY_Use"); } } internal static string EditorPromptText(string action) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) return "[<color=yellow><b>" + ((object)EditorKey/*cast due to .constrained prefix*/).ToString() + "</b></color>] " + action; } internal static string UsePromptText(string action) { return "[<color=yellow><b>" + UseKeyLabel + "</b></color>] " + action; } private void Awake() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown Current = this; editorKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Lift Editor", "Editor Key", (KeyCode)112, new ConfigDescription("Client-local. Key that opens the Lift Editor while looking at a lift, and call-button settings while looking at a call button.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 100 } })); showGridOverlay = ((BaseUnityPlugin)this).Config.Bind<bool>("Lift Editor", "Show Snap Grid Overlay", true, new ConfigDescription("Client-local. Draw the blueprint grid lines and snap point markers on lift frames in build mode.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 95 } })); PlatformLimits.Bind(((BaseUnityPlugin)this).Config); LiftEditor.BindSettings(((BaseUnityPlugin)this).Config); harmony = new Harmony("com.muji.DynamicPlatforms"); MotionStreaming.Install(harmony, "DP_LiftPlatform", "dp_lift", "dp_key"); LiftPatches.Install(harmony); MotionAuthority motionAuthority = ((Component)this).gameObject.AddComponent<MotionAuthority>(); motionAuthority.Initialize("com.muji.DynamicPlatforms"); motionAuthority.AddRoute("DP_LiftCmd", "DP_LiftPlatform", LiftPlatform.Authorize); motionAuthority.AddRoute("DP_CallCmd", "DP_LiftCallButton", LiftCallButton.Authorize); motionAuthority.AddRoute("DP_ControlCmd", "DP_LiftControls", LiftControlPresentation.Authorize); motionAuthority.AddRoute("DP_CallSizeCmd", "DP_LiftCallButton", LiftControlPresentation.Authorize); motionAuthority.AddRoute("DP_ControlStyleCmd", "DP_LiftControls", LiftControlPresentation.AuthorizeStyle); motionAuthority.AddRoute("DP_CallStyleCmd", "DP_LiftCallButton", LiftControlPresentation.AuthorizeStyle); ((Component)this).gameObject.AddComponent<LiftEditor>(); ((Component)this).gameObject.AddComponent<LiftPanel>(); ((Component)this).gameObject.AddComponent<LiftRegistry>(); PrefabManager.OnVanillaPrefabsAvailable += RegisterPieces; Logger.LogInfo((object)"DynamicPlatforms Elevators 0.2.0 loaded."); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterPieces; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } EditorBranding.Release(); LiftControlPresentation.Release(); } private void RegisterPieces() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterPieces; try { RegisterPlatform(); } catch (Exception ex) { Logger.LogError((object)("Lift Platform not registered: " + ex)); } try { RegisterSignPiece<LiftControls>("DP_LiftControls", "Lift Controls", "Build on a lift in build mode. Use it to open the lift panel and choose a floor."); } catch (Exception ex2) { Logger.LogError((object)("Lift Controls not registered: " + ex2)); } try { RegisterSignPiece<LiftCallButton>("DP_LiftCallButton", "Lift Call Button", "Build at a landing or on a lift in build mode. Use it as a direct button for one chosen floor."); } catch (Exception ex3) { Logger.LogError((object)("Lift Call Button not registered: " + ex3)); } } private static PieceConfig TestCost(string name, string description) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_003d: Expected O, but got Unknown PieceConfig val = new PieceConfig { Name = name, Description = description, PieceTable = PieceTables.Hammer, Category = "Dynamic Storage" }; val.AddRequirement(new RequirementConfig("Wood", 1, 0, true)); return val; } private static void StripVisuals(GameObject prefab, bool keepRenderers) { LODGroup[] componentsInChildren = prefab.GetComponentsInChildren<LODGroup>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } if (!keepRenderers) { Renderer[] componentsInChildren2 = prefab.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } MeshFilter[] componentsInChildren3 = prefab.GetComponentsInChildren<MeshFilter>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } } Collider[] componentsInChildren4 = prefab.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren4[i]); } Transform[] array = (from t in prefab.GetComponentsInChildren<Transform>(true) where Object.op_Implicit((Object)(object)t) && (Object)(object)t != (Object)(object)prefab.transform && ((Component)t).CompareTag("snappoint") select t).ToArray(); for (int i = 0; i < array.Length; i++) { Object.DestroyImmediate((Object)(object)((Component)array[i]).gameObject); } } private static void RegisterPlatform() { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab("wood_floor"); if (!Object.op_Implicit((Object)(object)prefab)) { Logger.LogError((object)"Lift Platform: vanilla wood_floor missing."); return; } LiftPlatform.FrameMaterial = (from r in prefab.GetComponentsInChildren<MeshRenderer>(true) select ((Renderer)r).sharedMaterial).FirstOrDefault((Func<Material, bool>)((Material m) => Object.op_Implicit((Object)(object)m))); GameObject prefab2 = PrefabManager.Instance.CreateClonedPrefab("DP_LiftPlatform", prefab); if (Object.op_Implicit((Object)(object)prefab2)) { Transform[] array = (from t in prefab2.GetComponentsInChildren<Transform>(true) where Object.op_Implicit((Object)(object)t) && (Object)(object)t != (Object)(object)prefab2.transform && ((Component)t).CompareTag("snappoint") select t).ToArray(); for (int num = 0; num < array.Length; num++) { Object.DestroyImmediate((Object)(object)((Component)array[num]).gameObject); } GameObject visual = new GameObject("DP_Visual"); visual.transform.SetParent(prefab2.transform, false); array = (from Transform t in (IEnumerable)prefab2.transform where (Object)