Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of NACops MONO v1.9.0
NACopsV1.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.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using FishNet.Connection; using FishNet.Managing; using FishNet.Managing.Object; using FishNet.Object; using HarmonyLib; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using NACopsV1; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using ScheduleOne.AvatarFramework; using ScheduleOne.AvatarFramework.Equipping; using ScheduleOne.DevUtilities; using ScheduleOne.Economy; using ScheduleOne.GameTime; using ScheduleOne.ItemFramework; using ScheduleOne.Law; using ScheduleOne.Map; using ScheduleOne.Money; using ScheduleOne.NPCs; using ScheduleOne.NPCs.Behaviour; using ScheduleOne.Persistence; using ScheduleOne.PlayerScripts; using ScheduleOne.Police; using ScheduleOne.Product; using ScheduleOne.Quests; using ScheduleOne.UI; using ScheduleOne.UI.Handover; using ScheduleOne.UI.MainMenu; using ScheduleOne.VoiceOver; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(NACops), "NACopsV1", "1.9.0", "XOWithSauce", null)] [assembly: MelonColor] [assembly: MelonOptionalDependencies(new string[] { "FishNet.Runtime" })] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("XOWithSauce")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright XOWithSauce 2025 Source MIT")] [assembly: AssemblyDescription("Schedule I NACops Mod")] [assembly: AssemblyFileVersion("1.9.0.0")] [assembly: AssemblyInformationalVersion("1.9.0")] [assembly: AssemblyProduct("NACops")] [assembly: AssemblyTitle("NACopsV1")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/XOWithSauce/schedule-nacops")] [assembly: NeutralResourcesLanguage("en-US")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NACopsV1 { public class FootPatrolGenerator { public static Dictionary<PatrolInstance, List<string>> generatedPatrolInstances = new Dictionary<PatrolInstance, List<string>>(); public static ConfigLoader.FootPatrolsSerialized serPatrols; public static PatrolInstance[] GeneratePatrol(LawActivitySettings template, string day = "") { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) if (generatedPatrolInstances.Count == 0) { Transform parent = ((Component)Singleton<LawController>.Instance).transform.Find("PatrolRoutes"); if (serPatrols == null) { serPatrols = ConfigLoader.LoadPatrolsConfig(); } foreach (SerializedFootPatrol loadedPatrol in serPatrols.loadedPatrols) { GameObject val = new GameObject(loadedPatrol.name); FootPatrolRoute val2 = val.AddComponent<FootPatrolRoute>(); ((Object)val2).name = loadedPatrol.name; val2.StartWaypointIndex = 0; Transform[] array = (Transform[])(object)new Transform[loadedPatrol.waypoints.Count]; for (int i = 0; i < loadedPatrol.waypoints.Count; i++) { GameObject val3 = new GameObject((i == 0) ? "Waypoint" : $"Waypoint ({i})"); val3.transform.position = loadedPatrol.waypoints[i]; val3.transform.parent = val.transform; array[i] = val3.transform; } val2.Waypoints = array; val.transform.parent = parent; PatrolInstance val4 = new PatrolInstance(); val4.StartTime = loadedPatrol.startTime; val4.EndTime = loadedPatrol.endTime; val4.Members = loadedPatrol.members; val4.Route = val2; val4.OnlyIfCurfewEnabled = loadedPatrol.onlyIfCurfew; val.transform.parent = parent; val.SetActive(true); generatedPatrolInstances.Add(val4, loadedPatrol.days); } } if (day == "") { int num = template.Patrols.Length; int count = generatedPatrolInstances.Count; int num2 = num + count; PatrolInstance[] array2 = (PatrolInstance[])(object)new PatrolInstance[num2]; Array.Copy(template.Patrols, array2, num); int num3 = num; foreach (KeyValuePair<PatrolInstance, List<string>> generatedPatrolInstance in generatedPatrolInstances) { if (num3 >= num2) { break; } array2[num3] = generatedPatrolInstance.Key; num3++; } return array2; } int num4 = template.Patrols.Length; int num5 = 0; foreach (KeyValuePair<PatrolInstance, List<string>> generatedPatrolInstance2 in generatedPatrolInstances) { if (generatedPatrolInstance2.Value.Contains(day)) { num5++; } } if (num5 == 0) { return template.Patrols; } int num6 = num4 + num5; PatrolInstance[] array3 = (PatrolInstance[])(object)new PatrolInstance[num6]; Array.Copy(template.Patrols, array3, num4); int num7 = num4; foreach (KeyValuePair<PatrolInstance, List<string>> generatedPatrolInstance3 in generatedPatrolInstances) { if (num7 >= num6) { break; } if (generatedPatrolInstance3.Value.Contains(day)) { array3[num7] = generatedPatrolInstance3.Key; num7++; } } return array3; } } [Serializable] public class SerializedFootPatrol { public int startTime = 1900; public int endTime = 500; public int members = 1; public int intensityRequirement = 1; public bool onlyIfCurfew; public string name = "NACops Extra Loop"; public List<string> days; public List<Vector3> waypoints = new List<Vector3>(); } public class SentryGenerator { public static Dictionary<SentryInstance, List<string>> generatedSentryInstances = new Dictionary<SentryInstance, List<string>>(); public static ConfigLoader.SentrysSerialized serSentries; public static SentryInstance[] GenerateSentry(LawActivitySettings template, string day = "") { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00d4: Expected O, but got Unknown //IL_00ee: 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_00f9: 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_012a: Expected O, but got Unknown if (generatedSentryInstances.Count == 0) { Transform val = ((Component)Singleton<LawController>.Instance).transform.Find("Sentry Locations"); _ = (Object)(object)val == (Object)null; if (serSentries == null) { serSentries = ConfigLoader.LoadSentryConfig(); } foreach (SerializedSentry loadedSentry in serSentries.loadedSentrys) { GameObject val2 = new GameObject(loadedSentry.name); SentryLocation val3 = val2.AddComponent<SentryLocation>(); val3.StandPoints = new List<Transform>(); GameObject val4 = new GameObject("Stand point"); val4.transform.parent = val2.transform; val4.transform.SetPositionAndRotation(loadedSentry.standPosition1, Quaternion.Euler(loadedSentry.pos1Rotation)); val3.StandPoints.Add(val4.transform); GameObject val5 = new GameObject("Stand point (1)"); val5.transform.parent = val2.transform; val5.transform.SetPositionAndRotation(loadedSentry.standPosition2, Quaternion.Euler(loadedSentry.pos2Rotation)); val3.StandPoints.Add(val5.transform); ((Component)val3).gameObject.SetActive(true); SentryInstance val6 = new SentryInstance(); val6.StartTime = loadedSentry.startTime; val6.EndTime = loadedSentry.endTime; val6.Members = loadedSentry.members; val6.Location = val3; val6.OnlyIfCurfewEnabled = loadedSentry.onlyIfCurfew; val2.transform.parent = val; val2.SetActive(true); generatedSentryInstances.Add(val6, loadedSentry.days); } } if (day == "") { int num = template.Sentries.Length; int count = generatedSentryInstances.Count; int num2 = num + count; SentryInstance[] array = (SentryInstance[])(object)new SentryInstance[num2]; Array.Copy(template.Sentries, array, num); int num3 = num; foreach (KeyValuePair<SentryInstance, List<string>> generatedSentryInstance in generatedSentryInstances) { if (num3 >= num2) { break; } array[num3] = generatedSentryInstance.Key; num3++; } return array; } int num4 = template.Sentries.Length; int num5 = 0; foreach (KeyValuePair<SentryInstance, List<string>> generatedSentryInstance2 in generatedSentryInstances) { if (generatedSentryInstance2.Value.Contains(day)) { num5++; } } if (num5 == 0) { return template.Sentries; } int num6 = num4 + num5; SentryInstance[] array2 = (SentryInstance[])(object)new SentryInstance[num6]; Array.Copy(template.Sentries, array2, num4); int num7 = num4; foreach (KeyValuePair<SentryInstance, List<string>> generatedSentryInstance3 in generatedSentryInstances) { if (num7 >= num6) { break; } if (generatedSentryInstance3.Value.Contains(day)) { array2[num7] = generatedSentryInstance3.Key; num7++; } } return array2; } } [Serializable] public class SerializedSentry { public int startTime = 1900; public int endTime = 500; public int members = 1; public int intensityRequirement = 1; public bool onlyIfCurfew; public string name; public List<string> days; public Vector3 standPosition1; public Vector3 pos1Rotation; public Vector3 standPosition2; public Vector3 pos2Rotation; } [HarmonyPatch(typeof(Customer), "ProcessHandover")] public static class Customer_ProcessHandover_Patch { [CompilerGenerated] private sealed class <DisposeSummoned>d__4 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public bool instant; public Player target; public NPC npc; public PoliceOfficer offc; private int <lifeTime>5__2; private int <maxTime>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DisposeSummoned>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = NACops.Wait1; <>1__state = 1; return true; case 1: <>1__state = -1; if (!NACops.registered) { return false; } <lifeTime>5__2 = 0; <maxTime>5__3 = 20; if (instant || !((Object)(object)target != (Object)null) || !((Object)(object)npc != (Object)null)) { break; } goto IL_00b5; case 2: { <>1__state = -1; if (!NACops.registered) { return false; } goto IL_00b5; } IL_00b5: if (<lifeTime>5__2 <= <maxTime>5__3 || target.IsArrested || npc.Health.IsDead || npc.Health.IsKnockedOut) { <lifeTime>5__2++; <>2__current = NACops.Wait1; <>1__state = 2; return true; } break; } try { if (NACops.currentSummoned.Contains(offc)) { NACops.currentSummoned.Remove(offc); } if ((Object)(object)npc != (Object)null && NPCManager.NPCRegistry.Contains(npc)) { NPCManager.NPCRegistry.Remove(npc); } if ((Object)(object)npc != (Object)null && (Object)(object)((Component)npc).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)npc).gameObject); } } catch (Exception ex) { MelonLogger.Error((object)ex); } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <PreProcessHandover>d__1 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public bool handoverByPlayer; public Customer __instance; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <PreProcessHandover>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!handoverByPlayer) { return false; } if (NACops.currentConfig.BuyBusts) { NACops.coros.Add(MelonCoroutines.Start(SummonBustCop(__instance))); } <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SetTaser>d__3 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public PoliceOfficer offc; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SetTaser>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; AvatarEquippable taserPrefab = offc.TaserPrefab; if ((Object)(object)taserPrefab == (Object)null) { return false; } AvatarRangedWeapon val = (AvatarRangedWeapon)(object)((taserPrefab is AvatarRangedWeapon) ? taserPrefab : null); if (val != null) { val.CanShootWhileMoving = true; val.MagazineSize = 20; val.MaxFireRate = 0.3f; ((AvatarWeapon)val).MaxUseRange = 24f; val.ReloadTime = 0.2f; val.RaiseTime = 0.1f; val.HitChance_MaxRange = 0.6f; val.HitChance_MinRange = 0.9f; } AvatarWeapon val2 = (AvatarWeapon)(object)((taserPrefab is AvatarWeapon) ? taserPrefab : null); if (val2 != null) { val2.CooldownDuration = 0.3f; } <>2__current = null; <>1__state = 1; return true; } case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SummonBustCop>d__2 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Customer customer; private NetworkObject <copNet>5__2; private NPC <myNpc>5__3; private PoliceOfficer <offc>5__4; private Vector3 <closest>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SummonBustCop>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <copNet>5__2 = null; <myNpc>5__3 = null; <offc>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_01ef: 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_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Expected O, but got Unknown //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) Player val; switch (<>1__state) { default: return false; case 0: { <>1__state = -1; int value = Mathf.RoundToInt(customer.NPC.RelationData.RelationDelta * 10f); var (num2, num3) = ThresholdUtils.Evaluate(ThresholdMappings.BuyBustProbability, value); if ((double)Random.Range(num2, num3) < 0.5) { return false; } <copNet>5__2 = Object.Instantiate<NetworkObject>(NACops.policeBase); <myNpc>5__3 = ((Component)<copNet>5__2).gameObject.GetComponent<NPC>(); NavMeshAgent component = ((Component)<copNet>5__2).GetComponent<NavMeshAgent>(); if (((Object)(object)component != (Object)null && !((Behaviour)component).enabled) || component.isStopped) { ((Behaviour)component).enabled = true; component.isStopped = false; } <myNpc>5__3.ID = $"NACop_{Guid.NewGuid()}"; <myNpc>5__3.FirstName = $"NACop_{Guid.NewGuid()}"; <myNpc>5__3.LastName = ""; ((Component)<myNpc>5__3).transform.parent = NetworkSingleton<NPCManager>.Instance.NPCContainer; NPCManager.NPCRegistry.Add(<myNpc>5__3); NACops.networkManager.ServerManager.Spawn(<copNet>5__2, (NetworkConnection)null, default(Scene)); <>2__current = NACops.Wait05; <>1__state = 1; return true; } case 1: <>1__state = -1; ((Component)<copNet>5__2).gameObject.SetActive(true); <>2__current = NACops.Wait01; <>1__state = 2; return true; case 2: { <>1__state = -1; <offc>5__4 = ((Component)<copNet>5__2).gameObject.GetComponent<PoliceOfficer>(); NACops.currentSummoned.Add(<offc>5__4); val = null; Vector3 val2 = ((Component)customer).transform.position + ((Component)customer).transform.forward * 3f; if (((NPC)<offc>5__4).Movement.GetClosestReachablePoint(val2, ref <closest>5__5) && <closest>5__5 != Vector3.zero) { NACops.coros.Add(MelonCoroutines.Start(SetTaser(<offc>5__4))); ((NPC)<offc>5__4).Movement.Warp(<closest>5__5); <>2__current = NACops.Wait1; <>1__state = 3; return true; } NACops.coros.Add(MelonCoroutines.Start(DisposeSummoned(<myNpc>5__3, <offc>5__4, instant: true, val))); goto IL_036b; } case 3: <>1__state = -1; ((VOEmitter)<offc>5__4.ChatterVO).Play((EVOLineType)2); ((NPC)<offc>5__4).Movement.FacePoint(((Component)customer).transform.position, 0.5f); <>2__current = NACops.Wait05; <>1__state = 4; return true; case 4: { <>1__state = -1; float num = default(float); val = Player.GetClosestPlayer(<closest>5__5, ref num, (List<Player>)null); val.CrimeData.SetPursuitLevel((EPursuitLevel)3); ((NPC)<offc>5__4).Movement.SetAgentType((EAgentType)1); <offc>5__4.BeginFootPursuit(val.PlayerCode); ((Behaviour)<offc>5__4.PursuitBehaviour).SendEnable(); val.CrimeData.AddCrime((Crime)new AttemptingToSell(), 10); goto IL_036b; } case 5: { <>1__state = -1; return false; } IL_036b: NACops.coros.Add(MelonCoroutines.Start(DisposeSummoned(<myNpc>5__3, <offc>5__4, instant: false, val))); <>2__current = null; <>1__state = 5; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static bool Prefix(Customer __instance, EHandoverOutcome outcome, Contract contract, List<ItemInstance> items, bool handoverByPlayer, bool giveBonuses = true) { NACops.coros.Add(MelonCoroutines.Start(PreProcessHandover(__instance, handoverByPlayer))); return true; } [IteratorStateMachine(typeof(<PreProcessHandover>d__1))] public static IEnumerator PreProcessHandover(Customer __instance, bool handoverByPlayer) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <PreProcessHandover>d__1(0) { __instance = __instance, handoverByPlayer = handoverByPlayer }; } [IteratorStateMachine(typeof(<SummonBustCop>d__2))] public static IEnumerator SummonBustCop(Customer customer) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SummonBustCop>d__2(0) { customer = customer }; } [IteratorStateMachine(typeof(<SetTaser>d__3))] public static IEnumerator SetTaser(PoliceOfficer offc) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SetTaser>d__3(0) { offc = offc }; } [IteratorStateMachine(typeof(<DisposeSummoned>d__4))] public static IEnumerator DisposeSummoned(NPC npc, PoliceOfficer offc, bool instant, Player target) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DisposeSummoned>d__4(0) { npc = npc, offc = offc, instant = instant, target = target }; } } public class UnityContractResolver : DefaultContractResolver { protected override JsonObjectContract CreateObjectContract(Type objectType) { JsonObjectContract val = ((DefaultContractResolver)this).CreateObjectContract(objectType); if (objectType == typeof(Vector3)) { for (int num = ((Collection<JsonProperty>)(object)val.Properties).Count - 1; num >= 0; num--) { JsonProperty val2 = ((Collection<JsonProperty>)(object)val.Properties)[num]; if (val2.PropertyName == "normalized" || val2.PropertyName == "magnitude" || val2.PropertyName == "sqrMagnitude") { ((Collection<JsonProperty>)(object)val.Properties).RemoveAt(num); } } } return val; } } public static class ConfigLoader { [Serializable] public class ModConfig { public bool ExtraOfficerPatrols = true; public bool ExtraOfficerSentries = true; public bool LethalCops = true; public bool NearbyCrazyCops = true; public bool CrazyCops = true; public bool PrivateInvestigator = true; public bool WeedInvestigator = true; public bool CorruptCops = true; public bool SnitchingSamples = true; public bool BuyBusts = true; } [Serializable] public class NAOfficerConfig { public int ModAddedOfficersCount = 8; public bool OverrideMovement = true; public bool OverrideCombatBeh = true; public bool OverrideBodySearch = true; public bool OverrideWeapon = true; public bool OverrideMaxHealth = true; public float MovementRunSpeed = 6.8f; public float MovementWalkSpeed = 2.4f; public float CombatGiveUpRange = 40f; public float CombatGiveUpTime = 60f; public float CombatSearchTime = 60f; public float CombatMoveSpeed = 6.8f; public int CombatEndAfterHits = 40; public float OfficerMaxHealth = 175f; public int WeaponMagSize = 20; public float WeaponFireRate = 0.33f; public float WeaponMaxRange = 25f; public float WeaponReloadTime = 0.5f; public float WeaponRaiseTime = 0.2f; public float WeaponHitChanceMax = 0.3f; public float WeaponHitChanceMin = 0.8f; } [Serializable] public class FootPatrolsSerialized { public List<SerializedFootPatrol> loadedPatrols = new List<SerializedFootPatrol>(); } [Serializable] public class SentrysSerialized { public List<SerializedSentry> loadedSentrys = new List<SerializedSentry>(); } private static string modConfig = Path.Combine(MelonEnvironment.ModsDirectory, "NACops", "config.json"); private static string officerConfig = Path.Combine(MelonEnvironment.ModsDirectory, "NACops", "officer.json"); private static string patrolsConfig = Path.Combine(MelonEnvironment.ModsDirectory, "NACops", "patrols.json"); private static string sentrysConfig = Path.Combine(MelonEnvironment.ModsDirectory, "NACops", "sentrys.json"); public static ModConfig LoadModConfig() { ModConfig modConfig; if (File.Exists(ConfigLoader.modConfig)) { try { modConfig = JsonConvert.DeserializeObject<ModConfig>(File.ReadAllText(ConfigLoader.modConfig)); } catch (Exception ex) { modConfig = new ModConfig(); MelonLogger.Warning("Failed to read NACops config: " + ex); } } else { modConfig = new ModConfig(); Save(modConfig); } return modConfig; } public static void Save(ModConfig config) { try { string contents = JsonConvert.SerializeObject((object)config, (Formatting)1); Directory.CreateDirectory(Path.GetDirectoryName(modConfig)); File.WriteAllText(modConfig, contents); } catch (Exception ex) { MelonLogger.Warning("Failed to save NACops config: " + ex); } } public static NAOfficerConfig LoadOfficerConfig() { NAOfficerConfig nAOfficerConfig; if (File.Exists(officerConfig)) { try { nAOfficerConfig = JsonConvert.DeserializeObject<NAOfficerConfig>(File.ReadAllText(officerConfig)); nAOfficerConfig.ModAddedOfficersCount = Mathf.Clamp(nAOfficerConfig.ModAddedOfficersCount, 0, 20); } catch (Exception ex) { nAOfficerConfig = new NAOfficerConfig(); MelonLogger.Warning("Failed to read NACops config: " + ex); } } else { nAOfficerConfig = new NAOfficerConfig(); Save(nAOfficerConfig); } return nAOfficerConfig; } public static void Save(NAOfficerConfig config) { try { string contents = JsonConvert.SerializeObject((object)config); Directory.CreateDirectory(Path.GetDirectoryName(officerConfig)); File.WriteAllText(officerConfig, contents); } catch (Exception ex) { MelonLogger.Warning("Failed to save NACops config: " + ex); } } public static FootPatrolsSerialized LoadPatrolsConfig() { FootPatrolsSerialized footPatrolsSerialized; if (File.Exists(patrolsConfig)) { try { footPatrolsSerialized = JsonConvert.DeserializeObject<FootPatrolsSerialized>(File.ReadAllText(patrolsConfig)); List<string> list = new List<string> { "mon", "tue", "wed", "thu", "fri", "sat", "sun" }; foreach (SerializedFootPatrol loadedPatrol in footPatrolsSerialized.loadedPatrols) { loadedPatrol.members = Mathf.Clamp(loadedPatrol.members, 1, 4); loadedPatrol.name = (string.IsNullOrEmpty(loadedPatrol.name) ? "NaCopsPatrol " : loadedPatrol.name); loadedPatrol.intensityRequirement = Mathf.Clamp(loadedPatrol.intensityRequirement, 0, 10); if (!TimeManager.IsValid24HourTime(loadedPatrol.startTime.ToString())) { MelonLogger.Warning("FootPatrolsConfig '" + loadedPatrol.name + "' has invalid start time"); loadedPatrol.startTime = 1900; } if (!TimeManager.IsValid24HourTime(loadedPatrol.endTime.ToString())) { MelonLogger.Warning("FootPatrolsConfig '" + loadedPatrol.name + "' has invalid end time"); loadedPatrol.endTime = 2330; } if (loadedPatrol.waypoints.Count == 0) { MelonLogger.Warning("FootPatrolsConfig is missing Waypoints for " + loadedPatrol.name); } for (int num = loadedPatrol.days.Count - 1; num != -1; num--) { if (loadedPatrol.days[num] != string.Empty) { loadedPatrol.days[num] = loadedPatrol.days[num].ToLower(); if (!list.Contains(loadedPatrol.days[num])) { MelonLogger.Warning("FootPatrolsConfig '" + loadedPatrol.name + "' has invalid weekday: '" + loadedPatrol.days[num] + "'"); loadedPatrol.days.RemoveAt(num); } } else { loadedPatrol.days.RemoveAt(num); } } } } catch (Exception ex) { footPatrolsSerialized = new FootPatrolsSerialized(); MelonLogger.Warning("Failed to read FootPatrolsSerialized config: " + ex); } } else { footPatrolsSerialized = new FootPatrolsSerialized(); } return footPatrolsSerialized; } public static SentrysSerialized LoadSentryConfig() { SentrysSerialized sentrysSerialized; if (File.Exists(sentrysConfig)) { try { sentrysSerialized = JsonConvert.DeserializeObject<SentrysSerialized>(File.ReadAllText(sentrysConfig)); List<string> list = new List<string> { "mon", "tue", "wed", "thu", "fri", "sat", "sun" }; foreach (SerializedSentry loadedSentry in sentrysSerialized.loadedSentrys) { loadedSentry.members = Mathf.Clamp(loadedSentry.members, 1, 2); loadedSentry.name = (string.IsNullOrEmpty(loadedSentry.name) ? "NACopsSentry " : loadedSentry.name); loadedSentry.intensityRequirement = Mathf.Clamp(loadedSentry.intensityRequirement, 0, 10); if (!TimeManager.IsValid24HourTime(loadedSentry.startTime.ToString())) { MelonLogger.Warning("SentryConfig '" + loadedSentry.name + "' has invalid start time"); loadedSentry.startTime = 1900; } if (!TimeManager.IsValid24HourTime(loadedSentry.endTime.ToString())) { MelonLogger.Warning("SentryConfig '" + loadedSentry.name + "' has invalid end time"); loadedSentry.endTime = 2330; } for (int num = loadedSentry.days.Count - 1; num != -1; num--) { if (loadedSentry.days[num] != string.Empty) { loadedSentry.days[num] = loadedSentry.days[num].ToLower(); if (!list.Contains(loadedSentry.days[num])) { MelonLogger.Warning("SentryConfig '" + loadedSentry.name + "' has invalid weekday: '" + loadedSentry.days[num] + "'"); loadedSentry.days.RemoveAt(num); } } else { loadedSentry.days.RemoveAt(num); } } } } catch (Exception ex) { sentrysSerialized = new SentrysSerialized(); MelonLogger.Warning("Failed to read SentrysSerialized config: " + ex); } } else { sentrysSerialized = new SentrysSerialized(); } return sentrysSerialized; } } public static class DebugModule { public static int origCount; [Conditional("DEBUG")] public static void Log(string msg) { MelonLogger.Msg(msg); } [Conditional("DEBUG")] public static void LogStateHourly() { } [Conditional("DEBUG")] public static void OnInput() { } } [HarmonyPatch(typeof(Player), "ConsumeProduct")] public static class Player_ConsumeProduct_Patch { [CompilerGenerated] private sealed class <ApprehenderOfficerClear>d__3 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public PoliceOfficer offc; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ApprehenderOfficerClear>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)offc == (Object)null) { return false; } <>2__current = NACops.Wait30; <>1__state = 1; return true; case 1: <>1__state = -1; if (NACops.currentDrugApprehender.Contains(offc)) { NACops.currentDrugApprehender.Remove(offc); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DrugConsumedCoro>d__2 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ProductItemInstance product; public Player player; private PoliceOfficer <noticeOfficer>5__2; private float <smallestDistance>5__3; private bool <direct>5__4; private bool <apprehending>5__5; private HashSet<PoliceOfficer>.Enumerator <>7__wrap5; private PoliceOfficer <offc>5__7; private int <i>5__8; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DrugConsumedCoro>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <noticeOfficer>5__2 = null; <>7__wrap5 = default(HashSet<PoliceOfficer>.Enumerator); <offc>5__7 = null; <>1__state = -2; } private bool MoveNext() { //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; if (!NACops.currentConfig.WeedInvestigator) { return false; } bool num2 = product is WeedInstance; bool flag = product is MethInstance; bool flag2 = product is CocaineInstance; if (num2 || flag || flag2) { <noticeOfficer>5__2 = null; <smallestDistance>5__3 = 49f; <direct>5__4 = false; <>7__wrap5 = NACops.allActiveOfficers.GetEnumerator(); <>1__state = -3; goto IL_028c; } goto IL_05c9; } case 1: <>1__state = -3; if (!BaseUtility.GUIDInUse.Contains(((NPC)<offc>5__7).BakedGUID) && !NACops.currentDrugApprehender.Contains(<offc>5__7) && !NACops.currentSummoned.Contains(<offc>5__7) && !(Vector3.Distance(((Component)<offc>5__7).transform.position, ((Component)player).transform.position) > 50f) && !((NPC)<offc>5__7).Health.IsDead && !((NPC)<offc>5__7).Health.IsKnockedOut) { if (((NPC)<offc>5__7).Awareness.VisionCone.IsPlayerVisible(player) && ((NPC)<offc>5__7).Movement.CanMove() && !((NPC)<offc>5__7).IsInVehicle && !((NPC)<offc>5__7).isInBuilding) { <offc>5__7.BeginFootPursuit(player.PlayerCode); NACops.coros.Add(MelonCoroutines.Start(BaseUtility.GiveFalseCharges(3, player))); <direct>5__4 = true; ((object)((NPC)<offc>5__7).Behaviour.activeBehaviour)?.ToString(); goto IL_029c; } float num = Vector3.Distance(((Component)<offc>5__7).transform.position, ((Component)player).transform.position); if (num < <smallestDistance>5__3 && !((NPC)<offc>5__7).IsInVehicle && !((NPC)<offc>5__7).isInBuilding) { <smallestDistance>5__3 = num; <noticeOfficer>5__2 = <offc>5__7; } <offc>5__7 = null; } goto IL_028c; case 2: <>1__state = -1; if (((NPC)<noticeOfficer>5__2).Awareness.VisionCone.IsPlayerVisible(player)) { <noticeOfficer>5__2.BeginBodySearch(player.PlayerCode); NACops.coros.Add(MelonCoroutines.Start(BaseUtility.GiveFalseCharges(3, player))); <apprehending>5__5 = true; } if ((Object)(object)<noticeOfficer>5__2 != (Object)null && !<apprehending>5__5) { <i>5__8 = 0; goto IL_05b6; } goto IL_05c2; case 3: <>1__state = -1; if (!NACops.registered) { return false; } if (!((NPC)<noticeOfficer>5__2).Health.IsDead && !((NPC)<noticeOfficer>5__2).Health.IsKnockedOut) { if (!((NPC)<noticeOfficer>5__2).Awareness.VisionCone.IsPlayerVisible(player)) { <>2__current = NACops.Wait05; <>1__state = 4; return true; } <noticeOfficer>5__2.BeginBodySearch(player.PlayerCode); if (Random.Range(1f, 0f) > 0.8f) { NACops.coros.Add(MelonCoroutines.Start(BaseUtility.GiveFalseCharges(1, player))); } } goto IL_05c2; case 4: <>1__state = -1; if (!NACops.registered) { return false; } if (!((NPC)<noticeOfficer>5__2).Health.IsDead && !((NPC)<noticeOfficer>5__2).Health.IsKnockedOut) { ((NPC)<noticeOfficer>5__2).Movement.SetDestination(player.CenterPointTransform.position); <>2__current = NACops.Wait1; <>1__state = 5; return true; } goto IL_05c2; case 5: <>1__state = -1; if (!NACops.registered) { return false; } if (!((NPC)<noticeOfficer>5__2).Health.IsDead && !((NPC)<noticeOfficer>5__2).Health.IsKnockedOut) { <i>5__8++; goto IL_05b6; } goto IL_05c2; case 6: { <>1__state = -1; return false; } IL_05c2: <noticeOfficer>5__2 = null; goto IL_05c9; IL_05b6: if (<i>5__8 <= 6) { if (!NACops.registered) { return false; } if (<i>5__8 <= 3 || !(Random.Range(1f, 0f) > 0.95f)) { ((NPC)<noticeOfficer>5__2).Movement.FacePoint(player.CenterPointTransform.position, 0.3f); <>2__current = NACops.Wait05; <>1__state = 3; return true; } } goto IL_05c2; IL_05c9: evaluating = false; <>2__current = null; <>1__state = 6; return true; IL_028c: if (<>7__wrap5.MoveNext()) { <offc>5__7 = <>7__wrap5.Current; <>2__current = NACops.Wait01; <>1__state = 1; return true; } goto IL_029c; IL_029c: <>m__Finally1(); <>7__wrap5 = default(HashSet<PoliceOfficer>.Enumerator); if (((Object)(object)<noticeOfficer>5__2 == (Object)null) | <direct>5__4) { evaluating = false; return false; } NACops.currentDrugApprehender.Add(<noticeOfficer>5__2); NACops.coros.Add(MelonCoroutines.Start(ApprehenderOfficerClear(<noticeOfficer>5__2))); <apprehending>5__5 = false; ((NPC)<noticeOfficer>5__2).Movement.FacePoint(((Component)player).transform.position, 0.4f); <>2__current = NACops.Wait05; <>1__state = 2; return true; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap5).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static bool evaluating; public static bool Prefix(Player __instance, ProductItemInstance product) { if (!evaluating && NACops.currentDrugApprehender.Count < 1) { evaluating = true; NACops.coros.Add(MelonCoroutines.Start(DrugConsumedCoro(__instance, product))); } return true; } [IteratorStateMachine(typeof(<DrugConsumedCoro>d__2))] public static IEnumerator DrugConsumedCoro(Player player, ProductItemInstance product) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DrugConsumedCoro>d__2(0) { player = player, product = product }; } [IteratorStateMachine(typeof(<ApprehenderOfficerClear>d__3))] public static IEnumerator ApprehenderOfficerClear(PoliceOfficer offc) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ApprehenderOfficerClear>d__3(0) { offc = offc }; } } public static class CrazyCops { [CompilerGenerated] private sealed class <RunCrazyCops>d__9 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private Player <randomPlayer>5__2; private Vector3 <playerPosition>5__3; private HashSet<PoliceOfficer>.Enumerator <>7__wrap3; private PoliceOfficer <officer>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RunCrazyCops>d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } <randomPlayer>5__2 = null; <>7__wrap3 = default(HashSet<PoliceOfficer>.Enumerator); <officer>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_01a8: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: 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) bool result; try { switch (<>1__state) { default: result = false; break; case 0: { <>1__state = -1; (float min, float max) tuple2 = ThresholdUtils.Evaluate(ThresholdMappings.CrazyCopsFreq, NetworkSingleton<TimeManager>.Instance.ElapsedDays); minWait = tuple2.min; maxWait = tuple2.max; randWaits = new List<WaitForSeconds> { new WaitForSeconds(Random.Range(minWait, maxWait)), new WaitForSeconds(Random.Range(minWait, maxWait)), new WaitForSeconds(Random.Range(minWait, maxWait)) }; goto IL_00ac; } case 1: { <>1__state = -1; if (!NACops.registered) { result = false; break; } Player[] array = Object.FindObjectsOfType<Player>(true); <randomPlayer>5__2 = array[Random.Range(0, array.Length)]; if ((Object)(object)<randomPlayer>5__2.CurrentProperty != (Object)null) { goto IL_00ac; } <playerPosition>5__3 = ((Component)<randomPlayer>5__2).transform.position; nearestOfficer = null; <>7__wrap3 = NACops.allActiveOfficers.GetEnumerator(); <>1__state = -3; goto IL_023a; } case 2: { <>1__state = -3; if (!NACops.registered) { result = false; <>m__Finally1(); break; } float num = Vector3.Distance(((Component)<officer>5__5).transform.position, <playerPosition>5__3); if (num < closestDistance && !NACops.currentSummoned.Contains(<officer>5__5) && !NACops.currentDrugApprehender.Contains(<officer>5__5) && !BaseUtility.GUIDInUse.Contains(((NPC)<officer>5__5).BakedGUID) && !BaseUtility.IsStationNearby(<playerPosition>5__3) && !((NPC)<officer>5__5).isInBuilding) { closestDistance = num; nearestOfficer = <officer>5__5; if (closestDistance <= earlyTermDist) { goto IL_024a; } } <officer>5__5 = null; goto IL_023a; } case 3: { <>1__state = -1; if (!NACops.registered) { result = false; break; } if (((NPC)nearestOfficer).Awareness.VisionCone.IsPlayerVisible(<randomPlayer>5__2)) { nearestOfficer.BeginFootPursuit(<randomPlayer>5__2.PlayerCode); NACops.coros.Add(MelonCoroutines.Start(BaseUtility.GiveFalseCharges(3, <randomPlayer>5__2))); } goto IL_046e; } IL_024a: <>m__Finally1(); <>7__wrap3 = default(HashSet<PoliceOfficer>.Enumerator); if (!((Object)(object)nearestOfficer == (Object)null)) { BaseUtility.GUIDInUse.Add(((NPC)nearestOfficer).BakedGUID); (float min, float max) tuple = ThresholdUtils.Evaluate(ThresholdMappings.CrazyCopsRange, (int)NetworkSingleton<MoneyManager>.Instance.LifetimeEarnings); minRange = tuple.min; maxRange = tuple.max; earlyTermDist = Mathf.Lerp(minRange, maxRange, 0.3f); if (!((Object)(object)nearestOfficer != (Object)null) || !(closestDistance < Random.Range(minRange, maxRange))) { goto IL_0499; } if (!Object.op_Implicit((Object)(object)((NPC)nearestOfficer).Behaviour.activeBehaviour) || !(((NPC)nearestOfficer).Behaviour.activeBehaviour is VehiclePatrolBehaviour)) { if (Random.Range(0f, 1f) > 0.3f) { ((NPC)nearestOfficer).Movement.FacePoint(((Component)<randomPlayer>5__2).transform.position, 0.4f); <>2__current = NACops.Wait05; <>1__state = 3; result = true; break; } NACops.coros.Add(MelonCoroutines.Start(BaseUtility.LateInvestigation(<randomPlayer>5__2))); goto IL_046e; } nearestOfficer.BeginVehiclePursuit(<randomPlayer>5__2.PlayerCode, ((NetworkBehaviour)nearestOfficer.AssignedVehicle).NetworkObject, true); NACops.coros.Add(MelonCoroutines.Start(BaseUtility.GiveFalseCharges(3, <randomPlayer>5__2))); if (BaseUtility.GUIDInUse.Contains(((NPC)nearestOfficer).BakedGUID)) { BaseUtility.GUIDInUse.Remove(((NPC)nearestOfficer).BakedGUID); } } goto IL_00ac; IL_046e: if (BaseUtility.GUIDInUse.Contains(((NPC)nearestOfficer).BakedGUID)) { BaseUtility.GUIDInUse.Remove(((NPC)nearestOfficer).BakedGUID); } goto IL_0499; IL_00ac: currentAwait = randWaits[Random.Range(0, randWaits.Count)]; <>2__current = currentAwait; <>1__state = 1; result = true; break; IL_0499: <randomPlayer>5__2 = null; goto IL_00ac; IL_023a: if (<>7__wrap3.MoveNext()) { <officer>5__5 = <>7__wrap3.Current; <>2__current = NACops.Wait01; <>1__state = 2; result = true; break; } goto IL_024a; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap3).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static float minWait; private static float maxWait; private static float minRange; private static float maxRange; private static List<WaitForSeconds> randWaits; private static WaitForSeconds currentAwait; private static PoliceOfficer nearestOfficer = null; private static float closestDistance = 100f; private static float earlyTermDist = 20f; [IteratorStateMachine(typeof(<RunCrazyCops>d__9))] public static IEnumerator RunCrazyCops() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RunCrazyCops>d__9(0); } } public static class LethalCops { [CompilerGenerated] private sealed class <RunNearbyLethalCops>d__6 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private float <minDistance>5__2; private Player <randomPlayer>5__3; private HashSet<PoliceOfficer>.Enumerator <>7__wrap3; private PoliceOfficer <officer>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RunNearbyLethalCops>d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 2) <= 1u) { try { } finally { <>m__Finally1(); } } <randomPlayer>5__3 = null; <>7__wrap3 = default(HashSet<PoliceOfficer>.Enumerator); <officer>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) bool result; try { switch (<>1__state) { default: result = false; goto end_IL_0000; case 0: { <>1__state = -1; (float min, float max) tuple2 = ThresholdUtils.Evaluate(ThresholdMappings.LethalCopFreq, NetworkSingleton<TimeManager>.Instance.ElapsedDays); minWait = tuple2.min; maxWait = tuple2.max; randWaits = new List<WaitForSeconds> { new WaitForSeconds(Random.Range(minWait, maxWait)), new WaitForSeconds(Random.Range(minWait, maxWait)), new WaitForSeconds(Random.Range(minWait, maxWait)) }; goto IL_00ac; } case 1: <>1__state = -1; if (NACops.registered) { (float min, float max) tuple = ThresholdUtils.Evaluate(ThresholdMappings.LethalCopRange, (int)NetworkSingleton<MoneyManager>.Instance.LifetimeEarnings); minRange = tuple.min; maxRange = tuple.max; <minDistance>5__2 = Random.Range(minRange, maxRange); Player[] array = Object.FindObjectsOfType<Player>(true); <randomPlayer>5__3 = array[Random.Range(0, array.Length)]; <>7__wrap3 = NACops.allActiveOfficers.GetEnumerator(); <>1__state = -3; goto IL_0377; } result = false; goto end_IL_0000; case 2: <>1__state = -3; if (!NACops.registered) { result = false; break; } if (!(Vector3.Distance(((Component)<officer>5__5).transform.position, ((Component)<randomPlayer>5__3).transform.position) < <minDistance>5__2) || NACops.currentSummoned.Contains(<officer>5__5) || NACops.currentDrugApprehender.Contains(<officer>5__5) || BaseUtility.IsStationNearby(((Component)<randomPlayer>5__3).transform.position) || <randomPlayer>5__3.CrimeData.BodySearchPending || ((NPC)<officer>5__5).IsInVehicle || !((Object)(object)((NPC)<officer>5__5).Behaviour.activeBehaviour != (Object)(object)<officer>5__5.CheckpointBehaviour) || ((NPC)<officer>5__5).isInBuilding || BaseUtility.GUIDInUse.Contains(((NPC)<officer>5__5).BakedGUID)) { <officer>5__5 = null; goto IL_0377; } BaseUtility.GUIDInUse.Add(((NPC)<officer>5__5).BakedGUID); ((NPC)<officer>5__5).Movement.FacePoint(((Component)Player.Local).transform.position, 0.4f); <>2__current = NACops.Wait05; <>1__state = 3; result = true; goto end_IL_0000; case 3: { <>1__state = -3; if (!NACops.registered) { result = false; break; } if (((NPC)<officer>5__5).Awareness.VisionCone.IsPlayerVisible(<randomPlayer>5__3)) { <randomPlayer>5__3.CrimeData.SetPursuitLevel((EPursuitLevel)4); <officer>5__5.BeginFootPursuit(<randomPlayer>5__3.PlayerCode); } if (BaseUtility.GUIDInUse.Contains(((NPC)<officer>5__5).BakedGUID)) { BaseUtility.GUIDInUse.Remove(((NPC)<officer>5__5).BakedGUID); } goto IL_0387; } IL_00ac: currentAwait = randWaits[Random.Range(0, randWaits.Count)]; <>2__current = currentAwait; <>1__state = 1; result = true; goto end_IL_0000; IL_0387: <>m__Finally1(); <>7__wrap3 = default(HashSet<PoliceOfficer>.Enumerator); <randomPlayer>5__3 = null; goto IL_00ac; IL_0377: if (!<>7__wrap3.MoveNext()) { goto IL_0387; } <officer>5__5 = <>7__wrap3.Current; <>2__current = NACops.Wait01; <>1__state = 2; result = true; goto end_IL_0000; } <>m__Finally1(); end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap3).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static float minWait; private static float maxWait; private static float minRange; private static float maxRange; private static List<WaitForSeconds> randWaits; private static WaitForSeconds currentAwait; [IteratorStateMachine(typeof(<RunNearbyLethalCops>d__6))] public static IEnumerator RunNearbyLethalCops() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RunNearbyLethalCops>d__6(0); } } public static class NearbyCrazyCops { [CompilerGenerated] private sealed class <GreedyBodySearchFind>d__7 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public PoliceOfficer officer; public Player player; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GreedyBodySearchFind>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; ((VOEmitter)officer.ChatterVO).Play((EVOLineType)13); ((NPC)officer).Movement.FacePoint(((Component)player).transform.position, 0.4f); <>2__current = NACops.Wait05; <>1__state = 1; return true; case 1: { <>1__state = -1; if (!NACops.registered) { return false; } if (((NPC)officer).Awareness.VisionCone.IsPlayerVisible(player) && !player.CrimeData.BodySearchPending) { officer.BeginBodySearch(player.PlayerCode); if (Random.Range(0f, 1f) > 0.8f) { NACops.coros.Add(MelonCoroutines.Start(BaseUtility.GiveFalseCharges(2, player))); } if (BaseUtility.GUIDInUse.Contains(((NPC)officer).BakedGUID)) { BaseUtility.GUIDInUse.Remove(((NPC)officer).BakedGUID); } return false; } Vector3 val = default(Vector3); ((NPC)officer).Movement.GetClosestReachablePoint(player.CenterPointTransform.position, ref val); if (val != Vector3.zero && ((NPC)officer).Movement.CanMove() && ((NPC)officer).Movement.CanGetTo(val, 1f)) { ((NPC)officer).Movement.SetDestination(val); } if (BaseUtility.GUIDInUse.Contains(((NPC)officer).BakedGUID)) { BaseUtility.GUIDInUse.Remove(((NPC)officer).BakedGUID); } <>2__current = null; <>1__state = 2; return true; } case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <RunNearbyCrazyCops>d__6 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private float <minDistance>5__2; private Player[] <>7__wrap2; private int <>7__wrap3; private Player <player>5__5; private HashSet<PoliceOfficer>.Enumerator <>7__wrap5; private PoliceOfficer <officer>5__7; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RunNearbyCrazyCops>d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } <>7__wrap2 = null; <player>5__5 = null; <>7__wrap5 = default(HashSet<PoliceOfficer>.Enumerator); <officer>5__7 = null; <>1__state = -2; } private bool MoveNext() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_026b: 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_02c5: Unknown result type (might be due to invalid IL or missing references) bool result; try { switch (<>1__state) { default: result = false; break; case 0: { <>1__state = -1; (float min, float max) tuple2 = ThresholdUtils.Evaluate(ThresholdMappings.NearbyCrazThres, NetworkSingleton<TimeManager>.Instance.ElapsedDays); minWait = tuple2.min; maxWait = tuple2.max; randWaits = new List<WaitForSeconds> { new WaitForSeconds(Random.Range(minWait, maxWait)), new WaitForSeconds(Random.Range(minWait, maxWait)), new WaitForSeconds(Random.Range(minWait, maxWait)) }; goto IL_00a8; } case 1: { <>1__state = -1; if (!NACops.registered) { result = false; break; } Player[] array = Object.FindObjectsOfType<Player>(true); (float min, float max) tuple = ThresholdUtils.Evaluate(ThresholdMappings.NearbyCrazRange, (int)NetworkSingleton<MoneyManager>.Instance.LifetimeEarnings); minRange = tuple.min; maxRange = tuple.max; <minDistance>5__2 = Random.Range(minRange, maxRange); <>7__wrap2 = array; <>7__wrap3 = 0; goto IL_0394; } case 2: { <>1__state = -3; if (!NACops.registered) { result = false; <>m__Finally1(); break; } if (!((NPC)<officer>5__7).IsInVehicle && (!Object.op_Implicit((Object)(object)((NPC)<officer>5__7).Behaviour.activeBehaviour) || !(((NPC)<officer>5__7).Behaviour.activeBehaviour is VehiclePatrolBehaviour)) && (!Object.op_Implicit((Object)(object)((NPC)<officer>5__7).Behaviour.activeBehaviour) || !(((NPC)<officer>5__7).Behaviour.activeBehaviour is VehiclePursuitBehaviour)) && !BaseUtility.GUIDInUse.Contains(((NPC)<officer>5__7).BakedGUID)) { if (Vector3.Distance(((Component)<officer>5__7).transform.position, ((Component)<player>5__5).transform.position) < <minDistance>5__2 && !NACops.currentSummoned.Contains(<officer>5__7) && !NACops.currentDrugApprehender.Contains(<officer>5__7) && !BaseUtility.IsStationNearby(((Component)<player>5__5).transform.position) && !((NPC)<officer>5__7).IsInVehicle && !((NPC)<officer>5__7).isInBuilding && !((NPC)<officer>5__7).Health.IsDead && !((NPC)<officer>5__7).Health.IsKnockedOut) { BaseUtility.GUIDInUse.Add(((NPC)<officer>5__7).BakedGUID); NACops.coros.Add(MelonCoroutines.Start(GreedyBodySearchFind(<officer>5__7, <player>5__5, <minDistance>5__2))); goto IL_0363; } <officer>5__7 = null; } goto IL_0353; } IL_0363: <>m__Finally1(); <>7__wrap5 = default(HashSet<PoliceOfficer>.Enumerator); <player>5__5 = null; goto IL_0386; IL_0386: <>7__wrap3++; goto IL_0394; IL_0394: if (<>7__wrap3 < <>7__wrap2.Length) { <player>5__5 = <>7__wrap2[<>7__wrap3]; if (!((Object)(object)<player>5__5.CurrentProperty != (Object)null)) { <>7__wrap5 = NACops.allActiveOfficers.GetEnumerator(); <>1__state = -3; goto IL_0353; } goto IL_0386; } <>7__wrap2 = null; goto IL_00a8; IL_00a8: currentAwait = randWaits[Random.Range(0, randWaits.Count)]; <>2__current = currentAwait; <>1__state = 1; result = true; break; IL_0353: if (<>7__wrap5.MoveNext()) { <officer>5__7 = <>7__wrap5.Current; <>2__current = NACops.Wait01; <>1__state = 2; result = true; break; } goto IL_0363; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap5).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static float minWait; private static float maxWait; private static float minRange; private static float maxRange; private static List<WaitForSeconds> randWaits; private static WaitForSeconds currentAwait; [IteratorStateMachine(typeof(<RunNearbyCrazyCops>d__6))] public static IEnumerator RunNearbyCrazyCops() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RunNearbyCrazyCops>d__6(0); } [IteratorStateMachine(typeof(<GreedyBodySearchFind>d__7))] public static IEnumerator GreedyBodySearchFind(PoliceOfficer officer, Player player, float minDistance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <GreedyBodySearchFind>d__7(0) { officer = officer, player = player }; } } public static class BuildInfo { public const string Name = "NACopsV1"; public const string Description = "Crazyyyy cops"; public const string Author = "XOWithSauce"; public const string Company = null; public const string Version = "1.9.0"; public const string DownloadLink = null; } public class NACops : MelonMod { [HarmonyPatch(typeof(LoadManager), "ExitToMenu")] public static class LoadManager_ExitToMenu_Patch { public static bool Prefix(LoadManager __instance, SaveInfo autoLoadSave = null, Data mainMenuPopup = null, bool preventLeaveLobby = false) { ExitPreTask(); return true; } } [HarmonyPatch(typeof(DeathScreen), "LoadSaveClicked")] public static class DeathScreen_LoadSaveClicked_Patch { public static bool Prefix(DeathScreen __instance) { ExitPreTask(); return true; } } [CompilerGenerated] private sealed class <OfficersInit>d__29 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OfficersInit>d__29(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { PoliceOfficer[] array; switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (officerConfig.ModAddedOfficersCount != 0) { <>2__current = MelonCoroutines.Start(OfficerOverrides.ExtendOfficerPool()); <>1__state = 1; return true; } goto IL_004e; case 1: <>1__state = -1; goto IL_004e; case 2: { <>1__state = -1; return false; } IL_004e: allActiveOfficers.Clear(); array = Object.FindObjectsOfType<PoliceOfficer>(true); foreach (PoliceOfficer item in array) { allActiveOfficers.Add(item); } coros.Add(MelonCoroutines.Start(OfficerOverrides.SetOfficers())); <>2__current = null; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <RunCoros>d__31 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RunCoros>d__31(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (currentConfig.CrazyCops) { coros.Add(MelonCoroutines.Start(CrazyCops.RunCrazyCops())); } if (currentConfig.NearbyCrazyCops) { coros.Add(MelonCoroutines.Start(NearbyCrazyCops.RunNearbyCrazyCops())); } if (currentConfig.LethalCops) { coros.Add(MelonCoroutines.Start(LethalCops.RunNearbyLethalCops())); } if (currentConfig.PrivateInvestigator) { coros.Add(MelonCoroutines.Start(PrivateInvestigator.RunInvestigator())); } <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <Setup>d__28 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Setup>d__28(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = Wait5; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = MelonCoroutines.Start(StationInit()); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = Wait2; <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = MelonCoroutines.Start(OfficersInit()); <>1__state = 4; return true; case 4: <>1__state = -1; <>2__current = Wait2; <>1__state = 5; return true; case 5: <>1__state = -1; coros.Add(MelonCoroutines.Start(RunCoros())); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <StationInit>d__30 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <StationInit>d__30(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (false) { bool flag = Singleton<LawController>.Instance.CurrentSettings == null; bool flag2 = Singleton<LawController>.Instance.MondaySettings == null; LawActivitySettings val; if (!flag) { val = Singleton<LawController>.Instance.CurrentSettings; } else { if (!flag || flag2) { return false; } val = Singleton<LawController>.Instance.MondaySettings; } LawActivitySettings val2 = new LawActivitySettings(); val2.Curfews = val.Curfews; val2.VehiclePatrols = val.VehiclePatrols; val2.Checkpoints = val.Checkpoints; if (currentConfig.ExtraOfficerPatrols) { val2.Patrols = FootPatrolGenerator.GeneratePatrol(val); } else { val2.Patrols = val.Patrols; } if (currentConfig.ExtraOfficerSentries) { val2.Sentries = SentryGenerator.GenerateSentry(val); } else { val2.Sentries = val.Sentries; } generatedLawSettings.Add(val2); Singleton<LawController>.Instance.OverrideSetings(val2); } else { foreach (KeyValuePair<string, LawActivitySettings> item in new Dictionary<string, LawActivitySettings> { { "mon", Singleton<LawController>.Instance.MondaySettings }, { "tue", Singleton<LawController>.Instance.TuesdaySettings }, { "wed", Singleton<LawController>.Instance.WednesdaySettings }, { "thu", Singleton<LawController>.Instance.ThursdaySettings }, { "fri", Singleton<LawController>.Instance.FridaySettings }, { "sat", Singleton<LawController>.Instance.SaturdaySettings }, { "sun", Singleton<LawController>.Instance.SundaySettings } }) { _ = item.Key; LawActivitySettings val3 = new LawActivitySettings(); val3.Curfews = item.Value.Curfews; val3.VehiclePatrols = item.Value.VehiclePatrols; val3.Checkpoints = item.Value.Checkpoints; if (currentConfig.ExtraOfficerPatrols) { val3.Patrols = FootPatrolGenerator.GeneratePatrol(item.Value, item.Key); } else { val3.Patrols = item.Value.Patrols; } if (currentConfig.ExtraOfficerSentries) { val3.Sentries = SentryGenerator.GenerateSentry(item.Value, item.Key); } else { val3.Sentries = item.Value.Sentries; } generatedLawSettings.Add(val3); switch (item.Key) { case "mon": Singleton<LawController>.Instance.MondaySettings = val3; break; case "tue": Singleton<LawController>.Instance.TuesdaySettings = val3; break; case "wed": Singleton<LawController>.Instance.WednesdaySettings = val3; break; case "thu": Singleton<LawController>.Instance.ThursdaySettings = val3; break; case "fri": Singleton<LawController>.Instance.FridaySettings = val3; break; case "sat": Singleton<LawController>.Instance.SaturdaySettings = val3; break; case "sun": Singleton<LawController>.Instance.SundaySettings = val3; break; } } } <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static ConfigLoader.ModConfig currentConfig; public static ConfigLoader.NAOfficerConfig officerConfig; public static List<object> coros = new List<object>(); public static readonly HashSet<PoliceOfficer> allActiveOfficers = new HashSet<PoliceOfficer>(); public static HashSet<PoliceOfficer> currentDrugApprehender = new HashSet<PoliceOfficer>(); public static HashSet<PoliceOfficer> currentSummoned = new HashSet<PoliceOfficer>(); public static int currentPICount = 0; public static bool registered = false; public static bool lastSaveLoad = false; public static bool firstTimeLoad = false; public static NetworkObject policeBase; public static NetworkManager networkManager; public static int sessionPropertyHeat = 0; public static List<LawActivitySettings> generatedLawSettings = new List<LawActivitySettings>(); public static WaitForSeconds Wait01 = new WaitForSeconds(0.1f); public static WaitForSeconds Wait05 = new WaitForSeconds(0.5f); public static WaitForSeconds Wait1 = new WaitForSeconds(1f); public static WaitForSeconds Wait2 = new WaitForSeconds(2f); public static WaitForSeconds Wait5 = new WaitForSeconds(5f); public static WaitForSeconds Wait30 = new WaitForSeconds(30f); public static NACops Instance { get; private set; } public override void OnInitializeMelon() { ((MelonBase)this).OnInitializeMelon(); Instance = this; MelonLogger.Msg("NACops Mod Loaded"); } public override void OnSceneWasInitialized(int buildIndex, string sceneName) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if (buildIndex == 1 && (Object)(object)Singleton<LoadManager>.Instance != (Object)null && !registered && !firstTimeLoad) { firstTimeLoad = true; Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(OnLoadCompleteCb)); } if (buildIndex != 1 && registered) { ExitPreTask(); } } public override void OnUpdate() { } private void OnLoadCompleteCb() { if (!registered) { registered = true; currentConfig = ConfigLoader.LoadModConfig(); officerConfig = ConfigLoader.LoadOfficerConfig(); networkManager = Object.FindObjectOfType<NetworkManager>(true); BaseUtility.SetPoliceNPC(); coros.Add(MelonCoroutines.Start(Setup())); } } [IteratorStateMachine(typeof(<Setup>d__28))] public static IEnumerator Setup() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Setup>d__28(0); } [IteratorStateMachine(typeof(<OfficersInit>d__29))] public static IEnumerator OfficersInit() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OfficersInit>d__29(0); } [IteratorStateMachine(typeof(<StationInit>d__30))] public static IEnumerator StationInit() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <StationInit>d__30(0); } [IteratorStateMachine(typeof(<RunCoros>d__31))] public static IEnumerator RunCoros() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RunCoros>d__31(0); } private static void ExitPreTask() { registered = false; foreach (object coro in coros) { if (coro != null) { MelonCoroutines.Stop(coro); } } allActiveOfficers.Clear(); coros.Clear(); currentSummoned.Clear(); currentDrugApprehender.Clear(); Player_ConsumeProduct_Patch.evaluating = false; OfficerOverrides.generatedOfficerPool.Clear(); generatedLawSettings.Clear(); FootPatrolGenerator.generatedPatrolInstances.Clear(); FootPatrolGenerator.serPatrols = null; SentryGenerator.generatedSentryInstances.Clear(); SentryGenerator.serSentries = null; } } [HarmonyPatch(typeof(BodySearchScreen), "Open")] public static class BodySearch_Open_Patch { public static bool Prefix(BodySearchScreen __instance, NPC _searcher, ref float searchTime) { if (NACops.officerConfig.OverrideBodySearch) { searchTime = Random.Range(8f, 20f); } return true; } } [HarmonyPatch(typeof(BodySearchScreen), "Update")] public static class BodySearch_Update_Patch { private static float randomSpeedTarget; private static float timeUntilNextRandomChange; private static bool isBoostingRandomly; public static void Postfix(BodySearchScreen __instance) { if (!__instance.IsOpen || !NACops.officerConfig.OverrideBodySearch) { return; } if (!isBoostingRandomly && Random.Range(0f, 1f) > 0.98f) { isBoostingRandomly = true; timeUntilNextRandomChange = Random.Range(0.8f, 1.5f); randomSpeedTarget = Random.Range(3.5f, 4.5f); } if (isBoostingRandomly) { timeUntilNextRandomChange -= Time.deltaTime; if (timeUntilNextRandomChange <= 0f) { isBoostingRandomly = false; } __instance.speedBoost = Mathf.MoveTowards(__instance.speedBoost, randomSpeedTarget, Time.deltaTime * 6f); } } } public static class OfficerOverrides { [CompilerGenerated] private sealed class <ExtendOfficerPool>d__1 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ExtendOfficerPool>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00d7: 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) switch (<>1__state) { default: return false; case 0: { <>1__state = -1; PoliceStation val = PoliceStation.PoliceStations.FirstOrDefault(); NetworkManager val2 = Object.FindObjectOfType<NetworkManager>(true); for (int i = 0; i < val.OfficerPool.Count; i++) { generatedOfficerPool.Add(val.OfficerPool[i]); } for (int j = 0; j < NACops.officerConfig.ModAddedOfficersCount; j++) { NetworkObject val3 = Object.Instantiate<NetworkObject>(NACops.policeBase); NPC component = ((Component)val3).gameObject.GetComponent<NPC>(); component.ID = $"NACops_Officer_{j}"; component.FirstName = "Cop"; component.LastName = ""; ((Component)component).transform.parent = NetworkSingleton<NPCManager>.Instance.NPCContainer; NPCManager.NPCRegistry.Add(component); val2.ServerManager.Spawn(val3, (NetworkConnection)null, default(Scene)); ((Component)val3).gameObject.SetActive(true); ((Object)val3).name = $"NACops_Officer_{j}"; PoliceOfficer component2 = ((Component)val3).gameObject.GetComponent<PoliceOfficer>(); generatedOfficerPool.Add(component2); ((NPCEnterableBuilding)val).NPCEnteredBuilding((NPC)(object)component2); } val.OfficerPool = generatedOfficerPool; <>2__current = null; <>1__state = 1; return true; } case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SetOfficers>d__2 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private HashSet<PoliceOfficer>.Enumerator <>7__wrap1; private PoliceOfficer <officer>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SetOfficers>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = default(HashSet<PoliceOfficer>.Enumerator); <officer>5__3 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = NACops.allActiveOfficers.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; <officer>5__3.Leniency = 0.1f; <officer>5__3.Suspicion = 1f; if (NACops.officerConfig.OverrideBodySearch) { <officer>5__3.BodySearchDuration = 20f; <officer>5__3.BodySearchChance = 1f; } if (NACops.officerConfig.OverrideMovement) { ((NPC)<officer>5__3).Movement.RunSpeed = NACops.officerConfig.MovementRunSpeed; ((NPC)<officer>5__3).Movement.WalkSpeed = NACops.officerConfig.MovementWalkSpeed; } if (NACops.officerConfig.OverrideCombatBeh) { ((NPC)<officer>5__3).Behaviour.CombatBehaviour.GiveUpRange = NACops.officerConfig.CombatGiveUpRange; ((NPC)<officer>5__3).Behaviour.CombatBehaviour.GiveUpTime = NACops.officerConfig.CombatGiveUpTime; ((NPC)<officer>5__3).Behaviour.CombatBehaviour.DefaultSearchTime = NACops.officerConfig.CombatSearchTime; ((NPC)<officer>5__3).Behaviour.CombatBehaviour.DefaultMovementSpeed = NACops.officerConfig.CombatMoveSpeed; ((NPC)<officer>5__3).Behaviour.CombatBehaviour.GiveUpAfterSuccessfulHits = NACops.officerConfig.CombatEndAfterHits; } if (NACops.officerConfig.OverrideMaxHealth) { ((NPC)<officer>5__3).Health.MaxHealth = NACops.officerConfig.OfficerMaxHealth; ((NPC)<officer>5__3).Health.Health = NACops.officerConfig.OfficerMaxHealth; if (((NPC)<officer>5__3).Health.IsDead || ((NPC)<officer>5__3).Health.IsKnockedOut) { ((NPC)<officer>5__3).Health.Revive(); } } if (NACops.officerConfig.OverrideWeapon) { AvatarEquippable gunPrefab = <officer>5__3.GunPrefab; _ = <officer>5__3.PursuitBehaviour.Weapon_Gun; if ((Object)(object)gunPrefab != (Object)null) { AvatarRangedWeapon val = (AvatarRangedWeapon)(object)((gunPrefab is AvatarRangedWeapon) ? gunPrefab : null); if (val != null) { val.CanShootWhileMoving = true; val.MagazineSize = NACops.officerConfig.WeaponMagSize; val.MaxFireRate = NACops.officerConfig.WeaponFireRate; ((AvatarWeapon)val).MaxUseRange = NACops.officerConfig.WeaponMaxRange; val.ReloadTime = NACops.officerConfig.WeaponReloadTime; val.RaiseTime = NACops.officerConfig.WeaponRaiseTime; val.HitChance_MaxRange = NACops.officerConfig.WeaponHitChanceMax; val.HitChance_MinRange = NACops.officerConfig.WeaponHitChanceMin; if ((Object)(object)((NPC)<officer>5__3).Behaviour.CombatBehaviour.DefaultWeapon == (Object)null) { ((NPC)<officer>5__3).Behaviour.CombatBehaviour.DefaultWeapon = (AvatarWeapon)(object)val; } } } if ((Object)(object)gunPrefab != (Object)null) { AvatarWeapon val2 = (AvatarWeapon)(object)((gunPrefab is AvatarWeapon) ? gunPrefab : null); if (val2 != null) { val2.CooldownDuration = NACops.officerConfig.WeaponFireRate; } } } <officer>5__3 = null; break; } if (<>7__wrap1.MoveNext()) { <officer>5__3 = <>7__wrap1.Current; <>2__current = NACops.Wait01; <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = default(HashSet<PoliceOfficer>.Enumerator); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static List<PoliceOfficer> generatedOfficerPool = new List<PoliceOfficer>(); [IteratorStateMachine(typeof(<ExtendOfficerPool>d__1))] public static IEnumerator ExtendOfficerPool() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ExtendOfficerPool>d__1(0); } [IteratorStateMachine(typeof(<SetOfficers>d__2))] public static IEnumerator SetOfficers() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SetOfficers>d__2(0); } } public static class PrivateInvestigator { [CompilerGenerated] private sealed class <PIAvatar>d__5 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public PoliceOfficer offc; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <PIAvatar>d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_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_00ba: 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_00cc: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //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_0114: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: 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_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: { <>1__state = -1; List<LayerSetting> bodyLayerSettings = ((NPC)offc).Avatar.CurrentSettings.BodyLayerSettings; List<LayerSetting> list = new List<LayerSetting>(); foreach (LayerSetting item in bodyLayerSettings) { list.Add(new LayerSetting { layerPath = item.layerPath, layerTint = item.layerTint }); } List<AccessorySetting> accessorySettings = ((NPC)offc).Avatar.CurrentSettings.AccessorySettings; List<AccessorySetting> list2 = new List<AccessorySetting>(); foreach (AccessorySetting item2 in accessorySettings) { list2.Add(new AccessorySetting { path = item2.path, color = item2.color }); } for (int i = 0; i < list.Count; i++) { LayerSetting value = list[i]; value.layerPath = ""; value.layerTint = Color.white; list[i] = value; } for (int j = 0; j < list2.Count; j++) { AccessorySetting val = list2[j]; val.path = ""; val.color = Color.white; list2[j] = val; } LayerSetting value2 = list[2]; value2.layerPath = "Avatar/Layers/Bottom/Jeans"; value2.layerTint = new Color(0.396f, 0.396f, 0.396f); list[2] = value2; LayerSetting value3 = list[3]; value3.layerPath = "Avatar/Layers/Top/RolledButtonUp"; value3.layerTint = new Color(0.326f, 0.578f, 0.896f); list[3] = value3; AccessorySetting val2 = list2[0]; val2.path = "Avatar/Accessories/Head/Cap/Cap"; val2.color = new Color(0.613f, 0.493f, 0.344f); list2[0] = val2; AccessorySetting val3 = list2[1]; val3.path = "Avatar/Accessories/Chest/Blazer/Blazer"; val3.color = new Color(0.613f, 0.493f, 0.344f); list2[1] = val3; AccessorySetting val4 = list2[2]; val4.path = "Avatar/Accessories/Feet/Sneakers/Sneakers"; val4.color = new Color(0.151f, 0.151f, 0.151f); list2[2] = val4; ((NPC)offc).Avatar.CurrentSettings.BodyLayerSettings = list; ((NPC)offc).Avatar.CurrentSettings.AccessorySettings = list2; ((NPC)offc).Avatar.ApplyBodyLayerSettings(((NPC)offc).Avatar.CurrentSettings, -1); ((NPC)offc).Avatar.ApplyAccessorySettings(((NPC)offc).Avatar.CurrentSettings); if (((NPC)offc).Avatar.onSettingsLoaded != null) { ((NPC)offc).Avatar.onSettingsLoaded.Invoke(); } <>2__current = null; <>1__state = 1; return true; } case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <RunInvestigator>d__4 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private float <maxTime>5__2; private Player <randomPlayer>5__3; private NetworkObject <copNet>5__4; private PoliceOfficer <offc>5__5; private Vector3 <warpInit>5__6; private int <maxWarpAttempts>5__7; private float <elapsed>5__8; private int <investigationDelta>5__9; private int <proximityDelta>5__10; private int <sightedAmount>5__11; private float <maxWarpCd>5__12; private float <lastWarp>5__13; private int <i>5__14; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RunInvestigator>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <randomPlayer>5__3 = null; <copNet>5__4 = null; <offc>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0388: 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_0392: 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_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Unknown result type (might be due to invalid IL or missing references) //IL_06ea: Unknown result type (might be due to invalid IL or missing references) //IL_0844: Unknown result type (might be due to invalid IL or missing references) //IL_089c: Unknown result type (might be due to invalid IL or missing references) //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_07c1: Unknown result type (might be due to invalid IL or missing references) //IL_07c6: Unknown result type (might be due to invalid IL or missing references) //IL_07cb: Unknown result type (might be due to invalid IL or missing references) //IL_07d8: Unknown result type (might be due to invalid IL or missing references) //IL_07e2: Unknown result type (might be due to invalid IL or missing references) //IL_07e4: Unknown result type (might be due to invalid IL or missing references) //IL_07f3: Unknown result type (might be due to invalid IL or missing references) //IL_0800: Unknown result type (might be due to invalid IL or missing references) //IL_0821: Unknown result type (might be due to invalid IL or missing references) Vector3 val3 = default(Vector3); switch (<>1__state) { def