Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of More Workers Mono v1.0.0
Khundian.S1.MoreWorkers-Mono.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; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using FishNet; using FishNet.Managing; using HarmonyLib; using Khundian.S1.MoreWorkers; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using ScheduleOne.Dialogue; using ScheduleOne.NPCs; using ScheduleOne.NPCs.CharacterClasses; using ScheduleOne.Property; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Khundian")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Adds in-game tools to author and adjust worker idle points per property, with visual markers, hotkeys, and support for extra hire locations like Motel Room, RV, and Sewer office, including in‑game movement of existing/default idle points.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+6d3a2c4bce97cfcd364aafc69b9c83cb67129a6b")] [assembly: AssemblyProduct("Khundian.S1.MoreWorkers")] [assembly: AssemblyTitle("Khundian.S1.MoreWorkers-Mono")] [assembly: MelonInfo(typeof(MoreWorkersMod), "More Workers", "1.0.0", "Khundian", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Khundian.S1.MoreWorkers { internal static class AuthoringTools { private static object? _selectedInstance; private static string? _selectedName; private static int _selectedExistingIndex = -1; private static string? _selectedExistingProperty; private static int _selectedManualIndex = -1; private static string? _selectedManualProperty; private static int _selectedManualIdleIndex = -1; private static Texture2D? _bgTex; private const float MinManualIdleDistanceMeters = 0.25f; internal static int SelectedExistingIndex => _selectedExistingIndex; internal static string? SelectedExistingPropertyName => _selectedExistingProperty; internal static int SelectedManualIndex => _selectedManualIndex; internal static string? SelectedManualPropertyName => _selectedManualProperty; internal static int SelectedManualIdleIndex => _selectedManualIdleIndex; internal static void OnSceneLoaded() { _selectedInstance = null; _selectedName = null; _selectedExistingIndex = -1; _selectedExistingProperty = null; _selectedManualIndex = -1; _selectedManualProperty = null; _selectedManualIdleIndex = -1; } internal static void OnUpdate() { //IL_01e9: 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_02eb: 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_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_005c: 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_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) //IL_00f1: 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_00ea: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) MelonPreferences_Entry<bool>? authoringMode = MoreWorkersPreferences.AuthoringMode; if (authoringMode == null || !authoringMode.Value || !MoreWorkersPreferences.EnableHotkeysEffective) { return; } MelonPreferences_Entry<KeyCode>? captureKey = MoreWorkersPreferences.CaptureKey; int num = ((captureKey == null) ? 290 : ((int)captureKey.Value)); MelonPreferences_Entry<KeyCode>? reloadKey = MoreWorkersPreferences.ReloadKey; num = ((reloadKey == null) ? 291 : ((int)reloadKey.Value)); KeyCode val = (KeyCode)num; MelonPreferences_Entry<KeyCode>? removeKey = MoreWorkersPreferences.RemoveKey; num = ((removeKey == null) ? 292 : ((int)removeKey.Value)); KeyCode val2 = (KeyCode)num; if (Input.GetKeyDown((KeyCode)num)) { if (IsClientOnly()) { Log.Msg("Authoring is host-only in multiplayer; ask the host to add idle points."); try { MoreWorkersSms.NotifyHostOnlyAuthoring(); return; } catch { return; } } _selectedInstance = null; _selectedName = null; if (!EnsureSelectionFromNearest()) { Log.Msg("No properties available for capture."); return; } Transform refTransform = GetRefTransform(); if ((Object)(object)refTransform == (Object)null) { Log.Msg("Capture failed: no camera/player."); return; } Vector3 val3 = refTransform.position; Vector3 forward = refTransform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 1E-06f) { forward = Vector3.forward; } float num2 = Mathf.Atan2(forward.x, forward.z) * 57.29578f; if (MoreWorkersPreferences.SnapToGroundEffective) { val3 = SnapToGroundPosition(val3, out var _); } object obj2 = _selectedInstance ?? TryResolveInstanceByName(_selectedName); if (obj2 != null && HasIdleWithinDistance(obj2, val3, 0.0625f)) { Log.Msg($"Cannot add idle point: too close (<{0.25f:F1}m) to an existing idle point for '{_selectedName}'."); try { MoreWorkersSms.NotifyIdlePointTooClose(_selectedName); return; } catch { return; } } if (ManualIdlePoints.AppendPoint(_selectedName, val3, num2)) { Log.Msg("Captured point -> '" + _selectedName + "'."); try { TryAppendLivePoint(_selectedInstance ?? TryResolveInstanceByName(_selectedName), val3, num2); } catch { } DebugMarkers.RebuildAll(); try { PropertyPatches.ReapplyCapacityForAll(); } catch { } } else { Log.Msg("Failed to append point for '" + _selectedName + "'."); } } if (Input.GetKeyDown(val)) { if (IsClientOnly()) { Log.Msg("Authoring reload is host-only in multiplayer; ask the host to refresh idle points."); try { MoreWorkersSms.NotifyHostOnlyAuthoring(); return; } catch { return; } } ManualIdlePoints.Reload(); DebugMarkers.RebuildAll(); _selectedInstance = null; _selectedName = null; try { EnsureSelectionFromNearest(); } catch { } Log.Msg("Reloaded points.json and rebuilt markers."); } if (Input.GetKeyDown(val2)) { if (IsClientOnly()) { Log.Msg("Authoring is host-only in multiplayer; ask the host to remove idle points."); try { MoreWorkersSms.NotifyHostOnlyAuthoring(); return; } catch { return; } } _selectedInstance = null; _selectedName = null; if (!EnsureSelectionFromNearest()) { Log.Msg("No properties available for remove."); return; } if (string.IsNullOrWhiteSpace(_selectedName)) { return; } string selectedName = _selectedName; object obj9 = _selectedInstance ?? TryResolveInstanceByName(selectedName); if (obj9 == null) { Log.Msg("Unable to resolve property instance for '" + selectedName + "'. Cannot remove idle point live."); return; } if (TryRemoveLastManualIdlePointLive(selectedName, obj9)) { DebugMarkers.RebuildAll(); try { PropertyPatches.ReapplyCapacityForAll(); } catch { } } } MelonPreferences_Entry<KeyCode>? overrideExistingKey = MoreWorkersPreferences.OverrideExistingKey; int num3 = ((overrideExistingKey == null) ? 289 : ((int)overrideExistingKey.Value)); bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); if (Input.GetKeyDown((KeyCode)num3)) { if (flag) { TrySelectIdlePoint(); } else { TryMoveSelectedIdlePoint(); } } } internal static void OnGUI() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_004d: 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_005e: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Expected O, but got I4 //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Expected O, but got Unknown //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_042e: 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_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0296->IL0296: Incompatible stack types: O vs I4 //IL_0291->IL0296: Incompatible stack types: I4 vs O //IL_0291->IL0296: Incompatible stack types: O vs I4 MelonPreferences_Entry<bool>? authoringMode = MoreWorkersPreferences.AuthoringMode; if (authoringMode == null || !authoringMode.Value || !MoreWorkersPreferences.ShowOverlayHUDEffective) { return; } Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } GUIStyle val = new GUIStyle(GUI.skin.label); val.fontSize = 20; val.normal.textColor = Color.white; GUIStyle val2 = new GUIStyle(val); val2.normal.textColor = new Color(0f, 0f, 0f, 0.6f); string text = _selectedName ?? "(None)"; Vector3 position = ((Component)main).transform.position; Vector3 forward = ((Component)main).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude > 1E-06f) { ((Vector3)(ref forward)).Normalize(); } float num = Mathf.Atan2(forward.x, forward.z) * 57.29578f; string text2 = (MoreWorkersPreferences.SnapToGroundEffective ? "On" : "Off"); int num2 = 0; int num3 = 0; if (!string.IsNullOrWhiteSpace(_selectedName)) { num3 = ManualIdlePoints.GetForProperty(_selectedName)?.Count ?? 0; if (_selectedInstance != null) { num2 = GetExistingIdleCountFiltered(_selectedInstance, _selectedName); } else { Component val3 = TryResolveInstanceByName(_selectedName); if ((Object)(object)val3 != (Object)null) { num2 = GetExistingIdleCountFiltered(val3, _selectedName); } } } int num4 = num2 + num3; string text3 = string.Empty; if (_selectedManualIndex >= 0 && !string.IsNullOrWhiteSpace(_selectedManualProperty) && string.Equals(_selectedManualProperty, _selectedName, StringComparison.Ordinal)) { text3 = $" | Editing manual #{_selectedManualIndex}"; } else if (_selectedExistingIndex >= 0 && !string.IsNullOrWhiteSpace(_selectedExistingProperty) && string.Equals(_selectedExistingProperty, _selectedName, StringComparison.Ordinal)) { text3 = $" | Editing existing #{_selectedExistingIndex}"; } string text4 = "Authoring ON | Property: " + text; string text5 = $"Pos: {position.x:F2}, {position.y:F2}, {position.z:F2} | Yaw: {num:F1}° | Snap: {text2}"; string text6 = $"Next idx: {num4} (existing {num2} + manual {num3}){text3}"; object obj = "[{0}] Capture [{1}] Reload [{2}] Remove"; MelonPreferences_Entry<KeyCode>? captureKey = MoreWorkersPreferences.CaptureKey; int num5; if (captureKey != null) { obj = captureKey.Value; num5 = (int)obj; } else { num5 = 290; obj = num5; num5 = (int)obj; } object obj2 = (object)(KeyCode)obj; MelonPreferences_Entry<KeyCode>? reloadKey = MoreWorkersPreferences.ReloadKey; num5 = ((reloadKey == null) ? 291 : ((int)reloadKey.Value)); obj2 = (object)(KeyCode)num5; MelonPreferences_Entry<KeyCode>? removeKey = MoreWorkersPreferences.RemoveKey; num5 = ((removeKey == null) ? 292 : ((int)removeKey.Value)); string text7 = string.Format((string)num5, obj2, obj2, (object)(KeyCode)num5); float num6 = 10f; Rect safeArea = Screen.safeArea; float num7 = Mathf.Max(80f, ((Rect)(ref safeArea)).yMin + 40f); float num8 = (float)val.fontSize + 6f; string[] array = new string[4] { text4, text5, text6, text7 }; float num9 = 0f; for (int i = 0; i < array.Length; i++) { Vector2 val4 = val.CalcSize(new GUIContent(array[i])); if (val4.x > num9) { num9 = val4.x; } } safeArea = Screen.safeArea; float num10 = Mathf.Max(100f, ((Rect)(ref safeArea)).xMax - num6 - 10f); num9 = Mathf.Min(num9 + 2f, num10); float num11 = 6f; DrawOpaqueBackground(new Rect(num6 - num11, num7 - num11, num9 + num11 * 2f, num8 * (float)array.Length + num11 * 2f), new Color(0f, 0f, 0f, 0.6f)); DrawShadowedLabel(new Rect(num6, num7, num9, num8), text4, val, val2); num7 += num8; DrawShadowedLabel(new Rect(num6, num7, num9, num8), text5, val, val2); num7 += num8; DrawShadowedLabel(new Rect(num6, num7, num9, num8), text6, val, val2); num7 += num8; DrawShadowedLabel(new Rect(num6, num7, num9, num8), text7, val, val2); } private static void DrawShadowedLabel(Rect r, string text, GUIStyle style, GUIStyle shadow) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Rect val = r; ((Rect)(ref val)).x = ((Rect)(ref val)).x + 1f; ((Rect)(ref val)).y = ((Rect)(ref val)).y + 1f; GUI.Label(val, text, shadow); GUI.Label(r, text, style); } private static void DrawOpaqueBackground(Rect r, Color color) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_001b: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)_bgTex == (Object)null) { _bgTex = new Texture2D(1, 1, (TextureFormat)4, false); _bgTex.SetPixel(0, 0, Color.white); _bgTex.Apply(); } Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(r, (Texture)(object)_bgTex, (ScaleMode)0); GUI.color = color2; } catch { } } private static void TryMoveSelectedIdlePoint() { try { MelonPreferences_Entry<bool>? authoringMode = MoreWorkersPreferences.AuthoringMode; if (authoringMode == null || !authoringMode.Value) { return; } if (IsClientOnly()) { Log.Msg("Authoring is host-only in multiplayer; ask the host to move idle points."); try { MoreWorkersSms.NotifyHostOnlyAuthoring(); return; } catch { return; } } if (_selectedManualIndex >= 0 && !string.IsNullOrWhiteSpace(_selectedManualProperty)) { TryMoveSelectedManualIdlePoint(); } else if (_selectedExistingIndex >= 0 && !string.IsNullOrWhiteSpace(_selectedExistingProperty)) { TryMoveSelectedExistingIdlePoint(); } else { Log.Msg("No idle point selected. Use Shift+F8 to select one first."); } } catch { } } private static void TryAppendLivePoint(object? instanceObj, Vector3 pos, float yaw) { //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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_0180: Unknown result type (might be due to invalid IL or missing references) if (instanceObj == null) { return; } try { Type type = instanceObj.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("EmployeeIdlePoints", bindingAttr); FieldInfo fieldInfo = ((property == null) ? type.GetField("EmployeeIdlePoints", bindingAttr) : null); if (!(((property != null) ? property.GetValue(instanceObj, null) : fieldInfo?.GetValue(instanceObj)) is Transform[] array) || array.Length == 0) { Component val = (Component)((instanceObj is Component) ? instanceObj : null); if ((Object)(object)val == (Object)null) { return; } Quaternion rotation = Quaternion.Euler(0f, yaw, 0f); Transform transform = new GameObject("EmployeeIdlePoint_0").transform; transform.SetParent(val.transform, false); transform.position = pos; transform.rotation = rotation; try { if ((Object)(object)((Component)transform).gameObject != (Object)null) { ((Object)((Component)transform).gameObject).name = "EmployeeIdlePoint_0 (MW_MANUAL)"; } } catch { } Transform[] value = (Transform[])(object)new Transform[1] { transform }; if (property != null) { property.SetValue(instanceObj, value, null); } else { fieldInfo.SetValue(instanceObj, value); } return; } Transform val2 = null; foreach (Transform val3 in array) { if ((Object)(object)val3 != (Object)null) { val2 = val3; break; } } if ((Object)(object)val2 == (Object)null) { return; } Transform val4 = val2; foreach (Transform val5 in array) { if ((Object)(object)val5 != (Object)null) { Vector3 val6 = val5.position - pos; if (((Vector3)(ref val6)).sqrMagnitude <= 0.0625f) { return; } } } Quaternion val7 = Quaternion.Euler(0f, yaw, 0f); Transform val8 = Object.Instantiate<Transform>(val4, pos, val7); if ((Object)(object)val8 == (Object)null) { return; } Transform val9 = val8; try { if ((Object)(object)((Component)val9).gameObject != (Object)null) { GameObject gameObject = ((Component)val9).gameObject; GameObject gameObject2 = ((Component)val4).gameObject; ((Object)gameObject).name = (((gameObject2 != null) ? ((Object)gameObject2).name : null) ?? "IdlePoint") + " (MW_MANUAL)"; } } catch { } int num = array.Length; Transform[] array2 = (Transform[])(object)new Transform[num + 1]; if (num > 0) { Array.Copy(array, array2, num); } array2[num] = val9; if (property != null) { property.SetValue(instanceObj, array2, null); } else { fieldInfo.SetValue(instanceObj, array2); } } catch { } } private static int GetExistingIdleCount(object instance) { try { Type type = instance.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("EmployeeIdlePoints", bindingAttr); FieldInfo fieldInfo = ((property == null) ? type.GetField("EmployeeIdlePoints", bindingAttr) : null); Transform[] obj = ((property != null) ? property.GetValue(instance, null) : fieldInfo?.GetValue(instance)) as Transform[]; return (obj != null) ? obj.Length : 0; } catch { return 0; } } private static int GetExistingIdleCountFiltered(object instance, string propertyName) { try { List<Vector3> idlePositions = GetIdlePositions(instance, excludeManualTagged: true); if (idlePositions == null || idlePositions.Count == 0) { return 0; } return idlePositions.Count; } catch { return 0; } } private static bool IsNearAny(in Vector3 pos, List<Vector3> list, float epsilon) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float num = epsilon * epsilon; for (int i = 0; i < list.Count; i++) { Vector3 val = list[i] - pos; if (((Vector3)(ref val)).sqrMagnitude <= num) { return true; } } return false; } private static void TryRaycastSelect() { //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) try { Camera main = Camera.main; RaycastHit val = default(RaycastHit); if ((Object)(object)main == (Object)null || !Physics.Raycast(main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)), ref val, 1000f, -1, (QueryTriggerInteraction)1)) { return; } Component val2 = FindPropertyComponentUpwards(((RaycastHit)(ref val)).transform); if ((Object)(object)val2 != (Object)null) { string propertyName = GetPropertyName(val2); if (!string.IsNullOrWhiteSpace(propertyName)) { _selectedInstance = val2; _selectedName = propertyName; Log.Msg("Selected property: '" + propertyName + "'."); } } } catch { } } private static void TrySelectIdlePoint() { //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: 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_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) try { MelonPreferences_Entry<bool>? authoringMode = MoreWorkersPreferences.AuthoringMode; if (authoringMode == null || !authoringMode.Value) { return; } _selectedInstance = null; _selectedName = null; if (!EnsureSelectionFromNearest()) { Log.Msg("No properties available to select an idle point."); } else { if (string.IsNullOrWhiteSpace(_selectedName)) { return; } string selectedName = _selectedName; object obj = _selectedInstance ?? TryResolveInstanceByName(selectedName); if (obj == null) { Log.Msg("Unable to resolve property instance for '" + selectedName + "'."); return; } Transform refTransform = GetRefTransform(); if ((Object)(object)refTransform == (Object)null) { Log.Msg("Cannot select idle point: no camera/player reference available."); return; } int num = -1; float num2 = float.MaxValue; int num3 = -1; float num4 = float.MaxValue; try { Type type = obj.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("EmployeeIdlePoints", bindingAttr); FieldInfo fieldInfo = ((property == null) ? type.GetField("EmployeeIdlePoints", bindingAttr) : null); if (((property != null) ? property.GetValue(obj, null) : fieldInfo?.GetValue(obj)) is Transform[] array && array.Length != 0) { Vector3 position = refTransform.position; for (int i = 0; i < array.Length; i++) { Transform val = array[i]; if ((Object)(object)val == (Object)null) { continue; } bool flag = false; try { GameObject gameObject = ((Component)val).gameObject; if ((Object)(object)gameObject != (Object)null) { string name = ((Object)gameObject).name; if (!string.IsNullOrEmpty(name) && name.Contains("MW_MANUAL")) { flag = true; } } } catch { } float num5 = Vector3.Distance(position, val.position); if (flag) { if (num5 < num2) { num2 = num5; num = i; } } else if (num5 < num4) { num4 = num5; num3 = i; } } } } catch { } int num6 = -1; if (num >= 0) { try { List<ManualIdlePoints.IdlePointWorld> forProperty = ManualIdlePoints.GetForProperty(selectedName); if (forProperty != null && forProperty.Count > 0) { Type type2 = obj.GetType(); BindingFlags bindingAttr2 = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property2 = type2.GetProperty("EmployeeIdlePoints", bindingAttr2); FieldInfo fieldInfo2 = ((property2 == null) ? type2.GetField("EmployeeIdlePoints", bindingAttr2) : null); if (((property2 != null) ? property2.GetValue(obj, null) : fieldInfo2?.GetValue(obj)) is Transform[] array2 && num >= 0 && num < array2.Length) { Transform val2 = array2[num]; if ((Object)(object)val2 != (Object)null) { Vector3 position2 = val2.position; float num7 = float.MaxValue; int num8 = -1; for (int j = 0; j < forProperty.Count; j++) { float num9 = Vector3.Distance(position2, forProperty[j].Position); if (num9 < num7) { num7 = num9; num8 = j; } } num6 = num8; } } } } catch { } } int num10 = -1; if (MoreWorkersPreferences.OverrideExistingIdlePointsEffective) { num10 = num3; } if (num6 >= 0 || num10 >= 0) { bool flag2; if (!MoreWorkersPreferences.OverrideExistingIdlePointsEffective) { flag2 = num6 >= 0; } else if (num6 >= 0 && num10 >= 0) { Vector3 position3 = refTransform.position; float num11 = float.MaxValue; float num12 = float.MaxValue; List<ManualIdlePoints.IdlePointWorld> forProperty2 = ManualIdlePoints.GetForProperty(selectedName); if (forProperty2 != null && num6 >= 0 && num6 < forProperty2.Count) { num11 = Vector3.Distance(position3, forProperty2[num6].Position); } try { Type type3 = obj.GetType(); BindingFlags bindingAttr3 = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property3 = type3.GetProperty("EmployeeIdlePoints", bindingAttr3); FieldInfo fieldInfo3 = ((property3 == null) ? type3.GetField("EmployeeIdlePoints", bindingAttr3) : null); if (((property3 != null) ? property3.GetValue(obj, null) : fieldInfo3?.GetValue(obj)) is Transform[] array3 && num10 >= 0 && num10 < array3.Length) { Transform val3 = array3[num10]; if ((Object)(object)val3 != (Object)null) { num12 = Vector3.Distance(position3, val3.position); } } } catch { } flag2 = num11 <= num12; } else { flag2 = num6 >= 0; } if (flag2 && num6 >= 0) { _selectedManualIndex = num6; _selectedManualProperty = selectedName; _selectedManualIdleIndex = num; _selectedExistingIndex = -1; _selectedExistingProperty = null; Log.Msg($"Selected manual idle point #{num6} for '{selectedName}'. Press F8 to move it."); } else { _selectedExistingIndex = num10; _selectedExistingProperty = selectedName; _selectedManualIndex = -1; _selectedManualProperty = null; Log.Msg($"Selected existing idle point #{num10} for '{selectedName}'. Press F8 to move it."); } try { DebugMarkers.RebuildAll(); return; } catch { return; } } Log.Msg("No idle points found for '" + selectedName + "' to edit."); _selectedExistingIndex = -1; _selectedExistingProperty = null; _selectedManualIndex = -1; _selectedManualProperty = null; _selectedManualIdleIndex = -1; } } catch { } } private static int FindNearestExistingIdleIndex(object instance, Vector3 refPos) { //IL_00c3: 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) try { Type type = instance.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("EmployeeIdlePoints", bindingAttr); FieldInfo fieldInfo = ((property == null) ? type.GetField("EmployeeIdlePoints", bindingAttr) : null); if (!(((property != null) ? property.GetValue(instance, null) : fieldInfo?.GetValue(instance)) is Transform[] array) || array.Length == 0) { return -1; } int result = -1; float num = float.MaxValue; for (int i = 0; i < array.Length; i++) { Transform val = array[i]; if ((Object)(object)val == (Object)null) { continue; } try { GameObject gameObject = ((Component)val).gameObject; if ((Object)(object)gameObject != (Object)null) { string name = ((Object)gameObject).name; if (!string.IsNullOrEmpty(name) && name.Contains("MW_MANUAL")) { continue; } } } catch { } float num2 = Vector3.Distance(refPos, val.position); if (num2 < num) { num = num2; result = i; } } return result; } catch { return -1; } } private static int FindNearestManualIdleIndex(string propertyName, Vector3 refPos) { //IL_0023: 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) try { List<ManualIdlePoints.IdlePointWorld> forProperty = ManualIdlePoints.GetForProperty(propertyName); if (forProperty == null || forProperty.Count == 0) { return -1; } int result = -1; float num = float.MaxValue; for (int i = 0; i < forProperty.Count; i++) { float num2 = Vector3.Distance(refPos, forProperty[i].Position); if (num2 < num) { num = num2; result = i; } } return result; } catch { return -1; } } private static void TryMoveSelectedExistingIdlePoint() { //IL_0208: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_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_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) try { MelonPreferences_Entry<bool>? authoringMode = MoreWorkersPreferences.AuthoringMode; if (authoringMode == null || !authoringMode.Value) { return; } if (IsClientOnly()) { Log.Msg("Authoring is host-only in multiplayer; ask the host to move existing idle points."); } else { if (!MoreWorkersPreferences.OverrideExistingIdlePointsEffective) { return; } if (_selectedExistingIndex < 0 || string.IsNullOrWhiteSpace(_selectedExistingProperty)) { Log.Msg("No existing idle point selected. Use Shift+F8 to select one first."); return; } string selectedExistingProperty = _selectedExistingProperty; object obj = _selectedInstance ?? TryResolveInstanceByName(selectedExistingProperty); if (obj == null) { Log.Msg("Unable to resolve property instance for '" + selectedExistingProperty + "'."); _selectedExistingIndex = -1; _selectedExistingProperty = null; return; } Transform refTransform = GetRefTransform(); if ((Object)(object)refTransform == (Object)null) { Log.Msg("Cannot move existing idle point: no camera/player reference available."); return; } Vector3 val = refTransform.position; Vector3 forward = refTransform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 1E-06f) { forward = Vector3.forward; } float num = Mathf.Atan2(forward.x, forward.z) * 57.29578f; if (MoreWorkersPreferences.SnapToGroundEffective) { val = SnapToGroundPosition(val, out var _); } try { Type type = obj.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("EmployeeIdlePoints", bindingAttr); FieldInfo fieldInfo = ((property == null) ? type.GetField("EmployeeIdlePoints", bindingAttr) : null); if (((property != null) ? property.GetValue(obj, null) : fieldInfo?.GetValue(obj)) is Transform[] array && array.Length != 0) { float num2 = 0.0625f; for (int i = 0; i < array.Length; i++) { if (i == _selectedExistingIndex) { continue; } Transform val2 = array[i]; if (!((Object)(object)val2 == (Object)null)) { Vector3 val3 = val2.position - val; if (((Vector3)(ref val3)).sqrMagnitude <= num2) { Log.Msg($"Cannot move existing idle point #{_selectedExistingIndex} for '{selectedExistingProperty}': too close (<{0.25f:F1}m) to another idle point."); return; } } } } } catch { } if (!ManualIdlePoints.UpsertExistingOverride(selectedExistingProperty, _selectedExistingIndex, val, num)) { Log.Msg($"Failed to update existing idle point #{_selectedExistingIndex} for '{selectedExistingProperty}'."); return; } try { Type type2 = obj.GetType(); BindingFlags bindingAttr2 = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property2 = type2.GetProperty("EmployeeIdlePoints", bindingAttr2); FieldInfo fieldInfo2 = ((property2 == null) ? type2.GetField("EmployeeIdlePoints", bindingAttr2) : null); if (((property2 != null) ? property2.GetValue(obj, null) : fieldInfo2?.GetValue(obj)) is Transform[] array2 && _selectedExistingIndex >= 0 && _selectedExistingIndex < array2.Length) { Transform val4 = array2[_selectedExistingIndex]; if ((Object)(object)val4 != (Object)null) { val4.position = val; val4.rotation = Quaternion.Euler(0f, num, 0f); } } } catch { } Log.Msg($"Moved existing idle point #{_selectedExistingIndex} for '{selectedExistingProperty}'."); _selectedExistingIndex = -1; _selectedExistingProperty = null; DebugMarkers.RebuildAll(); } } catch { } } private static void TryMoveSelectedManualIdlePoint() { //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_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_00f5: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) try { MelonPreferences_Entry<bool>? authoringMode = MoreWorkersPreferences.AuthoringMode; if (authoringMode == null || !authoringMode.Value) { return; } if (_selectedManualIndex < 0 || string.IsNullOrWhiteSpace(_selectedManualProperty) || _selectedManualIdleIndex < 0) { Log.Msg("No manual idle point selected. Use Shift+F8 to select one first."); return; } string selectedManualProperty = _selectedManualProperty; object obj = _selectedInstance ?? TryResolveInstanceByName(selectedManualProperty); if (obj == null) { Log.Msg("Unable to resolve property instance for '" + selectedManualProperty + "'."); _selectedManualIndex = -1; _selectedManualProperty = null; return; } Transform refTransform = GetRefTransform(); if ((Object)(object)refTransform == (Object)null) { Log.Msg("Cannot move manual idle point: no camera/player reference available."); return; } Vector3 val = refTransform.position; Vector3 forward = refTransform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 1E-06f) { forward = Vector3.forward; } float num = Mathf.Atan2(forward.x, forward.z) * 57.29578f; if (MoreWorkersPreferences.SnapToGroundEffective) { val = SnapToGroundPosition(val, out var _); } try { Type type = obj.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("EmployeeIdlePoints", bindingAttr); FieldInfo fieldInfo = ((property == null) ? type.GetField("EmployeeIdlePoints", bindingAttr) : null); if (((property != null) ? property.GetValue(obj, null) : fieldInfo?.GetValue(obj)) is Transform[] array && array.Length != 0) { float num2 = 0.0625f; for (int i = 0; i < array.Length; i++) { Transform val2 = array[i]; if (!((Object)(object)val2 == (Object)null) && i != _selectedManualIdleIndex) { Vector3 val3 = val2.position - val; if (((Vector3)(ref val3)).sqrMagnitude <= num2) { Log.Msg($"Cannot move manual idle point #{_selectedManualIndex} for '{selectedManualProperty}': too close (<{0.25f:F1}m) to another idle point."); return; } } } } } catch { } if (!ManualIdlePoints.UpdateManualPoint(selectedManualProperty, _selectedManualIndex, val, num)) { Log.Msg($"Failed to update manual idle point #{_selectedManualIndex} for '{selectedManualProperty}'."); return; } try { Type type2 = obj.GetType(); BindingFlags bindingAttr2 = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property2 = type2.GetProperty("EmployeeIdlePoints", bindingAttr2); FieldInfo fieldInfo2 = ((property2 == null) ? type2.GetField("EmployeeIdlePoints", bindingAttr2) : null); if (((property2 != null) ? property2.GetValue(obj, null) : fieldInfo2?.GetValue(obj)) is Transform[] array2 && array2.Length != 0 && _selectedManualIdleIndex >= 0 && _selectedManualIdleIndex < array2.Length) { Transform val4 = array2[_selectedManualIdleIndex]; if ((Object)(object)val4 != (Object)null) { val4.position = val; val4.rotation = Quaternion.Euler(0f, num, 0f); } } } catch { } Log.Msg($"Moved manual idle point #{_selectedManualIndex} for '{selectedManualProperty}'."); _selectedManualIndex = -1; _selectedManualProperty = null; _selectedManualIdleIndex = -1; DebugMarkers.RebuildAll(); } catch { } } private static bool HasIdleWithinDistance(object instance, Vector3 pos, float minSqr) { //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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) try { Type type = instance.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("EmployeeIdlePoints", bindingAttr); FieldInfo fieldInfo = ((property == null) ? type.GetField("EmployeeIdlePoints", bindingAttr) : null); if (!(((property != null) ? property.GetValue(instance, null) : fieldInfo?.GetValue(instance)) is Transform[] array) || array.Length == 0) { return false; } foreach (Transform val in array) { if (!((Object)(object)val == (Object)null)) { Vector3 val2 = val.position - pos; if (((Vector3)(ref val2)).sqrMagnitude <= minSqr) { return true; } } } } catch { } return false; } private static bool IsClientOnly() { try { NetworkManager networkManager = InstanceFinder.NetworkManager; if ((Object)(object)networkManager == (Object)null) { return false; } return networkManager.IsClient && !networkManager.IsServer; } catch { return false; } } private static bool TryRemoveLastManualIdlePointLive(string propertyName, object instance) { if (string.IsNullOrWhiteSpace(propertyName)) { return false; } try { List<ManualIdlePoints.IdlePointWorld> forProperty = ManualIdlePoints.GetForProperty(propertyName); if (forProperty == null || forProperty.Count == 0) { Log.Msg("No manual points to remove for '" + propertyName + "'."); return false; } Type type = instance.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("EmployeeIdlePoints", bindingAttr); FieldInfo fieldInfo = ((property == null) ? type.GetField("EmployeeIdlePoints", bindingAttr) : null); if (!(((property != null) ? property.GetValue(instance, null) : fieldInfo?.GetValue(instance)) is Transform[] array) || array.Length == 0) { Log.Msg("Property '" + propertyName + "' has no live idle points; cannot remove idle point in this scene."); return false; } int num = -1; Transform val = null; for (int num2 = array.Length - 1; num2 >= 0; num2--) { Transform val2 = array[num2]; if (!((Object)(object)val2 == (Object)null)) { bool flag = false; try { GameObject gameObject = ((Component)val2).gameObject; if ((Object)(object)gameObject != (Object)null) { string name = ((Object)gameObject).name; if (!string.IsNullOrEmpty(name) && name.Contains("MW_MANUAL")) { flag = true; } } } catch { } if (flag) { num = num2; val = val2; break; } } } if (num < 0 || (Object)(object)val == (Object)null) { Log.Msg("No MW_MANUAL idle transform found to remove for '" + propertyName + "'."); return false; } if (IsIdlePointInUseByEmployees(instance, val)) { Log.Msg("Cannot remove idle point for '" + propertyName + "': an employee is assigned to it."); try { MoreWorkersSms.NotifyIdlePointInUse(propertyName); } catch { } return false; } if (!ManualIdlePoints.PopLast(propertyName)) { Log.Msg("Failed to update points.json while removing idle point for '" + propertyName + "'."); return false; } Transform[] array2 = array; _ = array2.Length; _ = 1; Transform[] array3 = (Transform[])(object)new Transform[array2.Length - 1]; int num3 = 0; for (int i = 0; i < array2.Length; i++) { if (i != num) { array3[num3++] = array2[i]; } } if (property != null) { property.SetValue(instance, array3, null); } else { fieldInfo.SetValue(instance, array3); } try { GameObject gameObject2 = ((Component)val).gameObject; if ((Object)(object)gameObject2 != (Object)null) { Object.Destroy((Object)(object)gameObject2); } } catch { } Log.Msg("Removed last manual idle point for '" + propertyName + "' (live + JSON)."); return true; } catch { return false; } } private static bool IsIdlePointInUseByEmployees(object propertyInstance, Transform candidate) { if (propertyInstance == null || (Object)(object)candidate == (Object)null) { return false; } try { Type type = propertyInstance.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("Employees", bindingAttr); if (property == null) { return false; } object value = property.GetValue(propertyInstance, null); if (value == null) { return false; } if (value is IEnumerable enumerable) { foreach (object item in enumerable) { if (item != null) { Transform val = TryGetIdlePointForEmployee(item); if (!((Object)(object)val == (Object)null) && (Object)(object)val == (Object)(object)candidate) { return true; } } } return false; } Type type2 = value.GetType(); PropertyInfo property2 = type2.GetProperty("Count", bindingAttr); PropertyInfo property3 = type2.GetProperty("Item", bindingAttr, null, null, new Type[1] { typeof(int) }, null); if (property2 == null || property3 == null) { return false; } int num = 0; try { num = (int)(property2.GetValue(value, null) ?? ((object)0)); } catch { } if (num <= 0) { return false; } for (int i = 0; i < num; i++) { object obj2 = null; try { obj2 = property3.GetValue(value, new object[1] { i }); } catch { } if (obj2 != null) { Transform val2 = TryGetIdlePointForEmployee(obj2); if (!((Object)(object)val2 == (Object)null) && (Object)(object)val2 == (Object)(object)candidate) { return true; } } } } catch { } return false; } private static Transform? TryGetIdlePointForEmployee(object empObj) { if (empObj == null) { return null; } try { Type type = empObj.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("WaitOutside", bindingAttr); if (property == null) { return null; } object value = property.GetValue(empObj, null); if (value == null) { return null; } PropertyInfo property2 = value.GetType().GetProperty("IdlePoint", bindingAttr); if (property2 == null) { return null; } object? value2 = property2.GetValue(value, null); return (Transform?)((value2 is Transform) ? value2 : null); } catch { return null; } } private static void TrySelectNearestFromIndex() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) try { Transform refTransform = GetRefTransform(); if ((Object)(object)refTransform == (Object)null) { return; } PropertyIndex.Entry[] array = PropertyIndex.Snapshot(); if (array.Length == 0) { return; } string text = null; Component selectedInstance = null; float num = float.MaxValue; foreach (PropertyIndex.Entry entry in array) { float num2 = float.MaxValue; if (entry.IdlePoints != null && entry.IdlePoints.Length != 0) { for (int j = 0; j < entry.IdlePoints.Length; j++) { float num3 = Vector3.Distance(refTransform.position, entry.IdlePoints[j]); if (num3 < num2) { num2 = num3; } } } else { num2 = Vector3.Distance(refTransform.position, entry.Anchor); } if (num2 < num) { num = num2; text = entry.Name; object? instance = entry.Instance; selectedInstance = (Component)((instance is Component) ? instance : null); } } if (!string.IsNullOrWhiteSpace(text)) { _selectedName = text; _selectedInstance = selectedInstance; } } catch { } } private static bool EnsureSelectionFromNearest() { //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrWhiteSpace(_selectedName)) { return true; } Transform refTransform = GetRefTransform(); if ((Object)(object)refTransform == (Object)null) { return false; } PropertyIndex.Entry[] array = PropertyIndex.Snapshot(); if (array.Length != 0) { string text = null; Component selectedInstance = null; float num = float.MaxValue; foreach (PropertyIndex.Entry entry in array) { float num2 = float.MaxValue; if (entry.IdlePoints != null && entry.IdlePoints.Length != 0) { for (int j = 0; j < entry.IdlePoints.Length; j++) { float num3 = Vector3.Distance(refTransform.position, entry.IdlePoints[j]); if (num3 < num2) { num2 = num3; } } } else { num2 = Vector3.Distance(refTransform.position, entry.Anchor); } if (num2 < num) { num = num2; text = entry.Name; object? instance = entry.Instance; selectedInstance = (Component)((instance is Component) ? instance : null); } } if (!string.IsNullOrWhiteSpace(text)) { _selectedName = text; _selectedInstance = selectedInstance; return true; } } Type type = ResolvePropertyType(); if (type == null) { return false; } Component selectedInstance2 = null; string text2 = null; float num4 = float.MaxValue; foreach (object item in EnumerateProperties(type)) { string text3 = null; try { Component val = (Component)((item is Component) ? item : null); text3 = (((Object)(object)val != (Object)null) ? GetPropertyName(val) : GetPropertyNameViaObject(item)); } catch { } if (!string.IsNullOrWhiteSpace(text3)) { float num5 = DistanceToProperty(refTransform.position, item); if (num5 < num4) { num4 = num5; text2 = text3; selectedInstance2 = (Component)((item is Component) ? item : null); } } } if (!string.IsNullOrWhiteSpace(text2)) { _selectedInstance = selectedInstance2; _selectedName = text2; return true; } return false; } private static Transform? GetRefTransform() { try { GameObject val = GameObject.FindWithTag("Player") ?? GameObject.FindWithTag("LocalPlayer"); if ((Object)(object)val != (Object)null) { return val.transform; } } catch { } Camera main = Camera.main; if ((Object)(object)main != (Object)null) { return ((Component)main).transform; } return null; } private static string? GetPropertyNameViaObject(object inst) { try { Type type = inst.GetType(); PropertyInfo property = type.GetProperty("PropertyName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { object value = property.GetValue(inst, null); return (value as string) ?? value?.ToString(); } FieldInfo field = type.GetField("PropertyName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object value2 = field.GetValue(inst); return (value2 as string) ?? value2?.ToString(); } } catch { } return null; } private static Vector3? TryGetAnchor(object inst) { //IL_0016: 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_00a9: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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) try { Component val = (Component)((inst is Component) ? inst : null); if ((Object)(object)val != (Object)null) { return val.transform.position; } Type type = inst.GetType(); PropertyInfo property = type.GetProperty("EmployeeIdlePoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo fieldInfo = ((property == null) ? type.GetField("EmployeeIdlePoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null); if (((property != null) ? property.GetValue(inst) : fieldInfo?.GetValue(inst)) is Transform[] array && array.Length != 0) { Vector3 val2 = Vector3.zero; int num = 0; Transform[] array2 = array; foreach (Transform val3 in array2) { if ((Object)(object)val3 != (Object)null) { val2 += val3.position; num++; } } if (num > 0) { return val2 / (float)num; } } } catch { } return null; } private static List<Vector3>? GetIdlePositions(object inst, bool excludeManualTagged = false) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) try { Type type = inst.GetType(); PropertyInfo property = type.GetProperty("EmployeeIdlePoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo fieldInfo = ((property == null) ? type.GetField("EmployeeIdlePoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null); if (((property != null) ? property.GetValue(inst) : fieldInfo?.GetValue(inst)) is Transform[] array && array.Length != 0) { List<Vector3> list = new List<Vector3>(array.Length); Transform[] array2 = array; foreach (Transform val in array2) { if ((Object)(object)val == (Object)null) { continue; } if (excludeManualTagged) { try { GameObject gameObject = ((Component)val).gameObject; if ((Object)(object)gameObject != (Object)null) { string name = ((Object)gameObject).name; if (!string.IsNullOrEmpty(name) && name.Contains("MW_MANUAL")) { continue; } } } catch { } } list.Add(val.position); } return list; } } catch { } return null; } private static float DistanceToProperty(Vector3 refPos, object? inst) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0029: 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) if (inst == null) { return float.MaxValue; } try { List<Vector3> idlePositions = GetIdlePositions(inst, excludeManualTagged: true); if (idlePositions != null && idlePositions.Count > 0) { float num = float.MaxValue; for (int i = 0; i < idlePositions.Count; i++) { float num2 = Vector3.Distance(refPos, idlePositions[i]); if (num2 < num) { num = num2; } } return num; } Component val = (Component)((inst is Component) ? inst : null); if ((Object)(object)val != (Object)null) { return Vector3.Distance(refPos, val.transform.position); } Vector3? val2 = TryGetAnchor(inst); if (val2.HasValue) { return Vector3.Distance(refPos, val2.Value); } } catch { } return float.MaxValue; } private static void TrySelectNearestToCamera() { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00d8: 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_00fd: Unknown result type (might be due to invalid IL or missing references) try { Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } Vector3 position = ((Component)main).transform.position; Vector3 forward = ((Component)main).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude > 1E-06f) { ((Vector3)(ref forward)).Normalize(); } Type type = ResolvePropertyType(); if (type == null) { return; } float num = -1f; float num2 = float.MaxValue; Component val = null; float num3 = float.MaxValue; Component val2 = null; foreach (object item in EnumerateProperties(type)) { Component val3 = (Component)((item is Component) ? item : null); if ((Object)(object)val3 == (Object)null) { continue; } Vector3 val4 = val3.transform.position - position; float magnitude = ((Vector3)(ref val4)).magnitude; if (!(magnitude <= 0.0001f)) { Vector3 val5 = val4 / magnitude; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude > 1E-06f) { ((Vector3)(ref val5)).Normalize(); } float num4 = Vector3.Dot(val5, forward); if (magnitude < num3) { num3 = magnitude; val2 = val3; } if (num4 > 0.35f && ((Object)(object)val == (Object)null || magnitude < num2 || (Mathf.Approximately(magnitude, num2) && num4 > num))) { val = val3; num2 = magnitude; num = num4; } } } Component val6 = val ?? val2; if ((Object)(object)val6 != (Object)null) { string propertyName = GetPropertyName(val6); if (!string.IsNullOrWhiteSpace(propertyName)) { _selectedInstance = val6; _selectedName = propertyName; Log.Msg("Selected nearest property: '" + propertyName + "'."); } } } catch { } } private static Type? ResolvePropertyType() { return FindTypeByNames("ScheduleOne.Property.Property", "Il2CppScheduleOne.Property.Property"); } private static Component? TryResolveInstanceByName(string name) { try { PropertyIndex.Entry[] array = PropertyIndex.Snapshot(); for (int i = 0; i < array.Length; i++) { if (string.Equals(array[i].Name, name, StringComparison.OrdinalIgnoreCase)) { object? instance = array[i].Instance; Component val = (Component)((instance is Component) ? instance : null); if ((Object)(object)val != (Object)null) { return val; } } } } catch { } try { Type type = ResolvePropertyType(); if (type == null) { return null; } foreach (object item in EnumerateProperties(type)) { Component val2 = (Component)((item is Component) ? item : null); string text = (((Object)(object)val2 != (Object)null) ? GetPropertyName(val2) : GetPropertyNameViaObject(item)); if (!string.IsNullOrWhiteSpace(text) && string.Equals(text, name, StringComparison.OrdinalIgnoreCase)) { return val2; } } } catch { } return null; } private static Type? FindTypeByNames(params string[] names) { try { string[] array = names; for (int i = 0; i < array.Length; i++) { Type type = Type.GetType(array[i], throwOnError: false); if (type != null) { return type; } } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { array = names; foreach (string name in array) { Type type2 = assembly.GetType(name, throwOnError: false); if (type2 != null) { return type2; } } } } catch { } return null; } private static IEnumerable<object> EnumerateProperties(Type type) { object obj = null; try { BindingFlags bindingAttr = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo fieldInfo = type.GetField("Properties", bindingAttr) ?? type.GetField("OwnedProperties", bindingAttr); if (fieldInfo != null) { obj = fieldInfo.GetValue(null); } if (obj == null) { PropertyInfo propertyInfo = type.GetProperty("Properties", bindingAttr) ?? type.GetProperty("OwnedProperties", bindingAttr); if (propertyInfo != null) { obj = propertyInfo.GetValue(null, null); } } } catch { } if (!(obj is IEnumerable enumerable)) { yield break; } foreach (object item in enumerable) { if (item != null) { yield return item; } } } private static Component? FindPropertyComponentUpwards(Transform t) { Transform val = t; int num = 0; while ((Object)(object)val != (Object)null && num < 12) { Component[] array; try { array = ((Component)val).GetComponents<Component>(); } catch { array = Array.Empty<Component>(); } Component[] array2 = array; foreach (Component val2 in array2) { if ((Object)(object)val2 == (Object)null) { continue; } try { if (!string.IsNullOrWhiteSpace(GetPropertyName(val2))) { return val2; } } catch { } } val = val.parent; num++; } return null; } private static string? GetPropertyName(Component c) { try { Type type = ((object)c).GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; object obj = null; PropertyInfo property = type.GetProperty("PropertyName", bindingAttr); if (property != null) { obj = property.GetValue(c, null); } else { FieldInfo field = type.GetField("PropertyName", bindingAttr); if (field != null) { obj = field.GetValue(c); } } string text = obj as string; if (text == null && obj != null) { text = obj.ToString(); } return text; } catch { return null; } } private static Vector3 SnapToGroundPosition(Vector3 pos, out bool onNav) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_002c: 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_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_0041: 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_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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_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_0076: Unknown result type (might be due to invalid IL or missing references) onNav = false; try { float num = Math.Max(0.1f, MoreWorkersPreferences.SnapRadiusMetersEffective); NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(pos, ref val, num, -1)) { onNav = true; return ((NavMeshHit)(ref val)).position; } RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(new Ray(pos + Vector3.up * 2f, Vector3.down), ref val2, 10f, -1, (QueryTriggerInteraction)1)) { return ((RaycastHit)(ref val2)).point + Vector3.up * 0.02f; } return new Vector3(pos.x, pos.y + 0.02f, pos.z); } catch { return pos; } } } internal static class DebugMarkers { private const string GlobalRootName = "MoreWorkers_DebugMarkers_Global"; private const string LocalRootName = "MoreWorkers_DebugMarkers"; private static Material? _matExisting; private static Material? _matManualOk; private static Material? _matManualBad; private static Material? _matHighlight; private static readonly Color ExistingColor = new Color(0.2f, 0.6f, 1f, 0.85f); private static readonly Color ManualOkColor = new Color(0.2f, 0.9f, 0.3f, 0.9f); private static readonly Color ManualBadColor = new Color(1f, 0.25f, 0.25f, 0.95f); private static readonly Color HighlightColor = new Color(1f, 0.95f, 0.25f, 0.95f); private static void EnsureMaterials() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0076: 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_0097: Expected O, but got Unknown //IL_009c: 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_00bd: Expected O, but got Unknown //IL_00c2: 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_00e3: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) if (!Need(_matExisting) && !Need(_matManualOk) && !Need(_matManualBad) && !Need(_matHighlight)) { return; } Shader val = Shader.Find("Unlit/Color"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Standard"); } if (!((Object)(object)val == (Object)null)) { if (Need(_matExisting)) { _matExisting = new Material(val); _matExisting.color = ExistingColor; } if (Need(_matManualOk)) { _matManualOk = new Material(val); _matManualOk.color = ManualOkColor; } if (Need(_matManualBad)) { _matManualBad = new Material(val); _matManualBad.color = ManualBadColor; } if (Need(_matHighlight)) { _matHighlight = new Material(val); _matHighlight.color = HighlightColor; } } static bool Need(Material? m) { return (Object)(object)m == (Object)null; } } public static int RebuildAll() { try { MelonPreferences_Entry<bool>? authoringMode = MoreWorkersPreferences.AuthoringMode; if (authoringMode == null || !authoringMode.Value) { ClearAll(); return 0; } if (!MoreWorkersPreferences.VisualizeIdlePointsEffective) { ClearAll(); return 0; } int num = 0; PropertyIndex.Entry[] array = PropertyIndex.Snapshot(); HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); int num2 = 0; int num3 = 0; int num4 = 0; Type type = ResolvePropertyType(); if (type != null) { foreach (object item in EnumerateProperties(type)) { if (item != null) { DrawForInstance(item, type); string text = SafeGet<string>(item, type, "PropertyName"); if (!string.IsNullOrWhiteSpace(text)) { hashSet.Add(text); } num2++; } } num += num2; } if (array != null && array.Length != 0) { foreach (PropertyIndex.Entry entry in array) { if (entry == null) { continue; } object? instance = entry.Instance; Component val = (Component)((instance is Component) ? instance : null); if ((Object)(object)val == (Object)null) { continue; } string text2 = SafeGet<string>(val, ((object)val).GetType(), "PropertyName") ?? entry.Name; if (string.IsNullOrWhiteSpace(text2) || !hashSet.Contains(text2)) { DrawForInstance(val); if (!string.IsNullOrWhiteSpace(text2)) { hashSet.Add(text2); } num3++; } } num += num3; foreach (PropertyIndex.Entry entry2 in array) { if (entry2 != null && !(entry2.Instance is Component)) { string name = entry2.Name; if (!string.IsNullOrWhiteSpace(name) && !hashSet.Contains(name)) { DrawForNameOnly(name, entry2.IdlePoints); hashSet.Add(name); num4++; } } } } if (num2 + num3 == 0) { int num5 = ProbeSceneAndDraw(hashSet); num += num5; if (num > 0) { return num; } } if (num > 0) { return num; } if (type == null) { type = ResolvePropertyType(); } if (type == null) { return 0; } foreach (object item2 in EnumerateProperties(type)) { DrawForInstance(item2, type); num++; } return num; } catch (Exception arg) { Log.Warning($"Marker rebuild failed: {arg}"); return 0; } } public static void ClearAll() { try { GameObject val = GameObject.Find("MoreWorkers_DebugMarkers_Global"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } try { Transform[] array = Object.FindObjectsOfType<Transform>(true); foreach (Transform val2 in array) { if (!((Object)(object)val2 == (Object)null) && string.Equals(((Object)val2).name, "MoreWorkers_DebugMarkers", StringComparison.Ordinal)) { for (int num = val2.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)val2.GetChild(num)).gameObject); } Object.Destroy((Object)(object)((Component)val2).gameObject); } } } catch { } } catch (Exception arg) { Log.Warning($"Marker clear failed: {arg}"); } } public static void DrawForInstance(object instance) { DrawForInstance(instance, instance.GetType()); } private static void DrawForInstance(object instance, Type type) { //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0230: 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_0394: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_0262: 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_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0483: 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_039f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: 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_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: 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_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_0516: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Unknown result type (might be due to invalid IL or missing references) MelonPreferences_Entry<bool>? authoringMode = MoreWorkersPreferences.AuthoringMode; if (authoringMode == null || !authoringMode.Value || !MoreWorkersPreferences.VisualizeIdlePointsEffective) { return; } EnsureMaterials(); string text = SafeGet<string>(instance, type, "PropertyName") ?? "(unknown)"; Transform orCreateParent = GetOrCreateParent(instance, text); for (int num = orCreateParent.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)orCreateParent.GetChild(num)).gameObject); } List<Vector3> list = null; List<ManualIdlePoints.IdlePointWorld> forProperty = ManualIdlePoints.GetForProperty(text); if (forProperty != null && forProperty.Count > 0) { list = new List<Vector3>(forProperty.Count); for (int i = 0; i < forProperty.Count; i++) { Vector3 val = forProperty[i].Position; if (MoreWorkersPreferences.SnapToGroundEffective) { val = SnapToGroundPosition(val, out var _); } list.Add(val); } } int num2 = 0; Vector3 anchor = default(Vector3); bool flag = false; BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("EmployeeIdlePoints", bindingAttr); FieldInfo fieldInfo = ((property == null) ? type.GetField("EmployeeIdlePoints", bindingAttr) : null); Transform[] array = ((property != null) ? property.GetValue(instance) : fieldInfo?.GetValue(instance)) as Transform[]; Quaternion rotation; if (array != null) { int num3 = 0; for (int j = 0; j < array.Length; j++) { Transform val2 = array[j]; if ((Object)(object)val2 == (Object)null) { continue; } bool flag2 = false; try { GameObject gameObject = ((Component)val2).gameObject; if ((Object)(object)gameObject != (Object)null) { string name = ((Object)gameObject).name; if (!string.IsNullOrEmpty(name) && name.Contains("MW_MANUAL")) { flag2 = true; } } } catch { } if (!flag2 && (list == null || !IsNearAny(val2.position, list, 0.08f))) { bool flag3 = AuthoringTools.SelectedExistingIndex == j && !string.IsNullOrWhiteSpace(AuthoringTools.SelectedExistingPropertyName) && string.Equals(AuthoringTools.SelectedExistingPropertyName, text, StringComparison.Ordinal); if ((Object)(object)_matExisting != (Object)null) { Material mat = (flag3 ? (_matHighlight ?? _matExisting) : _matExisting); Vector3 pos = val2.position + Vector3.up * 0.05f; rotation = val2.rotation; MakeMarker(orCreateParent, pos, Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f), mat); } if (MoreWorkersPreferences.ShowIndexLabelsEffective) { Color color = (flag3 ? HighlightColor : ExistingColor); MakeLabel(orCreateParent, val2.position + Vector3.up * 0.35f, j, color); } if (!flag && (Object)(object)val2 != (Object)null) { anchor = val2.position; flag = true; } num3++; } } num2 = num3; } int num4 = 0; if (array != null) { for (int k = 0; k < array.Length; k++) { Transform val3 = array[k]; if ((Object)(object)val3 == (Object)null) { continue; } bool flag4 = false; try { GameObject gameObject2 = ((Component)val3).gameObject; if ((Object)(object)gameObject2 != (Object)null) { string name2 = ((Object)gameObject2).name; if (!string.IsNullOrEmpty(name2) && name2.Contains("MW_MANUAL")) { flag4 = true; } } } catch { } if (flag4) { Vector3 val4 = val3.position; bool onNav2 = false; if (MoreWorkersPreferences.SnapToGroundEffective) { val4 = SnapToGroundPosition(val4, out onNav2); } Material val5 = (onNav2 ? _matManualOk : _matManualBad); bool flag5 = AuthoringTools.SelectedManualIdleIndex >= 0 && !string.IsNullOrWhiteSpace(AuthoringTools.SelectedManualPropertyName) && string.Equals(AuthoringTools.SelectedManualPropertyName, text, StringComparison.Ordinal) && AuthoringTools.SelectedManualIdleIndex == k; Color val6 = (onNav2 ? ManualOkColor : ManualBadColor); Color color2 = (flag5 ? HighlightColor : val6); if ((Object)(object)val5 != (Object)null) { Material mat2 = (Material)(flag5 ? ((object)(_matHighlight ?? val5)) : ((object)val5)); Vector3 pos2 = val4 + Vector3.up * 0.05f; rotation = val3.rotation; MakeMarker(orCreateParent, pos2, Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f), mat2); } if (MoreWorkersPreferences.ShowIndexLabelsEffective) { int index = num2 + num4; MakeLabel(orCreateParent, val4 + Vector3.up * 0.35f, index, color2); } if (!flag) { anchor = val4; flag = true; } num4++; } } } else if (forProperty != null) { foreach (ManualIdlePoints.IdlePointWorld item in forProperty) { Vector3 val7 = item.Position; bool onNav3 = false; if (MoreWorkersPreferences.SnapToGroundEffective) { val7 = SnapToGroundPosition(val7, out onNav3); } Material val8 = (onNav3 ? _matManualOk : _matManualBad); if ((Object)(object)val8 != (Object)null) { Vector3 pos3 = val7 + Vector3.up * 0.05f; rotation = item.Rotation; MakeMarker(orCreateParent, pos3, Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f), val8); } if (MoreWorkersPreferences.ShowIndexLabelsEffective) { int index2 = num2 + num4; Color color3 = (onNav3 ? ManualOkColor : ManualBadColor); MakeLabel(orCreateParent, val7 + Vector3.up * 0.35f, index2, color3); } if (!flag) { anchor = val7; flag = true; } num4++; } } if (!flag) { Component val9 = (Component)((instance is Component) ? instance : null); if ((Object)(object)val9 != (Object)null) { anchor = val9.transform.position; flag = true; } } if (!flag) { return; } Vector3[] array2 = null; if (array != null && array.Length != 0) { List<Vector3> list2 = new List<Vector3>(array.Length); Transform[] array3 = array; foreach (Transform val10 in array3) { if ((Object)(object)val10 != (Object)null) { list2.Add(val10.position); } } array2 = list2.ToArray(); } if (array2 == null && forProperty != null && forProperty.Count > 0) { List<Vector3> list3 = new List<Vector3>(forProperty.Count); foreach (ManualIdlePoints.IdlePointWorld item2 in forProperty) { list3.Add(item2.Position); } array2 = list3.ToArray(); } PropertyIndex.Register(instance, text, anchor, array2); } private static void DrawForNameOnly(string propertyName, Vector3[]? existingPoints) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_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_00d4: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_0108: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) MelonPreferences_Entry<bool>? authoringMode = MoreWorkersPreferences.AuthoringMode; if (authoringMode == null || !authoringMode.Value || !MoreWorkersPreferences.VisualizeIdlePointsEffective) { return; } EnsureMaterials(); Transform orCreateParent = GetOrCreateParent(propertyName, propertyName); for (int num = orCreateParent.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)orCreateParent.GetChild(num)).gameObject); } int num2 = 0; List<ManualIdlePoints.IdlePointWorld> forProperty = ManualIdlePoints.GetForProperty(propertyName); int num3 = 0; if (forProperty == null) { return; } foreach (ManualIdlePoints.IdlePointWorld item in forProperty) { Vector3 val = item.Position; bool onNav = false; if (MoreWorkersPreferences.SnapToGroundEffective) { val = SnapToGroundPosition(val, out onNav); } Material val2 = (onNav ? _matManualOk : _matManualBad); if ((Object)(object)val2 != (Object)null) { Vector3 pos = val + Vector3.up * 0.05f; Quaternion rotation = item.Rotation; MakeMarker(orCreateParent, pos, Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f), val2); } if (MoreWorkersPreferences.ShowIndexLabelsEffective) { int index = num2 + num3; Color color = (onNav ? ManualOkColor : ManualBadColor); MakeLabel(orCreateParent, val + Vector3.up * 0.35f, index, color); } num3++; } } private static int ProbeSceneAndDraw(HashSet<string> drawnNames) { int num = 0; try { Transform[] array = Object.FindObjectsOfType<Transform>(true); foreach (Transform val in array) { if ((Object)(object)val == (Object)null) { continue; } Component[] components; try { components = ((Component)val).GetComponents<Component>(); } catch { continue; } foreach (Component val2 in components) { if ((Object)(object)val2 == (Object)null) { continue; } Type type = ((object)val2).GetType(); PropertyInfo? property = type.GetProperty("PropertyName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field = type.GetField("PropertyName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(property != null) && !(field != null)) { continue; } PropertyInfo? property2 = type.GetProperty("EmployeeIdlePoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field2 = type.GetField("EmployeeIdlePoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(property2 != null) && !(field2 != null)) { continue; } string text = SafeGet<string>(val2, type, "PropertyName"); if (!string.IsNullOrWhiteSpace(text)) { string item = text; if (drawnNames.Contains(item)) { continue; } } DrawForInstance(val2, type); if (!string.IsNullOrWhiteSpace(text)) { string item2 = text; drawnNames.Add(item2); } num++; } } } catch { } return num; } private static bool IsNearAny(Vector3 pos, List<Vector3> list, float epsilon) { //IL_000a: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) float num = epsilon * epsilon; for (int i = 0; i < list.Count; i++) { Vector3 val = list[i] - pos; if (((Vector3)(ref val)).sqrMagnitude <= num) { return true; } } return false; } private static Transform GetOrCreateParent(object instance, string propertyName) { //IL_002c: 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) Transform localRoot = GetLocalRoot(instance); if ((Object)(object)localRoot != (Object)null) { return localRoot; } GameObject val = (GameObject)(((object)GameObject.Find("MoreWorkers_DebugMarkers_Global")) ?? ((object)new GameObject("MoreWorkers_DebugMarkers_Global"))); Transform transform = new GameObject(propertyName).transform; transform.SetParent(val.transform, false); return transform; } private static Transform? GetLocalRoot(object instance) { //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) Component val = (Component)((instance is Component) ? instance : null); if ((Object)(object)val == (Object)null) { return null; } Transform val2 = val.transform.Find("MoreWorkers_DebugMarkers"); if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject("MoreWorkers_DebugMarkers"); val3.transform.SetParent(val.transform, false); val2 = val3.transform; } return val2; } private static void MakeMarker(Transform parent, Vector3 pos, Quaternion rot, Material mat) { //IL_0019: Unknown resul