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 v0.1.1
Khundian.S1.MoreWorkers-Mono.dll
Decompiled 17 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using HarmonyLib; using Khundian.S1.MoreWorkers; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; 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("Schedule I mod that enables Add/Remove worker idle points to/from properties with authoring tools; hotkeys and helpful visuals.")] [assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyInformationalVersion("0.1.1+3bc268901f71612dd31191d6dadc0b0c6ec5109b")] [assembly: AssemblyProduct("Khundian.S1.MoreWorkers")] [assembly: AssemblyTitle("Khundian.S1.MoreWorkers-Mono")] [assembly: MelonInfo(typeof(MoreWorkersMod), "More Workers", "0.1.1", "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 Texture2D? _bgTex; internal static void OnSceneLoaded() { _selectedInstance = null; _selectedName = null; } internal static void OnUpdate() { //IL_0171: 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_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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00db: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_013a: 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)) { _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 _); } 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)) { ManualIdlePoints.Reload(); DebugMarkers.RebuildAll(); _selectedInstance = null; _selectedName = null; try { EnsureSelectionFromNearest(); } catch { } Log.Msg("Reloaded points.json and rebuilt markers."); } if (!Input.GetKeyDown(val2)) { return; } if (string.IsNullOrWhiteSpace(_selectedName) && !EnsureSelectionFromNearest()) { Log.Msg("No properties available for remove."); } else { if (string.IsNullOrWhiteSpace(_selectedName)) { return; } if (ManualIdlePoints.PopLast(_selectedName)) { Log.Msg("Removed last point -> '" + _selectedName + "'."); DebugMarkers.RebuildAll(); try { PropertyPatches.ReapplyCapacityForAll(); return; } catch { return; } } Log.Msg("No manual points to remove for '" + _selectedName + "'."); } } 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_0185: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: 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_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got I4 //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Expected O, but got Unknown //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: 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_0334: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_037c: 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_03b6: 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_0201->IL0201: Incompatible stack types: O vs I4 //IL_01fc->IL0201: Incompatible stack types: I4 vs O //IL_01fc->IL0201: 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 = "Authoring ON | Property: " + text; string text4 = $"Pos: {position.x:F2}, {position.y:F2}, {position.z:F2} | Yaw: {num:F1}° | Snap: {text2}"; string text5 = $"Next idx: {num4} (existing {num2} + manual {num3})"; 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 text6 = 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] { text3, text4, text5, text6 }; 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), text3, val, val2); num7 += num8; 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); } 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 TryAppendLivePoint(object? instanceObj, Vector3 pos, float yaw) { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_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) 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) { return; } Transform val = null; foreach (Transform val2 in array) { if ((Object)(object)val2 != (Object)null) { val = val2; break; } } if ((Object)(object)val == (Object)null) { return; } Transform val3 = val; foreach (Transform val4 in array) { if ((Object)(object)val4 != (Object)null) { Vector3 val5 = val4.position - pos; if (((Vector3)(ref val5)).sqrMagnitude <= 0.0064f) { return; } } } Quaternion val6 = Quaternion.Euler(0f, yaw, 0f); Transform val7 = Object.Instantiate<Transform>(val3, pos, val6); if ((Object)(object)val7 == (Object)null) { return; } Transform val8 = val7; try { if ((Object)(object)((Component)val8).gameObject != (Object)null) { GameObject gameObject = ((Component)val8).gameObject; GameObject gameObject2 = ((Component)val3).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] = val8; 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) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) try { List<Vector3> list = null; List<ManualIdlePoints.IdlePointWorld> forProperty = ManualIdlePoints.GetForProperty(propertyName); 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); } } List<Vector3> idlePositions = GetIdlePositions(instance); if (idlePositions == null || idlePositions.Count == 0) { return 0; } if (list == null || list.Count == 0) { return idlePositions.Count; } int num = 0; for (int j = 0; j < idlePositions.Count; j++) { Vector3 pos = idlePositions[j]; if (!IsNearAny(in pos, list, 0.08f)) { num++; } } return num; } 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 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 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 void EnsureMaterials() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_006a: 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_008b: Expected O, but got Unknown //IL_0090: 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_00b1: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (!Need(_matExisting) && !Need(_matManualOk) && !Need(_matManualBad)) { 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; } } 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: 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_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: 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_029c: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: 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_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_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: 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_02f2: 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_0305: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0332: 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_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_034a: 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))) { if ((Object)(object)_matExisting != (Object)null) { Vector3 pos = val2.position + Vector3.up * 0.05f; rotation = val2.rotation; MakeMarker(orCreateParent, pos, Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f), _matExisting); } if (MoreWorkersPreferences.ShowIndexLabelsEffective) { MakeLabel(orCreateParent, val2.position + Vector3.up * 0.35f, j, ExistingColor); } if (!flag && (Object)(object)val2 != (Object)null) { anchor = val2.position; flag = true; } num3++; } } num2 = num3; } List<ManualIdlePoints.IdlePointWorld> list2 = forProperty; int num4 = 0; if (list2 != null) { foreach (ManualIdlePoints.IdlePointWorld item in list2) { Vector3 val3 = item.Position; bool onNav2 = false; if (MoreWorkersPreferences.SnapToGroundEffective) { val3 = SnapToGroundPosition(val3, out onNav2); } Material val4 = (onNav2 ? _matManualOk : _matManualBad); if ((Object)(object)val4 != (Object)null) { Vector3 pos2 = val3 + Vector3.up * 0.05f; rotation = item.Rotation; MakeMarker(orCreateParent, pos2, Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f), val4); } if (MoreWorkersPreferences.ShowIndexLabelsEffective) { int index = num2 + num4; Color color = (onNav2 ? ManualOkColor : ManualBadColor); MakeLabel(orCreateParent, val3 + Vector3.up * 0.35f, index, color); } if (!flag) { anchor = val3; flag = true; } num4++; } } if (!flag) { Component val5 = (Component)((instance is Component) ? instance : null); if ((Object)(object)val5 != (Object)null) { anchor = val5.transform.position; flag = true; } } if (!flag) { return; } Vector3[] array2 = null; if (array != null && array.Length != 0) { List<Vector3> list3 = new List<Vector3>(array.Length); Transform[] array3 = array; foreach (Transform val6 in array3) { if ((Object)(object)val6 != (Object)null) { list3.Add(val6.position); } } array2 = list3.ToArray(); } if (array2 == null && list2 != null && list2.Count > 0) { List<Vector3> list4 = new List<Vector3>(list2.Count); foreach (ManualIdlePoints.IdlePointWorld item2 in list2) { list4.Add(item2.Position); } array2 = list4.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 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_0040: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2); obj.transform.SetParent(parent, false); obj.transform.position = pos; obj.transform.rotation = rot; obj.transform.localScale = new Vector3(0.2f, 0.15f, 0.2f); Renderer component = obj.GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { component.material = mat; } Collider component2 = obj.GetComponent<Collider>(); if ((Object)(object)component2 != (Object)null) { component2.enabled = false; } } private static void MakeLabel(Transform parent, Vector3 pos, int index, Color color) { //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_0023: 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_002f: 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_006c: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject("idx_" + index); val.transform.SetParent(parent, false); val.transform.position = pos; val.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); TextMeshPro obj = val.AddComponent<TextMeshPro>(); ((TMP_Text)obj).text = index.ToString(); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((Graphic)obj).color = color; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).fontSize = 5f; } catch { } } 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; } } private static T? SafeGet<T>(object instance, Type type, string name) { try { PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { if (property.GetValue(instance, null) is T result) { return result; } return default(T); } FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { if (field.GetValue(instance) is T result2) { return result2; } return default(T); } } catch { } return default(T); } private static IEnumerable<object> EnumerateProperties(Type type) { object obj = null; 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); } } if (!(obj is IEnumerable enumerable)) { yield break; } foreach (object item in enumerable) { if (item != null) { yield return item; } } } private static Type? ResolvePropertyType() { return FindTypeByNames("ScheduleOne.Property.Property", "Il2CppScheduleOne.Property.Property"); } 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; } } internal static class Log { public static void Msg(string message) { Melon<MoreWorkersMod>.Logger.Msg(message); } public static void Warning(string message) { Melon<MoreWorkersMod>.Logger.Warning(message); } public static void Error(string message) { Melon<MoreWorkersMod>.Logger.Error(message); } } internal static class ManualIdlePoints { internal class PropertyPoints { public string? coordsSpace { get; set; } public List<PointModel>? points { get; set; } } internal class PointModel { public float[]? pos { get; set; } public float? yaw { get; set; } public string? note { get; set; } } internal struct IdlePointWorld { public Vector3 Position; public Quaternion Rotation; } private static string? _path; private static DateTime _lastWrite; private static Dictionary<string, List<IdlePointWorld>> _cache = new Dictionary<string, List<IdlePointWorld>>(); public static void SetPath(string? path) { _path = path; } public static void Reload() { _cache.Clear(); _lastWrite = default(DateTime); TryLoad(); } private static void TryLoad() { //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(_path)) { _path = Path.Combine(MelonEnvironment.UserDataDirectory, "More Workers", "points.json"); } try { string path = _path; if (!File.Exists(path)) { return; } FileInfo fileInfo = new FileInfo(path); if (fileInfo.LastWriteTimeUtc <= _lastWrite && _cache.Count > 0) { return; } Directory.CreateDirectory(Path.GetDirectoryName(path)); Dictionary<string, PropertyPoints> dictionary = JsonConvert.DeserializeObject<Dictionary<string, PropertyPoints>>(File.ReadAllText(path)); if (dictionary == null) { return; } Dictionary<string, List<IdlePointWorld>> dictionary2 = new Dictionary<string, List<IdlePointWorld>>(StringComparer.OrdinalIgnoreCase); Vector3 position = default(Vector3); foreach (KeyValuePair<string, PropertyPoints> item in dictionary) { string text = item.Key?.Trim(); if (string.IsNullOrEmpty(text)) { continue; } PropertyPoints value = item.Value; if (value?.points == null || value.points.Count == 0) { continue; } if ((value.coordsSpace ?? "world").Trim().ToLowerInvariant() != "world") { Log.Warning("Ignoring '" + text + "' points with coordsSpace='" + value.coordsSpace + "'. Phase 2 supports world-space only."); continue; } List<IdlePointWorld> list = new List<IdlePointWorld>(); foreach (PointModel point in value.points) { if (point?.pos != null && point.pos.Length >= 3) { ((Vector3)(ref position))..ctor(point.pos[0], point.pos[1], point.pos[2]); Quaternion rotation = (point.yaw.HasValue ? Quaternion.Euler(0f, point.yaw.Value, 0f) : Quaternion.identity); list.Add(new IdlePointWorld { Position = position, Rotation = rotation }); } } if (list.Count > 0) { dictionary2[text] = list; } } _cache = dictionary2; _lastWrite = fileInfo.LastWriteTimeUtc; } catch (Exception ex) { Log.Warning("Failed to load manual idle points: " + ex.Message); } } public static List<IdlePointWorld>? GetForProperty(string propertyName) { TryLoad(); if (string.IsNullOrWhiteSpace(propertyName)) { return null; } if (!_cache.TryGetValue(propertyName, out List<IdlePointWorld> value)) { return null; } return value; } public static bool AppendPoint(string propertyName, Vector3 position, float yawDegrees) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0057: 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) if (string.IsNullOrWhiteSpace(propertyName)) { return false; } TryLoad(); if (!_cache.TryGetValue(propertyName, out List<IdlePointWorld> value) || value == null) { value = new List<IdlePointWorld>(); _cache[propertyName] = value; } Quaternion rotation = Quaternion.Euler(0f, yawDegrees, 0f); value.Add(new IdlePointWorld { Position = position, Rotation = rotation }); return SaveAll(); } public static bool PopLast(string propertyName) { if (string.IsNullOrWhiteSpace(propertyName)) { return false; } TryLoad(); if (_cache.TryGetValue(propertyName, out List<IdlePointWorld> value) && value != null && value.Count > 0) { try { value.RemoveAt(value.Count - 1); } catch { return false; } return SaveAll(); } return false; } private static bool SaveAll() { //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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_0110: Unknown result type (might be due to invalid IL or missing references) try { if (string.IsNullOrWhiteSpace(_path)) { _path = Path.Combine(MelonEnvironment.UserDataDirectory, "More Workers", "points.json"); } string path = _path; Directory.CreateDirectory(Path.GetDirectoryName(path)); Dictionary<string, PropertyPoints> dictionary = new Dictionary<string, PropertyPoints>(StringComparer.OrdinalIgnoreCase); foreach (string key in _cache.Keys) { PropertyPoints propertyPoints = new PropertyPoints(); propertyPoints.coordsSpace = "world"; if (_cache.TryGetValue(key, out List<IdlePointWorld> value) && value != null && value.Count > 0) { propertyPoints.points = new List<PointModel>(value.Count); foreach (IdlePointWorld item in value) { Quaternion rotation = item.Rotation; float y = ((Quaternion)(ref rotation)).eulerAngles.y; propertyPoints.points.Add(new PointModel { pos = new float[3] { item.Position.x, item.Position.y, item.Position.z }, yaw = y }); } } dictionary[key] = propertyPoints; } string contents = JsonConvert.SerializeObject((object)dictionary, (Formatting)1); string text = path + ".tmp"; File.WriteAllText(text, contents); if (File.Exists(path)) { File.Delete(path); } File.Move(text, path); _lastWrite = new FileInfo(path).LastWriteTimeUtc; Reload(); return true; } catch (Exception ex) { Log.Warning("Failed to save idle points: " + ex.Message); return false; } } } public class MoreWorkersMod : MelonMod { private static Harmony? _harmony; private static bool _patched; private static int _lastAnchorSceneIndex = -1; private static string? _lastAnchorSceneName; public override void OnInitializeMelon() { //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_0015: Expected O, but got Unknown //IL_001f: Expected O, but got Unknown MoreWorkersPreferences.EnsureLoaded(); Harmony val = new Harmony("More Workers"); _patched = PropertyPatches.TryPatchNow(val); _harmony = val; Log.Msg("More Workers v0.1.1 Initialized."); } public override void OnUpdate() { AuthoringTools.OnUpdate(); } public override void OnGUI() { AuthoringTools.OnGUI(); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { PropertyPatches.ClearProcessed(); PropertyPatches.ClearProcessedNames(); bool flag = false; try { PropertyIndex.Entry[] array = PropertyIndex.Snapshot(); if (array != null) { for (int i = 0; i < array.Length; i++) { object? obj = array[i]?.Instance; if ((Object)((obj is Component) ? obj : null) != (Object)null) { flag = true; break; } } } } catch { } bool flag2 = _lastAnchorSceneIndex != buildIndex || !string.Equals(_lastAnchorSceneName, sceneName); if (!flag && flag2) { PropertyIndex.Clear(); PropertyAnchors.RegisterAnchors(); _lastAnchorSceneIndex = buildIndex; _lastAnchorSceneName = sceneName; } AuthoringTools.OnSceneLoaded(); if (_harmony != null && !_patched) { _patched = PropertyPatches.TryPatchNow(_harmony); if (_patched) { Log.Msg("Patches applied after scene load: " + sceneName); } } } } internal static class MoreWorkersPreferences { private static bool _loaded; public static MelonPreferences_Category? Category { get; private set; } public static MelonPreferences_Entry<bool>? SkipRV { get; private set; } public static MelonPreferences_Entry<bool>? SkipMotelRoom { get; private set; } public static MelonPreferences_Entry<bool>? UseManualIdlePoints { get; private set; } public static MelonPreferences_Entry<string>? IdlePointsJsonPath { get; private set; } public static MelonPreferences_Entry<bool>? ReloadIdlePoints { get; private set; } public static MelonPreferences_Entry<bool>? AuthoringMode { get; private set; } public static MelonPreferences_Entry<bool>? VisualizeIdlePoints { get; private set; } public static MelonPreferences_Entry<bool>? ShowIndexLabels { get; private set; } public static MelonPreferences_Entry<bool>? SnapToGround { get; private set; } public static MelonPreferences_Entry<float>? SnapRadiusMeters { get; private set; } public static MelonPreferences_Entry<string>? DebugFindPropertyName { get; private set; } public static MelonPreferences_Entry<bool>? EnableHotkeys { get; private set; } public static MelonPreferences_Entry<bool>? ShowOverlayHUD { get; private set; } public static MelonPreferences_Entry<KeyCode>? CaptureKey { get; private set; } public static MelonPreferences_Entry<KeyCode>? ReloadKey { get; private set; } public static MelonPreferences_Entry<KeyCode>? RemoveKey { get; private set; } public static bool SkipRVEffective => SkipRV?.Value ?? true; public static bool SkipMotelRoomEffective => SkipMotelRoom?.Value ?? true; public static bool UseManualIdlePointsEffective => UseManualIdlePoints?.Value ?? true; public static bool VisualizeIdlePointsEffective => VisualizeIdlePoints?.Value ?? true; public static bool ShowIndexLabelsEffective => ShowIndexLabels?.Value ?? true; public static bool SnapToGroundEffective => SnapToGround?.Value ?? true; public static float SnapRadiusMetersEffective => SnapRadiusMeters?.Value ?? 5f; public static bool EnableHotkeysEffective => EnableHotkeys?.Value ?? true; public static bool ShowOverlayHUDEffective => ShowOverlayHUD?.Value ?? true; public static string IdlePointsJsonPathEffective => IdlePointsJsonPath?.Value ?? Path.Combine(MelonEnvironment.UserDataDirectory, "More Workers", "points.json"); public static void EnsureLoaded() { if (_loaded) { return; } MelonPreferences.Load(); string text = "More Workers Preferences"; Category = MelonPreferences.CreateCategory("More Workers_Preferences", text); try { string text2 = Path.Combine(MelonEnvironment.UserDataDirectory, "More Workers"); Directory.CreateDirectory(text2); Category.SetFilePath(Path.Combine(text2, "More Workers.cfg")); } catch { } Path.Combine(MelonEnvironment.UserDataDirectory, "More Workers", "points.json"); AuthoringMode = Category.CreateEntry<bool>("AuthoringMode", false, "Authoring Mode", "Enable authoring features (markers and snapping). When off, no extra scene work is done.", false, false, (ValueValidator)null, (string)null); CaptureKey = Category.CreateEntry<KeyCode>("CaptureKey", (KeyCode)290, "Capture Key", "Capture current position/yaw to JSON (Authoring Mode only)", false, false, (ValueValidator)null, (string)null); ReloadKey = Category.CreateEntry<KeyCode>("ReloadKey", (KeyCode)291, "Reload Key", "Reload points.json and rebuild markers (Authoring Mode only)", false, false, (ValueValidator)null, (string)null); RemoveKey = Category.CreateEntry<KeyCode>("RemoveKey", (KeyCode)292, "Remove Key", "Remove last manual point from JSON for the selected property (Authoring Mode only)", false, false, (ValueValidator)null, (string)null); try { ((MelonEventBase<LemonAction<bool, bool>>)(object)AuthoringMode.OnEntryValueChanged).Subscribe((LemonAction<bool, bool>)delegate(bool oldVal, bool newVal) { if (newVal) { if (VisualizeIdlePointsEffective) { DebugMarkers.RebuildAll(); } } else { DebugMarkers.ClearAll(); } }, 0, false); ((MelonEventBase<LemonAction<KeyCode, KeyCode>>)(object)CaptureKey.OnEntryValueChanged).Subscribe((LemonAction<KeyCode, KeyCode>)delegate { }, 0, false); ((MelonEventBase<LemonAction<KeyCode, KeyCode>>)(object)ReloadKey.OnEntryValueChanged).Subscribe((LemonAction<KeyCode, KeyCode>)delegate { }, 0, false); ((MelonEventBase<LemonAction<KeyCode, KeyCode>>)(object)RemoveKey.OnEntryValueChanged).Subscribe((LemonAction<KeyCode, KeyCode>)delegate { }, 0, false); } catch { } MelonPreferences.Save(); _loaded = true; } } internal static class PropertyAnchors { private class AnchorModel { public float[][]? anchors { get; set; } } private static readonly Dictionary<string, List<Vector3>> Defaults = new Dictionary<string, List<Vector3>>(StringComparer.OrdinalIgnoreCase) { { "Bungalow", new List<Vector3> { new Vector3(-168f, -2.29f, 112f) } }, { "Barn", new List<Vector3> { new Vector3(108f, 1.74f, -5f) } }, { "Docks Warehouse", new List<Vector3> { new Vector3(-75f, -0.68f, -63f) } }, { "Storage Unit", new List<Vector3> { new Vector3(-7f, 1.84f, 103f) } }, { "Sweatshop", new List<Vector3> { new Vector3(-63f, -2.26f, 144f) } }, { "Hyland Manor", new List<Vector3> { new Vector3(164f, 11.76f, -67f) } } }; public static void RegisterAnchors() { //IL_0165: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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) try { Dictionary<string, List<Vector3>> dictionary = new Dictionary<string, List<Vector3>>(Defaults, StringComparer.OrdinalIgnoreCase); string path = Path.Combine(Path.Combine(MelonEnvironment.UserDataDirectory, "More Workers"), "anchors.json"); if (File.Exists(path)) { try { Dictionary<string, AnchorModel> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, AnchorModel>>(File.ReadAllText(path)); if (dictionary2 != null) { foreach (KeyValuePair<string, AnchorModel> item in dictionary2) { string text = item.Key?.Trim() ?? string.Empty; if (string.IsNullOrEmpty(text)) { continue; } List<Vector3> list = new List<Vector3>(); float[][] array = item.Value?.anchors; if (array != null) { float[][] array2 = array; foreach (float[] array3 in array2) { if (array3 != null && array3.Length >= 3) { list.Add(new Vector3(array3[0], array3[1], array3[2])); } } } if (list.Count > 0) { dictionary[text] = list; } } } } catch (Exception ex) { Log.Warning("Failed to load anchors.json: " + ex.Message); } } int num = 0; foreach (KeyValuePair<string, List<Vector3>> item2 in dictionary) { string key = item2.Key; List<Vector3> value = item2.Value; if (value != null && value.Count != 0) { Vector3 val = Vector3.zero; for (int j = 0; j < value.Count; j++) { val += value[j]; } val /= (float)value.Count; PropertyIndex.Register(key, key, val, value.ToArray()); num++; } } _ = 0; } catch { } } } internal static class PropertyIndex { internal class Entry { public object? Instance; public string Name = string.Empty; public Vector3 Anchor; public int Id; public Vector3[]? IdlePoints; } private static readonly List<Entry> _entries = new List<Entry>(); private static readonly Dictionary<int, int> _byId = new Dictionary<int, int>(); private static readonly Dictionary<string, int> _firstByName = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); internal static void Clear() { _entries.Clear(); _byId.Clear(); _firstByName.Clear(); } internal static void Register(object instance, string name, Vector3 anchor, Vector3[]? points = null) { //IL_0081: 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_004f: 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) int num = 0; try { object obj = ((instance is Component) ? instance : null); num = ((obj != null) ? ((Object)obj).GetInstanceID() : RuntimeHelpers.GetHashCode(instance)); } catch { num = RuntimeHelpers.GetHashCode(instance); } if (num != 0 && _byId.TryGetValue(num, out var value)) { Entry entry = _entries[value]; entry.Name = name; entry.Anchor = anchor; entry.Instance = instance; if (points != null && points.Length != 0) { entry.IdlePoints = points; } return; } Entry item = new Entry { Instance = instance, Name = name, Anchor = anchor, Id = num, IdlePoints = ((points != null && points.Length != 0) ? points : null) }; int count = _entries.Count; _entries.Add(item); if (num != 0) { _byId[num] = count; } if (!_firstByName.ContainsKey(name)) { _firstByName[name] = count; } } internal static Entry? GetNearest(Vector3 refPos, Vector3 refForward, float coneDot = 0.35f) { //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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0080: 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_0089: 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_00ae: Unknown result type (might be due to invalid IL or missing references) if (_entries.Count == 0) { return null; } Vector3 val = refForward; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 1E-06f) { ((Vector3)(ref val)).Normalize(); } Entry entry = null; float num = float.MaxValue; float num2 = -1f; Entry entry2 = null; float num3 = float.MaxValue; for (int i = 0; i < _entries.Count; i++) { Entry entry3 = _entries[i]; Vector3 val2 = entry3.Anchor - refPos; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude <= 0.0001f)) { Vector3 val3 = val2 / magnitude; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude > 1E-06f) { ((Vector3)(ref val3)).Normalize(); } float num4 = Vector3.Dot(val3, val); if (magnitude < num3) { entry2 = entry3; num3 = magnitude; } if (num4 > coneDot && (entry == null || magnitude < num || (Mathf.Approximately(magnitude, num) && num4 > num2))) { entry = entry3; num = magnitude; num2 = num4; } } } return entry ?? entry2; } internal static Entry? GetByName(string name) { if (string.IsNullOrWhiteSpace(name)) { return null; } if (_firstByName.TryGetValue(name, out var value)) { return _entries[value]; } string value2 = name.Trim(); for (int i = 0; i < _entries.Count; i++) { if (_entries[i].Name.IndexOf(value2, StringComparison.OrdinalIgnoreCase) >= 0) { return _entries[i]; } } return null; } internal static Entry[] Snapshot() { return _entries.ToArray(); } } internal static class PropertyPatches { private class MemberHandles { public PropertyInfo? NameProp; public FieldInfo? NameField; public PropertyInfo? CapacityProp; public FieldInfo? CapacityField; public PropertyInfo? IdleProp; public FieldInfo? IdleField; } private static readonly HashSet<int> _processed; private static readonly HashSet<string> _processedByName; private static readonly HashSet<string> _excludedNames; private static readonly Dictionary<Type, MemberHandles> _memberCache; private static MemberHandles Handles(Type t) { if (_memberCache.TryGetValue(t, out MemberHandles value)) { return value; } value = new MemberHandles { NameProp = t.GetProperty("PropertyName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), NameField = t.GetField("PropertyName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), CapacityProp = t.GetProperty("EmployeeCapacity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), CapacityField = t.GetField("EmployeeCapacity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), IdleProp = t.GetProperty("EmployeeIdlePoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), IdleField = t.GetField("EmployeeIdlePoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) }; _memberCache[t] = value; return value; } public static bool TryPatchNow(Harmony harmony) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown try { MethodBase methodBase = ResolveAwakeMethod(); if (methodBase == null) { Log.Warning("Target type/method not yet loaded. Will retry later."); return false; } HarmonyMethod val = new HarmonyMethod(typeof(PropertyPatches).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic)); harmony.Patch(methodBase, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); Log.Msg("Patched: " + methodBase.DeclaringType?.FullName + ".Awake"); Type type = ResolveBasePropertyType(); if (type != null) { foreach (MethodBase item in ResolveDerivedAwakeMethodsTargeted(type)) { try { harmony.Patch(item, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { Log.Warning("Failed to patch derived Awake " + item.DeclaringType?.FullName + ": " + ex.Message); } } Type type2 = FindTypeByNames("ScheduleOne.Property.Sweatshop", "Il2CppScheduleOne.Property.Sweatshop"); if (type2 != null) { MethodInfo method = type2.GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { harmony.Patch((MethodBase)method, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); } } Type type3 = FindTypeByNames("ScheduleOne.Property.RV", "Il2CppScheduleOne.Property.RV"); if (type3 != null) { MethodInfo method2 = type3.GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method2 != null) { harmony.Patch((MethodBase)method2, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); } } Type type4 = FindTypeByNames("ScheduleOne.Property.MotelRoom", "Il2CppScheduleOne.Property.MotelRoom"); if (type4 != null) { MethodInfo method3 = type4.GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method3 != null) { harmony.Patch((MethodBase)method3, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); } } } return true; } catch (Exception arg) { Log.Error($"Patch failed: {arg}"); return false; } } private static void Postfix(object __instance, MethodBase __originalMethod) { //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_0240: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_025a: 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_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) try { int num = 0; try { object obj = ((__instance is Component) ? __instance : null); num = ((obj != null) ? ((Object)obj).GetInstanceID() : RuntimeHelpers.GetHashCode(__instance)); } catch { } if (num != 0) { if (_processed.Contains(num)) { return; } _processed.Add(num); } Type type = __instance.GetType(); string text = GetMemberValue<string>(__instance, type, "PropertyName"); if (string.IsNullOrEmpty(text)) { text = "(unknown)"; } if (string.Equals(text, "Sweatshop", StringComparison.OrdinalIgnoreCase)) { if (_processedByName.Contains(text)) { return; } _processedByName.Add(text); } if ((MoreWorkersPreferences.SkipRVEffective && string.Equals(text, "RV", StringComparison.Ordinal)) || (MoreWorkersPreferences.SkipMotelRoomEffective && string.Equals(text, "Motel Room", StringComparison.Ordinal)) || _excludedNames.Contains(text)) { return; } int memberValue = GetMemberValue<int>(__instance, type, "EmployeeCapacity"); if (MoreWorkersPreferences.UseManualIdlePointsEffective) { AppendManualPoints(__instance, type, text); } int idleCountSafe = GetIdleCountSafe(__instance, type); int num2 = Math.Max(memberValue, idleCountSafe); if (num2 > idleCountSafe) { int toAdd = num2 - idleCountSafe; if (!EnsureIdlePoints(__instance, type, toAdd)) { idleCountSafe = GetIdleCountSafe(__instance, type); if (num2 > idleCountSafe) { num2 = idleCountSafe; } Log.Msg($"{text}: no idle points template available; capacity clamped to {num2}."); } } if (num2 != memberValue) { SetMemberValue(__instance, type, "EmployeeCapacity", num2); Log.Msg($"{text}: EmployeeCapacity {memberValue} -> {num2} (+{num2 - memberValue})"); } MelonPreferences_Entry<bool>? authoringMode = MoreWorkersPreferences.AuthoringMode; if (authoringMode != null && authoringMode.Value && MoreWorkersPreferences.VisualizeIdlePointsEffective) { DebugMarkers.DrawForInstance(__instance); } try { Vector3 anchor = Vector3.zero; bool flag = false; Vector3[] points = null; MemberHandles memberHandles = Handles(type); if (((memberHandles.IdleProp != null) ? memberHandles.IdleProp.GetValue(__instance) : memberHandles.IdleField?.GetValue(__instance)) is Transform[] array && array.Length != 0) { Vector3 val = Vector3.zero; int num3 = 0; List<Vector3> list = new List<Vector3>(array.Length); Transform[] array2 = array; foreach (Transform val2 in array2) { if ((Object)(object)val2 != (Object)null) { val += val2.position; num3++; list.Add(val2.position); } } if (num3 > 0) { anchor = val / (float)num3; flag = true; points = list.ToArray(); }