Decompiled source of Cartel Enforcer MONO v1.8.3

CartelEnforcer.dll

Decompiled 2 days ago
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.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using CartelEnforcer;
using FishNet;
using FishNet.Connection;
using FishNet.Managing;
using FishNet.Managing.Object;
using FishNet.Object;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using ScheduleOne;
using ScheduleOne.Audio;
using ScheduleOne.AvatarFramework;
using ScheduleOne.AvatarFramework.Animation;
using ScheduleOne.AvatarFramework.Equipping;
using ScheduleOne.Cartel;
using ScheduleOne.Combat;
using ScheduleOne.DevUtilities;
using ScheduleOne.Dialogue;
using ScheduleOne.Doors;
using ScheduleOne.Economy;
using ScheduleOne.EntityFramework;
using ScheduleOne.GameTime;
using ScheduleOne.Graffiti;
using ScheduleOne.Interaction;
using ScheduleOne.ItemFramework;
using ScheduleOne.Law;
using ScheduleOne.Levelling;
using ScheduleOne.Lighting;
using ScheduleOne.Map;
using ScheduleOne.Messaging;
using ScheduleOne.Misc;
using ScheduleOne.Money;
using ScheduleOne.NPCs;
using ScheduleOne.NPCs.Behaviour;
using ScheduleOne.NPCs.CharacterClasses;
using ScheduleOne.NPCs.Other;
using ScheduleOne.NPCs.Relation;
using ScheduleOne.NPCs.Schedules;
using ScheduleOne.ObjectScripts;
using ScheduleOne.Packaging;
using ScheduleOne.Persistence;
using ScheduleOne.PlayerScripts;
using ScheduleOne.Police;
using ScheduleOne.Product;
using ScheduleOne.Product.Packaging;
using ScheduleOne.Property;
using ScheduleOne.Quests;
using ScheduleOne.Storage;
using ScheduleOne.UI;
using ScheduleOne.UI.Handover;
using ScheduleOne.UI.MainMenu;
using ScheduleOne.UI.Phone.ContactsApp;
using ScheduleOne.Vehicles;
using ScheduleOne.Vehicles.AI;
using ScheduleOne.VoiceOver;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(global::CartelEnforcer.CartelEnforcer), "Cartel Enforcer", "1.8.3", "XOWithSauce", null)]
[assembly: MelonColor]
[assembly: MelonOptionalDependencies(new string[] { "FishNet.Runtime" })]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: MelonPlatformDomain(/*Could not decode attribute arguments.*/)]
[assembly: VerifyLoaderVersion("0.7.0", true)]
[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 2026 Source MIT")]
[assembly: AssemblyDescription("Schedule I Cartel Enforcer Mod")]
[assembly: AssemblyFileVersion("1.8.3.0")]
[assembly: AssemblyInformationalVersion("1.8.3")]
[assembly: AssemblyProduct("Cartel Enforcer")]
[assembly: AssemblyTitle("CartelEnforcer")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/XOWithSauce/schedule-cartelenforcer")]
[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 CartelEnforcer
{
	public static class DealerActivity
	{
		[HarmonyPatch(typeof(Dealer), "DealerUnconscious")]
		public static class Dealer_DealerUnconscious_Patch
		{
			[HarmonyPrefix]
			public static bool Prefix(Dealer __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				if ((int)__instance.DealerType == 1)
				{
					foreach (Contract item in new List<Contract>(__instance.ActiveContracts))
					{
						lock (playerDealerStolenLock)
						{
							if (!playerDealerStolen.ContainsKey(((Quest)item).GUID.ToString()))
							{
								((Quest)item).Fail(true);
							}
						}
					}
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Customer), "ProcessHandover")]
		public static class Customer_ProcessHandover_Patch
		{
			[HarmonyPrefix]
			public static bool Prefix(Customer __instance, EHandoverOutcome outcome, Contract contract, List<ItemInstance> items, bool handoverByPlayer, bool giveBonuses = true)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				if (handoverByPlayer)
				{
					return true;
				}
				if ((Object)(object)contract.Dealer == (Object)null)
				{
					return true;
				}
				CheckPlayerDealerStolen(__instance, contract, outcome);
				CheckIntercept(__instance, contract, outcome, handoverByPlayer);
				return true;
			}

			public static void CheckPlayerDealerStolen(Customer __instance, Contract contract, EHandoverOutcome outcome)
			{
				//IL_005c: 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_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				if (!playerDealerStolen.ContainsKey(((Quest)contract).GUID.ToString()))
				{
					return;
				}
				playerDealerStolen.TryGetValue(((Quest)contract).GUID.ToString(), out var value);
				if (value == null)
				{
					return;
				}
				Dealer item = value.Item1;
				int item2 = value.Item2;
				float num = Vector3.Distance(__instance.NPC.CenterPoint, ((NPC)contract.Dealer).CenterPoint);
				float num2 = Vector3.Distance(__instance.NPC.CenterPoint, ((NPC)item).CenterPoint);
				if (num2 < num && num2 < 2f)
				{
					if (contract.Dealer.ActiveContracts.Count != 0 && (Object)(object)contract.Dealer.ActiveContracts[0] == (Object)(object)contract)
					{
						((Quest)contract.Dealer.ActiveContracts[0]).Fail(true);
					}
					contract.Dealer = item;
					((Quest)contract).CompletionXP = item2;
					contract.completedContractsIncremented = true;
				}
				else if (num < num2 && num2 < 2f)
				{
					if (item.ActiveContracts.Count != 0 && (Object)(object)item.ActiveContracts[0] == (Object)(object)contract)
					{
						((Quest)item.ActiveContracts[0]).Fail(true);
					}
					if (CartelEnforcer.currentConfig.stealBackCustomers && __instance.NPC.RelationData.RelationDelta > 1f)
					{
						float relationDelta = Mathf.Clamp(Mathf.Max(__instance.NPC.RelationData.RelationDelta * 0.85f, 0.2f), 0f, 5f);
						__instance.NPC.RelationData.RelationDelta = relationDelta;
					}
				}
				lock (playerDealerStolenLock)
				{
					playerDealerStolen.Remove(((Quest)contract).GUID.ToString());
				}
				consumedGUIDs.Add(((Quest)contract).GUID.ToString());
			}

			public static void CheckIntercept(Customer __instance, Contract contract, EHandoverOutcome outcome, bool handoverByPlayer)
			{
				if (!CartelEnforcer.currentConfig.interceptDeals)
				{
					return;
				}
				string key = ((Quest)contract).GUID.ToString();
				if (InterceptEvent.contractGuids.ContainsKey(key))
				{
					if (handoverByPlayer)
					{
						InterceptEvent.contractGuids[key].CompletedByPlayer = true;
					}
					else
					{
						InterceptEvent.contractGuids[key].CompletedByCartel = true;
					}
				}
			}
		}

		[HarmonyPatch(typeof(CartelDealer), "RandomizeInventory")]
		public static class CartelDealer_RandomizeInventory_Patch
		{
			[HarmonyPrefix]
			public static bool Prefix(CartelDealer __instance)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Invalid comparison between Unknown and I4
				if (CartelEnforcer.currentConfig.alliedExtensions && (int)NetworkSingleton<Cartel>.Instance.Status == 1 && ((Dealer)__instance).IsRecruited)
				{
					return false;
				}
				if (stolenInDealerInv.TryGetValue(__instance, out var value) && value != null && value.Count != 0)
				{
					List<ItemInstance> list = new List<ItemInstance>();
					for (int i = 0; i < value.Count; i++)
					{
						for (int j = 0; j < ((NPC)__instance).Inventory.ItemSlots.Count; j++)
						{
							if (((NPC)__instance).Inventory.ItemSlots[j].ItemInstance == value[i])
							{
								list.Add(value[i]);
							}
						}
					}
					if (list.Count > 0)
					{
						CartelInventory.CartelStealsItems(list);
						stolenInDealerInv[__instance].Clear();
					}
				}
				return true;
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__OnDealerDied;
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass27_0
		{
			public CartelCustomerDeal dealEvent;

			internal bool <OnCartelCustomerDeal>b__0(Customer customer)
			{
				//IL_0006: 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)
				return customer.NPC.Region == ((CartelActivity)dealEvent).Region;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass27_1
		{
			public ProductDefinition tempDef;

			internal bool <OnCartelCustomerDeal>b__2(ProductTypeAffinity x)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				return x.DrugType == tempDef.DrugType;
			}
		}

		[CompilerGenerated]
		private sealed class <DespawnDefenderGoonsSoon>d__20 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public List<CartelGoon> goons;

			private int <maxHoursWaited>5__2;

			private int <goonsDead>5__3;

			private int <i>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DespawnDefenderGoonsSoon>d__20(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;
					<maxHoursWaited>5__2 = 2;
					<goonsDead>5__3 = 0;
					<i>5__4 = 0;
					goto IL_00fd;
				case 1:
					<>1__state = -1;
					foreach (CartelGoon goon in goons)
					{
						if ((((NPC)goon).Health.IsDead || ((NPC)goon).Health.IsKnockedOut) && goon.IsGoonSpawned)
						{
							<goonsDead>5__3++;
							((NPC)goon).Health.Revive();
							goon.Despawn();
							((Behaviour)((NPC)goon).Behaviour.CombatBehaviour).Disable_Networked((NetworkConnection)null);
						}
					}
					if (<goonsDead>5__3 != goons.Count)
					{
						<i>5__4++;
						goto IL_00fd;
					}
					goto IL_010e;
				case 2:
					{
						<>1__state = -1;
						return false;
					}
					IL_010e:
					foreach (CartelGoon goon2 in goons)
					{
						if (goon2.IsGoonSpawned)
						{
							goon2.Despawn();
							((Behaviour)((NPC)goon2).Behaviour.CombatBehaviour).Disable_Networked((NetworkConnection)null);
						}
					}
					<>2__current = null;
					<>1__state = 2;
					return true;
					IL_00fd:
					if (<i>5__4 < <maxHoursWaited>5__2)
					{
						<>2__current = CartelEnforcer.Wait60;
						<>1__state = 1;
						return true;
					}
					goto IL_010e;
				}
			}

			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 <EvaluateDealerState>d__17 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			private bool <isHostile>5__2;

			private bool <safetyThresholdMet>5__3;

			private CartelDealer[] <>7__wrap3;

			private int <>7__wrap4;

			private CartelDealer <d>5__6;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <EvaluateDealerState>d__17(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>7__wrap3 = null;
				<d>5__6 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0132: Unknown result type (might be due to invalid IL or missing references)
				//IL_0138: Invalid comparison between Unknown and I4
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = CartelEnforcer.Wait5;
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					if (allCartelDealers == null)
					{
						allCartelDealers = Object.FindObjectsOfType<CartelDealer>(true);
					}
					Dealer[] array = Object.FindObjectsOfType<Dealer>(true);
					foreach (Dealer val in array)
					{
						if ((int)val.DealerType == 0)
						{
							allDealers.Add(val);
						}
					}
					currentStayInsideStart = defaultStayInsideStart;
					currentStayInsideEnd = defaultStayInsideEnd;
					currentStayInsideDur = defaultStayInsideDur;
					SetupDealers();
					TimeManager instance = NetworkSingleton<TimeManager>.Instance;
					instance.onDayPass = (Action)Delegate.Combine(instance.onDayPass, new Action(OnDayPassChange));
					goto IL_052b;
				}
				case 2:
					<>1__state = -1;
					if (!CartelEnforcer.registered)
					{
						return false;
					}
					if (NetworkSingleton<TimeManager>.Instance.CurrentTime >= 1620 || NetworkSingleton<TimeManager>.Instance.CurrentTime <= 359)
					{
						<isHostile>5__2 = true;
						if ((int)NetworkSingleton<Cartel>.Instance.Status != 2)
						{
							<isHostile>5__2 = false;
						}
						if (currentDealerActivity != previousDealerActivity)
						{
							int num = 0;
							int num2 = 0;
							int num3 = 0;
							if (currentDealerActivity > 0f)
							{
								int minSumFrom24HourTime = TimeManager.GetMinSumFrom24HourTime(currentStayInsideStart);
								int minSumFrom24HourTime2 = TimeManager.GetMinSumFrom24HourTime(359);
								int num4 = Mathf.RoundToInt(Mathf.Lerp((float)minSumFrom24HourTime, (float)minSumFrom24HourTime2, currentDealerActivity));
								num = TimeManager.Get24HourTimeFromMinSum(num4);
								if (num == 400)
								{
									num = 359;
								}
								int minSumFrom24HourTime3 = TimeManager.GetMinSumFrom24HourTime(currentStayInsideEnd);
								int minSumFrom24HourTime4 = TimeManager.GetMinSumFrom24HourTime(1620);
								int num5 = Mathf.RoundToInt(Mathf.Lerp((float)minSumFrom24HourTime3, (float)minSumFrom24HourTime4, currentDealerActivity));
								num2 = TimeManager.Get24HourTimeFromMinSum(num5);
								num3 = num5 - num4;
							}
							else if (currentDealerActivity < 0f)
							{
								float num6 = 0f - currentDealerActivity;
								int minSumFrom24HourTime5 = TimeManager.GetMinSumFrom24HourTime(currentStayInsideStart);
								int minSumFrom24HourTime6 = TimeManager.GetMinSumFrom24HourTime(2);
								int num7 = Mathf.RoundToInt(Mathf.Lerp((float)minSumFrom24HourTime5, (float)minSumFrom24HourTime6, num6));
								num = TimeManager.Get24HourTimeFromMinSum(num7);
								int minSumFrom24HourTime7 = TimeManager.GetMinSumFrom24HourTime(currentStayInsideEnd);
								int minSumFrom24HourTime8 = TimeManager.GetMinSumFrom24HourTime(2359);
								int num8 = Mathf.RoundToInt(Mathf.Lerp((float)minSumFrom24HourTime7, (float)minSumFrom24HourTime8, num6));
								num2 = TimeManager.Get24HourTimeFromMinSum(num8);
								num3 = num8 - num7;
							}
							else
							{
								num = defaultStayInsideStart;
								num2 = defaultStayInsideEnd;
								num3 = defaultStayInsideDur;
							}
							currentStayInsideStart = num;
							currentStayInsideEnd = num2;
							currentStayInsideDur = num3;
							<>7__wrap3 = allCartelDealers;
							<>7__wrap4 = 0;
							goto IL_02fe;
						}
						goto IL_0315;
					}
					goto IL_052b;
				case 3:
					<>1__state = -1;
					if (!CartelEnforcer.registered)
					{
						return false;
					}
					ApplyNewEventState(<d>5__6, currentStayInsideStart, currentStayInsideEnd, currentStayInsideDur);
					<d>5__6 = null;
					<>7__wrap4++;
					goto IL_02fe;
				case 4:
					<>1__state = -1;
					if (!CartelEnforcer.registered)
					{
						return false;
					}
					ApplyNewEventState(<d>5__6, 600, 559, 1439);
					<d>5__6.SetIsAcceptingDeals(false);
					<d>5__6 = null;
					<>7__wrap4++;
					goto IL_03d6;
				case 5:
					<>1__state = -1;
					if (!CartelEnforcer.registered)
					{
						return false;
					}
					if (!((NPC)<d>5__6).isInBuilding && !((NPC)<d>5__6).Movement.HasDestination && !((NPC)<d>5__6).Health.IsDead && !((NPC)<d>5__6).Health.IsKnockedOut)
					{
						WalkToInterestPoint(<d>5__6);
					}
					<d>5__6 = null;
					<>7__wrap4++;
					goto IL_04b7;
				case 6:
					<>1__state = -1;
					if (!CartelEnforcer.registered)
					{
						return false;
					}
					goto IL_052b;
				case 7:
					{
						<>1__state = -1;
						return false;
					}
					IL_0315:
					previousDealerActivity = currentDealerActivity;
					<safetyThresholdMet>5__3 = false;
					if (dealerConfig.SafetyEnabled && currentDealerActivity <= dealerConfig.SafetyThreshold)
					{
						<safetyThresholdMet>5__3 = true;
						<>7__wrap3 = allCartelDealers;
						<>7__wrap4 = 0;
						goto IL_03d6;
					}
					goto IL_03f0;
					IL_03d6:
					if (<>7__wrap4 < <>7__wrap3.Length)
					{
						<d>5__6 = <>7__wrap3[<>7__wrap4];
						<>2__current = CartelEnforcer.Wait05;
						<>1__state = 4;
						return true;
					}
					<>7__wrap3 = null;
					goto IL_03f0;
					IL_052b:
					if (CartelEnforcer.registered)
					{
						<>2__current = CartelEnforcer.Wait60;
						<>1__state = 2;
						return true;
					}
					<>2__current = null;
					<>1__state = 7;
					return true;
					IL_02fe:
					if (<>7__wrap4 < <>7__wrap3.Length)
					{
						<d>5__6 = <>7__wrap3[<>7__wrap4];
						<>2__current = CartelEnforcer.Wait05;
						<>1__state = 3;
						return true;
					}
					<>7__wrap3 = null;
					goto IL_0315;
					IL_04b7:
					if (<>7__wrap4 < <>7__wrap3.Length)
					{
						<d>5__6 = <>7__wrap3[<>7__wrap4];
						<>2__current = CartelEnforcer.Wait2;
						<>1__state = 5;
						return true;
					}
					<>7__wrap3 = null;
					<>2__current = CartelEnforcer.Wait60;
					<>1__state = 6;
					return true;
					IL_03f0:
					if (!<safetyThresholdMet>5__3)
					{
						if (!<isHostile>5__2)
						{
							<>7__wrap3 = allCartelDealers;
							<>7__wrap4 = 0;
							goto IL_04b7;
						}
						if (NetworkSingleton<TimeManager>.Instance.CurrentTime >= currentStayInsideEnd || NetworkSingleton<TimeManager>.Instance.CurrentTime <= currentStayInsideStart)
						{
							CartelEnforcer.coros.Add(MelonCoroutines.Start(StartActiveSignal()));
						}
					}
					goto IL_052b;
				}
			}

			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 <OnCartelCustomerDeal>d__27 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public CartelCustomerDeal dealEvent;

			public bool started;

			private <>c__DisplayClass27_0 <>8__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnCartelCustomerDeal>d__27(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>8__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_016e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_0205: 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)
				//IL_0213: Unknown result type (might be due to invalid IL or missing references)
				//IL_0215: Unknown result type (might be due to invalid IL or missing references)
				//IL_0398: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_03be: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0310: Unknown result type (might be due to invalid IL or missing references)
				//IL_0312: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>8__1 = new <>c__DisplayClass27_0();
					<>8__1.dealEvent = dealEvent;
					<>2__current = CartelEnforcer.Wait2;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (started)
					{
						List<Customer> list = Customer.LockedCustomers.FindAll((Customer customer) => customer.NPC.Region == ((CartelActivity)<>8__1.dealEvent).Region);
						if (list.Count == 0)
						{
							((CartelActivity)<>8__1.dealEvent).Deactivate();
							return false;
						}
						int num = Random.Range(0, list.Count);
						Customer val = null;
						for (int i = 0; i < list.Count; i++)
						{
							val = list[num];
							bool flag = true;
							if ((Object)(object)val.CurrentContract != (Object)null)
							{
								flag = false;
							}
							if (!val.NPC.IsConscious)
							{
								flag = false;
							}
							int orderTime = val.customerData.OrderTime;
							int num2 = TimeManager.AddMinutesTo24HourTime(orderTime, 240);
							if (!NetworkSingleton<TimeManager>.Instance.IsCurrentTimeWithinRange(orderTime, num2))
							{
								flag = false;
							}
							if (!flag)
							{
								if (i == list.Count - 1)
								{
									((CartelActivity)<>8__1.dealEvent).Deactivate();
									val = null;
									return false;
								}
								num = (num + 1) % list.Count;
							}
						}
						if ((Object)(object)val == (Object)null)
						{
							((CartelActivity)<>8__1.dealEvent).Deactivate();
							return false;
						}
						EQuality correspondingQuality = StandardsMethod.GetCorrespondingQuality(val.customerData.Standards);
						List<ProductTypeAffinity> source = new List<ProductTypeAffinity>(val.CustomerData.DefaultAffinityData.ProductAffinities);
						source = source.OrderByDescending((ProductTypeAffinity x) => x.Affinity).ToList();
						bool flag2 = false;
						foreach (ItemSlot allSlot in ((Dealer)<>8__1.dealEvent.dealer).GetAllSlots())
						{
							if (allSlot.ItemInstance == null)
							{
								continue;
							}
							ItemInstance itemInstance = allSlot.ItemInstance;
							ProductItemInstance val2 = (ProductItemInstance)(object)((itemInstance is ProductItemInstance) ? itemInstance : null);
							if (val2 != null)
							{
								if (((QualityItemInstance)val2).Quality < correspondingQuality)
								{
									flag2 = true;
									((QualityItemInstance)val2).Quality = correspondingQuality;
								}
								else
								{
									flag2 = true;
								}
								break;
							}
						}
						if (!flag2)
						{
							List<ProductDefinition> list2 = <>8__1.dealEvent.dealer.RandomProducts.ToList();
							ProductDefinition val3 = null;
							float num3 = 0f;
							using (List<ProductDefinition>.Enumerator enumerator2 = list2.GetEnumerator())
							{
								while (enumerator2.MoveNext())
								{
									<>c__DisplayClass27_1 CS$<>8__locals0 = new <>c__DisplayClass27_1
									{
										tempDef = enumerator2.Current
									};
									ProductTypeAffinity val4 = source.First((ProductTypeAffinity x) => x.DrugType == CS$<>8__locals0.tempDef.DrugType);
									if (val4 != null && val4.Affinity > num3)
									{
										val3 = CS$<>8__locals0.tempDef;
										num3 = val4.Affinity;
									}
								}
							}
							if ((Object)(object)val3 == (Object)null)
							{
								val3 = <>8__1.dealEvent.dealer.RandomProducts[0];
							}
							ItemInstance defaultInstance = ((ItemDefinition)val3).GetDefaultInstance(10);
							QualityItemInstance val5 = (QualityItemInstance)(object)((defaultInstance is QualityItemInstance) ? defaultInstance : null);
							if (val5 != null)
							{
								val5.Quality = correspondingQuality;
							}
							if (((NPC)<>8__1.dealEvent.dealer).Inventory.CanItemFit(defaultInstance))
							{
								((NPC)<>8__1.dealEvent.dealer).Inventory.InsertItem(defaultInstance, true);
							}
						}
						ContractInfo val6 = val.TryGenerateContract((Dealer)(object)<>8__1.dealEvent.dealer);
						if (val6 != null)
						{
							int offeredDeals = val.OfferedDeals;
							val.OfferedDeals = offeredDeals + 1;
							val.TimeSinceLastDealOffered = 0;
							val.OfferedContractInfo = val6;
							val.OfferedContractTime = NetworkSingleton<TimeManager>.Instance.GetDateTime();
							val.HasChanged = true;
							EDealWindow dealWindow = ((Dealer)<>8__1.dealEvent.dealer).GetDealWindow();
							Contract val7 = val.ContractAccepted(dealWindow, false, (Dealer)(object)<>8__1.dealEvent.dealer);
							((Quest)val7).CompletionXP = 0;
							val7.completedContractsIncremented = false;
							((Dealer)<>8__1.dealEvent.dealer).AddContract(val7);
						}
						else
						{
							((CartelActivity)<>8__1.dealEvent).Deactivate();
						}
					}
					<>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 <StartActiveSignal>d__21 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			private Dictionary<EMapRegion, Contract> <validContracts>5__2;

			private Contract <contract>5__3;

			private List<Customer> <cList>5__4;

			private List<Customer> <validCustomers>5__5;

			private List<Dealer>.Enumerator <>7__wrap5;

			private Dealer <playerDealer>5__7;

			private CartelDealer[] <>7__wrap7;

			private int <>7__wrap8;

			private CartelDealer <d>5__10;

			private bool <actionTaken>5__11;

			private Customer <c>5__12;

			private ContractInfo <contractInfo>5__13;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <StartActiveSignal>d__21(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();
					}
				}
				<validContracts>5__2 = null;
				<contract>5__3 = null;
				<cList>5__4 = null;
				<validCustomers>5__5 = null;
				<>7__wrap5 = default(List<Dealer>.Enumerator);
				<playerDealer>5__7 = null;
				<>7__wrap7 = null;
				<d>5__10 = null;
				<c>5__12 = null;
				<contractInfo>5__13 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0721: Unknown result type (might be due to invalid IL or missing references)
				//IL_0726: Unknown result type (might be due to invalid IL or missing references)
				//IL_072f: Unknown result type (might be due to invalid IL or missing references)
				//IL_015c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: 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_016e: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0409: Unknown result type (might be due to invalid IL or missing references)
				//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_05de: Expected O, but got Unknown
				bool result;
				try
				{
					switch (<>1__state)
					{
					default:
						result = false;
						goto end_IL_0000;
					case 0:
						<>1__state = -1;
						<validContracts>5__2 = new Dictionary<EMapRegion, Contract>();
						<contract>5__3 = null;
						<>7__wrap5 = allDealers.GetEnumerator();
						<>1__state = -3;
						goto IL_0191;
					case 1:
						<>1__state = -3;
						if (CartelEnforcer.registered)
						{
							if (<playerDealer>5__7.ActiveContracts.Count != 0)
							{
								<contract>5__3 = <playerDealer>5__7.ActiveContracts[Random.Range(0, <playerDealer>5__7.ActiveContracts.Count)];
								string text = ((Quest)<contract>5__3).GUID.ToString();
								if (!InterceptEvent.contractGuids.Keys.Contains(text) && !<validContracts>5__2.ContainsValue(<contract>5__3) && !consumedGUIDs.Contains(text) && !playerDealerStolen.ContainsKey(text) && ((Quest)<contract>5__3).GetMinsUntilExpiry() > 120)
								{
									EMapRegion regionFromPosition = Singleton<Map>.Instance.GetRegionFromPosition(<contract>5__3.DeliveryLocation.CustomerStandPoint.position);
									if (!<validContracts>5__2.ContainsKey(regionFromPosition))
									{
										<validContracts>5__2.Add(regionFromPosition, <contract>5__3);
									}
								}
								<playerDealer>5__7 = null;
							}
							goto IL_0191;
						}
						result = false;
						<>m__Finally1();
						goto end_IL_0000;
					case 2:
						<>1__state = -1;
						if (CartelEnforcer.registered)
						{
							Customer val = <cList>5__4[Random.Range(0, <cList>5__4.Count)];
							if ((Object)(object)val.CurrentContract == (Object)null && (Object)(object)val.AssignedDealer == (Object)null && val.offeredContractInfo != null)
							{
								<validCustomers>5__5.Add(val);
							}
							<cList>5__4.Remove(val);
							if (<cList>5__4.Count > 0)
							{
								goto IL_0206;
							}
							<>7__wrap7 = allCartelDealers;
							<>7__wrap8 = 0;
							goto IL_0854;
						}
						result = false;
						goto end_IL_0000;
					case 3:
						<>1__state = -1;
						if (!CartelEnforcer.registered)
						{
							result = false;
						}
						else
						{
							if (NetworkSingleton<TimeManager>.Instance.CurrentTime < currentStayInsideEnd && NetworkSingleton<TimeManager>.Instance.CurrentTime > currentStayInsideStart)
							{
								break;
							}
							if (((Object)(object)InterceptEvent.interceptor != (Object)null && (Object)(object)InterceptEvent.interceptor == (Object)(object)<d>5__10) || ((NPC)<d>5__10).Health.IsDead || ((NPC)<d>5__10).Health.IsKnockedOut || ((Dealer)<d>5__10).ActiveContracts == null)
							{
								goto IL_0846;
							}
							if (((Dealer)<d>5__10).ActiveContracts.Count != 0)
							{
								if (!((Behaviour)((Dealer)<d>5__10)._attendDealBehaviour).Active)
								{
									((Dealer)<d>5__10).CheckAttendStart();
								}
								goto IL_0846;
							}
							<actionTaken>5__11 = false;
							if (<validContracts>5__2.Count > 0 && Random.Range(0.01f, 1f) < dealerConfig.StealDealerContractChance && dealerConfig.StealDealerContractChance != 0f)
							{
								if (<validContracts>5__2.ContainsKey(((NPC)<d>5__10).Region))
								{
									<contract>5__3 = <validContracts>5__2[((NPC)<d>5__10).Region];
								}
								if ((Object)(object)<contract>5__3 != (Object)null && !playerDealerStolen.ContainsKey(((Quest)<contract>5__3).GUID.ToString()) && !consumedGUIDs.Contains(((Quest)<contract>5__3).GUID.ToString()))
								{
									int completionXP = ((Quest)<contract>5__3).CompletionXP;
									((Quest)<contract>5__3).CompletionXP = 0;
									<contract>5__3.completedContractsIncremented = false;
									Dealer dealer = <contract>5__3.Dealer;
									lock (playerDealerStolenLock)
									{
										playerDealerStolen.Add(((Quest)<contract>5__3).GUID.ToString(), new Tuple<Dealer, int>(dealer, completionXP));
									}
									((Dealer)<d>5__10).AddContract(<contract>5__3);
									if (!((Behaviour)((Dealer)<d>5__10)._attendDealBehaviour).Active)
									{
										((Dealer)<d>5__10).CheckAttendStart();
									}
									<actionTaken>5__11 = true;
								}
								goto IL_07bd;
							}
							if (<validCustomers>5__5.Count <= 0 || !(Random.Range(0.01f, 1f) < dealerConfig.StealPlayerPendingChance) || dealerConfig.StealPlayerPendingChance == 0f)
							{
								goto IL_07bd;
							}
							<c>5__12 = <validCustomers>5__5[Random.Range(0, <validCustomers>5__5.Count)];
							if (!((Object)(object)<c>5__12.CurrentContract == (Object)null) || !((Object)(object)<c>5__12.AssignedDealer == (Object)null) || <c>5__12.offeredContractInfo == null)
							{
								goto IL_07a4;
							}
							<contractInfo>5__13 = new ContractInfo();
							<contractInfo>5__13.DeliveryLocation = <c>5__12.offeredContractInfo.DeliveryLocation;
							<contractInfo>5__13.DeliveryLocationGUID = <c>5__12.offeredContractInfo.DeliveryLocationGUID;
							<contractInfo>5__13.Payment = <c>5__12.offeredContractInfo.Payment;
							<contractInfo>5__13.Expires = <c>5__12.offeredContractInfo.Expires;
							<contractInfo>5__13.DeliveryWindow = <c>5__12.offeredContractInfo.DeliveryWindow;
							<contractInfo>5__13.PickupScheduleIndex = <c>5__12.offeredContractInfo.PickupScheduleIndex;
							<contractInfo>5__13.ExpiresAfter = <c>5__12.offeredContractInfo.ExpiresAfter;
							<contractInfo>5__13.IsCounterOffer = <c>5__12.offeredContractInfo.IsCounterOffer;
							<contractInfo>5__13.Products = <c>5__12.offeredContractInfo.Products;
							<c>5__12.ExpireOffer();
							<>2__current = CartelEnforcer.Wait01;
							<>1__state = 4;
							result = true;
						}
						goto end_IL_0000;
					case 4:
						{
							<>1__state = -1;
							if (CartelEnforcer.registered)
							{
								<c>5__12.offeredContractInfo = <contractInfo>5__13;
								EDealWindow dealWindow = ((Dealer)<d>5__10).GetDealWindow();
								<contract>5__3 = <c>5__12.ContractAccepted(dealWindow, false, (Dealer)(object)<d>5__10);
								if ((Object)(object)<contract>5__3 != (Object)null)
								{
									((Quest)<contract>5__3).CompletionXP = 0;
									<contract>5__3.completedContractsIncremented = false;
									((Dealer)<d>5__10).AddContract(<contract>5__3);
									if (!((Behaviour)((Dealer)<d>5__10)._attendDealBehaviour).Active)
									{
										((Dealer)<d>5__10).CheckAttendStart();
									}
									<actionTaken>5__11 = true;
								}
								<contractInfo>5__13 = null;
								goto IL_07a4;
							}
							result = false;
							goto end_IL_0000;
						}
						IL_0846:
						<>7__wrap8++;
						goto IL_0854;
						IL_07bd:
						if (!<actionTaken>5__11)
						{
							if (!((NPC)<d>5__10).isInBuilding && !((NPC)<d>5__10).Movement.HasDestination)
							{
								WalkToInterestPoint(<d>5__10);
							}
						}
						else if ((Object)(object)<contract>5__3 != (Object)null && (Object)(object)<d>5__10 != (Object)null)
						{
							CartelInventory.FulfillContractItems(<contract>5__3, <d>5__10);
						}
						<d>5__10 = null;
						goto IL_0846;
						IL_0191:
						if (!<>7__wrap5.MoveNext())
						{
							<>m__Finally1();
							<>7__wrap5 = default(List<Dealer>.Enumerator);
							<cList>5__4 = new List<Customer>();
							for (int i = 0; i < Customer.UnlockedCustomers.Count; i++)
							{
								<cList>5__4.Add(Customer.UnlockedCustomers[i]);
							}
							<validCustomers>5__5 = new List<Customer>();
							goto IL_0206;
						}
						<playerDealer>5__7 = <>7__wrap5.Current;
						<>2__current = CartelEnforcer.Wait01;
						<>1__state = 1;
						result = true;
						goto end_IL_0000;
						IL_07a4:
						<validCustomers>5__5.Remove(<c>5__12);
						<c>5__12 = null;
						goto IL_07bd;
						IL_0854:
						if (<>7__wrap8 >= <>7__wrap7.Length)
						{
							break;
						}
						<d>5__10 = <>7__wrap7[<>7__wrap8];
						<contract>5__3 = null;
						<>2__current = CartelEnforcer.Wait2;
						<>1__state = 3;
						result = true;
						goto end_IL_0000;
						IL_0206:
						<>2__current = CartelEnforcer.Wait01;
						<>1__state = 2;
						result = true;
						goto end_IL_0000;
					}
					<>7__wrap7 = null;
					<cList>5__4.Clear();
					<validCustomers>5__5.Clear();
					<validContracts>5__2.Clear();
					result = false;
					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__wrap5).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WalkToInterestPoint>d__24 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public WaitForSeconds delay;

			public CartelDealer d;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WalkToInterestPoint>d__24(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 = delay;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					WalkToInterestPoint(d);
					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();
			}
		}

		private static List<Dealer> allDealers = new List<Dealer>();

		public static CartelDealer[] allCartelDealers;

		public static CartelDealerConfig dealerConfig;

		public static float currentDealerActivity = 0f;

		public static float previousDealerActivity = 0f;

		private static float maxActivity = 1f;

		private static float minActivity = -1f;

		private static int defaultStayInsideStart = 200;

		private static int defaultStayInsideEnd = 2000;

		private static int defaultStayInsideDur = 1080;

		public static int currentStayInsideStart = 0;

		public static int currentStayInsideEnd = 0;

		public static int currentStayInsideDur = 0;

		public static Dictionary<string, Tuple<Dealer, int>> playerDealerStolen = new Dictionary<string, Tuple<Dealer, int>>();

		public static readonly object playerDealerStolenLock = new object();

		public static List<string> consumedGUIDs = new List<string>();

		public static Dictionary<CartelDealer, List<ItemInstance>> stolenInDealerInv = new Dictionary<CartelDealer, List<ItemInstance>>();

		[IteratorStateMachine(typeof(<EvaluateDealerState>d__17))]
		public static IEnumerator EvaluateDealerState()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <EvaluateDealerState>d__17(0);
		}

		public static void ApplyNewEventState(CartelDealer dealer, int inStart, int inEnd, int inDur)
		{
			if ((Object)(object)InterceptEvent.interceptor != (Object)null && (Object)(object)InterceptEvent.interceptor == (Object)(object)dealer)
			{
				return;
			}
			NPCEvent_StayInBuilding val = null;
			if (((NPC)dealer).Behaviour.ScheduleManager.ActionList != null)
			{
				foreach (NPCAction action in ((NPC)dealer).Behaviour.ScheduleManager.ActionList)
				{
					NPCEvent_StayInBuilding val2 = (NPCEvent_StayInBuilding)(object)((action is NPCEvent_StayInBuilding) ? action : null);
					if (val2 != null)
					{
						val = val2;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				((NPCAction)val).StartTime = inStart;
				((NPCEvent)val).EndTime = inEnd;
				((NPCEvent)val).Duration = inDur;
			}
		}

		public static void SetupDealers()
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Expected O, but got Unknown
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Expected O, but got Unknown
			CartelDealer[] array = allCartelDealers;
			foreach (CartelDealer key in array)
			{
				if (!stolenInDealerInv.ContainsKey(key))
				{
					stolenInDealerInv.Add(key, new List<ItemInstance>());
				}
			}
			string text = "";
			Object obj = Resources.Load(dealerConfig.CartelDealerWeapon.ToLower() switch
			{
				"m1911" => "Avatar/Equippables/M1911", 
				"revolver" => "Avatar/Equippables/Revolver", 
				"knife" => "Avatar/Equippables/Knife", 
				"shotgun" => "Avatar/Equippables/PumpShotgun", 
				_ => "Avatar/Equippables/M1911", 
			});
			Object obj2 = ((obj is GameObject) ? obj : null);
			_ = obj2 == (Object)null;
			AvatarEquippable component = Object.Instantiate<GameObject>((GameObject)(object)obj2, new Vector3(0f, -5f, 0f), Quaternion.identity, (Transform)null).GetComponent<AvatarEquippable>();
			AvatarRangedWeapon val = (AvatarRangedWeapon)(object)((component is AvatarRangedWeapon) ? component : null);
			AvatarMeleeWeapon val2 = (AvatarMeleeWeapon)(object)((component is AvatarMeleeWeapon) ? component : null);
			if ((Object)(object)val != (Object)null && dealerConfig.CartelDealerLethality > 0f)
			{
				val.Damage = Mathf.Lerp(val.Damage, val.Damage * 2f, dealerConfig.CartelDealerLethality);
				val.AimTime_Max = Mathf.Lerp(val.AimTime_Max, val.AimTime_Max * 0.5f, dealerConfig.CartelDealerLethality);
				val.AimTime_Min = Mathf.Lerp(val.AimTime_Min, val.AimTime_Min * 0.5f, dealerConfig.CartelDealerLethality);
				val.HitChance_MaxRange = Mathf.Lerp(val.HitChance_MaxRange, val.HitChance_MaxRange * 2f, dealerConfig.CartelDealerLethality);
				val.HitChance_MinRange = Mathf.Lerp(val.HitChance_MinRange, val.HitChance_MinRange * 2f, dealerConfig.CartelDealerLethality);
				((AvatarWeapon)val).MaxUseRange = Mathf.Lerp(((AvatarWeapon)val).MaxUseRange, ((AvatarWeapon)val).MaxUseRange * 2f, dealerConfig.CartelDealerLethality);
				((AvatarWeapon)val).MinUseRange = Mathf.Lerp(((AvatarWeapon)val).MinUseRange, ((AvatarWeapon)val).MinUseRange * 0.5f, dealerConfig.CartelDealerLethality);
				val.MaxFireRate = Mathf.Lerp(val.MaxFireRate, val.MaxFireRate * 0.5f, dealerConfig.CartelDealerLethality);
				val.ReloadTime = Mathf.Lerp(val.ReloadTime, val.ReloadTime * 0.5f, dealerConfig.CartelDealerLethality);
			}
			else if ((Object)(object)val2 != (Object)null && dealerConfig.CartelDealerLethality > 0f)
			{
				val2.Damage = Mathf.Lerp(val2.Damage, val2.Damage * 2f, dealerConfig.CartelDealerLethality);
				((AvatarWeapon)val2).CooldownDuration = Mathf.Lerp(((AvatarWeapon)val2).CooldownDuration, ((AvatarWeapon)val2).CooldownDuration * 0.5f, dealerConfig.CartelDealerLethality);
				val2.AttackRange = Mathf.Lerp(val2.AttackRange, val2.AttackRange * 2f, dealerConfig.CartelDealerLethality);
				val2.AttackRadius = Mathf.Lerp(val2.AttackRadius, val2.AttackRadius * 2f, dealerConfig.CartelDealerLethality);
				((AvatarWeapon)val2).MaxUseRange = Mathf.Lerp(((AvatarWeapon)val2).MaxUseRange, ((AvatarWeapon)val2).MaxUseRange * 2f, dealerConfig.CartelDealerLethality);
			}
			array = allCartelDealers;
			foreach (CartelDealer dealer in array)
			{
				((NPC)dealer).Movement.WalkSpeed = dealerConfig.CartelDealerWalkSpeed;
				((NPC)dealer).Health.MaxHealth = dealerConfig.CartelDealerHP;
				((NPC)dealer).Health.Health = dealerConfig.CartelDealerHP;
				AvatarWeapon val3 = (AvatarWeapon)(object)((component is AvatarWeapon) ? component : null);
				if (val3 != null)
				{
					((NPC)dealer).Behaviour.CombatBehaviour.DefaultWeapon = val3;
					if ((Object)(object)((NPC)dealer).Avatar != (Object)null)
					{
						component.Equip(((NPC)dealer).Avatar);
					}
				}
				((NPC)dealer).OverrideAggression(1f);
				NPCEvent_StayInBuilding val4 = null;
				if (((NPC)dealer).Behaviour.ScheduleManager.ActionList != null)
				{
					foreach (NPCAction action in ((NPC)dealer).Behaviour.ScheduleManager.ActionList)
					{
						NPCEvent_StayInBuilding val5 = (NPCEvent_StayInBuilding)(object)((action is NPCEvent_StayInBuilding) ? action : null);
						if (val5 != null)
						{
							val4 = val5;
						}
					}
					if ((Object)(object)val4 != (Object)null)
					{
						((NPCAction)val4).StartTime = defaultStayInsideStart;
						((NPCEvent)val4).EndTime = defaultStayInsideEnd;
						((NPCEvent)val4).Duration = defaultStayInsideDur;
						((NPCAction)val4).onEnded = (Action)Delegate.Combine(((NPCAction)val4).onEnded, new Action(onStayInsideEnd));
					}
				}
				UnityEvent onDieOrKnockedOut = ((NPC)dealer).Health.onDieOrKnockedOut;
				object obj3 = <>O.<0>__OnDealerDied;
				if (obj3 == null)
				{
					UnityAction val6 = OnDealerDied;
					<>O.<0>__OnDealerDied = val6;
					obj3 = (object)val6;
				}
				onDieOrKnockedOut.AddListener((UnityAction)obj3);
				((NPC)dealer).Health.onDieOrKnockedOut.AddListener(new UnityAction(TrySpawnGoonsOnDeath));
				void TrySpawnGoonsOnDeath()
				{
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					//IL_003e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0043: 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_00b8: 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_005d: Unknown result type (might be due to invalid IL or missing references)
					//IL_008c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0091: 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_009d: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
					if (!(Random.Range(0f, 1f) > 0.5f) && NetworkSingleton<Cartel>.Instance.GoonPool.UnspawnedGoonCount >= 2)
					{
						float num = default(float);
						Player closestPlayer = Player.GetClosestPlayer(((NPC)dealer).CenterPoint, ref num, (List<Player>)null);
						Vector3 val8 = Vector3.zero;
						int num2 = 4;
						int num3 = 0;
						do
						{
							if (!CartelEnforcer.registered)
							{
								return;
							}
							if (num3 == num2)
							{
								break;
							}
							Vector3 onUnitSphere = Random.onUnitSphere;
							onUnitSphere.y = 0f;
							((Vector3)(ref onUnitSphere)).Normalize();
							float num4 = Random.Range(16f, 24f);
							val8 = ((Component)dealer).transform.position + onUnitSphere * num4;
							num3++;
						}
						while (closestPlayer.IsPointVisibleToPlayer(val8, 30f, 5f));
						if (!(val8 == Vector3.zero))
						{
							List<CartelGoon> list2 = NetworkSingleton<Cartel>.Instance.GoonPool.SpawnMultipleGoons(val8, 2, true);
							foreach (CartelGoon item in list2)
							{
								((NPC)item).Movement.WarpToNavMesh();
								if (Random.Range(0f, 1f) > 0.7f && AmbushOverrides.RangedWeapons != null && AmbushOverrides.RangedWeapons.Length != 0)
								{
									((NPC)item).Behaviour.CombatBehaviour.DefaultWeapon = AmbushOverrides.RangedWeapons[Random.Range(0, AmbushOverrides.RangedWeapons.Length)];
								}
								else if (AmbushOverrides.MeleeWeapons != null && AmbushOverrides.MeleeWeapons.Length != 0)
								{
									((NPC)item).Behaviour.CombatBehaviour.DefaultWeapon = AmbushOverrides.MeleeWeapons[Random.Range(0, AmbushOverrides.MeleeWeapons.Length)];
								}
								item.AttackEntity(((Component)closestPlayer).GetComponent<ICombatTargetable>(), true);
							}
							CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnDefenderGoonsSoon(list2)));
						}
					}
				}
				void onStayInsideEnd()
				{
					if ((!InterceptEvent.interceptingDeal || !((Object)(object)InterceptEvent.interceptor != (Object)null) || !((Object)(object)dealer == (Object)(object)InterceptEvent.interceptor)) && ((Dealer)dealer).ActiveContracts.Count == 0)
					{
						if (!dealer.IsAcceptingDeals)
						{
							dealer.SetIsAcceptingDeals(true);
						}
						CartelEnforcer.coros.Add(MelonCoroutines.Start(WalkToInterestPoint(dealer, CartelEnforcer.Wait5)));
					}
				}
			}
			List<CartelDealer> list = new List<CartelDealer>();
			array = allCartelDealers;
			foreach (CartelDealer val7 in array)
			{
				if ((Object)(object)((NPC)val7).Avatar.CurrentSettings == (Object)null)
				{
					list.Add(val7);
				}
			}
			if (list.Count > 0)
			{
				foreach (CartelDealer item2 in list)
				{
					item2.RandomizeAppearance();
				}
			}
			list.Clear();
			list = null;
		}

		[IteratorStateMachine(typeof(<DespawnDefenderGoonsSoon>d__20))]
		public static IEnumerator DespawnDefenderGoonsSoon(List<CartelGoon> goons)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DespawnDefenderGoonsSoon>d__20(0)
			{
				goons = goons
			};
		}

		[IteratorStateMachine(typeof(<StartActiveSignal>d__21))]
		public static IEnumerator StartActiveSignal()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <StartActiveSignal>d__21(0);
		}

		public static bool IsWalkingEnabled(CartelDealer d)
		{
			if (!CartelEnforcer.currentConfig.enhancedDealers)
			{
				return false;
			}
			if (!dealerConfig.FreeTimeWalking)
			{
				return false;
			}
			if (InterceptEvent.interceptingDeal && (Object)(object)InterceptEvent.interceptor != (Object)null && (Object)(object)InterceptEvent.interceptor == (Object)(object)d)
			{
				return false;
			}
			if (((Dealer)d).ActiveContracts.Count > 0)
			{
				return false;
			}
			if (((NPC)d).Health.IsDead || ((NPC)d).Health.IsKnockedOut)
			{
				return false;
			}
			if (NetworkSingleton<TimeManager>.Instance.CurrentTime < currentStayInsideEnd && NetworkSingleton<TimeManager>.Instance.CurrentTime > currentStayInsideStart)
			{
				return false;
			}
			if ((Object)(object)((NPC)d).Behaviour.GetBehaviour("Smoke Break") != (Object)null && ((NPC)d).Behaviour.GetBehaviour("Smoke Break").Active)
			{
				return false;
			}
			return true;
		}

		public static void WalkToInterestPoint(CartelDealer d)
		{
			//IL_009d: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			if (!IsWalkingEnabled(d))
			{
				return;
			}
			if (Random.Range(0f, 1f) > 0.5f)
			{
				DeliveryLocation randomUnscheduledDeliveryLocation = Singleton<Map>.instance.Regions[((NPC)d).Region].GetRandomUnscheduledDeliveryLocation();
				((NPC)d).Movement.SetDestination(randomUnscheduledDeliveryLocation.CustomerStandPoint.position);
			}
			else
			{
				List<DeadDrop> list = DeadDrop.DeadDrops.FindAll((DeadDrop drop) => drop.Region == ((NPC)d).Region);
				DeadDrop val = list[Random.Range(0, list.Count)];
				_ = ((Component)val).transform.position;
				Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 1.6f + Vector3.down * 1.4f;
				Vector3 val3 = default(Vector3);
				((NPC)d).Movement.GetClosestReachablePoint(val2, ref val3);
				if (val3 != Vector3.zero)
				{
					((NPC)d).Movement.SetDestination(val3);
				}
			}
			if (!d.IsAcceptingDeals)
			{
				d.SetIsAcceptingDeals(true);
			}
		}

		[IteratorStateMachine(typeof(<WalkToInterestPoint>d__24))]
		public static IEnumerator WalkToInterestPoint(CartelDealer d, WaitForSeconds delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WalkToInterestPoint>d__24(0)
			{
				d = d,
				delay = delay
			};
		}

		public static void OnDealerDied()
		{
			currentDealerActivity = Mathf.Clamp(currentDealerActivity - dealerConfig.DealerActivityDecreasePerKill, minActivity, maxActivity);
		}

		public static void OnDayPassChange()
		{
			currentDealerActivity = Mathf.Clamp(currentDealerActivity + dealerConfig.DealerActivityIncreasePerDay, minActivity, maxActivity);
		}

		[IteratorStateMachine(typeof(<OnCartelCustomerDeal>d__27))]
		public static IEnumerator OnCartelCustomerDeal(CartelCustomerDeal dealEvent, bool started)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnCartelCustomerDeal>d__27(0)
			{
				dealEvent = dealEvent,
				started = started
			};
		}
	}
	[Serializable]
	public class CartelDealerConfig
	{
		public float CartelDealerWalkSpeed = 2.8f;

		public float CartelDealerHP = 200f;

		public float CartelDealerLethality = 0.5f;

		public string CartelDealerWeapon = "M1911";

		public float StealDealerContractChance = 0.06f;

		public float StealPlayerPendingChance = 0.08f;

		public float DealerActivityDecreasePerKill = 0.1f;

		public float DealerActivityIncreasePerDay = 0.25f;

		public float SafetyThreshold = -0.85f;

		public bool SafetyEnabled = true;

		public bool FreeTimeWalking = true;
	}
	public static class StealBackCustomer
	{
		public class StolenNPC
		{
			public NPC npc;

			public int sampleChancesProcessed = -1;
		}

		[CompilerGenerated]
		private sealed class <LateSendMessage>d__8 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public NPC npc;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <LateSendMessage>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (Random.Range(0f, 1f) > 0.5f)
					{
						<>2__current = CartelEnforcer.Wait30;
						<>1__state = 1;
						return true;
					}
					<>2__current = CartelEnforcer.Wait10;
					<>1__state = 2;
					return true;
				case 1:
					<>1__state = -1;
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (!CartelEnforcer.registered)
				{
					return false;
				}
				npc.MSGConversation.SendMessage(new Message(playerMessageTemplates[Random.Range(0, playerMessageTemplates.Count)], (ESenderType)1, true, -1), true, true);
				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 <StealCustomerWithDelay>d__5 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public float cartelInfluence;

			private List<Customer> <unlocked>5__2;

			private int <subtrahend>5__3;

			private int <i>5__4;

			private int <maxCustomersChecked>5__5;

			private int <maxSuccesfulStolen>5__6;

			private int <currentCustomersChecked>5__7;

			private int <currentStolen>5__8;

			private EMapRegion <region1StolenFrom>5__9;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <StealCustomerWithDelay>d__5(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<unlocked>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<unlocked>5__2 = new List<Customer>(Customer.UnlockedCustomers);
					if (<unlocked>5__2.Count <= 18)
					{
						return false;
					}
					<subtrahend>5__3 = Random.Range(3, 6);
					<i>5__4 = Mathf.Clamp(<unlocked>5__2.Count - <subtrahend>5__3, 0, <unlocked>5__2.Count - 1);
					<maxCustomersChecked>5__5 = 5;
					<maxSuccesfulStolen>5__6 = 2;
					<currentCustomersChecked>5__7 = 0;
					<currentStolen>5__8 = 0;
					<region1StolenFrom>5__9 = (EMapRegion)0;
					goto IL_016f;
				case 1:
					<>1__state = -1;
					goto IL_016f;
				case 2:
					{
						<>1__state = -1;
						return false;
					}
					IL_016f:
					if (CartelEnforcer.registered && <i>5__4 >= 0 && <currentStolen>5__8 < <maxSuccesfulStolen>5__6 && <currentCustomersChecked>5__7 < <maxCustomersChecked>5__5)
					{
						Customer val = <unlocked>5__2[<i>5__4];
						if (CanStealCustomer(val.NPC, cartelInfluence))
						{
							if ((int)<region1StolenFrom>5__9 == 0)
							{
								<region1StolenFrom>5__9 = val.NPC.Region;
							}
							else if (<region1StolenFrom>5__9 != val.NPC.Region)
							{
								StealCustomer(val.NPC);
								<currentStolen>5__8++;
							}
						}
						<i>5__4 = Mathf.Clamp(<i>5__4 - <subtrahend>5__3, 0, <unlocked>5__2.Count - 1);
						<subtrahend>5__3 = Random.Range(3, 6);
						<currentCustomersChecked>5__7++;
						<>2__current = CartelEnforcer.Wait05;
						<>1__state = 1;
						return true;
					}
					<>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 <WaitSleepEndTrySteal>d__4 : 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 <WaitSleepEndTrySteal>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Expected O, but got Unknown
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Invalid comparison between Unknown and I4
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_016e: Invalid comparison between Unknown and I4
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0119: Invalid comparison between Unknown and I4
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: Invalid comparison between Unknown and I4
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Invalid comparison between Unknown and I4
				//IL_0159: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Invalid comparison between Unknown and I4
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Invalid comparison between Unknown and I4
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = CartelEnforcer.Wait30;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => !CartelEnforcer.isSaving && !Singleton<SaveManager>.Instance.IsSaving));
					<>1__state = 2;
					return true;
				case 2:
				{
					<>1__state = -1;
					if (!CartelEnforcer.registered)
					{
						return false;
					}
					if (!InstanceFinder.NetworkManager.IsServer)
					{
						return false;
					}
					if ((int)NetworkSingleton<Cartel>.Instance.Status != 2)
					{
						return false;
					}
					float num = 0f;
					foreach (RegionInfluenceData item in NetworkSingleton<Cartel>.Instance.Influence.regionInfluence)
					{
						num += item.Influence;
					}
					float num2 = num / (float)NetworkSingleton<Cartel>.Instance.Influence.regionInfluence.Count;
					if (num2 > 0f && num2 <= 0.66f)
					{
						if ((int)NetworkSingleton<TimeManager>.Instance.CurrentDay != 1 && (int)NetworkSingleton<TimeManager>.Instance.CurrentDay != 4 && (int)NetworkSingleton<TimeManager>.Instance.CurrentDay != 6)
						{
							return false;
						}
					}
					else if (num2 > 0.66f && num2 < 0.8f)
					{
						if ((int)NetworkSingleton<TimeManager>.Instance.CurrentDay != 1 && (int)NetworkSingleton<TimeManager>.Instance.CurrentDay != 4)
						{
							return false;
						}
					}
					else if ((int)NetworkSingleton<TimeManager>.Instance.CurrentDay != 4)
					{
						return false;
					}
					CartelEnforcer.coros.Add(MelonCoroutines.Start(StealCustomerWithDelay(num2)));
					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 List<StolenNPC> stolenNPCs = new List<StolenNPC>();

		public static List<string> playerMessageTemplates = new List<string> { "I won't be hustling with you anymore. Got better quality from another person...", "Sorry, but I've got to change my local. These prices ain't it.", "Just letting you know that I won't be hitting you up anymore...", "These last deals have been a bit pricey. I'll get my stuff elsewhere.", "You've been cutting me short. I'm done buying from you.", "Thought we were cool, but you've been ripping me off. Peace.", "That last one was too light and quality was trash... I'll find someone else." };

		public static void OnDayPassTrySteal()
		{
			CartelEnforcer.coros.Add(MelonCoroutines.Start(WaitSleepEndTrySteal()));
		}

		[IteratorStateMachine(typeof(<WaitSleepEndTrySteal>d__4))]
		public static IEnumerator WaitSleepEndTrySteal()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitSleepEndTrySteal>d__4(0);
		}

		[IteratorStateMachine(typeof(<StealCustomerWithDelay>d__5))]
		public static IEnumerator StealCustomerWithDelay(float cartelInfluence)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <StealCustomerWithDelay>d__5(0)
			{
				cartelInfluence = cartelInfluence
			};
		}

		public static bool CanStealCustomer(NPC npc, float cartelInfluence)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			if ((int)npc.Region == 0)
			{
				return false;
			}
			if (!npc.RelationData.Unlocked)
			{
				return false;
			}
			float num = Random.Range(0f, 1f);
			if ((int)npc.Region == 1 && num > 0.5f)
			{
				return false;
			}
			float num2 = Mathf.Lerp(4.5f, 1.5f, cartelInfluence);
			if (npc.RelationData.RelationDelta > num2 && num > 0.1f)
			{
				return false;
			}
			Customer component = ((Component)npc).GetComponent<Customer>();
			if (Customer.LockedCustomers.Contains(component))
			{
				return false;
			}
			if ((Object)(object)component.CurrentContract != (Object)null)
			{
				return false;
			}
			if (component.CurrentAddiction > 0.8f && num > 0.2f)
			{
				return false;
			}
			if (npc.RelationData.Connections.Count < 2)
			{
				return false;
			}
			for (int i = 0; i < npc.RelationData.Connections.Count; i++)
			{
				if (!npc.RelationData.Connections[i].RelationData.Unlocked)
				{
					return false;
				}
			}
			List<StolenNPC> list = new List<StolenNPC>(stolenNPCs);
			for (int j = 0; j < list.Count; j++)
			{
				if ((Object)(object)list[j].npc == (Object)(object)npc)
				{
					return false;
				}
			}
			return true;
		}

		public static void StealCustomer(NPC npc)
		{
			npc.RelationData.Unlocked = false;
			Customer component = ((Component)npc).GetComponent<Customer>();
			if (!Customer.LockedCustomers.Contains(component))
			{
				Customer.LockedCustomers.Add(component);
			}
			if (Customer.UnlockedCustomers.Contains(component))
			{
				Customer.UnlockedCustomers.Remove(component);
			}
			component.minsSinceUnlocked = 0;
			component.customerData.GuaranteeFirstSampleSuccess = false;
			component.UpdatePotentialCustomerPoI();
			StolenNPC stolenNPC = new StolenNPC();
			stolenNPC.npc = npc;
			stolenNPC.sampleChancesProcessed = 1;
			stolenNPCs.Add(stolenNPC);
			if ((Object)(object)component.AssignedDealer != (Object)null)
			{
				component.AssignedDealer.RemoveCustomer(component);
			}
			Singleton<NewCustomerPopup>.Instance.PlayPopup(component);
			((TMP_Text)Singleton<NewCustomerPopup>.Instance.Title).text = "Customer has been stolen by Cartel!";
			CartelEnforcer.coros.Add(MelonCoroutines.Start(LateSendMessage(npc)));
		}

		[IteratorStateMachine(typeof(<LateSendMessage>d__8))]
		public static IEnumerator LateSendMessage(NPC npc)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LateSendMessage>d__8(0)
			{
				npc = npc
			};
		}
	}
	[HarmonyPatch(typeof(Customer), "GetSampleSuccess")]
	public static class Customer_GetSampleSuccess_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(Customer __instance, ref float __result)
		{
			List<StealBackCustomer.StolenNPC> list = new List<StealBackCustomer.StolenNPC>(StealBackCustomer.stolenNPCs);
			StealBackCustomer.StolenNPC stolenNPC = null;
			for (int i = 0; i < list.Count; i++)
			{
				if ((Object)(object)list[i].npc == (Object)(object)__instance.NPC)
				{
					stolenNPC = list[i];
					break;
				}
			}
			if (stolenNPC != null && stolenNPC.sampleChancesProcessed != -1)
			{
				float num = (float)stolenNPC.sampleChancesProcessed / 9f;
				if (num >= 1f)
				{
					__result = 0.95f;
				}
				else
				{
					__result = Mathf.Lerp(0.05f, 0.75f, Mathf.Clamp01(num * (1f + __instance.CurrentAddiction)));
				}
				stolenNPC.sampleChancesProcessed++;
			}
		}
	}
	public class CartelRegActivityHours
	{
		public int region;

		public int cartelActivityClass;

		public int hoursUntilEnable;
	}
	public class HrPassParameterMap
	{
		public string itemDesc { get; set; }

		public Func<int> Getter { get; set; }

		public Action<int> Setter { get; set; }

		public Action HourPassAction { get; set; }

		public int modTicksPassed { get; set; }

		public int currentModHours { get; set; }

		public Func<bool> CanPassHour { get; set; }
	}
	public static class FrequencyOverrides
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass3_0
		{
			public CartelActivities instanceActivities;

			public CartelDealManager instanceDealMgr;

			internal int <PopulateParameterMap>b__0()
			{
				return instanceActivities.HoursUntilNextGlobalActivity;
			}

			internal void <PopulateParameterMap>b__1(int value)
			{
				instanceActivities.HoursUntilNextGlobalActivity = value;
			}

			internal void <PopulateParameterMap>b__2()
			{
				instanceActivities.HourPass();
			}

			internal int <PopulateParameterMap>b__9()
			{
				return instanceDealMgr.HoursUntilNextDealRequest;
			}

			internal void <PopulateParameterMap>b__10(int value)
			{
				instanceDealMgr.HoursUntilNextDealRequest = value;
			}

			internal void <PopulateParameterMap>b__11()
			{
				instanceDealMgr.HourPass();
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass3_1
		{
			public CartelRegionActivities act;

			internal int <PopulateParameterMap>b__4()
			{
				return act.HoursUntilNextActivity;
			}

			internal void <PopulateParameterMap>b__5(int value)
			{
				act.HoursUntilNextActivity = value;
			}

			internal void <PopulateParameterMap>b__6()
			{
				act.HourPass();
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass3_2
		{
			public CartelCustomerDeal cartelCustomerDeal;
		}

		[CompilerGenerated]
		private sealed class <HelperSet>d__6 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public HrPassParameterMap hpmap;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <HelperSet>d__6(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 (!hpmap.CanPassHour())
					{
						return false;
					}
					if (!InstanceFinder.IsServer)
					{
						return false;
					}
					if (CartelEnforcer.currentConfig.activityFrequency > 0f)
					{
						hpmap.HourPassAction();
					}
					else
					{
						if (hpmap.Getter() == 1)
						{
							return false;
						}
						float num = Mathf.Lerp(1f, 10f, 0f - CartelEnforcer.currentConfig.activityFrequency);
						if (hpmap.Getter() < hpmap.currentModHours)
						{
							hpmap.Setter(hpmap.currentModHours);
						}
						else
						{
							hpmap.modTicksPassed = 0;
							hpmap.currentModHours = hpmap.Getter();
						}
						hpmap.modTicksPassed++;
						if ((float)hpmap.modTicksPassed >= num)
						{
							hpmap.HourPassAction();
							hpmap.modTicksPassed = 0;
							hpmap.currentModHours -= 1;
						}
					}
					<>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 <PopulateParameterMap>d__3 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			private <>c__DisplayClass3_0 <>8__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PopulateParameterMap>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>8__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0252: Unknown result type (might be due to invalid IL or missing references)
				//IL_025c: Expected I4, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>8__1 = new <>c__DisplayClass3_0();
					<>2__current = CartelEnforcer.Wait2;
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					if (!CartelEnforcer.registered)
					{
						return false;
					}
					int num = 0;
					<>8__1.instanceActivities = NetworkSingleton<Cartel>.Instance.Activities;
					actFreqMapping.Add(new HrPassParameterMap
					{
						itemDesc = "Global Activities",
						Getter = () => <>8__1.instanceActivities.HoursUntilNextGlobalActivity,
						Setter = delegate(int value)
						{
							<>8__1.instanceActivities.HoursUntilNextGlobalActivity = value;
						},
						HourPassAction = delegate
						{
							<>8__1.instanceActivities.HourPass();
						},
						modTicksPassed = 0,
						currentModHours = <>8__1.instanceActivities.HoursUntilNextGlobalActivity,
						CanPassHour = () => (int)NetworkSingleton<Cartel>.Instance.Status == 2
					});
					num++;
					CartelRegActivityHours item = new CartelRegActivityHours
					{
						region = -1,
						hoursUntilEnable = GetActivityHours(CartelEnforcer.currentConfig.ambushFrequency),
						cartelActivityClass = -1
					};
					regActivityHours.Add(item);
					CartelRegionActivities[] regionalActivities = NetworkSingleton<Cartel>.Instance.Activities.RegionalActivities;
					for (int i = 0; i < regionalActivities.Length; i++)
					{
						<>c__DisplayClass3_1 CS$<>8__locals1 = new <>c__DisplayClass3_1
						{
							act = regionalActivities[i]
						};
						actFreqMapping.Add(new HrPassParameterMap
						{
							itemDesc = "Cartel Regional Activities (" + ((object)(EMapRegion)(ref CS$<>8__locals1.act.Region)).ToString() + ")",
							Getter = () => CS$<>8__locals1.act.HoursUntilNextActivity,
							Setter = delegate(int value)
							{
								CS$<>8__locals1.act.HoursUntilNextActivity = value;
							},
							HourPassAction = delegate
							{
								CS$<>8__locals1.act.HourPass();
							},
							modTicksPassed = 0,
							currentModHours = CS$<>8__locals1.act.HoursUntilNextActivity,
							CanPassHour = () => (int)NetworkSingleton<Cartel>.Instance.Status == 2
						});
						num++;
						foreach (CartelActivity activity in CS$<>8__locals1.act.Activities)
						{
							CartelRegActivityHours cartelRegActivityHours = new CartelRegActivityHours
							{
								region = (int)CS$<>8__locals1.act.Region
							};
							int num2 = 0;
							<>c__DisplayClass3_2 CS$<>8__locals0;
							if (activity is StealDeadDrop)
							{
								cartelRegActivityHours.cartelActivityClass = 0;
								num2 = GetActivityHours(CartelEnforcer.currentConfig.deadDropStealFrequency);
							}
							else
							{
								CS$<>8__locals0 = new <>c__DisplayClass3_2
								{
									cartelCustomerDeal = (CartelCustomerDeal)(object)((activity is CartelCustomerDeal) ? activity : null)
								};
								if (CS$<>8__locals0.cartelCustomerDeal != null)
								{
									cartelRegActivityHours.cartelActivityClass = 1;
									num2 = GetActivityHours(CartelEnforcer.currentConfig.cartelCustomerDealFrequency);
									if (CartelEnforcer.currentConfig.enhancedDealers)
									{
										((CartelActivity)CS$<>8__locals0.cartelCustomerDeal).onActivated = (Action)Delegate.Combine(((CartelActivity)CS$<>8__locals0.cartelCustomerDeal).onActivated, new Action(OnCustomerDealActive));
									}
								}
								else if (activity is RobDealer)
								{
									cartelRegActivityHours.cartelActivityClass = 2;
									num2 = GetActivityHours(CartelEnforcer.currentConfig.cartelRobberyFrequency);
								}
								else
								{
									cartelRegActivityHours.cartelActivityClass = 3;
									num2 = GetActivityHours(CartelEnforcer.currentConfig.cartelGraffitiFrequency);
								}
							}
							cartelRegActivityHours.hoursUntilEnable = num2;
							regActivityHours.Add(cartelRegActivityHours);
							void OnCustomerDealActive()
							{
								CartelEnforcer.coros.Add(MelonCoroutines.Start(DealerActivity.OnCartelCustomerDeal(CS$<>8__locals0.cartelCustomerDeal, started: true)));
							}
						}
					}
					<>8__1.instanceDealMgr = NetworkSingleton<Cartel>.Instance.DealManager;
					actFreqMapping.Add(new HrPassParameterMap
					{
						itemDesc = "Cartel Deal Manager (Truced only)",
						Getter = () => <>8__1.instanceDealMgr.HoursUntilNextDealRequest,
						Setter = delegate(int value)
						{
							<>8__1.instanceDealMgr.HoursUntilNextDealRequest = value;
						},
						HourPassAction = delegate
						{
							<>8__1.instanceDealMgr.HourPass();
						},
						modTicksPassed = 0,
						currentModHours = <>8__1.instanceDealMgr.HoursUntilNextDealRequest,
						CanPassHour = () => (int)NetworkSingleton<Cartel>.Instance.Status == 1
					});
					num++;
					actFreqMapping.Add(new HrPassParameterMap
					{
						itemDesc = "Drive-By Events",
						Getter = () => DriveByEvent.hoursUntilDriveBy,
						Setter = delegate(int value)
						{
							DriveByEvent.hoursUntilDriveBy = value;
						},
						HourPassAction = delegate
						{
							DriveByEvent.hoursUntilDriveBy = Mathf.Clamp(DriveByEvent.hoursUntilDriveBy - 1, 0, 48);
						},
						modTicksPassed = 0,
						currentModHours = DriveByEvent.hoursUntilDriveBy,
						CanPassHour = () => (int)NetworkSingleton<Cartel>.Instance.Status == 2
					});
					<>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 <TickOverrideHourPass>d__5 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			private WaitForSeconds <WaitCalculated>5__2;

			private List<HrPassParameterMap>.Enumerator <>7__wrap2;

			private HrPassParameterMap <item>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TickOverrideHourPass>d__5(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();
					}
				}
				<WaitCalculated>5__2 = null;
				<>7__wrap2 = default(List<HrPassParameterMap>.Enumerator);
				<item>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Expected O, but got Unknown
				bool result;
				try
				{
					switch (<>1__state)
					{
					default:
						result = false;
						break;
					case 0:
						<>1__state = -1;
						<>2__current = CartelEnforcer.Wait5;
						<>1__state = 1;
						result = true;
						break;
					case 1:
					{
						<>1__state = -1;
						if (!CartelEnforcer.registered)
						{
							result = false;
							break;
						}
						if (CartelEnforcer.currentConfig.activityFrequency == 0f)
						{
							result = false;
							break;
						}
						float num = 60f;
						float num2 = 60f;
						if (CartelEnforcer.currentConfig.activityFrequency > 0f)
						{
							num2 = Mathf.Lerp(num, num / 10f, CartelEnforcer.currentConfig.activityFrequency);
						}
						<WaitCalculated>5__2 = new WaitForSeconds(num2 / (float)actFreqMapping.Count);
						goto IL_0179;
					}
					case 2:
						<>1__state = -3;
						if (!CartelEnforcer.registered)
						{
							result = false;
							<>m__Finally1();
							break;
						}
						MelonCoroutines.Start(HelperSet(<item>5__4));
						<item>5__4 = null;
						goto IL_0150;
					case 3:
						{
							<>1__state = -1;
							result = false;
							break;
						}
						IL_0179:
						while (true)
						{
							if (CartelEnforcer.registered)
							{
								if (!CartelEnforcer.registered)
								{
									result = false;
									break;
								}
								if (actFreqMapping.Count == 0)
								{
									continue;
								}
								<>7__wrap2 = actFreqMapping.GetEnumerator();
								<>1__state = -3;
								goto IL_0150;
							}
							<>2__current = null;
							<>1__state = 3;
							result = true;
							break;
						}
						break;
						IL_0150:
						if (<>7__wrap2.MoveNext())
						{
							<item>5__4 = <>7__wrap2.Current;
							<>2__current = <WaitCalculated>5__2;
							<>1__state = 2;
							result = true;
							break;
						}
						<>m__Finally1();
						<>7__wrap2 = default(List<HrPassParameterMap>.Enumerator);
						goto IL_0179;
					}
				}
				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__wrap2).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static List<HrPassParameterMap> actFreqMapping = new List<HrPassParameterMap>();

		public static List<CartelRegActivityHours> regActivityHours = new List<CartelRegActivityHours>();

		public static int GetActivityHours(float configValue)
		{
			int num = 0;
			if (configValue > 0f)
			{
				int num2 = 1;
				return Mathf.RoundToInt(Mathf.Lerp(48f, (float)num2, configValue));
			}
			if (configValue < 0f)
			{
				int num3 = 96;
				float num4 = 0f - configValue;
				return Mathf.RoundToInt(Mathf.Lerp(48f, (float)num3, num4));
			}
			return 48;
		}

		[IteratorStateMachine(typeof(<PopulateParameterMap>d__3))]
		public static IEnumerator PopulateParameterMap()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PopulateParameterMap>d__3(0);
		}

		public static void OnHourPassReduceCartelRegActHours()
		{
			if (regActivityHours.Count <= 0)
			{
				return;
			}
			foreach (CartelRegActivityHours regActivityHour in regActivityHours)
			{
				if (regActivityHour.hoursUntilEnable > 0)
				{
					regActivityHour.hoursUntilEnable--;
				}
			}
		}

		[IteratorStateMachine(typeof(<TickOverrideHourPass>d__5))]
		public static IEnumerator TickOverrideHourPass()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TickOverrideHourPass>d__5(0);
		}

		[IteratorStateMachine(typeof(<HelperSet>d__6))]
		public static IEnumerator HelperSet(HrPassParameterMap hpmap)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <HelperSet>d__6(0)
			{
				hpmap = hpmap
			};
		}
	}
	[HarmonyPatch(typeof(CartelActivities), "TryStartActivity")]
	public static class CartelActivities_TryStartActivityPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(CartelActivities __instance)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			__instance.HoursUntilNextGlobalActivity = CartelActivities.GetNewCooldown();
			if (!__instance.CanNewActivityBegin())
			{
				return false;
			}
			List<CartelActivity> activitiesReadyToStart = NetworkSingleton<Cartel>.Instance.Activities.GetActivitiesReadyToStart();
			List<EMapRegion> validRegionsForActivity = NetworkSingleton<Cartel>.Instance.Activities.GetValidRegionsForActivity();
			if (activitiesReadyToStart.Count == 0 || validRegionsForActivity.Count == 0)
			{
				return false;
			}
			validRegionsForActivity.Sort((EMapRegion a, EMapRegion b) => NetworkSingleton<Cartel>.Instance.Influence.GetInfluence(b).CompareTo(NetworkSingleton<Cartel>.Instance.Influence.GetInfluence(a)));
			EMapRegion val = (EMapRegion)0;
			bool flag = false;
			foreach (EMapRegion item in validRegionsForActivity)
			{
				float influence = NetworkSingleton<Cartel>.Instance.Influence.GetInfluence(item);
				float num = 0f;
				float num2 = 0f;
				if (CartelEnforcer.currentConfig.activityInfluenceMin == 0f)
				{
					num = 0.8f;
					num2 = influence * num;
					if (Random.Range(0f, 1f) < num2)
					{
						val = item;
						flag = true;
						break;
					}
					continue;
				}
				if (CartelEnforcer.currentConfig.activityInfluenceMin > 0f)
				{
					num2 = Mathf.Lerp(influence * 0.8f, 1f, CartelEnforcer.currentConfig.activityInfluenceMin);
					if (Random.Range(0f, 1f) < num2)
					{
						val = item;
						flag = true;
						break;
					}
					continue;
				}
				_ = CartelEnforcer.currentConfig.activityInfluenceMin;
				num = Mathf.Lerp(1f, 0f, CartelEnforcer.currentConfig.activityInfluenceMin);
				num2 = influence * num;
				if (Random.Range(0f, 1f) < num2)
				{
					val = item;
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				return false;
			}
			if (FrequencyOverrides.regActivityHours[0].hoursUntilEnable > 0)
			{
				return false;
			}
			int count = activitiesReadyToStart.Count;
			do
			{
				count = activitiesReadyToStart.Count;
				if (count == 0)
				{
					break;
				}
				int index = Random.Range(0, count);
				if (activitiesReadyToStart[index].IsRegionValidForActivity(val))
				{
					NetworkSingleton<Cartel>.Instance.Activities.StartGlobalActivity((NetworkConnection)null, val, 0);
					FrequencyOverrides.regActivityHours[0].hoursUntilEnable = FrequencyOverrides.GetActivityHours(CartelEnforcer.currentConfig.ambushFrequency);
					break;
				}
				activitiesReadyToStart.Remove(activitiesReadyToStart[index]);
			}
			while (count != 0);
			return false;
		}
	}
	[HarmonyPatch(typeof(CartelRegionActivities), "TryStartActivity")]
	public static class CartelRegionActivities_TryStartActivityPatch
	{
		public static Dictionary<CartelActivity, List<int>> enabledActivities = new Dictionary<CartelActivity, List<int>>();

		[HarmonyPrefix]
		public static bool Prefix(CartelRegionActivities __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between I4 and Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			__instance.HoursUntilNextActivity = CartelRegionActivities.GetNewCooldown(__instance.Region);
			List<int> list = new List<int>();
			for (int i = 0; i < FrequencyOverrides.regActivityHours.Count; i++)
			{
				if (FrequencyOverrides.regActivityHours[i].region == (int)__instance.Region)
				{
					list.Add(i);
				}
			}
			foreach (CartelActivity activity in __instance.Activities)
			{
				int num = 0;
				num = ((!(activity is StealDeadDrop)) ? ((activity is CartelCustomerDeal) ? 1 : ((!(activity is RobDealer)) ? 3 : 2)) : 0);
				for (int j = 0; j < list.Count; j++)
				{
					if (FrequencyOverrides.regActivityHours[list[j]].cartelActivityClass == num && FrequencyOverrides.regActivityHours[list[j]].hoursUntilEnable <= 0 && !enabledActivities.ContainsKey(activity))
					{
						List<int> value = new List<int>
						{
							list[j],
							num
						};
						enabledActivities.Add(activity, value);
					}
				}
			}
			if (enabledActivities.Count == 0)
			{
				enabledActivities.Clear();
				return false;
			}
			int count = enabledActivities.Count;
			do
			{
				count = enabledActivities.Count;
				if (count == 0)
				{
					break;
				}
				KeyValuePair<CartelActivity, List<int>> keyValuePair = enabledActivities.ElementAt(Random.Range(0, count));
				if (keyValuePair.Key.IsRegionValidForActivity(__instance.Region))
				{
					__instance.StartActivity((NetworkConnection)null, __instance.Activities.IndexOf(keyValuePair.Key));
					if (keyValuePair.Value[1] == 0)
					{
						FrequencyOverrides.regActivityHours[keyValuePair.Value[0]].hoursUntilEnable = FrequencyOverrides.GetActivityHours(CartelEnforcer.currentConfig.deadDropStealFrequency);
					}
					else if (keyValuePair.Value[1] == 1)
					{
						FrequencyOverrides.regActivityHours[keyValuePair.Value[0]].hoursUntilEnable = FrequencyOverrides.GetActivityHours(CartelEnforcer.currentConfig.cartelCustomerDealFrequency);
					}
					else if (keyValuePair.Value[1] == 2)
					{
						FrequencyOverrides.regActivityHours[keyValuePair.Value[0]].hoursUntilEnable = FrequencyOverrides.GetActivityHours(CartelEnforcer.currentConfig.cartelRobberyFrequency);
					}
					else if (keyValuePair.Value[1] == 3)
					{
						FrequencyOverrides.regActivityHours[keyValuePair.Value[0]].hoursUntilEnable = FrequencyOverrides.GetActivityHours(CartelEnforcer.currentConfig.cartelGraffitiFrequency);
					}
					break;
				}
				enabledActivities.Remove(keyValuePair.Key);
			}
			while (count != 0);
			enabledActivities.Clear();
			return false;
		}
	}
	public static class InfluenceOverrides
	{
		[CompilerGenerated]
		private sealed class <ApplyInfluenceConfig>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 <ApplyInfluenceConfig>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;
					<>2__current = CartelEnforcer.Wait2;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!CartelEnforcer.registered)
					{
						return false;
					}
					if (CartelEnforcer.currentConfig.activityInfluenceMin != 0f)
					{
						foreach (CartelActivity globalActivity in NetworkSingleton<Cartel>.Instance.Activities.GlobalActivities)
						{
							float num = 0f;
							num = ((!(CartelEnforcer.currentConfig.activityInfluenceMin > 0f) || !(globalActivity.InfluenceRequirement > 0f)) ? Mathf.Lerp(globalActivity.InfluenceRequirement, 0f, 0f - CartelEnforcer.currentConfig.activityInfluenceMin) : Mathf.Lerp(globalActivity.InfluenceRequirement, 1f, CartelEnforcer.currentConfig.activityInfluenceMin));
							globalActivity.InfluenceRequirement = num;
						}
						CartelRegionActivities[] array = Object.FindObjectsOfType<CartelRegionActivities>(true);
						for (int i = 0; i < array.Length; i++)
						{
							foreach (CartelActivity activity in array[i].Activities)
							{
								float num2 = 0f;
								num2 = ((!(CartelEnforcer.currentConfig.activityInfluenceMin > 0f) || !(activity.InfluenceRequirement > 0f)) ? Mathf.Lerp(activity.InfluenceRequirement, 0f, 0f - CartelEnforcer.currentConfig.activityInfluenceMin) : Mathf.Lerp(activity.InfluenceRequirement, 1f, CartelEnforcer.currentConfig.activityInfluenceMin));
								activity.InfluenceRequirement = num2;
							}
						}
					}
					<>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 <OnDayChangeApplyPassiveGain>d__2 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			private MapRegionData[] <>7__wrap1;

			private int <>7__wrap2;

			private MapRegionData <region>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnDayChangeApplyPassiveGain>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>7__wrap1 = null;
				<region>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_006f: 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)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>7__wrap1 = Singleton<Map>.Instance.Regions;
					<>7__wrap2 = 0;
					goto IL_00ba;
				case 1:
					<>1__state = -1;
					if (ShouldChangeInfluence(<region>5__4.Region))
					{
						NetworkSingleton<Cartel>.Instance.Influence.ChangeInfluence(<region>5__4.Region, -0.02f + CartelEnforcer.influenceConfig.passiveInfluenceGainPerDay);
					}
					<region>5__4 = null;
					<>7__wrap2++;
					goto IL_00ba;
				case 2:
					{
						<>1__state = -1;
						return false;
					}
					IL_00ba:
					if (<>7__wrap2 < <>7__wrap1.Length)
					{
						<region>5__4 = <>7__wrap1[<>7__wrap2];
						<>2__current = CartelEnforcer.Wait05;
						<>1__state = 1;
						return true;
					}
					<>7__wrap1 = null;
					<>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();
			}
		}

		public static bool ShouldChangeInfluence(EMapRegion region)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			bool result = false;
			if ((int)NetworkSingleton<Cartel>.Instance.Status != 2)
			{
				result = false;
			}
			if (InstanceFinder.IsServer && Singleton<Map>.Instance.GetUnlockedRegions().Contains(region))
			{
				result = true;
			}
			if ((int)region == 0)
			{
				result = false;
			}
			return result;
		}

		[IteratorStateMachine(typeof(<ApplyInfluenceConfig>d__1))]
		public static IEnumerator ApplyInfluenceConfig()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ApplyInfluenceConfig>d__1(0);
		}

		[IteratorStateMachine(typeof(<OnDayChangeApplyPassiveGain>d__2))]
		public static IEnumerator OnDayChangeApplyPassiveGain()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnDayChangeApplyPassiveGain>d__2(0);
		}

		public static void OnDayPassChangePassive()
		{
			CartelEnforcer.coros.Add(MelonCoroutines.Start(OnDayChangeApplyPassiveGain()));
		}
	}
	[Serializable]
	public class InfluenceConfig
	{
		public float interceptFail = 0.025f;

		public float interceptSuccess = -0.05f;

		public float deadDropFail = 0.025f;

		public float deadDropSuccess = -0.05f;

		public float gatheringFail = 0.025f;

		public float gatheringSuccess = -0.08f;

		public float robberyPlayerEscape = 0.025f;

		public float robberyGoonEscapeSuccess = 0.025f;

		public float robberyGoonDead = -0.08f;

		public float robberyGoonEscapeDead = -0.05f;

		public float sabotageBombDefused = -0.15f;

		public float sabotageGoonKilled = -0.05f;

		public float sabotageBombExploded = 0.2f;

		public float cartelDealerPersuaded = -0.1f;

		public float trucedGreetingChallenge = -0.15f;

		public float passiveInfluenceGainPerDay = 0.025f;

		public float cartelDealerDied = -0.1f;

		public float ambushDefeated = -0.1f;

		public float graffitiInfluenceReduction = -0.05f;

		public float customerUnlockInfluenceChange = -0.075f;
	}
	[HarmonyPatch(typeof(CartelDealer), "DiedOrKnockedOut")]
	public static class CartelDealer_Died_Patch
	{
		public static bool Prefix(CartelDealer __instance)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (!InstanceFinder.IsServer)
			{
				return false;
			}
			if ((int)NetworkSingleton<Cartel>.Instance.Status != 2)
			{
				return false;
			}
			NetworkSingleton<Cartel>.Instance.Influence.ChangeInfluence(((NPC)__instance).Region, CartelEnforcer.influenceConfig.cartelDealerDied);
			return false;
		}
	}
	[HarmonyPatch(typeof(Ambush), "SpawnAmbush")]
	public static class Ambush_SpawnAmbush_Patch
	{
		[CompilerGenerated]
		private sealed class <OverMonitorAmbush>d__1 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public List<CartelGoon> currentlySpawned;

			public EMapRegion region;

			private float <preMaxElapsed>5__2;

			private float <preElapsed>5__3;

			private List<CartelGoon> <ambushSpawned>5__4;

			private float <maxAmbushElapsed>5__5;

			private float <elapsed>5__6;

			private List<CartelGoon> <deadGoons>5__7;

			private int <spawnedCount>5__8;

			private List<CartelGoon>.Enumerator <>7__wrap8;

			private CartelGoon <goon>5__10;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OverMonitorAmbush>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				switch (<>1__state)
				{
				case -3:
				case 2: