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 MySix DisplayEverything v1.0.0
MySix.DisplayEverything.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using MySix.Core; using Unity.Collections; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("MySix.TestHarness")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] namespace MySix { internal static class ModVersion { public const string Value = "1.0.0"; } } namespace MySix.DisplayEverything { [BepInPlugin("com.mysix.displayeverything", "MySix Display Everything", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.mysix.displayeverything"; public const string PluginName = "MySix Display Everything"; public const string PluginVersion = "1.0.0"; private const int RequiredCoreApi = 1; internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; if (CorePlugin.RequireApi("MySix Display Everything", 1)) { Stands.Enabled = Settings.Register<bool>("MySix Display Everything", ((BaseUnityPlugin)this).Config.Bind<bool>("DisplayEverything", "Enabled", true, "Any item with a 3D model - anything you pick up off the ground as an object - can be put on the wall and horizontal item stands. Items the game already displays look exactly as before; the rest are shown with the model they have lying on the ground: lying down on the horizontal stand, hung like a plate on the wall stand, and made smaller if they would not fit."), (Scope)0, (string)null); DisplayModels.MaxSize = Settings.Register<float>("MySix Display Everything", ((BaseUnityPlugin)this).Config.Bind<float>("DisplayEverything", "MaxSize", 0.6f, "The largest an item shown from its ground model may be on the horizontal stand, in metres; bigger ones are made smaller to fit. On the wall stand they are kept a quarter smaller again, to sit within its plaque. Items the game already displays keep the game's own size."), (Scope)0, (string)null); _harmony = new Harmony("com.mysix.displayeverything"); _harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"MySix Display Everything 1.0.0 loaded"); } } private void Update() { DisplayModels.FitWaiting(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public static class DisplayModels { internal struct Pose { public int Up; public int Along; public bool Flat; } public static Setting<float> MaxSize; private static GameObject _holder; private static readonly Dictionary<string, GameObject> Made = new Dictionary<string, GameObject>(); private static readonly Dictionary<string, bool> Visible = new Dictionary<string, bool>(); private static readonly HashSet<GameObject> Ours = new HashSet<GameObject>(); private const string HandCopy = "equipoffset"; private static readonly HashSet<string> GameStood = new HashSet<string>(); private static Quaternion? _flatPose; private static Shader _standard; private static readonly Dictionary<Material, Material> Unswayed = new Dictionary<Material, Material>(); private const float LieDown = 2.5f; private const float FlatShare = 0.6f; private const float FaceShare = 1.75f; private const float StandShare = 0.55f; private const float SideShare = 1.1f; private const float WallShare = 0.75f; private const float Lift = 0.003f; private static readonly Queue<(ItemStand stand, GameObject visual, string item, List<Renderer> hidden)> Waiting = new Queue<(ItemStand, GameObject, string, List<Renderer>)>(); private const int MeasuredPerFrame = 2; private static int _frame = -1; private static int _measured; private static readonly HashSet<string> Fitted = new HashSet<string>(); public static GameObject GameAttach(GameObject item) { if (!((Object)(object)item != (Object)null)) { return null; } Transform obj = item.transform.Find("attach"); if (obj == null) { return null; } return ((Component)obj).gameObject; } public static bool HasModel(GameObject item) { if ((Object)(object)item == (Object)null) { return false; } if (Visible.TryGetValue(((Object)item).name, out var value)) { return value; } bool flag = false; Renderer[] componentsInChildren = item.GetComponentsInChildren<Renderer>(true); foreach (Renderer r in componentsInChildren) { flag |= IsGroundModel(r, item.transform); } Visible[((Object)item).name] = flag; return flag; } private static bool IsGroundModel(Renderer r, Transform root) { if (!r.enabled || r is ParticleSystemRenderer) { return false; } SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((r is SkinnedMeshRenderer) ? r : null); object obj; if (val == null) { MeshFilter component = ((Component)r).GetComponent<MeshFilter>(); obj = ((component != null) ? component.sharedMesh : null); } else { obj = val.sharedMesh; } if ((Object)obj == (Object)null) { return false; } Transform val2 = ((Component)r).transform; while ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)root) { if (!((Component)val2).gameObject.activeSelf || ((Object)val2).name == "equipoffset") { return false; } val2 = val2.parent; } return true; } public static bool IsOurs(GameObject attach) { if ((Object)(object)attach != (Object)null) { return Ours.Contains(attach); } return false; } public static bool Carried(ItemData item) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 if ((int)item.m_shared.m_itemType != 10 && item.m_shared.m_icons != null && item.m_shared.m_icons.Length != 0) { return (Object)(object)item.m_shared.m_icons[0] != (Object)null; } return false; } public static GameObject For(GameObject item) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) if (Made.TryGetValue(((Object)item).name, out var value) && (Object)(object)value != (Object)null) { return value; } if ((Object)(object)_holder == (Object)null) { _holder = new GameObject("MySix_DisplayModels"); _holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_holder); } GameObject val = new GameObject("attach"); val.transform.SetParent(_holder.transform, false); GameObject val2 = GameAttach(item); GameObject val3 = (((Object)(object)val2 != (Object)null && val2.GetComponentsInChildren<Renderer>(true).Any((Renderer r) => IsGroundModel(r, item.transform))) ? val2 : item); ZNetView.m_forceDisableInit = true; GameObject val4; try { val4 = Object.Instantiate<GameObject>(val3, val.transform, false); } finally { ZNetView.m_forceDisableInit = false; } ((Object)val4).name = ((Object)val3).name; val4.transform.localPosition = Vector3.zero; val4.transform.localRotation = (((Object)(object)val3 == (Object)(object)val2) ? (FlatPose() * val2.transform.localRotation) : Quaternion.identity); if ((Object)(object)val3 == (Object)(object)val2) { GameStood.Add(((Object)item).name); } Strip(val4); PlainPlants(val4); Made[((Object)item).name] = val; Ours.Add(val); return val; } private static Quaternion FlatPose() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (!_flatPose.HasValue) { GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("itemstandh") : null); ItemStand val2 = (((Object)(object)val != (Object)null) ? val.GetComponentInChildren<ItemStand>(true) : null); Transform val3 = (((Object)(object)val2 != (Object)null) ? val2.GetAttach((ItemData)null) : null); if ((Object)(object)val3 == (Object)null) { return Quaternion.identity; } _flatPose = Quaternion.Inverse(val.transform.rotation) * val3.rotation; } return _flatPose.Value; } public static bool IsPickupGlint(ParticleSystemRenderer r) { Material[] sharedMaterials = ((Renderer)r).sharedMaterials; foreach (Material val in sharedMaterials) { if ((Object)(object)val != (Object)null && ((Object)val).name.StartsWith("item_particle", StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private static void PlainPlants(GameObject copy) { //IL_00d7: 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_00f5: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_standard == (Object)null) { _standard = ((IEnumerable<Shader>)Resources.FindObjectsOfTypeAll<Shader>()).FirstOrDefault((Func<Shader, bool>)((Shader sh) => (Object)(object)sh != (Object)null && ((Object)sh).name == "Standard")); } if ((Object)(object)_standard == (Object)null) { Plugin.Log.LogWarning((object)"No Standard shader loaded; plants on stands keep the game's plant shader"); return; } Renderer[] componentsInChildren = copy.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; bool flag = false; for (int num2 = 0; num2 < sharedMaterials.Length; num2++) { Material val2 = sharedMaterials[num2]; if ((Object)(object)val2 == (Object)null || (Object)(object)val2.shader == (Object)null || ((Object)val2.shader).name.IndexOf("Vegetation", StringComparison.OrdinalIgnoreCase) < 0) { continue; } if (!Unswayed.TryGetValue(val2, out var value)) { value = new Material(_standard) { name = ((Object)val2).name + "_display" }; if (val2.HasProperty("_MainTex")) { value.mainTexture = val2.mainTexture; } if (val2.HasProperty("_Color")) { value.color = val2.color; } if (val2.HasProperty("_BumpMap") && (Object)(object)val2.GetTexture("_BumpMap") != (Object)null) { value.SetTexture("_BumpMap", val2.GetTexture("_BumpMap")); value.EnableKeyword("_NORMALMAP"); } value.SetFloat("_Mode", 1f); value.SetFloat("_Cutoff", val2.HasProperty("_Cutoff") ? val2.GetFloat("_Cutoff") : 0.5f); value.SetFloat("_Glossiness", 0.1f); value.EnableKeyword("_ALPHATEST_ON"); value.renderQueue = 2450; value.SetInt("_Cull", 0); Unswayed[val2] = value; } sharedMaterials[num2] = value; flag = true; } if (flag) { val.sharedMaterials = sharedMaterials; } } } private static void Strip(GameObject copy) { MonoBehaviour[] componentsInChildren = copy.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren) { if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } } Joint[] componentsInChildren2 = copy.GetComponentsInChildren<Joint>(true); foreach (Joint val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)val2); } } Transform[] componentsInChildren3 = copy.GetComponentsInChildren<Transform>(true); foreach (Transform val3 in componentsInChildren3) { if ((Object)(object)val3 != (Object)null && (Object)(object)val3 != (Object)(object)copy.transform && ((Object)val3).name == "equipoffset") { Object.DestroyImmediate((Object)(object)((Component)val3).gameObject); } } ParticleSystemRenderer[] componentsInChildren4 = copy.GetComponentsInChildren<ParticleSystemRenderer>(true); foreach (ParticleSystemRenderer val4 in componentsInChildren4) { if (!((Object)(object)val4 == (Object)null) && IsPickupGlint(val4)) { ParticleSystem component = ((Component)val4).GetComponent<ParticleSystem>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } if ((Object)(object)val4 != (Object)null) { Object.DestroyImmediate((Object)(object)val4); } } } Component[] componentsInChildren5 = copy.GetComponentsInChildren<Component>(true); foreach (Component val5 in componentsInChildren5) { if (!((Object)(object)val5 == (Object)null) && !(val5 is Transform) && !(val5 is MeshFilter) && !(val5 is Renderer) && !(val5 is LODGroup) && !(val5 is ParticleSystem) && !(val5 is Light) && !(val5 is Animator)) { Object.DestroyImmediate((Object)(object)val5); } } } internal static Pose Lying(Vector3 size, Vector3? faces, bool fish) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) float[] array = new float[3] { size.x, size.y, size.z }; int num = 0; int num2 = 0; for (int i = 1; i < 3; i++) { if (array[i] < array[num]) { num = i; } if (array[i] > array[num2]) { num2 = i; } } if (num2 == num) { num2 = (num + 1) % 3; } int num3 = 3 - num - num2; int num4 = num; bool flag = fish || array[num] < 0.6f * array[num3]; if (faces.HasValue) { Vector3 valueOrDefault = faces.GetValueOrDefault(); float[] array2 = new float[3] { valueOrDefault.x, valueOrDefault.y, valueOrDefault.z }; int num5 = 0; for (int j = 1; j < 3; j++) { if (array2[j] > array2[num5]) { num5 = j; } } if (fish || array2[num5] >= 1.75f * Mathf.Max(array2[(num5 + 1) % 3], array2[(num5 + 2) % 3])) { num4 = num5; flag = true; } } if (flag) { int num6 = (num4 + 1) % 3; int num7 = (num4 + 2) % 3; return new Pose { Up = num4, Along = ((array[num6] >= array[num7]) ? num6 : num7), Flat = true }; } if (size.y > 2.5f * Mathf.Max(size.x, size.z)) { return new Pose { Up = num, Along = 1 }; } return new Pose { Up = 1, Along = ((size.z > size.x) ? 2 : 0) }; } internal static void Hang(Vector3 size, Vector3? faces, Pose lying, bool gameStood, out int outAxis, out int upAxis) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) float[] array = new float[3] { size.x, size.y, size.z }; int num = 0; for (int i = 1; i < 3; i++) { if (array[i] > array[num]) { num = i; } } if (lying.Flat) { int num2 = (lying.Up + 1) % 3; int num3 = (lying.Up + 2) % 3; outAxis = lying.Up; upAxis = ((array[num2] >= array[num3]) ? num2 : num3); return; } int num4; if (faces.HasValue) { Vector3 valueOrDefault = faces.GetValueOrDefault(); num4 = ((valueOrDefault.y >= Mathf.Max(valueOrDefault.x, valueOrDefault.z)) ? 1 : 0); } else { num4 = 0; } bool flag = (byte)num4 != 0; upAxis = ((gameStood && !flag && lying.Up == 1 && array[1] >= 0.55f * array[num]) ? 1 : num); int num5 = (upAxis + 1) % 3; int num6 = (upAxis + 2) % 3; int num7 = ((array[num5] <= array[num6]) ? num5 : num6); int num8 = ((num7 == num5) ? num6 : num5); outAxis = num7; if (faces.HasValue) { Vector3 valueOrDefault2 = faces.GetValueOrDefault(); float[] array2 = new float[3] { valueOrDefault2.x, valueOrDefault2.y, valueOrDefault2.z }; if (array2[num8] > 1.1f * array2[num7]) { outAxis = num8; } } } public static void Fit(GameObject visual, Transform attachPoint, Transform stand, bool flat, string item = null) { //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_000d: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_028c: 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_028f: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: 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_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: 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_018d: 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_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) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: 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) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0220: 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_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: 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_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_0636: Unknown result type (might be due to invalid IL or missing references) //IL_0642: Unknown result type (might be due to invalid IL or missing references) //IL_0654: Unknown result type (might be due to invalid IL or missing references) //IL_0659: Unknown result type (might be due to invalid IL or missing references) //IL_065e: Unknown result type (might be due to invalid IL or missing references) //IL_0660: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_0665: Unknown result type (might be due to invalid IL or missing references) //IL_0671: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) //IL_0694: Unknown result type (might be due to invalid IL or missing references) //IL_0696: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_0599: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) Transform transform = visual.transform; Vector3 val = (flat ? Level(stand.forward) : OutOfStand(stand, attachPoint, visual)); Quaternion val2 = MainFrame(visual); Bounds local; bool flag = LocalBounds(visual, val2, out local); GameObject val3 = ((item != null && (Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(item) : null); bool flag2 = (Object)(object)val3 != (Object)null && Stands.IsFish(val3); Vector3[] array = (Vector3[])(object)new Vector3[3] { Vector3.right, Vector3.up, Vector3.forward }; Vector3 val4; if (!flag) { if (flat) { transform.rotation = Quaternion.LookRotation(val, Vector3.up); } } else if (!flat && Upright(visual)) { transform.rotation = Quaternion.LookRotation(val, Vector3.up); } else { Vector3 areas; Vector3? faces = (Drawn.Faces((item != null) ? (item + "|faces") : null, visual, val2, out areas) ? new Vector3?(areas) : ((Vector3?)null)); Pose lying = Lying(((Bounds)(ref local)).size, faces, flag2); if (!lying.Flat && val2 != Quaternion.identity) { val2 = Quaternion.identity; LocalBounds(visual, val2, out local); faces = (Drawn.Faces((item != null) ? (item + "|faces|model") : null, visual, val2, out areas) ? new Vector3?(areas) : ((Vector3?)null)); lying = Lying(((Bounds)(ref local)).size, faces, flag2); } if (flat) { val4 = Vector3.Cross(Vector3.up, val); Vector3 normalized = ((Vector3)(ref val4)).normalized; Quaternion val5 = Quaternion.LookRotation(array[lying.Along], array[lying.Up]); transform.rotation = Quaternion.LookRotation(normalized, Vector3.up) * Quaternion.Inverse(val5) * Quaternion.Inverse(val2); } else { Hang(((Bounds)(ref local)).size, faces, lying, item != null && GameStood.Contains(item), out var outAxis, out var upAxis); Quaternion val6 = Quaternion.LookRotation(array[outAxis], array[upAxis]); transform.rotation = Quaternion.LookRotation(val, Vector3.up) * Quaternion.Inverse(val6) * Quaternion.Inverse(val2); } } Vector3 up = Vector3.up; val4 = Vector3.Cross(up, val); Vector3 normalized2 = ((Vector3)(ref val4)).normalized; if (!Drawn.Measure((item != null) ? (item + (flat ? "|flat" : "|wall")) : null, visual, val, up, normalized2, out var reach)) { if (!Bounds(visual, out var bounds)) { return; } Vector3 val7 = ((Bounds)(ref bounds)).center - transform.position; float num = Vector3.Dot(val7, val); float num2 = Vector3.Dot(val7, up); float num3 = Vector3.Dot(val7, normalized2); reach = new Drawn.Reach { Out = new Vector2(num - HalfDepth(bounds, val), num + HalfDepth(bounds, val)), Up = new Vector2(num2 - HalfDepth(bounds, up), num2 + HalfDepth(bounds, up)), Across = new Vector2(num3 - HalfDepth(bounds, normalized2), num3 + HalfDepth(bounds, normalized2)) }; } float num4 = ((MaxSize != null) ? MaxSize.Value : 0.6f) * (flat ? 1f : 0.75f); float biggest = reach.Biggest; if (biggest > num4 && biggest > 0f && (!flag2 || !((Object)(object)GameAttach(val3) != (Object)null))) { transform.localScale *= num4 / biggest; reach = reach.Scaled(num4 / biggest); } Vector3 position = attachPoint.position; Vector3 position2 = transform.position; Vector3 val8 = normalized2 * (Vector3.Dot(position - position2, normalized2) - (reach.Across.x + reach.Across.y) / 2f); if (flat) { val8 += val * (Vector3.Dot(position - position2, val) - (reach.Out.x + reach.Out.y) / 2f); transform.position = position2 + val8; float num5 = float.NegativeInfinity; Renderer val9 = null; foreach (Renderer item2 in StandParts(stand)) { if (!Drawn.LowestOver((item != null) ? (item + "|rest|" + ((Object)stand).name + "|" + ((Object)item2).name) : null, visual, item2, val, out var lowest)) { continue; } float num6 = float.MinValue; foreach (Vector3 item3 in Drawn.Corners(item2)) { num6 = Mathf.Max(num6, item3.y); } if (num6 + 0.003f - lowest > num5) { num5 = num6 + 0.003f - lowest; val9 = item2; } } Bounds under; Renderer part; float num7 = Top(stand, attachPoint, out under, out part); if ((Object)(object)val9 != (Object)null) { part = val9; } if (float.IsNegativeInfinity(num5)) { num5 = num7 + 0.003f - (transform.position.y + reach.Up.x); } transform.position += up * num5; float num8 = transform.position.y + reach.Up.x; float num9 = Foot(stand) + 0.003f; if (num8 < num9) { transform.position += up * (num9 - num8); if ((Object)(object)part != (Object)null && num9 - num8 > 0.005f) { Pedestals.Raise(stand, part, num9 - num8); } } } else { val8 += up * (Vector3.Dot(position - position2, up) - (reach.Up.x + reach.Up.y) / 2f); val8 += val * (Face(stand, attachPoint, val) + 0.003f - Vector3.Dot(position2, val) - reach.Out.x); transform.position = position2 + val8; } } private static float Face(Transform stand, Transform attachPoint, Vector3 outward) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) List<Renderer> list = Pegs.Of(stand, attachPoint, outward); float num = float.MinValue; foreach (Renderer item in StandParts(stand)) { if (list.Contains(item)) { continue; } foreach (Vector3 item2 in Drawn.Corners(item)) { num = Mathf.Max(num, Vector3.Dot(item2, outward)); } } if (!(num > float.MinValue)) { return Vector3.Dot(attachPoint.position, outward); } return num; } internal static void FitOnStand(ItemStand stand, GameObject visual, string item) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) bool flag = Stands.IsFlat(stand); string item2 = (flag ? $"{item}|flat|{((Object)stand).name}|{Mathf.RoundToInt(Mathf.Abs(visual.transform.lossyScale.x) * 1000f)}" : (item + "|wall")); if (Drawn.CanMeasure && !Fitted.Contains(item2)) { if (_frame != Time.frameCount) { _frame = Time.frameCount; _measured = 0; } if (_measured >= 2) { List<Renderer> list = new List<Renderer>(); Renderer[] componentsInChildren = visual.GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if (val.enabled) { val.enabled = false; list.Add(val); } } Waiting.Enqueue((stand, visual, item, list)); return; } _measured++; } Fit(visual, stand.GetAttach((ItemData)null), ((Component)stand).transform, flag, item); Fitted.Add(item2); } internal static void FitWaiting() { while (Waiting.Count > 0) { if (_frame != Time.frameCount) { _frame = Time.frameCount; _measured = 0; } if (_measured >= 2) { break; } var (val, val2, item, list) = Waiting.Dequeue(); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)ShowAnything.VisualOf(val) != (Object)(object)val2) { continue; } foreach (Renderer item2 in list) { if ((Object)(object)item2 != (Object)null) { item2.enabled = true; } } FitOnStand(val, val2, item); } } private static float Top(Transform stand, Transform attachPoint, out Bounds under, out Renderer part) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) Vector3 position = attachPoint.position; float num = float.MinValue; under = default(Bounds); part = null; foreach (Renderer item in StandParts(stand)) { Bounds bounds = item.bounds; if (position.x >= ((Bounds)(ref bounds)).min.x - 0.01f && position.x <= ((Bounds)(ref bounds)).max.x + 0.01f && position.z >= ((Bounds)(ref bounds)).min.z - 0.01f && position.z <= ((Bounds)(ref bounds)).max.z + 0.01f && ((Bounds)(ref bounds)).max.y > num) { num = ((Bounds)(ref bounds)).max.y; under = bounds; part = item; } } if (!(num > float.MinValue)) { return position.y; } return num; } private static float Foot(Transform stand) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) float num = float.MaxValue; foreach (Renderer item in StandParts(stand)) { float num2 = num; Bounds bounds = item.bounds; num = Mathf.Min(num2, ((Bounds)(ref bounds)).min.y); } if (!(num < float.MaxValue)) { return stand.position.y; } return num; } internal static List<Renderer> StandParts(Transform stand) { List<Renderer> list = new List<Renderer>(); Renderer[] componentsInChildren = ((Component)stand).GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if (val.enabled && !(val is ParticleSystemRenderer) && !UnderAttach(((Component)val).transform, stand)) { list.Add(val); } } return list; } internal static bool UnderAttach(Transform t, Transform stand) { while ((Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)stand) { if (((Object)t).name.StartsWith("attach", StringComparison.Ordinal)) { return true; } t = t.parent; } return false; } private static Vector3 Level(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_001b: Unknown result type (might be due to invalid IL or missing references) v = Vector3.ProjectOnPlane(v, Vector3.up); if (!(((Vector3)(ref v)).sqrMagnitude > 1E-06f)) { return Vector3.forward; } return ((Vector3)(ref v)).normalized; } private static bool Upright(GameObject visual) { Renderer[] componentsInChildren = visual.GetComponentsInChildren<Renderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] sharedMaterials = componentsInChildren[i].sharedMaterials; foreach (Material val in sharedMaterials) { if ((Object)(object)val != (Object)null && (Object)(object)val.shader != (Object)null && ((Object)val.shader).name.IndexOf("Vegetation", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } } return false; } internal static Vector3 OutOfStand(Transform stand, Transform attachPoint, GameObject visual) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0099: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00de: 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) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Bounds b = default(Bounds); foreach (Renderer item in StandParts(stand)) { if (!((Object)(object)visual != (Object)null) || !((Component)item).transform.IsChildOf(visual.transform)) { if (!flag) { b = item.bounds; flag = true; } else { ((Bounds)(ref b)).Encapsulate(item.bounds); } } } Vector3 val = Vector3.zero; if (flag) { val = Vector3.ProjectOnPlane(attachPoint.position - ((Bounds)(ref b)).center, Vector3.up); if (((Vector3)(ref val)).magnitude < 0.02f) { Vector3 val2 = Vector3.ProjectOnPlane(stand.right, Vector3.up); Vector3 normalized = ((Vector3)(ref val2)).normalized; val2 = Vector3.ProjectOnPlane(stand.forward, Vector3.up); Vector3 normalized2 = ((Vector3)(ref val2)).normalized; val = ((HalfDepth(b, normalized) < HalfDepth(b, normalized2)) ? normalized : normalized2); } } if (((Vector3)(ref val)).sqrMagnitude < 1E-06f) { val = Vector3.ProjectOnPlane(stand.forward, Vector3.up); } if (((Vector3)(ref val)).sqrMagnitude < 1E-06f) { val = Vector3.forward; } return ((Vector3)(ref val)).normalized; } internal static bool LocalBounds(GameObject visual, out Bounds local) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return LocalBounds(visual, Quaternion.identity, out local); } internal static Quaternion MainFrame(GameObject visual) { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_0199: 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) Transform transform = visual.transform; Renderer val = null; float num = 0f; float num2 = 0f; Renderer[] componentsInChildren = visual.GetComponentsInChildren<Renderer>(); foreach (Renderer val2 in componentsInChildren) { SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((val2 is SkinnedMeshRenderer) ? val2 : null); object obj; if (val3 == null) { MeshFilter component = ((Component)val2).GetComponent<MeshFilter>(); obj = ((component != null) ? component.sharedMesh : null); } else { obj = val3.sharedMesh; } Mesh val4 = (Mesh)obj; if (!((Object)(object)val4 == (Object)null) && val2.enabled) { Bounds bounds = val4.bounds; Vector3 val5 = Vector3.Scale(((Bounds)(ref bounds)).size, ((Component)val2).transform.lossyScale); float num3 = Mathf.Abs(val5.x * val5.y * val5.z); num2 += num3; if (num3 > num) { num = num3; val = val2; } } } if ((Object)(object)val == (Object)null || num < 0.7f * num2) { return Quaternion.identity; } Quaternion val6 = Quaternion.Inverse(transform.rotation) * ((Component)val).transform.rotation; Vector3[] array = (Vector3[])(object)new Vector3[3] { Vector3.right, Vector3.up, Vector3.forward }; foreach (Vector3 val7 in array) { Vector3 val8 = val6 * val7; if (Mathf.Max(new float[3] { Mathf.Abs(val8.x), Mathf.Abs(val8.y), Mathf.Abs(val8.z) }) < 0.9998f) { return val6; } } return Quaternion.identity; } internal static bool LocalBounds(GameObject visual, Quaternion frame, out Bounds local) { //IL_0001: 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_0011: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) local = default(Bounds); bool flag = false; Transform transform = visual.transform; Quaternion val = Quaternion.Inverse(frame); Renderer[] componentsInChildren = visual.GetComponentsInChildren<Renderer>(); foreach (Renderer val2 in componentsInChildren) { Mesh val3 = null; if (val2 is MeshRenderer) { MeshFilter component = ((Component)val2).GetComponent<MeshFilter>(); val3 = ((component != null) ? component.sharedMesh : null); } else { SkinnedMeshRenderer val4 = (SkinnedMeshRenderer)(object)((val2 is SkinnedMeshRenderer) ? val2 : null); if (val4 != null) { val3 = val4.sharedMesh; } } if ((Object)(object)val3 == (Object)null || !val2.enabled) { continue; } Bounds bounds = val3.bounds; for (int j = 0; j < 8; j++) { Vector3 val5 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1)))); Vector3 val6 = val * transform.InverseTransformPoint(((Component)val2).transform.TransformPoint(val5)); if (!flag) { local = new Bounds(val6, Vector3.zero); flag = true; } else { ((Bounds)(ref local)).Encapsulate(val6); } } } return flag; } private static float HalfDepth(Bounds b, Vector3 d) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) return Mathf.Abs(d.x) * ((Bounds)(ref b)).extents.x + Mathf.Abs(d.y) * ((Bounds)(ref b)).extents.y + Mathf.Abs(d.z) * ((Bounds)(ref b)).extents.z; } private static bool Bounds(GameObject visual, out Bounds bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); bool flag = false; Renderer[] componentsInChildren = visual.GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if (!(val is ParticleSystemRenderer) && val.enabled) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } } return flag; } } internal static class Drawn { public struct Reach { public Vector2 Out; public Vector2 Up; public Vector2 Across; public float Biggest => Mathf.Max(Out.y - Out.x, Mathf.Max(Up.y - Up.x, Across.y - Across.x)); public Reach Scaled(float k) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) return new Reach { Out = Out * k, Up = Up * k, Across = Across * k }; } } private sealed class Film { public RenderTexture Target; public Texture2D Black; public Texture2D White; public int Size; } private sealed class Undo : IDisposable { private Action _undo; public Undo(Action undo) { _undo = undo; } public void Dispose() { _undo?.Invoke(); _undo = null; } } private sealed class Span { private float _min = float.MaxValue; private float _max = float.MinValue; public bool Any => _min <= _max; public Vector2 Range => new Vector2(_min, _max); public void Add(float v) { if (v < _min) { _min = v; } if (v > _max) { _max = v; } } } private const int Size = 192; private const int Small = 64; private static readonly Dictionary<string, Reach> Known = new Dictionary<string, Reach>(); private static readonly Dictionary<string, float> KnownRest = new Dictionary<string, float>(); private static readonly Dictionary<string, Vector3> KnownFaces = new Dictionary<string, Vector3>(); private static Camera _camera; private static Film _big; private static Film _small; private static int _layer = -1; private static int Layer { get { if (_layer < 0) { _layer = 0; for (int num = 31; num >= 8; num--) { if (string.IsNullOrEmpty(LayerMask.LayerToName(num))) { _layer = num; break; } } } return _layer; } } public static bool CanMeasure { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType != 4) { return Layer > 0; } return false; } } public static bool Knows(string key) { if (key != null) { return Known.ContainsKey(key); } return false; } public static bool Measure(string key, GameObject thing, Vector3 outward, Vector3 up, Vector3 across, out Reach reach) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0022: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_0178: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00b1: 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_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0271: 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_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: 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_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Abs(thing.transform.lossyScale.x); if (key != null && num > 0f && Known.TryGetValue(key, out reach)) { reach = reach.Scaled(num); return true; } reach = default(Reach); if (!CanMeasure) { return false; } List<Renderer> list = new List<Renderer>(); Bounds b = default(Bounds); Renderer[] componentsInChildren = thing.GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if (val.enabled && !(val is ParticleSystemRenderer)) { if (list.Count == 0) { b = val.bounds; } else { ((Bounds)(ref b)).Encapsulate(val.bounds); } list.Add(val); } } if (list.Count == 0) { return false; } Vector3 pivot = thing.transform.position; Span outs = new Span(); Span ups = new Span(); Span acrosses = new Span(); Vector3 extents = ((Bounds)(ref b)).extents; float num2 = Mathf.Max(((Vector3)(ref extents)).magnitude * 1.05f, 0.05f); using (Alone(thing, list)) { Photograph(((Bounds)(ref b)).center, across, up, num2, Side); Photograph(((Bounds)(ref b)).center, -across, up, num2, Side); Photograph(((Bounds)(ref b)).center, -outward, up, num2, Front); Photograph(((Bounds)(ref b)).center, outward, up, num2, Front); Photograph(((Bounds)(ref b)).center, -up, outward, num2, Top); } foreach (Renderer item in list) { Vector3 val2 = Facing(item); if (!(val2 == Vector3.zero)) { if (Mathf.Abs(Vector3.Dot(val2, outward)) > 0.9f) { Both(outs, item.bounds, pivot, outward); } else if (Mathf.Abs(Vector3.Dot(val2, up)) > 0.9f) { Both(ups, item.bounds, pivot, up); } else if (Mathf.Abs(Vector3.Dot(val2, across)) > 0.9f) { Both(acrosses, item.bounds, pivot, across); } } } if (!ups.Any) { Both(ups, b, pivot, up); } if (!outs.Any || !acrosses.Any) { return false; } Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor((0f - num2) / 192f, num2 / 192f); reach = new Reach { Out = outs.Range + val3, Up = ups.Range + val3, Across = acrosses.Range + val3 }; if (key != null && num > 0f) { Known[key] = reach.Scaled(1f / num); } return true; void Front(Vector3 p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) acrosses.Add(Vector3.Dot(p - pivot, across)); ups.Add(Vector3.Dot(p - pivot, up)); } void Side(Vector3 p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) outs.Add(Vector3.Dot(p - pivot, outward)); ups.Add(Vector3.Dot(p - pivot, up)); } void Top(Vector3 p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) acrosses.Add(Vector3.Dot(p - pivot, across)); outs.Add(Vector3.Dot(p - pivot, outward)); } } public static bool Faces(string key, GameObject thing, Quaternion frame, out Vector3 areas) { //IL_0006: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Abs(thing.transform.lossyScale.x); if (key != null && num > 0f && KnownFaces.TryGetValue(key, out areas)) { return true; } areas = default(Vector3); if (!CanMeasure || num <= 0f) { return false; } List<Renderer> list = new List<Renderer>(); Bounds val = default(Bounds); Renderer[] componentsInChildren = thing.GetComponentsInChildren<Renderer>(); foreach (Renderer val2 in componentsInChildren) { if (val2.enabled && !(val2 is ParticleSystemRenderer)) { if (list.Count == 0) { val = val2.bounds; } else { ((Bounds)(ref val)).Encapsulate(val2.bounds); } list.Add(val2); } } if (list.Count == 0) { return false; } Vector3 extents = ((Bounds)(ref val)).extents; float num2 = Mathf.Max(((Vector3)(ref extents)).magnitude * 1.05f, 0.05f); float num3 = 2f * num2 / 192f; Quaternion val3 = thing.transform.rotation * frame; Vector3[] array = (Vector3[])(object)new Vector3[3] { val3 * Vector3.right, val3 * Vector3.up, val3 * Vector3.forward }; Vector3[] array2 = (Vector3[])(object)new Vector3[3] { val3 * Vector3.up, val3 * Vector3.forward, val3 * Vector3.up }; int[] array3 = new int[3]; using (Alone(thing, list)) { for (int j = 0; j < 3; j++) { int[] array4 = new int[2] { 1, -1 }; foreach (int num4 in array4) { array3[j] = Mathf.Max(array3[j], Outline(((Bounds)(ref val)).center, array[j] * (float)num4, array2[j], num2)); } } } float num5 = num3 * num3 / (num * num); areas = new Vector3((float)array3[0] * num5, (float)array3[1] * num5, (float)array3[2] * num5); if (key != null) { KnownFaces[key] = areas; } return true; } public static bool LowestOver(string key, GameObject thing, Renderer top, Vector3 outward, out float lowest) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) lowest = 0f; float num = Mathf.Abs(thing.transform.lossyScale.x); Vector3 position = thing.transform.position; string text = ((key != null && num > 0f) ? (key + "|" + Mathf.RoundToInt(num * 1000f)) : null); if (text != null && KnownRest.TryGetValue(text, out var value)) { if (float.IsNaN(value)) { return false; } lowest = position.y + value; return true; } if (!CanMeasure || !Footprint(top, outward, out var mid, out var halfOut, out var halfAcross)) { return false; } List<Renderer> list = new List<Renderer>(); float num2 = float.MaxValue; float num3 = float.MinValue; Renderer[] componentsInChildren = thing.GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if (val.enabled && !(val is ParticleSystemRenderer)) { list.Add(val); float num4 = num2; Bounds bounds = val.bounds; num2 = Mathf.Min(num4, ((Bounds)(ref bounds)).min.y); float num5 = num3; bounds = val.bounds; num3 = Mathf.Max(num5, ((Bounds)(ref bounds)).max.y); } } if (list.Count == 0) { return false; } bool flag = false; using (Alone(thing, list)) { Camera cam = CameraFor(); float below = num2 - 0.5f; cam.orthographicSize = halfOut; cam.aspect = halfAcross / halfOut; cam.nearClipPlane = 0.01f; ((Component)cam).transform.position = new Vector3(mid.x, below, mid.z); ((Component)cam).transform.rotation = Quaternion.LookRotation(Vector3.up, outward); if (Shows(num3 + 0.001f)) { flag = true; float num6 = num2 - 0.001f; float num7 = num3 + 0.001f; while (num7 - num6 > 0.002f) { float num8 = (num6 + num7) / 2f; if (Shows(num8)) { num7 = num8; } else { num6 = num8; } } lowest = num7; } bool Shows(float h) { //IL_0039: 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) cam.farClipPlane = Mathf.Max(h - below, 0.02f); Shoot(Films(ref _small, 64), out var black, out var white); for (int j = 0; j < black.Length; j++) { if (IsDrawn(black[j], white[j])) { return true; } } return false; } } if (text != null) { KnownRest[text] = (flag ? (lowest - position.y) : float.NaN); } return flag; } private static bool Footprint(Renderer r, Vector3 outward, out Vector3 mid, out float halfOut, out float halfAcross) { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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) mid = default(Vector3); halfOut = (halfAcross = 0f); Vector3 val = Vector3.Cross(Vector3.up, outward); Vector3 normalized = ((Vector3)(ref val)).normalized; Span span = new Span(); Span span2 = new Span(); foreach (Vector3 item in Corners(r)) { span.Add(Vector3.Dot(item, outward)); span2.Add(Vector3.Dot(item, normalized)); } if (!span.Any) { return false; } mid = outward * ((span.Range.x + span.Range.y) / 2f) + normalized * ((span2.Range.x + span2.Range.y) / 2f); halfOut = Mathf.Max((span.Range.y - span.Range.x) / 2f, 0.005f); halfAcross = Mathf.Max((span2.Range.y - span2.Range.x) / 2f, 0.005f); return true; } internal static IEnumerable<Vector3> Corners(Renderer r) { SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((r is SkinnedMeshRenderer) ? r : null); object obj; if (val == null) { MeshFilter component = ((Component)r).GetComponent<MeshFilter>(); obj = ((component != null) ? component.sharedMesh : null); } else { obj = val.sharedMesh; } Mesh val2 = (Mesh)obj; if ((Object)(object)val2 == (Object)null) { Bounds b = r.bounds; for (int i = 0; i < 8; i++) { yield return ((Bounds)(ref b)).center + Vector3.Scale(((Bounds)(ref b)).extents, Sign(i)); } } else { Bounds m = val2.bounds; for (int i = 0; i < 8; i++) { yield return ((Component)r).transform.TransformPoint(((Bounds)(ref m)).center + Vector3.Scale(((Bounds)(ref m)).extents, Sign(i))); } } } private static Vector3 Sign(int i) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) return new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1))); } private static IDisposable Alone(GameObject thing, List<Renderer> parts) { List<Renderer> effects = new List<Renderer>(); Renderer[] componentsInChildren = thing.GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if (val is ParticleSystemRenderer && val.enabled) { effects.Add(val); val.enabled = false; } } List<(GameObject go, int layer)> layers = new List<(GameObject, int)>(); foreach (Renderer part in parts) { layers.Add((((Component)part).gameObject, ((Component)part).gameObject.layer)); ((Component)part).gameObject.layer = Layer; } CameraFor().cullingMask = 1 << Layer; return new Undo(delegate { foreach (var (val2, layer) in layers) { if ((Object)(object)val2 != (Object)null) { val2.layer = layer; } } foreach (Renderer item in effects) { if ((Object)(object)item != (Object)null) { item.enabled = true; } } }); } private static void Both(Span span, Bounds b, Vector3 pivot, Vector3 way) { //IL_0003: 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_0009: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) span.Add(Vector3.Dot(((Bounds)(ref b)).center - pivot, way) - HalfAlong(b, way)); span.Add(Vector3.Dot(((Bounds)(ref b)).center - pivot, way) + HalfAlong(b, way)); } private static Vector3 Facing(Renderer r) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((r is SkinnedMeshRenderer) ? r : null); object obj; if (val == null) { MeshFilter component = ((Component)r).GetComponent<MeshFilter>(); obj = ((component != null) ? component.sharedMesh : null); } else { obj = val.sharedMesh; } Mesh val2 = (Mesh)obj; if ((Object)(object)val2 == (Object)null) { return Vector3.zero; } Bounds bounds = val2.bounds; Vector3 val3 = Vector3.Scale(((Bounds)(ref bounds)).size, ((Component)r).transform.lossyScale); ((Vector3)(ref val3))..ctor(Mathf.Abs(val3.x), Mathf.Abs(val3.y), Mathf.Abs(val3.z)); float num = Mathf.Max(val3.x, Mathf.Max(val3.y, val3.z)); Vector3 val4 = ((val3.x <= val3.y && val3.x <= val3.z) ? Vector3.right : ((val3.y <= val3.z) ? Vector3.up : Vector3.forward)); float num2 = Vector3.Dot(val3, val4); if (!(num > 0f) || !(num2 < num * 0.02f)) { return Vector3.zero; } Vector3 val5 = ((Component)r).transform.TransformDirection(val4); return ((Vector3)(ref val5)).normalized; } private static float HalfAlong(Bounds b, Vector3 d) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) return Mathf.Abs(d.x) * ((Bounds)(ref b)).extents.x + Mathf.Abs(d.y) * ((Bounds)(ref b)).extents.y + Mathf.Abs(d.z) * ((Bounds)(ref b)).extents.z; } private static bool IsDrawn(Color32 onBlack, Color32 onWhite) { //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_0018: 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_0025: Unknown result type (might be due to invalid IL or missing references) if (onBlack.r + onBlack.g + onBlack.b <= 24) { return onWhite.r + onWhite.g + onWhite.b < 741; } return true; } private static int Outline(Vector3 centre, Vector3 look, Vector3 up, float half) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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) Aim(centre, look, up, half); Shoot(Films(ref _big, 192), out var black, out var white); int num = 0; for (int i = 0; i < 192; i++) { int num2 = -1; int num3 = -1; for (int j = 0; j < 192; j++) { if (IsDrawn(black[i * 192 + j], white[i * 192 + j])) { if (num2 < 0) { num2 = j; } num3 = j; } } if (num2 >= 0) { num += num3 - num2 + 1; } } return num; } private static void Aim(Vector3 centre, Vector3 look, Vector3 up, float half) { //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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) Camera obj = CameraFor(); obj.orthographicSize = half; obj.aspect = 1f; obj.nearClipPlane = 0.01f; obj.farClipPlane = half * 2f + 2f; ((Component)obj).transform.position = centre - look * (half + 1f); ((Component)obj).transform.rotation = Quaternion.LookRotation(look, up); } private static void Photograph(Vector3 centre, Vector3 look, Vector3 up, float half, Action<Vector3> drawn) { //IL_0005: 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_0007: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) Camera obj = CameraFor(); Aim(centre, look, up, half); Shoot(Films(ref _big, 192), out var black, out var white); Vector3 right = ((Component)obj).transform.right; Vector3 up2 = ((Component)obj).transform.up; for (int i = 0; i < 192; i++) { for (int j = 0; j < 192; j++) { if (IsDrawn(black[i * 192 + j], white[i * 192 + j])) { float num = (((float)j + 0.5f) / 192f * 2f - 1f) * half; float num2 = (((float)i + 0.5f) / 192f * 2f - 1f) * half; drawn(centre + right * num + up2 * num2); } } } } private static Camera CameraFor() { //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_001d: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_camera == (Object)null) { GameObject val = new GameObject("MySix_DisplayEverything_Measure"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; _camera = val.AddComponent<Camera>(); ((Behaviour)_camera).enabled = false; _camera.orthographic = true; _camera.clearFlags = (CameraClearFlags)2; _camera.allowHDR = false; _camera.allowMSAA = false; } return _camera; } private static Film Films(ref Film film, int size) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (film == null) { film = new Film { Size = size, Target = new RenderTexture(size, size, 24, (RenderTextureFormat)0), Black = new Texture2D(size, size, (TextureFormat)4, false), White = new Texture2D(size, size, (TextureFormat)4, false) }; } return film; } private static void Shoot(Film film, out NativeArray<Color32> black, out NativeArray<Color32> white) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_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_00c0: 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) Camera obj = CameraFor(); obj.targetTexture = film.Target; RenderTexture active = RenderTexture.active; RenderTexture.active = film.Target; obj.backgroundColor = Color.black; obj.Render(); film.Black.ReadPixels(new Rect(0f, 0f, (float)film.Size, (float)film.Size), 0, 0, false); obj.backgroundColor = Color.white; obj.Render(); film.White.ReadPixe