using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using CartelEnforcer; using HarmonyLib; using Il2Cpp; using Il2CppFishNet; using Il2CppFishNet.Connection; using Il2CppFishNet.Managing; using Il2CppFishNet.Managing.Object; using Il2CppFishNet.Object; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.Audio; using Il2CppScheduleOne.AvatarFramework; using Il2CppScheduleOne.AvatarFramework.Equipping; using Il2CppScheduleOne.Cartel; using Il2CppScheduleOne.Combat; using Il2CppScheduleOne.Core.Items.Framework; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Dialogue; using Il2CppScheduleOne.Doors; using Il2CppScheduleOne.Dragging; using Il2CppScheduleOne.Economy; using Il2CppScheduleOne.EntityFramework; using Il2CppScheduleOne.GameTime; using Il2CppScheduleOne.Graffiti; using Il2CppScheduleOne.Interaction; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Law; using Il2CppScheduleOne.Levelling; using Il2CppScheduleOne.Lighting; using Il2CppScheduleOne.Map; using Il2CppScheduleOne.Messaging; using Il2CppScheduleOne.Misc; using Il2CppScheduleOne.Money; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.NPCs.Behaviour; using Il2CppScheduleOne.NPCs.CharacterClasses; using Il2CppScheduleOne.NPCs.Framework; using Il2CppScheduleOne.NPCs.Other; using Il2CppScheduleOne.NPCs.Relation; using Il2CppScheduleOne.NPCs.Schedules; using Il2CppScheduleOne.ObjectScripts; using Il2CppScheduleOne.Packaging; using Il2CppScheduleOne.Persistence; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.Police; using Il2CppScheduleOne.Product; using Il2CppScheduleOne.Product.Packaging; using Il2CppScheduleOne.Property; using Il2CppScheduleOne.Quests; using Il2CppScheduleOne.Storage; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Handover; using Il2CppScheduleOne.UI.MainMenu; using Il2CppScheduleOne.UI.Phone.ContactsApp; using Il2CppScheduleOne.Vehicles; using Il2CppScheduleOne.Vehicles.AI; using Il2CppScheduleOne.VoiceOver; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using UnityEngine; using UnityEngine.AI; 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", "2.0.0", "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.2", true)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("XOWithSauce")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright XOWithSauce 2026 Source MIT")] [assembly: AssemblyDescription("Schedule I Cartel Enforcer Mod")] [assembly: AssemblyFileVersion("2.0.0.0")] [assembly: AssemblyInformationalVersion("2.0.0")] [assembly: AssemblyProduct("Cartel Enforcer")] [assembly: AssemblyTitle("CartelEnforcer-IL2Cpp")] [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] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0200: 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) if ((int)__instance.DealerData.DealerType == 1) { List val = new List(); for (int i = 0; i < __instance.ActiveContracts.Count; i++) { if ((Object)(object)__instance.ActiveContracts[i] != (Object)null && !val.Contains(__instance.ActiveContracts[i])) { val.Add(__instance.ActiveContracts[i]); } } List list = new List(); List list2 = new List(); Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Contract current = enumerator.Current; lock (playerDealerStolenLock) { if (playerDealerStolen.ContainsKey(((object)((Quest)current).GUID/*cast due to .constrained prefix*/).ToString())) { list2.Add(current); } else { list.Add(current); } } } if (list.Count > 0) { foreach (Contract item in list) { ((Quest)item).Fail(true); } } if (list2.Count > 0) { foreach (Contract item2 in list2) { Dealer dealer = null; int completionXP = 0; if (playerDealerStolen.TryGetValue(((object)((Quest)item2).GUID/*cast due to .constrained prefix*/).ToString(), out var value)) { dealer = value.Item1; completionXP = value.Item2; } Customer component = ((Component)item2.Customer).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.CurrentContract != (Object)null) { if ((Object)(object)component.CurrentContract.Dealer != (Object)null && (Object)(object)component.CurrentContract.Dealer == (Object)(object)__instance) { component.CurrentContract.Dealer = dealer; } ((Quest)component.CurrentContract).CompletionXP = completionXP; } lock (playerDealerStolenLock) { playerDealerStolen.Remove(((object)((Quest)item2).GUID/*cast due to .constrained prefix*/).ToString()); } __instance.ActiveContracts.Remove(item2); __instance.currentContract = null; } } return false; } return true; } } [HarmonyPatch(typeof(Customer), "ProcessHandover")] public static class Customer_ProcessHandover_Patch { private static readonly string name = "ProcessHandover"; [HarmonyPrefix] public static bool Prefix(Customer __instance, EHandoverOutcome outcome, Contract contract, List items, bool handoverByPlayer, bool giveBonuses = true) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (handoverByPlayer) { return true; } if ((Object)(object)contract.Dealer == (Object)null) { CheckIntercept(__instance, contract, outcome, handoverByPlayer); return true; } CheckPlayerDealerStolen(__instance, contract, outcome); return true; } public static void CheckPlayerDealerStolen(Customer __instance, Contract contract, EHandoverOutcome outcome) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) if (!playerDealerStolen.ContainsKey(((object)((Quest)contract).GUID/*cast due to .constrained prefix*/).ToString())) { return; } playerDealerStolen.TryGetValue(((object)((Quest)contract).GUID/*cast due to .constrained prefix*/).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 && num < 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(((object)((Quest)contract).GUID/*cast due to .constrained prefix*/).ToString()); } consumedGUIDs.Add(((object)((Quest)contract).GUID/*cast due to .constrained prefix*/).ToString()); } public static void CheckIntercept(Customer __instance, Contract contract, EHandoverOutcome outcome, bool handoverByPlayer) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!CartelEnforcer.currentConfig.interceptDeals) { return; } string key = ((object)((Quest)contract).GUID/*cast due to .constrained prefix*/).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.Instance.Status == 1 && ((Dealer)__instance).IsRecruited) { return false; } bool flag = false; Enumerator enumerator = ((NPC)__instance).Inventory.ItemSlots.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Current.ItemInstance != null) { flag = true; } } if (flag) { return false; } return true; } } [HarmonyPatch(typeof(Dealer), "CheckNotifyPlayerOfDeal")] public static class Dealer_CheckNotifyPlayerOfDeal_Patch { [HarmonyPrefix] public static bool Prefix(Dealer __instance, Dealer cartelDealer, Contract contract) { //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.Instance.Status == 1 && cartelDealer.IsRecruited) { return false; } return true; } } private static List allDealers = new List(); 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> playerDealerStolen = new Dictionary>(); public static readonly object playerDealerStolenLock = new object(); public static List consumedGUIDs = new List(); public static IEnumerator EvaluateDealerState() { yield return CartelEnforcer.Wait5; if (allCartelDealers == null) { allCartelDealers = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType(true)); } Dealer[] array = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType(true)); foreach (Dealer val in array) { if ((int)val.DealerData.DealerType == 0) { allDealers.Add(val); } } currentStayInsideStart = defaultStayInsideStart; currentStayInsideEnd = defaultStayInsideEnd; currentStayInsideDur = defaultStayInsideDur; SetupDealers(); TimeManager instance = NetworkSingleton.Instance; instance.onDayPass += Action.op_Implicit((Action)OnDayPassChange); while (CartelEnforcer.registered) { yield return CartelEnforcer.Wait60; if (!CartelEnforcer.registered) { yield break; } if (!CartelEnforcer.currentConfig.enhancedDealers || (NetworkSingleton.Instance.CurrentTime < 1620 && NetworkSingleton.Instance.CurrentTime > 359)) { continue; } bool isHostile = true; if ((int)NetworkSingleton.Instance.Status != 2) { isHostile = false; } if (currentDealerActivity != previousDealerActivity) { int num2; int num4; int num5; if (currentDealerActivity > 0f) { int minSumFrom24HourTime = TimeManager.GetMinSumFrom24HourTime(currentStayInsideStart); int minSumFrom24HourTime2 = TimeManager.GetMinSumFrom24HourTime(359); int num = Mathf.RoundToInt(Mathf.Lerp((float)minSumFrom24HourTime, (float)minSumFrom24HourTime2, currentDealerActivity)); num2 = TimeManager.Get24HourTimeFromMinSum(num); if (num2 == 400) { num2 = 359; } int minSumFrom24HourTime3 = TimeManager.GetMinSumFrom24HourTime(currentStayInsideEnd); int minSumFrom24HourTime4 = TimeManager.GetMinSumFrom24HourTime(1620); int num3 = Mathf.RoundToInt(Mathf.Lerp((float)minSumFrom24HourTime3, (float)minSumFrom24HourTime4, currentDealerActivity)); num4 = TimeManager.Get24HourTimeFromMinSum(num3); num5 = num3 - num; } 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)); num2 = TimeManager.Get24HourTimeFromMinSum(num7); int minSumFrom24HourTime7 = TimeManager.GetMinSumFrom24HourTime(currentStayInsideEnd); int minSumFrom24HourTime8 = TimeManager.GetMinSumFrom24HourTime(2359); int num8 = Mathf.RoundToInt(Mathf.Lerp((float)minSumFrom24HourTime7, (float)minSumFrom24HourTime8, num6)); num4 = TimeManager.Get24HourTimeFromMinSum(num8); num5 = num8 - num7; } else { num2 = defaultStayInsideStart; num4 = defaultStayInsideEnd; num5 = defaultStayInsideDur; } currentStayInsideStart = num2; currentStayInsideEnd = num4; currentStayInsideDur = num5; CartelDealer[] array2 = allCartelDealers; foreach (CartelDealer d in array2) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } ApplyNewEventState(d, currentStayInsideStart, currentStayInsideEnd, currentStayInsideDur); } } previousDealerActivity = currentDealerActivity; bool safetyThresholdMet = false; if (dealerConfig.SafetyEnabled && currentDealerActivity <= dealerConfig.SafetyThreshold) { safetyThresholdMet = true; CartelDealer[] array2 = allCartelDealers; foreach (CartelDealer d in array2) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } ApplyNewEventState(d, 600, 559, 1439); d.SetIsAcceptingDeals(false); } } if (safetyThresholdMet) { continue; } if (!isHostile) { CartelDealer[] array2 = allCartelDealers; foreach (CartelDealer d in array2) { yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { yield break; } if (!((NPC)d).isInBuilding && !((NPC)d).Movement.HasDestination && !((NPC)d).Health.IsDead && !((NPC)d).Health.IsKnockedOut) { WalkToInterestPoint(d); } } yield return CartelEnforcer.Wait60; if (!CartelEnforcer.registered) { yield break; } } else if (NetworkSingleton.Instance.CurrentTime >= currentStayInsideEnd || NetworkSingleton.Instance.CurrentTime <= currentStayInsideStart) { CartelEnforcer.coros.Add(MelonCoroutines.Start(StartActiveSignal())); } } yield return null; } 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) { Enumerator enumerator = ((NPC)dealer).Behaviour.ScheduleManager.ActionList.GetEnumerator(); while (enumerator.MoveNext()) { NPCEvent_StayInBuilding val2 = ((Il2CppObjectBase)enumerator.Current).TryCast(); if ((Object)(object)val2 != (Object)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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) string text = ""; GameObject obj = ((Il2CppObjectBase)Resources.Load(dealerConfig.CartelDealerWeapon.ToLower() switch { "m1911" => "Avatar/Equippables/M1911", "goldenm1911" => "Avatar/Equippables/M1911_Gold", "revolver" => "Avatar/Equippables/Revolver", "knife" => "Avatar/Equippables/Knife", "brokenbottle" => "Avatar/Equippables/BrokenBottle", "shotgun" => "Avatar/Equippables/PumpShotgun", _ => "Avatar/Equippables/M1911", })).TryCast(); _ = (Object)(object)obj == (Object)null; AvatarEquippable component = Object.Instantiate(obj, new Vector3(0f, -5f, 0f), Quaternion.identity, (Transform)null).GetComponent(); if (!((Component)component).gameObject.activeSelf) { ((Component)component).gameObject.SetActive(true); } AvatarRangedWeapon val = ((Il2CppObjectBase)component).TryCast(); AvatarMeleeWeapon val2 = ((Il2CppObjectBase)component).TryCast(); 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); } CartelDealer[] array = allCartelDealers; foreach (CartelDealer dealer in array) { ((NPC)dealer).NPCData.Movement.WalkSpeed = dealerConfig.CartelDealerWalkSpeed; ((NPC)dealer).NPCData.Health.MaxHealth = dealerConfig.CartelDealerHP; ((NPC)dealer).Health.Health = dealerConfig.CartelDealerHP; AvatarWeapon val3 = null; AvatarWeapon val4 = ((Il2CppObjectBase)component).TryCast(); if ((Object)(object)val4 != (Object)null) { val3 = val4; } if ((Object)(object)val3 != (Object)null) { ((NPC)dealer).Behaviour.CombatBehaviour.SetDefaultWeapon(val3); if ((Object)(object)((NPC)dealer).Avatar != (Object)null) { component.Equip(((NPC)dealer).Avatar); } } ((NPC)dealer).NPCData.Behaviour.DefaultAggression = 1f; NPCEvent_StayInBuilding val5 = null; if (((NPC)dealer).Behaviour.ScheduleManager.ActionList != null) { Enumerator enumerator = ((NPC)dealer).Behaviour.ScheduleManager.ActionList.GetEnumerator(); while (enumerator.MoveNext()) { NPCEvent_StayInBuilding val6 = ((Il2CppObjectBase)enumerator.Current).TryCast(); if ((Object)(object)val6 != (Object)null) { val5 = val6; } } if ((Object)(object)val5 != (Object)null) { ((NPCAction)val5).StartTime = defaultStayInsideStart; ((NPCEvent)val5).EndTime = defaultStayInsideEnd; ((NPCEvent)val5).Duration = defaultStayInsideDur; NPCEvent_StayInBuilding obj2 = val5; ((NPCAction)obj2).onEnded = ((NPCAction)obj2).onEnded + Action.op_Implicit((Action)onStayInsideEnd); } } ((NPC)dealer).Health.onDieOrKnockedOut.AddListener(UnityAction.op_Implicit((Action)OnDealerDied)); ((NPC)dealer).Health.onDieOrKnockedOut.AddListener(UnityAction.op_Implicit((Action)TrySpawnGoonsOnDeath)); void TrySpawnGoonsOnDeath() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if ((!(Random.Range(0f, 1f) > 0.5f) || CartelEnforcer.currentConfig.debugMode) && NetworkSingleton.Instance.GoonPool.UnspawnedGoonCount >= 2) { float num = default(float); Player closestPlayer = PlayerManager.GetClosestPlayer(((NPC)dealer).CenterPoint, ref num, (List)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 val9 = NetworkSingleton.Instance.GoonPool.SpawnMultipleGoons(val8, 2, true); Enumerator enumerator3 = val9.GetEnumerator(); while (enumerator3.MoveNext()) { CartelGoon current = enumerator3.Current; ((NPC)current).Movement.WarpToNavMesh(); if (Random.Range(0f, 1f) > 0.7f && AmbushOverrides.RangedWeapons != null && AmbushOverrides.RangedWeapons.Length != 0) { ((NPC)current).Behaviour.CombatBehaviour.SetDefaultWeapon(AmbushOverrides.RangedWeapons[Random.Range(0, AmbushOverrides.RangedWeapons.Length)]); } else if (AmbushOverrides.MeleeWeapons != null && AmbushOverrides.MeleeWeapons.Length != 0) { ((NPC)current).Behaviour.CombatBehaviour.SetDefaultWeapon(AmbushOverrides.MeleeWeapons[Random.Range(0, AmbushOverrides.MeleeWeapons.Length)]); } current.AttackEntity(((Component)closestPlayer).GetComponent(), true); } CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnDefenderGoonsSoon(val9))); } } } 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 list = new List(); 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 item in list) { item.RandomizeAppearance(); } } list.Clear(); list = null; array = allCartelDealers; for (int i = 0; i < array.Length; i++) { ((NPC)array[i]).NPCData.Inventory.ClearInventoryOnNewDay = false; } } public static IEnumerator DespawnDefenderGoonsSoon(List goons) { int maxHoursWaited = 2; int goonsDead = 0; Enumerator enumerator; for (int i = 0; i < maxHoursWaited; i++) { yield return CartelEnforcer.Wait60; enumerator = goons.GetEnumerator(); while (enumerator.MoveNext()) { CartelGoon current = enumerator.Current; if ((((NPC)current).Health.IsDead || ((NPC)current).Health.IsKnockedOut) && current.IsGoonSpawned) { goonsDead++; current.Despawn(); } } if (goonsDead == goons.Count) { break; } } enumerator = goons.GetEnumerator(); while (enumerator.MoveNext()) { CartelGoon current2 = enumerator.Current; if (current2.IsGoonSpawned) { current2.Despawn(); } } yield return null; } public static IEnumerator StartActiveSignal() { Dictionary validContracts = new Dictionary(); foreach (Dealer playerDealer in allDealers) { yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { yield break; } if (playerDealer.ActiveContracts.Count == 0) { continue; } Contract contract = playerDealer.ActiveContracts[Random.Range(0, playerDealer.ActiveContracts.Count)]; string text = ((object)((Quest)contract).GUID/*cast due to .constrained prefix*/).ToString(); if (!Enumerable.Contains(InterceptEvent.contractGuids.Keys, text) && !validContracts.ContainsValue(contract) && !consumedGUIDs.Contains(text) && !playerDealerStolen.ContainsKey(text) && ((Quest)contract).GetMinsUntilExpiry() > 60) { EMapRegion regionFromPosition = Singleton.Instance.GetRegionFromPosition(contract.DeliveryLocation.CustomerStandPoint.position); if (!validContracts.ContainsKey(regionFromPosition)) { validContracts.Add(regionFromPosition, contract); } } } List cList = new List(); for (int i = 0; i < Customer.UnlockedCustomers.Count; i++) { cList.Add(Customer.UnlockedCustomers[i]); } List validCustomers = new List(); while (true) { yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { break; } Customer val = cList[Random.Range(0, cList.Count)]; if ((Object)(object)val.CurrentContract == (Object)null && (Object)(object)val.AssignedDealer == (Object)null && val.offeredContractInfo != null) { validCustomers.Add(val); } cList.Remove(val); if (cList.Count > 0) { continue; } CartelDealer[] array = allCartelDealers; int num = 0; while (true) { if (num < array.Length) { CartelDealer d = array[num]; Contract contract = null; yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { break; } if (NetworkSingleton.Instance.CurrentTime >= currentStayInsideEnd || NetworkSingleton.Instance.CurrentTime <= currentStayInsideStart) { if ((!((Object)(object)InterceptEvent.interceptor != (Object)null) || !((Object)(object)InterceptEvent.interceptor == (Object)(object)d)) && !((NPC)d).Health.IsDead && !((NPC)d).Health.IsKnockedOut && ((Dealer)d).ActiveContracts != null) { if (((Dealer)d).ActiveContracts.Count == 0) { bool actionTaken = false; if (validContracts.Count > 0 && validContracts.ContainsKey(((NPC)d).Region) && Random.Range(0.01f, 1f) < dealerConfig.StealDealerContractChance && dealerConfig.StealDealerContractChance != 0f) { contract = validContracts[((NPC)d).Region]; if ((Object)(object)contract != (Object)null && (int)((Quest)contract).State == 1 && !playerDealerStolen.ContainsKey(((object)((Quest)contract).GUID/*cast due to .constrained prefix*/).ToString()) && !consumedGUIDs.Contains(((object)((Quest)contract).GUID/*cast due to .constrained prefix*/).ToString())) { int completionXP = ((Quest)contract).CompletionXP; ((Quest)contract).CompletionXP = 0; contract.completedContractsIncremented = false; Dealer dealer = contract.Dealer; lock (playerDealerStolenLock) { playerDealerStolen.Add(((object)((Quest)contract).GUID/*cast due to .constrained prefix*/).ToString(), new Tuple(dealer, completionXP)); } ((Dealer)d).AddContract(contract); if (!((Behaviour)((Dealer)d)._attendDealBehaviour).Active) { ((Dealer)d).CheckAttendStart(); } actionTaken = true; } } else if (validCustomers.Count > 0 && Random.Range(0.01f, 1f) < dealerConfig.StealPlayerPendingChance && dealerConfig.StealPlayerPendingChance != 0f) { Customer c = validCustomers[Random.Range(0, validCustomers.Count)]; if ((Object)(object)c.CurrentContract == (Object)null && (Object)(object)c.AssignedDealer == (Object)null && c.offeredContractInfo != null) { ContractInfo contractInfo = new ContractInfo(); contractInfo.DeliveryLocation = c.offeredContractInfo.DeliveryLocation; contractInfo.DeliveryLocationGUID = c.offeredContractInfo.DeliveryLocationGUID; contractInfo.Payment = c.offeredContractInfo.Payment; contractInfo.Expires = c.offeredContractInfo.Expires; contractInfo.DeliveryWindow = c.offeredContractInfo.DeliveryWindow; contractInfo.PickupScheduleIndex = c.offeredContractInfo.PickupScheduleIndex; contractInfo.ExpiresAfter = c.offeredContractInfo.ExpiresAfter; contractInfo.IsCounterOffer = c.offeredContractInfo.IsCounterOffer; contractInfo.Products = c.offeredContractInfo.Products; c.ExpireOffer(); yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { break; } c.offeredContractInfo = contractInfo; EDealWindow dealWindow = ((Dealer)d).GetDealWindow(); contract = c.ContractAccepted(dealWindow, false, (Dealer)(object)d); if ((Object)(object)contract != (Object)null) { ((Quest)contract).CompletionXP = 0; contract.completedContractsIncremented = false; ((Dealer)d).AddContract(contract); if (!((Behaviour)((Dealer)d)._attendDealBehaviour).Active) { ((Dealer)d).CheckAttendStart(); } actionTaken = true; } } validCustomers.Remove(c); } if (!actionTaken) { if (!((NPC)d).isInBuilding && !((NPC)d).Movement.HasDestination) { WalkToInterestPoint(d); } } else if ((Object)(object)contract != (Object)null && (Object)(object)d != (Object)null) { CartelInventory.FulfillContractItems(contract, d); } } else if (!((Behaviour)((Dealer)d)._attendDealBehaviour).Active) { ((Dealer)d).CheckAttendStart(); } } num++; continue; } } cList.Clear(); validCustomers.Clear(); validContracts.Clear(); break; } break; } } 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.Instance.CurrentTime < currentStayInsideEnd && NetworkSingleton.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; } if ((Object)(object)((NPC)d).Behaviour.activeBehaviour != (Object)null && (Object)(object)((NPC)d).Behaviour.activeBehaviour == (Object)(object)((NPC)d).Behaviour.GenericDialogueBehaviour && (Object)(object)((NPC)d).Behaviour.GenericDialogueBehaviour.targetPlayer != (Object)null) { return false; } return true; } public static void WalkToInterestPoint(CartelDealer d) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected I4, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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 = ((Il2CppArrayBase)(object)Singleton.instance.Regions)[(int)((NPC)d).Region].GetRandomUnscheduledDeliveryLocation(); ((NPC)d).Movement.SetDestination(randomUnscheduledDeliveryLocation.CustomerStandPoint.position); } else { List list = new List(); for (int i = 0; i < DeadDrop.DeadDrops.Count; i++) { if (DeadDrop.DeadDrops[i].Region == ((NPC)d).Region) { list.Add(DeadDrop.DeadDrops[i]); } } 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); } } public static IEnumerator WalkToInterestPoint(CartelDealer d, WaitForSeconds delay) { yield return delay; WalkToInterestPoint(d); } public static void OnDealerDied() { currentDealerActivity = Mathf.Clamp(currentDealerActivity - dealerConfig.DealerActivityDecreasePerKill, minActivity, maxActivity); } public static void OnDayPassChange() { currentDealerActivity = Mathf.Clamp(currentDealerActivity + dealerConfig.DealerActivityIncreasePerDay, minActivity, maxActivity); } public static IEnumerator OnCartelCustomerDeal(CartelCustomerDeal dealEvent, bool started) { yield return CartelEnforcer.Wait2; if (started) { List val = new List(); Enumerator enumerator = Customer.LockedCustomers.GetEnumerator(); while (enumerator.MoveNext()) { Customer current = enumerator.Current; if (current.NPC.Region == ((CartelActivity)dealEvent).Region) { val.Add(current); } } if (val.Count == 0) { ((CartelActivity)dealEvent).Deactivate(); yield break; } int num = Random.Range(0, val.Count); Customer val2 = null; for (int i = 0; i < val.Count; i++) { val2 = val[num]; bool flag = true; if ((Object)(object)val2.CurrentContract != (Object)null) { flag = false; } if (!val2.NPC.IsConscious) { flag = false; } int orderTime = val2.customerData.OrderTime; int num2 = TimeManager.AddMinutesTo24HourTime(orderTime, 240); if (!NetworkSingleton.Instance.IsCurrentTimeWithinRange(orderTime, num2)) { flag = false; } if (!flag) { if (i == val.Count - 1) { ((CartelActivity)dealEvent).Deactivate(); yield break; } num = (num + 1) % val.Count; } } if ((Object)(object)val2 == (Object)null) { ((CartelActivity)dealEvent).Deactivate(); yield break; } EQuality correspondingQuality = StandardsMethod.GetCorrespondingQuality(val2.customerData.Standards); List list = new List(); Enumerator enumerator2 = val2.CustomerData.DefaultAffinityData.ProductAffinities.GetEnumerator(); while (enumerator2.MoveNext()) { ProductTypeAffinity current2 = enumerator2.Current; list.Add(current2); } list = list.OrderByDescending((ProductTypeAffinity x) => x.Affinity).ToList(); bool flag2 = false; Enumerator enumerator3 = ((Dealer)dealEvent.dealer).GetAllSlots().GetEnumerator(); while (enumerator3.MoveNext()) { ItemSlot current3 = enumerator3.Current; if (current3.ItemInstance == null) { continue; } ProductItemInstance val3 = ((Il2CppObjectBase)current3.ItemInstance).TryCast(); if (val3 != null) { if (((QualityItemInstance)val3).Quality < correspondingQuality) { flag2 = true; ((QualityItemInstance)val3).Quality = correspondingQuality; } else { flag2 = true; } break; } } if (!flag2) { List list2 = ((IEnumerable)dealEvent.dealer.RandomProducts).ToList(); ProductDefinition val4 = null; float num3 = 0f; foreach (ProductDefinition tempDef in list2) { ProductTypeAffinity val5 = list.First((ProductTypeAffinity x) => x.DrugType == tempDef.DrugType); if (val5 != null && val5.Affinity > num3) { val4 = tempDef; num3 = val5.Affinity; } } if ((Object)(object)val4 == (Object)null) { val4 = ((Il2CppArrayBase)(object)dealEvent.dealer.RandomProducts)[0]; } ItemInstance defaultInstance = ((ItemDefinition)val4).GetDefaultInstance(10); QualityItemInstance val6 = ((Il2CppObjectBase)defaultInstance).TryCast(); if (val6 != null) { val6.Quality = correspondingQuality; } if (((NPC)dealEvent.dealer).Inventory.CanItemFit(defaultInstance)) { ((NPC)dealEvent.dealer).Inventory.InsertItem(defaultInstance, true); } } ContractInfo val7 = val2.TryGenerateContract((Dealer)(object)dealEvent.dealer); if (val7 != null) { int offeredDeals = val2.OfferedDeals; val2.OfferedDeals = offeredDeals + 1; val2.TimeSinceLastDealOffered = 0; val2.OfferedContractInfo = val7; val2.OfferedContractTime = NetworkSingleton.Instance.GetDateTime(); val2.HasChanged = true; EDealWindow dealWindow = ((Dealer)dealEvent.dealer).GetDealWindow(); Contract val8 = val2.ContractAccepted(dealWindow, false, (Dealer)(object)dealEvent.dealer); ((Quest)val8).CompletionXP = 0; val8.completedContractsIncremented = false; ((Dealer)dealEvent.dealer).AddContract(val8); } else { ((CartelActivity)dealEvent).Deactivate(); } } yield return null; } } [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 { [Serializable] public class StolenNPCSerialized { public string npcID; public int sampleChancesProcessed; } [Serializable] public class SerializedStolenNPCs { public List stolenCustomers; } public class StolenNPC { public NPC npc; public int sampleChancesProcessed = -1; } public static List stolenNPCs = new List(); public static List playerMessageTemplates = new List { "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() { if (CartelEnforcer.currentConfig.stealBackCustomers) { CartelEnforcer.coros.Add(MelonCoroutines.Start(WaitSleepEndTrySteal())); } } public static IEnumerator WaitSleepEndTrySteal() { yield return CartelEnforcer.Wait30; yield return (object)new WaitUntil(Func.op_Implicit((Func)(() => !CartelEnforcer.isSaving && !Singleton.Instance.IsSaving))); if (!CartelEnforcer.registered || !CartelEnforcer.currentConfig.stealBackCustomers || !InstanceFinder.NetworkManager.IsServer || (int)NetworkSingleton.Instance.Status != 2) { yield break; } float num = 0f; Enumerator enumerator = NetworkSingleton.Instance.Influence.regionInfluence.GetEnumerator(); while (enumerator.MoveNext()) { RegionInfluenceData current = enumerator.Current; num += current.Influence; } float num2 = num / (float)NetworkSingleton.Instance.Influence.regionInfluence.Count; if (num2 > 0f && num2 <= 0.66f) { if ((int)NetworkSingleton.Instance.CurrentDay != 1 && (int)NetworkSingleton.Instance.CurrentDay != 4 && (int)NetworkSingleton.Instance.CurrentDay != 6) { yield break; } } else if (num2 > 0.66f && num2 < 0.8f) { if ((int)NetworkSingleton.Instance.CurrentDay != 1 && (int)NetworkSingleton.Instance.CurrentDay != 4) { yield break; } } else if ((int)NetworkSingleton.Instance.CurrentDay != 4) { yield break; } CartelEnforcer.coros.Add(MelonCoroutines.Start(StealCustomerWithDelay(num2))); } public static IEnumerator StealCustomerWithDelay(float cartelInfluence) { List unlocked = new List(); Enumerator enumerator = Customer.UnlockedCustomers.GetEnumerator(); while (enumerator.MoveNext()) { Customer current = enumerator.Current; if (!unlocked.Contains(current)) { unlocked.Add(current); } } if (unlocked.Count <= 18) { yield break; } int subtrahend = Random.Range(3, 6); int i = Mathf.Clamp(unlocked.Count - subtrahend, 0, unlocked.Count - 1); int maxCustomersChecked = 5; int maxSuccesfulStolen = 2; int currentCustomersChecked = 0; int currentStolen = 0; EMapRegion region1StolenFrom = (EMapRegion)0; while (CartelEnforcer.registered && i >= 0 && currentStolen < maxSuccesfulStolen && currentCustomersChecked < maxCustomersChecked) { Customer val = unlocked[i]; if (CanStealCustomer(val.NPC, cartelInfluence) && region1StolenFrom != val.NPC.Region) { StealCustomer(val.NPC); currentStolen++; region1StolenFrom = val.NPC.Region; } i = Mathf.Clamp(i - subtrahend, 0, unlocked.Count - 1); subtrahend = Random.Range(3, 6); currentCustomersChecked++; yield return CartelEnforcer.Wait05; } yield return null; } 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(); 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 list = new List(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(); 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.Instance.PlayPopup(component); ((TMP_Text)Singleton.Instance.Title).text = "Customer has been stolen by Cartel!"; CartelEnforcer.coros.Add(MelonCoroutines.Start(LateSendMessage(npc))); } public static IEnumerator LateSendMessage(NPC npc) { if (Random.Range(0f, 1f) > 0.5f) { yield return CartelEnforcer.Wait30; } else { yield return CartelEnforcer.Wait10; } if (CartelEnforcer.registered) { npc.MSGConversation.SendMessage(new Message(playerMessageTemplates[Random.Range(0, playerMessageTemplates.Count)], (ESenderType)1, true, -1), true, true); } } } [HarmonyPatch(typeof(Customer), "SampleConsumed")] public static class Customer_SampleConsumed_Patch { [HarmonyPrefix] public static bool Prefix(Customer __instance) { if (!CartelEnforcer.currentConfig.stealBackCustomers) { return true; } if (StealBackCustomer.stolenNPCs.Count == 0) { return true; } List list = new List(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) { return true; } stolenNPC.sampleChancesProcessed++; return true; } } [HarmonyPatch(typeof(Customer), "GetSampleSuccess")] public static class Customer_GetSampleSuccess_Patch { [HarmonyPostfix] public static void Postfix(Customer __instance, ref float __result) { if (!CartelEnforcer.currentConfig.stealBackCustomers || StealBackCustomer.stolenNPCs.Count == 0) { return; } List list = new List(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))); } } } } [HarmonyPatch(typeof(Customer), "SampleWasSufficient")] public static class Customer_SampleWasSufficient_Patch { [HarmonyPrefix] public static bool Prefix(Customer __instance) { if (!CartelEnforcer.currentConfig.stealBackCustomers) { return true; } if (StealBackCustomer.stolenNPCs.Count == 0) { return true; } StealBackCustomer.StolenNPC stolenNPC = StealBackCustomer.stolenNPCs.First((StealBackCustomer.StolenNPC x) => (Object)(object)x.npc == (Object)(object)__instance.NPC); if (stolenNPC != null) { StealBackCustomer.stolenNPCs.Remove(stolenNPC); } return true; } } public class CartelRegActivityHours { public int cartelActivityClass; public int hoursUntilEnable; } [Serializable] public class EventFrequencyConfig { public List events; public void InitializeDefault() { events = new List(); events.Add(new EventFrequency { Identifier = "Ambush", CooldownHours = 0, InfluenceRequirement = -1f, RandomTimeRangePercentage = 0f }); events.Add(new EventFrequency { Identifier = "RegionActivity", CooldownHours = 0, InfluenceRequirement = -1f, RandomTimeRangePercentage = 0f }); events.Add(new EventFrequency { Identifier = "StealDeadDrop", CooldownHours = 0, InfluenceRequirement = -1f, RandomTimeRangePercentage = 0f }); events.Add(new EventFrequency { Identifier = "CartelCustomerDeal", CooldownHours = 0, InfluenceRequirement = -1f, RandomTimeRangePercentage = 0f }); events.Add(new EventFrequency { Identifier = "RobDealer", CooldownHours = 0, InfluenceRequirement = -1f, RandomTimeRangePercentage = 0f }); events.Add(new EventFrequency { Identifier = "SprayGraffiti", CooldownHours = 0, InfluenceRequirement = -1f, RandomTimeRangePercentage = 0f }); events.Add(new EventFrequency { Identifier = "CartelPlayerDeal", CooldownHours = 0, InfluenceRequirement = -1f, RandomTimeRangePercentage = 0f }); events.Add(new EventFrequency { Identifier = "DriveBy", CooldownHours = 0, InfluenceRequirement = -1f, RandomTimeRangePercentage = 0f }); events.Add(new EventFrequency { Identifier = "InterceptDeals", CooldownHours = 0, InfluenceRequirement = -1f, RandomTimeRangePercentage = 0f }); events.Add(new EventFrequency { Identifier = "Gathering", CooldownHours = 0, InfluenceRequirement = -1f, RandomTimeRangePercentage = 0f }); events.Add(new EventFrequency { Identifier = "Sabotage", CooldownHours = 0, InfluenceRequirement = -1f, RandomTimeRangePercentage = 0f }); } } [Serializable] public class EventFrequency { public string Identifier = ""; public int CooldownHours; public float InfluenceRequirement; public float RandomTimeRangePercentage = 0.15f; } [Serializable] public class CurrentEventCooldowns { public int StealDeadDropCooldown; public int CartelCustomerDealCooldown; public int RobDealerCooldown; public int SprayGraffitiCooldown; public int DriveByCooldown; public int GatheringCooldown; public int InterceptDealsCooldown; public Dictionary SabotageCooldowns; public void InitializeDefault() { StealDeadDropCooldown = FrequencyOverrides.GetActivityHours("StealDeadDrop"); CartelCustomerDealCooldown = FrequencyOverrides.GetActivityHours("CartelCustomerDeal"); RobDealerCooldown = FrequencyOverrides.GetActivityHours("RobDealer"); SprayGraffitiCooldown = FrequencyOverrides.GetActivityHours("SprayGraffiti"); int activityHours = FrequencyOverrides.GetActivityHours("DriveBy"); DriveByCooldown = ((activityHours != 0) ? activityHours : Random.Range(24, 68)); int activityHours2 = FrequencyOverrides.GetActivityHours("Gathering"); GatheringCooldown = ((activityHours2 != 0) ? activityHours2 : Random.Range(6, 15)); int activityHours3 = FrequencyOverrides.GetActivityHours("InterceptDeals"); InterceptDealsCooldown = ((activityHours3 != 0) ? activityHours3 : Random.Range(2, 8)); int activityHours4 = FrequencyOverrides.GetActivityHours("Sabotage"); activityHours4 = ((activityHours4 != 0) ? activityHours4 : Random.Range(16, 64)); SabotageCooldowns = new Dictionary { { "Laundromat", activityHours4 }, { "Post Office", activityHours4 }, { "Taco Ticklers", activityHours4 } }; } } public static class FrequencyOverrides { public static EventFrequencyConfig frequencyConfig; public static List regActivityHours = new List(); public static readonly List SupportedEventIdentifiers = new List { "Ambush", "RegionActivity", "StealDeadDrop", "CartelCustomerDeal", "RobDealer", "SprayGraffiti", "CartelPlayerDeal", "DriveBy", "InterceptDeals", "Gathering", "Sabotage" }; public static void InitFrequencyOverrides() { regActivityHours.Add(new CartelRegActivityHours { cartelActivityClass = 0, hoursUntilEnable = CartelEnforcer.eventCooldowns.StealDeadDropCooldown }); regActivityHours.Add(new CartelRegActivityHours { cartelActivityClass = 1, hoursUntilEnable = CartelEnforcer.eventCooldowns.CartelCustomerDealCooldown }); regActivityHours.Add(new CartelRegActivityHours { cartelActivityClass = 2, hoursUntilEnable = CartelEnforcer.eventCooldowns.RobDealerCooldown }); regActivityHours.Add(new CartelRegActivityHours { cartelActivityClass = 3, hoursUntilEnable = CartelEnforcer.eventCooldowns.SprayGraffitiCooldown }); DriveByEvent.hoursUntilDriveBy = CartelEnforcer.eventCooldowns.DriveByCooldown; CartelGathering.hoursUntilNextGathering = CartelEnforcer.eventCooldowns.GatheringCooldown; InterceptEvent.hoursUntilInterceptEvent = CartelEnforcer.eventCooldowns.InterceptDealsCooldown; if (CartelEnforcer.eventCooldowns.SabotageCooldowns != null && CartelEnforcer.eventCooldowns.SabotageCooldowns.Count > 0) { try { SabotageEvent.locations.ForEach(delegate(SabotageEvent.SabotageEventLocation x) { x.hoursUntilEnabled = CartelEnforcer.eventCooldowns.SabotageCooldowns.First((KeyValuePair y) => y.Key == ((Property)x.business).propertyName).Value; }); } catch (Exception) { } } Enumerator enumerator = NetworkSingleton.Instance.Activities.GlobalActivities.GetEnumerator(); while (enumerator.MoveNext()) { CartelActivity current = enumerator.Current; float influenceRequirement = GetByID("Ambush").InfluenceRequirement; if (influenceRequirement >= 0f) { current.InfluenceRequirement = influenceRequirement; } } CartelRegionActivities[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)NetworkSingleton.Instance.Activities.RegionalActivities); for (int num = 0; num < array.Length; num++) { enumerator = array[num].Activities.GetEnumerator(); while (enumerator.MoveNext()) { CartelActivity current2 = enumerator.Current; float influenceRequirement2 = GetByID(((MemberInfo)((Object)current2).GetIl2CppType()).Name).InfluenceRequirement; if (influenceRequirement2 >= 0f) { current2.InfluenceRequirement = influenceRequirement2; } } } } public static int GetActivityHours(string identifier) { EventFrequency byID = GetByID(identifier); _ = byID.RandomTimeRangePercentage; int num = Mathf.RoundToInt((float)byID.CooldownHours * (1f + byID.RandomTimeRangePercentage)); int num2 = Mathf.Clamp(Mathf.RoundToInt((float)byID.CooldownHours * (1f - byID.RandomTimeRangePercentage)), 1, num - 1); if (byID.CooldownHours != 0) { return Random.Range(num2, num); } return byID.CooldownHours; } public static EventFrequency GetByID(string identifier) { return frequencyConfig.events.First((EventFrequency x) => SupportedEventIdentifiers.Contains(x.Identifier) && x.Identifier == identifier); } public static void OnHourPassReduceCartelRegActHours() { if (regActivityHours == null || regActivityHours.Count == 0 || Singleton.Instance.IsSaving || CartelEnforcer.isSaving) { return; } foreach (CartelRegActivityHours regActivityHour in regActivityHours) { if (regActivityHour.hoursUntilEnable > 0) { regActivityHour.hoursUntilEnable--; } } } } [HarmonyPatch(typeof(CartelDealManager), "CompleteDeal")] public static class CartelDealManager_CompleteDeal_Patch { [HarmonyPostfix] public static void Postfix(CartelDealManager __instance) { int activityHours = FrequencyOverrides.GetActivityHours("CartelPlayerDeal"); __instance.HoursUntilNextDealRequest = ((activityHours != 0) ? activityHours : __instance.HoursUntilNextDealRequest); } } [HarmonyPatch(typeof(CartelActivities), "TryStartActivity")] public static class CartelActivities_TryStartActivityPatch { private static readonly string name = "TryStartGlobalActivity"; [HarmonyPrefix] public static bool Prefix(CartelActivities __instance) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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) int activityHours = FrequencyOverrides.GetActivityHours("Ambush"); if (activityHours == 0) { __instance.HoursUntilNextGlobalActivity = CartelActivities.GetNewCooldown(); } else { __instance.HoursUntilNextGlobalActivity = activityHours; } if (!__instance.CanNewActivityBegin()) { return false; } List list = new List(); List list2 = new List(); Enumerator enumerator = __instance.GetActivitiesReadyToStart().GetEnumerator(); while (enumerator.MoveNext()) { CartelActivity current = enumerator.Current; list.Add(current); } Enumerator enumerator2 = __instance.GetValidRegionsForActivity().GetEnumerator(); while (enumerator2.MoveNext()) { EMapRegion current2 = enumerator2.Current; list2.Add(current2); } if (list.Count == 0 || list2.Count == 0) { return false; } list2.Sort((EMapRegion a, EMapRegion b) => NetworkSingleton.Instance.Influence.GetInfluence(b).CompareTo(NetworkSingleton.Instance.Influence.GetInfluence(a))); bool flag = false; EMapRegion currentRegion = Player.Local.CurrentRegion; if (list2.Contains(currentRegion)) { flag = true; list2.Remove(currentRegion); list2.Insert(0, currentRegion); } EMapRegion val = (EMapRegion)0; bool flag2 = false; if (!CartelEnforcer.currentConfig.debugMode) { foreach (EMapRegion item in list2) { float influence = NetworkSingleton.Instance.Influence.GetInfluence(item); float num = 0f; float num2 = 0f; num = AmbushOverrides.ambushSettings.AmbushTriggerProbability; num2 = influence * num; if (Random.Range(0f, 1f) < num2) { val = item; flag2 = true; break; } } if (!flag2) { return false; } } else { flag2 = true; val = Player.Local.CurrentRegion; } int count = list.Count; bool flag3 = false; do { count = list.Count; if (count == 0) { break; } int num3 = 0; if (flag) { num3 = (flag3 ? Random.Range(0, count) : 0); flag3 = true; } else { num3 = Random.Range(0, count); } if (list[num3].IsRegionValidForActivity(val)) { NetworkSingleton.Instance.Activities.StartGlobalActivity((NetworkConnection)null, val, 0); if (activityHours == 0) { __instance.HoursUntilNextGlobalActivity = CartelActivities.GetNewCooldown(); } else { __instance.HoursUntilNextGlobalActivity = activityHours; } break; } list.Remove(list[num3]); } while (count != 0); list.Clear(); list2.Clear(); return false; } } [HarmonyPatch(typeof(CartelRegionActivities), "TryStartActivity")] public static class CartelRegionActivities_TryStartActivityPatch { private static readonly string name = "TryStartRegionActivity"; [HarmonyPrefix] public static bool Prefix(CartelRegionActivities __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) Dictionary> dictionary = new Dictionary>(); int activityHours = FrequencyOverrides.GetActivityHours("RegionActivity"); if (activityHours == 0) { __instance.HoursUntilNextActivity = CartelRegionActivities.GetNewCooldown(__instance.Region); } else { __instance.HoursUntilNextActivity = activityHours; } Enumerator enumerator = __instance.Activities.GetEnumerator(); while (enumerator.MoveNext()) { CartelActivity current = enumerator.Current; int actInt = 0; string text = ""; if ((Object)(object)((Il2CppObjectBase)current).TryCast() != (Object)null) { actInt = 0; text = "StealDeadDrop"; } else if ((Object)(object)((Il2CppObjectBase)current).TryCast() != (Object)null) { actInt = 1; text = "CartelCustomerDeal"; } else if ((Object)(object)((Il2CppObjectBase)current).TryCast() != (Object)null) { actInt = 2; text = "RobDealer"; } else { actInt = 3; text = "SprayGraffiti"; } CartelRegActivityHours cartelRegActivityHours = FrequencyOverrides.regActivityHours.First((CartelRegActivityHours x) => x.cartelActivityClass == actInt); if (cartelRegActivityHours != null && cartelRegActivityHours.hoursUntilEnable <= 0) { dictionary.Add(current, new Tuple(actInt, text)); } } if (dictionary.Count == 0) { dictionary.Clear(); return false; } int count = dictionary.Count; do { count = dictionary.Count; if (count == 0) { break; } KeyValuePair> keyValuePair = dictionary.ElementAt(Random.Range(0, count)); if (keyValuePair.Key.IsRegionValidForActivity(__instance.Region)) { __instance.StartActivity((NetworkConnection)null, __instance.Activities.IndexOf(keyValuePair.Key)); FrequencyOverrides.regActivityHours[keyValuePair.Value.Item1].hoursUntilEnable = FrequencyOverrides.GetActivityHours(keyValuePair.Value.Item2); break; } dictionary.Remove(keyValuePair.Key); } while (count != 0); dictionary.Clear(); dictionary = null; return false; } } public static class InfluenceOverrides { 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) bool result = false; if ((int)NetworkSingleton.Instance.Status != 2) { result = false; } Enumerator enumerator = Singleton.Instance.GetUnlockedRegions().GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Current == region && InstanceFinder.IsServer) { result = true; break; } } if ((int)region == 0) { result = false; } return result; } public static IEnumerator OnDayChangeApplyPassiveGain() { foreach (MapRegionData region in (Il2CppArrayBase)(object)Singleton.Instance.Regions) { yield return CartelEnforcer.Wait05; if (ShouldChangeInfluence(region.Region)) { NetworkSingleton.Instance.Influence.ChangeInfluence(region.Region, CartelEnforcer.influenceConfig.passiveInfluenceGainPerDay); } } yield return null; } public static void OnDayPassChangePassive() { if (CartelEnforcer.influenceConfig.passiveInfluenceGainPerDay != 0f) { 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.Instance.Status != 2) { return false; } NetworkSingleton.Instance.Influence.ChangeInfluence(((NPC)__instance).Region, CartelEnforcer.influenceConfig.cartelDealerDied); return false; } } [HarmonyPatch(typeof(Ambush), "SpawnAmbush")] public static class Ambush_SpawnAmbush_Patch { public static bool Prefix(Ambush __instance, Player target, Vector3[] potentialSpawnPoints) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) List spawnedGoons = NetworkSingleton.Instance.GoonPool.spawnedGoons; List list = new List(spawnedGoons.Count); Enumerator enumerator = spawnedGoons.GetEnumerator(); while (enumerator.MoveNext()) { CartelGoon current = enumerator.Current; list.Add(current); } List currentlySpawned = list; CartelEnforcer.coros.Add(MelonCoroutines.Start(OverMonitorAmbush(potentialSpawnPoints, currentlySpawned, ((CartelActivity)__instance).Region))); return true; } public static IEnumerator OverMonitorAmbush(Vector3[] potentialSpawnPoints, List currentlySpawned, EMapRegion region) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) List ambushSpawned = new List(); yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { yield break; } if (NetworkSingleton.Instance.GoonPool.spawnedGoons.Count != currentlySpawned.Count) { Enumerator enumerator = NetworkSingleton.Instance.GoonPool.spawnedGoons.GetEnumerator(); while (enumerator.MoveNext()) { CartelGoon current = enumerator.Current; if (current.IsGoonSpawned && !((NPC)current).Health.IsDead && !((NPC)current).Health.IsKnockedOut) { bool flag = false; if (((Behaviour)((NPC)current).Behaviour.CombatBehaviour).Active && ((NPC)current).Behaviour.CombatBehaviour.Target != null) { flag = true; } bool flag2 = false; if ((Object)(object)SabotageEvent.sabotager != (Object)null && (Object)(object)current == (Object)(object)SabotageEvent.sabotager) { flag2 = true; } if (!currentlySpawned.Contains(current) && !ambushSpawned.Contains(current) && !CartelGathering.spawnedGatherGoons.Contains(current) && !flag2 && flag) { ambushSpawned.Add(current); } } } } if (ambushSpawned.Count == 0) { yield break; } foreach (CartelGoon item in ambushSpawned) { _ = item; } float maxAmbushElapsed = Ambush.CANCEL_AMBUSH_AFTER_MINS; float elapsed = 0f; List deadGoons = new List(); int spawnedCount = ambushSpawned.Count; while (CartelEnforcer.registered && elapsed < maxAmbushElapsed && ambushSpawned.Count != 0 && deadGoons.Count != spawnedCount) { foreach (CartelGoon goon in ambushSpawned) { yield return CartelEnforcer.Wait05; elapsed += 0.5f; if (!deadGoons.Contains(goon) && (((NPC)goon).Health.IsDead || ((NPC)goon).Health.IsKnockedOut)) { deadGoons.Add(goon); } } foreach (CartelGoon goon in deadGoons) { yield return CartelEnforcer.Wait05; elapsed += 0.5f; if (ambushSpawned.Contains(goon)) { ambushSpawned.Remove(goon); } } } yield return CartelEnforcer.Wait01; if ((ambushSpawned.Count == 0 || deadGoons.Count == spawnedCount) && InstanceFinder.IsServer) { float num = 0f - Ambush.AMBUSH_DEFEATED_INFLUENCE_CHANGE + CartelEnforcer.influenceConfig.ambushDefeated; if (num != 0f) { NetworkSingleton.Instance.Influence.ChangeInfluence(region, num); } } ambushSpawned.Clear(); deadGoons.Clear(); } } [HarmonyPatch(typeof(WorldSpraySurface), "Reward")] public static class WorldSpraySurface_Reward_Patch { public static bool Prefix(WorldSpraySurface __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 NetworkSingleton.Instance.AddXP(50); if (!InstanceFinder.IsServer) { return false; } if ((int)NetworkSingleton.Instance.Status != 2 || (CartelEnforcer.currentConfig.alliedExtensions && (int)NetworkSingleton.Instance.Status == 1)) { NetworkSingleton.Instance.Influence.ChangeInfluence(__instance.Region, CartelEnforcer.influenceConfig.graffitiInfluenceReduction); } return false; } } [HarmonyPatch(typeof(Customer), "OnCustomerUnlocked")] public static class Customer_OnCustomerUnlocked_Patch { public static bool Prefix(Customer __instance, EUnlockType unlockType, bool notify) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0145: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if (!notify || !NetworkSingleton.InstanceExists) { return true; } bool flag = (int)NetworkSingleton.Instance.Status == 2; bool flag2 = (int)NetworkSingleton.Instance.Status == 1; if (flag || flag2) { if (flag2 && !CartelEnforcer.currentConfig.alliedExtensions) { return true; } if (flag) { if (CartelEnforcer.currentConfig.stealBackCustomers) { List list = new List(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) { float num = 0f - Customer.CUSTOMER_UNLOCKED_CARTEL_INFLUENCE_CHANGE + CartelEnforcer.influenceConfig.customerUnlockInfluenceChange * 0.5f; if (num != 0f && (int)__instance.NPC.Region != 0) { NetworkSingleton.Instance.Influence.ChangeInfluence(__instance.NPC.Region, num); } } } else { float num2 = 0f - Customer.CUSTOMER_UNLOCKED_CARTEL_INFLUENCE_CHANGE + CartelEnforcer.influenceConfig.customerUnlockInfluenceChange; if (num2 != 0f && (int)__instance.NPC.Region != 0) { NetworkSingleton.Instance.Influence.ChangeInfluence(__instance.NPC.Region, num2); } } } else if (flag2 && (int)__instance.NPC.Region != 0) { NetworkSingleton.Instance.Influence.ChangeInfluence(__instance.NPC.Region, CartelEnforcer.influenceConfig.customerUnlockInfluenceChange); } return true; } return true; } } public static class AlliedExtension { public static ConfigLoader.CartelAlliedConfig alliedConfig; public static ConfigLoader.CartelAlliedQuests alliedQuests; public static DialogueContainer persuadeContainer; public static DialogueNodeData entryNode; public static Dictionary dealersByRegion; public static void MakeMapPoI(Dealer dealer) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Object.Instantiate(((Component)NetworkSingleton.Instance.NPCPoIPrefab).gameObject); obj.transform.parent = ((Component)dealer).transform; obj.transform.localPosition = Vector3.zero; obj.transform.rotation = Quaternion.identity; NPCPoI component = obj.GetComponent(); component.NPC = (NPC)(object)dealer; ((POI)component).MainText = $"Cartel Dealer ({((NPC)dealer).Region})"; ((POI)component).InitializeUI(); dealer.DealerPoI = component; } public static IEnumerator DelayedStateChange(ECartelStatus oldStatus, ECartelStatus newStatus) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) yield return CartelEnforcer.Wait5; if ((int)oldStatus == 0 && (int)newStatus == 1) { NPC val = null; Enumerator enumerator = Dealer.AllPlayerDealers.GetEnumerator(); while (enumerator.MoveNext()) { Dealer current = enumerator.Current; if (((NPC)current).ID == "molly_presley") { val = (NPC)(object)current; } } _ = (Object)(object)val == (Object)null; CartelDealer[] allCartelDealers = DealerActivity.allCartelDealers; foreach (CartelDealer val2 in allCartelDealers) { AssignDealerConfig(val2); if (dealersByRegion.Count > 0) { if ((int)((NPC)val2).Region == 1) { ((NPC)val2).RelationData.Connections.Add(val); } else { EMapRegion key = (EMapRegion)(((NPC)val2).Region - 1); ((NPC)val2).RelationData.Connections.Add((NPC)(object)dealersByRegion[key]); } } CartelPersuade.AddPersuadeDialogue(val2); } if (!alliedQuests.alliedIntroCompleted && (Object)(object)EndGameQuest.activeTruceIntro == (Object)null) { yield return (object)new WaitUntil(Func.op_Implicit((Func)CanStart)); yield return CartelEnforcer.Wait05; CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.SetupTruceIntroQuest())); } } else if ((int)oldStatus == 1 && (int)newStatus == 2) { CartelDealer[] allCartelDealers = DealerActivity.allCartelDealers; foreach (CartelDealer val3 in allCartelDealers) { if (((Dealer)val3).IsRecruited) { ((Dealer)val3).IsRecruited = false; ((NPC)val3).NPCData.Inventory.ClearInventoryOnNewDay = true; if (((Dealer)val3).AssignedCustomers.Count == 0) { continue; } for (int num = ((Dealer)val3).AssignedCustomers.Count - 1; num >= 0; num--) { if ((Object)(object)((Dealer)val3).AssignedCustomers[num] != (Object)null) { ((Dealer)val3).RemoveCustomer(((Dealer)val3).AssignedCustomers[num]); } } } if (((Dealer)val3).HasBeenRecommended) { ((Dealer)val3).HasBeenRecommended = false; } if (((NPC)val3).RelationData.Unlocked) { ((NPC)val3).RelationData.Unlocked = false; } } } yield return null; static bool CanStart() { if (!Singleton.Instance.IsOpen && !Singleton.Instance.IsOpen) { return PlayerSingleton.Instance.ActiveUIElementCount <= 0; } return false; } } public static void OnAlliedStateChange(ECartelStatus oldStatus, ECartelStatus newStatus) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (CartelEnforcer.currentConfig.alliedExtensions) { CartelEnforcer.coros.Add(MelonCoroutines.Start(DelayedStateChange(oldStatus, newStatus))); } } public static IEnumerator SetupAlliedExtension() { yield return CartelEnforcer.Wait10; alliedConfig = ConfigLoader.LoadAlliedConfig(); alliedQuests = ConfigLoader.LoadAlliedQuests(); persuadeContainer = CartelPersuade.InitPersuadeContainer(); SuppliesModule.InitSuppliesModule(); NetworkSingleton.Instance.onMinutePass.Add(Action.op_Implicit((Action)CartelPersuade.ReduceCooldown)); TimeManager instance = NetworkSingleton.Instance; instance.onHourPass += Action.op_Implicit((Action)SuppliesModule.OnHourPassEvaluateSupply); TimeManager instance2 = NetworkSingleton.Instance; instance2.onHourPass += Action.op_Implicit((Action)OnHourPassTrySpawnEncounter); TimeManager instance3 = NetworkSingleton.Instance; instance3.onSleepEnd += Action.op_Implicit((Action)OnSleepEndIncreaseEncounterChance); if ((int)NetworkSingleton.Instance.Status == 0 || (int)NetworkSingleton.Instance.Status == 1) { Cartel instance4 = NetworkSingleton.Instance; instance4.OnStatusChange += Action.op_Implicit((Action)OnAlliedStateChange); } if (DealerActivity.allCartelDealers == null) { DealerActivity.allCartelDealers = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType(true)); } if (DealerActivity.allCartelDealers == null || DealerActivity.allCartelDealers.Length == 0) { yield break; } NPC val = null; Enumerator enumerator = Dealer.AllPlayerDealers.GetEnumerator(); while (enumerator.MoveNext()) { Dealer current = enumerator.Current; if (((NPC)current).ID == "molly_presley") { val = (NPC)(object)current; } } dealersByRegion = new Dictionary(); CartelDealer[] allCartelDealers = DealerActivity.allCartelDealers; foreach (CartelDealer val2 in allCartelDealers) { EMapRegion region = ((NPC)val2).Region; switch (region - 1) { case 0: dealersByRegion.Add((EMapRegion)1, val2); break; case 1: dealersByRegion.Add((EMapRegion)2, val2); break; case 2: dealersByRegion.Add((EMapRegion)3, val2); break; case 3: dealersByRegion.Add((EMapRegion)4, val2); break; case 4: dealersByRegion.Add((EMapRegion)5, val2); break; } } if ((int)NetworkSingleton.Instance.Status == 1) { bool flag = false; allCartelDealers = DealerActivity.allCartelDealers; foreach (CartelDealer val3 in allCartelDealers) { AssignDealerConfig(val3); ((NPC)val3).NPCData.Appearance.Mugshot = InterceptEvent.benziesLogo; ((NPC)val3).NPCData.BasicInfo.FirstName = $"{((NPC)val3).FirstName} ({((NPC)val3).Region})"; if ((int)((NPC)val3).Region == 1 && ((Dealer)val3).IsRecruited) { flag = true; } if (((Dealer)val3).IsRecruited) { ((NPC)val3).NPCData.Inventory.ClearInventoryOnNewDay = false; } else if (!((Dealer)val3).IsRecruited && !((Dealer)val3).HasBeenRecommended) { CartelPersuade.AddPersuadeDialogue(val3); } } foreach (KeyValuePair item in dealersByRegion) { if ((int)item.Key == 1) { ((NPC)dealersByRegion[item.Key]).RelationData.Connections.Add(val); } else { EMapRegion key = (EMapRegion)(item.Key - 1); ((NPC)dealersByRegion[item.Key]).RelationData.Connections.Add((NPC)(object)dealersByRegion[key]); } if (!((Dealer)item.Value).IsRecruited && ((Dealer)item.Value).HasBeenRecommended) { ((Dealer)item.Value).SetUpDialogue(); } if (((Dealer)item.Value).IsRecruited) { MakeMapPoI((Dealer)(object)item.Value); } } if (!alliedQuests.alliedIntroCompleted && (Object)(object)EndGameQuest.activeTruceIntro == (Object)null && !flag) { CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.SetupTruceIntroQuest())); } } yield return null; } public static bool IsTrucedDialogueEnabled() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if ((int)NetworkSingleton.Instance.Status != 1) { return CartelEnforcer.currentConfig.debugMode; } return true; } public static void OnHourPassTrySpawnEncounter() { if (!EndGameQuest.trueBrothersCompleted && !((Object)(object)EndGameQuest.activeTrueBrothersQuest != (Object)null) && !EndGameQuest.encounterActive && NetworkSingleton.Instance.CurrentTime >= 1100 && NetworkSingleton.Instance.CurrentTime <= 2300 && !((Object)(object)Player.Local.CurrentProperty != (Object)null) && EndGameQuest.TrueBrothersQuestPreRequirementsMet()) { float num = Random.Range(0f, 1f); float num2 = Mathf.Lerp(0.98f, 0.7f, Mathf.Clamp01((float)alliedQuests.daysPassedSinceEncounter / 7f)); if (!(num < num2)) { CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.SummonConversateGoon())); } } } public static void OnSleepEndIncreaseEncounterChance() { if (EndGameQuest.TrueBrothersQuestPreRequirementsMet()) { alliedQuests.daysPassedSinceEncounter++; } } public static void AssignDealerConfig(CartelDealer d) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected I4, but got Unknown EMapRegion region = ((NPC)d).Region; switch (region - 1) { case 0: ((Dealer)d).DealerData.SalesCutPercentage = alliedConfig.WestvilleCartelDealerCut; ((Dealer)d).DealerData.SigningFee = alliedConfig.WestvilleCartelSigningFee; break; case 1: ((Dealer)d).DealerData.SalesCutPercentage = alliedConfig.DowntownCartelDealerCut; ((Dealer)d).DealerData.SigningFee = alliedConfig.DowntownCartelSigningFee; break; case 2: ((Dealer)d).DealerData.SalesCutPercentage = alliedConfig.DocksCartelDealerCut; ((Dealer)d).DealerData.SigningFee = alliedConfig.DocksCartelSigningFee; break; case 3: ((Dealer)d).DealerData.SalesCutPercentage = alliedConfig.SuburbiaCartelDealerCut; ((Dealer)d).DealerData.SigningFee = alliedConfig.SuburbiaCartelSigningFee; break; case 4: ((Dealer)d).DealerData.SalesCutPercentage = alliedConfig.UptownCartelDealerCut; ((Dealer)d).DealerData.SigningFee = alliedConfig.UptownCartelSigningFee; break; default: ((Dealer)d).DealerData.SalesCutPercentage = 99f; ((Dealer)d).DealerData.SigningFee = 9999f; break; } } } [HarmonyPatch(typeof(CartelDealManager), "ExpireDeal")] public static class CartelDealManager_ExpireDeal_Patch { [HarmonyPrefix] public static bool Prefix(CartelDealManager __instance) { if (!CartelEnforcer.currentConfig.alliedExtensions) { return true; } ((Quest)__instance.DealQuest).Expire(true); __instance.SendExpiryMessage(); __instance.ActiveDeal = null; return false; } } [HarmonyPatch(typeof(CartelInfluenceChangePopup), "Show")] public static class CartelInfluenceChangePopup_Show_Patch { public static bool showEnqueued; [HarmonyPrefix] public static bool Prefix(CartelInfluenceChangePopup __instance, EMapRegion region, float oldInfluence, float newInfluence) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (!CartelEnforcer.currentConfig.alliedExtensions) { return true; } if ((int)NetworkSingleton.Instance.Status != 1) { return true; } if (Singleton.Instance.IsLoading) { return false; } if (newInfluence >= oldInfluence) { return false; } if (!showEnqueued) { showEnqueued = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(InfluenceChangeAnimation(__instance, region, oldInfluence, newInfluence))); } return false; } public static bool CanShowInfluenceChange() { if (!Singleton.Instance.IsOpen && !Singleton.Instance.IsPlaying) { return !Singleton.Instance.IsPlaying; } return false; } public static IEnumerator InfluenceChangeAnimation(CartelInfluenceChangePopup __instance, EMapRegion region, float oldInfluence, float newInfluence) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) yield return (object)new WaitUntil(Func.op_Implicit((Func)CanShowInfluenceChange)); yield return (object)new WaitForSeconds(0.5f); __instance.SetDisplayedInfluence(oldInfluence); ((TMP_Text)__instance.TitleLabel).text = $"Benzies' Influence in {region}"; __instance.Anim.Play(); yield return (object)new WaitForSeconds(0.8f); float elapsed = 0f; while (elapsed <= 1.5f) { elapsed += Time.deltaTime; float displayedInfluence = Mathf.Lerp(oldInfluence, newInfluence, elapsed / 1.5f); __instance.SetDisplayedInfluence(displayedInfluence); yield return (object)new WaitForEndOfFrame(); } __instance.SetDisplayedInfluence(newInfluence); showEnqueued = false; yield return null; } } [HarmonyPatch(typeof(ContactsApp), "SetSelectedRegion")] public static class ContactsApp_SetSelectedRegion_Patch { [HarmonyPostfix] public unsafe static void Postfix(ContactsApp __instance, EMapRegion region, bool selectNPC) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Invalid comparison between Unknown and I4 //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) if (!CartelEnforcer.currentConfig.alliedExtensions || (int)NetworkSingleton.Instance.Status != 1 || (int)region == 0) { return; } float influence = NetworkSingleton.Instance.Influence.GetInfluence(region); ((Component)__instance.LowerContainer).gameObject.SetActive(true); __instance.HorizontalScrollbarRectTransform.anchoredPosition = new Vector2(0f, 77f); ((Component)__instance.UnlockRegionSliderNotch).gameObject.SetActive(true); __instance.InfluenceSlider.value = influence; __instance.InfluenceCountLabel.text = Mathf.RoundToInt(influence * 1000f) + " / 1000"; __instance.InfluenceText.text = "Cartel influence in " + ((object)(*(EMapRegion*)(®ion))/*cast due to .constrained prefix*/).ToString(); if (Singleton.Instance.GetRegionData(region).IsUnlocked) { return; } if ((int)region >= 3 && ((Component)__instance.RegionLocked_Unavailable).gameObject.activeSelf) { ((Component)__instance.RegionLocked_Unavailable).gameObject.SetActive(false); } ((Component)__instance.RegionLockedContainer).gameObject.SetActive(true); ((Component)__instance.RegionLocked_CartelInfluence).gameObject.SetActive(true); EMapRegion value = (EMapRegion)(region - 1); __instance.RegionLocked_CartelInfluence_Text.text = $"Reduce cartel influence in {value}\n\n\nto unlock this region."; Transform val = ((Component)__instance.RegionLocked_CartelInfluence_Text).transform.Find("CARTEL_ENFORCER_TEXT"); if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("CARTEL_ENFORCER_TEXT"); val2.transform.parent = ((Component)__instance.RegionLocked_CartelInfluence_Text).transform; Text val3 = val2.AddComponent(); val3.text = $"Or recruit the {value} Cartel Dealer"; RectTransform component = val2.GetComponent(); component.anchoredPosition = Vector2.zero; component.anchoredPosition3D = Vector3.zero; component.anchorMax = new Vector2(0.5f, 0.5f); component.anchorMin = new Vector2(0.5f, 0.5f); component.offsetMax = new Vector2(150.5f, 214.25f); component.offsetMin = new Vector2(-150.5f, -214.25f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(301f, 428.5f); val3.alignment = (TextAnchor)4; val3.fontSize = 28; val3.resizeTextMinSize = 0; ((Graphic)val3).color = new Color(1f, 0.23f, 0.23f, 0.7f); Transform val4 = ((Component)__instance.RegionLocked_CartelInfluence_Text).transform.Find("Rank"); if ((Object)(object)val4 != (Object)null) { Text component2 = ((Component)val4).GetComponent(); if ((Object)(object)component2 != (Object)null) { val3.font = component2.font; } } val2.transform.localEulerAngles = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; val2.transform.localPosition = new Vector3(0f, -105f, 0f); } else { ((Component)val).gameObject.GetComponent().text = $"Or recruit the {value} Cartel Dealer"; } } } [HarmonyPatch(typeof(Quest_DefeatCartel), "OnSleepEnd")] public static class Quest_DefeatCartel_OnSleepEnd_Patch { [HarmonyPrefix] public static bool Prefix(Quest_DefeatCartel __instance) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 if (!CartelEnforcer.currentConfig.alliedExtensions) { return true; } if ((int)((Quest)__instance).State == 0 && Singleton.Instance.GetRegionData((EMapRegion)5).IsUnlocked && ((int)NetworkSingleton.Instance.Status == 1 || (int)NetworkSingleton.Instance.Status == 2)) { ((Quest)__instance).Begin(true); } return true; } } public static class AlliedCartelDialogue { public static readonly List dealerEntryNodeTexts = new List { "You've got a lot of nerve showing up like this.", "What's your problem?", "What do you want?!", "Start talking or start walking young punk." }; public static readonly List alliedDialogueKeys = new List { "CLOTHING_SIMILARITY", "CARTEL_INFLUENCE", "THREATEN_CARTEL", "SPREAD_RUMOURS", "EXIT" }; public static readonly Dictionary> alliedDialogue = new Dictionary> { { alliedDialogueKeys[0], new List { "Check out my new drip.", "Same style, same goals, yeah?", "You're rocking the same vest?" } }, { alliedDialogueKeys[1], new List { "The Benzies are small time!", "Are the Benzies having it rough lately?", "The Benzies are a bunch of young punks." } }, { alliedDialogueKeys[2], new List { "Check the piece. You want a taste of lead?", "I'm packing some serious heat.", "You're about to get yo' ass whooped." } }, { alliedDialogueKeys[3], new List { "You know that Thomas has been talking to the cops right?", "I heard that Thomas is going to cut you out.", "Better watch out, that Thomas is a snake." } }, { alliedDialogueKeys[4], new List { "Nevermind.", "I got to go." } } }; public static Dictionary persuasionChances = new Dictionary { { alliedDialogueKeys[0], 0f }, { alliedDialogueKeys[1], 0f }, { alliedDialogueKeys[2], 0f }, { alliedDialogueKeys[3], 0f } }; public static readonly Dictionary persuasionBaseChances = new Dictionary { { alliedDialogueKeys[0], CartelPersuade.CLOTHING_SIMILARITY_BASE_CHANCE }, { alliedDialogueKeys[1], CartelPersuade.CARTEL_INFLUENCE_BASE_CHANCE }, { alliedDialogueKeys[2], CartelPersuade.THREATEN_CARTEL_BASE_CHANCE }, { alliedDialogueKeys[3], CartelPersuade.SPREAD_RUMOURS_BASE_CHANCE } }; } public static class CartelPersuade { public static readonly float CLOTHING_SIMILARITY_BASE_CHANCE = 0.01f; public static readonly float CLOTHING_SIMILARITY_MAX_CHANCE = 0.85f; public static readonly float CARTEL_INFLUENCE_BASE_CHANCE = 0.02f; public static readonly float CARTEL_INFLUENCE_MAX_CHANCE = 0.35f; public static readonly float THREATEN_CARTEL_BASE_CHANCE = 0.01f; public static readonly float THREATEN_CARTEL_MAX_CHANCE = 0.6f; public static readonly float SPREAD_RUMOURS_BASE_CHANCE = 0.03f; public static readonly float SPREAD_RUMOURS_MAX_CHANCE = 0.45f; public static int persuadeCooldown = 60; public static readonly float colorSimilarityThreshold = 0.2f; public static void ReduceCooldown() { if (CartelEnforcer.currentConfig.alliedExtensions && persuadeCooldown > 0) { persuadeCooldown--; } } public static DialogueContainer InitPersuadeContainer() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0094: 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_00c4: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown DialogueContainer val = ScriptableObject.CreateInstance(); ((Object)val).name = "CARTEL_ENFORCER_PERSUADE"; val.allowExit = true; val.BranchNodeData = new List(); val.DialogueNodeData = new List(); val.NodeLinks = new List(); AlliedExtension.entryNode = new DialogueNodeData(); AlliedExtension.entryNode.DialogueNodeLabel = "ENTRY"; AlliedExtension.entryNode.DialogueText = AlliedCartelDialogue.dealerEntryNodeTexts[Random.Range(0, AlliedCartelDialogue.dealerEntryNodeTexts.Count)]; AlliedExtension.entryNode.Guid = GetGuid(); AlliedExtension.entryNode.Position = new Vector2(-284f, 572f); AlliedExtension.entryNode.VoiceLine = (EVOLineType)1; AlliedExtension.entryNode.choices = Il2CppReferenceArray.op_Implicit((DialogueChoiceData[])(object)new DialogueChoiceData[2]); DialogueChoiceData val2 = new DialogueChoiceData(); val2.ChoiceLabel = "START_PERSUADE"; val2.ChoiceText = "[Persuade] Just hear me out. You could work for me instead."; val2.Guid = GetGuid(); val2.ShowWorldspaceDialogue = true; DialogueChoiceData val3 = new DialogueChoiceData(); val3.ChoiceLabel = "EXIT"; val3.ChoiceText = "Nevermind."; val3.Guid = GetGuid(); val3.ShowWorldspaceDialogue = true; ((Il2CppArrayBase)(object)AlliedExtension.entryNode.choices)[0] = val2; ((Il2CppArrayBase)(object)AlliedExtension.entryNode.choices)[1] = val3; DialogueNodeData val4 = new DialogueNodeData(); val4.DialogueNodeLabel = "ENTRY"; val4.DialogueText = "I'm not so sure about that..."; val4.Guid = GetGuid(); val4.Position = new Vector2(-284f, 572f); val4.VoiceLine = (EVOLineType)11; val4.choices = Il2CppReferenceArray.op_Implicit((DialogueChoiceData[])(object)new DialogueChoiceData[5]); for (int i = 0; i < 5; i++) { DialogueChoiceData val5 = new DialogueChoiceData(); val5.ChoiceLabel = AlliedCartelDialogue.alliedDialogueKeys[i]; val5.ChoiceText = AlliedCartelDialogue.alliedDialogue[AlliedCartelDialogue.alliedDialogueKeys[i]][0]; val5.Guid = GetGuid(); val5.ShowWorldspaceDialogue = true; ((Il2CppArrayBase)(object)val4.choices)[i] = val5; } NodeLinkData val6 = new NodeLinkData(); val6.BaseDialogueOrBranchNodeGuid = AlliedExtension.entryNode.Guid; val6.BaseChoiceOrOptionGUID = val2.Guid; val6.TargetNodeGuid = val4.Guid; val.DialogueNodeData.Add(AlliedExtension.entryNode); val.DialogueNodeData.Add(val4); val.NodeLinks.Add(val6); return val; static string GetGuid() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return ((object)Guid.NewGuid()/*cast due to .constrained prefix*/).ToString(); } } public static void AddPersuadeDialogue(CartelDealer d) { if (!((Object)(object)d == (Object)null)) { DialogueController component = ((Component)((NPC)d).DialogueHandler).GetComponent(); if (!((Object)(object)component == (Object)null)) { component.OverrideContainer = AlliedExtension.persuadeContainer; ((NPC)d).DialogueHandler.onConversationStart.AddListener(UnityAction.op_Implicit((Action)OnConversationStarted)); } } static void OnConversationStarted() { DialogueHandler.ActiveDialogueNode = AlliedExtension.entryNode; } } public static IEnumerator UpdatePersuadeCooldownText() { while ((Object)(object)DialogueHandler.ActiveDialogue != (Object)null && DialogueHandler.ActiveDialogueNode != null && ((Object)DialogueHandler.ActiveDialogue).name == "CARTEL_ENFORCER_PERSUADE" && DialogueHandler.ActiveDialogueNode.Guid == AlliedExtension.entryNode.Guid && Singleton.Instance.dialogueChoices.Count != 0) { DialogueChoiceEntry val = Singleton.Instance.dialogueChoices[0]; if (persuadeCooldown == 0 && val.NotPossibleGameObject.activeSelf) { val.NotPossibleGameObject.SetActive(false); ((Selectable)val.Button).interactable = true; ColorBlock colors = ((Selectable)val.Button).colors; ((ColorBlock)(ref colors)).disabledColor = ((ColorBlock)(ref colors)).pressedColor; ((Selectable)val.Button).colors = colors; ((Component)val.Label).GetComponent().offsetMax = new Vector2(0f, 0f); } else { string text = $"On cooldown: {persuadeCooldown}"; ((TMP_Text)val.NotPossibleText).text = text.ToUpper(); } yield return CartelEnforcer.Wait1; if (!CartelEnforcer.registered) { yield break; } } yield return null; } public static float ExpCurve(float baseVal, float maxVal, float t) { return baseVal * Mathf.Pow(maxVal / baseVal, t); } public static float CalculateClothingSimilarity(Dealer d) { //IL_00b0: 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_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) int num = 0; int num2 = 0; if ((Object)(object)Player.Local.Avatar.CurrentSettings == (Object)null) { return 0f; } AvatarSettings currentSettings = Player.Local.Avatar.CurrentSettings; for (int i = 0; i < ((NPC)d).Avatar.CurrentSettings.BodyLayerSettings.Count; i++) { LayerSetting val = ((NPC)d).Avatar.CurrentSettings.BodyLayerSettings[i]; if (val.layerPath == null || val.layerPath == string.Empty) { continue; } num++; for (int j = 0; j < currentSettings.BodyLayerSettings.Count; j++) { bool flag = false; bool flag2 = false; LayerSetting val2 = currentSettings.BodyLayerSettings[j]; if (val2.layerPath != null && !(val.layerPath == string.Empty)) { if (CalculateColorSimilarity(val.layerTint, val2.layerTint) > colorSimilarityThreshold) { flag = true; } if (ClothingPathMatches(val.layerPath, val2.layerPath)) { flag2 = true; } if (flag2 && flag) { num2++; break; } } } } for (int k = 0; k < ((Il2CppArrayBase)(object)((NPC)d).Avatar.appliedAccessories).Length; k++) { if ((Object)(object)((Il2CppArrayBase)(object)((NPC)d).Avatar.appliedAccessories)[k] == (Object)null) { continue; } num++; Accessory val3 = ((Il2CppArrayBase)(object)((NPC)d).Avatar.appliedAccessories)[k]; for (int l = 0; l < Player.Local.Avatar.CurrentSettings.AccessorySettings.Count; l++) { if (Player.Local.Avatar.CurrentSettings.AccessorySettings[l] != null) { bool flag3 = false; bool flag4 = false; AccessorySetting val4 = Player.Local.Avatar.CurrentSettings.AccessorySettings[l]; Color a = Color.black; if (((IEnumerable)val3.meshesToColor).Count() > 0) { a = ((Renderer)((Il2CppArrayBase)(object)val3.meshesToColor)[0]).material.color; } else if (((Il2CppArrayBase)(object)val3.skinnedMeshesToColor).Length > 0) { a = ((Renderer)((Il2CppArrayBase)(object)val3.skinnedMeshesToBind)[0]).material.color; } if (CalculateColorSimilarity(a, val4.color) < colorSimilarityThreshold) { flag3 = true; } if (ClothingPathMatches(val3.AssetPath, val4.path)) { flag4 = true; } if (flag4 && flag3) { num2++; break; } } } } if (num == 0) { return 0f; } float t = Mathf.Clamp01((float)num2 / (float)num * 1.2f); return ExpCurve(CLOTHING_SIMILARITY_BASE_CHANCE, CLOTHING_SIMILARITY_MAX_CHANCE, t); } public static float CalculateColorSimilarity(Color a, Color b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(new Vector3(a.r, a.g, a.b), new Vector3(b.r, b.g, b.b)) / Mathf.Sqrt(3f); } public static bool ClothingPathMatches(string a, string b) { if (a == "Avatar/Layers/Top/Tucked T-Shirt") { a = "Avatar/Layers/Top/T-Shirt"; } return a == b; } public static float CalculateInfluenceProbability() { float num = 0f; Enumerator enumerator = NetworkSingleton.Instance.Influence.regionInfluence.GetEnumerator(); while (enumerator.MoveNext()) { RegionInfluenceData current = enumerator.Current; num += current.Influence; } float t = num / (float)NetworkSingleton.Instance.Influence.regionInfluence.Count; return ExpCurve(CARTEL_INFLUENCE_BASE_CHANCE, CARTEL_INFLUENCE_MAX_CHANCE, t); } public static float CalculateThreathenProbability() { int priorEquippedSlotIndex = PlayerSingleton.Instance.PriorEquippedSlotIndex; string text = ""; if (priorEquippedSlotIndex >= 0 && priorEquippedSlotIndex < 8) { ItemInstance itemInstance = ((Il2CppArrayBase)(object)Player.Local._inventory)[priorEquippedSlotIndex].ItemInstance; if (itemInstance != null) { text = ((BaseItemInstance)itemInstance).ID; float num = 0f; return ExpCurve(THREATEN_CARTEL_BASE_CHANCE, THREATEN_CARTEL_MAX_CHANCE, text switch { "baseballbat" => 0.2f, "fryingpan" => 0.3f, "machete" => 0.5f, "revolver" => 0.65f, "m1911" => 0.8f, "pumpshotgun" => 0.95f, _ => 0.1f, }); } return 0f; } return 0f; } public static float CalculateRumourProbability() { float result = ExpCurve(SPREAD_RUMOURS_BASE_CHANCE, SPREAD_RUMOURS_MAX_CHANCE, (float)AlliedExtension.alliedQuests.timesPersuaded / 10f); if (CartelEnforcer.currentConfig.debugMode) { result = 0.99f; } return result; } } [HarmonyPatch(typeof(DialogueController_Dealer), "CheckChoice")] public static class DialogueController_Dealer_CheckChoice_Patch { public static bool IsHireChoiceValid(Dealer d, out string invalidReason) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) invalidReason = ""; if (d.IsRecruited) { invalidReason = "Already recruited."; return false; } if (!d.HasBeenRecommended) { invalidReason = "Persuade the dealer first."; return false; } List lockedConnections = ((NPC)d).RelationData.GetLockedConnections(false); if (lockedConnections != null && lockedConnections.Count > 0) { if ((int)((NPC)d).Region == 1) { invalidReason = "Unlock Molly first."; return false; } EMapRegion value = (EMapRegion)(((NPC)d).Region - 1); invalidReason = $"Unlock {value} dealer first."; return false; } return true; } [HarmonyPostfix] public static void Postfix(DialogueController_Dealer __instance, ref string choiceLabel, ref bool __result, ref string invalidReason) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if ((int)__instance.Dealer.DealerData.DealerType == 0 || !CartelEnforcer.currentConfig.alliedExtensions || (Object)(object)DialogueHandler.ActiveDialogue == (Object)null) { return; } if (((DialogueController)__instance).shownChoices.Contains(__instance.Dealer.recruitChoice) && choiceLabel == "GENERIC_CHOICE_0") { if (!IsHireChoiceValid(__instance.Dealer, out invalidReason)) { __result = false; } else { __result = true; } } else { if (!(((Object)DialogueHandler.ActiveDialogue).name == "CARTEL_ENFORCER_PERSUADE")) { return; } ((DialogueController)__instance).OverrideContainer.DialogueNodeData[0].DialogueText = AlliedCartelDialogue.dealerEntryNodeTexts[Random.Range(0, AlliedCartelDialogue.dealerEntryNodeTexts.Count)]; if (choiceLabel == "EXIT") { __result = true; return; } if (__instance.Dealer.IsRecruited || __instance.Dealer.HasBeenRecommended) { invalidReason = "Can't persuade this dealer."; __result = false; } if (choiceLabel == "START_PERSUADE") { if (CartelPersuade.persuadeCooldown != 0) { invalidReason = $"On cooldown: {CartelPersuade.persuadeCooldown}"; CartelEnforcer.coros.Add(MelonCoroutines.Start(CartelPersuade.UpdatePersuadeCooldownText())); __result = false; } else { __result = true; } } else { __result = true; } } } } [HarmonyPatch(typeof(DialogueController_Dealer), "ChoiceCallback")] public static class DialogueController_Dealer_ChoiceCallback_Patch { public static readonly float redColorThreshold = 0.12f; public static readonly float yellowColorThreshold = 0.25f; public static IEnumerator EnableDelayed(DialogueController_Dealer __instance, string choiceLabel) { yield return CartelEnforcer.Wait01; AlliedExtension.alliedQuests.timesPersuaded = 0; __instance.Dealer.HasBeenRecommended = true; ((DialogueController)__instance).handler.EndDialogue(); ((DialogueController)__instance.Dealer.DialogueController).DialogueEnabled = false; yield return CartelEnforcer.Wait1; if (!CartelEnforcer.registered) { yield break; } if ((Object)(object)((DialogueController)__instance).OverrideContainer != (Object)null) { ((DialogueController)__instance).ClearOverrideContainer(); } __instance.Dealer.SetUpDialogue(); if (__instance.Dealer.recruitChoice != null) { __instance.Dealer.recruitChoice.onChoosen.AddListener(UnityAction.op_Implicit((Action)DisableInventoryClear)); } if (choiceLabel == "THREATEN_CARTEL") { ((NPC)__instance.Dealer).SetPanicked_Server(); ((DialogueController)__instance).npc.PlayVO((EVOLineType)12, false); } else { ((DialogueController)__instance).npc.PlayVO((EVOLineType)19, false); } yield return CartelEnforcer.Wait1; if (CartelEnforcer.registered) { switch (Random.Range(0, 4)) { case 0: ((DialogueController)__instance).handler.WorldspaceRend.ShowText($"Pay me ${__instance.Dealer.DealerData.SigningFee} and I'll work for you.", 10f); break; case 1: ((DialogueController)__instance).handler.WorldspaceRend.ShowText($"Come back with ${__instance.Dealer.DealerData.SigningFee}. Then we can talk.", 10f); break; case 2: ((DialogueController)__instance).handler.WorldspaceRend.ShowText($"My price is ${__instance.Dealer.DealerData.SigningFee}. Take it or leave it!", 10f); break; case 3: ((DialogueController)__instance).handler.WorldspaceRend.ShowText($"Fine! For ${__instance.Dealer.DealerData.SigningFee} cash I'm in.", 10f); break; default: ((DialogueController)__instance).handler.WorldspaceRend.ShowText($"Pay me ${__instance.Dealer.DealerData.SigningFee} and I'll work for you.", 10f); break; } ((DialogueController)__instance.Dealer.DialogueController).DialogueEnabled = true; } void DisableInventoryClear() { CartelEnforcer.coros.Add(MelonCoroutines.Start(DisableInventoryClearDelayed(__instance.Dealer))); } } public static IEnumerator DisableInventoryClearDelayed(Dealer d) { yield return CartelEnforcer.Wait2; if (d.IsRecruited) { ((NPC)d).NPCData.Inventory.ClearInventoryOnNewDay = false; } } [HarmonyPrefix] public static bool Prefix(DialogueController_Dealer __instance, string choiceLabel) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) if ((int)__instance.Dealer.DealerData.DealerType == 0) { return true; } if (!CartelEnforcer.currentConfig.alliedExtensions) { return true; } DialogueContainer activeDialogue = DialogueHandler.ActiveDialogue; if (((activeDialogue != null) ? ((Object)activeDialogue).name : null) != "CARTEL_ENFORCER_PERSUADE") { return true; } if (choiceLabel == "START_PERSUADE") { if (((DialogueController)__instance).OverrideContainer.DialogueNodeData.Count != 2) { return true; } AlliedCartelDialogue.persuasionChances["CLOTHING_SIMILARITY"] = CartelPersuade.CalculateClothingSimilarity(__instance.Dealer); AlliedCartelDialogue.persuasionChances["CARTEL_INFLUENCE"] = CartelPersuade.CalculateInfluenceProbability(); AlliedCartelDialogue.persuasionChances["THREATEN_CARTEL"] = CartelPersuade.CalculateThreathenProbability(); AlliedCartelDialogue.persuasionChances["SPREAD_RUMOURS"] = CartelPersuade.CalculateRumourProbability(); CartelPersuade.persuadeCooldown = AlliedExtension.alliedConfig.PersuadeCooldownMins; for (int i = 0; i < ((Il2CppArrayBase)(object)((DialogueController)__instance).OverrideContainer.DialogueNodeData[1].choices).Length; i++) { DialogueChoiceData val = ((Il2CppArrayBase)(object)((DialogueController)__instance).OverrideContainer.DialogueNodeData[1].choices)[i]; float value = 0f; string text = "#000000"; if (AlliedCartelDialogue.alliedDialogue.TryGetValue(val.ChoiceLabel, out var value2) && AlliedCartelDialogue.persuasionChances.TryGetValue(val.ChoiceLabel, out value)) { text = ((value <= redColorThreshold) ? "#F08473" : ((!(value > redColorThreshold) || !(value <= yellowColorThreshold)) ? "#65E07C" : "#E2E872")); string choiceText = $"{value2[Random.Range(0, value2.Count)]} ({Mathf.RoundToInt(value * 100f)}% Chance)"; val.ChoiceText = choiceText; } } } else if (choiceLabel == "EXIT") { ((DialogueController)__instance).handler.EndDialogue(); ((DialogueController)__instance).handler.WorldspaceRend.ShowText("Just a waste of my time...", 5f); ((DialogueController)__instance).npc.PlayVO((EVOLineType)9, false); } else { NetworkSingleton.Instance.Influence.ChangeInfluence(((NPC)__instance.Dealer).Region, CartelEnforcer.influenceConfig.cartelDealerPersuaded); if (CartelEnforcer.registered && !Singleton.Instance.IsSaving && !CartelEnforcer.isSaving && AlliedExtension.alliedQuests != null) { AlliedExtension.alliedQuests.timesPersuaded++; } float value3 = 0f; if (AlliedCartelDialogue.persuasionChances.TryGetValue(choiceLabel, out value3)) { if (value3 != 0f && Random.Range(0f, 1f) < value3) { CartelEnforcer.coros.Add(MelonCoroutines.Start(EnableDelayed(__instance, choiceLabel))); } else { switch (Random.Range(0, 5)) { case 0: ((DialogueController)__instance).handler.WorldspaceRend.ShowText("Piss off mate!", 10f); ((DialogueController)__instance).npc.PlayVO((EVOLineType)9, false); break; case 1: ((DialogueController)__instance).handler.WorldspaceRend.ShowText("I'm busy...", 10f); ((DialogueController)__instance).npc.PlayVO((EVOLineType)17, false); break; case 2: ((DialogueController)__instance).handler.WorldspaceRend.ShowText("Get out of here!", 10f); ((DialogueController)__instance).npc.PlayVO((EVOLineType)10, false); break; case 3: ((DialogueController)__instance).handler.WorldspaceRend.ShowText("Keep walking bloke!", 10f); ((DialogueController)__instance).npc.PlayVO((EVOLineType)9, false); break; } if (choiceLabel == "THREATEN_CARTEL") { ((NPC)__instance.Dealer).Behaviour.CombatBehaviour.SetTarget(((Component)Player.Local).GetComponent().NetworkObject); ((Behaviour)((NPC)__instance.Dealer).Behaviour.CombatBehaviour).Enable_Networked(); } } } } return true; } } [RegisterTypeInIl2Cpp] public class Quest_TrucedRecruits : ModQuestBase { protected readonly QuestHelperBase _helper; private CartelDealer westvilleDealer; public QuestEntry QuestEntry_FindCartel; private UnityAction _findCartelAction; public QuestEntry QuestEntry_GreetGoons; public QuestEntry QuestEntry_PersuadeCartelDealer; private UnityAction _persuadeCartelAction; public QuestEntry QuestEntry_HireCartelDealer; public Quest_TrucedRecruits(IntPtr ptr) : base(ptr) { _helper = new QuestHelperBase(this); } public Quest_TrucedRecruits() : base(ClassInjector.DerivedConstructorPointer()) { ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this); } public override void Complete(bool network = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 try { if ((int)((Quest)this).State != 2) { if (InstanceFinder.IsServer && !Singleton.Instance.IsLoading) { NetworkSingleton.Instance.AddXP(((Quest)this).CompletionXP); } ((Quest)this).SetQuestState((EQuestState)2, false); NetworkSingleton.Instance.PlayCompleteQuestSound(); ((Quest)this).End(); } } catch (Exception) { throw; } } public override void Fail(bool network = true) { try { ((Quest)this).SetQuestState((EQuestState)3, false); ((Quest)this).End(); } catch (Exception) { throw; } } public override void End() { try { if ((Object)(object)((Quest)this).hudUI != (Object)null) { ((Quest)this).hudUI.Complete(); } TimeManager instance = NetworkSingleton.Instance; Action action = ((Quest)this).OnMinPass; if ((Object)(object)instance == (Object)null) { return; } instance.onMinutePass.Remove(Action.op_Implicit(action)); } catch (Exception) { throw; } ((Component)this).gameObject.SetActive(false); } public void SetupSelf() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_0092: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) _helper.InitializeQuest("Truced Recruits", 200); foreach (CartelDealer item in Object.FindObjectsOfType(true)) { if ((int)((NPC)item).Region == 1) { westvilleDealer = item; break; } } _findCartelAction = UnityAction.op_Implicit((Action)OnFindCartelComplete); _helper.InitializeQuestEntry(ref QuestEntry_FindCartel, "FindCartel", "Find the Westville Cartel Dealer", new PoIConfig(usePoI: true, useParent: false, useTransformLocal: false, null, ((NPC)westvilleDealer).CenterPoint), _findCartelAction); _helper.InitializeQuestEntry(ref QuestEntry_GreetGoons, "GreetGoons", "(Optional) Say greetings to all 3 gathering goons", new PoIConfig(usePoI: true, useParent: false, useTransformLocal: false)); _persuadeCartelAction = UnityAction.op_Implicit((Action)OnPersuadeComplete); _helper.InitializeQuestEntry(ref QuestEntry_PersuadeCartelDealer, "PersuadeCartel", "Try persuading the Westville Cartel Dealer", new PoIConfig(usePoI: true, useParent: true, useTransformLocal: true, ((Component)westvilleDealer).transform, Vector3.zero), _persuadeCartelAction); _helper.InitializeQuestEntry(ref QuestEntry_HireCartelDealer, "HireCartel", "Hire the Westville Cartel Dealer", new PoIConfig(usePoI: true, useParent: true, useTransformLocal: true, ((Component)westvilleDealer).transform, Vector3.zero)); TimeManager instance = NetworkSingleton.Instance; Action action = ((Quest)this).OnMinPass; instance.onMinutePass += Action.op_Implicit(action); _helper.StartQuestFromEntry(QuestEntry_FindCartel); } public override void OnMinPass() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Invalid comparison between Unknown and I4 //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Invalid comparison between Unknown and I4 //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Invalid comparison between Unknown and I4 //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Invalid comparison between Unknown and I4 //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if (!CartelEnforcer.registered || Singleton.Instance.IsSaving || AlliedExtension.alliedQuests.alliedIntroCompleted || (int)((Quest)this).State != 1 || !InstanceFinder.IsServer) { return; } if ((int)NetworkSingleton.Instance.Status != 1) { ((Quest)this).Fail(true); } if ((Object)(object)westvilleDealer == (Object)null) { return; } if ((Object)(object)QuestEntry_GreetGoons != (Object)null && (int)QuestEntry_GreetGoons.State == 1) { if (!CartelGathering.areGoonsGathering) { QuestEntry_GreetGoons.SetState((EQuestState)4, false); } } else if ((Object)(object)QuestEntry_GreetGoons != (Object)null && ((int)QuestEntry_GreetGoons.State == 0 || (int)QuestEntry_GreetGoons.State == 4) && CartelGathering.areGoonsGathering && CartelGathering.currentGatheringLocation != null) { QuestEntry_GreetGoons.Begin(); EndGameQuest.UpdateQuestMapLogo(QuestEntry_GreetGoons); if (CartelGathering.currentGatheringLocation != null) { _ = CartelGathering.currentGatheringLocation.position; QuestEntry_GreetGoons.SetPoILocation(CartelGathering.currentGatheringLocation.position); } } if ((Object)(object)QuestEntry_FindCartel != (Object)null && (int)QuestEntry_FindCartel.State == 1 && !((NPC)westvilleDealer).isInBuilding && Player.Local.IsPointVisibleToPlayer(((NPC)westvilleDealer).CenterPoint, 20f, 1f)) { QuestEntry_FindCartel.Complete(); } else if ((Object)(object)QuestEntry_PersuadeCartelDealer != (Object)null && (int)QuestEntry_PersuadeCartelDealer.State == 1 && ((Dealer)westvilleDealer).HasBeenRecommended) { QuestEntry_PersuadeCartelDealer.Complete(); } else if ((Object)(object)QuestEntry_HireCartelDealer != (Object)null && (int)QuestEntry_HireCartelDealer.State == 1 && ((Dealer)westvilleDealer).IsRecruited && !Singleton.Instance.IsSaving && !CartelEnforcer.isSaving) { AlliedExtension.alliedQuests.alliedIntroCompleted = true; ((Quest)this).Complete(true); } } public void OnFindCartelComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((!((Object)(object)QuestEntry_FindCartel != (Object)null) || (int)QuestEntry_FindCartel.State != 3) && !((Object)(object)QuestEntry_PersuadeCartelDealer == (Object)null)) { QuestEntry_PersuadeCartelDealer.SetState((EQuestState)1, false); EndGameQuest.UpdateQuestMapLogo(QuestEntry_PersuadeCartelDealer); if ((Delegate)(object)_findCartelAction != (Delegate)null) { QuestEntry_FindCartel.onComplete.RemoveListener(_findCartelAction); _findCartelAction = null; } } } public void OnPersuadeComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((!((Object)(object)QuestEntry_PersuadeCartelDealer != (Object)null) || (int)QuestEntry_PersuadeCartelDealer.State != 3) && !((Object)(object)QuestEntry_HireCartelDealer == (Object)null)) { QuestEntry_HireCartelDealer.Begin(); EndGameQuest.UpdateQuestMapLogo(QuestEntry_HireCartelDealer); if ((Object)(object)QuestEntry_PersuadeCartelDealer != (Object)null) { QuestEntry_PersuadeCartelDealer.onComplete.RemoveListener(_persuadeCartelAction); _persuadeCartelAction = null; } } } } [RegisterTypeInIl2Cpp] public class Quest_AlliedSupplies : ModQuestBase { protected readonly QuestHelperBase _helper; public string title; public string Subtitle; public RectTransform groupRt; public SupplyLocation location; public bool playerNoticed; public bool playerInterrogated; public bool interrogatingPlayer; public QuestEntry QuestEntry_LocateSupplies; private UnityAction _locateSuppliesAction; public QuestEntry QuestEntry_GatherSupplies; public Quest_AlliedSupplies(IntPtr ptr) : base(ptr) { _helper = new QuestHelperBase(this); } public Quest_AlliedSupplies() : base(ClassInjector.DerivedConstructorPointer()) { ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this); } public override void Complete(bool network = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 try { if ((int)((Quest)this).State != 2) { if (InstanceFinder.IsServer && !Singleton.Instance.IsLoading) { NetworkSingleton.Instance.AddXP(((Quest)this).CompletionXP); } ((Quest)this).SetQuestState((EQuestState)2, false); NetworkSingleton.Instance.PlayCompleteQuestSound(); ((Quest)this).End(); } } catch (Exception) { throw; } } public override void Fail(bool network = true) { try { ((Quest)this).SetQuestState((EQuestState)3, false); ((Quest)this).End(); } catch (Exception) { throw; } } public override void End() { try { if ((Object)(object)((Quest)this).hudUI != (Object)null) { ((Component)((Quest)this).hudUI).gameObject.SetActive(false); } CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.CleanupTruceSuppliesQuest(location))); } catch (Exception) { throw; } ((Component)this).gameObject.SetActive(false); } public void ResetSelf() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) EndGameQuest.alliedSuppliesActive = true; if (!((Object)(object)EndGameQuest.activeAlliedSupplies == (Object)null) && ((int)((Quest)this).State == 2 || (int)((Quest)this).State == 4)) { int num = Random.Range(0, SuppliesModule.supplyLocations.Count); if (SuppliesModule.supplyLocations[num] == location) { location = SuppliesModule.supplyLocations[(num + 1) % SuppliesModule.supplyLocations.Count]; } else { location = SuppliesModule.supplyLocations[num]; } interrogatingPlayer = false; playerInterrogated = false; playerNoticed = false; TimeManager instance = NetworkSingleton.Instance; ((Quest)this).Expiry = new GameDateTime(instance.ElapsedDays + 1, 401); Subtitle = "\n" + ((Quest)this).GetExpiryText() + " until supplies vanish"; title = "Allied Supplies"; ((Component)this).gameObject.SetActive(true); QuestEntry_GatherSupplies.SetState((EQuestState)0, false); QuestEntry_LocateSupplies.SetState((EQuestState)1, false); ((Quest)this).SetQuestState((EQuestState)1, true); if ((Object)(object)QuestEntry_GatherSupplies.PoI != (Object)null && (Object)(object)QuestEntry_GatherSupplies.PoI.UI != (Object)null) { ((Component)QuestEntry_GatherSupplies.PoI.UI).gameObject.SetActive(false); } ((Component)QuestEntry_GatherSupplies.PoILocation).transform.position = ((location.Type == ESupplyType.Van) ? location.CarPosition : location.BarrelObjects[0].transform.position); if (QuestEntry_GatherSupplies.compassElement != null && QuestEntry_GatherSupplies.compassElement.Visible) { QuestEntry_GatherSupplies.compassElement.Visible = false; } if (QuestEntry_LocateSupplies.compassElement != null && QuestEntry_LocateSupplies.compassElement.Visible) { QuestEntry_LocateSupplies.compassElement.Visible = false; } ((Component)((Quest)this).hudUI).gameObject.SetActive(true); QuestEntry_LocateSupplies.entryUI.FadeIn(); CartelEnforcer.coros.Add(MelonCoroutines.Start(SuppliesModule.SpawnSupply(location))); } } public void SetupSelf() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_010e: Unknown result type (might be due to invalid IL or missing references) EndGameQuest.alliedSuppliesActive = true; TimeManager instance = NetworkSingleton.Instance; GameDateTime expiry = default(GameDateTime); ((GameDateTime)(ref expiry))..ctor(instance.ElapsedDays + 1, 401); _helper.InitializeQuest("Allied Supplies", 300, expires: true, expiry, trackOnBegin: false); Subtitle = "\n" + ((Quest)this).GetExpiryText() + " until supplies vanish"; location = SuppliesModule.supplyLocations[Random.Range(0, SuppliesModule.supplyLocations.Count)]; _locateSuppliesAction = UnityAction.op_Implicit((Action)OnLocateSuppliesComplete); _helper.InitializeQuestEntry(ref QuestEntry_LocateSupplies, "LocateSupplies", "Read Thomas' message and locate the Cartel supplies", new PoIConfig(usePoI: false, useParent: false, useTransformLocal: false), _locateSuppliesAction); Vector3 poiPosition = ((location.Type == ESupplyType.Van) ? location.CarPosition : location.BarrelObjects[0].transform.position); _helper.InitializeQuestEntry(ref QuestEntry_GatherSupplies, "GatherSupplies", "Receive the Cartel supplies", new PoIConfig(usePoI: true, useParent: false, useTransformLocal: false, null, poiPosition)); _helper.StartQuestFromEntry(QuestEntry_LocateSupplies); if ((Object)(object)QuestEntry_LocateSupplies != (Object)null) { if (QuestEntry_LocateSupplies.compassElement != null) { QuestEntry_LocateSupplies.compassElement.Visible = false; } else { QuestEntry_LocateSupplies.CreateCompassElement(); QuestEntry_LocateSupplies.compassElement.Visible = false; } } instance.onMinutePass += Action.op_Implicit((Action)((Quest)this).OnMinPass); CartelEnforcer.coros.Add(MelonCoroutines.Start(SuppliesModule.SpawnSupply(location))); } public override void OnMinPass() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Invalid comparison between Unknown and I4 //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Invalid comparison between Unknown and I4 //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Invalid comparison between Unknown and I4 //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) if (!CartelEnforcer.registered || Singleton.Instance.IsSaving || !EndGameQuest.alliedSuppliesActive || (int)((Quest)this).State != 1 || !InstanceFinder.IsServer) { return; } if ((int)NetworkSingleton.Instance.Status != 1) { ((Quest)this).Fail(true); } Subtitle = "\n" + ((Quest)this).GetExpiryText() + " until supplies vanish"; SuppliesModule.UpdateQuestHUD(); ((Quest)this).CheckExpiry(); if ((int)((Quest)this).State != 1) { return; } if ((Object)(object)QuestEntry_LocateSupplies != (Object)null && (int)QuestEntry_LocateSupplies.State == 1 && Vector3.Distance(Player.Local.CenterPointTransform.position, (location.Type == ESupplyType.Van) ? location.CarPosition : location.BarrelObjects[0].transform.position) < 14f) { QuestEntry_LocateSupplies.SetState((EQuestState)2, false); } else { if (!((Object)(object)QuestEntry_GatherSupplies != (Object)null) || (int)QuestEntry_GatherSupplies.State != 1) { return; } bool flag = false; if (location.Type == ESupplyType.Barrel) { Vector3 val = Vector3.zero; int num = 0; foreach (GameObject barrelObject in location.BarrelObjects) { Transform val2 = barrelObject.transform.Find("CE_SUPPLY"); if ((Object)(object)val2 == (Object)null) { num++; } else { val = val2.position; } } if (num == location.BarrelObjects.Count) { flag = true; } else if (val != Vector3.zero && (Object)(object)QuestEntry_GatherSupplies.PoI != (Object)null && (Object)(object)((Component)QuestEntry_GatherSupplies.PoI).gameObject != (Object)null) { QuestEntry_GatherSupplies.SetPoILocation(val); } } if (flag) { ((Quest)this).Complete(false); } } } public void OnLocateSuppliesComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if ((!((Object)(object)QuestEntry_LocateSupplies != (Object)null) || (int)QuestEntry_LocateSupplies.State != 3) && !((Object)(object)QuestEntry_GatherSupplies == (Object)null)) { QuestEntry_GatherSupplies.Begin(); EndGameQuest.UpdateQuestMapLogo(QuestEntry_GatherSupplies); QuestEntry_GatherSupplies.SetPoILocation((location.Type == ESupplyType.Van) ? location.CarPosition : location.BarrelObjects[0].transform.position); } } } public static class SuppliesModule { public static List supplyLocations; public static readonly List barrelLootIds = new List { "acid", "phosphorus", "gasoline", "fertilizer", "pgr", "speedgrow" }; public static List barrelLoot = new List(); public static readonly List commonLootPool = new List { "fertilizer", "longlifesoil", "extralonglifesoil", "airpot", "moisturepreservingpot" }; public static readonly List rareLootPool = new List { "fullspectrumgrowlight", "ledgrowlight", "dryingrack", "airpot", "moisturepreservingpot" }; public static readonly List legendaryLootPool = new List { "bigsprinkler", "brickpress", "mixingstationmk2", "cauldron", "laboven", "chemistrystation", "acunit" }; public static Dictionary> carLoot = new Dictionary> { { "Common", new List() }, { "Rare", new List() }, { "Legendary", new List() } }; public static readonly List thomasMessageTemplates = new List { "We need to expand production in Hyland Point. Help us unload supplies from", "New shipment just arrived. I need you to secure contents of", "Product demand is spiking. Go and recover the supplies from", "We're scaling the operation. Move quickly and get the contents of", "Run up some logistics for me. Pick up the contents of" }; public static void InitSuppliesModule() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) SupplyLocation supplyLocation = new SupplyLocation(); supplyLocation.CarPosition = new Vector3(167.3347f, 10.5078f, -68.9665f); supplyLocation.CarRotation = new Vector3(0f, 15.2327f, 0f); supplyLocation.Description = "the Uptown manor parking lot"; supplyLocation.Name = "Manor Supplies"; supplyLocation.ID = "SUPPLY_MANOR"; supplyLocation.Type = ESupplyType.Van; supplyLocation.GuardPosition = new Vector3(162.3889f, 10.99f, -73.1324f); supplyLocation.GuardRotation = new Vector3(0f, 92f, 0f); SupplyLocation supplyLocation2 = new SupplyLocation(); supplyLocation2.CarPosition = new Vector3(18.3931f, 0.5828f, 71.3268f); supplyLocation2.CarRotation = new Vector3(0f, 271.5327f, 0f); supplyLocation2.Description = "the Downtown supermarket"; supplyLocation2.Name = "Supermarket Supplies"; supplyLocation2.ID = "SUPPLY_SUPERMARKET"; supplyLocation2.Type = ESupplyType.Van; supplyLocation2.GuardPosition = new Vector3(24.7739f, 1.065f, 68.6945f); supplyLocation2.GuardRotation = Vector3.zero; SupplyLocation supplyLocation3 = new SupplyLocation(); supplyLocation3.CarPosition = new Vector3(-129.0546f, -3.5171f, 96.506f); supplyLocation3.CarRotation = new Vector3(0f, 27.2817f, 0f); supplyLocation3.Description = "the Westville construction site"; supplyLocation3.Name = "Construction Site Supplies"; supplyLocation3.ID = "SUPPLY_CONSTRUCTION_SITE"; supplyLocation3.Type = ESupplyType.Van; supplyLocation3.GuardPosition = new Vector3(-134.0546f, -3.5171f, 96.506f); supplyLocation3.GuardRotation = new Vector3(0f, 158f, 0f); string text = ""; SupplyLocation supplyLocation4 = new SupplyLocation(); supplyLocation4.Description = "the Northtown waterfront"; supplyLocation4.Name = "Northtown Waterfront Supplies"; supplyLocation4.ID = "SUPPLY_WATERFRONT"; supplyLocation4.Type = ESupplyType.Barrel; supplyLocation4.GuardPosition = new Vector3(-63.3022f, -4.035f, 163.7165f); supplyLocation4.GuardRotation = new Vector3(0f, 94.6f, 0f); supplyLocation4.BarrelObjects = new List(); text = "Pallet_LiquidDrum"; PopulateBarrels("Hyland Point/Region_Northtown/Waterfront/Pallet Rack/", text, supplyLocation4.BarrelObjects); SupplyLocation supplyLocation5 = new SupplyLocation(); supplyLocation5.Description = "the Northtown Thompsons' construction yard"; supplyLocation5.Name = "Northtown Thompsons' Supplies"; supplyLocation5.ID = "SUPPLY_THOMPSONS"; supplyLocation5.Type = ESupplyType.Barrel; supplyLocation5.GuardPosition = new Vector3(-31.4224f, 1.0639f, 97.6543f); supplyLocation5.GuardRotation = Vector3.zero; supplyLocation5.BarrelObjects = new List(); text = "Liquid Drum"; PopulateBarrels("Hyland Point/Region_Northtown/Construction yard/Fence/", text, supplyLocation5.BarrelObjects); SupplyLocation supplyLocation6 = new SupplyLocation(); supplyLocation6.Description = "the Docks"; supplyLocation6.Name = "Docks Supplies"; supplyLocation6.ID = "SUPPLY_DOCKS"; supplyLocation6.Type = ESupplyType.Barrel; supplyLocation6.GuardPosition = new Vector3(-71.1649f, -1.535f, -33.5302f); supplyLocation6.GuardRotation = new Vector3(0f, 240f, 0f); supplyLocation6.BarrelObjects = new List(); text = "Liquid Drum"; PopulateBarrels("Hyland Point/Region_Docks/", text, supplyLocation6.BarrelObjects); supplyLocations = new List { supplyLocation, supplyLocation2, supplyLocation3, supplyLocation4, supplyLocation5, supplyLocation6 }; Func func = Registry.GetItem; foreach (string barrelLootId in barrelLootIds) { ItemDefinition val = func(barrelLootId); barrelLoot.Add(val.GetDefaultInstance(5)); } foreach (string item in commonLootPool) { int num = Random.Range(4, 8); ItemDefinition val2 = func(item); carLoot["Common"].Add(val2.GetDefaultInstance(num)); } foreach (string item2 in rareLootPool) { int num2 = Random.Range(2, 5); ItemDefinition val3 = func(item2); carLoot["Rare"].Add(val3.GetDefaultInstance(num2)); } foreach (string item3 in legendaryLootPool) { ItemDefinition val4 = func(item3); carLoot["Legendary"].Add(val4.GetDefaultInstance(1)); } } public static void PopulateBarrels(string transformPath, string searchName, List populateList) { Transform val = ((Component)Singleton.Instance).transform.Find(transformPath); if (!((Object)(object)val != (Object)null)) { return; } Transform val2 = null; for (int i = 0; i < val.childCount; i++) { val2 = val.GetChild(i); if ((Object)(object)val2 != (Object)null && ((Object)val2).name.Contains(searchName)) { populateList.Add(((Component)val2).gameObject); } } } public static IEnumerator SpawnSupply(SupplyLocation location) { string value = ((location.Type == ESupplyType.Barrel) ? "the blue barrels" : "a white van"); string text = $"{thomasMessageTemplates[Random.Range(0, thomasMessageTemplates.Count)]} {value} at {location.Description}."; Thomas val = Object.FindObjectOfType(true); if ((Object)(object)val == (Object)null) { yield break; } ((NPC)val).MSGConversation.SendMessage(new Message(text, (ESenderType)1, true, -1), true, true); if (location.Type == ESupplyType.Barrel) { foreach (GameObject go in location.BarrelObjects) { if (location.ID == "SUPPLY_DOCKS") { RemoveDragInteraction(go); } yield return CartelEnforcer.Wait01; SetBarrelInteractable(go, barrelLoot[Random.Range(0, barrelLoot.Count)], 20); } } else { if (location.ID == "SUPPLY_MANOR") { for (int i = 0; i < Property.Properties.Count; i++) { if (!(Property.Properties[i].propertyCode == "manor")) { continue; } ManorGate componentInChildren = ((Component)Property.Properties[i]).gameObject.GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null) { Transform val2 = ((Component)Property.Properties[i]).transform.Find("Manor Gate"); if ((Object)(object)val2 != (Object)null) { ManorGate component = ((Component)val2).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { component.SetEnterable(true); } } } else { componentInChildren.SetEnterable(true); } } } CartelEnforcer.coros.Add(MelonCoroutines.Start(SpawnSupplyVan(new Tuple(location.CarPosition, location.CarRotation)))); } if ((Object)(object)EndGameQuest.activeAlliedSupplies != (Object)null) { SpawnGuardGoon(location.GuardPosition, location.GuardRotation); } yield return null; } public static IEnumerator SpawnSupplyVan(Tuple target) { NetworkManager val = Object.FindObjectOfType(true); PrefabObjects spawnablePrefabs = val.SpawnablePrefabs; NetworkObject val2 = null; StorageEntity rewardStorage = null; for (int i = 0; i < spawnablePrefabs.GetObjectCount(); i++) { NetworkObject val3 = spawnablePrefabs.GetObject(true, i); object obj; if (val3 == null) { obj = null; } else { GameObject gameObject = ((Component)val3).gameObject; obj = ((gameObject != null) ? ((Object)gameObject).name : null); } if ((string?)obj == "Van") { val2 = val3; } } NetworkObject veeperVeh = Object.Instantiate(val2); val.ServerManager.Spawn(veeperVeh, (NetworkConnection)null, default(Scene)); EndGameQuest.alliedVanObject = veeperVeh; yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { yield break; } ((Component)veeperVeh).transform.parent = ((Component)Singleton.Instance).transform; ((Component)veeperVeh).gameObject.SetActive(true); ((Component)veeperVeh).transform.SetPositionAndRotation(target.Item1, Quaternion.Euler(target.Item2)); rewardStorage = ((Component)veeperVeh).GetComponent(); rewardStorage.AccessSettings = (EAccessSettings)2; yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { ((Component)veeperVeh).GetComponent().isKinematic = true; int num = Random.Range(4, 9); for (int j = 0; j < rewardStorage.ItemSlots.Count && j < num; j++) { float num2 = Random.Range(0f, 1f); List list = ((!(num2 <= 0.6f)) ? ((!(num2 > 0.6f) || !(num2 <= 0.95f)) ? carLoot["Legendary"] : carLoot["Rare"]) : carLoot["Common"]); ItemInstance copy = list[Random.Range(0, list.Count)].GetCopy(-1); rewardStorage.ItemSlots[j].InsertItem(copy); rewardStorage.ContentsChanged(); } Action val4 = Action.op_Implicit((Action)CloseTrigger); StorageEntity obj2 = rewardStorage; obj2.onClosed += val4; rewardStorage.StorageEntitySubtitle = "Cartel Supply Delivery"; } void CloseTrigger() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 if (!((Object)(object)EndGameQuest.activeAlliedSupplies == (Object)null) && (int)((Quest)EndGameQuest.activeAlliedSupplies).State == 1 && (Object)(object)EndGameQuest.activeAlliedSupplies.QuestEntry_GatherSupplies != (Object)null && (int)EndGameQuest.activeAlliedSupplies.QuestEntry_GatherSupplies.State == 1 && rewardStorage.ItemCount == 0) { EndGameQuest.activeAlliedSupplies.QuestEntry_GatherSupplies.Complete(); ((Quest)EndGameQuest.activeAlliedSupplies).Complete(false); } } } public static void RemoveDragInteraction(GameObject target) { InteractableObject component = target.GetComponent(); Rigidbody component2 = target.GetComponent(); Draggable component3 = target.GetComponent(); if ((Object)(object)component3 != (Object)null) { Object.Destroy((Object)(object)component3); } if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } if ((Object)(object)component2 != (Object)null) { component2.isKinematic = true; } } public static void SetBarrelInteractable(GameObject target, ItemInstance item, int capacity) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown GameObject barrelMarker = new GameObject("CE_SUPPLY"); barrelMarker.transform.SetParent(target.transform); InteractableObject intObj = target.AddComponent(); intObj.message = "Take 5 x " + ((BaseItemInstance)item).Name; intObj.SetInteractableState((EInteractableState)0); int remainingCapacity = capacity; UnityAction val = null; val = UnityAction.op_Implicit((Action)OnBarrelInteracted); intObj.onInteractStart.AddListener(val); void OnBarrelInteracted() { if (PlayerSingleton.InstanceExists) { if (PlayerSingleton.Instance.CanItemFitInInventory(item, 5)) { PlayerSingleton.Instance.AddItemToInventory(item); remainingCapacity -= 5; } if (remainingCapacity <= 0) { Object.Destroy((Object)(object)barrelMarker); if ((Object)(object)intObj != (Object)null) { Object.Destroy((Object)(object)intObj); } } } } } public static void SpawnGuardGoon(Vector3 pos, Vector3 rot) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown CartelGoon val = null; DialogueController controller; if (NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count != 0) { val = NetworkSingleton.Instance.GoonPool.SpawnGoon(pos); ((Component)((NPC)val).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)val).Behaviour.ScheduleManager.DisableSchedule(); if (((NPC)val).isInBuilding) { ((NPC)val).ExitBuilding(((NPC)val).CurrentBuilding); ((NPC)val).Movement.Warp(pos); } ((Component)val).transform.rotation = Quaternion.Euler(rot); AvatarEquippable component = Object.Instantiate(((Il2CppObjectBase)Resources.Load("Avatar/Equippables/PumpShotgun")).TryCast(), new Vector3(0f, -5f, 0f), Quaternion.identity).GetComponent(); AvatarWeapon val2 = ((Il2CppObjectBase)component).TryCast(); AvatarRangedWeapon val3 = ((Il2CppObjectBase)component).TryCast(); if ((Object)(object)val2 != (Object)null) { ((NPC)val).Behaviour.CombatBehaviour.SetDefaultWeapon(val2); } if ((Object)(object)val3 != (Object)null) { val3.MaxFireRate = 0.6f; val3.RepositionAfterHit = true; val3.CanShootWhileMoving = true; val3.EquipTime = 0.1f; val3.HitChance_MinRange = 99f; val3.HitChance_MaxRange = 80f; val3.Damage = 98f; ((AvatarWeapon)val3).CooldownDuration = 0.8f; ((AvatarWeapon)val3).MaxUseRange = 36f; ((AvatarWeapon)val3).MinUseRange = 0.1f; } ((AvatarEquippable)((NPC)val).Behaviour.CombatBehaviour._defaultWeapon).Equip(((NPC)val).Avatar); ((NPC)val).NPCData.Health.MaxHealth = 500f; ((NPC)val).Health.Health = 500f; ((NPC)val).Movement.SpeedController.AddSpeedControl(new SpeedControl("combat", 5, 0.55f)); controller = ((Component)((NPC)val).DialogueHandler).gameObject.GetComponent(); DialogueChoice val4 = new DialogueChoice(); string text = "Relax buddy, the boss sent me."; val4.ChoiceText = text ?? ""; val4.Enabled = true; val4.onChoosen.AddListener(UnityAction.op_Implicit((Action)ReplyChosen)); EndGameQuest.guardChoiceIndex = controller.AddDialogueChoice(val4, 0); EndGameQuest.alliedGuard = val; CartelEnforcer.coros.Add(MelonCoroutines.Start(HandleGuardGoon())); } void ReplyChosen() { EndGameQuest.activeAlliedSupplies.interrogatingPlayer = false; controller.npc.PlayVO((EVOLineType)14, false); controller.handler.WorldspaceRend.ShowText("Go ahead and grab the supplies", 6f); controller.handler.ContinueSubmitted(); if (EndGameQuest.guardChoiceIndex != -1) { List choices = controller.Choices; choices.RemoveAt(EndGameQuest.guardChoiceIndex); controller.Choices = choices; EndGameQuest.guardChoiceIndex = -1; } } } public static IEnumerator HandleGuardGoon() { CartelEnforcer.coros.Add(MelonCoroutines.Start(CheckInterrogate())); while (true) { yield return CartelEnforcer.Wait1; if (!CartelEnforcer.registered) { break; } if (EndGameQuest.activeAlliedSupplies.interrogatingPlayer) { continue; } if ((Object)(object)EndGameQuest.activeAlliedSupplies == (Object)null || (int)((Quest)EndGameQuest.activeAlliedSupplies).State != 1 || (Object)(object)EndGameQuest.alliedGuard == (Object)null || ((NPC)EndGameQuest.alliedGuard).Health.IsDead || ((NPC)EndGameQuest.alliedGuard).Health.IsKnockedOut || (Object)(object)((NPC)EndGameQuest.alliedGuard).Behaviour.activeBehaviour == (Object)(object)((NPC)EndGameQuest.alliedGuard).Behaviour.CombatBehaviour) { break; } float num = Vector3.Distance(((NPC)EndGameQuest.alliedGuard).CenterPoint, EndGameQuest.activeAlliedSupplies.location.GuardPosition); if (num > 30f || (EndGameQuest.activeAlliedSupplies.playerNoticed && EndGameQuest.activeAlliedSupplies.playerInterrogated && num > 2f)) { if (!((NPC)EndGameQuest.alliedGuard).Movement.HasDestination || !(Vector3.Distance(((NPC)EndGameQuest.alliedGuard).Movement.CurrentDestination, EndGameQuest.activeAlliedSupplies.location.GuardPosition) < 2f)) { ((NPC)EndGameQuest.alliedGuard).Movement.EndSetDestination((WalkResult)1); Action val = Action.op_Implicit((Action)OnGuardArrivedToPos); ((NPC)EndGameQuest.alliedGuard).Movement.SetDestination(EndGameQuest.activeAlliedSupplies.location.GuardPosition, val, true, 1f, 1f); if (((NPC)EndGameQuest.alliedGuard).Movement.IsPaused) { ((NPC)EndGameQuest.alliedGuard).Movement.ResumeMovement(); } } } else { if (Vector3.Distance(((NPC)EndGameQuest.alliedGuard).CenterPoint, Player.Local.CenterPointTransform.position) > 40f) { continue; } if (!EndGameQuest.activeAlliedSupplies.playerNoticed && !EndGameQuest.activeAlliedSupplies.playerInterrogated) { if (Player.Local.IsPointVisibleToPlayer(((NPC)EndGameQuest.alliedGuard).CenterPointTransform.position, 30f, 5f)) { ((NPC)EndGameQuest.alliedGuard).Movement.FacePoint(Player.Local.CenterPointTransform.position, 0.9f); } if (((NPC)EndGameQuest.alliedGuard).Awareness.VisionCone.IsPlayerVisible(Player.Local)) { EndGameQuest.activeAlliedSupplies.playerNoticed = true; } } if (EndGameQuest.activeAlliedSupplies.playerNoticed && !EndGameQuest.activeAlliedSupplies.playerInterrogated && !((NPC)EndGameQuest.alliedGuard).Movement.HasDestination && !((NPC)EndGameQuest.alliedGuard).Movement.IsMoving) { ((NPC)EndGameQuest.alliedGuard).Movement.SetDestination(Player.Local.CenterPointTransform); if (((NPC)EndGameQuest.alliedGuard).Movement.IsPaused) { ((NPC)EndGameQuest.alliedGuard).Movement.ResumeMovement(); } } } } static void OnGuardArrivedToPos(WalkResult result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if ((int)result == 4) { Vector3 val2 = EndGameQuest.activeAlliedSupplies.location.GuardPosition + Quaternion.Euler(EndGameQuest.activeAlliedSupplies.location.GuardRotation) * Vector3.forward * 1.5f; ((NPC)EndGameQuest.alliedGuard).Movement.FacePoint(val2, 0.5f); ((NPC)EndGameQuest.alliedGuard).Movement.PauseMovement(); } } } private static bool CanStartInterrogate() { if (!Singleton.Instance.IsOpen && !Singleton.Instance.IsOpen && PlayerSingleton.Instance.ActiveUIElementCount <= 0) { return !((NPC)EndGameQuest.alliedGuard).DialogueHandler.IsDialogueInProgress; } return false; } public static IEnumerator CheckInterrogate() { while (true) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered || (Object)(object)EndGameQuest.activeAlliedSupplies == (Object)null || (int)((Quest)EndGameQuest.activeAlliedSupplies).State != 1 || (Object)(object)EndGameQuest.alliedGuard == (Object)null || ((NPC)EndGameQuest.alliedGuard).Health.IsDead || ((NPC)EndGameQuest.alliedGuard).Health.IsKnockedOut || (Object)(object)((NPC)EndGameQuest.alliedGuard).Behaviour.activeBehaviour == (Object)(object)((NPC)EndGameQuest.alliedGuard).Behaviour.CombatBehaviour || EndGameQuest.activeAlliedSupplies.playerInterrogated || EndGameQuest.activeAlliedSupplies.interrogatingPlayer) { yield break; } if (!(Vector3.Distance(Player.Local.CenterPointTransform.position, ((NPC)EndGameQuest.alliedGuard).CenterPoint) > 3f)) { yield return (object)new WaitUntil(Func.op_Implicit((Func)CanStartInterrogate)); if (!(Vector3.Distance(Player.Local.CenterPointTransform.position, ((NPC)EndGameQuest.alliedGuard).CenterPoint) > 3f)) { break; } } } EndGameQuest.activeAlliedSupplies.playerInterrogated = true; if ((Object)(object)((NPC)EndGameQuest.alliedGuard).DialogueHandler != (Object)null) { EndGameQuest.activeAlliedSupplies.interrogatingPlayer = true; ((NPC)EndGameQuest.alliedGuard).Movement.EndSetDestination((WalkResult)4); DialogueController component = ((Component)((NPC)EndGameQuest.alliedGuard).DialogueHandler).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { component.StartGenericDialogue(false); } } } public static void OnHourPassEvaluateSupply() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 if (!CartelEnforcer.registered || Singleton.Instance.IsSaving || CartelEnforcer.isSaving || !CartelEnforcer.currentConfig.alliedExtensions || (int)NetworkSingleton.Instance.Status != 1 || EndGameQuest.alliedSuppliesActive) { return; } if (AlliedExtension.alliedQuests.hoursUntilNextSupplies > 0) { AlliedExtension.alliedQuests.hoursUntilNextSupplies--; return; } int currentTime = NetworkSingleton.Instance.CurrentTime; if (currentTime <= 801 && currentTime >= 759) { if ((Object)(object)EndGameQuest.activeAlliedSupplies == (Object)null) { CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.SetupTruceSuppliesQuest())); } else { EndGameQuest.activeAlliedSupplies.ResetSelf(); } } } public static void UpdateQuestHUD() { if (!((Object)(object)((Quest)EndGameQuest.activeAlliedSupplies).hudUI != (Object)null) || ((Il2CppObjectBase)((Quest)EndGameQuest.activeAlliedSupplies).hudUI).WasCollected || !(((Il2CppObjectBase)((Quest)EndGameQuest.activeAlliedSupplies).hudUI).Pointer != IntPtr.Zero)) { return; } TextMeshProUGUI mainLabel = ((Quest)EndGameQuest.activeAlliedSupplies).hudUI.MainLabel; if ((Object)(object)mainLabel != (Object)null && !((Il2CppObjectBase)mainLabel).WasCollected && ((Il2CppObjectBase)mainLabel).Pointer != IntPtr.Zero) { ((TMP_Text)mainLabel).text = ((Quest)EndGameQuest.activeAlliedSupplies).GetQuestTitle() + EndGameQuest.activeAlliedSupplies.Subtitle; ((TMP_Text)mainLabel).ForceMeshUpdate(false, false); } VerticalLayoutGroup hudUILayout = ((Quest)EndGameQuest.activeAlliedSupplies).hudUI.hudUILayout; if ((Object)(object)hudUILayout != (Object)null && !((Il2CppObjectBase)hudUILayout).WasCollected && ((Il2CppObjectBase)hudUILayout).Pointer != IntPtr.Zero) { ((LayoutGroup)hudUILayout).CalculateLayoutInputVertical(); ((LayoutGroup)hudUILayout).SetLayoutVertical(); if ((Object)(object)EndGameQuest.activeAlliedSupplies.groupRt == (Object)null) { EndGameQuest.activeAlliedSupplies.groupRt = ((Component)hudUILayout).GetComponent(); } LayoutRebuilder.ForceRebuildLayoutImmediate(EndGameQuest.activeAlliedSupplies.groupRt); ((Behaviour)hudUILayout).enabled = false; ((Behaviour)hudUILayout).enabled = true; } } } public enum ESupplyType { Barrel, Van } public class SupplyLocation { public string Name { get; set; } public string ID { get; set; } public string Description { get; set; } public Vector3 CarPosition { get; set; } public Vector3 CarRotation { get; set; } public Vector3 GuardPosition { get; set; } public Vector3 GuardRotation { get; set; } public List BarrelObjects { get; set; } public ESupplyType Type { get; set; } } [RegisterTypeInIl2Cpp] public class Quest_TrueBrothers : ModQuestBase { protected readonly TrueBrothersHelper _helper; public readonly List pileBasePos = new List { new Vector3(-14.6f, -4.77f, 168.2f), new Vector3(-14.6f, -4.77f, 168.6f), new Vector3(-14.4f, -4.77f, 168.2f), new Vector3(-14.4f, -4.77f, 168.6f), new Vector3(-14.8f, -4.77f, 168.7f), new Vector3(-15.3f, -4.77f, 168.6f) }; public readonly List ambushCopSpawnPositions = new List { new Vector3(-48.54f, -3.64f, 166.59f), new Vector3(-34.67f, -2.54f, 155.85f), new Vector3(-42.38f, -2.54f, 152.52f) }; public static readonly Vector3 followDestination = new Vector3(-32.68f, -2.54f, 168.73f); public CartelGoon startGoon; public static readonly float startGoonMoveSpeed = 0.4f; public List alliedGoons = new List(); public List ambushCops = new List(); public GameObject brickBase; public List spawnedDecor = new List(); public StorageEntity destinationStorage; public LandVehicle spawnedVehicle; public List> spawnedBrickPiles = new List>(); public int totalBricksCount; public int bricksInPallet; public int bricksInSUV; public int currentAmbushWave = 1; public int currentDeadCopsCount; public bool ambushDefeated; public bool preCompleteQueued; public float defaultM1911Dmg; public QuestEntry QuestEntry_FollowGoon; private UnityAction _followGoonAction; public QuestEntry QuestEntry_MoveCocaine; private UnityAction _moveCocaineAction; public QuestEntry QuestEntry_PoliceAmbush; private Action _playerArrestedAction; public static List skinColors = new List { new Color(0.729412f, 0.596078f, 0.541176f), new Color(0.7768f, 0.5931f, 0.4442f), new Color(0.364705f, 0.298039f, 0.270588f), new Color(0.454902f, 0.372549f, 0.337255f), new Color(0.7768f, 0.5931f, 0.4442f) }; public static List randomFaceLayers = new List { "Avatar/Layers/Face/Face_SmugPout", "Avatar/Layers/Face/Face_SlightSmile", "Avatar/Layers/Face/Face_Neutral", "Avatar/Layers/Face/Face_NeutralPout" }; public static List randomMaleHairLayers = new List { "Avatar/Hair/Balding/Balding", "Avatar/Hair/BuzzCut/BuzzCut", "Avatar/Hair/Peaked/Peaked", "Avatar/Hair/DoubleTopKnot/DoubleTopKnot" }; public static List randomFacialHairLayers = new List { "Avatar/Layers/Face/FacialHair_Swirl", "Avatar/Layers/Face/FacialHair_Goatee" }; public static List randomFemaleHairLayers = new List { "Avatar/Hair/MidFringe/MidFringe", "Avatar/Hair/LowBun/LowBun", "Avatar/Hair/DoubleTopKnot/DoubleTopKnot" }; public static List randomHairColors = new List { new Color(0.141176f, 0.109803f, 0.066666f), new Color(0.666666f, 0.533333f, 0.4f), new Color(0.50196f, 0.501965f, 0.5019607f), new Color(0.294117f, 0.196078f, 0.121568f), new Color(0.6071f, 0.3886f, 0.087f), new Color(0.0804f, 0.0699f, 0.0624f), new Color(0.1278f, 0.1278f, 0.1278f) }; public Quest_TrueBrothers(IntPtr ptr) : base(ptr) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) _helper = new TrueBrothersHelper(this); } public Quest_TrueBrothers() : base(ClassInjector.DerivedConstructorPointer()) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this); } public override void Complete(bool network = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 try { if ((int)((Quest)this).State != 2) { if (InstanceFinder.IsServer && !Singleton.Instance.IsLoading) { NetworkSingleton.Instance.AddXP(((Quest)this).CompletionXP); } ((Quest)this).SetQuestState((EQuestState)2, false); NetworkSingleton.Instance.PlayCompleteQuestSound(); ((Quest)this).End(); } } catch (Exception) { throw; } } public override void Fail(bool network = true) { try { ((Quest)this).SetQuestState((EQuestState)3, false); ((Quest)this).End(); } catch (Exception) { throw; } } public override void End() { EndGameQuest.trueBrothersCompleted = true; try { if ((Object)(object)((Quest)this).hudUI != (Object)null) { ((Quest)this).hudUI.Complete(); } TimeManager instance = NetworkSingleton.Instance; Action action = ((Quest)this).OnMinPass; if ((Object)(object)instance == (Object)null) { return; } instance.onMinutePass.Remove(Action.op_Implicit(action)); CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.CleanupTrueBrothersQuest())); } catch (Exception) { throw; } ((Component)this).gameObject.SetActive(false); } public void SetupSelf() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00d6: 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) _helper.InitializeQuest("Allied Supplies", 1500); _followGoonAction = UnityAction.op_Implicit((Action)OnFollowGoonComplete); _helper.InitializeQuestEntry(ref QuestEntry_FollowGoon, "FollowGoon", "Follow the Cartel Goon to Northern Waterfront", new PoIConfig(usePoI: true, useParent: true, useTransformLocal: true, ((Component)startGoon).transform, Vector3.zero), _followGoonAction); _moveCocaineAction = UnityAction.op_Implicit((Action)OnMoveCocaineComplete); _helper.InitializeQuestEntry(ref QuestEntry_MoveCocaine, "MoveCocaine", "Move cocaine from the pallets to the SUV", new PoIConfig(usePoI: false, useParent: false, useTransformLocal: false), _moveCocaineAction); _helper.InitializeQuestEntry(ref QuestEntry_PoliceAmbush, "PoliceAmbush", "Defeat the police ambush", new PoIConfig(usePoI: false, useParent: false, useTransformLocal: false)); TimeManager instance = NetworkSingleton.Instance; Action action = ((Quest)this).OnMinPass; instance.onMinutePass += Action.op_Implicit(action); _helper.StartQuestFromEntry(QuestEntry_FollowGoon); Player local = Player.Local; local.onArrested += Action.op_Implicit((Action)OnPlayerArrested); CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.SpawnCarMeetup())); } public override void OnMinPass() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Invalid comparison between Unknown and I4 //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Invalid comparison between Unknown and I4 //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Expected O, but got Unknown //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Invalid comparison between Unknown and I4 if (!CartelEnforcer.registered || Singleton.Instance.IsSaving || EndGameQuest.trueBrothersCompleted || (int)((Quest)this).State != 1 || !InstanceFinder.IsServer) { return; } if ((int)NetworkSingleton.Instance.Status != 1) { ((Quest)this).Fail(true); } if (preCompleteQueued) { return; } if (NetworkSingleton.Instance.CurrentTime >= 359 && NetworkSingleton.Instance.CurrentTime <= 701) { ((Quest)this).Fail(true); } if ((Object)(object)QuestEntry_FollowGoon != (Object)null && (Object)(object)startGoon != (Object)null && (int)QuestEntry_FollowGoon.State == 1) { if (((NPC)startGoon).Health.IsDead || ((NPC)startGoon).Health.IsKnockedOut || ((Object)(object)((NPC)startGoon).Behaviour.activeBehaviour != (Object)null && (Object)(object)((NPC)startGoon).Behaviour.activeBehaviour == (Object)(object)((NPC)startGoon).Behaviour.CombatBehaviour)) { ((Quest)this).Fail(true); } ((Component)QuestEntry_FollowGoon.PoILocation).transform.position = ((Component)startGoon).transform.position; if (Vector3.Distance(Player.Local.CenterPointTransform.position, followDestination) < 5f) { QuestEntry_FollowGoon.Complete(); return; } if (!((NPC)startGoon).Movement.HasDestination) { ((NPC)startGoon).Movement.SetDestination(followDestination); } if (((NPC)startGoon).Movement.IsPaused) { ((NPC)startGoon).Movement.ResumeMovement(); } } if ((Object)(object)QuestEntry_MoveCocaine != (Object)null && (int)QuestEntry_MoveCocaine.State == 1) { int num = totalBricksCount - bricksInSUV; int num2 = totalBricksCount - bricksInPallet; if (Mathf.Abs(totalBricksCount - (num + num2)) > 0 && Vector3.Distance(Player.Local.CenterPointTransform.position, ((Component)destinationStorage).transform.position) > 14f) { ((Quest)this).Fail(true); ICombatTargetable component = ((Component)Player.Local).GetComponent(); startGoon.AttackEntity(component, true); foreach (CartelGoon alliedGoon in alliedGoons) { ((NPC)alliedGoon).Movement.SpeedController.AddSpeedControl(new SpeedControl("combat", 5, 0.75f)); alliedGoon.AttackEntity(component, true); } } } if (!((Object)(object)QuestEntry_PoliceAmbush != (Object)null) || (int)QuestEntry_PoliceAmbush.State != 1) { return; } List list = new List(); if (currentDeadCopsCount != ambushCops.Count) { for (int i = 0; i < ambushCops.Count; i++) { PoliceOfficer val = ambushCops[i]; if (((NPC)val).Health.IsDead || ((NPC)val).Health.IsKnockedOut || ((NPC)val).IsInVehicle) { continue; } list.Add(i); if ((Object)(object)((NPC)val).Behaviour.CombatBehaviour.currentWeapon == (Object)null) { ((NPC)val).Behaviour.CombatBehaviour.SetWeapon("Avatar/Equippables/M1911"); } if ((Object)(object)((NPC)val).Behaviour.activeBehaviour != (Object)(object)((NPC)val).Behaviour.CombatBehaviour) { ((Behaviour)((NPC)val).Behaviour.CombatBehaviour).Enable_Networked(); } if (((NPC)val).Behaviour.CombatBehaviour.Target != null) { continue; } if (Random.Range(0f, 1f) > 0.5f) { foreach (CartelGoon alliedGoon2 in alliedGoons) { if (!((NPC)alliedGoon2).Health.IsDead && !((NPC)alliedGoon2).Health.IsKnockedOut) { if (((Behaviour)((NPC)val).Awareness).enabled) { ((NPC)val).Awareness.SetAwarenessActive(false); } ((NPC)val).Behaviour.CombatBehaviour.SetTarget(((Component)alliedGoon2).GetComponent().NetworkObject); break; } } } else { if (!((Behaviour)((NPC)val).Awareness).enabled) { ((NPC)val).Awareness.SetAwarenessActive(true); } ((NPC)val).Behaviour.CombatBehaviour.SetTarget(((Component)Player.Local).GetComponent().NetworkObject); } } } foreach (CartelGoon alliedGoon3 in alliedGoons) { if (((NPC)alliedGoon3).Health.IsDead || ((NPC)alliedGoon3).Health.IsKnockedOut) { continue; } if ((Object)(object)((NPC)alliedGoon3).Behaviour.CombatBehaviour.currentWeapon == (Object)null) { ((NPC)alliedGoon3).Behaviour.CombatBehaviour.SetWeapon("Avatar/Equippables/M1911"); } if (list.Count > 0 && ((NPC)alliedGoon3).Behaviour.CombatBehaviour.Target == null) { int index = Random.Range(0, list.Count); PoliceOfficer val2 = ambushCops[list[index]]; ((NPC)alliedGoon3).Behaviour.CombatBehaviour.SetTarget(((Component)val2).GetComponent().NetworkObject); if ((Object)(object)((NPC)alliedGoon3).Behaviour.activeBehaviour == (Object)null || (Object)(object)((NPC)alliedGoon3).Behaviour.activeBehaviour != (Object)(object)((NPC)alliedGoon3).Behaviour.CombatBehaviour) { ((Behaviour)((NPC)alliedGoon3).Behaviour.CombatBehaviour).Enable_Networked(); } } } if ((int)Player.Local.CrimeData.CurrentPursuitLevel == 0 && ambushDefeated) { if (!preCompleteQueued) { preCompleteQueued = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.PreComplete())); } } else if ((int)Player.Local.CrimeData.CurrentPursuitLevel != 4 && !ambushDefeated) { Player.Local.CrimeData.SetPursuitLevel((EPursuitLevel)4); } } public void OnFollowGoonComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if (((Object)(object)QuestEntry_FollowGoon != (Object)null && (int)QuestEntry_FollowGoon.State == 3) || (Object)(object)QuestEntry_MoveCocaine == (Object)null) { return; } QuestEntry_MoveCocaine.Begin(); if ((Object)(object)QuestEntry_MoveCocaine != (Object)null) { if (QuestEntry_MoveCocaine.compassElement != null) { QuestEntry_MoveCocaine.compassElement.Visible = false; } else { QuestEntry_MoveCocaine.CreateCompassElement(); QuestEntry_MoveCocaine.compassElement.Visible = false; } } if ((Delegate)(object)_followGoonAction != (Delegate)null) { QuestEntry_FollowGoon.onComplete.RemoveListener(_followGoonAction); _followGoonAction = null; } } public void OnMoveCocaineComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if (((Object)(object)QuestEntry_MoveCocaine != (Object)null && (int)QuestEntry_MoveCocaine.State == 3) || (Object)(object)QuestEntry_PoliceAmbush == (Object)null) { return; } QuestEntry_PoliceAmbush.Begin(); if ((Object)(object)QuestEntry_PoliceAmbush != (Object)null) { if (QuestEntry_PoliceAmbush.compassElement != null) { QuestEntry_PoliceAmbush.compassElement.Visible = false; } else { QuestEntry_PoliceAmbush.CreateCompassElement(); QuestEntry_PoliceAmbush.compassElement.Visible = false; } } if ((Object)(object)QuestEntry_MoveCocaine != (Object)null) { QuestEntry_MoveCocaine.onComplete.RemoveListener(_moveCocaineAction); _moveCocaineAction = null; } CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.SpawnPoliceAmbush())); } public void OnPlayerArrested() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)((Quest)this).State == 1) { ((Quest)this).Fail(true); if (_playerArrestedAction != null) { Player local = Player.Local; local.onArrested -= Action.op_Implicit(_playerArrestedAction); _playerArrestedAction = null; } } } public void SetRandomOfficerAvatar(PoliceOfficer offc) { AvatarSettings val = ScriptableObject.CreateInstance(); List accessorySettings = ((NPC)offc).Avatar.CurrentSettings.AccessorySettings; List bodyLayerSettings = ((NPC)offc).Avatar.CurrentSettings.BodyLayerSettings; List faceLayerSettings = SetRandomLook(val); val.AccessorySettings = new List(); for (int i = 0; i < accessorySettings.Count; i++) { val.AccessorySettings.Add(accessorySettings[i]); } val.BodyLayerSettings = new List(); for (int j = 0; j < bodyLayerSettings.Count; j++) { val.BodyLayerSettings.Add(bodyLayerSettings[j]); } val.FaceLayerSettings = faceLayerSettings; ((NPC)offc).Avatar.LoadAvatarSettings(val); } public static List SetRandomLook(AvatarSettings newSettings) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) List val = new List(); for (int i = 0; i < 6; i++) { val.Add(new LayerSetting { layerPath = "", layerTint = Color.white }); } LayerSetting val2 = val[0]; val2.layerPath = randomFaceLayers[Random.Range(0, randomFaceLayers.Count)]; val2.layerTint = new Color(0f, 0f, 0f, 1f); val[0] = val2; newSettings.Gender = Random.Range(0f, 1f); if (Random.Range(0f, 1f) > 0.6f && newSettings.Gender < 0.5f) { LayerSetting val3 = val[1]; val3.layerPath = randomFacialHairLayers[Random.Range(0, randomFacialHairLayers.Count)]; val3.layerTint = new Color(0f, 0f, 0f, 1f); val[1] = val3; } LayerSetting val4 = val[3]; val4.layerPath = "Avatar/Layers/Face/EyeShadow"; val4.layerTint = new Color(0f, 0f, 0f, 0.96f); val[3] = val4; if (Random.Range(0f, 1f) > 0.3f) { LayerSetting val5 = val[4]; string text = ""; text = ((!(Random.Range(0f, 1f) > 0.5f)) ? "Avatar/Layers/Face/Freckles" : "Avatar/Layers/Face/OldPersonWrinkles"); val5.layerPath = text; val5.layerTint = new Color(0f, 0f, 0f, 0.55f); val[4] = val5; } newSettings.UseCombinedLayer = false; newSettings.EyebrowScale = Random.Range(1f, 1.1f); newSettings.EyebrowThickness = Random.Range(1f, 1.4f); newSettings.EyebrowRestingHeight = Random.Range(-1f, -1.4f); newSettings.EyeBallTint = new Color(1f, 1f, 1f); newSettings.EyeballMaterialIdentifier = "Default"; newSettings.Height = Random.Range(0.96f, 1f); newSettings.HairColor = randomHairColors[Random.Range(0, randomHairColors.Count)]; if (newSettings.Gender < 0.5f) { newSettings.HairPath = randomMaleHairLayers[Random.Range(0, randomMaleHairLayers.Count)]; } else { newSettings.HairPath = randomFemaleHairLayers[Random.Range(0, randomFemaleHairLayers.Count)]; } newSettings.Weight = Random.Range(0.3f, 0.7f); newSettings.PupilDilation = 0.55f; newSettings.RightEyeLidColor = new Color(0.4118f, 0.3216f, 0.2471f); newSettings.LeftEyeLidColor = new Color(0.4118f, 0.3216f, 0.2471f); newSettings.RightEyeRestingState = new EyeLidConfiguration { bottomLidOpen = 0.2719f, topLidOpen = 0.4313f }; newSettings.LeftEyeRestingState = new EyeLidConfiguration { bottomLidOpen = 0.2719f, topLidOpen = 0.4313f }; newSettings.SkinColor = skinColors[Random.Range(0, skinColors.Count)]; return val; } } public class TrueBrothersHelper : QuestHelperBase { public TrueBrothersHelper(Quest_TrueBrothers quest) : base(quest) { } public IEnumerator SpawnCarMeetup() { _quest.alliedGoons.Add(_quest.startGoon); NetworkManager netManager = Object.FindObjectOfType(true); PrefabObjects spawnablePrefabs = netManager.SpawnablePrefabs; NetworkObject nobSuv = null; GameObject objPallet = null; for (int i = 0; i < spawnablePrefabs.GetObjectCount(); i++) { NetworkObject val = spawnablePrefabs.GetObject(true, i); object obj; if (val == null) { obj = null; } else { GameObject gameObject = ((Component)val).gameObject; obj = ((gameObject != null) ? ((Object)gameObject).name : null); } if ((string?)obj == "BoxSUV") { nobSuv = val; } } GameObject val2 = GameObject.Find("Map/Hyland Point/Region_Northtown/Hardware Store/Loading bay/PalletStand (2)/Container"); int num = 0; for (int j = 0; j < val2.transform.childCount; j++) { Transform child = val2.transform.GetChild(j); if (((Object)child).name == "Pallet") { num++; if (num == 2) { objPallet = ((Component)child).gameObject; break; } } } _ = (Object)(object)objPallet == (Object)null; Func func = Registry.GetItem; ItemInstance cokeInst = null; ItemDefinition val3 = func("cocaine"); cokeInst = val3.GetDefaultInstance(1); ProductItemInstance val4 = ((Il2CppObjectBase)cokeInst).TryCast(); if (val4 != null) { ((QualityItemInstance)val4).Quality = (EQuality)3; if ((Object)(object)CartelInventory.brickPackaging != (Object)null) { val4.SetPackaging(CartelInventory.brickPackaging); } if ((Object)(object)((StorableItemInstance)val4).StoredItem != (Object)null) { FilledPackaging_StoredItem val5 = ((Il2CppObjectBase)((StorableItemInstance)val4).StoredItem).TryCast(); if ((Object)(object)val5 != (Object)null) { GameObject gameObject2 = ((Component)((ProductVisualsSetter)val5.Visuals.CocaineVisuals).VisualsContainer).gameObject; if ((Object)(object)gameObject2 != (Object)null) { _quest.brickBase = Object.Instantiate(gameObject2); ((Object)_quest.brickBase).name = "CokeBrickDecor"; _quest.brickBase.transform.SetParent(((Component)_quest).transform); } } } } _quest.spawnedDecor.Add(_quest.brickBase); NetworkObject boxSuv1 = Object.Instantiate(nobSuv); _quest.spawnedDecor.Add(((Component)boxSuv1).gameObject); netManager.ServerManager.Spawn(boxSuv1, (NetworkConnection)null, default(Scene)); yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered || (int)((Quest)_quest).State != 1) { yield break; } ((Component)boxSuv1).transform.parent = ((Component)Singleton.Instance).transform; ((Component)boxSuv1).gameObject.SetActive(true); ((Component)boxSuv1).transform.SetPositionAndRotation(new Vector3(-19.0712f, -4.1883f, 174.4196f), Quaternion.Euler(0.0009f, 0.4645f, 0f)); _quest.destinationStorage = ((Component)boxSuv1).GetComponent(); _quest.destinationStorage.AccessSettings = (EAccessSettings)2; yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered || (int)((Quest)_quest).State != 1) { yield break; } NetworkObject boxSuv2 = Object.Instantiate(nobSuv); _quest.spawnedDecor.Add(((Component)boxSuv2).gameObject); ((Component)boxSuv2).transform.SetPositionAndRotation(new Vector3(-20.2015f, -3.9164f, 167.2993f), Quaternion.Euler(2.5122f, 79.6851f, 359.3438f)); netManager.ServerManager.Spawn(boxSuv2, (NetworkConnection)null, default(Scene)); yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered || (int)((Quest)_quest).State != 1) { yield break; } ((Component)boxSuv2).transform.parent = ((Component)Singleton.Instance).transform; ((Component)boxSuv2).gameObject.SetActive(true); yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered || (int)((Quest)_quest).State != 1) { yield break; } ((Component)boxSuv2).GetComponent().HeadlightsOn = true; GameObject pallet = Object.Instantiate(objPallet); _quest.spawnedDecor.Add(pallet); pallet.transform.parent = ((Component)Singleton.Instance).transform; pallet.gameObject.SetActive(true); pallet.transform.position = new Vector3(-14.93f, -5f, 168.7f); Rigidbody component = pallet.GetComponent(); if ((Object)(object)component != (Object)null) { component.isKinematic = true; } GameObject val6 = new GameObject("InteractableCollider"); val6.transform.parent = pallet.transform; val6.transform.localPosition = new Vector3(0.4f, 0f, -0.5f); BoxCollider val7 = val6.AddComponent(); val7.size = new Vector3(0.5f, 2f, 0.5f); InteractableObject palletInteractable = pallet.AddComponent(); palletInteractable.message = "Pick Up"; palletInteractable.displayLocationCollider = (Collider)(object)val7; palletInteractable.onInteractStart.AddListener(UnityAction.op_Implicit((Action)OnPalletInteracted)); for (int k = 0; k < _quest.pileBasePos.Count; k++) { List newPile = new List(); Vector3 basePos = _quest.pileBasePos[k]; for (int l = 0; l < Random.Range(6, 11); l++) { yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered || (int)((Quest)_quest).State != 1) { yield break; } GameObject val8 = Object.Instantiate(_quest.brickBase, pallet.transform); val8.transform.position = new Vector3(basePos.x, basePos.y + 0.06f * (float)l, basePos.z); val8.transform.rotation = Quaternion.Euler(0f, Mathf.Round(Random.Range(85f, 95f)), 0f); val8.gameObject.SetActive(true); _quest.spawnedDecor.Add(val8); newPile.Add(val8); _quest.totalBricksCount++; } _quest.spawnedBrickPiles.Add(newPile); } _quest.bricksInPallet = _quest.totalBricksCount; if (NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count < 2) { foreach (CartelGoon item in (Il2CppArrayBase)(object)NetworkSingleton.Instance.GoonPool.goons) { if (NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count >= 2) { break; } if (NetworkSingleton.Instance.GoonPool.spawnedGoons.Contains(item) && item.IsGoonSpawned && (((NPC)item).Health.IsDead || ((NPC)item).Health.IsKnockedOut)) { item.Despawn(); } } } CartelGoon val9 = NetworkSingleton.Instance.GoonPool.SpawnGoon(new Vector3(-32.68f, -2.54f, 168.73f)); ((Component)((NPC)val9).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)val9).Behaviour.ScheduleManager.DisableSchedule(); ((Component)val9).transform.rotation = Quaternion.Euler(0f, 226f, 0f); _quest.alliedGoons.Add(val9); CartelGoon val10 = NetworkSingleton.Instance.GoonPool.SpawnGoon(new Vector3(-31f, -2.54f, 168.73f)); ((Component)((NPC)val10).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)val10).Behaviour.ScheduleManager.DisableSchedule(); ((Component)val10).transform.rotation = Quaternion.Euler(0f, 226f, 0f); _quest.alliedGoons.Add(val10); foreach (CartelGoon alliedGoon in _quest.alliedGoons) { ((NPC)alliedGoon).HasUmbrella = false; ((NPC)alliedGoon).Behaviour.CombatBehaviour.SetWeapon("Avatar/Equippables/M1911"); if ((Object)(object)((NPC)alliedGoon).Behaviour.CombatBehaviour.currentWeapon != (Object)null) { AvatarRangedWeapon val11 = ((Il2CppObjectBase)((NPC)alliedGoon).Behaviour.CombatBehaviour.currentWeapon).Cast(); if ((Object)(object)val11 != (Object)null) { _quest.defaultM1911Dmg = val11.Damage; val11.Damage = 100f; } } } Action val12 = Action.op_Implicit((Action)CloseTrigger); StorageEntity destinationStorage = _quest.destinationStorage; destinationStorage.onClosed += val12; _quest.destinationStorage.StorageEntitySubtitle = "Cocaine Transport"; void CloseTrigger() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Invalid comparison between Unknown and I4 if (!((Object)(object)_quest.QuestEntry_MoveCocaine == (Object)null) && (int)_quest.QuestEntry_MoveCocaine.State == 1) { int num2 = 0; Enumerator enumerator3 = _quest.destinationStorage.ItemSlots.GetEnumerator(); while (enumerator3.MoveNext()) { ItemSlot current3 = enumerator3.Current; if (current3.ItemInstance != null && ((BaseItemDefinition)current3.ItemInstance.Definition).ID == "cocaine") { ProductItemInstance val13 = null; val13 = ((Il2CppObjectBase)current3.ItemInstance).TryCast(); if (val13 != null && (int)((QualityItemInstance)val13).Quality == 3 && (Object)(object)val13.AppliedPackaging == (Object)(object)CartelInventory.brickPackaging) { num2 += ((BaseItemInstance)val13).Quantity; } } } _quest.bricksInSUV = num2; if (num2 >= _quest.totalBricksCount) { _quest.destinationStorage.AccessSettings = (EAccessSettings)0; _quest.QuestEntry_MoveCocaine.Complete(); } } } void OnPalletInteracted() { if (PlayerSingleton.Instance.CanItemFitInInventory(cokeInst, 1)) { if (_quest.spawnedBrickPiles.Count > 0) { int num2 = -1; int num3 = 0; for (int m = 0; m < _quest.spawnedBrickPiles.Count; m++) { if (_quest.spawnedBrickPiles[m].Count > num3) { num3 = _quest.spawnedBrickPiles[m].Count; num2 = m; } } if (num2 != -1) { int index = _quest.spawnedBrickPiles[num2].Count - 1; GameObject obj2 = _quest.spawnedBrickPiles[num2][index]; _quest.spawnedBrickPiles[num2].RemoveAt(index); Object.Destroy((Object)(object)obj2); if (_quest.spawnedBrickPiles[num2].Count == 0) { _quest.spawnedBrickPiles.RemoveAt(num2); } PlayerSingleton.Instance.AddItemToInventory(cokeInst); _quest.bricksInPallet--; } } if (_quest.spawnedBrickPiles.Count == 0) { Object.Destroy((Object)(object)palletInteractable); } } } } public IEnumerator InstantiateAmbushNPCs() { for (int i = 0; i < 3; i++) { NetworkManager netManager = Object.FindObjectOfType(true); GameObject copNet = Object.Instantiate(EndGameQuest.copBaseClone); NetworkObject component = copNet.GetComponent(); PoliceOfficer offc = copNet.gameObject.GetComponent(); offc.AutoDeactivate = false; ((Object)copNet).name = $"RuntimeOfficer_{i}"; yield return MelonCoroutines.Start(NPCInitHelper.InitiateClone(component, netManager)); NPC component2 = copNet.gameObject.GetComponent(); component2.NPCData.BasicInfo.ID = $"RuntimeOfficer_{i}"; component2.NPCData.BasicInfo.FirstName = "Officer"; component2.NPCData.BasicInfo.LastName = ""; component2.NPCData.Inventory.CanBePickpocketed = false; ((Component)component2).transform.parent = NetworkSingleton.Instance.NPCContainer; if (!NPCManager.NPCRegistry.Contains(component2)) { NPCManager.NPCRegistry.Add(component2); } netManager.ServerManager.Spawn(copNet, (NetworkConnection)null, default(Scene)); copNet.gameObject.SetActive(true); ((Component)((NPC)offc).DialogueHandler).GetComponent().Choices.Clear(); ((Component)copNet.transform.Find("Avatar")).gameObject.SetActive(true); ((Behaviour)copNet.GetComponent()).enabled = true; _quest.SetRandomOfficerAvatar(offc); offc.PursuitBehaviour.arrestingEnabled = false; ((NPC)offc).Behaviour.ScheduleManager.DisableSchedule(); ((NPC)offc).Movement.PauseMovement(); ((NPC)offc).Movement.Warp(_quest.ambushCopSpawnPositions[i]); ((NPC)offc).Awareness.VisionCone.WorldspaceIconsEnabled = false; ((NPC)offc).Awareness.SetAwarenessActive(false); _quest.ambushCops.Add(offc); } } public IEnumerator SpawnPoliceAmbush() { yield return MelonCoroutines.Start(InstantiateAmbushNPCs()); ((NPC)_quest.ambushCops[0]).Behaviour.CombatBehaviour.SetTarget(((Component)_quest.alliedGoons[0]).GetComponent().NetworkObject); ((NPC)_quest.alliedGoons[0]).Behaviour.CombatBehaviour.SetTarget(((Component)_quest.ambushCops[0]).GetComponent().NetworkObject); ((NPC)_quest.ambushCops[1]).Behaviour.CombatBehaviour.SetTarget(((Component)_quest.alliedGoons[1]).GetComponent().NetworkObject); ((NPC)_quest.alliedGoons[1]).Behaviour.CombatBehaviour.SetTarget(((Component)_quest.ambushCops[1]).GetComponent().NetworkObject); ((NPC)_quest.ambushCops[2]).Behaviour.CombatBehaviour.SetTarget(((Component)Player.Local).GetComponent().NetworkObject); ((NPC)_quest.ambushCops[2]).Awareness.SetAwarenessActive(true); ((NPC)_quest.alliedGoons[2]).Behaviour.CombatBehaviour.SetTarget(((Component)_quest.ambushCops[2]).GetComponent().NetworkObject); foreach (PoliceOfficer ambushCop in _quest.ambushCops) { PoliceOfficer offc = ambushCop; UnityAction OnCopDiedAction = null; OnCopDiedAction = UnityAction.op_Implicit((Action)OnCopDied); ((NPC)offc).Health.onDieOrKnockedOut.AddListener(OnCopDiedAction); ((NPC)offc).Movement.ResumeMovement(); ((NPC)offc).Movement.SetDestination(Quest_TrueBrothers.followDestination); ((Behaviour)((NPC)offc).Behaviour.CombatBehaviour).Enable_Networked(); void OnCopDied() { _quest.currentDeadCopsCount++; if ((Delegate)(object)OnCopDiedAction != (Delegate)null) { ((NPC)offc).Health.onDieOrKnockedOut.RemoveListener(OnCopDiedAction); OnCopDiedAction = null; } if (_quest.currentDeadCopsCount == _quest.ambushCops.Count && _quest.currentAmbushWave == 1) { _quest.currentAmbushWave++; CartelEnforcer.coros.Add(MelonCoroutines.Start(SpawnSecondWave())); } } } yield return CartelEnforcer.Wait1; if (!CartelEnforcer.registered) { yield break; } foreach (PoliceOfficer ambushCop2 in _quest.ambushCops) { ((Behaviour)((NPC)ambushCop2).Behaviour.CombatBehaviour).Enable_Networked(); ((NPC)ambushCop2).Behaviour.CombatBehaviour.SetWeapon("Avatar/Equippables/M1911"); if ((Object)(object)((NPC)ambushCop2).Behaviour.CombatBehaviour.currentWeapon != (Object)null) { AvatarRangedWeapon val = ((Il2CppObjectBase)((NPC)ambushCop2).Behaviour.CombatBehaviour.currentWeapon).Cast(); if ((Object)(object)val != (Object)null) { val.CanShootWhileMoving = true; val.MaxMovingShotsBeforeReposition = 2; val.MaxStationaryShotsBeforeReposition = 1; } } } foreach (CartelGoon alliedGoon in _quest.alliedGoons) { ((NPC)alliedGoon).Behaviour.CombatBehaviour.SetWeapon("Avatar/Equippables/M1911"); if ((Object)(object)((NPC)alliedGoon).Behaviour.CombatBehaviour.currentWeapon != (Object)null) { AvatarRangedWeapon val2 = ((Il2CppObjectBase)((NPC)alliedGoon).Behaviour.CombatBehaviour.currentWeapon).Cast(); if ((Object)(object)val2 != (Object)null) { val2.Damage = _quest.defaultM1911Dmg; } } ((NPC)alliedGoon).Movement.ResumeMovement(); ((Behaviour)((NPC)alliedGoon).Behaviour.CombatBehaviour).Enable_Networked(); } yield return CartelEnforcer.Wait1; if (CartelEnforcer.registered) { Player.Local.CrimeData.SetPursuitLevel((EPursuitLevel)4); } } public IEnumerator SpawnSecondWave() { yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { yield break; } LandVehicle val = ((Il2CppArrayBase)(object)PoliceStation.PoliceStations[0].PoliceVehicles)[1]; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(-17f, 0.975f, 94.75f); Quaternion val3 = Quaternion.Euler(Vector3.zero); LandVehicle policeVehicle = NetworkSingleton.Instance.SpawnAndReturnVehicle(val.vehicleCode, Vector3.zero, Quaternion.identity, false); ((Component)policeVehicle).gameObject.SetActive(true); _quest.spawnedVehicle = policeVehicle; policeVehicle.SetTransform_Server(val2, val3); ((Component)policeVehicle).GetComponent().MoveToRoadNetwork(false); _quest.currentDeadCopsCount = 0; foreach (PoliceOfficer ambushCop in _quest.ambushCops) { PoliceOfficer offc = ambushCop; ((NPC)offc).EnterVehicle((NetworkConnection)null, policeVehicle); ((NPC)offc).Health.Revive(); ((Behaviour)((NPC)offc).Behaviour.CombatBehaviour).Disable_Networked((NetworkConnection)null); ((UnityEventBase)((NPC)offc).Health.onDieOrKnockedOut).RemoveAllListeners(); UnityAction OnCopDiedAction = null; OnCopDiedAction = UnityAction.op_Implicit((Action)OnCopDied); ((NPC)offc).Health.onDieOrKnockedOut.AddListener(OnCopDiedAction); void OnCopDied() { _quest.currentDeadCopsCount++; if ((Delegate)(object)OnCopDiedAction != (Delegate)null) { ((NPC)offc).Health.onDieOrKnockedOut.RemoveListener(OnCopDiedAction); OnCopDiedAction = null; } if (_quest.currentDeadCopsCount == _quest.ambushCops.Count && _quest.currentAmbushWave == 2) { _quest.currentAmbushWave++; _quest.ambushDefeated = true; } } } ((Component)policeVehicle).GetComponentInChildren().IsOn = true; bool hasArrived = false; policeVehicle.Agent.Flags.OverriddenSpeed = 70f; policeVehicle.Agent.Flags.OverrideSpeed = true; policeVehicle.Agent.Navigate(new Vector3(-36.8969f, -3.025f, 145.251f), (NavigationSettings)null, NavigationCallback.op_Implicit((Action)CarNavComplete)); int maxNavigationTime = 20; int currentNavigationTime = 0; while (true) { yield return CartelEnforcer.Wait1; if (!CartelEnforcer.registered) { break; } currentNavigationTime++; if (currentNavigationTime >= maxNavigationTime) { if ((Delegate)(object)policeVehicle.Agent.storedNavigationCallback != (Delegate)null) { policeVehicle.Agent.storedNavigationCallback = null; } policeVehicle.Agent.StopNavigating(); hasArrived = true; } if (!hasArrived) { continue; } if ((int)Player.Local.CrimeData.CurrentPursuitLevel != 4) { Player.Local.CrimeData.SetPursuitLevel((EPursuitLevel)4); } foreach (PoliceOfficer offc2 in _quest.ambushCops) { yield return CartelEnforcer.Wait1; if (!CartelEnforcer.registered) { yield break; } ((NPC)offc2).ExitVehicle(); ((NPC)offc2).Awareness.SetAwarenessActive(true); ((NPC)offc2).Behaviour.CombatBehaviour.SetTarget(((Component)Player.Local).GetComponent().NetworkObject); ((Behaviour)((NPC)offc2).Behaviour.CombatBehaviour).Enable_Networked(); ((NPC)offc2).Behaviour.CombatBehaviour.SetWeapon("Avatar/Equippables/M1911"); if ((Object)(object)((NPC)offc2).Behaviour.CombatBehaviour.currentWeapon != (Object)null) { AvatarRangedWeapon val4 = ((Il2CppObjectBase)((NPC)offc2).Behaviour.CombatBehaviour.currentWeapon).Cast(); if ((Object)(object)val4 != (Object)null) { val4.CanShootWhileMoving = true; val4.MaxMovingShotsBeforeReposition = 2; val4.MaxStationaryShotsBeforeReposition = 1; } } } foreach (PoliceOfficer offc2 in _quest.ambushCops) { yield return CartelEnforcer.Wait01; if (CartelEnforcer.registered) { if (((NPC)offc2).IsInVehicle) { ((NPC)offc2).ExitVehicle(); } continue; } yield break; } for (int i = 0; i < _quest.alliedGoons.Count; i++) { ((NPC)_quest.alliedGoons[i]).Behaviour.CombatBehaviour.SetTarget(((Component)_quest.ambushCops[i]).GetComponent().NetworkObject); } break; } void CarNavComplete(ENavigationResult result) { if (!(!CartelEnforcer.registered || hasArrived)) { hasArrived = true; policeVehicle.Agent.storedNavigationCallback = null; policeVehicle.Agent.StopNavigating(); } } } public IEnumerator PreComplete() { foreach (CartelGoon goon in _quest.alliedGoons) { yield return CartelEnforcer.Wait1; if (CartelEnforcer.registered) { if (!((Object)(object)goon == (Object)(object)_quest.startGoon)) { ((Component)((NPC)goon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); ((NPC)goon).Behaviour.ScheduleManager.EnableSchedule(); } continue; } yield break; } bool playerConversated = false; DialogueController controller; GreetingOverride greeting; if (!((NPC)_quest.startGoon).Health.IsDead && !((NPC)_quest.startGoon).Health.IsKnockedOut && ((NPC)_quest.startGoon).IsConscious) { ((NPC)_quest.startGoon).Movement.SpeedController.AddSpeedControl(new SpeedControl("combat", 5, Quest_TrueBrothers.startGoonMoveSpeed)); ((Component)((NPC)_quest.startGoon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)_quest.startGoon).Behaviour.ScheduleManager.DisableSchedule(); controller = ((Component)((NPC)_quest.startGoon).DialogueHandler).gameObject.GetComponent(); greeting = new GreetingOverride(); greeting.ShouldShow = true; string text = (Player.Local.Avatar.IsMale() ? "brother" : "sister"); greeting.Greeting = "Thanks for your help! You're our true " + text + "!"; greeting.VOType = (EVOLineType)0; greeting.PlayVO = true; controller.AddGreetingOverride(greeting); DialogueChoice val = new DialogueChoice(); string text2 = "Continue"; val.ChoiceText = text2 ?? ""; val.Enabled = true; val.onChoosen.AddListener(UnityAction.op_Implicit((Action)ContinueChosen)); controller.AddDialogueChoice(val, 0); int maxTraverseTime = 30; int traverseTime = 0; bool playerConversatable = false; while (true) { yield return CartelEnforcer.Wait1; if (!CartelEnforcer.registered) { yield break; } if (traverseTime >= maxTraverseTime) { break; } traverseTime++; if ((Object)(object)_quest.startGoon == (Object)null || ((NPC)_quest.startGoon).Health.IsDead || ((NPC)_quest.startGoon).Health.IsKnockedOut || !((NPC)_quest.startGoon).IsConscious || (Object)(object)((NPC)_quest.startGoon).Behaviour.activeBehaviour == (Object)(object)((NPC)_quest.startGoon).Behaviour.CombatBehaviour) { break; } if (!playerConversated && playerConversatable) { ((NPC)_quest.startGoon).Movement.EndSetDestination((WalkResult)4); ((NPC)_quest.startGoon).Movement.FacePoint(Player.Local.CenterPointTransform.position, 0.5f); ((NPC)_quest.startGoon).Movement.PauseMovement(); controller.StartGenericDialogue(false); playerConversated = true; break; } if (Vector3.Distance(Player.Local.CenterPointTransform.position, ((NPC)_quest.startGoon).CenterPoint) < 3f) { yield return (object)new WaitUntil(Func.op_Implicit((Func)EndGameQuest.CanStartConversate)); playerConversatable = true; continue; } if (!((NPC)_quest.startGoon).Movement.HasDestination) { ((NPC)_quest.startGoon).Movement.SetDestination(Player.Local.CenterPointTransform); } if (((NPC)_quest.startGoon).Movement.IsPaused) { ((NPC)_quest.startGoon).Movement.ResumeMovement(); } } ((Component)((NPC)_quest.startGoon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); ((NPC)_quest.startGoon).Behaviour.ScheduleManager.EnableSchedule(); } if ((int)((Quest)_quest).State == 1 && !playerConversated) { ((Quest)_quest).Complete(true); } void ContinueChosen() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 controller.npc.PlayVO((EVOLineType)3, false); controller.handler.ContinueSubmitted(); if ((int)((Quest)_quest).State == 1) { ((Quest)_quest).Complete(true); } ((Component)((NPC)_quest.startGoon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); ((NPC)_quest.startGoon).Behaviour.ScheduleManager.EnableSchedule(); List choices = controller.Choices; choices.Clear(); controller.Choices = choices; controller.GreetingOverrides.Remove(greeting); } } } [HarmonyPatch(typeof(CombatBehaviour), "SetTarget_Client")] public static class CombatBehaviour_SetTarget_Client_Patch { public static bool Prefix(CombatBehaviour __instance, NetworkObject target) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)EndGameQuest.activeTrueBrothersQuest == (Object)null) { return true; } if ((int)((Quest)EndGameQuest.activeTrueBrothersQuest).State != 1) { return true; } if ((int)EndGameQuest.activeTrueBrothersQuest.QuestEntry_PoliceAmbush.State != 1) { return true; } CartelGoon val = null; PoliceOfficer val2 = null; val = ((Il2CppObjectBase)((Behaviour)__instance).Npc).TryCast(); val2 = ((Il2CppObjectBase)((Behaviour)__instance).Npc).TryCast(); if ((Object)(object)val == (Object)null && (Object)(object)val2 == (Object)null) { return true; } if ((Object)(object)val != (Object)null && (Object)(object)target == (Object)(object)((NetworkBehaviour)Player.Local).NetworkObject) { return false; } if ((Object)(object)val2 != (Object)null && (Object)(object)target == (Object)(object)((NetworkBehaviour)Player.Local).NetworkObject) { for (int i = 0; i < EndGameQuest.activeTrueBrothersQuest.alliedGoons.Count; i++) { CartelGoon val3 = EndGameQuest.activeTrueBrothersQuest.alliedGoons[i]; if (!((NPC)val3).Health.IsDead && !((NPC)val3).Health.IsKnockedOut && !(Vector3.Distance(((NPC)val3).CenterPoint, ((Behaviour)__instance).Npc.CenterPoint) > 40f)) { ((NPC)val3).Behaviour.CombatBehaviour.SetTarget(((Component)((Behaviour)__instance).Npc).GetComponent().NetworkObject); ((Behaviour)((NPC)val3).Behaviour.CombatBehaviour).Enable_Networked(); break; } } } return true; } } [Serializable] public class NewAmbushConfig { public int mapRegion; public Vector3 ambushPosition = Vector3.zero; public List spawnPoints = new List(); public float detectionRadius = 10f; } [Serializable] public class ListNewAmbush { public List addedAmbushes = new List(); } [Serializable] public class AmbushGeneralSettingsSerialized { public List RangedWeapons; public List MeleeWeapons; public int MinRankForRanged = 2; public bool AfterDealAmbushEnabled = true; public float AmbushTriggerProbability = 0.8f; public float AmbushWeaponLethality = 0.33f; } public static class AmbushOverrides { [HarmonyPatch(typeof(Ambush), "ContractReceiptRecorded")] public static class Ambush_ContractReceiptRecorded_Patch { [HarmonyPrefix] public static bool Prefix(Ambush __instance, ContractReceipt receipt) { return ambushSettings.AfterDealAmbushEnabled; } } public static ListNewAmbush ambushConfig; public static ListNewAmbush gameDefaultAmbush; public static AmbushGeneralSettingsSerialized ambushSettings; public static AvatarWeapon[] MeleeWeapons; public static AvatarWeapon[] RangedWeapons; public static IEnumerator ApplyGameDefaultAmbush() { yield return CartelEnforcer.Wait5; if (!CartelEnforcer.registered) { yield break; } ambushConfig = ConfigLoader.LoadAmbushConfig(); gameDefaultAmbush = ConfigLoader.LoadDefaultAmbushConfig(); ambushSettings = ConfigLoader.LoadAmbushSettings(); CartelRegionActivities[] array = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType(true)); int num = 0; CartelRegionActivities[] array2 = array; for (int i = 0; i < array2.Length; i++) { foreach (CartelAmbushLocation item in (Il2CppArrayBase)(object)array2[i].AmbushLocations) { List list = ((IEnumerable)item.AmbushPoints).Select((Transform tr) => tr.position).ToList(); NewAmbushConfig newAmbushConfig = gameDefaultAmbush.addedAmbushes.ElementAt(num); num++; if (newAmbushConfig.spawnPoints.Count != list.Count) { continue; } if (((Component)item).transform.position != newAmbushConfig.ambushPosition) { ((Component)item).transform.position = newAmbushConfig.ambushPosition; } if (item.DetectionRadius != newAmbushConfig.detectionRadius) { item.DetectionRadius = newAmbushConfig.detectionRadius; } for (int num2 = 0; num2 < newAmbushConfig.spawnPoints.Count; num2++) { if (newAmbushConfig.spawnPoints[num2] != list[num2]) { ((Il2CppArrayBase)(object)item.AmbushPoints)[num2].position = newAmbushConfig.spawnPoints[num2]; } } } } yield return null; } public static IEnumerator AddUserModdedAmbush() { yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { yield break; } CartelRegionActivities[] source = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)NetworkSingleton.Instance.Activities.RegionalActivities); int num = 1; if (ambushConfig.addedAmbushes == null || ambushConfig.addedAmbushes.Count <= 0) { yield break; } foreach (NewAmbushConfig config in ambushConfig.addedAmbushes) { CartelRegionActivities val = ((IEnumerable)source).FirstOrDefault((Func)((CartelRegionActivities act) => (int)act.Region == config.mapRegion)); Transform val2 = ((Component)val).transform.Find("Ambush locations"); GameObject val3 = new GameObject($"AmbushLocation ({val2.childCount})"); val3.SetActive(false); CartelAmbushLocation val4 = val3.AddComponent(); val3.transform.position = config.ambushPosition; val4.DetectionRadius = config.detectionRadius; GameObject val5 = new GameObject("SpawnPoints"); val5.transform.parent = val3.transform; val4.AmbushPoints = Il2CppReferenceArray.op_Implicit((Transform[])(object)new Transform[config.spawnPoints.Count]); int num2 = 0; foreach (Vector3 spawnPoint in config.spawnPoints) { GameObject val6 = new GameObject("SP" + ((num2 == 0) ? "" : (" (" + num2 + ")"))); val6.transform.position = spawnPoint; val6.transform.parent = val5.transform; ((Il2CppArrayBase)(object)val4.AmbushPoints)[num2] = val6.transform; ((Behaviour)val4).enabled = true; num2++; } num++; CartelAmbushLocation[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)val.AmbushLocations); CartelAmbushLocation[] array2 = (CartelAmbushLocation[])(object)new CartelAmbushLocation[array.Length + 1]; Array.Copy(array, array2, array.Length); array2[^1] = val4; val.AmbushLocations = Il2CppReferenceArray.op_Implicit(array2); val3.SetActive(true); val3.transform.parent = val2; } } public static IEnumerator SetAmbushGeneralSettings() { List list = new List(); List list2 = new List(); foreach (string rangedWeapon in ambushSettings.RangedWeapons) { if (rangedWeapon != null && !(rangedWeapon == string.Empty)) { string text = rangedWeapon.ToLower() switch { "m1911" => "Avatar/Equippables/M1911", "goldenm1911" => "Avatar/Equippables/M1911_Gold", "revolver" => "Avatar/Equippables/Revolver", "shotgun" => "Avatar/Equippables/PumpShotgun", _ => string.Empty, }; if (text != string.Empty) { list.Add(text); } } } foreach (string meleeWeapon in ambushSettings.MeleeWeapons) { if (meleeWeapon == null || meleeWeapon == string.Empty) { continue; } string text2 = ""; string text3 = meleeWeapon.ToLower(); if (!(text3 == "knife")) { if (text3 == "brokenbottle") { text2 = "Avatar/Equippables/BrokenBottle"; } } else { text2 = "Avatar/Equippables/Knife"; } if (text2 != string.Empty) { list2.Add(text2); } } if (list != null && list.Count > 0) { RangedWeapons = (AvatarWeapon[])(object)new AvatarWeapon[list.Count]; } if (list2 != null && list2.Count > 0) { MeleeWeapons = (AvatarWeapon[])(object)new AvatarWeapon[list2.Count]; } int count = list.Count; for (int i = 0; i < count; i++) { AvatarEquippable component = Object.Instantiate(((Il2CppObjectBase)Resources.Load(list[i])).TryCast(), new Vector3(0f, -5f, 0f), Quaternion.identity, (Transform)null).GetComponent(); if (!((Object)(object)component == (Object)null)) { if (!((Component)component).gameObject.activeSelf) { ((Component)component).gameObject.SetActive(true); } AvatarWeapon val = ((Il2CppObjectBase)component).TryCast(); if ((Object)(object)val != (Object)null) { RangedWeapons[i] = val; } AvatarRangedWeapon val2 = ((Il2CppObjectBase)component).TryCast(); if ((Object)(object)val2 != (Object)null && ambushSettings.AmbushWeaponLethality > 0f) { val2.Damage = Mathf.Lerp(val2.Damage, val2.Damage * 2f, ambushSettings.AmbushWeaponLethality); val2.AimTime_Max = Mathf.Lerp(val2.AimTime_Max, val2.AimTime_Max * 0.5f, ambushSettings.AmbushWeaponLethality); val2.AimTime_Min = Mathf.Lerp(val2.AimTime_Min, val2.AimTime_Min * 0.5f, ambushSettings.AmbushWeaponLethality); val2.HitChance_MaxRange = Mathf.Lerp(val2.HitChance_MaxRange, val2.HitChance_MaxRange * 2f, ambushSettings.AmbushWeaponLethality); val2.HitChance_MinRange = Mathf.Lerp(val2.HitChance_MinRange, val2.HitChance_MinRange * 2f, ambushSettings.AmbushWeaponLethality); ((AvatarWeapon)val2).MaxUseRange = Mathf.Lerp(((AvatarWeapon)val2).MaxUseRange, ((AvatarWeapon)val2).MaxUseRange * 2f, ambushSettings.AmbushWeaponLethality); ((AvatarWeapon)val2).MinUseRange = Mathf.Lerp(((AvatarWeapon)val2).MinUseRange, ((AvatarWeapon)val2).MinUseRange * 0.5f, ambushSettings.AmbushWeaponLethality); val2.MaxFireRate = Mathf.Lerp(val2.MaxFireRate, val2.MaxFireRate * 0.5f, ambushSettings.AmbushWeaponLethality); val2.ReloadTime = Mathf.Lerp(val2.ReloadTime, val2.ReloadTime * 0.5f, ambushSettings.AmbushWeaponLethality); } } } count = list2.Count; for (int j = 0; j < count; j++) { AvatarEquippable component2 = Object.Instantiate(((Il2CppObjectBase)Resources.Load(list2[j])).TryCast(), new Vector3(0f, -5f, 0f), Quaternion.identity, (Transform)null).GetComponent(); if (!((Object)(object)component2 == (Object)null)) { if (!((Component)component2).gameObject.activeSelf) { ((Component)component2).gameObject.SetActive(true); } AvatarWeapon val3 = ((Il2CppObjectBase)component2).TryCast(); if ((Object)(object)val3 != (Object)null) { MeleeWeapons[j] = val3; } AvatarMeleeWeapon val4 = ((Il2CppObjectBase)component2).TryCast(); if ((Object)(object)val4 != (Object)null && ambushSettings.AmbushWeaponLethality > 0f) { val4.Damage = Mathf.Lerp(val4.Damage, val4.Damage * 2f, ambushSettings.AmbushWeaponLethality); ((AvatarWeapon)val4).CooldownDuration = Mathf.Lerp(((AvatarWeapon)val4).CooldownDuration, ((AvatarWeapon)val4).CooldownDuration * 0.5f, ambushSettings.AmbushWeaponLethality); val4.AttackRange = Mathf.Lerp(val4.AttackRange, val4.AttackRange * 2f, ambushSettings.AmbushWeaponLethality); val4.AttackRadius = Mathf.Lerp(val4.AttackRadius, val4.AttackRadius * 2f, ambushSettings.AmbushWeaponLethality); ((AvatarWeapon)val4).MaxUseRange = Mathf.Lerp(((AvatarWeapon)val4).MaxUseRange, ((AvatarWeapon)val4).MaxUseRange * 2f, ambushSettings.AmbushWeaponLethality); } } } Ambush.MIN_RANK_FOR_RANGED_WEAPONS = new FullRank((ERank)ambushSettings.MinRankForRanged, 1); Enumerator enumerator2 = NetworkSingleton.Instance.Activities.GlobalActivities.GetEnumerator(); while (enumerator2.MoveNext()) { Ambush val5 = ((Il2CppObjectBase)enumerator2.Current).TryCast(); if ((Object)(object)val5 != (Object)null) { val5.RangedWeapons = Il2CppReferenceArray.op_Implicit(RangedWeapons); val5.MeleeWeapons = Il2CppReferenceArray.op_Implicit(MeleeWeapons); } } yield return null; } } public static class BuildInfo { public const string Name = "Cartel Enforcer"; public const string Description = "Cartel - Modded and configurable"; public const string Author = "XOWithSauce"; public const string Company = null; public const string Version = "2.0.0"; public const string DownloadLink = null; } public class CartelEnforcer : MelonMod { [HarmonyPatch(typeof(SaveManager), "Save", new Type[] { typeof(string) })] public static class SaveManager_Save_String_Patch { public static bool Prefix(SaveManager __instance, string saveFolderPath) { if (!isSaving) { isSaving = true; ConfigLoader.Save(CartelInventory.cartelStolenItems); if (currentConfig.alliedExtensions) { ConfigLoader.Save(AlliedExtension.alliedQuests); } if (currentConfig.stealBackCustomers) { StealBackCustomer.SerializedStolenNPCs serializedStolenNPCs = new StealBackCustomer.SerializedStolenNPCs(); serializedStolenNPCs.stolenCustomers = new List(); foreach (StealBackCustomer.StolenNPC stolenNPC in StealBackCustomer.stolenNPCs) { StealBackCustomer.StolenNPCSerialized stolenNPCSerialized = new StealBackCustomer.StolenNPCSerialized(); stolenNPCSerialized.npcID = stolenNPC.npc.ID; stolenNPCSerialized.sampleChancesProcessed = stolenNPC.sampleChancesProcessed; serializedStolenNPCs.stolenCustomers.Add(stolenNPCSerialized); } ConfigLoader.Save(serializedStolenNPCs); } CurrentEventCooldowns currentCooldowns = new CurrentEventCooldowns(); currentCooldowns.StealDeadDropCooldown = FrequencyOverrides.regActivityHours.First((CartelRegActivityHours x) => x.cartelActivityClass == 0).hoursUntilEnable; currentCooldowns.CartelCustomerDealCooldown = FrequencyOverrides.regActivityHours.First((CartelRegActivityHours x) => x.cartelActivityClass == 1).hoursUntilEnable; currentCooldowns.RobDealerCooldown = FrequencyOverrides.regActivityHours.First((CartelRegActivityHours x) => x.cartelActivityClass == 2).hoursUntilEnable; currentCooldowns.SprayGraffitiCooldown = FrequencyOverrides.regActivityHours.First((CartelRegActivityHours x) => x.cartelActivityClass == 3).hoursUntilEnable; currentCooldowns.DriveByCooldown = DriveByEvent.hoursUntilDriveBy; currentCooldowns.GatheringCooldown = CartelGathering.hoursUntilNextGathering; currentCooldowns.InterceptDealsCooldown = InterceptEvent.hoursUntilInterceptEvent; currentCooldowns.SabotageCooldowns = new Dictionary(); SabotageEvent.locations.ForEach(delegate(SabotageEvent.SabotageEventLocation x) { currentCooldowns.SabotageCooldowns.Add(((Property)x.business).PropertyName, x.hoursUntilEnabled); }); ConfigLoader.Save(currentCooldowns); } isSaving = false; return true; } } [HarmonyPatch(typeof(SaveManager), "Save", new Type[] { })] public static class SaveManager_Save_Patch { public static bool Prefix(SaveManager __instance) { return true; } } [HarmonyPatch(typeof(LoadManager), "ExitToMenu")] public static class LoadManager_ExitToMenu_Patch { public static bool Prefix(LoadManager __instance, SaveInfo autoLoadSave = null, Data mainMenuPopup = null, bool preventLeaveLobby = false) { ExitPreTask(); return true; } } [HarmonyPatch(typeof(DeathScreen), "LoadSaveClicked")] public static class DeathScreen_LoadSaveClicked_Patch { public static bool Prefix(DeathScreen __instance) { ExitPreTask(); return true; } } [HarmonyPatch(typeof(CartelGoon), "Spawn")] public static class CartelGoon_Spawn_Patch { [HarmonyPostfix] public static void Postfix(CartelGoon __instance) { coros.Add(MelonCoroutines.Start(AfterSpawnEvaluate(__instance))); } public static IEnumerator AfterSpawnEvaluate(CartelGoon __instance) { yield return Wait01; if (registered) { if (!__instance.IsGoonSpawned) { __instance.IsGoonSpawned = true; } if (NetworkSingleton.Instance.GoonPool.unspawnedGoons.Contains(__instance)) { NetworkSingleton.Instance.GoonPool.unspawnedGoons.Remove(__instance); } if (!NetworkSingleton.Instance.GoonPool.spawnedGoons.Contains(__instance)) { NetworkSingleton.Instance.GoonPool.spawnedGoons.Add(__instance); } if (((NPC)__instance).Movement.IsPaused) { ((NPC)__instance).Movement.ResumeMovement(); } if (!((Behaviour)((NPC)__instance).Movement.Agent).enabled) { ((Behaviour)((NPC)__instance).Movement.Agent).enabled = true; } if (!((NPC)__instance).isVisible) { ((NPC)__instance).SetVisible(true, false); } if (!((Behaviour)((NPC)__instance).Awareness).enabled) { ((NPC)__instance).Awareness.SetAwarenessActive(true); } if (__instance.goonMates.Count > 0) { __instance.goonMates.Clear(); } if (!((Component)__instance).gameObject.activeSelf) { ((Component)__instance).gameObject.SetActive(true); } } } } [HarmonyPatch(typeof(CartelGoon), "Despawn")] public static class CartelGoon_Despawn_Patch { [HarmonyPostfix] public static void Postfix(CartelGoon __instance) { coros.Add(MelonCoroutines.Start(AfterDespawnEvaluate(__instance))); } public static IEnumerator AfterDespawnEvaluate(CartelGoon __instance) { yield return Wait01; if (registered) { if (__instance.IsGoonSpawned) { __instance.IsGoonSpawned = false; } if (NetworkSingleton.Instance.GoonPool.spawnedGoons.Contains(__instance)) { NetworkSingleton.Instance.GoonPool.spawnedGoons.Remove(__instance); } if (!NetworkSingleton.Instance.GoonPool.unspawnedGoons.Contains(__instance)) { NetworkSingleton.Instance.GoonPool.unspawnedGoons.Add(__instance); } if (!((NPC)__instance).Movement.IsPaused) { ((NPC)__instance).Movement.PauseMovement(); } if (((Behaviour)((NPC)__instance).Movement.Agent).enabled) { ((Behaviour)((NPC)__instance).Movement.Agent).enabled = false; } if (((NPC)__instance).isVisible) { ((NPC)__instance).SetVisible(false, false); } if (((Behaviour)((NPC)__instance).Awareness).enabled) { ((NPC)__instance).Awareness.SetAwarenessActive(false); } if (__instance.goonMates.Count > 0) { __instance.goonMates.Clear(); } } } } public static ModConfig currentConfig; public static InfluenceConfig influenceConfig; public static CurrentEventCooldowns eventCooldowns; public static List coros = new List(); public static bool registered = false; private bool firstTimeLoad; public static bool isSaving = false; public static WaitForEndOfFrame frameEnd = new WaitForEndOfFrame(); public static WaitForSeconds Wait01 = new WaitForSeconds(0.1f); public static WaitForSeconds Wait025 = new WaitForSeconds(0.25f); public static WaitForSeconds Wait05 = new WaitForSeconds(0.5f); public static WaitForSeconds Wait1 = new WaitForSeconds(1f); public static WaitForSeconds Wait2 = new WaitForSeconds(2f); public static WaitForSeconds Wait5 = new WaitForSeconds(5f); public static WaitForSeconds Wait10 = new WaitForSeconds(10f); public static WaitForSeconds Wait30 = new WaitForSeconds(30f); public static WaitForSeconds Wait60 = new WaitForSeconds(60f); public static ModPrefsHandler Prefs { get; private set; } public static CartelEnforcer Instance { get; private set; } public static void SyncConfig() { bool flag = false; FieldInfo[] fields = currentConfig.GetType().GetFields(); foreach (FieldInfo fieldInfo in fields) { if (!fieldInfo.Name.Contains("endGameQuestMonologueSpeed")) { MelonPreferences_Entry entry = Prefs.modConfigCategory.GetEntry(fieldInfo.Name); if (entry != null && (bool)fieldInfo.GetValue(currentConfig) != (bool)entry.BoxedValue) { flag = true; fieldInfo.SetValue(currentConfig, entry.BoxedValue); } } } if (currentConfig.alliedExtensions && !currentConfig.endGameQuest) { flag = true; currentConfig.endGameQuest = true; } if (flag) { ConfigLoader.Save(currentConfig, logResult: false); } } public override void OnInitializeMelon() { ((MelonBase)this).OnInitializeMelon(); Instance = this; currentConfig = ConfigLoader.Load(); influenceConfig = ConfigLoader.LoadInfluenceConfig(); Prefs = new ModPrefsHandler(); Prefs.SetupMelonPreferences(); SyncConfig(); MelonLogger.Msg("Cartel Enforcer Mod Loaded"); } public override void OnUpdate() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_009d: Unknown result type (might be due to invalid IL or missing references) if (registered && currentConfig != null && currentConfig.debugMode && (Object)(object)DebugModule.playerTransform != (Object)null && (Object)(object)DebugModule.positionText != (Object)null) { Vector3 position = DebugModule.playerTransform.position; string text = $"X: {position.x:F2}\nY: {position.y:F2}\nZ: {position.z:F2}"; ((TMP_Text)DebugModule.positionText).text = text; } } public override void OnSceneWasInitialized(int buildIndex, string sceneName) { if (buildIndex == 1 && (Object)(object)Singleton.Instance != (Object)null && !registered && !firstTimeLoad) { firstTimeLoad = true; Singleton.Instance.onLoadComplete.AddListener(UnityAction.op_Implicit((Action)OnLoadCompleteCb)); } if (buildIndex != 1 && registered) { ExitPreTask(); } } private void OnLoadCompleteCb() { if (!registered) { registered = true; coros.Add(MelonCoroutines.Start(Setup())); } } public static IEnumerator Setup() { yield return (object)new WaitUntil(Func.op_Implicit((Func)(() => Singleton.Instance.IsGameLoaded))); currentConfig = ConfigLoader.Load(); influenceConfig = ConfigLoader.LoadInfluenceConfig(); CartelInventory.cartelStolenItems = ConfigLoader.LoadStolenItems(); FrequencyOverrides.frequencyConfig = ConfigLoader.LoadEventFrequencyConfig(); eventCooldowns = ConfigLoader.LoadPersistentCooldowns(); DealerActivity.dealerConfig = ConfigLoader.LoadDealerConfig(); StealBackCustomer.stolenNPCs = ConfigLoader.LoadStolenCustomers(); TimeManager instance = NetworkSingleton.Instance; instance.onDayPass += Action.op_Implicit((Action)InfluenceOverrides.OnDayPassChangePassive); CartelInventory.PreparePackagingRefs(); SabotageEvent.PopulateBombLocations(); SabotageEvent.PrepareBombFXObjects(); coros.Add(MelonCoroutines.Start(InterceptEvent.FetchUIElementsInit())); coros.Add(MelonCoroutines.Start(InitializeAndEvaluateDriveBy())); coros.Add(MelonCoroutines.Start(InitializeAmbush())); FrequencyOverrides.InitFrequencyOverrides(); TimeManager instance2 = NetworkSingleton.Instance; instance2.onHourPass += Action.op_Implicit((Action)FrequencyOverrides.OnHourPassReduceCartelRegActHours); coros.Add(MelonCoroutines.Start(InitializeAndEvaluateMiniQuest())); coros.Add(MelonCoroutines.Start(InterceptEvent.EvaluateCartelIntercepts())); TimeManager instance3 = NetworkSingleton.Instance; instance3.onHourPass += Action.op_Implicit((Action)InterceptEvent.HourPassInterceptCooldown); coros.Add(MelonCoroutines.Start(EndGameQuest.InitializeEndGameQuest())); coros.Add(MelonCoroutines.Start(DealerActivity.EvaluateDealerState())); coros.Add(MelonCoroutines.Start(AlliedExtension.SetupAlliedExtension())); TimeManager instance4 = NetworkSingleton.Instance; instance4.onHourPass += Action.op_Implicit((Action)CartelGathering.OnHourPassTryGather); coros.Add(MelonCoroutines.Start(InitializeAndEvaluateSabotage())); TimeManager instance5 = NetworkSingleton.Instance; instance5.onSleepEnd += Action.op_Implicit((Action)StealBackCustomer.OnDayPassTrySteal); if (currentConfig.debugMode) { coros.Add(MelonCoroutines.Start(DebugModule.GodMode())); MelonCoroutines.Start(DebugModule.MakeUI()); } if (currentConfig.endGameQuest && currentConfig.alliedExtensions) { coros.Add(MelonCoroutines.Start(EndGameQuest.ReplicateCopNPC())); } coros.Add(MelonCoroutines.Start(ExtendGoonPool())); } public static void ReduceDriveByHours() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 if (!isSaving && currentConfig.driveByEnabled && (int)NetworkSingleton.Instance.Status == 2) { DriveByEvent.hoursUntilDriveBy = Mathf.Clamp(DriveByEvent.hoursUntilDriveBy - 1, 0, int.MaxValue); } } public static IEnumerator InitializeAndEvaluateDriveBy() { yield return MelonCoroutines.Start(DriveByEvent.InitializeDriveByData()); TimeManager instance = NetworkSingleton.Instance; instance.onHourPass += Action.op_Implicit((Action)ReduceDriveByHours); coros.Add(MelonCoroutines.Start(DriveByEvent.EvaluateDriveBy())); if (currentConfig.debugMode) { yield return MelonCoroutines.Start(DebugModule.SpawnDriveByAreaVisual()); } } public static IEnumerator InitializeAmbush() { yield return MelonCoroutines.Start(AmbushOverrides.ApplyGameDefaultAmbush()); yield return MelonCoroutines.Start(AmbushOverrides.AddUserModdedAmbush()); yield return MelonCoroutines.Start(AmbushOverrides.SetAmbushGeneralSettings()); if (currentConfig.debugMode) { yield return MelonCoroutines.Start(DebugModule.SpawnAmbushAreaVisual()); } } public static IEnumerator InitializeAndEvaluateSabotage() { yield return Wait2; if (registered) { TimeManager instance = NetworkSingleton.Instance; instance.onHourPass += Action.op_Implicit((Action)SabotageEvent.ReduceSabotageHours); coros.Add(MelonCoroutines.Start(SabotageEvent.EvaluateBombEvent())); } } public static IEnumerator InitializeAndEvaluateMiniQuest() { yield return Wait10; if (registered) { yield return MiniQuest.InitMiniQuest(); TimeManager instance = NetworkSingleton.Instance; instance.onDayPass += Action.op_Implicit((Action)MiniQuest.OnDayPassNewDiag); coros.Add(MelonCoroutines.Start(MiniQuest.EvaluateMiniQuestCreation())); } } public static IEnumerator ExtendGoonPool() { NetworkManager netManager = Object.FindObjectOfType(true); WaitForEndOfFrame frameEnd = new WaitForEndOfFrame(); CartelGoon goon = Object.FindObjectOfType(true); if ((Object)(object)goon == (Object)null) { yield break; } GameObject obj = ((Component)goon).gameObject; obj.SetActive(false); yield return Wait01; yield return frameEnd; NPCData templateData = null; if (((NPC)goon).NPCData != null) { templateData = ((NPC)goon).NPCData.GetDeepCopy(); if (templateData != null && templateData.WeatherBehaviour != null) { templateData.WeatherBehaviour.UseUmbrellaChance = 0f; } } List clones = new List(); for (int i = 5; i <= 9; i++) { yield return Wait01; yield return frameEnd; GameObject clone = Object.Instantiate(obj); NetworkObject newNob = clone.GetComponent(); NPC component = clone.GetComponent(); component.GUID = GUIDManager.GenerateUniqueGUID(); if (GUIDManager.IsGUIDAlreadyRegistered(component.GUID)) { continue; } clone.transform.position = Vector3.zero; clone.transform.rotation = Quaternion.identity; ((Object)clone).name = $"CartelGoon ({i})"; yield return MelonCoroutines.Start(NPCInitHelper.InitiateClone(newNob, netManager, templateData)); netManager.ServerManager.Spawn(newNob, (NetworkConnection)null, default(Scene)); CartelGoon component2 = clone.GetComponent(); if (!((Object)(object)((NPC)component2).DialogueHandler == (Object)null)) { DialogueController component3 = ((Component)((NPC)component2).DialogueHandler).GetComponent(); if (!((Object)(object)component3 == (Object)null)) { component3.Choices.Clear(); } } clones.Add(component2); } obj.SetActive(true); try { GoonPool goonPool = NetworkSingleton.Instance.GoonPool; CartelGoon[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)goonPool.goons); int num = array.Length; int count = clones.Count; int num2 = num + count; CartelGoon[] array2 = (CartelGoon[])(object)new CartelGoon[num2]; Array.Copy(array, array2, num); _ = goonPool.unspawnedGoons; int num3 = 0; for (int j = num; j < num2; j++) { if (num3 >= clones.Count) { break; } CartelGoon val = (array2[j] = clones[num3]); goonPool.unspawnedGoons.Add(val); num3++; } goonPool.goons = Il2CppReferenceArray.op_Implicit(array2); } catch (Exception) { } } private static void ExitPreTask() { registered = false; foreach (object coro in coros) { if (coro != null) { MelonCoroutines.Stop(coro); } } coros.Clear(); DriveByEvent.driveByLocations.Clear(); FrequencyOverrides.regActivityHours.Clear(); MiniQuest.targetNPCs.Clear(); CartelInventory.cartelStolenItems.Clear(); MiniQuest.emptyDrops.Clear(); MiniQuest.targetNPCsList.Clear(); MiniQuest.targetNPCs.Clear(); EndGameQuest.manorGoons.Clear(); EndGameQuest.manorGoonGuids.Clear(); CartelGathering.spawnedGatherGoons.Clear(); SabotageEvent.burningPlayers.Clear(); SabotageEvent.locations.Clear(); DealerActivity.playerDealerStolen.Clear(); DealerActivity.consumedGUIDs.Clear(); StealBackCustomer.stolenNPCs.Clear(); SuppliesModule.supplyLocations.Clear(); SuppliesModule.barrelLoot.Clear(); foreach (string item in SuppliesModule.carLoot.Keys.ToList()) { SuppliesModule.carLoot[item].Clear(); } foreach (string alliedDialogueKey in AlliedCartelDialogue.alliedDialogueKeys) { AlliedCartelDialogue.persuasionChances[alliedDialogueKey] = 0f; } DealerActivity.allCartelDealers = null; influenceConfig = null; eventCooldowns = null; isSaving = false; EndGameQuest.activeDefeatEnforcerQuest = null; EndGameQuest.defeatEnforcerCompleted = false; EndGameQuest.activeManorQuest = null; EndGameQuest.manorCompleted = false; EndGameQuest.activeCarMeetupQuest = null; EndGameQuest.carMeetupCompleted = false; EndGameQuest.hasGeneratedDefeatEnforcerQuest = false; EndGameQuest.hasGeneratedManorQuest = false; EndGameQuest.hasGeneratedCarQuest = false; RandomManorGenerator.ResetManorItemRef(); EndGameQuest.activeTruceIntro = null; EndGameQuest.activeAlliedSupplies = null; EndGameQuest.alliedSuppliesActive = false; EndGameQuest.alliedGuard = null; EndGameQuest.alliedVanObject = null; EndGameQuest.guardChoiceIndex = -1; EndGameQuest.activeTrueBrothersQuest = null; EndGameQuest.trueBrothersCompleted = false; EndGameQuest.encounterActive = false; EndGameQuest.fixer = null; EndGameQuest.ray = null; EndGameQuest.jeremy = null; EndGameQuest.crankyFrank = null; EndGameQuest.bossGoon = null; EndGameQuest.fixerDiagIndex = 0; EndGameQuest.rayChoiceIndex = 0; EndGameQuest.jeremyDiagIndex = -1; EndGameQuest.frankDiagIndex = -1; EndGameQuest.jeremyDialogueActive = false; CartelGathering.lootGoblinIndex = -1; EndGameQuest.StageDeadDropsObserved = 0; EndGameQuest.StageGatheringsDefeated = 0; DriveByEvent.driveByActive = false; InterceptEvent.interceptingDeal = false; InterceptEvent.interceptor = null; CartelGathering.startedCombat = false; CartelGathering.areGoonsGathering = false; CartelGathering.currentGatheringLocation = null; CartelGathering.previousGatheringLocation = null; SabotageEvent.bombDefused = false; SabotageEvent.sabotageEventActive = false; SabotageEvent.sabotager = null; SabotageEvent.interactionsUntilDefuse = 6; SabotageEvent.intBomb = null; SabotageEvent.reactiveFire = null; SabotageEvent.bombInteractable = null; SabotageEvent.bombLight = null; SabotageEvent.bombCubeMat = null; SabotageEvent.bombSound = null; SabotageEvent.fireHandler = null; SabotageEvent.fireLight = null; CartelInventory.jarPackaging = null; CartelInventory.brickPackaging = null; CartelInventory.cartelCashAmount = 0f; CartelInfluenceChangePopup_Show_Patch.showEnqueued = false; CartelGathering.hoursUntilNextGathering = 3; DealerActivity.currentDealerActivity = 0f; DealerActivity.previousDealerActivity = 0f; } } [Serializable] public class ModConfig { public bool debugMode; public bool driveByEnabled = true; public bool realRobberyEnabled = true; public bool defaultRobberyEnabled = true; public bool miniQuestsEnabled = true; public bool interceptDeals = true; public bool enhancedDealers = true; public bool cartelGatherings = true; public bool businessSabotage = true; public bool stealBackCustomers = true; public bool alliedExtensions = true; public bool endGameQuest = true; public float endGameQuestMonologueSpeed = 1f; } public class UnityContractResolver : DefaultContractResolver { protected override JsonObjectContract CreateObjectContract(Type objectType) { JsonObjectContract val = ((DefaultContractResolver)this).CreateObjectContract(objectType); if (objectType == typeof(Vector3)) { for (int num = ((Collection)(object)val.Properties).Count - 1; num >= 0; num--) { JsonProperty val2 = ((Collection)(object)val.Properties)[num]; if (val2.PropertyName == "normalized" || val2.PropertyName == "magnitude" || val2.PropertyName == "sqrMagnitude") { ((Collection)(object)val.Properties).RemoveAt(num); } } } return val; } } public static class ConfigLoader { [Serializable] public class DriveByTriggersSerialized { public List triggers; } [Serializable] public class CartelAlliedConfig { public float WestvilleCartelDealerCut = 0.3f; public float WestvilleCartelSigningFee = 6000f; public float DowntownCartelDealerCut = 0.4f; public float DowntownCartelSigningFee = 12000f; public float DocksCartelDealerCut = 0.5f; public float DocksCartelSigningFee = 18000f; public float SuburbiaCartelDealerCut = 0.55f; public float SuburbiaCartelSigningFee = 24000f; public float UptownCartelDealerCut = 0.6f; public float UptownCartelSigningFee = 36000f; public int PersuadeCooldownMins = 60; public int SupplyQuestCooldownHours = 48; } [Serializable] public class CartelAlliedQuests { public bool alliedIntroCompleted; public int timesPersuaded; public int hoursUntilNextSupplies = 48; public int daysPassedSinceEncounter; } public static ModConfig Load() { //IL_0061: Expected O, but got Unknown string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathModConfig); ModConfig modConfig; if (File.Exists(pathTo)) { try { modConfig = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); modConfig.endGameQuestMonologueSpeed = Mathf.Clamp(modConfig.endGameQuestMonologueSpeed, 0f, 1f); if (modConfig.alliedExtensions && !modConfig.endGameQuest) { MelonLogger.Warning("Cartel Enforcer Allied Extensions depend on End Game Quests. Enabling End Game Quest config automatically."); modConfig.endGameQuest = true; } } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; modConfig = new ModConfig(); MelonLogger.Error("Failed to deserialize CartelEnforcer config: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { modConfig = new ModConfig(); MelonLogger.Warning("Failed to read CartelEnforcer config: " + ex3); } } else { MelonLogger.Warning("Missing CartelEnforcer basic mod config, creating directory and template."); modConfig = new ModConfig(); Save(modConfig); } return modConfig; } public static void Save(ModConfig config, bool logResult = true) { try { string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathModConfig); string contents = JsonConvert.SerializeObject((object)config, (Formatting)1); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); } catch (Exception ex) { MelonLogger.Warning("Failed to save CartelEnforcer config: " + ex); } } public static ListNewAmbush LoadAmbushConfig() { //IL_0022: Expected O, but got Unknown string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathAmbushes); ListNewAmbush listNewAmbush; if (File.Exists(pathTo)) { try { listNewAmbush = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; listNewAmbush = new ListNewAmbush(); MelonLogger.Error("Failed to deserialize CartelEnforcer User Added Ambush config: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { listNewAmbush = new ListNewAmbush(); listNewAmbush.addedAmbushes = new List(); MelonLogger.Warning("Failed to read CartelEnforcer User Added Ambush config: " + ex3); } } else { MelonLogger.Warning("Missing CartelEnforcer User Added Ambush config, creating directory and template."); listNewAmbush = new ListNewAmbush(); listNewAmbush.addedAmbushes = new List(); Save(listNewAmbush); } return listNewAmbush; } public static void Save(ListNewAmbush config) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown try { JsonSerializerSettings val = new JsonSerializerSettings { ContractResolver = (IContractResolver)(object)new UnityContractResolver() }; string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathAmbushes); string contents = JsonConvert.SerializeObject((object)config, (Formatting)1, val); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); MelonLogger.Warning(" CartelEnforcer User Added Ambush config written to: " + pathTo); } catch (Exception ex) { MelonLogger.Warning("Failed to save CartelEnforcer config: " + ex); } } public static ListNewAmbush LoadDefaultAmbushConfig() { //IL_0022: Expected O, but got Unknown string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathDefAmbushes); ListNewAmbush result; if (File.Exists(pathTo)) { try { result = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; result = new ListNewAmbush(); MelonLogger.Error("Failed to deserialize CartelEnforcer Default ambush config: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { result = new ListNewAmbush(); MelonLogger.Warning("Failed to read Cartel Enforcer Default ambush config: " + ex3); } } else { MelonLogger.Warning("Missing CartelEnforcer Default ambush config, creating directory and template."); result = GenerateAmbushState(); } return result; } public static ListNewAmbush GenerateAmbushState() { //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected I4, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) ListNewAmbush listNewAmbush = new ListNewAmbush(); listNewAmbush.addedAmbushes = new List(); try { CartelRegionActivities[] array = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType(true)); foreach (CartelRegionActivities val in array) { foreach (CartelAmbushLocation item in (Il2CppArrayBase)(object)val.AmbushLocations) { NewAmbushConfig config = new NewAmbushConfig(); config.mapRegion = (int)val.Region; config.ambushPosition = ((Component)item).transform.position; config.spawnPoints = ((IEnumerable)item.AmbushPoints).Select((Transform tr) => tr.position).ToList(); config.detectionRadius = item.DetectionRadius; if (!listNewAmbush.addedAmbushes.Any((NewAmbushConfig existingConfig) => existingConfig.mapRegion == config.mapRegion && existingConfig.ambushPosition == config.ambushPosition)) { listNewAmbush.addedAmbushes.Add(config); } } } JsonSerializerSettings val2 = new JsonSerializerSettings { ContractResolver = (IContractResolver)(object)new UnityContractResolver() }; string contents = JsonConvert.SerializeObject((object)listNewAmbush, (Formatting)1, val2); string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathDefAmbushes); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); MelonLogger.Warning(" CartelEnforcer Default Ambush config written to: " + pathTo); } catch (Exception ex) { MelonLogger.Warning("Failed to save default.json config: " + ex); } return listNewAmbush; } public static AmbushGeneralSettingsSerialized LoadAmbushSettings() { //IL_007a: Expected O, but got Unknown string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathSettingsAmbushes); AmbushGeneralSettingsSerialized ambushGeneralSettingsSerialized; if (File.Exists(pathTo)) { try { ambushGeneralSettingsSerialized = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); int num = Enum.GetValues(typeof(ERank)).Cast().Max(); if (ambushGeneralSettingsSerialized.MinRankForRanged >= num || ambushGeneralSettingsSerialized.MinRankForRanged < 0) { ambushGeneralSettingsSerialized.MinRankForRanged = Mathf.Clamp(ambushGeneralSettingsSerialized.MinRankForRanged, 0, num - 1); } ambushGeneralSettingsSerialized.AmbushWeaponLethality = Mathf.Clamp01(ambushGeneralSettingsSerialized.AmbushWeaponLethality); } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; ambushGeneralSettingsSerialized = new AmbushGeneralSettingsSerialized(); ambushGeneralSettingsSerialized.RangedWeapons = new List { "m1911" }; ambushGeneralSettingsSerialized.MeleeWeapons = new List { "knife" }; MelonLogger.Error("Failed to deserialize CartelEnforcer Ambush/settings.json config: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { ambushGeneralSettingsSerialized = new AmbushGeneralSettingsSerialized(); ambushGeneralSettingsSerialized.RangedWeapons = new List { "m1911" }; ambushGeneralSettingsSerialized.MeleeWeapons = new List { "knife" }; MelonLogger.Warning("Failed to read Ambush/settings.json config: " + ex3); } } else { MelonLogger.Warning("Could not find settings.json at Ambush/settings.json. Generating default template."); ambushGeneralSettingsSerialized = new AmbushGeneralSettingsSerialized(); ambushGeneralSettingsSerialized.RangedWeapons = new List { "m1911" }; ambushGeneralSettingsSerialized.MeleeWeapons = new List { "knife" }; string contents = JsonConvert.SerializeObject((object)ambushGeneralSettingsSerialized, (Formatting)1); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); } return ambushGeneralSettingsSerialized; } private static DriveByTriggersSerialized GenerateDefault() { DriveByTriggersSerialized driveByTriggersSerialized = new DriveByTriggersSerialized(); driveByTriggersSerialized.triggers = new List(); DriveByEvent.GenerateDefaultDriveByTriggers(); foreach (KeyValuePair driveByLocation in DriveByEvent.driveByLocations) { driveByTriggersSerialized.triggers.Add(driveByLocation.Key); } return driveByTriggersSerialized; } public static DriveByTriggersSerialized LoadDriveByConfig() { //IL_0027: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown DriveByTriggersSerialized driveByTriggersSerialized = null; string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathDriveBys); if (File.Exists(pathTo)) { try { driveByTriggersSerialized = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; driveByTriggersSerialized = GenerateDefault(); MelonLogger.Error("Failed to deserialize CartelEnforcer DriveBy/driveby.json config: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { driveByTriggersSerialized = GenerateDefault(); MelonLogger.Warning("Failed to read DriveBy/driveby.json config: " + ex3); } } else { MelonLogger.Warning("Could not find a file at DriveBy/driveby.json. Generating default template."); driveByTriggersSerialized = GenerateDefault(); JsonSerializerSettings val = new JsonSerializerSettings { ContractResolver = (IContractResolver)(object)new UnityContractResolver() }; string contents = JsonConvert.SerializeObject((object)driveByTriggersSerialized, (Formatting)1, val); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); } return driveByTriggersSerialized; } public static string SanitizeAndFormatName(string orgName) { string text = orgName; if (text != null) { text = text.Replace(" ", "_").ToLower(); text = text.Replace(",", ""); text = text.Replace(".", ""); text = text.Replace("<", ""); text = text.Replace(">", ""); text = text.Replace(":", ""); text = text.Replace("\"", ""); text = text.Replace("/", ""); text = text.Replace("\\", ""); text = text.Replace("|", ""); text = text.Replace("?", ""); text = text.Replace("*", ""); } return text + ".json"; } public static List LoadStolenItems() { //IL_0084: Expected O, but got Unknown StolenItemsList stolenItemsList = new StolenItemsList(); string organisationName = Singleton.Instance.ActiveSaveInfo.OrganisationName; int saveSlotNumber = Singleton.Instance.ActiveSaveInfo.SaveSlotNumber; string path = $"{saveSlotNumber}_{SanitizeAndFormatName(organisationName)}"; string pathTo = ModDataPaths.GetPathTo(Path.Combine(ModDataPaths.pathCartelStolen, path)); if (File.Exists(pathTo)) { try { stolenItemsList = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; stolenItemsList = new StolenItemsList(); MelonLogger.Error("Failed to deserialize Cartel Stolen items data: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { stolenItemsList = new StolenItemsList(); MelonLogger.Warning("Failed to read Cartel Stolen Items data: " + ex3); } } else { stolenItemsList = new StolenItemsList(); } CartelInventory.cartelCashAmount = stolenItemsList.balance; List list = new List(); if (stolenItemsList.items != null && stolenItemsList.items.Count > 0) { foreach (SerializeStolenItems item in stolenItemsList.items) { if (item.ID == null || item.ID == string.Empty) { MelonLogger.Msg("Stolen Item ID is null"); continue; } if (item.Quality < 0 || item.Quality > 4) { MelonLogger.Msg("Stolen Quality not allowed"); continue; } if (item.Quantity >= int.MaxValue) { MelonLogger.Msg("Stolen Quantity is over the max limit"); continue; } QualityItemInstance val = ((Il2CppObjectBase)Registry.GetItem(item.ID).GetDefaultInstance(item.Quantity)).TryCast(); if (val != null) { switch (item.Quality) { case 0: val.Quality = (EQuality)0; break; case 1: val.Quality = (EQuality)1; break; case 2: val.Quality = (EQuality)2; break; case 3: val.Quality = (EQuality)3; break; case 4: val.Quality = (EQuality)4; break; } list.Add(val); } else { MelonLogger.Msg("Tried to load item thats not quality item instance"); } } } return list; } public static void Save(List stolenItems) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected I4, but got Unknown StolenItemsList stolenItemsList = new StolenItemsList(); stolenItemsList.items = new List(); lock (CartelInventory.cartelItemLock) { foreach (QualityItemInstance stolenItem in stolenItems) { SerializeStolenItems item = new SerializeStolenItems { ID = ((BaseItemInstance)stolenItem).ID, Quality = (int)stolenItem.Quality, Quantity = ((BaseItemInstance)stolenItem).Quantity }; stolenItemsList.items.Add(item); } stolenItemsList.balance = Mathf.Round(CartelInventory.cartelCashAmount); try { string organisationName = Singleton.Instance.ActiveSaveInfo.OrganisationName; int saveSlotNumber = Singleton.Instance.ActiveSaveInfo.SaveSlotNumber; string path = $"{saveSlotNumber}_{SanitizeAndFormatName(organisationName)}"; string pathTo = ModDataPaths.GetPathTo(Path.Combine(ModDataPaths.pathCartelStolen, path)); string contents = JsonConvert.SerializeObject((object)stolenItemsList, (Formatting)1); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); } catch (Exception ex) { MelonLogger.Warning("Failed to save Cartel Stolen Items data: " + ex); } } } public static List LoadStolenCustomers() { //IL_008c: Expected O, but got Unknown StealBackCustomer.SerializedStolenNPCs serializedStolenNPCs = new StealBackCustomer.SerializedStolenNPCs(); List list = new List(); string organisationName = Singleton.Instance.ActiveSaveInfo.OrganisationName; int saveSlotNumber = Singleton.Instance.ActiveSaveInfo.SaveSlotNumber; string path = $"{saveSlotNumber}_{SanitizeAndFormatName(organisationName)}"; string pathTo = ModDataPaths.GetPathTo(Path.Combine(ModDataPaths.pathStolenCustomers, path)); if (File.Exists(pathTo)) { try { serializedStolenNPCs = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; serializedStolenNPCs = new StealBackCustomer.SerializedStolenNPCs(); serializedStolenNPCs.stolenCustomers = new List(); MelonLogger.Error("Failed to deserialize CartelEnforcer stolen customer data: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { serializedStolenNPCs = new StealBackCustomer.SerializedStolenNPCs(); serializedStolenNPCs.stolenCustomers = new List(); MelonLogger.Warning("Failed to read CartelEnforcer stolen customer data: " + ex3); } } else { MelonLogger.Warning("Missing CartelEnforcer stolen customer data, creating directory and template."); serializedStolenNPCs = new StealBackCustomer.SerializedStolenNPCs(); serializedStolenNPCs.stolenCustomers = new List(); Save(serializedStolenNPCs); } if (serializedStolenNPCs != null && serializedStolenNPCs.stolenCustomers.Count != 0) { Dictionary idSampleDict = new Dictionary(); serializedStolenNPCs.stolenCustomers.ForEach(delegate(StealBackCustomer.StolenNPCSerialized x) { idSampleDict.Add(x.npcID, x.sampleChancesProcessed); }); Enumerator enumerator = Customer.LockedCustomers.GetEnumerator(); while (enumerator.MoveNext()) { Customer current = enumerator.Current; if (idSampleDict.ContainsKey(current.NPC.ID)) { StealBackCustomer.StolenNPC stolenNPC = new StealBackCustomer.StolenNPC(); stolenNPC.sampleChancesProcessed = Mathf.Clamp(idSampleDict[current.NPC.ID], 1, 9); stolenNPC.npc = current.NPC; list.Add(stolenNPC); } } } return list; } public static void Save(StealBackCustomer.SerializedStolenNPCs stolenCustomers) { try { string organisationName = Singleton.Instance.ActiveSaveInfo.OrganisationName; int saveSlotNumber = Singleton.Instance.ActiveSaveInfo.SaveSlotNumber; string path = $"{saveSlotNumber}_{SanitizeAndFormatName(organisationName)}"; string pathTo = ModDataPaths.GetPathTo(Path.Combine(ModDataPaths.pathStolenCustomers, path)); string contents = JsonConvert.SerializeObject((object)stolenCustomers, (Formatting)1); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); } catch (Exception ex) { MelonLogger.Warning("Failed to save CartelEnforcer stolen customer data: " + ex); } } public static CartelDealerConfig LoadDealerConfig() { //IL_00f9: Expected O, but got Unknown CartelDealerConfig cartelDealerConfig = new CartelDealerConfig(); string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathDealerConfig); if (File.Exists(pathTo)) { try { cartelDealerConfig = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); cartelDealerConfig.CartelDealerWalkSpeed = Mathf.Clamp(cartelDealerConfig.CartelDealerWalkSpeed, 1f, 7f); cartelDealerConfig.CartelDealerHP = Mathf.Clamp(cartelDealerConfig.CartelDealerHP, 10f, 2000f); cartelDealerConfig.CartelDealerLethality = Mathf.Clamp01(cartelDealerConfig.CartelDealerLethality); cartelDealerConfig.SafetyThreshold = Mathf.Clamp(cartelDealerConfig.SafetyThreshold, -1f, 1f); cartelDealerConfig.DealerActivityIncreasePerDay = Mathf.Clamp(cartelDealerConfig.DealerActivityIncreasePerDay, 0f, 1f); cartelDealerConfig.DealerActivityDecreasePerKill = Mathf.Clamp(cartelDealerConfig.DealerActivityDecreasePerKill, 0f, 1f); cartelDealerConfig.StealDealerContractChance = Mathf.Clamp(cartelDealerConfig.StealDealerContractChance, 0f, 1f); cartelDealerConfig.StealPlayerPendingChance = Mathf.Clamp(cartelDealerConfig.StealPlayerPendingChance, 0f, 1f); } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; cartelDealerConfig = new CartelDealerConfig(); MelonLogger.Error("Failed to deserialize CartelEnforcer Dealer config: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { cartelDealerConfig = new CartelDealerConfig(); MelonLogger.Warning("Failed to read CartelEnforcer Dealer config: " + ex3); } } else { MelonLogger.Warning("Missing CartelEnforcer Dealer config, creating directory and template."); cartelDealerConfig = new CartelDealerConfig(); Save(cartelDealerConfig); } return cartelDealerConfig; } public static void Save(CartelDealerConfig dealerConfig) { try { string contents = JsonConvert.SerializeObject((object)dealerConfig, (Formatting)1); string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathDealerConfig); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); MelonLogger.Warning(" CartelEnforcer Dealer config written to: " + pathTo); } catch (Exception ex) { MelonLogger.Warning("Failed to save CartelEnforcer Dealer config: " + ex); } } public static InfluenceConfig LoadInfluenceConfig() { //IL_016f: Expected O, but got Unknown InfluenceConfig influenceConfig = new InfluenceConfig(); string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathInfluenceConfig); if (File.Exists(pathTo)) { try { influenceConfig = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); influenceConfig.interceptFail = ClampInfluence(influenceConfig.interceptFail, clampPositive: true); influenceConfig.interceptSuccess = ClampInfluence(influenceConfig.interceptSuccess, clampPositive: false); influenceConfig.deadDropFail = ClampInfluence(influenceConfig.deadDropFail, clampPositive: true); influenceConfig.deadDropSuccess = ClampInfluence(influenceConfig.deadDropSuccess, clampPositive: false); influenceConfig.gatheringFail = ClampInfluence(influenceConfig.gatheringFail, clampPositive: true); influenceConfig.gatheringSuccess = ClampInfluence(influenceConfig.gatheringSuccess, clampPositive: false); influenceConfig.robberyPlayerEscape = ClampInfluence(influenceConfig.robberyPlayerEscape, clampPositive: true); influenceConfig.robberyGoonEscapeSuccess = ClampInfluence(influenceConfig.robberyGoonEscapeSuccess, clampPositive: true); influenceConfig.robberyGoonDead = ClampInfluence(influenceConfig.robberyGoonDead, clampPositive: false); influenceConfig.robberyGoonEscapeDead = ClampInfluence(influenceConfig.robberyGoonEscapeDead, clampPositive: false); influenceConfig.sabotageBombDefused = ClampInfluence(influenceConfig.sabotageBombDefused, clampPositive: false); influenceConfig.sabotageGoonKilled = ClampInfluence(influenceConfig.sabotageGoonKilled, clampPositive: false); influenceConfig.sabotageBombExploded = ClampInfluence(influenceConfig.sabotageBombExploded, clampPositive: true); influenceConfig.passiveInfluenceGainPerDay = ClampInfluence(influenceConfig.passiveInfluenceGainPerDay, clampPositive: true); influenceConfig.cartelDealerDied = ClampInfluence(influenceConfig.cartelDealerDied, clampPositive: false); influenceConfig.ambushDefeated = ClampInfluence(influenceConfig.ambushDefeated, clampPositive: false); influenceConfig.graffitiInfluenceReduction = ClampInfluence(influenceConfig.graffitiInfluenceReduction, clampPositive: false); influenceConfig.customerUnlockInfluenceChange = ClampInfluence(influenceConfig.customerUnlockInfluenceChange, clampPositive: false); } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; influenceConfig = new InfluenceConfig(); MelonLogger.Error("Failed to deserialize CartelEnforcer influence config: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { influenceConfig = new InfluenceConfig(); MelonLogger.Warning("Failed to read CartelEnforcer influence config: " + ex3); } } else { MelonLogger.Warning("Missing CartelEnforcer Influence config, creating directory and template."); influenceConfig = new InfluenceConfig(); Save(influenceConfig); } return influenceConfig; } public static void Save(InfluenceConfig influenceConfig) { try { string contents = JsonConvert.SerializeObject((object)influenceConfig, (Formatting)1); string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathInfluenceConfig); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); MelonLogger.Warning(" CartelEnforcer Influence config written to: " + pathTo); } catch (Exception ex) { MelonLogger.Warning("Failed to save CartelEnforcer Influence config: " + ex); } } private static float ClampInfluence(float value, bool clampPositive) { if (!clampPositive) { return Mathf.Clamp(value, -1f, 0f); } return Mathf.Clamp(value, 0f, 1f); } public static CartelAlliedConfig LoadAlliedConfig() { //IL_0028: Expected O, but got Unknown CartelAlliedConfig cartelAlliedConfig = new CartelAlliedConfig(); string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathAlliedConfig); if (File.Exists(pathTo)) { try { cartelAlliedConfig = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; cartelAlliedConfig = new CartelAlliedConfig(); MelonLogger.Error("Failed to deserialize CartelEnforcer Allied config: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { cartelAlliedConfig = new CartelAlliedConfig(); MelonLogger.Warning("Failed to read CartelEnforcer Allied config: " + ex3); } } else { MelonLogger.Warning("Missing CartelEnforcer Allied config, creating directory and template."); cartelAlliedConfig = new CartelAlliedConfig(); Save(cartelAlliedConfig); } return cartelAlliedConfig; } public static void Save(CartelAlliedConfig alliedConfig) { try { string contents = JsonConvert.SerializeObject((object)alliedConfig, (Formatting)1); string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathAlliedConfig); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); } catch (Exception ex) { MelonLogger.Warning("Failed to save CartelEnforcer Allied Config Data: " + ex); } } public static CartelAlliedQuests LoadAlliedQuests() { //IL_0084: Expected O, but got Unknown CartelAlliedQuests cartelAlliedQuests = new CartelAlliedQuests(); string organisationName = Singleton.Instance.ActiveSaveInfo.OrganisationName; int saveSlotNumber = Singleton.Instance.ActiveSaveInfo.SaveSlotNumber; string path = $"{saveSlotNumber}_{SanitizeAndFormatName(organisationName)}"; string pathTo = ModDataPaths.GetPathTo(Path.Combine(ModDataPaths.pathAlliedPersist, path)); if (File.Exists(pathTo)) { try { cartelAlliedQuests = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; cartelAlliedQuests = new CartelAlliedQuests(); MelonLogger.Error("Failed to deserialize CartelEnforcer Allied Quests config: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { cartelAlliedQuests = new CartelAlliedQuests(); MelonLogger.Warning("Failed to read CartelEnforcer Allied Quests config: " + ex3); } } else { MelonLogger.Warning("Missing CartelEnforcer Allied Quests config, creating directory and template."); cartelAlliedQuests = new CartelAlliedQuests(); Save(cartelAlliedQuests); } return cartelAlliedQuests; } public static void Save(CartelAlliedQuests alliedQuestsState) { try { string organisationName = Singleton.Instance.ActiveSaveInfo.OrganisationName; int saveSlotNumber = Singleton.Instance.ActiveSaveInfo.SaveSlotNumber; string path = $"{saveSlotNumber}_{SanitizeAndFormatName(organisationName)}"; string pathTo = ModDataPaths.GetPathTo(Path.Combine(ModDataPaths.pathAlliedPersist, path)); string contents = JsonConvert.SerializeObject((object)alliedQuestsState, (Formatting)1); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); } catch (Exception ex) { MelonLogger.Warning("Failed to save CartelEnforcer Allied Quests Data: " + ex); } } public static EventFrequencyConfig LoadEventFrequencyConfig() { //IL_014f: Expected O, but got Unknown EventFrequencyConfig eventFrequencyConfig = new EventFrequencyConfig(); string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathEventFrequency); if (File.Exists(pathTo)) { try { eventFrequencyConfig = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); List list = new List(); for (int i = 0; i < eventFrequencyConfig.events.Count; i++) { if (eventFrequencyConfig.events[i].Identifier == string.Empty) { list.Add(i); MelonLogger.Warning("Identifier cannot be empty for event frequency found in file at: " + pathTo); } else { eventFrequencyConfig.events[i].CooldownHours = Mathf.Clamp(eventFrequencyConfig.events[i].CooldownHours, 0, int.MaxValue); eventFrequencyConfig.events[i].InfluenceRequirement = Mathf.Clamp01(eventFrequencyConfig.events[i].InfluenceRequirement); eventFrequencyConfig.events[i].RandomTimeRangePercentage = Mathf.Clamp01(eventFrequencyConfig.events[i].RandomTimeRangePercentage); } } if (list.Count > 0) { List list2 = new List(); for (int j = 0; j < eventFrequencyConfig.events.Count; j++) { if (!list.Contains(j)) { list2.Add(eventFrequencyConfig.events[j]); } } eventFrequencyConfig.events = list2; } } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; eventFrequencyConfig = new EventFrequencyConfig(); eventFrequencyConfig.InitializeDefault(); MelonLogger.Error("Failed to deserialize CartelEnforcer Event Frequency config: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { eventFrequencyConfig = new EventFrequencyConfig(); eventFrequencyConfig.InitializeDefault(); MelonLogger.Warning("Failed to read CartelEnforcer Event Frequency config: " + ex3); } } else { MelonLogger.Warning("Missing CartelEnforcer Event Frequency config, creating directory and template."); eventFrequencyConfig = new EventFrequencyConfig(); eventFrequencyConfig.InitializeDefault(); Save(eventFrequencyConfig); } return eventFrequencyConfig; } public static void Save(EventFrequencyConfig config) { try { string contents = JsonConvert.SerializeObject((object)config, (Formatting)1); string pathTo = ModDataPaths.GetPathTo(ModDataPaths.pathEventFrequency); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); MelonLogger.Warning(" CartelEnforcer Event frequency config written to: " + pathTo); } catch (Exception ex) { MelonLogger.Warning("Failed to save CartelEnforcer Event frequency config: " + ex); } } public static CurrentEventCooldowns LoadPersistentCooldowns() { //IL_0155: Expected O, but got Unknown CurrentEventCooldowns currentEventCooldowns = new CurrentEventCooldowns(); string organisationName = Singleton.Instance.ActiveSaveInfo.OrganisationName; int saveSlotNumber = Singleton.Instance.ActiveSaveInfo.SaveSlotNumber; string path = $"{saveSlotNumber}_{SanitizeAndFormatName(organisationName)}"; string pathTo = ModDataPaths.GetPathTo(Path.Combine(ModDataPaths.pathEventFrequencyPersist, path)); if (File.Exists(pathTo)) { try { currentEventCooldowns = JsonConvert.DeserializeObject(File.ReadAllText(pathTo)); bool flag = true; if (currentEventCooldowns.SabotageCooldowns != null) { if (currentEventCooldowns.SabotageCooldowns.Count != 3) { flag = false; } if (!Enumerable.Contains(currentEventCooldowns.SabotageCooldowns.Keys, "Laundromat")) { flag = false; } if (!Enumerable.Contains(currentEventCooldowns.SabotageCooldowns.Keys, "Post Office")) { flag = false; } if (!Enumerable.Contains(currentEventCooldowns.SabotageCooldowns.Keys, "Taco Ticklers")) { flag = false; } } else { flag = false; } if (!flag) { MelonLogger.Error("Cartel Enforcer Frequency persistent data has incorrect sagotage cooldowns. Resetting values"); int activityHours = FrequencyOverrides.GetActivityHours("Sabotage"); activityHours = ((activityHours != 0) ? activityHours : Random.Range(16, 64)); currentEventCooldowns.SabotageCooldowns = new Dictionary { { "Laundromat", activityHours }, { "Post Office", activityHours }, { "Taco Ticklers", activityHours } }; } } catch (JsonSerializationException ex) { JsonSerializationException ex2 = ex; currentEventCooldowns = new CurrentEventCooldowns(); currentEventCooldowns.InitializeDefault(); MelonLogger.Error("Failed to deserialize CartelEnforcer Frequency persistent data: " + ((Exception)(object)ex2).Message); } catch (Exception ex3) { currentEventCooldowns = new CurrentEventCooldowns(); currentEventCooldowns.InitializeDefault(); MelonLogger.Warning("Failed to read CartelEnforcer Frequency persistent data: " + ex3); } } else { MelonLogger.Warning("Missing CartelEnforcer Frequency persistent data, creating directory and template."); currentEventCooldowns = new CurrentEventCooldowns(); currentEventCooldowns.InitializeDefault(); Save(currentEventCooldowns); } return currentEventCooldowns; } public static void Save(CurrentEventCooldowns cooldowns) { try { string organisationName = Singleton.Instance.ActiveSaveInfo.OrganisationName; int saveSlotNumber = Singleton.Instance.ActiveSaveInfo.SaveSlotNumber; string path = $"{saveSlotNumber}_{SanitizeAndFormatName(organisationName)}"; string pathTo = ModDataPaths.GetPathTo(Path.Combine(ModDataPaths.pathEventFrequencyPersist, path)); string contents = JsonConvert.SerializeObject((object)cooldowns, (Formatting)1); Directory.CreateDirectory(Path.GetDirectoryName(pathTo)); File.WriteAllText(pathTo, contents); } catch (Exception ex) { MelonLogger.Warning("Failed to save CartelEnforcer Frequency persistent data: " + ex); } } } public class ModPrefsHandler { public MelonPreferences_Category modConfigCategory; public void SetupMelonPreferences() { string text = "Cartel Enforcer XOWithSauce"; modConfigCategory = MelonPreferences.CreateCategory(text, "Cartel Enforcer"); modConfigCategory.CreateEntry("debugMode", CartelEnforcer.currentConfig.debugMode, "Debug Mode Enabled", "Enable keybinds & display visual cues", false, false, (ValueValidator)null, (string)null); modConfigCategory.CreateEntry("driveByEnabled", CartelEnforcer.currentConfig.driveByEnabled, "Drive By Enabled", "Enables drive-by events where Thomas shoots the player", false, false, (ValueValidator)null, (string)null); modConfigCategory.CreateEntry("realRobberyEnabled", CartelEnforcer.currentConfig.realRobberyEnabled, "Real Robbery Enabled", "Enables robberies where a goon is spawned to fight the dealer", false, false, (ValueValidator)null, (string)null); modConfigCategory.CreateEntry("defaultRobberyEnabled", CartelEnforcer.currentConfig.defaultRobberyEnabled, "Default Robbery Enabled", "Enables the robberies where you only get a text message", false, false, (ValueValidator)null, (string)null); modConfigCategory.CreateEntry("miniQuestsEnabled", CartelEnforcer.currentConfig.miniQuestsEnabled, "Mini Quests Enabled", "Enables mini quest generation for finding cartels dead drops", false, false, (ValueValidator)null, (string)null); modConfigCategory.CreateEntry("interceptDeals", CartelEnforcer.currentConfig.interceptDeals, "Intercept Deals Enabled", "Enables an event where Cartel Dealers try to steal your active deals", false, false, (ValueValidator)null, (string)null); modConfigCategory.CreateEntry("enhancedDealers", CartelEnforcer.currentConfig.enhancedDealers, "Enhanced Dealers Enabled", "Use custom behaviour for Cartel Dealers", false, false, (ValueValidator)null, (string)null); modConfigCategory.CreateEntry("cartelGatherings", CartelEnforcer.currentConfig.cartelGatherings, "Cartel Gatherings Enabled", "Enables an event where Cartel Goons gather around randomly during the day", false, false, (ValueValidator)null, (string)null); modConfigCategory.CreateEntry("businessSabotage", CartelEnforcer.currentConfig.businessSabotage, "Business Sabotage Enabled", "Enables an event where a Cartel Goon tries to plant a bomb at your business", false, false, (ValueValidator)null, (string)null); modConfigCategory.CreateEntry("stealBackCustomers", CartelEnforcer.currentConfig.stealBackCustomers, "Steal Back Customers Enabled", "Enables a feature where the Cartel can steal back your customers and lock them", false, false, (ValueValidator)null, (string)null); modConfigCategory.CreateEntry("alliedExtensions", CartelEnforcer.currentConfig.alliedExtensions, "Allied Extensions Enabled", "Allows you to hire cartel dealers and partake in supply quests while enabled. Requires End Game Quests to be enabled.", false, false, (ValueValidator)null, (string)null); modConfigCategory.CreateEntry("endGameQuest", CartelEnforcer.currentConfig.endGameQuest, "End Game Quests Enabled", "Enables the generation of custom quests for Cartel", false, false, (ValueValidator)null, (string)null); for (int i = 0; i < modConfigCategory.Entries.Count; i++) { string id = modConfigCategory.Entries[i].Identifier; ((MelonEventBase>)(object)modConfigCategory.Entries[i].OnEntryValueChangedUntyped).Subscribe((LemonAction)ThisEntryChanged, 0, false); void ThisEntryChanged(object objOld, object objNew) { OnEntryChange(id, objOld, objNew); } } MelonPreferences.SaveCategory(text, false); } public static void OnEntryChange(string identifier, object objOld, object objNew) { FieldInfo[] fields = CartelEnforcer.currentConfig.GetType().GetFields(); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.Name.Contains(identifier) && fieldInfo.Name.Contains("endGameQuestMonologueSpeed")) { if (fieldInfo.Name.Contains("endGameQuest") && CartelEnforcer.currentConfig.alliedExtensions && !(bool)objNew) { break; } fieldInfo.SetValue(CartelEnforcer.currentConfig, (bool)objNew); } } ConfigLoader.Save(CartelEnforcer.currentConfig, logResult: false); } } public static class ModDataPaths { private static readonly string BASE_USERDATA_NAME = "XO_WithSauce-CartelEnforcer"; private static readonly string TS_PACKAGE_NAME = "XO_WithSauce-CartelEnforcer_"; private static readonly string packagePathUserData = Path.Combine(MelonEnvironment.UserDataDirectory, TS_PACKAGE_NAME + "IL2CPP", BASE_USERDATA_NAME); private static readonly string manualPathUserData = Path.Combine(MelonEnvironment.UserDataDirectory, BASE_USERDATA_NAME); public static readonly string pathModConfig = "config.json"; public static readonly string pathAmbushes = Path.Combine("Ambush", "ambush.json"); public static readonly string pathDefAmbushes = Path.Combine("Ambush", "default.json"); public static readonly string pathSettingsAmbushes = Path.Combine("Ambush", "settings.json"); public static readonly string pathDriveBys = Path.Combine("DriveBy", "driveby.json"); public static readonly string pathDealerConfig = Path.Combine("Dealers", "dealer.json"); public static readonly string pathCartelStolen = "CartelItems"; public static readonly string pathInfluenceConfig = Path.Combine("Influence", "influence.json"); public static readonly string pathAlliedConfig = Path.Combine("Allied", "config.json"); public static readonly string pathAlliedPersist = Path.Combine("Allied", "QuestData"); public static readonly string pathEventFrequency = Path.Combine("EventFrequency", "config.json"); public static readonly string pathEventFrequencyPersist = Path.Combine("EventFrequency", "Cooldowns"); public static readonly string pathStolenCustomers = "StolenCustomers"; private static bool hasCheckedInstallationPath = false; private static bool isModManagerInstallation = false; public static string GetPathTo(string modDataDestination) { if (!hasCheckedInstallationPath) { if (Directory.Exists(packagePathUserData)) { isModManagerInstallation = true; } if (Directory.Exists(manualPathUserData)) { isModManagerInstallation = false; } hasCheckedInstallationPath = true; } return Path.Combine(isModManagerInstallation ? packagePathUserData : manualPathUserData, modDataDestination); } } public static class ConsoleModule { [Flags] public enum CommandSupport { None = 0, List = 1, Start = 2 } public abstract class ConsoleCommandBase { public virtual string Name { get; } public virtual CommandSupport SupportedMethods { get; } public virtual void List() { } public virtual void Start() { } } public class RobberyTarget : ConsoleCommandBase { public override string Name => "robbery"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { CartelEnforcer.coros.Add(MelonCoroutines.Start(DebugModule.OnInputStartRob())); } } public class DriveByTarget : ConsoleCommandBase { public override string Name => "driveby"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { CartelEnforcer.coros.Add(MelonCoroutines.Start(DebugModule.OnInputStartDriveBy())); } } public class MiniQuestTarget : ConsoleCommandBase { public override string Name => "miniquest"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { CartelEnforcer.coros.Add(MelonCoroutines.Start(DebugModule.OnInputGiveMiniQuest())); } } public class InterceptDealTarget : ConsoleCommandBase { public override string Name => "intercept"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { CartelEnforcer.coros.Add(MelonCoroutines.Start(DebugModule.OnInputInterceptContract())); } } public class GatheringTarget : ConsoleCommandBase { public override string Name => "gathering"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { CartelGathering.hoursUntilNextGathering = 1; CartelEnforcer.coros.Add(MelonCoroutines.Start(CartelGathering.TryStartGathering())); } } public class SabotageTarget : ConsoleCommandBase { public override string Name => "sabotage"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { CartelEnforcer.coros.Add(MelonCoroutines.Start(DebugModule.OnInputStartSabotage())); } } public class StealBackCustomerTarget : ConsoleCommandBase { public override string Name => "stealback"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { CartelEnforcer.coros.Add(MelonCoroutines.Start(DebugModule.OnInputStealNearestCustomer())); } } public class AlliedSuppliesTarget : ConsoleCommandBase { public override string Name => "alliedsupplies"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { CartelEnforcer.coros.Add(MelonCoroutines.Start(DebugModule.OnInputGenerateAlliedSupplyQuest())); } } public class AlliedIntroTarget : ConsoleCommandBase { public override string Name => "alliedintro"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { CartelEnforcer.coros.Add(MelonCoroutines.Start(DebugModule.OnInputGenerateAlliedIntroQuest())); } } public class AlliedTrueBrothersTarget : ConsoleCommandBase { public override string Name => "truebrothers"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.SummonConversateGoon())); } } public class UnexpectedAlliancesTarget : ConsoleCommandBase { public override string Name => "unexpectedalliances"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { EndGameQuest.hasGeneratedDefeatEnforcerQuest = true; EndGameQuest.fixer = (NPC)(object)Object.FindObjectOfType(true); CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.GenerateQuestState())); } } public class InfiltrateManorTarget : ConsoleCommandBase { public override string Name => "infiltratemanor"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { EndGameQuest.hasGeneratedManorQuest = true; NetworkSingleton.Instance.SetTimeAndSync(1816); DialogueController component = ((Component)((NPC)Object.FindObjectOfType(true)).DialogueHandler).gameObject.GetComponent(); int num = -1; for (int i = 0; i < component.Choices.Count; i++) { if (component.Choices[i].ChoiceText.Contains("What can you tell me about the owner of that manor")) { num = i; break; } } List choices = component.Choices; choices.RemoveAt(num); component.Choices = choices; CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.GenerateManorQuestState())); } } public class FourWheelsTarget : ConsoleCommandBase { public override string Name => "fourwheels"; public override CommandSupport SupportedMethods => CommandSupport.Start; public override void Start() { EndGameQuest.hasGeneratedCarQuest = true; NetworkSingleton.Instance.SetTimeAndSync(1700); CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.GenerateCarQuestState())); } } } public static class DebugModule { public static TextMeshProUGUI positionText; public static Transform playerTransform; public static Transform debugVisualParent; public static Dictionary consoleTargets = new Dictionary { { "robbery", new ConsoleModule.RobberyTarget() }, { "driveby", new ConsoleModule.DriveByTarget() }, { "miniquest", new ConsoleModule.MiniQuestTarget() }, { "intercept", new ConsoleModule.InterceptDealTarget() }, { "gathering", new ConsoleModule.GatheringTarget() }, { "sabotage", new ConsoleModule.SabotageTarget() }, { "stealback", new ConsoleModule.StealBackCustomerTarget() }, { "alliedsupplies", new ConsoleModule.AlliedSuppliesTarget() }, { "alliedintro", new ConsoleModule.AlliedIntroTarget() }, { "truebrothers", new ConsoleModule.AlliedTrueBrothersTarget() }, { "unexpectedalliances", new ConsoleModule.UnexpectedAlliancesTarget() }, { "infiltratemanor", new ConsoleModule.InfiltrateManorTarget() }, { "fourwheels", new ConsoleModule.FourWheelsTarget() } }; [Conditional("DEBUG")] public static void Log(string msg, [CallerMemberName] string memberName = "") { if (CartelEnforcer.currentConfig.debugMode) { MelonLogger.Msg("[" + memberName + "] " + msg); } } public static void LogRelease(string msg, [CallerMemberName] string memberName = "") { MelonLogger.Msg("[" + memberName + "] " + msg); } public static void RunCommand(List args) { if (args.Count == 2 && args[1].ToLower() == "help") { Help(); return; } if (args.Count < 3) { LogRelease("Usage: cartelenforcer (action) (target)\n Try: cartelenforcer help", "RunCommand"); return; } string text = args[1].ToLower(); string text2 = args[2].ToLower(); if (!consoleTargets.TryGetValue(text2, out var value)) { LogRelease("Unknown command target '" + text2 + "'", "RunCommand"); return; } ConsoleModule.CommandSupport commandSupport = ((text == "list") ? ConsoleModule.CommandSupport.List : ((text == "start") ? ConsoleModule.CommandSupport.Start : ConsoleModule.CommandSupport.None)); ConsoleModule.CommandSupport commandSupport2 = commandSupport; if ((value.SupportedMethods & commandSupport2) == 0) { LogRelease($"Command target '{text2}' does not support requested method '{commandSupport2}'", "RunCommand"); return; } switch (commandSupport2) { case ConsoleModule.CommandSupport.List: value.List(); break; case ConsoleModule.CommandSupport.Start: value.Start(); break; } } public static void Help() { string text = ""; text += "\nSupported Commands:"; foreach (ConsoleModule.ConsoleCommandBase value in consoleTargets.Values) { text = text + "\n\n# " + value.Name.ToUpper(); if (value.SupportedMethods.HasFlag(ConsoleModule.CommandSupport.List)) { text = text + "\ncartelenforcer list " + value.Name; } if (value.SupportedMethods.HasFlag(ConsoleModule.CommandSupport.Start)) { text = text + "\ncartelenforcer start " + value.Name; } } LogRelease(text, "Help"); } public static IEnumerator OnInputGenerateAlliedIntroQuest() { if (!AlliedExtension.alliedQuests.alliedIntroCompleted && (Object)(object)EndGameQuest.activeTruceIntro == (Object)null) { CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.SetupTruceIntroQuest())); } yield break; } public static IEnumerator OnInputGenerateAlliedSupplyQuest() { if ((Object)(object)EndGameQuest.activeAlliedSupplies == (Object)null && !EndGameQuest.alliedSuppliesActive) { CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.SetupTruceSuppliesQuest())); } else if ((Object)(object)EndGameQuest.activeAlliedSupplies != (Object)null && !EndGameQuest.alliedSuppliesActive) { EndGameQuest.activeAlliedSupplies.ResetSelf(); } LogRelease("Generated Allied Supply Quest", "OnInputGenerateAlliedSupplyQuest"); yield break; } public static IEnumerator OnInputStartDriveBy() { LogRelease("Starting Instant Drive By", "OnInputStartDriveBy"); Player.Local.Health.RecoverHealth(100f); float num = 150f; DriveByEvent.DriveByTrigger trig = null; foreach (KeyValuePair driveByLocation in DriveByEvent.driveByLocations) { float num2 = Vector3.Distance(Player.Local.CenterPointTransform.position, driveByLocation.Key.triggerPosition); if (num2 <= num) { trig = driveByLocation.Key; num = num2; } } CartelEnforcer.coros.Add(MelonCoroutines.Start(DriveByEvent.BeginDriveBy(trig))); yield break; } public static IEnumerator OnInputStartRob() { Transform playerLocal = ((Component)Player.Local).transform; Dealer[] array = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType(true)); Dealer nearest = null; float distanceToP = 160f; Dealer[] array2 = array; foreach (Dealer d in array2) { if ((int)d.DealerData.DealerType != 1 && d.IsRecruited && !((NPC)d).isInBuilding) { yield return CartelEnforcer.Wait01; float num = Vector3.Distance(((Component)d).transform.position, playerLocal.position); if (num < distanceToP) { distanceToP = num; nearest = d; } } } LogRelease("Starting robbery on nearest dealer", "OnInputStartRob"); nearest.TryRobDealer(); } public static IEnumerator OnInputGiveMiniQuest() { List list = MiniQuest.targetNPCs.Keys.ToList(); NPC val = list[Random.Range(0, list.Count)]; if (MiniQuest.targetNPCs.ContainsKey(val)) { if (!MiniQuest.targetNPCs[val].HasActiveQuest && !MiniQuest.targetNPCs[val].HasAskedQuestToday) { MiniQuest.targetNPCs[val].HasActiveQuest = true; MiniQuest.InitMiniQuestDialogue(val); LogRelease("Started Mini Quest for NPC: " + val.ID, "OnInputGiveMiniQuest"); } else { LogRelease("Failed to give Mini Quest for NPC: " + val.ID + ", try again", "OnInputGiveMiniQuest"); } } yield break; } public static IEnumerator OnInputInterceptContract() { CartelEnforcer.coros.Add(MelonCoroutines.Start(InterceptEvent.StartInterceptDeal())); LogRelease("Started Intercept Deals event", "OnInputInterceptContract"); yield break; } public static IEnumerator OnInputStartSabotage() { SabotageEvent.sabotageEventActive = true; SabotageEvent.SabotageEventLocation selected = null; float num = 500f; foreach (SabotageEvent.SabotageEventLocation location in SabotageEvent.locations) { if (Vector3.Distance(((Component)location.business).transform.position, Player.Local.CenterPointTransform.position) < num) { num = Vector3.Distance(((Component)location.business).transform.position, Player.Local.CenterPointTransform.position); selected = location; } } LogRelease("Starting sabotage event in 10sec at: " + ((Property)selected.business).PropertyName, "OnInputStartSabotage"); yield return CartelEnforcer.Wait10; if (CartelEnforcer.registered) { CartelEnforcer.coros.Add(MelonCoroutines.Start(SabotageEvent.GoonPlantBomb(selected))); } } public static IEnumerator OnInputStealNearestCustomer() { Customer val = null; float num = 15f; Enumerator enumerator = Customer.UnlockedCustomers.GetEnumerator(); while (enumerator.MoveNext()) { Customer current = enumerator.Current; if (Vector3.Distance(Player.Local.CenterPointTransform.position, current.NPC.CenterPoint) < num) { val = current; num = Vector3.Distance(Player.Local.CenterPointTransform.position, current.NPC.CenterPoint); } } if (!((Object)(object)val == (Object)null)) { LogRelease("Stealing Nearest Customer: " + val.NPC.ID, "OnInputStealNearestCustomer"); StealBackCustomer.StealCustomer(val.NPC); } yield break; } public static IEnumerator GodMode() { while (true) { yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { break; } if (Player.Local.Health.CurrentHealth < 100f) { Player.Local.Health.RecoverHealth(100f); } } } public static IEnumerator MakeUI() { playerTransform = Player.Local.CenterPointTransform; HUD instance = Singleton.Instance; positionText = new GameObject("PlayerPositionText").AddComponent(); ((TMP_Text)positionText).transform.SetParent(((Component)instance.canvas).transform, false); ((TMP_Text)positionText).alignment = (TextAlignmentOptions)257; ((TMP_Text)positionText).fontSize = 16f; ((Graphic)positionText).color = Color.red; ((TMP_Text)positionText).rectTransform.anchorMin = new Vector2(0f, 1f); ((TMP_Text)positionText).rectTransform.anchorMax = new Vector2(0f, 1f); ((TMP_Text)positionText).rectTransform.pivot = new Vector2(0f, 1f); ((TMP_Text)positionText).rectTransform.anchoredPosition = new Vector2(40f, -40f); yield return null; } public static IEnumerator SpawnAmbushAreaVisual() { if ((Object)(object)debugVisualParent == (Object)null) { debugVisualParent = new GameObject("DebugVisuals").transform; } Shader val = Shader.Find("Universal Render Pipeline/Lit"); Dictionary dictionary = new Dictionary(); foreach (EMapRegion value2 in Enum.GetValues(typeof(EMapRegion))) { Material val3 = new Material(val); val3.color = GetColorCorrespondance(value2); dictionary[value2] = val3; } Material val4 = new Material(val); val4.color = Color.cyan; CartelRegionActivities[] array = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType(true)); Vector3 val7 = default(Vector3); foreach (CartelRegionActivities val5 in array) { foreach (CartelAmbushLocation item in (Il2CppArrayBase)(object)val5.AmbushLocations) { float detectionRadius = item.DetectionRadius; GameObject val6 = GameObject.CreatePrimitive((PrimitiveType)3); MeshRenderer component = val6.GetComponent(); if (dictionary.TryGetValue(val5.Region, out var value)) { ((Renderer)component).material = value; } else { ((Renderer)component).material = new Material(val); ((Renderer)component).material.color = Color.white; } ((Renderer)component).receiveShadows = false; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; val6.transform.parent = debugVisualParent; val6.transform.localScale = new Vector3(detectionRadius, detectionRadius, detectionRadius); val6.transform.position = ((Component)item).transform.position + new Vector3(0f, 25f + detectionRadius, 0f); val6.SetActive(true); foreach (Transform item2 in (Il2CppArrayBase)(object)item.AmbushPoints) { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)1); MeshRenderer component2 = obj.GetComponent(); ((Renderer)component2).material = val4; ((Renderer)component2).receiveShadows = false; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; obj.transform.position = ((Component)item2).transform.position + new Vector3(0f, 20f, 0f); obj.transform.parent = val6.transform; ((Vector3)(ref val7))..ctor(0.2f, 12f, 0.2f); Vector3 lossyScale = val6.transform.lossyScale; obj.transform.localScale = new Vector3(val7.x / lossyScale.x, val7.y / lossyScale.y, val7.z / lossyScale.z); obj.SetActive(true); } } } yield return null; } public static IEnumerator SpawnDriveByAreaVisual() { if ((Object)(object)debugVisualParent == (Object)null) { debugVisualParent = new GameObject("DebugVisuals").transform; } Material val = new Material(Shader.Find("Universal Render Pipeline/Lit")); val.color = new Color(1f, 29f / 51f, 0f); foreach (KeyValuePair driveByLocation in DriveByEvent.driveByLocations) { DriveByEvent.DriveByTrigger key = driveByLocation.Key; float radius = key.radius; GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); MeshRenderer component = obj.GetComponent(); ((Renderer)component).material = val; ((Renderer)component).receiveShadows = false; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; obj.transform.parent = debugVisualParent; obj.transform.localScale = new Vector3(radius * 2f, radius * 2f, radius * 2f); obj.transform.position = key.triggerPosition + new Vector3(0f, 20f + radius * 2f, 0f); obj.SetActive(true); } yield break; } private static Color GetColorCorrespondance(EMapRegion reg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected I4, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0044: Unknown result type (might be due to invalid IL or missing references) return (Color)((int)reg switch { 0 => Color.yellow, 1 => Color.blue, 2 => Color.red, 3 => Color.green, 4 => Color.magenta, 5 => Color.black, _ => Color.white, }); } } [HarmonyPatch(typeof(Console), "SubmitCommand", new Type[] { typeof(List) })] public static class Console_SubmitCommand_ListString_Patch { public static bool Prefix(Console __instance, List args) { List list = new List(); Enumerator enumerator = args.GetEnumerator(); while (enumerator.MoveNext()) { string current = enumerator.Current; list.Add(current); } if (args.Count == 0) { return true; } if (args[0].ToLower() == "cartelenforcer") { DebugModule.RunCommand(list); return true; } return true; } } [HarmonyPatch(typeof(Console), "SubmitCommand", new Type[] { typeof(string) })] public static class Console_SubmitCommand_String_Patch { public static bool Prefix(Console __instance, string args) { return true; } } public static class DriveByEvent { [Serializable] public class DriveByTrigger { public string name; public Vector3 triggerPosition; public float radius; public Vector3 spawnEulerAngles; public Vector3 startPosition; public Vector3 endPosition; } public class HitComparer : IComparer { public int Compare(RaycastHit x, RaycastHit y) { bool flag = (Object)(object)((RaycastHit)(ref x)).collider != (Object)null; bool flag2 = (Object)(object)((RaycastHit)(ref y)).collider != (Object)null; if (flag && !flag2) { return -1; } if (!flag && flag2) { return 1; } if (!flag && !flag2) { return 0; } return ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance); } } public static LandVehicle driveByVeh; public static Vector3 localOrigin; public static Quaternion localRotation; public static VehicleAgent driveByAgent; public static VehicleTeleporter driveByTp; public static bool driveByActive = false; public static Thomas thomasInstance; public static ParkData driveByParking; public static int hoursUntilDriveBy = 5; public static Dictionary driveByLocations = new Dictionary(); private static Il2CppStructArray _raycastHitBuffer = new Il2CppStructArray(8L); public static IEnumerator InitializeDriveByData() { ConfigLoader.DriveByTriggersSerialized driveByTriggersSerialized = ConfigLoader.LoadDriveByConfig(); driveByLocations = new Dictionary(); foreach (DriveByTrigger trigger in driveByTriggersSerialized.triggers) { driveByLocations.Add(trigger, Singleton.Instance.GetRegionFromPosition(trigger.triggerPosition)); } yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { yield break; } Transform thomasCar = ((Component)NetworkSingleton.Instance).transform.Find("ThomasBoxSUV"); if ((Object)(object)thomasCar != (Object)null) { if (!((Component)thomasCar).gameObject.activeSelf) { ((Component)thomasCar).gameObject.SetActive(true); } driveByVeh = ((Component)thomasCar).GetComponent(); driveByAgent = ((Component)thomasCar).GetComponent(); driveByTp = ((Component)thomasCar).GetComponent(); thomasInstance = Object.FindObjectOfType(); localOrigin = ((Component)thomasInstance).transform.localPosition; localRotation = ((Component)thomasInstance).transform.localRotation; if ((Object)(object)driveByVeh != (Object)null) { driveByVeh.TopSpeed = 100f; ParkData val = new ParkData { spotIndex = -1 }; ParkingLot val2 = Object.FindObjectOfType(); val.lotGUID = new Guid(val2.BakedGUID); driveByParking = val; } if ((Object)(object)driveByAgent != (Object)null) { driveByAgent.Flags.OverriddenSpeed = 75f; driveByAgent.Flags.OverrideSpeed = true; driveByAgent.Flags.IgnoreTrafficLights = true; driveByAgent.Flags.ObstacleMode = (EObstacleMode)1; driveByAgent.turnSpeedReductionDivisor = 150f; driveByAgent.turnSpeedReductionMaxRange = 20f; driveByAgent.turnSpeedReductionMinRange = 6f; } if ((Object)(object)thomasInstance != (Object)null) { ((NPC)thomasInstance).Behaviour.CombatBehaviour.SetWeapon("Avatar/Equippables/M1911"); yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { yield break; } AvatarRangedWeapon val3 = null; try { val3 = ((Il2CppObjectBase)((NPC)thomasInstance).Behaviour.CombatBehaviour.currentWeapon).Cast(); } catch (InvalidCastException) { } if ((Object)(object)val3 != (Object)null) { ((AvatarWeapon)val3).MaxUseRange = 45f; ((AvatarWeapon)val3).MinUseRange = 8f; val3.HitChance_MaxRange = 0.4f; val3.HitChance_MinRange = 0.9f; val3.MaxFireRate = 0.1f; ((AvatarWeapon)val3).CooldownDuration = 0.1f; val3.Damage = 33f; } } Transform val4 = thomasCar.Find("Box SUV"); if (!((Component)val4).gameObject.activeSelf) { ((Component)val4).gameObject.SetActive(true); } } hoursUntilDriveBy = CartelEnforcer.eventCooldowns.DriveByCooldown; } public static void GenerateDefaultDriveByTriggers() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05cc: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0625: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_065e: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_0683: Unknown result type (might be due to invalid IL or missing references) //IL_0688: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_0715: Unknown result type (might be due to invalid IL or missing references) //IL_071a: 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_0734: Unknown result type (might be due to invalid IL or missing references) //IL_0749: Unknown result type (might be due to invalid IL or missing references) //IL_074e: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_0787: Unknown result type (might be due to invalid IL or missing references) //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_07ac: Unknown result type (might be due to invalid IL or missing references) //IL_07c1: Unknown result type (might be due to invalid IL or missing references) //IL_07c6: Unknown result type (might be due to invalid IL or missing references) //IL_07db: Unknown result type (might be due to invalid IL or missing references) //IL_07e0: Unknown result type (might be due to invalid IL or missing references) //IL_0814: Unknown result type (might be due to invalid IL or missing references) //IL_0819: Unknown result type (might be due to invalid IL or missing references) //IL_0839: Unknown result type (might be due to invalid IL or missing references) //IL_083e: Unknown result type (might be due to invalid IL or missing references) //IL_0853: Unknown result type (might be due to invalid IL or missing references) //IL_0858: Unknown result type (might be due to invalid IL or missing references) //IL_086d: Unknown result type (might be due to invalid IL or missing references) //IL_0872: Unknown result type (might be due to invalid IL or missing references) DriveByTrigger key = new DriveByTrigger { name = "Suburbia Bus Stop", triggerPosition = new Vector3(110.39f, 5.36f, -111.69f), radius = 2f, startPosition = new Vector3(144.68f, 5.6f, -103.69f), spawnEulerAngles = new Vector3(0f, 270f, 0f), endPosition = new Vector3(17.4f, 1.37f, -103.53f) }; driveByLocations.Add(key, (EMapRegion)4); DriveByTrigger key2 = new DriveByTrigger { name = "Suburbia Gazebo Park", triggerPosition = new Vector3(84.99f, 5.36f, -122.38f), radius = 7f, startPosition = new Vector3(144.68f, 5.6f, -103.69f), spawnEulerAngles = new Vector3(0f, 270f, 0f), endPosition = new Vector3(17.4f, 1.37f, -103.53f) }; driveByLocations.Add(key2, (EMapRegion)4); DriveByTrigger key3 = new DriveByTrigger { name = "Barn path towards road", triggerPosition = new Vector3(163.29f, 1.18f, -9.95f), radius = 6f, startPosition = new Vector3(155.2f, 1.37f, 22.79f), spawnEulerAngles = new Vector3(0f, 240f, 0f), endPosition = new Vector3(89.85f, 5.37f, -81.81f) }; driveByLocations.Add(key3, (EMapRegion)5); DriveByTrigger key4 = new DriveByTrigger { name = "Mollys apartment", triggerPosition = new Vector3(-168.44f, -2.54f, 88.32f), radius = 15f, startPosition = new Vector3(-146.4f, -2.63f, 39.92f), spawnEulerAngles = new Vector3(0f, 310f, 0f), endPosition = new Vector3(-111.28f, -2.64f, 123.4f) }; driveByLocations.Add(key4, (EMapRegion)1); DriveByTrigger key5 = new DriveByTrigger { name = "Car Wash Computer", triggerPosition = new Vector3(-6.05f, 1.21f, -17.83f), radius = 5f, startPosition = new Vector3(-19.96f, 1.37f, 20.44f), spawnEulerAngles = new Vector3(0f, 180f, 0f), endPosition = new Vector3(-10.61f, 1.37f, -102.43f) }; driveByLocations.Add(key5, (EMapRegion)2); DriveByTrigger key6 = new DriveByTrigger { name = "Laundromat computer", triggerPosition = new Vector3(-29.19f, 1.96f, 26.13f), radius = 4f, startPosition = new Vector3(-17.17f, 1.37f, -22.86f), spawnEulerAngles = new Vector3(0f, 0f, 0f), endPosition = new Vector3(-16.98f, -2.51f, 123.42f) }; driveByLocations.Add(key6, (EMapRegion)3); DriveByTrigger key7 = new DriveByTrigger { name = "Grocery Market Downtown", triggerPosition = new Vector3(17.62f, 1.61f, -3.31f), radius = 6f, startPosition = new Vector3(-11.64f, 1.15f, -43.54f), spawnEulerAngles = new Vector3(0f, 60f, 0f), endPosition = new Vector3(33.02f, 1.15f, 65.28f) }; driveByLocations.Add(key7, (EMapRegion)2); DriveByTrigger key8 = new DriveByTrigger { name = "Jane's RV", triggerPosition = new Vector3(-36.74f, 0.14f, -77.14f), radius = 11f, startPosition = new Vector3(3.98f, 1.37f, -103.35f), spawnEulerAngles = new Vector3(0f, 270f, 0f), endPosition = new Vector3(-16.9f, 1.37f, 52f) }; driveByLocations.Add(key8, (EMapRegion)3); DriveByTrigger key9 = new DriveByTrigger { name = "Town hall stairs", triggerPosition = new Vector3(51.28f, 1.48f, 31.03f), radius = 6f, startPosition = new Vector3(29.97f, 1.37f, 81.63f), spawnEulerAngles = new Vector3(0f, 180f, 0f), endPosition = new Vector3(-12.39f, 1.37f, -40.43f) }; driveByLocations.Add(key9, (EMapRegion)2); DriveByTrigger key10 = new DriveByTrigger { name = "Alley between Ham Legal and Hyland Tower", triggerPosition = new Vector3(84.01f, 1.46f, 63.21f), radius = 2f, startPosition = new Vector3(61.99f, 1.37f, 49.59f), spawnEulerAngles = new Vector3(0f, 90f, 0f), endPosition = new Vector3(90.05f, 5.37f, -79.52f) }; driveByLocations.Add(key10, (EMapRegion)5); DriveByTrigger key11 = new DriveByTrigger { name = "Road in front of Ray's Estate and Blueball Boutique", triggerPosition = new Vector3(74.65f, 1.37f, -3.24f), radius = 8f, startPosition = new Vector3(93.06f, 2.3f, -37.39f), spawnEulerAngles = new Vector3(6f, 0f, 0f), endPosition = new Vector3(30.11f, 1.37f, 72.9f) }; driveByLocations.Add(key11, (EMapRegion)5); DriveByTrigger key12 = new DriveByTrigger { name = "Behind the Taco Ticklers", triggerPosition = new Vector3(-33.19f, 1.46f, 85.58f), radius = 6f, startPosition = new Vector3(-17.13f, 1.37f, 61f), spawnEulerAngles = new Vector3(0f, 0f, 0f), endPosition = new Vector3(-28.73f, -2.63f, 132.68f) }; driveByLocations.Add(key12, (EMapRegion)0); DriveByTrigger key13 = new DriveByTrigger { name = "Skatepark and surrounding area", triggerPosition = new Vector3(-49.25f, 1.09f, 75.8f), radius = 10f, startPosition = new Vector3(-93.33f, -1.43f, 70.9f), spawnEulerAngles = new Vector3(-8f, 110f, 0f), endPosition = new Vector3(-16.86f, 1.37f, -5.03f) }; driveByLocations.Add(key13, (EMapRegion)0); DriveByTrigger key14 = new DriveByTrigger { name = "Behind Crimson Canary", triggerPosition = new Vector3(48.51f, 1.46f, 66.55f), radius = 8f, startPosition = new Vector3(27.37f, 1.37f, 49.58f), spawnEulerAngles = new Vector3(0f, 90f, 0f), endPosition = new Vector3(90.05f, 1.37f, 22.96f) }; driveByLocations.Add(key14, (EMapRegion)2); DriveByTrigger key15 = new DriveByTrigger { name = "Suburbia Jeremys house", triggerPosition = new Vector3(69.55f, 5.93f, -117.93f), radius = 2f, startPosition = new Vector3(144.68f, 5.6f, -103.69f), spawnEulerAngles = new Vector3(0f, 270f, 0f), endPosition = new Vector3(17.4f, 1.37f, -103.53f) }; driveByLocations.Add(key15, (EMapRegion)4); } public static IEnumerator EvaluateDriveBy() { yield return CartelEnforcer.Wait5; if (!CartelEnforcer.registered || !InstanceFinder.NetworkManager.IsServer) { yield break; } float influenceRequirement = FrequencyOverrides.GetByID("DriveBy").InfluenceRequirement; while (CartelEnforcer.registered) { yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { break; } if (Singleton.Instance.IsSaving || CartelEnforcer.isSaving || !CartelEnforcer.currentConfig.driveByEnabled) { continue; } bool num = (int)NetworkSingleton.Instance.Status == 2; bool flag = NetworkSingleton.Instance.IsCurrentTimeWithinRange(2230, 500); if (!num || driveByActive || !flag || hoursUntilDriveBy > 0 || (Object)(object)EndGameQuest.activeManorQuest != (Object)null) { yield return CartelEnforcer.Wait60; if (!CartelEnforcer.registered) { break; } continue; } foreach (KeyValuePair kvp in driveByLocations) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { if (!(Vector3.Distance(Player.Local.CenterPointTransform.position, kvp.Key.triggerPosition) > kvp.Key.radius) && !((Object)(object)Player.Local.CurrentVehicle != (Object)null) && (!(influenceRequirement >= 0f) || !(NetworkSingleton.Instance.Influence.GetRegionData(kvp.Value).Influence < influenceRequirement)) && !driveByActive) { CartelEnforcer.coros.Add(MelonCoroutines.Start(BeginDriveBy(kvp.Key))); break; } continue; } yield break; } } } public static IEnumerator BeginDriveBy(DriveByTrigger trig) { if (!driveByActive && CartelEnforcer.registered) { driveByActive = true; float num = default(float); Player closestPlayer = PlayerManager.GetClosestPlayer(trig.triggerPosition, ref num, (List)null); driveByVeh.ExitPark_Networked((NetworkConnection)null, false); driveByVeh.SetTransform_Server(trig.startPosition, Quaternion.Euler(trig.spawnEulerAngles)); driveByTp.MoveToRoadNetwork(false); driveByAgent.Navigate(trig.endPosition, (NavigationSettings)null, NavigationCallback.op_Implicit((Action)DriveByNavComplete)); driveByAgent.AutoDriving = true; ((Component)thomasInstance).gameObject.SetActive(true); if (((NPC)thomasInstance).HasUmbrella) { ((NPC)thomasInstance).HasUmbrella = false; } CartelEnforcer.coros.Add(MelonCoroutines.Start(DriveByShooting(closestPlayer))); yield return null; } } public static IEnumerator DriveByShooting(Player player) { int maxBulletsShot = Random.Range(4, 9); int bulletsShot = 0; ((NPC)thomasInstance).Behaviour.CombatBehaviour.SetTarget(((Component)player).GetComponent().NetworkObject); ((NPC)thomasInstance).Behaviour.CombatBehaviour.SetWeaponRaised(true); int playerLayer = LayerMask.NameToLayer("Player"); int obstacleLayerMask = LayerMask.GetMask(new string[3] { "Terrain", "Default", "Vehicle" }); int maxIter = 80; int j = 0; while (driveByActive) { j++; yield return CartelEnforcer.Wait025; if (!CartelEnforcer.registered) { yield break; } if (bulletsShot >= maxBulletsShot || j >= maxIter) { break; } float num = Vector3.Distance(((Component)thomasInstance).transform.position, player.CenterPointTransform.position); Vector3 val = ((Component)thomasInstance).transform.position + ((Component)thomasInstance).transform.up * 1.7f - ((Component)thomasInstance).transform.right * 0.8f; Vector3 val2 = player.CenterPointTransform.position - val; float num2 = Vector3.SignedAngle(((Component)thomasInstance).transform.forward, val2, Vector3.up); int num3 = Physics.RaycastNonAlloc(val, val2, _raycastHitBuffer, 50f); Array.Sort(Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)_raycastHitBuffer), 0, num3, new HitComparer()); bool flag = false; for (int i = 0; i < num3; i++) { RaycastHit val3 = ((Il2CppArrayBase)(object)_raycastHitBuffer)[i]; if ((obstacleLayerMask & (1 << ((Component)((RaycastHit)(ref val3)).collider).gameObject.layer)) != 0) { flag = false; break; } if (((Component)((RaycastHit)(ref val3)).collider).gameObject.layer == playerLayer) { flag = true; break; } } if (!flag || !(num2 < -10f) || !(num2 > -80f)) { continue; } if (num < 15f) { if (Random.Range(0f, 1f) > 0.1f || (num2 < -20f && num2 > -80f)) { ((NPC)thomasInstance).Behaviour.CombatBehaviour.Shoot(); bulletsShot++; } } else if (num < 25f) { if (Random.Range(0f, 1f) > 0.2f || (num2 < -25f && num2 > -70f)) { ((NPC)thomasInstance).Behaviour.CombatBehaviour.Shoot(); bulletsShot++; } } else if (num < 35f) { if (Random.Range(0f, 1f) > 0.4f || (num2 < -30f && num2 > -60f)) { ((NPC)thomasInstance).Behaviour.CombatBehaviour.Shoot(); bulletsShot++; } } else if (num < 45f) { if (Random.Range(0f, 1f) > 0.7f || (num2 < -40f && num2 > -80f)) { ((NPC)thomasInstance).Behaviour.CombatBehaviour.Shoot(); bulletsShot++; } } else if (flag && num2 < -30f && num2 > -80f && Random.Range(0f, 1f) > 0.9f) { ((NPC)thomasInstance).Behaviour.CombatBehaviour.Shoot(); bulletsShot++; } } yield return null; } public static void DriveByNavComplete(ENavigationResult result) { if (CartelEnforcer.registered) { driveByAgent.storedNavigationCallback = null; driveByAgent.StopNavigating(); driveByVeh.Park_Networked((NetworkConnection)null, driveByParking); ((Component)thomasInstance).gameObject.SetActive(false); CartelEnforcer.coros.Add(MelonCoroutines.Start(ResetDriveByHours())); } } public static IEnumerator ResetDriveByHours() { if (Singleton.Instance.IsSaving || CartelEnforcer.isSaving) { yield return (object)new WaitUntil(Func.op_Implicit((Func)(() => !Singleton.Instance.IsSaving && !CartelEnforcer.isSaving))); } int activityHours = FrequencyOverrides.GetActivityHours("DriveBy"); if (activityHours != 0) { hoursUntilDriveBy = activityHours; } else { hoursUntilDriveBy = Random.Range(24, 68); } driveByActive = false; } } public static class CartelGathering { public static Dictionary> gatheringLocationsByRegion = new Dictionary> { { 5, new List { new GatheringLocation(new Vector3(151.39f, 2.18f, -16.93f), 5, "forest next to the barn in the Uptown region."), new GatheringLocation(new Vector3(98.23f, 1.43f, 3.16f), 5, "sewer entrance next to Handy Hank's in the Uptown region."), new GatheringLocation(new Vector3(126.84f, 1.46f, 55.52f), 5, "parking lot infront of the Church in the Uptown region."), new GatheringLocation(new Vector3(65.94f, 1.46f, 65.51f), 5, "alley between the Hyland towers.") } }, { 4, new List { new GatheringLocation(new Vector3(92.06f, 5.61f, -128.88f), 4, "park in the Suburbia region."), new GatheringLocation(new Vector3(13.5f, 1.31f, -77.06f), 4, "broken RV in the Suburbia region.") } }, { 3, new List { new GatheringLocation(new Vector3(-53.69f, -1.14f, -84.46f), 3, "shipping containers in the Docks region."), new GatheringLocation(new Vector3(-19.31f, -3.17f, -5.31f), 3, "canal in the Docks region."), new GatheringLocation(new Vector3(-66.38f, -1.14f, 21.06f), 3, "southern wharf next to warehouse.") } }, { 2, new List { new GatheringLocation(new Vector3(43.65f, 1.46f, 24.2f), 2, "town hall."), new GatheringLocation(new Vector3(-8.86f, 1.56f, 79.54f), 2, "parking garage in the Downtown region."), new GatheringLocation(new Vector3(3.5f, 5.56f, 84f), 2, "parking garage in the Downtown region."), new GatheringLocation(new Vector3(23.46f, 1.46f, 84.16f), 2, "casino in the Downtown region.") } }, { 1, new List { new GatheringLocation(new Vector3(-139.19f, -2.57f, 71.38f), 1, "Top Tattoo in the Westville region."), new GatheringLocation(new Vector3(-175.95f, -2.54f, 81.69f), 1, "brown apartment block parking lot."), new GatheringLocation(new Vector3(-97.42f, -2.72f, 60.7f), 1, "small RV next to western gas mart.") } }, { 0, new List { new GatheringLocation(new Vector3(-62.84f, -3.64f, 166.34f), 0, "northern waterfront in the Northtown region."), new GatheringLocation(new Vector3(-86.51f, -4.12f, 108.41f), 0, "western canal in the Northtown region."), new GatheringLocation(new Vector3(-31.51f, 1.46f, 100.46f), 0, "area in front of Thompson's Construction"), new GatheringLocation(new Vector3(-76.09f, -2.54f, 140.6f), 0, "basketball court in the Northtown region.") } } }; public static bool areGoonsGathering = false; public static int hoursUntilNextGathering = 3; public static List spawnedGatherGoons = new List(); public static bool startedCombat = false; public static GatheringLocation currentGatheringLocation = null; public static GatheringLocation previousGatheringLocation = null; public static int lootGoblinIndex = -1; public static int startEarliest = 0; public static int startLatest = 0; public static UnityAction combatStartedAction = null; public static UnityAction endSmokeAction = null; public static UnityAction endDrinkAction = null; public static void OnHourPassTryGather() { if (CartelEnforcer.currentConfig.cartelGatherings) { CartelEnforcer.coros.Add(MelonCoroutines.Start(TryStartGathering())); } } public static IEnumerator TryStartGathering() { if (areGoonsGathering || CartelEnforcer.isSaving || NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count < 3) { yield break; } hoursUntilNextGathering = Mathf.Clamp(hoursUntilNextGathering - 1, 0, int.MaxValue); if (hoursUntilNextGathering > 0) { yield break; } if (DealerActivity.currentDealerActivity >= 0f) { startEarliest = 1200; startLatest = 1800; } else { startEarliest = 1000; startLatest = 2000; } if (!NetworkSingleton.Instance.IsCurrentTimeWithinRange(startEarliest, startLatest)) { yield break; } float influenceRequirement = FrequencyOverrides.GetByID("Gathering").InfluenceRequirement; List list = new List(); List value = null; Enumerator enumerator = Singleton.Instance.GetUnlockedRegions().GetEnumerator(); while (enumerator.MoveNext()) { EMapRegion current = enumerator.Current; if (influenceRequirement >= 0f && NetworkSingleton.Instance.Influence.GetRegionData(current).Influence < influenceRequirement) { continue; } gatheringLocationsByRegion.TryGetValue((int)current, out value); if (value == null) { continue; } foreach (GatheringLocation item in value) { if (previousGatheringLocation != null && item != previousGatheringLocation && !list.Contains(item)) { list.Add(item); } else if (!list.Contains(item)) { list.Add(item); } } } if (list.Count == 0) { yield break; } int activityHours = FrequencyOverrides.GetActivityHours("Gathering"); if (activityHours != 0) { hoursUntilNextGathering = activityHours; } else if (DealerActivity.currentDealerActivity >= 0f) { hoursUntilNextGathering = Random.Range(6, 15); } else if (DealerActivity.currentDealerActivity < 0f && DealerActivity.currentDealerActivity > -0.5f) { hoursUntilNextGathering = Random.Range(5, 12); } else { hoursUntilNextGathering = Random.Range(4, 9); } GatheringLocation location = list[Random.Range(0, list.Count)]; currentGatheringLocation = location; previousGatheringLocation = location; areGoonsGathering = true; float num = 0.67f; Vector3 val = location.position + Vector3.forward * (num + Random.Range(-0.05f, 0.05f)); Vector3 val2 = location.position + Vector3.right * (num + Random.Range(-0.05f, 0.05f)); Vector3 val3 = location.position + Vector3.left * (num + Random.Range(-0.05f, 0.05f)); spawnedGatherGoons.Add(NetworkSingleton.Instance.GoonPool.SpawnGoon(val)); spawnedGatherGoons.Add(NetworkSingleton.Instance.GoonPool.SpawnGoon(val2)); spawnedGatherGoons.Add(NetworkSingleton.Instance.GoonPool.SpawnGoon(val3)); combatStartedAction = UnityAction.op_Implicit((Action)CombatStarted); for (int i = 0; i < spawnedGatherGoons.Count; i++) { ((Component)((NPC)spawnedGatherGoons[i]).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)spawnedGatherGoons[i]).Behaviour.ScheduleManager.DisableSchedule(); ((NPC)spawnedGatherGoons[i]).Movement.FacePoint(location.position, 0.5f); ((Behaviour)((NPC)spawnedGatherGoons[i]).Behaviour.CombatBehaviour).onBegin.AddListener(combatStartedAction); if (DealerActivity.currentDealerActivity < 0f) { ((NPC)spawnedGatherGoons[i]).NPCData.Health.MaxHealth = Mathf.Lerp(100f, 250f, 0f - DealerActivity.currentDealerActivity); ((NPC)spawnedGatherGoons[i]).Health.Health = Mathf.Lerp(100f, 250f, 0f - DealerActivity.currentDealerActivity); } } List fromPool = CartelInventory.GetFromPool(3); lootGoblinIndex = -1; if (fromPool.Count > 0) { lootGoblinIndex = Random.Range(0, spawnedGatherGoons.Count); ((NPC)spawnedGatherGoons[lootGoblinIndex]).Inventory.Clear(); foreach (ItemInstance item2 in fromPool) { if (((NPC)spawnedGatherGoons[lootGoblinIndex]).Inventory.CanItemFit(item2)) { ((NPC)spawnedGatherGoons[lootGoblinIndex]).Inventory.InsertItem(item2, true); } } } if (CartelInventory.cartelCashAmount > 2500f) { foreach (CartelGoon spawnedGatherGoon in spawnedGatherGoons) { CashInstance cashInstance = NetworkSingleton.Instance.GetCashInstance(500f); if (((NPC)spawnedGatherGoon).Inventory.CanItemFit((ItemInstance)(object)cashInstance)) { ((NPC)spawnedGatherGoon).Inventory.InsertItem((ItemInstance)(object)cashInstance, true); CartelInventory.cartelCashAmount -= 500f; } } } DrinkItem drinkAct; if (Random.Range(0f, 1f) > 0.2f) { drinkAct = ((Component)((Component)spawnedGatherGoons[0]).transform.Find("Aux/Drink")).GetComponent(); drinkAct.Begin(); endDrinkAction = UnityAction.op_Implicit((Action)CombatStartedEndAct); ((Behaviour)((NPC)spawnedGatherGoons[0]).Behaviour.CombatBehaviour).onBegin.AddListener(endDrinkAction); } SmokeCigarette smokeAct; if (Random.Range(0f, 1f) > 0.2f) { smokeAct = ((Component)((Component)spawnedGatherGoons[1]).transform.Find("Aux/SmokeCigarette")).GetComponent(); smokeAct.Begin(); endSmokeAction = UnityAction.op_Implicit((Action)CombatStartedEndAct2); ((Behaviour)((NPC)spawnedGatherGoons[1]).Behaviour.CombatBehaviour).onBegin.AddListener(endSmokeAction); } CartelEnforcer.coros.Add(MelonCoroutines.Start(EvaluateCurrentGathering(location))); void CombatStarted() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!startedCombat) { startedCombat = true; float num2 = default(float); Player closestPlayer = PlayerManager.GetClosestPlayer(location.position, ref num2, (List)null); foreach (CartelGoon spawnedGatherGoon2 in spawnedGatherGoons) { if ((Delegate)(object)combatStartedAction != (Delegate)null) { ((Behaviour)((NPC)spawnedGatherGoon2).Behaviour.CombatBehaviour).onBegin.RemoveListener(combatStartedAction); } ((NPC)spawnedGatherGoon2).Behaviour.CombatBehaviour.SetDefaultWeapon(AmbushOverrides.RangedWeapons[Random.Range(0, AmbushOverrides.RangedWeapons.Length)]); spawnedGatherGoon2.AttackEntity(((Component)closestPlayer).GetComponent(), true); } combatStartedAction = null; } } void CombatStartedEndAct() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) drinkAct.End(); float num2 = default(float); Player closestPlayer = PlayerManager.GetClosestPlayer(location.position, ref num2, (List)null); spawnedGatherGoons[0].AttackEntity(((Component)closestPlayer).GetComponent(), true); if ((Delegate)(object)endDrinkAction != (Delegate)null) { ((Behaviour)((NPC)spawnedGatherGoons[0]).Behaviour.CombatBehaviour).onBegin.RemoveListener(endDrinkAction); endDrinkAction = null; } } void CombatStartedEndAct2() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) smokeAct.End(); float num2 = default(float); Player closestPlayer = PlayerManager.GetClosestPlayer(location.position, ref num2, (List)null); spawnedGatherGoons[1].AttackEntity(((Component)closestPlayer).GetComponent(), true); if ((Delegate)(object)endSmokeAction != (Delegate)null) { ((Behaviour)((NPC)spawnedGatherGoons[1]).Behaviour.CombatBehaviour).onBegin.RemoveListener(endSmokeAction); endSmokeAction = null; } } } public static IEnumerator EvaluateCurrentGathering(GatheringLocation location) { yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { yield break; } int elapsed = 0; int dead = 0; int annoyance = 0; int deltaSecondsForAnnoyance = 0; int deltaSecondsDecrAnnoyance = 0; bool truceRewarded = false; List controllers = new List(); if ((int)NetworkSingleton.Instance.Status == 1) { foreach (CartelGoon spawnedGatherGoon in spawnedGatherGoons) { DialogueController component = ((Component)((NPC)spawnedGatherGoon).DialogueHandler).gameObject.GetComponent(); if (!((Object)(object)component == (Object)null) && !controllers.Contains(component)) { controllers.Add(component); } } } float num3 = default(float); while (true) { if (CartelEnforcer.registered) { dead = 0; foreach (CartelGoon spawnedGatherGoon2 in spawnedGatherGoons) { if (((NPC)spawnedGatherGoon2).Health.IsDead || ((NPC)spawnedGatherGoon2).Health.IsKnockedOut) { dead++; } } if (elapsed <= 180 && dead != 3 && NetworkSingleton.Instance.CurrentTime >= startEarliest) { if (!startedCombat) { float num = Vector3.Distance(Player.Local.CenterPointTransform.position, location.position); bool flag = false; if ((Object)(object)Player.Local.CurrentProperty != (Object)null) { flag = true; } if (DealerActivity.currentDealerActivity < 0f) { float num2 = Mathf.Lerp(8f, 18f, 0f - DealerActivity.currentDealerActivity); if (num < num2 && !flag) { Player p = PlayerManager.GetClosestPlayer(location.position, ref num3, (List)null); int randomIndex = Random.Range(0, spawnedGatherGoons.Count); ((NPC)spawnedGatherGoons[randomIndex]).Movement.FacePoint(p.CenterPointTransform.position, 0.5f); yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { break; } if (startedCombat) { continue; } if (((NPC)spawnedGatherGoons[randomIndex]).Awareness.VisionCone.IsPlayerVisible(p) || DealerActivity.currentDealerActivity < -0.75f) { spawnedGatherGoons[randomIndex].AttackEntity(((Component)p).GetComponent(), true); } else { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { break; } if (startedCombat) { continue; } ((NPC)spawnedGatherGoons[randomIndex]).Movement.FacePoint(location.position, 0.5f); } } } else { float num4 = Mathf.Lerp(9f, 5f, DealerActivity.currentDealerActivity); float num5 = Mathf.RoundToInt(Mathf.Lerp(3f, 6f, DealerActivity.currentDealerActivity)); if (num < num4 && !flag && (int)NetworkSingleton.Instance.Status != 1) { deltaSecondsForAnnoyance += 2; if (deltaSecondsForAnnoyance >= 4) { annoyance++; deltaSecondsForAnnoyance = 0; } if (annoyance == 1) { Player closestPlayer = PlayerManager.GetClosestPlayer(location.position, ref num3, (List)null); int index = Random.Range(0, spawnedGatherGoons.Count); ((NPC)spawnedGatherGoons[index]).Movement.FacePoint(closestPlayer.CenterPointTransform.position, 1.4f); ((NPC)spawnedGatherGoons[index]).PlayVO((EVOLineType)9, true); } else if (annoyance > 1) { Player closestPlayer2 = PlayerManager.GetClosestPlayer(location.position, ref num3, (List)null); int index2 = Random.Range(0, spawnedGatherGoons.Count); ((NPC)spawnedGatherGoons[index2]).Movement.FacePoint(closestPlayer2.CenterPointTransform.position, 1.4f); ((NPC)spawnedGatherGoons[index2]).PlayVO((EVOLineType)10, true); ((NPC)spawnedGatherGoons[index2]).Avatar.EmotionManager.AddEmotionOverride("Annoyed", "product_rejected", 6f, 1); if ((float)annoyance >= num5) { spawnedGatherGoons[index2].AttackEntity(((Component)closestPlayer2).GetComponent(), true); } } } else { if ((int)NetworkSingleton.Instance.Status != 1) { deltaSecondsDecrAnnoyance += 2; if (deltaSecondsDecrAnnoyance >= 8) { annoyance = Mathf.Clamp(annoyance - 1, 0, 8); deltaSecondsDecrAnnoyance = 0; } } else if (CartelEnforcer.currentConfig.alliedExtensions && !truceRewarded && location.region != 0) { float num6 = GetSumOfLastGreet(); if (num6 > 0f && num6 <= 7f) { truceRewarded = true; NetworkSingleton.Instance.Influence.ChangeInfluence((EMapRegion)location.region, CartelEnforcer.influenceConfig.trucedGreetingChallenge); if ((Object)(object)EndGameQuest.activeTruceIntro != (Object)null && (int)((Quest)EndGameQuest.activeTruceIntro).State == 1 && (int)EndGameQuest.activeTruceIntro.QuestEntry_GreetGoons.State == 1) { EndGameQuest.activeTruceIntro.QuestEntry_GreetGoons.SetState((EQuestState)2, false); } } } int num7 = Random.Range(0, spawnedGatherGoons.Count); if (num < 40f) { if (Random.Range(0f, 1f) > 0.8f) { int randomIndex = (num7 + 1) % spawnedGatherGoons.Count; if (startedCombat) { continue; } ((NPC)spawnedGatherGoons[num7]).Movement.FacePoint(((NPC)spawnedGatherGoons[randomIndex]).CenterPoint, 0.5f); switch (Random.Range(0, 4)) { case 0: ((NPC)spawnedGatherGoons[num7]).PlayVO((EVOLineType)14, true); break; case 1: ((NPC)spawnedGatherGoons[num7]).PlayVO((EVOLineType)17, true); break; case 2: ((NPC)spawnedGatherGoons[num7]).PlayVO((EVOLineType)19, true); break; case 3: ((NPC)spawnedGatherGoons[num7]).PlayVO((EVOLineType)6, true); break; } yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { break; } elapsed += 2; if (startedCombat) { continue; } switch (Random.Range(0, 3)) { case 0: ((NPC)spawnedGatherGoons[randomIndex]).PlayVO((EVOLineType)3, true); break; case 1: ((NPC)spawnedGatherGoons[randomIndex]).PlayVO((EVOLineType)11, true); break; case 2: ((NPC)spawnedGatherGoons[randomIndex]).PlayVO((EVOLineType)2, true); break; } } else { ((NPC)spawnedGatherGoons[num7]).Movement.FacePoint(location.position, 0.5f); } } else { ((NPC)spawnedGatherGoons[num7]).Movement.FacePoint(location.position, 0.5f); } } } } yield return CartelEnforcer.Wait2; if (CartelEnforcer.registered) { elapsed += 2; continue; } break; } } foreach (CartelGoon goon in spawnedGatherGoons) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { ((Component)((NPC)goon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); ((NPC)goon).Behaviour.ScheduleManager.EnableSchedule(); continue; } yield break; } bool defeated = dead == 3 && elapsed < 180; CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGatherEvent(defeated, location))); yield return null; break; } float GetSumOfLastGreet() { if (controllers.Count == 0) { return 0f; } float num8 = 0f; foreach (DialogueController item in controllers) { num8 += Time.time - item.lastGreetingTime; } return num8; } } public static IEnumerator EndGatherEvent(bool defeated, GatheringLocation location) { EMapRegion val = (EMapRegion)location.region; if (defeated) { if (InfluenceOverrides.ShouldChangeInfluence(val)) { NetworkSingleton.Instance.Influence.ChangeInfluence(val, CartelEnforcer.influenceConfig.gatheringSuccess); } if ((Object)(object)EndGameQuest.activeDefeatEnforcerQuest != (Object)null && (int)((Quest)EndGameQuest.activeDefeatEnforcerQuest).State == 1 && (Object)(object)EndGameQuest.activeDefeatEnforcerQuest.QuestEntry_Investigate != (Object)null && (int)EndGameQuest.activeDefeatEnforcerQuest.QuestEntry_Investigate.State == 1 && EndGameQuest.StageGatheringsDefeated == 0) { EndGameQuest.StageGatheringsDefeated++; } } else if ((int)val != 0 && NetworkSingleton.Instance.Influence.GetRegionData(val).Influence < 0.4f && InfluenceOverrides.ShouldChangeInfluence(val)) { NetworkSingleton.Instance.Influence.ChangeInfluence(val, CartelEnforcer.influenceConfig.gatheringFail); } yield return CartelEnforcer.Wait30; if (!CartelEnforcer.registered) { yield break; } foreach (CartelGoon goon in spawnedGatherGoons) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { ((NPC)goon).NPCData.Health.MaxHealth = 100f; if (goon.IsGoonSpawned) { goon.Despawn(); } continue; } yield break; } if ((Delegate)(object)combatStartedAction != (Delegate)null) { foreach (CartelGoon spawnedGatherGoon in spawnedGatherGoons) { ((Behaviour)((NPC)spawnedGatherGoon).Behaviour.CombatBehaviour).onBegin.RemoveListener(combatStartedAction); } combatStartedAction = null; } if ((Delegate)(object)endDrinkAction != (Delegate)null) { ((Behaviour)((NPC)spawnedGatherGoons[0]).Behaviour.CombatBehaviour).onBegin.RemoveListener(endDrinkAction); endDrinkAction = null; } if ((Delegate)(object)endSmokeAction != (Delegate)null) { ((Behaviour)((NPC)spawnedGatherGoons[1]).Behaviour.CombatBehaviour).onBegin.RemoveListener(endSmokeAction); endSmokeAction = null; } if (!defeated) { if (lootGoblinIndex != -1) { List list = new List(); Enumerator enumerator3 = ((NPC)spawnedGatherGoons[lootGoblinIndex]).Inventory.ItemSlots.GetEnumerator(); while (enumerator3.MoveNext()) { ItemSlot current = enumerator3.Current; if (current.ItemInstance == null) { continue; } if ((int)((BaseItemInstance)current.ItemInstance).Category == 6) { if ((float)((BaseItemInstance)current.ItemInstance).Quantity >= 500f) { CartelInventory.cartelCashAmount += 500f; } current.ClearItemInstanceRequested(); } else { list.Add(current.ItemInstance); } } CartelInventory.CartelStealsItems(list); ((NPC)spawnedGatherGoons[lootGoblinIndex]).Inventory.Clear(); spawnedGatherGoons.RemoveAt(lootGoblinIndex); } foreach (CartelGoon spawnedGatherGoon2 in spawnedGatherGoons) { Enumerator enumerator3 = ((NPC)spawnedGatherGoon2).Inventory.ItemSlots.GetEnumerator(); while (enumerator3.MoveNext()) { ItemSlot current2 = enumerator3.Current; if (current2.ItemInstance != null && (int)((BaseItemInstance)current2.ItemInstance).Category == 6) { if ((float)((BaseItemInstance)current2.ItemInstance).Quantity >= 500f) { CartelInventory.cartelCashAmount += 500f; } current2.ClearItemInstanceRequested(); } } } } startedCombat = false; areGoonsGathering = false; spawnedGatherGoons.Clear(); currentGatheringLocation = null; endSmokeAction = null; endDrinkAction = null; combatStartedAction = null; lootGoblinIndex = -1; } } public class GatheringLocation { public Vector3 position; public int region; public string description; public GatheringLocation(Vector3 pos, int region, string desc) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) position = pos; this.region = region; description = desc; } } public static class InterceptEvent { public class InterceptContractState { public bool CompletedByPlayer { get; set; } public bool CompletedByCartel { get; set; } public InterceptContractState() { CompletedByPlayer = false; CompletedByCartel = false; } } public static Color questIconBack; public static Sprite handshake; public static Sprite benziesLogo; private static CartelDealer[] allCartelDealers; public static Dictionary contractGuids = new Dictionary(); public static bool interceptingDeal = false; public static CartelDealer interceptor = null; public static int hoursUntilInterceptEvent = 4; public static void HourPassInterceptCooldown() { if (CartelEnforcer.registered && CartelEnforcer.currentConfig.interceptDeals && !CartelEnforcer.isSaving) { hoursUntilInterceptEvent = Mathf.Clamp(hoursUntilInterceptEvent - 1, 0, int.MaxValue); } } public static IEnumerator EvaluateCartelIntercepts() { yield return CartelEnforcer.Wait5; allCartelDealers = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType(true)); while (CartelEnforcer.registered) { yield return CartelEnforcer.Wait60; if (!CartelEnforcer.registered) { break; } if (CartelEnforcer.currentConfig.interceptDeals && hoursUntilInterceptEvent <= 0 && (NetworkSingleton.Instance.CurrentTime >= 1620 || NetworkSingleton.Instance.CurrentTime <= 420) && (int)NetworkSingleton.Instance.Status == 2 && !interceptingDeal) { int activityHours = FrequencyOverrides.GetActivityHours("InterceptDeals"); if (activityHours != 0) { hoursUntilInterceptEvent = activityHours; } else { hoursUntilInterceptEvent = Random.Range(2, 8); } CartelEnforcer.coros.Add(MelonCoroutines.Start(StartInterceptDeal())); } } } public static IEnumerator StartInterceptDeal() { List list = new List(); int num = 0; float influenceRequirement = FrequencyOverrides.GetByID("InterceptDeals").InfluenceRequirement; CartelDealer[] array = allCartelDealers; foreach (CartelDealer obj in array) { bool flag = false; Enumerator enumerator = ((Dealer)obj).ActiveContracts.GetEnumerator(); while (enumerator.MoveNext()) { Contract current = enumerator.Current; flag = true; if (!list.Contains(((object)((Quest)current).GUID/*cast due to .constrained prefix*/).ToString())) { list.Add(((object)((Quest)current).GUID/*cast due to .constrained prefix*/).ToString()); } } if (flag) { num++; } } if (allCartelDealers.Length == num) { yield break; } List validContracts = new List(); for (int num2 = Contract.Contracts.Count - 1; num2 >= 0; num2--) { Contract val = Contract.Contracts[num2]; if ((Object)(object)val != (Object)null && !((Object)(object)val.Dealer != (Object)null) && !((Object)(object)val.Customer == (Object)null) && (int)((Quest)val).State == 1 && ((Quest)val).hudUIExists && !((Object)(object)((Quest)val).hudUI == (Object)null) && !((Object)(object)((Component)((Quest)val).hudUI).gameObject == (Object)null) && ((Component)((Quest)val).hudUI).gameObject.activeSelf && !list.Contains(((object)((Quest)val).GUID/*cast due to .constrained prefix*/).ToString()) && ((Quest)val).GetMinsUntilExpiry() <= 300 && ((Quest)val).GetMinsUntilExpiry() >= 90 && !contractGuids.Keys.Contains(((object)((Quest)val).GUID/*cast due to .constrained prefix*/).ToString()) && !validContracts.Contains(val)) { validContracts.Add(val); } } if (validContracts.Count == 0) { yield break; } Customer customer = null; Contract randomContract = null; float num3 = default(float); do { yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { yield break; } if (validContracts.Count == 0) { break; } int index = Random.Range(0, validContracts.Count); randomContract = validContracts[index]; if ((Object)(object)randomContract == (Object)null || ((Object)(object)randomContract != (Object)null && (int)((Quest)randomContract).State == 2)) { validContracts.RemoveAt(index); randomContract = null; continue; } customer = ((Component)randomContract.Customer).GetComponent(); if (customer.NPC.Health.IsDead || customer.NPC.Health.IsKnockedOut) { validContracts.RemoveAt(index); randomContract = null; continue; } if (!((Object)(object)PlayerManager.GetClosestPlayer(customer.NPC.CenterPoint, ref num3, (List)null) != (Object)null) || !(num3 < 40f)) { break; } validContracts.RemoveAt(index); randomContract = null; } while (CartelEnforcer.registered && validContracts.Count != 0); if ((Object)(object)customer == (Object)null || (Object)(object)randomContract == (Object)null) { yield break; } EMapRegion region = Singleton.Instance.GetRegionFromPosition(customer.NPC.CenterPoint); if (influenceRequirement >= 0f && NetworkSingleton.Instance.Influence.GetRegionData(region).Influence < influenceRequirement) { yield break; } CartelDealer selected = (((int)region != 0) ? NetworkSingleton.Instance.Activities.GetRegionalActivities(region).CartelDealer : NetworkSingleton.Instance.Activities.GetRegionalActivities((EMapRegion)1).CartelDealer); if ((((Dealer)selected).ActiveContracts != null && ((Dealer)selected).ActiveContracts.Count >= 1) || ((NPC)selected).Health.IsDead || ((NPC)selected).Health.IsKnockedOut) { bool foundReplacement = false; CartelDealer[] array2 = allCartelDealers; foreach (CartelDealer otherDealer in array2) { yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { yield break; } if (!((Object)(object)otherDealer == (Object)(object)selected) && !((NPC)otherDealer).Health.IsDead && !((NPC)otherDealer).Health.IsKnockedOut && (((Dealer)otherDealer).ActiveContracts == null || ((Dealer)otherDealer).ActiveContracts.Count < 1) && Vector3.Distance(((NPC)otherDealer).CenterPoint, customer.NPC.CenterPoint) < 80f) { foundReplacement = true; selected = otherDealer; break; } } if (!foundReplacement) { yield break; } } string text = ((object)((Quest)randomContract).GUID/*cast due to .constrained prefix*/).ToString(); if (!Enumerable.Contains(contractGuids.Keys, text)) { contractGuids.Add(text, new InterceptContractState()); } string text2 = ""; switch (Random.Range(0, 7)) { case 0: text2 = "What's taking so long? I will just find another dealer..."; break; case 1: text2 = "Nevermind! I made a deal with someone else."; break; case 2: text2 = "Are you coming or not? I might just buy from someone else."; break; case 3: text2 = "Yo where are you?! I've been waiting at our spot. I'll message another dealer then..."; break; case 4: text2 = "This isn't working out. I'm taking my business elsewhere."; break; case 5: text2 = "I'm not waiting around all day. Don't bother texting me back."; break; case 6: text2 = "You snooze, you lose. Found another dealer to sell me my shit."; break; case 7: text2 = "I'll hustle with someone else if you ghost me like this..."; break; } customer.NPC.RelationData.ChangeRelationship(-0.15f, true); customer.NPC.MSGConversation.SendMessage(new Message(text2, (ESenderType)1, true, -1), true, true); interceptingDeal = true; interceptor = selected; CartelEnforcer.coros.Add(MelonCoroutines.Start(QuestUIEffect(randomContract))); CartelEnforcer.coros.Add(MelonCoroutines.Start(BeginIntercept(selected, randomContract, customer, region, text))); yield return null; } public static IEnumerator BeginIntercept(CartelDealer dealer, Contract contract, Customer customer, EMapRegion region, string cGuid) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) yield return CartelEnforcer.Wait30; if (!CartelEnforcer.registered) { yield break; } bool changeInfluence = InfluenceOverrides.ShouldChangeInfluence(region); if ((Object)(object)customer.CurrentContract == (Object)null && (Object)(object)contract != (Object)null && (int)((Quest)contract).State == 2) { if (changeInfluence) { NetworkSingleton.Instance.Influence.ChangeInfluence(region, CartelEnforcer.influenceConfig.interceptSuccess); } if (Enumerable.Contains(contractGuids.Keys, cGuid)) { contractGuids.Remove(cGuid); } interceptingDeal = false; interceptor = null; yield break; } int originalXP = ((Quest)contract).CompletionXP; ((Quest)contract).CompletionXP = 0; ((Quest)contract).BopHUDUI(); CartelInventory.FulfillContractItems(contract, dealer); for (int i = 0; i < ((NPC)dealer).Inventory.ItemSlots.Count; i++) { if (((NPC)dealer).Inventory.ItemSlots[i].ItemInstance == null) { List fromPool = CartelInventory.GetFromPool(1); if (fromPool != null && fromPool.Count > 0) { ItemInstance val = fromPool[0]; ((NPC)dealer).Inventory.ItemSlots[i].SetStoredItem(val, false); } break; } } int currentStayInsideStart = ((NPCAction)((Dealer)dealer).HomeEvent).StartTime; int currentStayInsideEnd = ((NPCEvent)((Dealer)dealer).HomeEvent).EndTime; int currentStayInsideDur = ((NPCEvent)((Dealer)dealer).HomeEvent).Duration; bool runOnce = false; Action cb = null; cb = OnQuestEndEvaluateResult; ((Quest)contract).onQuestEnd.AddListener(UnityAction.op_Implicit(cb)); if (!dealer.IsAcceptingDeals) { dealer.SetIsAcceptingDeals(true); } ((Dealer)dealer).AddContract(contract); dealer.SetIsAcceptingDeals(false); ((NPCAction)((Dealer)dealer).HomeEvent).StartTime = 420; ((NPCEvent)((Dealer)dealer).HomeEvent).EndTime = 1620; ((NPCEvent)((Dealer)dealer).HomeEvent).Duration = 720; ((NPCAction)((Dealer)dealer).HomeEvent).End(); ((NPCAction)((Dealer)dealer).HomeEvent).HasStarted = false; ((Behaviour)((Dealer)dealer).HomeEvent).enabled = false; ((Dealer)dealer).CheckAttendStart(); if ((Object)(object)customer.CurrentContract != (Object)null && (Object)(object)customer.CurrentContract.Dealer != (Object)null) { customer.CurrentContract.Dealer = null; } yield return null; void OnQuestEndEvaluateResult(EQuestState state) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Invalid comparison between Unknown and I4 //IL_015f: Unknown result type (might be due to invalid IL or missing references) if (!runOnce) { runOnce = true; if (contractGuids.ContainsKey(cGuid)) { if (cb != null) { ((Quest)contract).onQuestEnd.RemoveListener(UnityAction.op_Implicit(cb)); } if ((int)state == 3 && (((NPC)dealer).Health.IsDead || ((NPC)dealer).Health.IsKnockedOut)) { CartelEnforcer.coros.Add(MelonCoroutines.Start(AssignContractSoon(customer, contract, originalXP))); if (Enumerable.Contains(contractGuids.Keys, cGuid)) { contractGuids.Remove(cGuid); } ((Behaviour)((Dealer)dealer).HomeEvent).enabled = true; ((NPCAction)((Dealer)dealer).HomeEvent).StartTime = currentStayInsideStart; ((NPCEvent)((Dealer)dealer).HomeEvent).EndTime = currentStayInsideEnd; ((NPCEvent)((Dealer)dealer).HomeEvent).Duration = currentStayInsideDur; ((NPCAction)((Dealer)dealer).HomeEvent).HasStarted = true; ((NPCAction)((Dealer)dealer).HomeEvent).Resume(); interceptingDeal = false; interceptor = null; } else if ((int)state == 2) { CartelEnforcer.coros.Add(MelonCoroutines.Start(WaitForContractState(dealer, contract, customer, region, cGuid, changeInfluence, originalXP))); } else { if (Enumerable.Contains(contractGuids.Keys, cGuid)) { contractGuids.Remove(cGuid); } ((Behaviour)((Dealer)dealer).HomeEvent).enabled = true; ((NPCAction)((Dealer)dealer).HomeEvent).StartTime = currentStayInsideStart; ((NPCEvent)((Dealer)dealer).HomeEvent).EndTime = currentStayInsideEnd; ((NPCEvent)((Dealer)dealer).HomeEvent).Duration = currentStayInsideDur; ((NPCAction)((Dealer)dealer).HomeEvent).HasStarted = true; ((NPCAction)((Dealer)dealer).HomeEvent).Resume(); interceptingDeal = false; interceptor = null; } } } } } public static IEnumerator WaitForContractState(CartelDealer dealer, Contract contract, Customer customer, EMapRegion region, string cGuid, bool changeInfluence, int originalXP) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) yield return (object)new WaitUntil(Func.op_Implicit((Func)(() => contractGuids[cGuid].CompletedByPlayer || contractGuids[cGuid].CompletedByCartel || !CartelEnforcer.registered))); if (!CartelEnforcer.registered) { yield break; } if (contractGuids[cGuid].CompletedByPlayer) { NetworkSingleton.Instance.AddXP(originalXP); if (changeInfluence) { NetworkSingleton.Instance.Influence.ChangeInfluence(region, CartelEnforcer.influenceConfig.interceptSuccess); } customer.NPC.RelationData.ChangeRelationship(0.15f, true); } else if (contractGuids[cGuid].CompletedByCartel) { if (changeInfluence) { NetworkSingleton.Instance.Influence.ChangeInfluence(region, CartelEnforcer.influenceConfig.interceptFail); } customer.NPC.RelationData.ChangeRelationship(-0.6f, true); } contractGuids.Remove(cGuid); ((Behaviour)((Dealer)dealer).HomeEvent).enabled = true; ((NPCAction)((Dealer)dealer).HomeEvent).StartTime = DealerActivity.currentStayInsideStart; ((NPCEvent)((Dealer)dealer).HomeEvent).EndTime = DealerActivity.currentStayInsideEnd; ((NPCEvent)((Dealer)dealer).HomeEvent).Duration = DealerActivity.currentStayInsideDur; ((NPCAction)((Dealer)dealer).HomeEvent).HasStarted = true; ((NPCAction)((Dealer)dealer).HomeEvent).Resume(); interceptingDeal = false; interceptor = null; } public static IEnumerator AssignContractSoon(Customer customer, Contract contract, int XP) { yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { yield break; } if ((int)((Quest)contract).State != 1) { ((Quest)contract).SetQuestState((EQuestState)1, true); } customer.AssignContract(contract); ((Quest)customer.CurrentContract).CompletionXP = XP; customer.CurrentContract.DeliveryWindow.WindowStartTime = NetworkSingleton.Instance.CurrentTime; customer._attendDealBehaviour.SetContract(contract); ((Behaviour)customer._attendDealBehaviour).Activate(); customer.UpdateDealAttendance(); customer.SetIsAwaitingDelivery(true); ((Quest)contract).SetIsTracked(true); if (!((Object)(object)((Quest)customer.CurrentContract).hudUI == (Object)null)) { QuestHUDUI hudUI = ((Quest)customer.CurrentContract).hudUI; if (!((Object)(object)((hudUI != null) ? ((Component)hudUI).gameObject : null) == (Object)null)) { goto IL_0145; } } ((Quest)customer.CurrentContract).SetupHUDUI(); goto IL_0145; IL_0145: if (!Contract.Contracts.Contains(contract)) { Contract.Contracts.Add(contract); } if ((Object)(object)contract.DeliveryLocation != (Object)null && !contract.DeliveryLocation.ScheduledContracts.Contains(contract)) { contract.DeliveryLocation.ScheduledContracts.Add(contract); } yield return CartelEnforcer.Wait05; yield return CartelEnforcer.Wait01; if (CartelEnforcer.registered) { if (!((Component)((Quest)customer.CurrentContract).hudUI).gameObject.activeSelf) { ((Component)((Quest)customer.CurrentContract).hudUI).gameObject.SetActive(true); } customer.HasChanged = true; ((Quest)contract).HasChanged = true; ((Quest)customer.CurrentContract).hudUI.FadeIn(); if (((Quest)contract).Entries.Count != 0) { ((Quest)contract).Entries[0].CreateEntryUI(); } Action action = ((Quest)contract).OnMinPass; TimeManager instance = NetworkSingleton.Instance; instance.onMinutePass += Action.op_Implicit(action); yield return null; } } public static IEnumerator FetchUIElementsInit() { yield return CartelEnforcer.Wait5; if (CartelEnforcer.registered) { benziesLogo = ((NPC)Object.FindObjectOfType(true)).GetMessagingIcon(); yield return null; } } public static IEnumerator QuestUIEffect(Contract contract) { if ((Object)(object)((Quest)contract).hudUI == (Object)null || (Object)(object)((Quest)contract).hudUI.MainLabel == (Object)null || (Object)(object)((TMP_Text)((Quest)contract).hudUI.MainLabel).transform == (Object)null) { yield break; } Transform val = ((TMP_Text)((Quest)contract).hudUI.MainLabel).transform.Find("IconContainer"); if ((Object)(object)val == (Object)null) { yield break; } Transform val2 = val.Find("ContractIcon(Clone)"); if ((Object)(object)val2 == (Object)null) { yield break; } Transform val3 = val2.Find("Background"); if (!((Object)(object)val3 == (Object)null)) { Image component = ((Component)val3).GetComponent(); questIconBack = ((Graphic)component).color; CartelEnforcer.coros.Add(MelonCoroutines.Start(LerpQuestColor(component))); Transform val4 = val2.Find("Fill"); if (!((Object)(object)val4 == (Object)null)) { Image component2 = ((Component)val4).GetComponent(); handshake = component2.sprite; ((Quest)contract).hudUI.BopIcon(); component2.overrideSprite = benziesLogo; CartelEnforcer.coros.Add(MelonCoroutines.Start(ResetQuestUIEffect(component2, component))); yield return null; } } } public static IEnumerator ResetQuestUIEffect(Image fillImg, Image background) { while (interceptingDeal && CartelEnforcer.registered) { yield return CartelEnforcer.Wait5; } if ((Object)(object)background != (Object)null) { ((Graphic)background).color = questIconBack; } if (Object.op_Implicit((Object)(object)fillImg)) { fillImg.overrideSprite = handshake; } yield return null; } public static IEnumerator LerpQuestColor(Image background) { Color startColor = ((Graphic)background).color; Color endColor = Color.white; float duration = 2f; float timer = 0f; while (timer < duration && CartelEnforcer.registered) { float num = timer / duration; ((Graphic)background).color = Color.Lerp(startColor, endColor, num); timer += Time.deltaTime; yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { yield break; } } yield return null; } } [Serializable] public class SerializeStolenItems { public string ID; public int Quality; public int Quantity; } [Serializable] public class StolenItemsList { public float balance; public List items; } public static class CartelInventory { public static List cartelStolenItems = new List(); public static float cartelCashAmount = 0f; public static readonly object cartelItemLock = new object(); public static PackagingDefinition jarPackaging = null; public static PackagingDefinition brickPackaging = null; public static readonly int brickQuantity = 20; public static readonly int jarQuantity = 5; public static void PreparePackagingRefs() { PrefabObjects spawnablePrefabs = Object.FindObjectOfType(true).SpawnablePrefabs; NetworkObject val = null; for (int i = 0; i < spawnablePrefabs.GetObjectCount(); i++) { NetworkObject val2 = spawnablePrefabs.GetObject(true, i); object obj; if (val2 == null) { obj = null; } else { GameObject gameObject = ((Component)val2).gameObject; obj = ((gameObject != null) ? ((Object)gameObject).name : null); } if ((string?)obj == "BrickPress") { val = val2; } } BrickPress component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.BrickPackaging != (Object)null) { brickPackaging = component.BrickPackaging; } ItemDefinition val3 = new Func(Registry.GetItem)("jar"); if (!((Object)(object)val3 == (Object)null)) { PackagingDefinition val4 = ((Il2CppObjectBase)val3).TryCast(); if ((Object)(object)val4 != (Object)null) { jarPackaging = val4; } } } public static IEnumerator CartelStealsItems(List items, Action cb = null) { lock (cartelItemLock) { for (int i = 0; i < items.Count; i++) { int num = 1; QualityItemInstance val = ((Il2CppObjectBase)items[i]).TryCast(); if (val == null) { continue; } int num2 = -1; if (cartelStolenItems.Count > 0) { for (int j = 0; j < cartelStolenItems.Count; j++) { if (((BaseItemInstance)cartelStolenItems[j]).ID == ((BaseItemInstance)val).ID && cartelStolenItems[j].Quality == val.Quality) { num2 = j; break; } } } ProductItemInstance val2 = ((Il2CppObjectBase)items[i]).TryCast(); if (val2 != null && val2.PackagingID != null) { string packagingID = val2.PackagingID; num = ((packagingID == "jar") ? jarQuantity : ((!(packagingID == "brick")) ? 1 : brickQuantity)); } if (num2 >= 0) { QualityItemInstance obj = cartelStolenItems[num2]; ((BaseItemInstance)obj).Quantity = ((BaseItemInstance)obj).Quantity + ((BaseItemInstance)val).Quantity * num; } else { ((BaseItemInstance)val).Quantity = ((BaseItemInstance)val).Quantity * num; cartelStolenItems.Add(val); } } } cb?.Invoke(); yield return null; } public static List GetFromPool(int maxEmptySlotsToFill) { //IL_01f6: Unknown result type (might be due to invalid IL or missing references) List list = new List(); lock (cartelItemLock) { int num = Mathf.Min(maxEmptySlotsToFill, cartelStolenItems.Count); for (int i = 0; i < num; i++) { if (cartelStolenItems.Count == 0) { break; } int index = Random.Range(0, cartelStolenItems.Count); ItemDefinition item = Registry.GetItem(((BaseItemInstance)cartelStolenItems[index]).ID); int num2 = Mathf.Min(Mathf.FloorToInt((float)(((BaseItemInstance)cartelStolenItems[index]).Quantity / brickQuantity)), 20); int num3 = Mathf.Min(Mathf.FloorToInt((float)(((BaseItemInstance)cartelStolenItems[index]).Quantity / jarQuantity)), 20); ItemInstance val = null; PackagingDefinition val2 = null; int num4; if (num2 > 5) { num4 = brickQuantity * num2; float num5 = num4 / ((BaseItemInstance)cartelStolenItems[index]).Quantity; int num6 = Mathf.RoundToInt(Mathf.Lerp((float)num2, Mathf.Clamp((float)num2 / 2f, 1f, 20f), num5)); num4 = brickQuantity * num6; val = item.GetDefaultInstance(num6); val2 = brickPackaging; } else if (num3 > 1) { num4 = jarQuantity * num3; float num7 = num4 / ((BaseItemInstance)cartelStolenItems[index]).Quantity; int num8 = Mathf.RoundToInt(Mathf.Lerp((float)num3, Mathf.Clamp((float)num3 / 2f, 1f, 20f), num7)); num4 = jarQuantity * num8; val = item.GetDefaultInstance(num8); val2 = jarPackaging; } else { num4 = Mathf.Min(((BaseItemInstance)cartelStolenItems[index]).Quantity, 1); val = item.GetDefaultInstance(num4); } if ((Object)(object)val2 != (Object)null) { ProductItemInstance val3 = ((Il2CppObjectBase)val).TryCast(); if (val3 != null) { val3.SetPackaging(val2); } } QualityItemInstance val4 = ((Il2CppObjectBase)val).TryCast(); if (val4 != null) { val4.Quality = cartelStolenItems[index].Quality; } list.Add(val); if (num4 >= ((BaseItemInstance)cartelStolenItems[index]).Quantity) { cartelStolenItems.RemoveAt(index); continue; } QualityItemInstance obj = cartelStolenItems[index]; ((BaseItemInstance)obj).Quantity = ((BaseItemInstance)obj).Quantity - num4; } } return list; } public static List GetFromPool(string id, EQuality quality, int qty, out int returnedQty) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (cartelStolenItems.Count == 0) { returnedQty = 0; return new List(); } List list = new List(); lock (cartelItemLock) { ItemDefinition item = Registry.GetItem(id); QualityItemInstance val = cartelStolenItems.First((QualityItemInstance val6) => ((BaseItemInstance)val6).ID == id && val6.Quality >= quality); if (val == null || ((BaseItemInstance)val).Quantity <= 5) { returnedQty = 0; return list; } int index = cartelStolenItems.IndexOf(val); int num = Mathf.FloorToInt((float)((BaseItemInstance)val).Quantity / (float)jarQuantity); int num2 = Mathf.CeilToInt((float)qty / (float)jarQuantity); PackagingDefinition val2 = jarPackaging; int num3 = 0; int num4 = 0; if (num2 > num) { returnedQty = num * jarQuantity; num4 = num; num3 = Mathf.CeilToInt((float)num / 20f); } else { returnedQty = num2 * jarQuantity; num4 = num2; num3 = Mathf.CeilToInt((float)num2 / 20f); } for (int num5 = 0; num5 < num3; num5++) { ItemInstance val3 = null; if (num4 > 20) { val3 = item.GetDefaultInstance(20); num4 -= 20; } else { val3 = item.GetDefaultInstance(num4); } if ((Object)(object)val2 != (Object)null) { ProductItemInstance val4 = ((Il2CppObjectBase)val3).TryCast(); if (val4 != null) { val4.SetPackaging(val2); } } QualityItemInstance val5 = ((Il2CppObjectBase)val3).TryCast(); if (val5 != null) { val5.Quality = quality; } list.Add(val3); } if (returnedQty >= ((BaseItemInstance)val).Quantity) { cartelStolenItems.Remove(val); } else { QualityItemInstance obj = cartelStolenItems[index]; ((BaseItemInstance)obj).Quantity = ((BaseItemInstance)obj).Quantity - returnedQty; } } return list; } public static List MakeItem(string id, EQuality quality, int qty) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) List list = new List(); ItemDefinition item = Registry.GetItem(id); int num = Mathf.CeilToInt((float)qty / (float)jarQuantity); PackagingDefinition val = jarPackaging; int num2 = 0; int num3 = num; num2 = Mathf.CeilToInt((float)num / 20f); for (int i = 0; i < num2; i++) { ItemInstance val2 = null; if (num3 > 20) { val2 = item.GetDefaultInstance(20); num3 -= 20; } else { val2 = item.GetDefaultInstance(num3); } if ((Object)(object)val != (Object)null) { ProductItemInstance val3 = ((Il2CppObjectBase)val2).TryCast(); if (val3 != null) { val3.SetPackaging(val); } } QualityItemInstance val4 = ((Il2CppObjectBase)val2).TryCast(); if (val4 != null) { val4.Quality = quality; } list.Add(val2); } return list; } public static bool ExistsInInventory(string id, EQuality quality, out int qty) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) bool flag = false; lock (cartelItemLock) { flag = cartelStolenItems.Any((QualityItemInstance item) => ((BaseItemInstance)item).ID == id && item.Quality >= quality); if (flag) { qty = ((BaseItemInstance)cartelStolenItems.First((QualityItemInstance item) => ((BaseItemInstance)item).ID == id && item.Quality >= quality)).Quantity; } else { qty = 0; } } return flag; } public static void FulfillContractItems(Contract contract, CartelDealer dealer) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Enumerator enumerator = contract.ProductList.entries.GetEnumerator(); while (enumerator.MoveNext()) { Entry current = enumerator.Current; bool flag = false; int num = -1; if (ExistsInInventory(current.ProductID, current.Quality, out var _)) { list.AddRange(GetFromPool(current.ProductID, current.Quality, current.Quantity, out var returnedQty)); if (returnedQty < current.Quantity) { num = current.Quantity - returnedQty; } else { flag = true; } } if (!flag || num > 0) { if (num > 0) { list.AddRange(MakeItem(current.ProductID, current.Quality, num)); } else { list.AddRange(MakeItem(current.ProductID, current.Quality, current.Quantity)); } } } for (int i = 0; i < list.Count; i++) { if (list[i] != null && ((NPC)dealer).Inventory.CanItemFit(list[i])) { ((NPC)dealer).Inventory.InsertItem(list[i], true); } } } } public static class NPCInitHelper { public static IEnumerator InitiateClone(NetworkObject newNob, NetworkManager netManager, NPCData dataPreset = null) { NPC npc = ((Component)newNob).GetComponent(); ((Component)((Component)newNob).transform.Find("Avatar")).gameObject.SetActive(true); ((Component)((Component)newNob).transform.Find("Avatar/BodyContainer")).gameObject.SetActive(true); ((Behaviour)((Component)newNob).GetComponent()).enabled = true; ((Component)newNob).gameObject.SetActive(true); yield return CartelEnforcer.Wait01; yield return CartelEnforcer.frameEnd; ((Component)((Component)newNob).transform.Find("Avatar")).gameObject.SetActive(false); ((Component)((Component)newNob).transform.Find("Avatar/BodyContainer")).gameObject.SetActive(false); ((Behaviour)((Component)newNob).GetComponent()).enabled = false; if (((Component)newNob).gameObject.activeSelf) { ((Component)newNob).gameObject.SetActive(false); } Behaviour behaviour = npc.Behaviour.GetBehaviour("Customer attend deal"); if (Object.op_Implicit((Object)(object)behaviour)) { Object.Destroy((Object)(object)((Component)behaviour).gameObject); ((NetworkBehaviour)npc.Behaviour).OnValidate(); } try { byte b = 0; newNob.UpdateNetworkBehaviours(newNob, ref b); } catch (Exception) { } if (dataPreset != null) { npc.ApplyNPCData(dataPreset); } try { newNob.Preinitialize_Internal(netManager, 150, (NetworkConnection)null, true); } catch (Exception) { } try { newNob.Initialize(true, true); } catch (Exception) { } try { newNob.SetIsNetworked(false); } catch (Exception) { } CapsuleCollider component = ((Component)((Component)((Component)newNob).GetComponentInChildren().IntObj).transform.Find("Sphere")).GetComponent(); component.height = 1.85f; component.radius = 0.5f; } } [RegisterTypeInIl2Cpp] public class Quest_CarMeetup : ModQuestBase { protected CarMeetupHelper _helper; public float questDifficultyScalar = 1f; public readonly List pileBasePos = new List { new Vector3(-14.6f, -4.77f, 168.2f), new Vector3(-14.6f, -4.77f, 168.6f), new Vector3(-14.4f, -4.77f, 168.2f), new Vector3(-14.4f, -4.77f, 168.6f), new Vector3(-14.8f, -4.77f, 168.7f), new Vector3(-15.3f, -4.77f, 168.6f) }; public GameObject brickBase; public List spawnedDecor = new List(); public Dictionary spawnedGoons = new Dictionary(); public List spawnedGoonsGuids = new List(); public StorageEntity rewardStorage; public bool combatBegun; public bool playerSightedActive; public bool investigationActive; public bool hasSavedCombatVariables; public float GiveUpRange; public int GiveUpAfterSuccessfulHits; public float DefaultSearchTime; public UnityAction combatStartedAction; public UnityAction goonDiedAction; public UnityAction combatEndCrouchAction; public QuestEntry QuestEntry_TalkToJeremy; private UnityAction _talkToJeremyAction; public QuestEntry QuestEntry_StopCarMeetup; private UnityAction _stopCarMeetupAction; public QuestEntry QuestEntry_EscapeNorthWaterfront; private UnityAction _escapeAction; public Quest_CarMeetup(IntPtr ptr) : base(ptr) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) _helper = new CarMeetupHelper(this); } public Quest_CarMeetup() : base(ClassInjector.DerivedConstructorPointer()) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this); } public override void Complete(bool network = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 try { if ((int)((Quest)this).State != 2) { if (InstanceFinder.IsServer && !Singleton.Instance.IsLoading) { NetworkSingleton.Instance.AddXP(((Quest)this).CompletionXP); } ((Quest)this).SetQuestState((EQuestState)2, false); NetworkSingleton.Instance.PlayCompleteQuestSound(); ((Quest)this).End(); } } catch (Exception) { throw; } } public override void Fail(bool network = true) { try { ((Quest)this).SetQuestState((EQuestState)3, false); ((Quest)this).End(); } catch (Exception) { throw; } } public override void End() { try { if ((Object)(object)((Quest)this).hudUI != (Object)null) { ((Quest)this).hudUI.Complete(); } TimeManager instance = NetworkSingleton.Instance; if ((Object)(object)instance == (Object)null) { return; } Action action = ((Quest)this).OnMinPass; instance.onHourPass -= Action.op_Implicit((Action)HourPass); instance.onMinutePass.Remove(Action.op_Implicit(action)); investigationActive = false; playerSightedActive = false; combatBegun = false; } catch (Exception) { throw; } ((Component)this).gameObject.SetActive(false); } public void SetupSelf() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) float num = 0f; Enumerator enumerator = NetworkSingleton.Instance.Influence.regionInfluence.GetEnumerator(); while (enumerator.MoveNext()) { RegionInfluenceData current = enumerator.Current; num += current.Influence; } float num2 = num / (float)NetworkSingleton.Instance.Influence.regionInfluence.Count; questDifficultyScalar = 1f + num2; _helper.InitializeQuest("Four Wheels", Mathf.RoundToInt(300f * questDifficultyScalar)); _talkToJeremyAction = UnityAction.op_Implicit((Action)OnTalkToJeremyComplete); _helper.InitializeQuestEntry(ref QuestEntry_TalkToJeremy, "TalkToJeremy", "Ask Jeremy about the cars at their home after curfew", new PoIConfig(usePoI: true, useParent: false, useTransformLocal: false, null, new Vector3(69f, 5.93f, -119.09f)), _talkToJeremyAction); _stopCarMeetupAction = UnityAction.op_Implicit((Action)OnStopCarMeetupComplete); _helper.InitializeQuestEntry(ref QuestEntry_StopCarMeetup, "StopCarMeetup", "• Stop the Benzies from transporting cocaine\n• Avoid police attention", new PoIConfig(usePoI: true, useParent: false, useTransformLocal: false, null, new Vector3(-32.68f, -2.54f, 168.73f)), _stopCarMeetupAction); _helper.InitializeQuestEntry(ref QuestEntry_StopCarMeetup, "Escape", "• Steal Cocaine from the SUV\n• Escape before police arrive", new PoIConfig(usePoI: false, useParent: false, useTransformLocal: false)); TimeManager instance = NetworkSingleton.Instance; Action action = ((Quest)this).OnMinPass; instance.onHourPass += Action.op_Implicit((Action)HourPass); instance.onMinutePass += Action.op_Implicit(action); _helper.StartQuestFromEntry(QuestEntry_TalkToJeremy); } public override void OnMinPass() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Invalid comparison between Unknown and I4 //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Invalid comparison between Unknown and I4 //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) if (!CartelEnforcer.registered || Singleton.Instance.IsSaving || EndGameQuest.carMeetupCompleted || (int)((Quest)this).State != 1 || !InstanceFinder.IsServer) { return; } if ((Object)(object)QuestEntry_StopCarMeetup != (Object)null && (int)QuestEntry_StopCarMeetup.State == 1) { if ((int)Player.Local.CrimeData.CurrentPursuitLevel != 0) { EndGameQuest.carMeetupCompleted = true; QuestEntry_StopCarMeetup.SetState((EQuestState)3, true); ((Quest)this).Fail(true); CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.CleanupCarMeetup())); return; } if (NetworkSingleton.Instance.CurrentTime < 2100 && NetworkSingleton.Instance.CurrentTime > 359) { EndGameQuest.carMeetupCompleted = true; QuestEntry_StopCarMeetup.SetState((EQuestState)3, true); ((Quest)this).Fail(true); CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.CleanupCarMeetup())); return; } if (combatBegun) { int num = 0; foreach (KeyValuePair spawnedGoon in spawnedGoons) { if (((NPC)spawnedGoon.Value).Health.IsDead || ((NPC)spawnedGoon.Value).Health.IsKnockedOut) { num++; } } if (num == spawnedGoons.Count) { QuestEntry_StopCarMeetup.Complete(); } return; } if (!playerSightedActive && Enumerable.Contains(spawnedGoons.Keys, "guard")) { float num2 = default(float); Player closestPlayer = PlayerManager.GetClosestPlayer(((Component)QuestEntry_StopCarMeetup.PoI).transform.position, ref num2, (List)null); if (Vector3.Distance(closestPlayer.CenterPointTransform.position, ((Component)QuestEntry_StopCarMeetup.PoI).transform.position) < 30f) { if (closestPlayer.IsPointVisibleToPlayer(((NPC)spawnedGoons["guard"]).CenterPointTransform.position, 30f, 5f)) { if (Random.Range(0f, 1f) > 0.8f) { ((NPC)spawnedGoons["guard"]).Movement.FacePoint(closestPlayer.CenterPointTransform.position, 1f); } } else if (Random.Range(0f, 1f) > 0.9f && Vector3.Distance(closestPlayer.CenterPointTransform.position, ((Component)QuestEntry_StopCarMeetup.PoI).transform.position) < 15f) { ((NPC)spawnedGoons["guard"]).Movement.FacePoint(closestPlayer.CenterPointTransform.position, 1f); } if (((NPC)spawnedGoons["guard"]).Awareness.VisionCone.IsPlayerVisible(closestPlayer)) { playerSightedActive = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.PlayerSightedByGuard(closestPlayer))); } } } } if ((Object)(object)QuestEntry_EscapeNorthWaterfront != (Object)null && (int)QuestEntry_EscapeNorthWaterfront.State == 1 && investigationActive) { if ((int)Player.Local.CrimeData.CurrentPursuitLevel == 0) { EndGameQuest.carMeetupCompleted = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.QuestCarMeetupReward())); ((Quest)this).Complete(true); CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.CleanupCarMeetup())); } else if ((int)Player.Local.CrimeData.CurrentPursuitLevel != 0 && (int)Player.Local.CrimeData.CurrentPursuitLevel != 1) { EndGameQuest.carMeetupCompleted = true; ((Quest)this).Fail(true); CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.CleanupCarMeetup())); } } } private void HourPass() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 if (CartelEnforcer.registered && !Singleton.Instance.IsSaving && !EndGameQuest.carMeetupCompleted && !((Object)(object)this == (Object)null) && (int)((Quest)this).State == 1 && InstanceFinder.IsServer && (Object)(object)QuestEntry_TalkToJeremy != (Object)null && (int)QuestEntry_TalkToJeremy.State == 1) { if (NetworkSingleton.Instance.CurrentTime >= 2059 && NetworkSingleton.Instance.CurrentTime <= 2102) { Action cb = OnDialogComplete; CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.GenJeremyOption(cb))); } else if (EndGameQuest.jeremyDiagIndex != -1 && NetworkSingleton.Instance.CurrentTime < 2059 && !EndGameQuest.jeremyDialogueActive) { DialogueController component = ((Component)EndGameQuest.jeremy.DialogueHandler).gameObject.GetComponent(); CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.DisposeJeremyChoice(component))); } } } private void OnDialogComplete() { QuestEntry_TalkToJeremy.Complete(); } public void CombatStarted() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (combatBegun) { return; } combatBegun = true; foreach (KeyValuePair spawnedGoon in spawnedGoons) { if ((Delegate)(object)combatStartedAction != (Delegate)null) { ((Behaviour)((NPC)spawnedGoon.Value).Behaviour.CombatBehaviour).onBegin.RemoveListener(combatStartedAction); } if ((Delegate)(object)goonDiedAction != (Delegate)null) { ((NPC)spawnedGoon.Value).Health.onDieOrKnockedOut.RemoveListener(goonDiedAction); } } float num = default(float); Player closestPlayer = PlayerManager.GetClosestPlayer(((NPC)spawnedGoons["guard"]).CenterPointTransform.position, ref num, (List)null); spawnedGoons["guard"].AttackEntity(((Component)closestPlayer).GetComponent(), true); spawnedGoons["extra1"].AttackEntity(((Component)closestPlayer).GetComponent(), true); combatStartedAction = null; goonDiedAction = null; } public void OnCarMeetupGoonDie() { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) if (combatBegun) { return; } combatBegun = true; foreach (KeyValuePair spawnedGoon in spawnedGoons) { if ((Delegate)(object)combatStartedAction != (Delegate)null) { ((Behaviour)((NPC)spawnedGoon.Value).Behaviour.CombatBehaviour).onBegin.RemoveListener(combatStartedAction); } if ((Delegate)(object)goonDiedAction != (Delegate)null) { ((NPC)spawnedGoon.Value).Health.onDieOrKnockedOut.RemoveListener(goonDiedAction); } } CartelGoon val = null; if (Enumerable.Contains(spawnedGoons.Keys, "guard")) { val = spawnedGoons["guard"]; } Player val2 = null; if ((Object)(object)val != (Object)null) { float num = default(float); val2 = PlayerManager.GetClosestPlayer(((NPC)spawnedGoons["guard"]).CenterPointTransform.position, ref num, (List)null); spawnedGoons["guard"].AttackEntity(((Component)val2).GetComponent(), true); } if ((Object)(object)val2 != (Object)null && Enumerable.Contains(spawnedGoons.Keys, "extra1")) { spawnedGoons["extra1"].AttackEntity(((Component)val2).GetComponent(), true); } combatStartedAction = null; goonDiedAction = null; } private void OnTalkToJeremyComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((!((Object)(object)QuestEntry_TalkToJeremy != (Object)null) || (int)QuestEntry_TalkToJeremy.State != 3) && !((Object)(object)QuestEntry_StopCarMeetup == (Object)null)) { QuestEntry_StopCarMeetup.Begin(); EndGameQuest.UpdateQuestMapLogo(QuestEntry_StopCarMeetup); CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.SpawnCarMeetup())); if ((Delegate)(object)_talkToJeremyAction != (Delegate)null) { QuestEntry_TalkToJeremy.onComplete.RemoveListener(_talkToJeremyAction); _talkToJeremyAction = null; } } } private void OnStopCarMeetupComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((!((Object)(object)QuestEntry_StopCarMeetup != (Object)null) || (int)QuestEntry_StopCarMeetup.State != 3) && !((Object)(object)QuestEntry_EscapeNorthWaterfront == (Object)null)) { CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.StartLateInvestigation())); rewardStorage.AccessSettings = (EAccessSettings)2; QuestEntry_EscapeNorthWaterfront.Begin(); if (QuestEntry_EscapeNorthWaterfront.compassElement != null) { QuestEntry_EscapeNorthWaterfront.compassElement.Visible = false; } if ((Delegate)(object)_stopCarMeetupAction != (Delegate)null) { QuestEntry_StopCarMeetup.onComplete.RemoveListener(_stopCarMeetupAction); _stopCarMeetupAction = null; } } } } public class CarMeetupHelper : QuestHelperBase { public CarMeetupHelper(Quest_CarMeetup quest) : base(quest) { } public IEnumerator SpawnCarMeetup() { NetworkManager netManager = Object.FindObjectOfType(true); PrefabObjects spawnablePrefabs = netManager.SpawnablePrefabs; NetworkObject nobSuv = null; GameObject objPallet = null; for (int i = 0; i < spawnablePrefabs.GetObjectCount(); i++) { NetworkObject val = spawnablePrefabs.GetObject(true, i); object obj; if (val == null) { obj = null; } else { GameObject gameObject = ((Component)val).gameObject; obj = ((gameObject != null) ? ((Object)gameObject).name : null); } if ((string?)obj == "BoxSUV") { nobSuv = val; } } GameObject val2 = GameObject.Find("Map/Hyland Point/Region_Northtown/Hardware Store/Loading bay/PalletStand (2)/Container"); int num = 0; for (int j = 0; j < val2.transform.childCount; j++) { Transform child = val2.transform.GetChild(j); if (((Object)child).name == "Pallet") { num++; if (num == 2) { objPallet = ((Component)child).gameObject; break; } } } _ = (Object)(object)objPallet == (Object)null; Func func = Registry.GetItem; ItemDefinition def = func("cocaine"); ItemInstance defaultInstance = def.GetDefaultInstance(1); ProductItemInstance val3 = ((Il2CppObjectBase)defaultInstance).TryCast(); if (val3 != null) { if ((Object)(object)CartelInventory.brickPackaging != (Object)null) { val3.SetPackaging(CartelInventory.brickPackaging); } if ((Object)(object)((StorableItemInstance)val3).StoredItem != (Object)null) { FilledPackaging_StoredItem val4 = ((Il2CppObjectBase)((StorableItemInstance)val3).StoredItem).TryCast(); if ((Object)(object)val4 != (Object)null) { GameObject gameObject2 = ((Component)((ProductVisualsSetter)val4.Visuals.CocaineVisuals).VisualsContainer).gameObject; if ((Object)(object)gameObject2 != (Object)null) { _quest.brickBase = Object.Instantiate(gameObject2); ((Object)_quest.brickBase).name = "CokeBrickDecor"; _quest.brickBase.transform.SetParent(((Component)_quest).transform); } } } } NetworkObject boxSuv1 = Object.Instantiate(nobSuv); netManager.ServerManager.Spawn(boxSuv1, (NetworkConnection)null, default(Scene)); yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { yield break; } ((Component)boxSuv1).transform.parent = ((Component)Singleton.Instance).transform; ((Component)boxSuv1).gameObject.SetActive(true); ((Component)boxSuv1).transform.SetPositionAndRotation(new Vector3(-19.0712f, -4.1883f, 174.4196f), Quaternion.Euler(0.0009f, 0.4645f, 0f)); _quest.rewardStorage = ((Component)boxSuv1).GetComponent(); yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } ((Component)boxSuv1).GetComponent().isKinematic = true; _quest.spawnedDecor.Add(((Component)boxSuv1).gameObject); int num2 = Mathf.RoundToInt(Mathf.Lerp(2f, 4f, _quest.questDifficultyScalar - 1f)); int num3 = Random.Range(1, num2); for (int k = 0; k < num3; k++) { int num4 = Mathf.RoundToInt(Mathf.Lerp(5f, 10f, _quest.questDifficultyScalar - 1f)); int num5 = Random.Range(3, num4); defaultInstance = def.GetDefaultInstance(num5); ProductItemInstance val5 = ((Il2CppObjectBase)defaultInstance).TryCast(); if (val5 != null && (Object)(object)CartelInventory.brickPackaging != (Object)null) { val5.SetPackaging(CartelInventory.brickPackaging); } if (k < _quest.rewardStorage.ItemSlots.Count) { _quest.rewardStorage.ItemSlots[k].InsertItem(defaultInstance); } } NetworkObject boxSuv2 = Object.Instantiate(nobSuv); ((Component)boxSuv2).transform.SetPositionAndRotation(new Vector3(-20.2015f, -3.9164f, 167.2993f), Quaternion.Euler(2.5122f, 79.6851f, 359.3438f)); netManager.ServerManager.Spawn(boxSuv2, (NetworkConnection)null, default(Scene)); yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { yield break; } ((Component)boxSuv2).transform.parent = ((Component)Singleton.Instance).transform; ((Component)boxSuv2).gameObject.SetActive(true); yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } ((Component)boxSuv2).GetComponent().isKinematic = true; ((Component)boxSuv2).GetComponent().HeadlightsOn = true; _quest.spawnedDecor.Add(((Component)boxSuv2).gameObject); GameObject pallet = Object.Instantiate(objPallet); pallet.transform.parent = ((Component)Singleton.Instance).transform; pallet.gameObject.SetActive(true); pallet.transform.position = new Vector3(-14.93f, -5f, 168.7f); Rigidbody component = pallet.GetComponent(); if ((Object)(object)component != (Object)null) { component.isKinematic = true; } _quest.spawnedDecor.Add(pallet.gameObject); foreach (Vector3 basePos in _quest.pileBasePos) { for (int l = 0; l < Random.Range(4, 9); l++) { yield return CartelEnforcer.Wait01; if (CartelEnforcer.registered) { GameObject val6 = Object.Instantiate(_quest.brickBase, pallet.transform); val6.transform.position = new Vector3(basePos.x, basePos.y + 0.06f * (float)l, basePos.z); val6.transform.rotation = Quaternion.Euler(0f, Mathf.Round(Random.Range(85f, 95f)), 0f); val6.gameObject.SetActive(true); _quest.spawnedDecor.Add(val6); continue; } yield break; } } if (NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count < 4) { foreach (CartelGoon item in (Il2CppArrayBase)(object)NetworkSingleton.Instance.GoonPool.goons) { if (NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count < 4) { if (NetworkSingleton.Instance.GoonPool.spawnedGoons.Contains(item) && item.IsGoonSpawned && (((NPC)item).Health.IsDead || ((NPC)item).Health.IsKnockedOut)) { item.Despawn(); } continue; } break; } } CartelGoon goonHandler = NetworkSingleton.Instance.GoonPool.SpawnGoon(new Vector3(-16.11f, -3.64f, 169.57f)); ((Component)((NPC)goonHandler).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)goonHandler).Behaviour.ScheduleManager.DisableSchedule(); ((Component)goonHandler).transform.rotation = Quaternion.Euler(0f, 116f, 0f); ((NPC)goonHandler).Avatar.Animation.SetCrouched(true); _quest.spawnedGoons.Add("handler", goonHandler); CartelGoon val7 = NetworkSingleton.Instance.GoonPool.SpawnGoon(new Vector3(-32.68f, -2.54f, 168.73f)); ((Component)((NPC)val7).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)val7).Behaviour.ScheduleManager.DisableSchedule(); ((Component)val7).transform.rotation = Quaternion.Euler(0f, 226f, 0f); _quest.spawnedGoons.Add("guard", val7); CartelGoon val8 = NetworkSingleton.Instance.GoonPool.SpawnGoon(new Vector3(-16.2101f, -3.64f, 173.96f)); ((Component)((NPC)val8).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)val8).Behaviour.ScheduleManager.DisableSchedule(); ((Component)val8).transform.rotation = Quaternion.Euler(0f, 180f, 0f); _quest.spawnedGoons.Add("extra1", val8); CartelGoon val9 = NetworkSingleton.Instance.GoonPool.SpawnGoon(new Vector3(-29.09f, -2.64f, 158.73f)); ((Component)((NPC)val9).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)val9).Behaviour.ScheduleManager.DisableSchedule(); ((Component)val9).transform.rotation = Quaternion.Euler(0f, 0f, 0f); _quest.spawnedGoons.Add("extra2", val9); val7.AddGoonMate(val9); val7.AddGoonMate(val8); val7.AddGoonMate(goonHandler); val8.AddGoonMate(goonHandler); _quest.combatStartedAction = UnityAction.op_Implicit((Action)_quest.CombatStarted); _quest.goonDiedAction = UnityAction.op_Implicit((Action)_quest.OnCarMeetupGoonDie); foreach (KeyValuePair spawnedGoon in _quest.spawnedGoons) { if (((NPC)spawnedGoon.Value).Health.IsDead || ((NPC)spawnedGoon.Value).Health.IsKnockedOut) { ((NPC)spawnedGoon.Value).Health.Revive(); } float num6 = Mathf.Round(Random.Range(160f, 230f) / 10f) * 10f; ((NPC)spawnedGoon.Value).NPCData.Health.MaxHealth = Mathf.Round(Mathf.Lerp(100f, num6, _quest.questDifficultyScalar - 1f)); ((NPC)spawnedGoon.Value).Health.Health = Mathf.Round(Mathf.Lerp(100f, num6, _quest.questDifficultyScalar - 1f)); ((NPC)spawnedGoon.Value).Movement.MoveSpeedMultiplier = Mathf.Lerp(Random.Range(1.1f, 1.3f), 1.5f, _quest.questDifficultyScalar - 1f); ((Behaviour)((NPC)spawnedGoon.Value).Behaviour.CombatBehaviour).onBegin.AddListener(_quest.combatStartedAction); ((NPC)spawnedGoon.Value).Health.onDieOrKnockedOut.AddListener(_quest.goonDiedAction); if (!_quest.hasSavedCombatVariables) { _quest.GiveUpRange = ((NPC)spawnedGoon.Value).Behaviour.CombatBehaviour.GiveUpRange; _quest.GiveUpAfterSuccessfulHits = ((NPC)spawnedGoon.Value).Behaviour.CombatBehaviour.GiveUpAfterSuccessfulHits; _quest.DefaultSearchTime = ((NPC)spawnedGoon.Value).Behaviour.CombatBehaviour.DefaultSearchTime; } ((NPC)spawnedGoon.Value).Behaviour.CombatBehaviour.GiveUpRange = 120f; ((NPC)spawnedGoon.Value).Behaviour.CombatBehaviour.GiveUpAfterSuccessfulHits = 60; ((NPC)spawnedGoon.Value).Behaviour.CombatBehaviour.DefaultSearchTime = 300f; _quest.spawnedGoonsGuids.Add(((object)((NPC)spawnedGoon.Value).GUID/*cast due to .constrained prefix*/).ToString()); } AvatarWeapon val10 = ((Il2CppObjectBase)Object.Instantiate(((Il2CppObjectBase)Resources.Load("Avatar/Equippables/M1911")).TryCast(), new Vector3(0f, -5f, 0f), Quaternion.identity, ((Component)_quest).transform).GetComponent()).TryCast(); if ((Object)(object)val10 != (Object)null) { ((NPC)val8).Behaviour.CombatBehaviour.SetDefaultWeapon(val10); ((NPC)val9).Behaviour.CombatBehaviour.SetDefaultWeapon(val10); } AvatarWeapon val11 = ((Il2CppObjectBase)Object.Instantiate(((Il2CppObjectBase)Resources.Load("Avatar/Equippables/PumpShotgun")).TryCast(), new Vector3(0f, -5f, 0f), Quaternion.identity, ((Component)_quest).transform).GetComponent()).TryCast(); if ((Object)(object)val11 != (Object)null) { ((NPC)val7).Behaviour.CombatBehaviour.SetDefaultWeapon(val11); } AvatarWeapon val12 = ((Il2CppObjectBase)Object.Instantiate(((Il2CppObjectBase)Resources.Load("Avatar/Equippables/Knife")).TryCast(), new Vector3(0f, -5f, 0f), Quaternion.identity, ((Component)_quest).transform).GetComponent()).TryCast(); if ((Object)(object)val12 != (Object)null) { ((NPC)goonHandler).Behaviour.CombatBehaviour.SetDefaultWeapon(val12); } _quest.combatEndCrouchAction = UnityAction.op_Implicit((Action)EndCrouchOnCombat); ((Behaviour)((NPC)goonHandler).Behaviour.CombatBehaviour).onBegin.AddListener(_quest.combatEndCrouchAction); void EndCrouchOnCombat() { ((NPC)goonHandler).Avatar.Animation.SetCrouched(false); if ((Delegate)(object)_quest.combatEndCrouchAction != (Delegate)null) { ((Behaviour)((NPC)goonHandler).Behaviour.CombatBehaviour).onBegin.RemoveListener(_quest.combatEndCrouchAction); _quest.combatEndCrouchAction = null; } } } public IEnumerator PlayerSightedByGuard(Player p) { if (!Enumerable.Contains(_quest.spawnedGoons.Keys, "guard")) { yield break; } DialogueController controller = ((Component)((NPC)_quest.spawnedGoons["guard"]).DialogueHandler).gameObject.GetComponent(); int timesWarned = 0; Vector3 zero = Vector3.zero; while (CartelEnforcer.registered && !_quest.combatBegun && Enumerable.Contains(_quest.spawnedGoons.Keys, "guard") && !((NPC)_quest.spawnedGoons["guard"]).Health.IsDead && !((NPC)_quest.spawnedGoons["guard"]).Health.IsKnockedOut) { ((NPC)_quest.spawnedGoons["guard"]).Movement.GetClosestReachablePoint(p.CenterPointTransform.position, ref zero); if (zero != Vector3.zero) { ((NPC)_quest.spawnedGoons["guard"]).Movement.SetDestination(zero); } yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered || _quest.combatBegun) { break; } ((NPC)_quest.spawnedGoons["guard"]).Movement.FacePoint(p.CenterPointTransform.position, 0.5f); if (timesWarned < 2) { switch (Random.Range(0, 4)) { case 0: controller.handler.WorldspaceRend.ShowText("Get out of here you punk!", 3f); break; case 1: controller.handler.WorldspaceRend.ShowText("This ain't your business!", 3f); break; case 2: controller.handler.WorldspaceRend.ShowText("Screw off mate!", 3f); break; case 3: controller.handler.WorldspaceRend.ShowText("You're not invited here, get lost!", 3f); break; } timesWarned++; ((NPC)_quest.spawnedGoons["guard"]).PlayVO((EVOLineType)2, false); } else { switch (timesWarned) { case 2: switch (Random.Range(0, 3)) { case 0: controller.handler.WorldspaceRend.ShowText("Last warning buddy!", 3f); break; case 1: controller.handler.WorldspaceRend.ShowText("Walk away or you get shot.", 3f); break; case 2: controller.handler.WorldspaceRend.ShowText("One of us is going to leave in a casket...", 5f); break; } ((NPC)_quest.spawnedGoons["guard"]).PlayVO((EVOLineType)10, false); ((NPC)_quest.spawnedGoons["guard"]).Avatar.EmotionManager.AddEmotionOverride("Annoyed", "product_rejected", 10f, 1); ((NPC)_quest.spawnedGoons["guard"]).Behaviour.CombatBehaviour.SetWeaponRaised(true); yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered && !_quest.combatBegun) { ((NPC)_quest.spawnedGoons["guard"]).Movement.FacePoint(p.CenterPointTransform.position, 0.5f); timesWarned++; break; } yield break; case 3: if (!_quest.combatBegun) { _quest.spawnedGoons["guard"].AttackEntity(((Component)p).GetComponent(), true); yield break; } break; } } yield return CartelEnforcer.Wait2; if (CartelEnforcer.registered && !_quest.combatBegun) { ((NPC)_quest.spawnedGoons["guard"]).Movement.FacePoint(p.CenterPointTransform.position, 0.5f); continue; } break; } } public IEnumerator StartLateInvestigation() { yield return CartelEnforcer.Wait10; Player.Local.CrimeData.SetPursuitLevel((EPursuitLevel)1); PoliceStation.PoliceStations[0].Dispatch(1, Player.Local, (EDispatchType)0, true); _quest.investigationActive = true; } public IEnumerator CleanupCarMeetup() { yield return CartelEnforcer.Wait10; if (!CartelEnforcer.registered) { yield break; } foreach (GameObject go in _quest.spawnedDecor) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { if ((Object)(object)go != (Object)null) { Object.Destroy((Object)(object)go); } continue; } yield break; } _quest.spawnedDecor.Clear(); foreach (KeyValuePair kvp in _quest.spawnedGoons) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { if ((Delegate)(object)_quest.combatStartedAction != (Delegate)null) { ((Behaviour)((NPC)kvp.Value).Behaviour.CombatBehaviour).onBegin.RemoveListener(_quest.combatStartedAction); } if ((Delegate)(object)_quest.goonDiedAction != (Delegate)null) { ((NPC)kvp.Value).Health.onDieOrKnockedOut.RemoveListener(_quest.goonDiedAction); } if ((Delegate)(object)_quest.combatEndCrouchAction != (Delegate)null) { ((NPC)kvp.Value).Health.onDieOrKnockedOut.RemoveListener(_quest.combatEndCrouchAction); } if (((NPC)kvp.Value).Health.IsDead) { ((NPC)kvp.Value).Health.Revive(); } ((Behaviour)((NPC)kvp.Value).Behaviour.CombatBehaviour).Disable_Networked((NetworkConnection)null); ((NPC)kvp.Value).Movement.MoveSpeedMultiplier = 1f; ((NPC)kvp.Value).NPCData.Health.MaxHealth = 100f; ((NPC)kvp.Value).Health.Health = 100f; ((NPC)kvp.Value).Behaviour.CombatBehaviour.GiveUpRange = _quest.GiveUpRange; ((NPC)kvp.Value).Behaviour.CombatBehaviour.GiveUpAfterSuccessfulHits = _quest.GiveUpAfterSuccessfulHits; ((NPC)kvp.Value).Behaviour.CombatBehaviour.DefaultSearchTime = _quest.DefaultSearchTime; ((NPC)kvp.Value).Behaviour.ScheduleManager.EnableSchedule(); ((Component)((NPC)kvp.Value).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); if (kvp.Value.IsGoonSpawned) { kvp.Value.Despawn(); } continue; } yield break; } _quest.spawnedGoons.Clear(); _quest.spawnedGoonsGuids.Clear(); _quest.combatStartedAction = null; _quest.goonDiedAction = null; _quest.combatEndCrouchAction = null; } } [RegisterTypeInIl2Cpp] public class Quest_DefeatEnforcer : ModQuestBase { protected readonly DefeatEnforcerHelper _helper; public bool bossHasSpawned; public bool bossCombatBegun; public bool rageStageStarted; public int fightElapsed; public float questDifficultyScalar; public bool hasSavedCombatVariables; public float GiveUpRange; public int GiveUpAfterSuccessfulHits; public float DefaultSearchTime; public int mannyMessagesSent; public bool mannyMessageRead; public bool isBossSpawning; public QuestEntry QuestEntry_Investigate; private UnityAction _investigateAction; public QuestEntry QuestEntry_WaitForContact; private UnityAction _contactAction; public QuestEntry QuestEntry_DefeatBoss; public UnityAction bossDiedAction; public readonly List encounterPositions = new List { new Vector3(156.38f, 6.7f, 123.95f), new Vector3(65.6153f, 3.0466f, -46.6993f), new Vector3(29.5507f, 0.6506f, -69.1599f), new Vector3(121.7651f, 1.4617f, -46.0731f) }; public Vector3 bossSelectedPosition = Vector3.zero; public Quest_DefeatEnforcer(IntPtr ptr) : base(ptr) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) _helper = new DefeatEnforcerHelper(this); } public Quest_DefeatEnforcer() : base(ClassInjector.DerivedConstructorPointer()) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this); } public override void Complete(bool network = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 try { if ((int)((Quest)this).State != 2) { if (InstanceFinder.IsServer && !Singleton.Instance.IsLoading) { NetworkSingleton.Instance.AddXP(((Quest)this).CompletionXP); } ((Quest)this).SetQuestState((EQuestState)2, false); NetworkSingleton.Instance.PlayCompleteQuestSound(); ((Quest)this).End(); } } catch (Exception) { throw; } } public override void Fail(bool network = true) { try { ((Quest)this).SetQuestState((EQuestState)3, false); ((Quest)this).End(); } catch (Exception) { throw; } } public override void End() { try { if ((Object)(object)((Quest)this).hudUI != (Object)null) { ((Quest)this).hudUI.Complete(); } TimeManager instance = NetworkSingleton.Instance; if ((Object)(object)instance == (Object)null) { return; } Action action = ((Quest)this).OnMinPass; instance.onHourPass -= Action.op_Implicit((Action)HourPass); instance.onMinutePass.Remove(Action.op_Implicit(action)); } catch (Exception) { throw; } ((Component)this).gameObject.SetActive(false); } public void SetupSelf() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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) float num = 0f; Enumerator enumerator = NetworkSingleton.Instance.Influence.regionInfluence.GetEnumerator(); while (enumerator.MoveNext()) { RegionInfluenceData current = enumerator.Current; num += current.Influence; } float num2 = num / (float)NetworkSingleton.Instance.Influence.regionInfluence.Count; questDifficultyScalar = 1f + num2; bossSelectedPosition = encounterPositions[Random.Range(0, encounterPositions.Count)]; _helper.InitializeQuest("Unexpected Alliances", Mathf.RoundToInt(850f * questDifficultyScalar)); _investigateAction = UnityAction.op_Implicit((Action)OnInvestigateComplete); _helper.InitializeQuestEntry(ref QuestEntry_Investigate, "Investigate", "• Intercept Cartel Dead Drops (0/2)\nOR\n• Defeat Cartel Gatherings (0/1)", new PoIConfig(usePoI: false, useParent: false, useTransformLocal: false), _investigateAction); _contactAction = UnityAction.op_Implicit((Action)OnContactComplete); _helper.InitializeQuestEntry(ref QuestEntry_WaitForContact, "Contact", "Wait for Manny to contact you", new PoIConfig(usePoI: false, useParent: false, useTransformLocal: false), _contactAction); _helper.InitializeQuestEntry(ref QuestEntry_DefeatBoss, "Defeat", "Defeat the Cartel Brute", new PoIConfig(usePoI: true, useParent: false, useTransformLocal: false, null, bossSelectedPosition)); TimeManager instance = NetworkSingleton.Instance; Action action = ((Quest)this).OnMinPass; instance.onHourPass += Action.op_Implicit((Action)HourPass); instance.onMinutePass += Action.op_Implicit(action); _helper.StartQuestFromEntry(QuestEntry_Investigate); if ((Object)(object)QuestEntry_Investigate != (Object)null) { if (QuestEntry_Investigate.compassElement != null) { QuestEntry_Investigate.compassElement.Visible = false; return; } QuestEntry_Investigate.CreateCompassElement(); QuestEntry_Investigate.compassElement.Visible = false; } } private void SendMannyMessage() { switch (mannyMessagesSent) { case 0: EndGameQuest.fixer.SendTextMessage("One of the cartel brutes is hiding out in the woods. I sent you the location."); break; case 1: EndGameQuest.fixer.SendTextMessage("Hurry up! Go take down the Benzies thug. They will leave the area soon."); break; case 2: EndGameQuest.fixer.SendTextMessage("I marked the location on your map. Head there and take the down their brute."); break; case 3: EndGameQuest.fixer.SendTextMessage("Nevermind. I guess you were not the right person for the job."); break; } mannyMessagesSent++; } public override void OnMinPass() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Invalid comparison between Unknown and I4 //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Invalid comparison between Unknown and I4 //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) if (!CartelEnforcer.registered || Singleton.Instance.IsSaving || EndGameQuest.defeatEnforcerCompleted || (int)((Quest)this).State != 1 || !InstanceFinder.IsServer) { return; } if ((Object)(object)QuestEntry_Investigate != (Object)null && (int)QuestEntry_Investigate.State == 1) { if ((Object)(object)QuestEntry_Investigate != (Object)null && (Object)(object)QuestEntry_Investigate.entryUI != (Object)null && ((Quest)this).hudUIExists) { QuestEntry_Investigate.SetEntryTitle($"• Intercept Cartel Dead Drops ({EndGameQuest.StageDeadDropsObserved}/2)\nOR\n• Defeat Cartel Gatherings ({EndGameQuest.StageGatheringsDefeated}/1)"); } if (EndGameQuest.StageDeadDropsObserved >= 2 || EndGameQuest.StageGatheringsDefeated >= 1) { QuestEntry_Investigate.Complete(); } } else if ((Object)(object)QuestEntry_WaitForContact != (Object)null && (int)QuestEntry_WaitForContact.State == 1) { if ((Object)(object)EndGameQuest.fixer != (Object)null && EndGameQuest.fixer.MSGConversation != null && EndGameQuest.fixer.MSGConversation.isOpen && mannyMessagesSent > 0) { mannyMessageRead = true; QuestEntry_WaitForContact.Complete(); } if (mannyMessagesSent > 2) { ((Quest)this).Fail(true); } } else { if (!((Object)(object)QuestEntry_DefeatBoss != (Object)null) || (int)QuestEntry_DefeatBoss.State != 1) { return; } if (NetworkSingleton.Instance.CurrentTime >= 659 && NetworkSingleton.Instance.CurrentTime <= 800) { EndGameQuest.defeatEnforcerCompleted = true; if ((Object)(object)EndGameQuest.bossGoon != (Object)null) { EndGameQuest.bossGoon.Despawn(); ResetGoonBoss(); } ((Quest)this).Fail(true); return; } if ((Object)(object)EndGameQuest.bossGoon == (Object)null && !isBossSpawning && !bossHasSpawned) { float num = default(float); PlayerManager.GetClosestPlayer(((Component)QuestEntry_DefeatBoss.PoILocation).transform.position, ref num, (List)null); if (num < 40f) { isBossSpawning = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.RunBossSpawn())); return; } } if (!((Object)(object)EndGameQuest.bossGoon != (Object)null) || !bossHasSpawned) { return; } QuestEntry_DefeatBoss.SetEntryTitle($"Defeat the Cartel Brute\nHP:{Mathf.RoundToInt(((NPC)EndGameQuest.bossGoon).Health.Health)}"); float num2 = default(float); Player closestPlayer = PlayerManager.GetClosestPlayer(((Component)EndGameQuest.bossGoon).transform.position, ref num2, (List)null); if (num2 < 16f && !bossCombatBegun) { bossCombatBegun = true; ((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.SetTarget(((Component)closestPlayer).GetComponent().NetworkObject); ((Behaviour)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour).Enable_Networked(); } if (!bossCombatBegun) { return; } fightElapsed++; if (!rageStageStarted) { if ((Object)(object)((NPC)EndGameQuest.bossGoon).Behaviour.activeBehaviour == (Object)null || (Object)(object)((NPC)EndGameQuest.bossGoon).Behaviour.activeBehaviour != (Object)(object)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour) { if (((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.Target == null) { ((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.SetTarget(((Component)closestPlayer).GetComponent().NetworkObject); } ((Behaviour)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour).Enable_Networked(); } if ((Object)(object)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.currentWeapon == (Object)null || ((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.IsCurrentWeaponMelee()) { CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.EquipBossWeapon())); } if (((NPC)EndGameQuest.bossGoon).Health.Health < 230f || fightElapsed > 40) { rageStageStarted = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.RunRageStage())); } } if (num2 > 70f || Vector3.Distance(((NPC)EndGameQuest.bossGoon).CenterPoint, bossSelectedPosition) > 70f || fightElapsed > 300) { EndGameQuest.defeatEnforcerCompleted = true; QuestEntry_DefeatBoss.SetState((EQuestState)3, true); EndGameQuest.bossGoon.Despawn(); ResetGoonBoss(); ((Quest)this).Fail(true); } } } private void HourPass() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 if (!CartelEnforcer.registered || Singleton.Instance.IsSaving || EndGameQuest.defeatEnforcerCompleted || (int)((Quest)this).State != 1 || !InstanceFinder.IsServer || (int)QuestEntry_WaitForContact.State != 1) { return; } if (NetworkSingleton.Instance.CurrentTime >= 2159 || NetworkSingleton.Instance.CurrentTime <= 200) { if (mannyMessagesSent == 0) { QuestEntry_WaitForContact.SetEntryTitle("Read Mannys text message."); } SendMannyMessage(); } else if (NetworkSingleton.Instance.CurrentTime >= 359 && NetworkSingleton.Instance.CurrentTime <= 402 && !mannyMessageRead) { EndGameQuest.defeatEnforcerCompleted = true; ((Quest)this).Fail(true); } } private void OnInvestigateComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((!((Object)(object)QuestEntry_Investigate != (Object)null) || (int)QuestEntry_Investigate.State != 3) && !((Object)(object)QuestEntry_WaitForContact == (Object)null)) { QuestEntry_WaitForContact.Begin(); EndGameQuest.UpdateQuestMapLogo(QuestEntry_WaitForContact); if ((Object)(object)QuestEntry_WaitForContact.PoI != (Object)null && (Object)(object)QuestEntry_WaitForContact.PoI.UI != (Object)null) { ((Component)QuestEntry_WaitForContact.PoI.UI).gameObject.SetActive(false); } if (QuestEntry_WaitForContact.compassElement != null) { QuestEntry_WaitForContact.compassElement.Visible = false; } if ((Delegate)(object)_investigateAction != (Delegate)null) { QuestEntry_Investigate.onComplete.RemoveListener(_investigateAction); _investigateAction = null; } } } private void OnContactComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((!((Object)(object)QuestEntry_WaitForContact != (Object)null) || (int)QuestEntry_WaitForContact.State != 3) && !((Object)(object)QuestEntry_DefeatBoss == (Object)null)) { QuestEntry_DefeatBoss.Begin(); EndGameQuest.UpdateQuestMapLogo(QuestEntry_DefeatBoss); if ((Delegate)(object)_contactAction != (Delegate)null) { QuestEntry_WaitForContact.onComplete.RemoveListener(_contactAction); _contactAction = null; } } } public void OnBossDied() { EndGameQuest.defeatEnforcerCompleted = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.QuestReward(EndGameQuest.bossGoon))); ((Quest)this).Complete(true); if ((Delegate)(object)bossDiedAction != (Delegate)null) { ((NPC)EndGameQuest.bossGoon).Health.onDieOrKnockedOut.RemoveListener(bossDiedAction); bossDiedAction = null; } } private void ResetGoonBoss() { if ((Object)(object)EndGameQuest.bossGoon != (Object)null) { if (((Behaviour)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour).Active) { ((Behaviour)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour).Disable_Networked((NetworkConnection)null); } if ((Delegate)(object)bossDiedAction != (Delegate)null) { ((NPC)EndGameQuest.bossGoon).Health.onDieOrKnockedOut.RemoveListener(bossDiedAction); bossDiedAction = null; } ((NPC)EndGameQuest.bossGoon).NPCData.Health.MaxHealth = 100f; ((NPC)EndGameQuest.bossGoon).Movement.MoveSpeedMultiplier = 1f; ((NPC)EndGameQuest.bossGoon).Behaviour.ScheduleManager.EnableSchedule(); ((Component)((NPC)EndGameQuest.bossGoon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); ((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.GiveUpRange = GiveUpRange; ((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.GiveUpAfterSuccessfulHits = GiveUpAfterSuccessfulHits; ((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.DefaultSearchTime = DefaultSearchTime; } } } public class DefeatEnforcerHelper : QuestHelperBase { public DefeatEnforcerHelper(Quest_DefeatEnforcer quest) : base(quest) { } public IEnumerator RunBossSpawn() { Vector3 position = _quest.QuestEntry_DefeatBoss.PoILocation.position; if (NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count == 0) { foreach (CartelGoon item in (Il2CppArrayBase)(object)NetworkSingleton.Instance.GoonPool.goons) { if (NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count >= 1) { break; } if (NetworkSingleton.Instance.GoonPool.spawnedGoons.Contains(item) && item.IsGoonSpawned && (((NPC)item).Health.IsDead || ((NPC)item).Health.IsKnockedOut)) { item.Despawn(); } } } CartelGoon val = NetworkSingleton.Instance.GoonPool.SpawnGoon(position); ((Component)_quest.QuestEntry_DefeatBoss.PoILocation).transform.SetParent(((Component)val).transform); ((Component)_quest.QuestEntry_DefeatBoss.PoILocation).transform.localPosition = Vector3.zero; ((Component)((NPC)val).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)val).Behaviour.ScheduleManager.DisableSchedule(); EndGameQuest.bossGoon = val; ((NPC)val).NPCData.Health.MaxHealth = Mathf.Round(Mathf.Lerp(500f, 1000f, _quest.questDifficultyScalar - 1f) / 10f) * 10f; ((NPC)val).Health.Health = Mathf.Round(Mathf.Lerp(500f, 1000f, _quest.questDifficultyScalar - 1f) / 10f) * 10f; ((NPC)val).Movement.MoveSpeedMultiplier = 0.4f; CartelEnforcer.coros.Add(MelonCoroutines.Start(EquipBossWeapon())); List accessorySettings = ((NPC)val).Avatar.CurrentSettings.AccessorySettings; List val2 = new List(); Enumerator enumerator2 = accessorySettings.GetEnumerator(); while (enumerator2.MoveNext()) { AccessorySetting current2 = enumerator2.Current; val2.Add(new AccessorySetting { path = current2.path, color = current2.color }); } for (int i = 0; i < val2.Count; i++) { AccessorySetting val3 = val2[i]; val3.path = ""; val3.color = Color.white; val2[i] = val3; } AccessorySetting val4 = val2[0]; val4.path = "Avatar/Accessories/Chest/BulletproofVest/BulletproofVest"; val4.color = new Color(0.1f, 0.5f, 0.1f); val2[0] = val4; AccessorySetting val5 = val2[1]; val5.path = "Avatar/Accessories/Neck/GoldChain/GoldChain"; val5.color = new Color(0.96f, 0.79f, 0.23f); val2[1] = val5; AccessorySetting val6 = val2[2]; val6.path = "Avatar/Accessories/Hands/Polex/Polex"; val6.color = new Color(0.96f, 0.79f, 0.23f); val2[2] = val6; ((NPC)val).Avatar.CurrentSettings.Height = 2f; ((NPC)val).Avatar.CurrentSettings.Weight = 1f; ((NPC)val).Avatar.SetAdditionalWeight(0.5f); ((NPC)val).Avatar.ApplyBodySettings(((NPC)val).Avatar.CurrentSettings); ((NPC)val).Avatar.CurrentSettings.AccessorySettings = val2; ((NPC)val).Avatar.ApplyAccessorySettings(((NPC)val).Avatar.CurrentSettings); ((NPC)val).Avatar.Impostor.SetAvatarSettings(((NPC)val).Avatar.CurrentSettings); if (((NPC)val).Avatar.onSettingsLoaded != null) { ((NPC)val).Avatar.onSettingsLoaded.Invoke(); } if (!_quest.hasSavedCombatVariables) { _quest.GiveUpRange = ((NPC)val).Behaviour.CombatBehaviour.GiveUpRange; _quest.GiveUpAfterSuccessfulHits = ((NPC)val).Behaviour.CombatBehaviour.GiveUpAfterSuccessfulHits; _quest.DefaultSearchTime = ((NPC)val).Behaviour.CombatBehaviour.DefaultSearchTime; _quest.hasSavedCombatVariables = true; } ((NPC)val).Behaviour.CombatBehaviour.GiveUpRange = 70f; ((NPC)val).Behaviour.CombatBehaviour.GiveUpAfterSuccessfulHits = 200; ((NPC)val).Behaviour.CombatBehaviour.DefaultSearchTime = 300f; _quest.bossDiedAction = UnityAction.op_Implicit((Action)_quest.OnBossDied); ((NPC)EndGameQuest.bossGoon).Health.onDieOrKnockedOut.AddListener(_quest.bossDiedAction); _quest.bossHasSpawned = true; yield break; } public IEnumerator EquipBossWeapon() { ((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.SetWeapon("Avatar/Equippables/PumpShotgun"); yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } if ((Object)(object)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.currentWeapon != (Object)null) { AvatarRangedWeapon val = ((Il2CppObjectBase)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.currentWeapon).TryCast(); if ((Object)(object)val != (Object)null) { ((AvatarWeapon)val).MaxUseRange = Mathf.Round(25f * _quest.questDifficultyScalar); ((AvatarWeapon)val).MinUseRange = 0.4f; val.HitChance_MaxRange = Mathf.Lerp(0.08f, 0.15f, _quest.questDifficultyScalar - 1f); val.HitChance_MinRange = Mathf.Lerp(0.65f, 0.85f, _quest.questDifficultyScalar - 1f); val.MaxFireRate = 2.6f - (_quest.questDifficultyScalar - 1f); ((AvatarWeapon)val).CooldownDuration = 0.8f; val.Damage = 55f; val.ReloadTime = 2.3f; val.RaiseTime = 1.3f; val.ImpactForce = 28f; val.AimTime_Max = 1.2f; val.RepositionAfterHit = true; val.CanShootWhileMoving = true; } } if ((Object)(object)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour._defaultWeapon == (Object)null && (Object)(object)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.currentWeapon != (Object)null) { ((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour._defaultWeapon = ((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.currentWeapon; } } public IEnumerator RunRageStage() { DrinkItem drinkAct = ((Component)((Component)EndGameQuest.bossGoon).transform.Find("Aux/Drink")).GetComponent(); bool healthRegenerated = false; float num = default(float); while (CartelEnforcer.registered) { yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered || ((NPC)EndGameQuest.bossGoon).Health.IsDead || ((NPC)EndGameQuest.bossGoon).Health.IsKnockedOut) { break; } if (!((Behaviour)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour).isActiveAndEnabled) { ((Behaviour)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour).Enable_Networked(); } if ((Object)(object)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.currentWeapon == (Object)null) { CartelEnforcer.coros.Add(MelonCoroutines.Start(EquipBossWeapon())); } if (Random.Range(0f, 1f) > 0.95f && !healthRegenerated) { if ((Object)(object)drinkAct != (Object)null) { ((NPC)EndGameQuest.bossGoon).Movement.PauseMovement(); drinkAct.Begin(); for (int i = 0; i < 3; i++) { yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered || ((NPC)EndGameQuest.bossGoon).Health.IsDead || ((NPC)EndGameQuest.bossGoon).Health.IsKnockedOut) { yield break; } NPCHealth health = ((NPC)EndGameQuest.bossGoon).Health; health.Health += (float)Mathf.RoundToInt(Mathf.Lerp(35f, 65f, _quest.questDifficultyScalar - 1f)); } drinkAct.End(); healthRegenerated = true; } Player p = PlayerManager.GetClosestPlayer(((Component)EndGameQuest.bossGoon).transform.position, ref num, (List)null); yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { break; } ((NPC)EndGameQuest.bossGoon).Movement.ResumeMovement(); if (((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.Target == null) { ((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour.SetTarget(((Component)p).GetComponent().NetworkObject); } if (!((Behaviour)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour).isActiveAndEnabled) { ((Behaviour)((NPC)EndGameQuest.bossGoon).Behaviour.CombatBehaviour).Enable_Networked(); } yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { break; } CartelEnforcer.coros.Add(MelonCoroutines.Start(EquipBossWeapon())); } yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered || ((NPC)EndGameQuest.bossGoon).Health.IsDead || ((NPC)EndGameQuest.bossGoon).Health.IsKnockedOut) { break; } if (!(Random.Range(0f, 1f) > 0.95f)) { continue; } for (int i = 0; i < 3; i++) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered || ((NPC)EndGameQuest.bossGoon).Health.IsDead || ((NPC)EndGameQuest.bossGoon).Health.IsKnockedOut) { break; } ((NPC)EndGameQuest.bossGoon).Movement.MoveSpeedMultiplier = Mathf.Lerp(((NPC)EndGameQuest.bossGoon).Movement.MoveSpeedMultiplier, 2.6f, 0.33f); } for (int i = 0; i < 3; i++) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered || ((NPC)EndGameQuest.bossGoon).Health.IsDead || ((NPC)EndGameQuest.bossGoon).Health.IsKnockedOut) { break; } ((NPC)EndGameQuest.bossGoon).Movement.MoveSpeedMultiplier = Mathf.Lerp(((NPC)EndGameQuest.bossGoon).Movement.MoveSpeedMultiplier, 0.4f, 0.33f); } ((NPC)EndGameQuest.bossGoon).Movement.MoveSpeedMultiplier = 0.4f; } } } [HarmonyPatch(typeof(NPC), "ProcessImpactForce")] public static class NPC_ProcessImpactForce_Patch { [HarmonyPrefix] public static bool Prefix(NPC __instance, Vector3 forcePoint, Vector3 forceDirection, ref float force) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)EndGameQuest.activeDefeatEnforcerQuest == (Object)null && (Object)(object)EndGameQuest.activeManorQuest == (Object)null && (Object)(object)EndGameQuest.activeCarMeetupQuest == (Object)null) { return true; } if ((Object)(object)EndGameQuest.activeDefeatEnforcerQuest != (Object)null && ((Component)EndGameQuest.activeDefeatEnforcerQuest).gameObject.activeSelf) { if ((Object)(object)EndGameQuest.bossGoon != (Object)null && ((NPC)EndGameQuest.bossGoon).GUID == __instance.GUID) { force = 10f; } } else if ((Object)(object)EndGameQuest.activeManorQuest != (Object)null && ((Component)EndGameQuest.activeManorQuest).gameObject.activeSelf) { if (EndGameQuest.manorGoonGuids.Count > 0 && EndGameQuest.manorGoonGuids.Contains(((object)__instance.GUID/*cast due to .constrained prefix*/).ToString())) { force = 10f; } } else if ((Object)(object)EndGameQuest.activeCarMeetupQuest != (Object)null && ((Component)EndGameQuest.activeCarMeetupQuest).gameObject.activeSelf && EndGameQuest.activeCarMeetupQuest.spawnedGoonsGuids.Count > 0 && EndGameQuest.activeCarMeetupQuest.spawnedGoonsGuids.Contains(((object)__instance.GUID/*cast due to .constrained prefix*/).ToString())) { force = 10f; } return true; } } [HarmonyPatch(typeof(CallPoliceBehaviour), "IsTargetValid")] public static class Behaviour_IsTargetValid_Patch { [HarmonyPrefix] public static bool Prefix(CallPoliceBehaviour __instance) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if ((Object)(object)EndGameQuest.activeCarMeetupQuest != (Object)null) { QuestEntry questEntry_StopCarMeetup = EndGameQuest.activeCarMeetupQuest.QuestEntry_StopCarMeetup; if (questEntry_StopCarMeetup != null && (int)questEntry_StopCarMeetup.State == 1) { __instance.Target = null; } } return true; } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static class Quest_ActiveEntryCount_Get_Patch { [HarmonyPrefix] public static bool Prefix(Quest __instance, ref int __result) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 if (!(__instance is ModQuestBase)) { return true; } int num = 0; for (int i = 0; i < __instance.Entries.Count; i++) { if ((int)__instance.Entries[i].State == 1) { num++; } } __result = num; return false; } } public class ModQuestBase : Quest { public ModQuestBase(IntPtr ptr) : base(ptr) { } public ModQuestBase() : base(ClassInjector.DerivedConstructorPointer()) { ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this); } } public class QuestHelperBase where T : Quest { protected readonly T _quest; protected string QuestTypeName => ((object)_quest).GetType().Name; public QuestHelperBase(T quest) { _quest = quest; } public void InitializeQuest(string title, int xp, bool expires = false, GameDateTime expiry = default(GameDateTime), bool trackOnBegin = true) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) ((Object)(object)_quest).name = QuestTypeName; ((Quest)_quest).Expires = expires; ((Quest)_quest).title = title; ((Quest)_quest).CompletionXP = xp; ((Quest)_quest).Description = ""; ((Quest)_quest).TrackOnBegin = trackOnBegin; ((Quest)_quest).autoInitialize = false; ((Quest)_quest).AutoCompleteOnAllEntriesComplete = false; ((Quest)_quest).AutoStartFirstEntry = false; ((Quest)_quest).ShouldSendExpiryReminder = false; ((Quest)_quest).ShouldSendExpiredNotification = false; if (expires) { ((Quest)_quest).Expiry = expiry; ((Quest)_quest).ExpiryVisibility = (EExpiryVisibility)0; } ((Quest)_quest).onQuestBegin = new UnityEvent(); ((Quest)_quest).onQuestEnd = new UnityEvent(); ((Quest)_quest).onTrackChange = new UnityEvent(); ((Quest)_quest).Entries = new List(); Transform questContainer = NetworkSingleton.Instance.QuestContainer; Transform val = ((questContainer != null) ? questContainer.GetChild(0) : null); if ((Object)(object)val != (Object)null) { ((Component)(object)_quest).transform.SetParent(val); } ((Quest)_quest).IconPrefab = EndGameQuest.MakeIcon(((Component)(object)_quest).transform); ((Quest)_quest).PoIPrefab = EndGameQuest.MakePOI(); ((Quest)_quest).SetGUID(Guid.NewGuid()); } public void InitializeQuestEntry(ref QuestEntry targetEntry, string name, string title, PoIConfig poiSettings, UnityAction completeCallback = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("QuestEntry_" + name); val.SetActive(false); val.transform.SetParent(((Component)(object)_quest).transform); targetEntry = val.AddComponent(); targetEntry.EntryTitle = title; targetEntry.ParentQuest = (Quest)(object)_quest; targetEntry.CompleteParentQuest = false; targetEntry.PoILocation = new GameObject(name + "Entry_POI").transform; if (poiSettings.usePoI) { if (poiSettings.useParent && (Object)(object)poiSettings.parent != (Object)null) { ((Component)targetEntry.PoILocation).transform.SetParent(poiSettings.parent); } else { ((Component)targetEntry.PoILocation).transform.SetParent(((Component)targetEntry).transform); } if (poiSettings.useTransformLocal) { ((Component)targetEntry.PoILocation).transform.localPosition = poiSettings.poiPosition; } else { ((Component)targetEntry.PoILocation).transform.position = poiSettings.poiPosition; } targetEntry.AutoUpdatePoILocation = true; } else { targetEntry.AutoCreatePoI = false; ((Component)targetEntry.PoILocation).transform.SetParent(((Component)targetEntry).transform); targetEntry.AutoUpdatePoILocation = false; } targetEntry.onComplete = new UnityEvent(); if ((Delegate)(object)completeCallback != (Delegate)null) { targetEntry.onComplete.AddListener(completeCallback); } targetEntry.state = (EQuestState)0; ((Quest)_quest).Entries.Add(targetEntry); } public void StartQuestFromEntry(QuestEntry startEntry) { ((Quest)_quest).SetupHUDUI(); ((Quest)_quest).SetupJournalEntry(); if ((Object)(object)((Quest)_quest).hudUI != (Object)null) { if ((Object)(object)((Quest)_quest).hudUI.MainLabel != (Object)null) { ((TMP_Text)((Quest)_quest).hudUI.MainLabel).text = ((Quest)_quest).title; } ((Component)((Quest)_quest).hudUI).gameObject.SetActive(true); } Enumerator enumerator = ((Quest)_quest).Entries.GetEnumerator(); while (enumerator.MoveNext()) { ((Component)enumerator.Current).gameObject.SetActive(true); } ((Quest)_quest).SetIsTracked(true); ((Quest)_quest).SetQuestState((EQuestState)1, true); startEntry.SetState((EQuestState)1, false); EndGameQuest.UpdateQuestMapLogo(startEntry); } } public class PoIConfig { public bool usePoI; public bool useParent; public bool useTransformLocal; public Transform parent; public Vector3 poiPosition; public PoIConfig(bool usePoI, bool useParent, bool useTransformLocal, Transform parent = null, Vector3 poiPosition = default(Vector3)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) this.usePoI = usePoI; this.useParent = useParent; this.useTransformLocal = useTransformLocal; this.parent = parent; this.poiPosition = poiPosition; } } public static class EndGameQuest { public static bool hasGeneratedDefeatEnforcerQuest = false; public static bool hasGeneratedManorQuest = false; public static bool hasGeneratedCarQuest = false; public static bool defeatEnforcerCompleted = false; public static int StageDeadDropsObserved = 0; public static int StageGatheringsDefeated = 0; public static NPC fixer; public static CartelGoon bossGoon; public static Quest_DefeatEnforcer activeDefeatEnforcerQuest = null; public static int fixerDiagIndex = 0; public static List> dialogOptions = new List> { new List { "I ain't having the Benzies come messing with my operation. Not here, not ever.", "First move, we gotta rattle them a little bit.", "Go make a couple of their dead drops disappear.", "After that, I'll set you up with a gig." }, new List { "The Benzies are getting bold. I can't have that.", "I'm about to show them how we do things out here. No games.", "Find their dead drops and clean 'em out. A couple of them going missing will send a message.", "Once you get that done, I'll tell you how to proceed." }, new List { "I don't want the Benzies to ruin my business here either.", "We need to send a message. They got to leave.", "They have been moving product through dead drops. You know what to do.", "Get started and I'll see how we can take down the Benzies..." } }; public static NPC ray; public static Quest_InfiltrateManor activeManorQuest = null; public static bool manorCompleted = false; public static int rayChoiceIndex = 0; public static readonly Vector3 standPos = new Vector3(70.96f, 1.46f, 16.03f); public static List manorGoons = new List(); public static List manorGoonGuids = new List(); public static List> dialogManorOptions = new List> { new List { "Look, the Benzies family have been here for longer than I can remember.", "Thomas Benzie owns the manor but you don't want to mess with him.", "Honestly, he is a criminal and overall thats bad for my business.", "Property values have been plummeting so I wouldn't mind him leaving..." }, new List { "Oh, Thomas? I don't know much about him. The Benzies family runs the town.", "He paid off a lot of people to get where he is today.", "Cops, lawyers, even some folks at Town Hall...", "He's been trying to get me to sell him my agency." }, new List { "His manor is a monument to his ego. He bought it just to show off.", "Don't go near the place. He has people guarding the property.", "You'll get yourself killed poking around.", "He's not someone you want to mess with." } }; public static NPC crankyFrank = null; public static NPC jeremy = null; public static Quest_CarMeetup activeCarMeetupQuest = null; public static Vector3 frankStandPos = new Vector3(-55.29f, -3.64f, 167.14f); public static Vector3 jeremyStandPos = new Vector3(69f, 5.93f, -119.09f); public static bool carMeetupCompleted = false; public static int frankDiagIndex = -1; public static int jeremyDiagIndex = -1; public static bool jeremyDialogueActive = false; public static List> frankDialogOptions = new List> { new List { "I've seen some green clunkers speeding down the street like they're running from something.", "They always pull up behind that obnoxious red building. Hard to miss.", "You should ask Jeremy. He might know who owns the cars." }, new List { "Bunch of damn green cars driving around late at night.", "They always cruise past here then turn down the alley next to that ugly red building.", "You know Jeremy, the Car Shop guy? He should know who they are." }, new List { "The only thing I've seen is some shiny green cars causing trouble after the sun goes down.", "Yeah, those punks always hide behind that red building over there.", "Go bug Jeremy, the car guy. He knows who's in those cars." } }; public static Quest_TrucedRecruits activeTruceIntro = null; public static Quest_TrueBrothers activeTrueBrothersQuest = null; public static bool trueBrothersCompleted = false; public static bool encounterActive = false; public static GameObject copBaseClone = null; public static Quest_AlliedSupplies activeAlliedSupplies = null; public static bool alliedSuppliesActive = false; public static CartelGoon alliedGuard = null; public static NetworkObject alliedVanObject = null; public static int guardChoiceIndex = -1; public static bool CanEvaluate() { if (!Singleton.Instance.IsOpen && !Singleton.Instance.IsOpen) { return PlayerSingleton.Instance.ActiveUIElementCount <= 0; } return false; } public static IEnumerator InitializeEndGameQuest() { yield return CartelEnforcer.Wait10; if (!CartelEnforcer.registered) { yield break; } CartelEnforcer.coros.Add(MelonCoroutines.Start(RandomManorGenerator.InitManorItemRef())); while (CartelEnforcer.registered) { yield return CartelEnforcer.Wait30; if (!CartelEnforcer.registered) { break; } if (CartelEnforcer.currentConfig.endGameQuest) { yield return (object)new WaitUntil(Func.op_Implicit((Func)CanEvaluate)); if (PreRequirementsMet() && !defeatEnforcerCompleted && !hasGeneratedDefeatEnforcerQuest && (Object)(object)activeDefeatEnforcerQuest == (Object)null) { hasGeneratedDefeatEnforcerQuest = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(GenDialogOption())); } if (PreRequirementsMet() && !manorCompleted && !hasGeneratedManorQuest && (Object)(object)activeManorQuest == (Object)null) { hasGeneratedManorQuest = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(GenManorDialogOption())); } bool flag = NetworkSingleton.Instance.CurrentTime >= 1559 && NetworkSingleton.Instance.CurrentTime <= 1801; if (CarQuestPreRequirementsMet() && !carMeetupCompleted && !hasGeneratedCarQuest && frankDiagIndex == -1 && flag && (Object)(object)activeCarMeetupQuest == (Object)null) { hasGeneratedCarQuest = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(GenFrankOption())); } else if (hasGeneratedCarQuest && !carMeetupCompleted && frankDiagIndex != -1 && !flag && (Object)(object)crankyFrank != (Object)null && (Object)(object)activeCarMeetupQuest == (Object)null) { hasGeneratedCarQuest = false; DialogueController component = ((Component)crankyFrank.DialogueHandler).gameObject.GetComponent(); CartelEnforcer.coros.Add(MelonCoroutines.Start(DisposeFrankChoice(component))); } } } } public static bool PreRequirementsMet() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 if (!InstanceFinder.IsServer) { return false; } if ((int)NetworkSingleton.Instance.Status != 2) { return false; } int num = 0; for (int i = 0; i < Customer.UnlockedCustomers.Count; i++) { if ((int)Customer.UnlockedCustomers[i].NPC.Region == 4) { num++; } } if (num < 1) { return false; } if ((int)NetworkSingleton.Instance.Rank < 4) { return false; } return true; } public static IEnumerator GenDialogOption() { NPC val = (NPC)(object)Object.FindObjectOfType(true); if ((Object)(object)val != (Object)null) { fixer = val; } DialogueController controller = ((Component)val.DialogueHandler).gameObject.GetComponent(); DialogueChoice val2 = new DialogueChoice(); val2.ChoiceText = "How do we get rid of the Benzies? (Bribe $5000)"; val2.Enabled = true; val2.onChoosen.AddListener(UnityAction.op_Implicit((Action)OnQuestChosenWrapped)); fixerDiagIndex = controller.AddDialogueChoice(val2, 0); void OnQuestChosenWrapped() { OnQuestChosen(controller); } yield break; } public static IEnumerator DisposeChoice(DialogueController controller) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { List choices = controller.Choices; choices.RemoveAt(fixerDiagIndex); controller.Choices = choices; } } public static void OnQuestChosen(DialogueController controller) { controller.handler.ContinueSubmitted(); if (NetworkSingleton.Instance.cashBalance >= 5000f) { NetworkSingleton.Instance.ChangeCashBalance(-5000f, true, false); MelonCoroutines.Start(DisposeChoice(controller)); MelonCoroutines.Start(EventInstructions(controller)); MelonCoroutines.Start(GenerateQuestState()); } else { controller.npc.PlayVO((EVOLineType)9, false); } } public static IEnumerator EventInstructions(DialogueController controller) { float lerpWait = Mathf.Lerp(10f, 5f, CartelEnforcer.currentConfig.endGameQuestMonologueSpeed); WaitForSeconds waitObj = new WaitForSeconds(lerpWait); List dialog = dialogOptions[Random.Range(0, dialogOptions.Count)]; controller.handler.WorldspaceRend.ShowText(dialog[0], lerpWait); yield return waitObj; if (!CartelEnforcer.registered) { yield break; } controller.npc.PlayVO((EVOLineType)19, false); controller.handler.WorldspaceRend.ShowText(dialog[1], lerpWait); yield return waitObj; if (CartelEnforcer.registered) { controller.handler.WorldspaceRend.ShowText(dialog[2], lerpWait); yield return waitObj; if (CartelEnforcer.registered) { controller.npc.PlayVO((EVOLineType)14, false); controller.handler.WorldspaceRend.ShowText(dialog[3], lerpWait); yield return waitObj; _ = CartelEnforcer.registered; } } } public static IEnumerator GenerateQuestState() { GameObject val = new GameObject(); activeDefeatEnforcerQuest = val.AddComponent(); val.SetActive(true); ((Behaviour)activeDefeatEnforcerQuest).enabled = true; activeDefeatEnforcerQuest.SetupSelf(); yield break; } public static IEnumerator QuestReward(CartelGoon goon) { yield return CartelEnforcer.Wait025; if (!CartelEnforcer.registered) { yield break; } ((NPC)goon).Inventory.Clear(); Func func = Registry.GetItem; ItemInstance defaultInstance = func("goldwatch").GetDefaultInstance(1); ((NPC)goon).Inventory.InsertItem(defaultInstance, true); ItemInstance defaultInstance2 = func("goldchain").GetDefaultInstance(1); ((NPC)goon).Inventory.InsertItem(defaultInstance2, true); ItemInstance defaultInstance3 = func("pumpshotgun").GetDefaultInstance(1); ((NPC)goon).Inventory.InsertItem(defaultInstance3, true); ItemInstance defaultInstance4 = func("shotgunshell").GetDefaultInstance(Random.Range(4, 10)); ((NPC)goon).Inventory.InsertItem(defaultInstance4, true); for (int i = 0; i < Customer.UnlockedCustomers.Count; i++) { yield return CartelEnforcer.Wait025; if (!CartelEnforcer.registered) { yield break; } if (Customer.UnlockedCustomers[i].NPC.RelationData.RelationDelta != 5f) { Customer.UnlockedCustomers[i].NPC.RelationData.ChangeRelationship(0.25f, true); } } if (InstanceFinder.IsServer) { Enumerator enumerator = Singleton.Instance.GetUnlockedRegions().GetEnumerator(); while (enumerator.MoveNext()) { EMapRegion unlmapReg = enumerator.Current; if ((int)unlmapReg != 0) { yield return CartelEnforcer.Wait5; if (!CartelEnforcer.registered) { yield break; } float influence = NetworkSingleton.Instance.Influence.GetRegionData(unlmapReg).Influence; if (influence > 0f) { float num = influence * 0.75f; float num2 = Mathf.Round((influence - num) * 100f) / 100f; NetworkSingleton.Instance.Influence.ChangeInfluence(unlmapReg, 0f - num2); } } } } float num3 = Mathf.Clamp(Singleton.Instance.internalLawIntensity * 0.25f, 0f, 2.5f); if (num3 != 0f) { Singleton.Instance.ChangeInternalIntensity(0f - num3); } yield return CartelEnforcer.Wait60; if (CartelEnforcer.registered && bossGoon.IsGoonSpawned) { ((NPC)bossGoon).NPCData.Health.MaxHealth = 100f; ((NPC)bossGoon).Health.Health = 100f; ((NPC)bossGoon).Movement.MoveSpeedMultiplier = 0.8f; ((Component)bossGoon).transform.localScale = new Vector3(1f, 1f, 1f); ((NPC)bossGoon).Behaviour.ScheduleManager.EnableSchedule(); ((Component)((NPC)bossGoon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); bossGoon.Despawn(); bossGoon = null; } } public static IEnumerator GenManorDialogOption() { NPC val = (NPC)(object)Object.FindObjectOfType(true); if ((Object)(object)val != (Object)null) { ray = val; } DialogueController controller = ((Component)val.DialogueHandler).gameObject.GetComponent(); DialogueChoice val2 = new DialogueChoice(); val2.ChoiceText = "Who owns that big manor? (Bribe $2500)"; val2.Enabled = true; val2.onChoosen.AddListener(UnityAction.op_Implicit((Action)OnQuestChosenWrapped)); rayChoiceIndex = controller.AddDialogueChoice(val2, 0); yield return null; void OnQuestChosenWrapped() { OnManorQuestChosen(controller); } } public static void OnManorQuestChosen(DialogueController controller) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) controller.handler.ContinueSubmitted(); bool flag = NetworkSingleton.Instance.CurrentTime >= 1815 && NetworkSingleton.Instance.CurrentTime <= 1858; bool num = NetworkSingleton.Instance.cashBalance >= 2500f; bool flag2 = Vector3.Distance(ray.CenterPoint, standPos) < 1f; if (num && flag && flag2) { NetworkSingleton.Instance.ChangeCashBalance(-2500f, true, false); MelonCoroutines.Start(DisposeRayChoice(controller)); MelonCoroutines.Start(EventManorInstructions(controller)); MelonCoroutines.Start(GenerateManorQuestState()); } else { controller.handler.WorldspaceRend.ShowText("Talk with me at the courthouse between 18:15 and 19:00.", 7f); controller.npc.PlayVO((EVOLineType)9, false); } } public static IEnumerator DisposeRayChoice(DialogueController controller) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { NPCEvent_LocationBasedAction val = ((Il2CppObjectBase)ray.Behaviour.ScheduleManager.ActiveAction).TryCast(); if ((Object)(object)val != (Object)null) { ((NPCEvent)val).EndTime = 2200; ((NPCEvent)val).Duration = 240; ((NPCAction)val).Start(); } ray.Behaviour.ScheduleManager.DisableSchedule(); List choices = controller.Choices; choices.RemoveAt(rayChoiceIndex); controller.Choices = choices; yield return null; } } public static IEnumerator EventManorInstructions(DialogueController controller) { float lerpWait = Mathf.Lerp(10f, 5f, CartelEnforcer.currentConfig.endGameQuestMonologueSpeed); WaitForSeconds waitObj = new WaitForSeconds(lerpWait); List dialog = dialogManorOptions[Random.Range(0, dialogManorOptions.Count)]; controller.npc.PlayVO((EVOLineType)14, false); controller.handler.WorldspaceRend.ShowText(dialog[0], lerpWait); yield return waitObj; if (!CartelEnforcer.registered) { yield break; } controller.npc.PlayVO((EVOLineType)5, false); controller.handler.WorldspaceRend.ShowText(dialog[1], lerpWait); yield return waitObj; if (!CartelEnforcer.registered) { yield break; } controller.handler.WorldspaceRend.ShowText(dialog[2], lerpWait); yield return waitObj; if (CartelEnforcer.registered) { controller.npc.PlayVO((EVOLineType)11, false); controller.handler.WorldspaceRend.ShowText(dialog[3], lerpWait); yield return waitObj; if (CartelEnforcer.registered) { yield return null; } } } public static IEnumerator GenerateManorQuestState() { GameObject val = new GameObject(); activeManorQuest = val.AddComponent(); val.SetActive(true); ((Behaviour)activeManorQuest).enabled = true; activeManorQuest.SetupSelf(); yield return null; } public static IEnumerator GenRaySecondDialog(Action cb) { DialogueController controller = ((Component)ray.DialogueHandler).gameObject.GetComponent(); DialogueChoice val = new DialogueChoice(); string text = "Is there any way I can get in the Manor?"; val.ChoiceText = text ?? ""; val.Enabled = true; val.onChoosen.AddListener(UnityAction.op_Implicit((Action)OnQuestChosenWrapped)); rayChoiceIndex = controller.AddDialogueChoice(val, 0); yield return null; void OnQuestChosenWrapped() { OnSecondDialogChosen(controller, cb); } } public static void OnSecondDialogChosen(DialogueController controller, Action cb) { controller.handler.ContinueSubmitted(); MelonCoroutines.Start(DisposeRaySecondChoice(controller)); MelonCoroutines.Start(PlaySecondRayDialog(controller, cb)); } public static IEnumerator DisposeRaySecondChoice(DialogueController controller) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { List choices = controller.Choices; choices.RemoveAt(rayChoiceIndex); controller.Choices = choices; yield return CartelEnforcer.Wait30; if (CartelEnforcer.registered) { CartelEnforcer.coros.Add(MelonCoroutines.Start(ResetRayAFK())); yield return null; } } } public static IEnumerator ResetRayAFK() { NPCEvent_LocationBasedAction val = ((Il2CppObjectBase)ray.Behaviour.ScheduleManager.ActiveAction).TryCast(); if ((Object)(object)val != (Object)null) { ((NPCEvent)val).EndTime = 1800; ((NPCEvent)val).Duration = 60; } ray.Behaviour.ScheduleManager.EnableSchedule(); yield return null; } public static IEnumerator PlaySecondRayDialog(DialogueController controller, Action cb) { float lerpWait = Mathf.Lerp(10f, 5f, CartelEnforcer.currentConfig.endGameQuestMonologueSpeed); WaitForSeconds waitObj = new WaitForSeconds(lerpWait); float lerpWaitLong = Mathf.Lerp(15f, 7f, CartelEnforcer.currentConfig.endGameQuestMonologueSpeed); WaitForSeconds waitObjLong = new WaitForSeconds(lerpWaitLong); controller.npc.PlayVO((EVOLineType)17, false); controller.handler.WorldspaceRend.ShowText("I don't think so. The whole place is fenced off.", lerpWait); yield return waitObj; if (!CartelEnforcer.registered) { yield break; } controller.npc.PlayVO((EVOLineType)19, false); controller.handler.WorldspaceRend.ShowText("If you manage to make it over the fence, there is a way for me to get you inside.", lerpWaitLong); yield return waitObjLong; if (!CartelEnforcer.registered) { yield break; } controller.handler.WorldspaceRend.ShowText("Here, take my master key. It's from back when the Manor was built.", lerpWait + 2f); yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { yield break; } controller.npc.PlayVO((EVOLineType)14, false); controller.npc.SetAnimationTrigger("GrabItem"); yield return waitObj; if (CartelEnforcer.registered) { controller.handler.WorldspaceRend.ShowText("It won't work on the main entrance so try the back door.", 5f); yield return waitObj; if (CartelEnforcer.registered) { cb?.Invoke(); yield return null; } } } public static IEnumerator QuestManorReward() { yield return CartelEnforcer.Wait025; if (!CartelEnforcer.registered) { yield break; } for (int i = 0; i < Business.Businesses.Count; i++) { yield return CartelEnforcer.Wait025; if (!CartelEnforcer.registered) { yield break; } ((Property)Business.Businesses[i]).Price = ((Property)Business.Businesses[i]).Price * 0.85f; } for (int i = 0; i < Property.Properties.Count; i++) { yield return CartelEnforcer.Wait025; if (!CartelEnforcer.registered) { yield break; } Property.Properties[i].Price = Property.Properties[i].Price * 0.85f; } if (InstanceFinder.IsServer) { Enumerator enumerator = Singleton.Instance.GetUnlockedRegions().GetEnumerator(); while (enumerator.MoveNext()) { EMapRegion unlmapReg = enumerator.Current; if ((int)unlmapReg != 0) { yield return CartelEnforcer.Wait5; if (!CartelEnforcer.registered) { yield break; } float influence = NetworkSingleton.Instance.Influence.GetRegionData(unlmapReg).Influence; if (influence > 0f) { float num = influence * 0.85f; float num2 = Mathf.Round((influence - num) * 100f) / 100f; NetworkSingleton.Instance.Influence.ChangeInfluence(unlmapReg, 0f - num2); } } } } yield return null; } public static bool CarQuestPreRequirementsMet() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 if (!InstanceFinder.IsServer) { return false; } if ((int)NetworkSingleton.Instance.Status != 2) { return false; } int num = 0; for (int i = 0; i < Customer.UnlockedCustomers.Count; i++) { if ((int)Customer.UnlockedCustomers[i].NPC.Region == 3) { num++; } } if (num < 3) { return false; } if ((int)NetworkSingleton.Instance.Rank < 3) { return false; } return true; } public static IEnumerator GenFrankOption() { if ((Object)(object)crankyFrank == (Object)null) { NPC val = (NPC)(object)Object.FindObjectOfType(true); if ((Object)(object)val != (Object)null) { crankyFrank = val; } } DialogueController controller = ((Component)crankyFrank.DialogueHandler).gameObject.GetComponent(); DialogueChoice val2 = new DialogueChoice(); val2.ChoiceText = "Have you seen any Benzies around here? (Bribe $3500)"; val2.Enabled = true; val2.onChoosen.AddListener(UnityAction.op_Implicit((Action)OnQuestChosenWrapped)); frankDiagIndex = controller.AddDialogueChoice(val2, 0); yield return null; void OnQuestChosenWrapped() { OnCarQuestChosen(controller); } } public static void OnCarQuestChosen(DialogueController controller) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) controller.handler.ContinueSubmitted(); bool flag = NetworkSingleton.Instance.CurrentTime >= 1600 && NetworkSingleton.Instance.CurrentTime <= 1800; bool num = NetworkSingleton.Instance.cashBalance >= 3500f; bool flag2 = Vector3.Distance(crankyFrank.CenterPoint, frankStandPos) < 0.7f; if (num && flag && flag2) { NetworkSingleton.Instance.ChangeCashBalance(-3500f, true, false); MelonCoroutines.Start(DisposeFrankChoice(controller)); MelonCoroutines.Start(EventFrankInstructions(controller)); } else { controller.handler.WorldspaceRend.ShowText("Meet me at the north waterfront between 16:00 and 18:00.", 7f); controller.npc.PlayVO((EVOLineType)9, false); } } public static IEnumerator DisposeFrankChoice(DialogueController controller) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { if (frankDiagIndex != -1) { List choices = controller.Choices; choices.RemoveAt(frankDiagIndex); controller.Choices = choices; frankDiagIndex = -1; } yield return null; } } public static IEnumerator EventFrankInstructions(DialogueController controller) { controller.npc.Behaviour.ScheduleManager.DisableSchedule(); float lerpWait = Mathf.Lerp(11f, 6f, CartelEnforcer.currentConfig.endGameQuestMonologueSpeed); WaitForSeconds waitObj = new WaitForSeconds(lerpWait); List dialog = frankDialogOptions[Random.Range(0, frankDialogOptions.Count)]; controller.npc.PlayVO((EVOLineType)10, false); controller.handler.WorldspaceRend.ShowText(dialog[0], lerpWait); yield return waitObj; if (!CartelEnforcer.registered) { yield break; } controller.npc.PlayVO((EVOLineType)9, false); controller.handler.WorldspaceRend.ShowText(dialog[1], lerpWait + 2f); controller.npc.Movement.FacePoint(new Vector3(-32.68f, -2.54f, 168.73f), 1f); yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { yield break; } float num = default(float); controller.npc.Movement.FacePoint(PlayerManager.GetClosestPlayer(controller.npc.CenterPoint, ref num, (List)null).CenterPointTransform.position, 1f); yield return waitObj; if (CartelEnforcer.registered) { controller.npc.PlayVO((EVOLineType)19, false); controller.handler.WorldspaceRend.ShowText(dialog[2], lerpWait); yield return waitObj; if (CartelEnforcer.registered) { controller.npc.Behaviour.ScheduleManager.EnableSchedule(); MelonCoroutines.Start(GenerateCarQuestState()); yield return null; } } } public static IEnumerator GenerateCarQuestState() { GameObject val = new GameObject(); activeCarMeetupQuest = val.AddComponent(); val.SetActive(true); ((Behaviour)activeCarMeetupQuest).enabled = true; activeCarMeetupQuest.SetupSelf(); yield return null; } public static IEnumerator GenJeremyOption(Action cb) { if ((Object)(object)jeremy == (Object)null) { NPC val = (NPC)(object)Object.FindObjectOfType(true); if ((Object)(object)val != (Object)null) { jeremy = val; } } DialogueController controller = ((Component)jeremy.DialogueHandler).gameObject.GetComponent(); DialogueChoice val2 = new DialogueChoice(); string text = "Who is buying green cars from you?"; val2.ChoiceText = text + " (Bribe $6000)"; val2.Enabled = true; val2.onChoosen.AddListener(UnityAction.op_Implicit((Action)OnQuestChosenWrapped)); jeremyDiagIndex = controller.AddDialogueChoice(val2, 0); yield return null; void OnQuestChosenWrapped() { OnJeremyOptionSelected(controller, cb); } } public static void OnJeremyOptionSelected(DialogueController controller, Action cb) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) controller.handler.ContinueSubmitted(); Transform child = ((Component)controller.npc.Behaviour.ScheduleManager).transform.GetChild(0); if (child != null) { GameObject gameObject = ((Component)child).gameObject; if (gameObject != null) { gameObject.SetActive(false); } } bool flag = NetworkSingleton.Instance.CurrentTime >= 2059 && NetworkSingleton.Instance.CurrentTime <= 2359; bool flag2 = (int)Player.Local.CrimeData.CurrentPursuitLevel > 0; bool num = NetworkSingleton.Instance.cashBalance >= 6000f; bool flag3 = Vector3.Distance(jeremy.CenterPoint, jeremyStandPos) < 10f; if (num && flag && flag3 && !flag2) { NetworkSingleton.Instance.ChangeCashBalance(-6000f, true, false); MelonCoroutines.Start(DisposeJeremyChoice(controller)); MelonCoroutines.Start(JeremyDialogue(controller, cb)); return; } if (flag2) { controller.handler.WorldspaceRend.ShowText("Get out of here! I don't want police at my house!", 8f); controller.npc.PlayVO((EVOLineType)10, false); controller.npc.Avatar.EmotionManager.AddEmotionOverride("Annoyed", "product_rejected", 8f, 1); } else { controller.handler.WorldspaceRend.ShowText("Talk to me after 21:00 at my house.", 8f); controller.npc.PlayVO((EVOLineType)9, false); } Transform child2 = ((Component)controller.npc.Behaviour.ScheduleManager).transform.GetChild(0); if (child2 != null) { GameObject gameObject2 = ((Component)child2).gameObject; if (gameObject2 != null) { gameObject2.SetActive(true); } } } public static IEnumerator DisposeJeremyChoice(DialogueController controller) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { if (jeremyDiagIndex != -1) { List choices = controller.Choices; choices.RemoveAt(jeremyDiagIndex); controller.Choices = choices; jeremyDiagIndex = -1; } yield return null; } } public static IEnumerator JeremyDialogue(DialogueController controller, Action cb) { jeremyDialogueActive = true; float lerpWait = Mathf.Lerp(10f, 5f, CartelEnforcer.currentConfig.endGameQuestMonologueSpeed); WaitForSeconds waitObj = new WaitForSeconds(lerpWait); controller.npc.PlayVO((EVOLineType)3, false); controller.handler.WorldspaceRend.ShowText("You got to be careful now. The Benzies Cartel is no joke.", lerpWait); yield return waitObj; if (!CartelEnforcer.registered) { yield break; } controller.npc.PlayVO((EVOLineType)19, false); controller.handler.WorldspaceRend.ShowText("Thomas Benzie has been putting in alot of orders for those Green SUVs.", lerpWait); yield return waitObj; if (!CartelEnforcer.registered) { yield break; } controller.npc.PlayVO((EVOLineType)14, false); controller.handler.WorldspaceRend.ShowText("I don't really ask around. He always pays more than the retail price.", lerpWait); yield return waitObj; if (!CartelEnforcer.registered) { yield break; } jeremyDialogueActive = false; cb?.Invoke(); Transform child = ((Component)controller.npc.Behaviour.ScheduleManager).transform.GetChild(0); if (child != null) { GameObject gameObject = ((Component)child).gameObject; if (gameObject != null) { gameObject.SetActive(true); } } yield return null; } public static IEnumerator QuestCarMeetupReward() { yield return CartelEnforcer.Wait5; if (InstanceFinder.IsServer) { Enumerator enumerator = Singleton.Instance.GetUnlockedRegions().GetEnumerator(); while (enumerator.MoveNext()) { EMapRegion unlmapReg = enumerator.Current; if ((int)unlmapReg != 0) { yield return CartelEnforcer.Wait5; if (!CartelEnforcer.registered) { yield break; } float influence = NetworkSingleton.Instance.Influence.GetRegionData(unlmapReg).Influence; if (influence > 0f) { float num = influence * 0.9f; float num2 = Mathf.Round((influence - num) * 100f) / 100f; NetworkSingleton.Instance.Influence.ChangeInfluence(unlmapReg, 0f - num2); } } } } yield return null; } public static IEnumerator SetupTruceIntroQuest() { GameObject val = new GameObject(); activeTruceIntro = val.AddComponent(); val.SetActive(true); ((Behaviour)activeTruceIntro).enabled = true; activeTruceIntro.SetupSelf(); yield return null; } public static IEnumerator SetupTrueBrothersQuest(CartelGoon spawnedGoon) { GameObject val = new GameObject(); activeTrueBrothersQuest = val.AddComponent(); activeTrueBrothersQuest.startGoon = spawnedGoon; val.SetActive(true); ((Behaviour)activeTrueBrothersQuest).enabled = true; activeTrueBrothersQuest.SetupSelf(); if (encounterActive) { encounterActive = false; } yield break; } public static bool TrueBrothersQuestPreRequirementsMet() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 if (!InstanceFinder.IsServer) { return false; } if ((int)NetworkSingleton.Instance.Status != 1) { return false; } int num = 0; for (int i = 0; i < Customer.UnlockedCustomers.Count; i++) { if ((int)Customer.UnlockedCustomers[i].NPC.Region == 4) { num++; } } if (num < 4) { return false; } return true; } public static bool CanStartConversate() { if (!Singleton.Instance.IsOpen && !Singleton.Instance.IsOpen) { return PlayerSingleton.Instance.ActiveUIElementCount <= 0; } return false; } public static IEnumerator SummonConversateGoon() { Vector3 val = Vector3.zero; int num = 8; int num2 = 0; do { if (!CartelEnforcer.registered) { yield break; } if (num2 == num) { break; } Vector3 onUnitSphere = Random.onUnitSphere; onUnitSphere.y = 0f; ((Vector3)(ref onUnitSphere)).Normalize(); float num3 = Random.Range(20f, 32f); val = Player.Local.CenterPointTransform.position + onUnitSphere * num3; num2++; } while (Player.Local.IsPointVisibleToPlayer(val, 30f, 5f)); if (val == Vector3.zero) { yield break; } CartelGoon spawnedGoon = null; encounterActive = true; spawnedGoon = NetworkSingleton.Instance.GoonPool.SpawnGoon(val); ((Component)((NPC)spawnedGoon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)spawnedGoon).Behaviour.ScheduleManager.DisableSchedule(); ((NPC)spawnedGoon).Movement.SpeedController.AddSpeedControl(new SpeedControl("combat", 5, Quest_TrueBrothers.startGoonMoveSpeed)); DialogueController controller = ((Component)((NPC)spawnedGoon).DialogueHandler).gameObject.GetComponent(); GreetingOverride greeting = new GreetingOverride(); greeting.ShouldShow = true; greeting.Greeting = "We need your help at the northern waterfront!"; greeting.VOType = (EVOLineType)1; greeting.PlayVO = true; controller.AddGreetingOverride(greeting); DialogueChoice val2 = new DialogueChoice(); string text = "Accept Quest"; val2.ChoiceText = text ?? ""; val2.Enabled = true; DialogueChoice val3 = new DialogueChoice(); string text2 = "Refuse Quest"; val3.ChoiceText = text2 ?? ""; val3.Enabled = true; bool accepted = false; bool refused = false; val2.onChoosen.AddListener(UnityAction.op_Implicit((Action)AcceptChosen)); controller.AddDialogueChoice(val2, 0); val3.onChoosen.AddListener(UnityAction.op_Implicit((Action)RefuseChosen)); controller.AddDialogueChoice(val3, 0); int maxTraverseTime = 60; int traverseTime = 0; bool playerConversated = false; while (true) { yield return CartelEnforcer.Wait1; if (!CartelEnforcer.registered) { yield break; } if (traverseTime >= maxTraverseTime) { break; } traverseTime++; if ((Object)(object)spawnedGoon == (Object)null || ((NPC)spawnedGoon).Health.IsDead || ((NPC)spawnedGoon).Health.IsKnockedOut || (Object)(object)((NPC)spawnedGoon).Behaviour.activeBehaviour == (Object)(object)((NPC)spawnedGoon).Behaviour.CombatBehaviour) { break; } if (playerConversated) { ((NPC)spawnedGoon).Movement.EndSetDestination((WalkResult)4); ((NPC)spawnedGoon).Movement.FacePoint(Player.Local.CenterPointTransform.position, 0.5f); ((NPC)spawnedGoon).Movement.PauseMovement(); controller.StartGenericDialogue(false); break; } if (Vector3.Distance(Player.Local.CenterPointTransform.position, ((NPC)spawnedGoon).CenterPoint) < 3f) { yield return (object)new WaitUntil(Func.op_Implicit((Func)CanStartConversate)); playerConversated = true; continue; } if (!((NPC)spawnedGoon).Movement.HasDestination) { ((NPC)spawnedGoon).Movement.SetDestination(Player.Local.CenterPointTransform); } if (((NPC)spawnedGoon).Movement.IsPaused) { ((NPC)spawnedGoon).Movement.ResumeMovement(); } } bool shouldDespawn = false; if (traverseTime >= maxTraverseTime) { controller.Choices = new List(); if (controller.GreetingOverrides.Contains(greeting)) { controller.GreetingOverrides.Remove(greeting); } ((Component)((NPC)spawnedGoon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); yield return CartelEnforcer.Wait10; if (!CartelEnforcer.registered) { yield break; } if (!CartelEnforcer.isSaving) { AlliedExtension.alliedQuests.daysPassedSinceEncounter = Mathf.Clamp(AlliedExtension.alliedQuests.daysPassedSinceEncounter - 2, 0, 7); } shouldDespawn = true; } else if (playerConversated) { yield return (object)new WaitUntil(Func.op_Implicit((Func)(() => accepted || refused))); if (!CartelEnforcer.registered) { yield break; } if (accepted) { ((NPC)spawnedGoon).Movement.SetDestination(Quest_TrueBrothers.followDestination); ((NPC)spawnedGoon).Movement.ResumeMovement(); controller.handler.WorldspaceRend.ShowText("Follow me", 6f); } if (refused) { ((Component)((NPC)spawnedGoon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); yield return CartelEnforcer.Wait10; if (!CartelEnforcer.registered) { yield break; } shouldDespawn = true; } if (!CartelEnforcer.isSaving) { AlliedExtension.alliedQuests.daysPassedSinceEncounter = 0; } } else if ((Object)(object)spawnedGoon == (Object)null || ((NPC)spawnedGoon).Health.IsDead || ((NPC)spawnedGoon).Health.IsKnockedOut || (Object)(object)((NPC)spawnedGoon).Behaviour.activeBehaviour == (Object)(object)((NPC)spawnedGoon).Behaviour.CombatBehaviour) { controller.Choices = new List(); if (controller.GreetingOverrides.Contains(greeting)) { controller.GreetingOverrides.Remove(greeting); } yield return CartelEnforcer.Wait10; if (!CartelEnforcer.registered) { yield break; } if (!CartelEnforcer.isSaving) { AlliedExtension.alliedQuests.daysPassedSinceEncounter = 0; } shouldDespawn = true; } if (shouldDespawn) { ((NPC)spawnedGoon).Behaviour.ScheduleManager.EnableSchedule(); if (!((Component)((NPC)spawnedGoon).Behaviour.ScheduleManager.ActionList[0]).gameObject.activeSelf) { ((Component)((NPC)spawnedGoon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); } spawnedGoon.Despawn(); spawnedGoon = null; encounterActive = false; } void AcceptChosen() { controller.npc.PlayVO((EVOLineType)14, false); controller.handler.WorldspaceRend.ShowText("Follow me", 6f); controller.handler.ContinueSubmitted(); accepted = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(SetupTrueBrothersQuest(spawnedGoon))); controller.Choices = new List(); if (controller.GreetingOverrides.Contains(greeting)) { controller.GreetingOverrides.Remove(greeting); } } void RefuseChosen() { controller.npc.PlayVO((EVOLineType)9, false); controller.handler.WorldspaceRend.ShowText("God damnit!", 6f); controller.handler.ContinueSubmitted(); refused = true; controller.Choices = new List(); if (controller.GreetingOverrides.Contains(greeting)) { controller.GreetingOverrides.Remove(greeting); } } } public static IEnumerator CleanupTrueBrothersQuest() { yield return CartelEnforcer.Wait10; if ((int)((Quest)activeTrueBrothersQuest).State == 2) { CartelEnforcer.coros.Add(MelonCoroutines.Start(RewardTrueBrothersQuest())); } yield return CartelEnforcer.Wait30; if (!CartelEnforcer.registered) { yield break; } foreach (CartelGoon alliedGoon in activeTrueBrothersQuest.alliedGoons) { ((Component)((NPC)alliedGoon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); ((NPC)alliedGoon).Behaviour.ScheduleManager.EnableSchedule(); ((NPC)alliedGoon).Movement.SpeedController.RemoveSpeedControl("combat"); alliedGoon.Despawn(); } foreach (GameObject go in activeTrueBrothersQuest.spawnedDecor) { if ((Object)(object)go != (Object)null) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } Object.Destroy((Object)(object)go); } } foreach (PoliceOfficer ambushCop in activeTrueBrothersQuest.ambushCops) { if ((Object)(object)((Component)ambushCop).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)ambushCop).gameObject); } } if ((Object)(object)activeTrueBrothersQuest.spawnedVehicle != (Object)null && (Object)(object)((Component)activeTrueBrothersQuest.spawnedVehicle).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)activeTrueBrothersQuest.spawnedVehicle).gameObject); } activeTrueBrothersQuest.startGoon = null; activeTrueBrothersQuest.destinationStorage = null; activeTrueBrothersQuest.spawnedVehicle = null; activeTrueBrothersQuest.brickBase = null; activeTrueBrothersQuest.alliedGoons.Clear(); activeTrueBrothersQuest.ambushCops.Clear(); activeTrueBrothersQuest.spawnedDecor.Clear(); activeTrueBrothersQuest.spawnedBrickPiles.Clear(); } public static IEnumerator RewardTrueBrothersQuest() { NetworkSingleton.Instance.CreateOnlineTransaction("Business Investment", 30000f, 1f, string.Empty); yield return CartelEnforcer.Wait2; string text = "Your help has been very valuable. If you need to launder some cash, I can help with bigger batches. But for now, I've wired you $30000 for your trouble."; Thomas val = Object.FindObjectOfType(true); if (!((Object)(object)val == (Object)null)) { ((NPC)val).MSGConversation.SendMessage(new Message(text, (ESenderType)1, true, -1), true, true); } } public static IEnumerator ReplicateCopNPC() { NetworkManager netManager = Object.FindObjectOfType(true); PoliceOfficer val = Object.FindObjectOfType(); AvatarSettings copySettings = ((NPC)val).Avatar.CurrentSettings; if (!((Object)(object)val == (Object)null)) { GameObject obj = ((Component)val).gameObject; obj.SetActive(false); new List(); new WaitForEndOfFrame(); GameObject val2 = (copBaseClone = Object.Instantiate(obj)); val2.transform.position = Vector3.zero; val2.transform.rotation = Quaternion.identity; NPC npc = val2.GetComponent(); NetworkObject newNob = val2.GetComponent(); PoliceOfficer offc = val2.GetComponent(); offc.AutoDeactivate = false; ((Object)val2).name = "RuntimeOfficer"; yield return MelonCoroutines.Start(NPCInitHelper.InitiateClone(newNob, netManager)); npc.NPCData.BasicInfo.ID = "officerPrefab"; if (!NPCManager.NPCRegistry.Contains(npc)) { NPCManager.NPCRegistry.Add(npc); } npc.Avatar.LoadAvatarSettings(copySettings); offc.PursuitBehaviour.arrestingEnabled = false; try { netManager.ServerManager.Spawn(newNob, (NetworkConnection)null, default(Scene)); } catch (Exception) { } ((NPC)offc).Behaviour.ScheduleManager.DisableSchedule(); ((NPC)offc).Movement.PauseMovement(); obj.SetActive(true); } } public static IEnumerator SetupTruceSuppliesQuest() { GameObject val = new GameObject(); activeAlliedSupplies = val.AddComponent(); val.SetActive(true); ((Behaviour)activeAlliedSupplies).enabled = true; activeAlliedSupplies.SetupSelf(); yield return null; } public static IEnumerator CleanupTruceSuppliesQuest(SupplyLocation location) { if (location.Type == ESupplyType.Barrel) { foreach (GameObject barrelObject in location.BarrelObjects) { InteractableObject component = barrelObject.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } } yield return CartelEnforcer.Wait30; if (!CartelEnforcer.registered) { yield break; } if (location.Type == ESupplyType.Van) { if ((Object)(object)alliedVanObject != (Object)null) { Object.Destroy((Object)(object)((Component)alliedVanObject).gameObject); } alliedVanObject = null; } if ((Object)(object)alliedGuard != (Object)null) { ((NPC)alliedGuard).Behaviour.ScheduleManager.EnableSchedule(); ((Component)((NPC)alliedGuard).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); ((NPC)alliedGuard).Movement.SpeedController.RemoveSpeedControl("combat"); alliedGuard.Despawn(); alliedGuard = null; } if (location.ID == "SUPPLY_MANOR") { for (int i = 0; i < Property.Properties.Count; i++) { if (!(Property.Properties[i].propertyCode == "manor")) { continue; } ManorGate componentInChildren = ((Component)Property.Properties[i]).gameObject.GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null) { Transform val = ((Component)Property.Properties[i]).transform.Find("Manor Gate"); if ((Object)(object)val != (Object)null) { ManorGate component2 = ((Component)val).gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.SetEnterable(false); } } } else { componentInChildren.SetEnterable(false); } } } if (!Singleton.Instance.IsSaving && !CartelEnforcer.isSaving) { AlliedExtension.alliedQuests.hoursUntilNextSupplies = AlliedExtension.alliedConfig.SupplyQuestCooldownHours; } else { yield return (object)new WaitUntil((Func)(object)Object.op_Implicit(!Singleton.Instance.IsSaving && !CartelEnforcer.isSaving)); AlliedExtension.alliedQuests.hoursUntilNextSupplies = AlliedExtension.alliedConfig.SupplyQuestCooldownHours; } alliedSuppliesActive = false; yield return null; } public static void UpdateQuestMapLogo(QuestEntry entry) { CartelEnforcer.coros.Add(MelonCoroutines.Start(WaitQuestUI(entry))); } public static IEnumerator WaitQuestUI(QuestEntry entry) { yield return (object)new WaitUntil(Func.op_Implicit((Func)EntryPoIExists)); if ((Object)(object)entry.PoIIcon == (Object)null) { entry.PoIIcon = Object.Instantiate(((Component)entry.ParentQuest.IconPrefab).gameObject, (Transform)(object)entry.PoI.IconContainer).GetComponent(); entry.PoIIcon.sizeDelta = new Vector2(20f, 20f); } if ((Object)(object)entry.PoI != (Object)null && (Object)(object)entry.PoI.IconContainer != (Object)null) { Transform val = ((Transform)entry.PoI.IconContainer).Find("Shade"); if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.SetActive(false); } } bool EntryPoIExists() { if ((Object)(object)entry.PoI != (Object)null && (Object)(object)entry.PoI.IconContainer != (Object)null) { return entry.PoI.UISetup; } return false; } } public static RectTransform MakeIcon(Transform parent) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(((POI)NetworkSingleton.Instance.PotentialCustomerPoIPrefab).UIPrefab); Transform obj = ((Component)val.GetComponent()).transform.Find("Area"); GameObject val2 = new GameObject("BenziesLogoQuest"); RectTransform result = val2.AddComponent(); GameObject obj2 = Object.Instantiate(((Component)obj).gameObject); RectTransform component = obj2.GetComponent(); ((Transform)component).SetParent(val2.transform); ((Transform)component).localScale = Vector3.one; ((Transform)component).localPosition = Vector3.one; ((Transform)component).rotation = Quaternion.identity; component.sizeDelta = new Vector2(25f, 25f); Object.Destroy((Object)(object)val); ((Graphic)obj2.GetComponent()).color = new Color(0.15f, 0.7f, 0.15f, 0.5f); GameObject val3 = new GameObject("Image"); val3.transform.SetParent(val2.transform); val3.transform.localScale = Vector3.one; val3.transform.localPosition = Vector3.one; val3.transform.rotation = Quaternion.identity; val3.AddComponent().sprite = InterceptEvent.benziesLogo; val3.GetComponent().sizeDelta = new Vector2(20f, 20f); val2.transform.SetParent(parent, false); return result; } public static GameObject MakePOI() { return Quest.Quests[0].PoIPrefab; } } [RegisterTypeInIl2Cpp] public class Quest_InfiltrateManor : ModQuestBase { protected InfiltrateManorHelper _helper; public string title; public string Subtitle; private float questDifficultyScalar = 1f; private int manorGoonsAlive = 4; private readonly List forestSearchLocs = new List { new Vector3(164.96f, 3.1f, -32.65f), new Vector3(151.45f, 3.2f, -35.21f), new Vector3(139.41f, 1.96f, -45.71f), new Vector3(135.26f, 2.72f, -66.56f) }; private readonly Dictionary roomsPositions = new Dictionary { { new Vector3(166.58f, 15.61f, -52.99f), false }, { new Vector3(160.65f, 15.61f, -52.97f), false }, { new Vector3(160.65f, 15.61f, -61f), false }, { new Vector3(166.58f, 15.61f, -61f), false } }; public bool hasSavedCombatVariables; public float GiveUpRange; public int GiveUpAfterSuccessfulHits; public float DefaultSearchTime; private bool forestGoonSpawned; private int forestPosSearched; private int roomsVisited; public bool isJukeboxPlaying; public QuestEntry QuestEntry_InvestigateWoods; private UnityAction _investigateAction; public QuestEntry QuestEntry_ReturnToRay; private UnityAction _returnToRayAction; public QuestEntry QuestEntry_WaitForNight; private UnityAction _waitForNightAction; public QuestEntry QuestEntry_BreakIn; private UnityAction _breakInAction; public QuestEntry QuestEntry_DefeatManorGoons; private UnityAction _defeatGoonsAction; public QuestEntry QuestEntry_SearchResidence; private UnityAction _searchAction; public QuestEntry QuestEntry_EscapeManor; public Quest_InfiltrateManor(IntPtr ptr) : base(ptr) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) _helper = new InfiltrateManorHelper(this); } public Quest_InfiltrateManor() : base(ClassInjector.DerivedConstructorPointer()) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this); } public override void Complete(bool network = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 try { if ((int)((Quest)this).State != 2) { if (InstanceFinder.IsServer && !Singleton.Instance.IsLoading) { NetworkSingleton.Instance.AddXP(((Quest)this).CompletionXP); } ((Quest)this).SetQuestState((EQuestState)2, false); NetworkSingleton.Instance.PlayCompleteQuestSound(); ((Quest)this).End(); } } catch (Exception) { throw; } } public override void Fail(bool network = true) { try { ((Quest)this).SetQuestState((EQuestState)3, false); ((Quest)this).End(); } catch (Exception) { throw; } } public override void End() { try { if ((Object)(object)((Quest)this).hudUI != (Object)null) { ((Quest)this).hudUI.Complete(); } TimeManager instance = NetworkSingleton.Instance; if ((Object)(object)instance == (Object)null) { return; } Action action = ((Quest)this).OnMinPass; instance.onHourPass -= Action.op_Implicit((Action)HourPass); instance.onMinutePass.Remove(Action.op_Implicit(action)); } catch (Exception) { throw; } ((Component)this).gameObject.SetActive(false); } public void SetupSelf() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) float num = 0f; Enumerator enumerator = NetworkSingleton.Instance.Influence.regionInfluence.GetEnumerator(); while (enumerator.MoveNext()) { RegionInfluenceData current = enumerator.Current; num += current.Influence; } float num2 = num / (float)NetworkSingleton.Instance.Influence.regionInfluence.Count; questDifficultyScalar = 1f + num2; _helper.InitializeQuest("Infiltrate Manor", Mathf.RoundToInt(600f * questDifficultyScalar)); _investigateAction = UnityAction.op_Implicit((Action)OnInvestigateComplete); _helper.InitializeQuestEntry(ref QuestEntry_InvestigateWoods, "InvestigateWoods", "Investigate the hillside forest near Manor (0/4)", new PoIConfig(usePoI: true, useParent: false, useTransformLocal: false, null, new Vector3(164.96f, 3.1f, -32.65f)), _investigateAction); _returnToRayAction = UnityAction.op_Implicit((Action)OnReturnToRayComplete); _helper.InitializeQuestEntry(ref QuestEntry_ReturnToRay, "ReturnToRay", "Return to Ray and ask for more information", new PoIConfig(usePoI: true, useParent: false, useTransformLocal: false, null, new Vector3(77.3f, 1.46f, -12.85f)), _returnToRayAction); _waitForNightAction = UnityAction.op_Implicit((Action)OnWaitForNightComplete); _helper.InitializeQuestEntry(ref QuestEntry_WaitForNight, "WaitForNight", "Wait for night time (22:00)", new PoIConfig(usePoI: false, useParent: false, useTransformLocal: false), _waitForNightAction); _breakInAction = UnityAction.op_Implicit((Action)OnBreakInComplete); _helper.InitializeQuestEntry(ref QuestEntry_BreakIn, "BreakIn", "Break into Manor through the back door", new PoIConfig(usePoI: true, useParent: false, useTransformLocal: false, null, new Vector3(163.37f, 11.86f, -50.12f)), _breakInAction); _defeatGoonsAction = UnityAction.op_Implicit((Action)OnDefeatGoonsComplete); _helper.InitializeQuestEntry(ref QuestEntry_DefeatManorGoons, "DefeatGoons", "Defeat the Manor Goons", new PoIConfig(usePoI: false, useParent: false, useTransformLocal: false), _defeatGoonsAction); _searchAction = UnityAction.op_Implicit((Action)OnSearchResidenceCompete); _helper.InitializeQuestEntry(ref QuestEntry_SearchResidence, "SearchResidence", "Investigate the upstairs rooms (0/4)", new PoIConfig(usePoI: true, useParent: false, useTransformLocal: false), _searchAction); _helper.InitializeQuestEntry(ref QuestEntry_EscapeManor, "EscapeManor", "Escape the Manor before the Police arrive", new PoIConfig(usePoI: false, useParent: false, useTransformLocal: false)); TimeManager instance = NetworkSingleton.Instance; Action action = ((Quest)this).OnMinPass; instance.onHourPass += Action.op_Implicit((Action)HourPass); instance.onMinutePass += Action.op_Implicit(action); _helper.StartQuestFromEntry(QuestEntry_InvestigateWoods); } public void SpawnManorGoons() { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Expected O, but got Unknown //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) List list = roomsPositions.Keys.ToList(); if (NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count == 0) { foreach (CartelGoon item in (Il2CppArrayBase)(object)NetworkSingleton.Instance.GoonPool.goons) { if (NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count >= 3) { break; } if (NetworkSingleton.Instance.GoonPool.spawnedGoons.Contains(item) && item.IsGoonSpawned && (((NPC)item).Health.IsDead || ((NPC)item).Health.IsKnockedOut)) { item.Despawn(); } } } for (int i = 0; i < 3; i++) { CartelGoon goon = NetworkSingleton.Instance.GoonPool.SpawnGoon(list[i]); ((Component)((NPC)goon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)goon).Behaviour.ScheduleManager.DisableSchedule(); goon.IsGoonSpawned = true; if (!((Component)goon).gameObject.activeSelf) { ((Component)goon).gameObject.SetActive(true); } if (!((Behaviour)((NPC)goon).Avatar).enabled || !((Component)((NPC)goon).Avatar).gameObject.activeSelf) { ((Component)((NPC)goon).Avatar).gameObject.SetActive(true); ((Behaviour)((NPC)goon).Avatar).enabled = true; } SetupGoonWeapon(goon); ((NPC)goon).Inventory.AddCash(Mathf.Round(Random.Range(500f * questDifficultyScalar, 1300f * questDifficultyScalar))); ((NPC)goon).NPCData.Health.MaxHealth = Mathf.Round(Mathf.Lerp(150f, 300f, questDifficultyScalar - 1f)); ((NPC)goon).Health.Health = Mathf.Round(Mathf.Lerp(150f, 300f, questDifficultyScalar - 1f)); UnityAction onGoonDiedAction = null; onGoonDiedAction = UnityAction.op_Implicit((Action)onGoonDie); ((NPC)goon).Health.onDieOrKnockedOut.AddListener(onGoonDiedAction); if (!hasSavedCombatVariables) { GiveUpRange = ((NPC)goon).Behaviour.CombatBehaviour.GiveUpRange; GiveUpAfterSuccessfulHits = ((NPC)goon).Behaviour.CombatBehaviour.GiveUpAfterSuccessfulHits; DefaultSearchTime = ((NPC)goon).Behaviour.CombatBehaviour.DefaultSearchTime; hasSavedCombatVariables = true; } ((NPC)goon).Behaviour.CombatBehaviour.GiveUpRange = 60f; ((NPC)goon).Behaviour.CombatBehaviour.GiveUpAfterSuccessfulHits = 60; ((NPC)goon).Behaviour.CombatBehaviour.DefaultSearchTime = 120f; ((NPC)goon).Behaviour.CombatBehaviour.SetTarget(((Component)Player.Local).GetComponent().NetworkObject); ((Behaviour)((NPC)goon).Behaviour.CombatBehaviour).Enable_Networked(); float num = Mathf.Lerp(Random.Range(0.42f, 0.55f), 0.67f, questDifficultyScalar - 1f); ((NPC)goon).Movement.SpeedController.AddSpeedControl(new SpeedControl("combat", 5, num)); ((NPC)goon).Movement.Agent.avoidancePriority = 30; EndGameQuest.manorGoons.Add(goon); EndGameQuest.manorGoonGuids.Add(((object)((NPC)goon).GUID/*cast due to .constrained prefix*/).ToString()); void onGoonDie() { manorGoonsAlive--; if ((Delegate)(object)onGoonDiedAction != (Delegate)null) { ((NPC)goon).Health.onDieOrKnockedOut.RemoveListener(onGoonDiedAction); onGoonDiedAction = null; } } } manorGoonsAlive = EndGameQuest.manorGoons.Count(); } private void SetupGoonWeapon(CartelGoon goon) { ((NPC)goon).Behaviour.CombatBehaviour.SetWeapon("Avatar/Equippables/M1911"); if ((Object)(object)((NPC)goon).Behaviour.CombatBehaviour.currentWeapon != (Object)null) { AvatarRangedWeapon val = null; val = ((Il2CppObjectBase)((NPC)goon).Behaviour.CombatBehaviour.currentWeapon).Cast(); if ((Object)(object)val != (Object)null) { float num = 26f; float num2 = 45f; float num3 = Mathf.Clamp01(questDifficultyScalar - 1f); val.CanShootWhileMoving = true; val.AimTime_Max = 0.3f; val.AimTime_Min = 0.1f; val.HitChance_MaxRange = 65f; val.HitChance_MinRange = 85f; val.MaxFireRate = Mathf.Lerp(0.7f, 1.2f, num3); val.MaxMovingShotsBeforeReposition = 3; val.MaxStationaryShotsBeforeReposition = 1; ((AvatarWeapon)val).MaxUseRange = 7f; ((AvatarWeapon)val).MinUseRange = 0.1f; ((AvatarWeapon)val).CooldownDuration = Mathf.Lerp(0.7f, 1.2f, num3); val.Damage = Mathf.Round(Mathf.Lerp(num, num2, num3)); } } } private void SpawnForestGoon() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Expected O, but got Unknown //IL_02c9: Unknown result type (might be due to invalid IL or missing references) if (NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count == 0) { return; } CartelGoon val = NetworkSingleton.Instance.GoonPool.SpawnGoon(forestSearchLocs[forestSearchLocs.Count - 1]); ((Component)((NPC)val).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)val).Behaviour.ScheduleManager.DisableSchedule(); if (!((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); } if (!((Behaviour)((NPC)val).Avatar).enabled || !((Component)((NPC)val).Avatar).gameObject.activeSelf) { ((Component)((NPC)val).Avatar).gameObject.SetActive(true); ((Behaviour)((NPC)val).Avatar).enabled = true; } ((NPC)val).Inventory.AddCash(Mathf.Round(Random.Range(500f * questDifficultyScalar, 1300f * questDifficultyScalar))); ((NPC)val).NPCData.Health.MaxHealth = Mathf.Round(Mathf.Lerp(35f, 85f, questDifficultyScalar - 1f)); ((NPC)val).Health.Health = Mathf.Round(Mathf.Lerp(35f, 85f, questDifficultyScalar - 1f)); ((NPC)val).Behaviour.CombatBehaviour.SetWeapon("Avatar/Equippables/Knife"); if ((Object)(object)((NPC)val).Behaviour.CombatBehaviour.currentWeapon != (Object)null) { AvatarMeleeWeapon val2 = null; val2 = ((Il2CppObjectBase)((NPC)val).Behaviour.CombatBehaviour.currentWeapon).Cast(); if ((Object)(object)val2 != (Object)null) { float num = 66f; float num2 = 87f; float num3 = Mathf.Clamp01(questDifficultyScalar - 1f); ((AvatarWeapon)val2).MaxUseRange = 2.3f; ((AvatarWeapon)val2).MinUseRange = 0.2f; val2.AttackRadius = Mathf.Lerp(2.3f, 3.2f, num3); val2.AttackRange = Mathf.Lerp(2.3f, 3.2f, num3); ((AvatarWeapon)val2).CooldownDuration = Mathf.Lerp(0.6f, 1.2f, num3); val2.Damage = Mathf.Round(Mathf.Lerp(num, num2, num3)); } } ((NPC)val).Behaviour.CombatBehaviour.SetTarget(((Component)Player.Local).GetComponent().NetworkObject); ((Behaviour)((NPC)val).Behaviour.CombatBehaviour).Enable_Networked(); float num4 = Mathf.Lerp(Random.Range(0.55f, 0.76f), 0.86f, questDifficultyScalar - 1f); ((NPC)val).Movement.SpeedController.AddSpeedControl(new SpeedControl("combat", 5, num4)); ((NPC)val).Movement.Agent.avoidancePriority = 30; ((Component)val).transform.localScale = new Vector3(0.81f, 0.81f, 0.81f); CartelEnforcer.coros.Add(MelonCoroutines.Start(_helper.DespawnForestGoon(val))); } public override void OnMinPass() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Invalid comparison between Unknown and I4 //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Invalid comparison between Unknown and I4 //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Invalid comparison between Unknown and I4 //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Invalid comparison between Unknown and I4 //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Invalid comparison between Unknown and I4 //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) if (!CartelEnforcer.registered || Singleton.Instance.IsSaving || EndGameQuest.manorCompleted || (int)((Quest)this).State != 1 || !InstanceFinder.IsServer) { return; } if ((Object)(object)QuestEntry_InvestigateWoods != (Object)null && (int)QuestEntry_InvestigateWoods.State == 1) { QuestEntry_InvestigateWoods.SetEntryTitle($"Investigate the hillside forest near Manor ({forestPosSearched}/4)"); if (forestPosSearched > 0 && forestPosSearched < 3 && !forestGoonSpawned && Random.Range(0f, 1f) > 0.9f) { forestGoonSpawned = true; SpawnForestGoon(); } if (forestSearchLocs == null) { return; } if (forestPosSearched == 4) { QuestEntry_InvestigateWoods.SetEntryTitle("Investigate the hillside forest near Manor (4/4)"); QuestEntry_InvestigateWoods.Complete(); return; } if (forestPosSearched < forestSearchLocs.Count && Vector3.Distance(Player.Local.CenterPointTransform.position, forestSearchLocs[forestPosSearched]) < 5f) { forestPosSearched++; QuestEntry_InvestigateWoods.SetEntryTitle($"Investigate the hillside forest near Manor ({forestPosSearched}/4)"); if (forestPosSearched >= forestSearchLocs.Count) { QuestEntry_InvestigateWoods.SetEntryTitle("Investigate the hillside forest near Manor (4/4)"); QuestEntry_InvestigateWoods.Complete(); return; } QuestEntry_InvestigateWoods.SetPoILocation(forestSearchLocs[forestPosSearched]); } if (NetworkSingleton.Instance.CurrentTime >= 2200) { EndGameQuest.manorCompleted = true; QuestEntry_InvestigateWoods.SetState((EQuestState)3, true); CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.ResetRayAFK())); ((Quest)this).Fail(true); } } else if ((Object)(object)QuestEntry_ReturnToRay != (Object)null && (int)QuestEntry_ReturnToRay.State == 1) { if (NetworkSingleton.Instance.CurrentTime >= 2200) { EndGameQuest.manorCompleted = true; QuestEntry_ReturnToRay.SetState((EQuestState)3, true); CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.ResetRayAFK())); ((Quest)this).Fail(true); } } else if ((Object)(object)QuestEntry_DefeatManorGoons != (Object)null && (int)QuestEntry_DefeatManorGoons.State == 1) { if (EndGameQuest.manorGoons != null && EndGameQuest.manorGoons.Count > 0 && manorGoonsAlive == 0) { QuestEntry_DefeatManorGoons.Complete(); } if (Vector3.Distance(QuestEntry_BreakIn.PoILocation.position, Player.Local.CenterPointTransform.position) > 70f) { EndGameQuest.manorCompleted = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(RandomManorGenerator.CleanupManor())); ((Quest)this).Fail(true); } else if (NetworkSingleton.Instance.CurrentTime < 2200 && NetworkSingleton.Instance.CurrentTime > 359) { EndGameQuest.manorCompleted = true; QuestEntry_DefeatManorGoons.SetState((EQuestState)3, true); CartelEnforcer.coros.Add(MelonCoroutines.Start(RandomManorGenerator.CleanupManor())); ((Quest)this).Fail(true); } } else if ((Object)(object)QuestEntry_SearchResidence != (Object)null && (int)QuestEntry_SearchResidence.State == 1) { QuestEntry_SearchResidence.SetEntryTitle($"Investigate the upstairs rooms ({roomsVisited}/4)"); bool flag = true; foreach (KeyValuePair roomsPosition in roomsPositions) { Vector3 key = roomsPosition.Key; if (!roomsPosition.Value && Vector3.Distance(Player.Local.CenterPointTransform.position, key) < 1.85f) { roomsPositions[key] = true; roomsVisited++; break; } } foreach (KeyValuePair roomsPosition2 in roomsPositions) { if (!roomsPosition2.Value) { QuestEntry_SearchResidence.SetPoILocation(roomsPosition2.Key); flag = false; break; } } if (flag) { QuestEntry_SearchResidence.Complete(); } else if (NetworkSingleton.Instance.CurrentTime < 2200 && NetworkSingleton.Instance.CurrentTime > 359) { EndGameQuest.manorCompleted = true; QuestEntry_SearchResidence.SetState((EQuestState)3, true); CartelEnforcer.coros.Add(MelonCoroutines.Start(RandomManorGenerator.CleanupManor())); ((Quest)this).Fail(true); } } else if ((Object)(object)QuestEntry_EscapeManor != (Object)null && (int)QuestEntry_EscapeManor.State == 1) { if ((int)Player.Local.CrimeData.CurrentPursuitLevel == 0 && Vector3.Distance(QuestEntry_BreakIn.PoILocation.position, Player.Local.CenterPointTransform.position) > 70f) { EndGameQuest.manorCompleted = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(RandomManorGenerator.CleanupManor())); CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.QuestManorReward())); ((Quest)this).Complete(true); } else if ((int)Player.Local.CrimeData.CurrentPursuitLevel != 0 && (int)Player.Local.CrimeData.CurrentPursuitLevel != 1) { EndGameQuest.manorCompleted = true; QuestEntry_EscapeManor.SetState((EQuestState)3, true); CartelEnforcer.coros.Add(MelonCoroutines.Start(RandomManorGenerator.CleanupManor())); ((Quest)this).Fail(true); } } } private void HourPass() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 if (CartelEnforcer.registered && !Singleton.Instance.IsSaving && !EndGameQuest.manorCompleted && (int)((Quest)this).State == 1 && InstanceFinder.IsServer && (Object)(object)QuestEntry_WaitForNight != (Object)null && (int)QuestEntry_WaitForNight.State == 1 && NetworkSingleton.Instance.CurrentTime >= 2200 && NetworkSingleton.Instance.CurrentTime <= 2359) { QuestEntry_WaitForNight.Complete(); } } private void OnInvestigateComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) if ((!((Object)(object)QuestEntry_InvestigateWoods != (Object)null) || (int)QuestEntry_InvestigateWoods.State != 3) && !((Object)(object)QuestEntry_ReturnToRay == (Object)null)) { QuestEntry_ReturnToRay.Begin(); EndGameQuest.UpdateQuestMapLogo(QuestEntry_ReturnToRay); QuestEntry_ReturnToRay.SetPoILocation(((Component)EndGameQuest.ray).transform.position); CartelEnforcer.coros.Add(MelonCoroutines.Start(EndGameQuest.GenRaySecondDialog((Action)QuestEntry_ReturnToRay.Complete))); if ((Delegate)(object)_investigateAction != (Delegate)null) { QuestEntry_InvestigateWoods.onComplete.RemoveListener(_investigateAction); _investigateAction = null; } } } private void OnReturnToRayComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((!((Object)(object)QuestEntry_ReturnToRay != (Object)null) || (int)QuestEntry_ReturnToRay.State != 3) && !((Object)(object)QuestEntry_WaitForNight == (Object)null)) { QuestEntry_WaitForNight.Begin(); if (QuestEntry_WaitForNight.compassElement != null) { QuestEntry_WaitForNight.compassElement.Visible = false; } CartelEnforcer.coros.Add(MelonCoroutines.Start(RandomManorGenerator.SetupManor())); if ((Delegate)(object)_returnToRayAction != (Delegate)null) { QuestEntry_ReturnToRay.onComplete.RemoveListener(_returnToRayAction); _returnToRayAction = null; } } } private void OnWaitForNightComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((!((Object)(object)QuestEntry_WaitForNight != (Object)null) || (int)QuestEntry_WaitForNight.State != 3) && !((Object)(object)QuestEntry_BreakIn == (Object)null)) { QuestEntry_BreakIn.Begin(); EndGameQuest.UpdateQuestMapLogo(QuestEntry_BreakIn); if ((Delegate)(object)_waitForNightAction != (Delegate)null) { QuestEntry_WaitForNight.onComplete.RemoveListener(_waitForNightAction); _waitForNightAction = null; } } } private void OnBreakInComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((!((Object)(object)QuestEntry_BreakIn != (Object)null) || (int)QuestEntry_BreakIn.State != 3) && !((Object)(object)QuestEntry_DefeatManorGoons == (Object)null)) { SpawnManorGoons(); QuestEntry_DefeatManorGoons.Begin(); if (QuestEntry_DefeatManorGoons.compassElement != null) { QuestEntry_DefeatManorGoons.compassElement.Visible = false; } if ((Delegate)(object)_breakInAction != (Delegate)null) { QuestEntry_BreakIn.onComplete.RemoveListener(_breakInAction); _breakInAction = null; } } } private void OnDefeatGoonsComplete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0053: Unknown result type (might be due to invalid IL or missing references) if ((!((Object)(object)QuestEntry_DefeatManorGoons != (Object)null) || (int)QuestEntry_DefeatManorGoons.State != 3) && !((Object)(object)QuestEntry_SearchResidence == (Object)null)) { QuestEntry_SearchResidence.Begin(); EndGameQuest.UpdateQuestMapLogo(QuestEntry_SearchResidence); QuestEntry_SearchResidence.SetPoILocation(roomsPositions.Keys.FirstOrDefault()); if ((Delegate)(object)_defeatGoonsAction != (Delegate)null) { QuestEntry_DefeatManorGoons.onComplete.RemoveListener(_defeatGoonsAction); _defeatGoonsAction = null; } } } private void OnSearchResidenceCompete() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if (((Object)(object)QuestEntry_SearchResidence != (Object)null && (int)QuestEntry_SearchResidence.State == 3) || (Object)(object)QuestEntry_EscapeManor == (Object)null) { return; } QuestEntry_EscapeManor.Begin(); if (QuestEntry_EscapeManor.compassElement != null) { QuestEntry_EscapeManor.compassElement.Visible = false; } Player.Local.CrimeData.SetPursuitLevel((EPursuitLevel)1); PoliceStation.PoliceStations[0].Dispatch(1, Player.Local, (EDispatchType)0, true); if ((Delegate)(object)_searchAction != (Delegate)null) { QuestEntry_SearchResidence.onComplete.RemoveListener(_searchAction); _searchAction = null; } try { if (RandomManorGenerator.activeJukebox.IsPlaying) { RandomManorGenerator.OnJukeboxStateChange(); } } catch (Exception) { } } } public class InfiltrateManorHelper : QuestHelperBase { public InfiltrateManorHelper(Quest_InfiltrateManor quest) : base(quest) { } public IEnumerator DespawnForestGoon(CartelGoon goon) { int maxWaitMins = 2; for (int i = 0; i < 60 * maxWaitMins; i++) { yield return CartelEnforcer.Wait1; if (!CartelEnforcer.registered) { yield break; } if (((NPC)goon).Health.IsDead || ((NPC)goon).Health.IsKnockedOut || (Object)(object)((NPC)goon).Behaviour.activeBehaviour == (Object)null || (Object)(object)((NPC)goon).Behaviour.activeBehaviour != (Object)(object)((NPC)goon).Behaviour.CombatBehaviour) { break; } } yield return CartelEnforcer.Wait30; ((NPC)goon).NPCData.Health.MaxHealth = 100f; ((NPC)goon).Health.Health = 100f; ((Component)((NPC)goon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); ((NPC)goon).Behaviour.ScheduleManager.EnableSchedule(); if (goon.IsGoonSpawned) { goon.Despawn(); } ((NPC)goon).Movement.SpeedController.RemoveSpeedControl("combat"); } } public static class MiniQuest { public class NpcQuestStatus { public bool HasAskedQuestToday { get; set; } public bool HasActiveQuest { get; set; } } public static Dictionary targetNPCs = new Dictionary(); public static List targetNPCsList = new List(); public static List emptyDrops = new List(); public static List rareDrops = new List { "silverwatch", "goldwatch", "silverchain", "goldchain", "oldmanjimmys", "brutdugloop", "sewerkey" }; public static List commonDrops = new List { "cocaine", "meth", "greencrackseed", "ogkushseed" }; public static IEnumerator InitMiniQuest() { Anna val = Object.FindObjectOfType(); if ((Object)(object)val != (Object)null) { targetNPCs.Add((NPC)(object)val, new NpcQuestStatus { HasAskedQuestToday = false, HasActiveQuest = false }); } Fiona val2 = Object.FindObjectOfType(); if ((Object)(object)val2 != (Object)null) { targetNPCs.Add((NPC)(object)val2, new NpcQuestStatus { HasAskedQuestToday = false, HasActiveQuest = false }); } Dean val3 = Object.FindObjectOfType(); if ((Object)(object)val3 != (Object)null) { targetNPCs.Add((NPC)(object)val3, new NpcQuestStatus { HasAskedQuestToday = false, HasActiveQuest = false }); } Mick val4 = Object.FindObjectOfType(); if ((Object)(object)val4 != (Object)null) { targetNPCs.Add((NPC)(object)val4, new NpcQuestStatus { HasAskedQuestToday = false, HasActiveQuest = false }); } Jeff val5 = Object.FindObjectOfType(); if ((Object)(object)val5 != (Object)null) { targetNPCs.Add((NPC)(object)val5, new NpcQuestStatus { HasAskedQuestToday = false, HasActiveQuest = false }); } Dan val6 = Object.FindObjectOfType(); if ((Object)(object)val6 != (Object)null) { targetNPCs.Add((NPC)(object)val6, new NpcQuestStatus { HasAskedQuestToday = false, HasActiveQuest = false }); } Marco val7 = Object.FindObjectOfType(); if ((Object)(object)val7 != (Object)null) { targetNPCs.Add((NPC)(object)val7, new NpcQuestStatus { HasAskedQuestToday = false, HasActiveQuest = false }); } Herbert val8 = Object.FindObjectOfType(); if ((Object)(object)val8 != (Object)null) { targetNPCs.Add((NPC)(object)val8, new NpcQuestStatus { HasAskedQuestToday = false, HasActiveQuest = false }); } targetNPCsList = targetNPCs.Keys.ToList(); yield return null; } public static void OnDayPassNewDiag() { if (!CartelEnforcer.currentConfig.miniQuestsEnabled) { return; } foreach (NPC targetNPCs in targetNPCsList) { MiniQuest.targetNPCs[targetNPCs].HasAskedQuestToday = false; } } public static IEnumerator EvaluateMiniQuestCreation() { WaitForSeconds upperWait = new WaitForSeconds(240f); bool questGenerated = false; while (CartelEnforcer.registered) { yield return CartelEnforcer.Wait2; if (!CartelEnforcer.currentConfig.miniQuestsEnabled) { continue; } bool flag = (int)NetworkSingleton.Instance.Status == 2; bool flag2 = ((NetworkSingleton.Instance.CurrentTime >= 659 && NetworkSingleton.Instance.CurrentTime <= 2359) ? true : false); if (flag && flag2) { NPC val = targetNPCsList[Random.Range(0, targetNPCsList.Count)]; if (targetNPCs.ContainsKey(val) && !targetNPCs[val].HasActiveQuest && !targetNPCs[val].HasAskedQuestToday) { float num = 1f; if (!val.RelationData.Unlocked) { num = Random.Range(0f, 1f); } if (num > 0.2f) { targetNPCs[val].HasActiveQuest = true; InitMiniQuestDialogue(val); questGenerated = true; } } } if (questGenerated) { yield return upperWait; } else { yield return CartelEnforcer.Wait30; } if (!CartelEnforcer.registered) { break; } questGenerated = false; } } public static void InitMiniQuestDialogue(NPC npc) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown DialogueController controller = ((Component)npc.DialogueHandler).gameObject.GetComponent(); DialogueChoice choice = new DialogueChoice(); string value = ""; float paid = 500f; if (npc.RelationData != null) { paid = Mathf.Lerp(500f, 100f, npc.RelationData.NormalizedRelationDelta); } if (float.IsNaN(paid)) { paid = 500f; } paid = Mathf.Round(paid / 20f) * 20f; switch (Random.Range(0, 3)) { case 0: value = "Have you heard anything new about the Benzies?"; break; case 1: value = "Any rumours about the Cartel you could share?"; break; case 2: value = "What's the word around town? I need info on the Benzies."; break; } choice.ChoiceText = $"{value} (Bribe ${paid})"; choice.Enabled = true; choice.onChoosen.AddListener(UnityAction.op_Implicit((Action)OnMiniQuestChosenWrapped)); controller.AddDialogueChoice(choice, 0); void OnMiniQuestChosenWrapped() { OnMiniQuestChosen(choice, npc, controller, paid); } } public static void OnMiniQuestChosen(DialogueChoice choice, NPC npc, DialogueController controller, float paid) { //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Lerp(0.4f, 0.75f, npc.RelationData.NormalizedRelationDelta); bool flag = NetworkSingleton.Instance.cashBalance >= paid; if (NetworkSingleton.Instance.CurrentTime >= 1200 || NetworkSingleton.Instance.CurrentTime <= 1800) { num = Mathf.Lerp(num, 1f, num); } if (CartelGathering.areGoonsGathering) { num = Mathf.Lerp(num, 0f, 0.5f); } if (Random.Range(0f, 1f) < num && flag) { emptyDrops.Clear(); Enumerator enumerator = DeadDrop.DeadDrops.GetEnumerator(); while (enumerator.MoveNext()) { DeadDrop current = enumerator.Current; if (((StorageEntity)current.Storage).ItemCount == 0) { emptyDrops.Add(current); } } if (emptyDrops.Count == 0) { return; } DeadDrop val = emptyDrops[Random.Range(0, emptyDrops.Count)]; string text = ""; bool flag2 = false; if (Random.Range(0f, 1f) > num) { text = ((object)val.Region/*cast due to .constrained prefix*/).ToString() + " region"; } else { text = val.DeadDropName; text = text.ToLower(); List list = text.Split(' ').ToList(); if (list.Count > 0 && (list[0] == "under" || list[0] == "behind")) { flag2 = true; } } List list2 = new List(); Func func = Registry.GetItem; if (Random.Range(0f, 1f) > 0.2f) { ItemDefinition obj = func(commonDrops[Random.Range(0, commonDrops.Count)]); int num2 = Random.Range(3, 11); ItemInstance defaultInstance = obj.GetDefaultInstance(num2); list2.Add(defaultInstance); } else { ItemDefinition obj2 = func(rareDrops[Random.Range(0, rareDrops.Count)]); int num2 = 1; ItemInstance defaultInstance = obj2.GetDefaultInstance(num2); list2.Add(defaultInstance); } List list3 = new List(); if (CartelInventory.cartelStolenItems.Count > 0) { list3 = CartelInventory.GetFromPool(2); if (list3.Count > 0) { list2.AddRange(list3); } } CartelEnforcer.coros.Add(MelonCoroutines.Start(CreateDropContent(val, list2, npc, list3, flag2))); controller.handler.ContinueSubmitted(); NetworkSingleton.Instance.ChangeCashBalance(0f - paid, true, false); string text2 = ""; switch (Random.Range(0, 5)) { case 0: text2 = (flag2 ? "" : "around"); controller.handler.WorldspaceRend.ShowText($"I heard them talk about some drop {text2} {text}...", 9f); break; case 1: text2 = (flag2 ? "" : "near"); controller.handler.WorldspaceRend.ShowText($"There are rumours about a suspicious drop {text2} {text}!", 9f); break; case 2: text2 = (flag2 ? "" : "near"); controller.handler.WorldspaceRend.ShowText($"Yes! I heard they stashed something {text2} {text}!", 9f); break; case 3: text2 = (flag2 ? "" : "around"); controller.handler.WorldspaceRend.ShowText($"I saw one of them hide something in a dead drop {text2} {text}.", 9f); break; case 4: text2 = (flag2 ? "" : "at"); controller.handler.WorldspaceRend.ShowText($"They have been stashing items {text2} {text}.", 9f); break; } CartelEnforcer.coros.Add(MelonCoroutines.Start(HurryUpMessage(controller))); } else if (CartelGathering.areGoonsGathering && CartelGathering.currentGatheringLocation != null && flag) { controller.handler.ContinueSubmitted(); NetworkSingleton.Instance.ChangeCashBalance(0f - paid, true, false); switch (Random.Range(0, 3)) { case 0: controller.handler.WorldspaceRend.ShowText("I saw a group of them at the " + CartelGathering.currentGatheringLocation.description, 15f); npc.PlayVO((EVOLineType)19, false); break; case 1: controller.handler.WorldspaceRend.ShowText("There is a group of Benzies at the " + CartelGathering.currentGatheringLocation.description, 15f); npc.PlayVO((EVOLineType)3, false); break; case 2: controller.handler.WorldspaceRend.ShowText("The Benzies are gathering at the " + CartelGathering.currentGatheringLocation.description, 15f); npc.PlayVO((EVOLineType)5, false); break; } } else { controller.handler.ContinueSubmitted(); switch (Random.Range(0, 3)) { case 0: controller.handler.WorldspaceRend.ShowText("I've heard nothing...", 15f); npc.PlayVO((EVOLineType)17, false); break; case 1: controller.handler.WorldspaceRend.ShowText("No! Leave me alone!", 15f); npc.Avatar.EmotionManager.AddEmotionOverride("Annoyed", "product_rejected", 6f, 1); npc.PlayVO((EVOLineType)9, false); break; case 2: controller.handler.WorldspaceRend.ShowText("I'm afraid to talk about it...", 15f); npc.PlayVO((EVOLineType)5, false); break; } } targetNPCs[npc].HasActiveQuest = false; targetNPCs[npc].HasAskedQuestToday = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(DisposeChoice(controller, npc))); } public static IEnumerator HurryUpMessage(DialogueController controller) { yield return CartelEnforcer.Wait10; controller.handler.WorldspaceRend.ShowText("You need to hurry before they grab it!", 5f); yield return null; } public static IEnumerator DisposeChoice(DialogueController controller, NPC npc) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { List choices = controller.Choices; choices.RemoveAt(choices.Count - 1); controller.Choices = choices; yield return null; } } public static IEnumerator CreateDropContent(DeadDrop entity, List filledItems, NPC npc, List itemsFromPool = null, bool useShortTimeout = true) { yield return CartelEnforcer.Wait5; if (!CartelEnforcer.registered) { yield break; } bool changeInfluence = InfluenceOverrides.ShouldChangeInfluence(entity.Region); for (int i = 0; i < filledItems.Count; i++) { ((StorageEntity)entity.Storage).InsertItem(filledItems[i], true); } bool opened = false; Action onOpenedAction = null; onOpenedAction = Action.op_Implicit((Action)WrapOnOpenCallback); WorldStorageEntity storage = entity.Storage; ((StorageEntity)storage).onOpened = ((StorageEntity)storage).onOpened + onOpenedAction; yield return CartelEnforcer.Wait60; if (!CartelEnforcer.registered) { yield break; } if (!useShortTimeout) { yield return CartelEnforcer.Wait60; if (!CartelEnforcer.registered) { yield break; } } if (!opened) { if (changeInfluence) { NetworkSingleton.Instance.Influence.ChangeInfluence(entity.Region, CartelEnforcer.influenceConfig.deadDropFail); } if (itemsFromPool != null && itemsFromPool.Count > 0) { CartelInventory.CartelStealsItems(itemsFromPool); } ((StorageEntity)entity.Storage).ClearContents(); } if ((Delegate)(object)onOpenedAction != (Delegate)null) { WorldStorageEntity storage2 = entity.Storage; ((StorageEntity)storage2).onOpened = ((StorageEntity)storage2).onOpened - onOpenedAction; onOpenedAction = null; } yield return null; void WrapOnOpenCallback() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Invalid comparison between Unknown and I4 NetworkSingleton.Instance.AddXP(100); opened = true; if (changeInfluence) { NetworkSingleton.Instance.Influence.ChangeInfluence(entity.Region, CartelEnforcer.influenceConfig.deadDropSuccess); } if ((Object)(object)EndGameQuest.activeDefeatEnforcerQuest != (Object)null && (int)((Quest)EndGameQuest.activeDefeatEnforcerQuest).State == 1 && (Object)(object)EndGameQuest.activeDefeatEnforcerQuest.QuestEntry_Investigate != (Object)null && (int)EndGameQuest.activeDefeatEnforcerQuest.QuestEntry_Investigate.State == 1 && EndGameQuest.StageDeadDropsObserved <= 1) { EndGameQuest.StageDeadDropsObserved++; } if ((Delegate)(object)onOpenedAction != (Delegate)null) { WorldStorageEntity storage3 = entity.Storage; ((StorageEntity)storage3).onOpened = ((StorageEntity)storage3).onOpened - onOpenedAction; onOpenedAction = null; } } } } public static class RandomManorGenerator { public class SafeSpawnSpot { public Vector3 spawnSpot; public Vector3 eulerAngles; public SafeSpawnSpot(Vector3 pos, Vector3 rot) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) spawnSpot = pos; eulerAngles = rot; } } public abstract class RoomDesignBase { public WaitForSeconds waitInstantiateEach; public Vector3 roomCenter { get; set; } public Vector3 roomRotation { get; set; } public Transform roomTransform { get; set; } public bool canGenerateSafe { get; set; } public abstract IEnumerator SpawnDesign(); public void AfterSpawnComplete() { for (int i = 0; i < roomTransform.childCount; i++) { ((Component)roomTransform.GetChild(i)).gameObject.SetActive(true); } } public void SpawnItemOut(string itemKey, out NetworkObject nob) { nob = null; if (buildablesMap.ContainsKey(itemKey)) { nob = SpawnItem(buildablesMap[itemKey]); } } public void AdjustY(NetworkObject nob) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)nob).transform.Find("Bounds"); if ((Object)(object)val == (Object)null) { return; } Transform val2 = ((Component)nob).transform.Find("BuildPoint"); if (!((Object)(object)val2 == (Object)null)) { float num = val2.localPosition.y; if (num < 0f) { num = 0f - num; } float y = val.localPosition.y; float num2 = num + y; ((Component)nob).transform.localPosition = new Vector3(((Component)nob).transform.localPosition.x, num2, ((Component)nob).transform.localPosition.z); } } private GameObject SpawnItem(GameObject obj) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) GameObject obj2 = Object.Instantiate(obj, roomTransform); obj2.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity); return obj2; } private NetworkObject SpawnItem(NetworkObject obj) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) NetworkObject obj2 = Object.Instantiate(obj, roomTransform); ((Component)obj2).transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity); return obj2; } } private class UpstairsLivingRoom : RoomDesignBase { private readonly Vector3 coffeeTablePos = new Vector3(-0.2873f, 0f, 1.2164f); private readonly Vector3 coffeeTableRot = Vector3.zero; private readonly Vector3 displayCabinetPos = new Vector3(0.9627f, 0.85f, -1.2836f); private readonly Vector3 displayCabinetRot = Vector3.zero; private readonly Vector3 safePos = new Vector3(0.7f, 2.535f, -1.4f); private readonly Vector3 safeRot = new Vector3(0f, 270f, 0f); public override IEnumerator SpawnDesign() { base.roomTransform.position = base.roomCenter; SpawnItemOut("CoffeeTable", out var nob); ((Component)nob).transform.localPosition = coffeeTablePos; ((Component)nob).transform.localRotation = Quaternion.Euler(coffeeTableRot); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } SpawnItemOut("DisplayCabinet", out var nob2); ((Component)nob2).transform.localPosition = displayCabinetPos; ((Component)nob2).transform.localRotation = Quaternion.Euler(displayCabinetRot); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } if (base.canGenerateSafe) { SpawnItemOut("Small Safe", out var safe); questSafe = ((Component)safe).GetComponent(); ((Component)safe).transform.localPosition = safePos; ((Component)safe).transform.rotation = Quaternion.Euler(safeRot.x, safeRot.y, 90f); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } ((Component)safe).gameObject.SetActive(true); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } ((Component)safe).gameObject.SetActive(true); if (onSafeBuilt != null) { onSafeBuilt(); } } AfterSpawnComplete(); } } private class UpstairsBedRoom : RoomDesignBase { private readonly Vector3 floorLampPos = new Vector3(-1.0373f, 0f, 1.4664f); private readonly Vector3 floorLampRot = Vector3.zero; private readonly Vector3 bedPos = new Vector3(-0.0373f, 0f, 0.4664f); private readonly Vector3 bedRot = new Vector3(0f, 90f, 0f); private readonly Vector3 woodTablePos = new Vector3(-0.7872f, 0f, -0.7836f); private readonly Vector3 woodTableRot = Vector3.zero; private readonly Vector3 safePos = new Vector3(-0.74f, 0.175f, -0.76f); private readonly Vector3 safeRot = new Vector3(0f, 90f, 0f); public override IEnumerator SpawnDesign() { base.roomTransform.position = base.roomCenter; SpawnItemOut("FloorLamp", out var nob); ((Component)nob).transform.localPosition = floorLampPos; ((Component)nob).transform.localRotation = Quaternion.Euler(floorLampRot); AdjustY(nob); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } SpawnItemOut("SingleBed", out var nob2); ((Component)nob2).transform.localPosition = bedPos; ((Component)nob2).transform.localRotation = Quaternion.Euler(bedRot); AdjustY(nob2); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } SpawnItemOut("WoodSquareTable", out var nob3); ((Component)nob3).transform.localPosition = woodTablePos; ((Component)nob3).transform.localRotation = Quaternion.Euler(woodTableRot); AdjustY(nob3); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } if (base.canGenerateSafe) { SpawnItemOut("Small Safe", out var safe); questSafe = ((Component)safe).GetComponent(); ((Component)safe).transform.localPosition = safePos; ((Component)safe).transform.rotation = Quaternion.Euler(safeRot.x, safeRot.y, 90f); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } ((Component)safe).gameObject.SetActive(true); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } ((Component)safe).gameObject.SetActive(true); if (onSafeBuilt != null) { onSafeBuilt(); } } AfterSpawnComplete(); } } private class DownstairsLivingRoom : RoomDesignBase { private readonly Vector3 tvPos = new Vector3(0.295f, 0f, 2.4532f); private readonly Vector3 tvRot = new Vector3(0f, 180f, 0f); private readonly Vector3 displayCabinet1Pos = new Vector3(2.045f, 0.85f, 2.4532f); private readonly Vector3 displayCabinet1Rot = new Vector3(0f, 180f, 0f); private readonly Vector3 displayCabinet2Pos = new Vector3(-1.455f, 0.85f, 2.4532f); private readonly Vector3 displayCabinet2Rot = new Vector3(0f, 180f, 0f); private readonly Vector3 woodTablePos = new Vector3(-1.205f, 0f, -0.0468f); private readonly Vector3 woodTableRot = Vector3.zero; public override IEnumerator SpawnDesign() { base.roomTransform.position = base.roomCenter; SpawnItemOut("TV_Built", out var nob); ((Component)nob).transform.localPosition = tvPos; ((Component)nob).transform.localRotation = Quaternion.Euler(tvRot); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } SpawnItemOut("DisplayCabinet", out var nob2); ((Component)nob2).transform.localPosition = displayCabinet1Pos; ((Component)nob2).transform.localRotation = Quaternion.Euler(displayCabinet1Rot); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } SpawnItemOut("DisplayCabinet", out var nob3); ((Component)nob3).transform.localPosition = displayCabinet2Pos; ((Component)nob3).transform.localRotation = Quaternion.Euler(displayCabinet2Rot); yield return waitInstantiateEach; if (CartelEnforcer.registered) { SpawnItemOut("WoodSquareTable", out var nob4); ((Component)nob4).transform.localPosition = woodTablePos; ((Component)nob4).transform.localRotation = Quaternion.Euler(woodTableRot); yield return waitInstantiateEach; if (CartelEnforcer.registered) { AfterSpawnComplete(); } } } } private class DownstairsKitchenRoom : RoomDesignBase { private readonly Vector3 jukeboxPos = new Vector3(1.795f, 0f, -1.5468f); private readonly Vector3 jukeboxRot = Vector3.zero; private readonly Vector3 mixingStationPos = new Vector3(0.295f, 0f, 2.4532f); private readonly Vector3 mixingStationRot = new Vector3(0f, 180f, 0f); private readonly Vector3 displayCabinet1Pos = new Vector3(-1.455f, 0.85f, -1.5468f); private readonly Vector3 displayCabinet1Rot = Vector3.zero; private readonly Vector3 displayCabinet2Pos = new Vector3(0.045f, 0.85f, -1.5468f); private readonly Vector3 displayCabinet2Rot = Vector3.zero; private readonly Vector3 metalTable1Pos = new Vector3(-1.205f, 0f, 2.4532f); private readonly Vector3 metalTable1Rot = Vector3.zero; private readonly Vector3 metalTable2Pos = new Vector3(1.795f, 0f, 2.4532f); private readonly Vector3 metalTable2Rot = Vector3.zero; public override IEnumerator SpawnDesign() { base.roomTransform.position = base.roomCenter; SpawnItemOut("Jukebox_Built", out var nob); ((Component)nob).transform.localPosition = jukeboxPos; ((Component)nob).transform.localRotation = Quaternion.Euler(jukeboxRot); activeJukebox = ((Component)nob).GetComponent(); AdjustY(nob); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } SpawnItemOut("MixingStation_Built", out var nob2); ((Component)nob2).transform.localPosition = mixingStationPos; ((Component)nob2).transform.localRotation = Quaternion.Euler(mixingStationRot); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } SpawnItemOut("DisplayCabinet", out var nob3); ((Component)nob3).transform.localPosition = displayCabinet1Pos; ((Component)nob3).transform.localRotation = Quaternion.Euler(displayCabinet1Rot); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } SpawnItemOut("DisplayCabinet", out var nob4); ((Component)nob4).transform.localPosition = displayCabinet2Pos; ((Component)nob4).transform.localRotation = Quaternion.Euler(displayCabinet2Rot); yield return waitInstantiateEach; if (!CartelEnforcer.registered) { yield break; } SpawnItemOut("MetalSquareTable", out var nob5); ((Component)nob5).transform.localPosition = metalTable1Pos; ((Component)nob5).transform.localRotation = Quaternion.Euler(metalTable1Rot); AdjustY(nob5); yield return waitInstantiateEach; if (CartelEnforcer.registered) { SpawnItemOut("MetalSquareTable", out var nob6); ((Component)nob6).transform.localPosition = metalTable2Pos; ((Component)nob6).transform.localRotation = Quaternion.Euler(metalTable2Rot); AdjustY(nob6); yield return waitInstantiateEach; if (CartelEnforcer.registered) { AfterSpawnComplete(); } } } } private class ExceedinglyRareGoldenRoomWithThomasTakingAShitOnAGoldenToilet : RoomDesignBase { public ExceedinglyRareGoldenRoomWithThomasTakingAShitOnAGoldenToilet() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) base.roomCenter = upstairsRoomCenters[1]; } public override IEnumerator SpawnDesign() { goldenRoomWasGenerated = true; NetworkObject toilet = Object.Instantiate(buildablesMap["GoldenToilet"], base.roomTransform); ((Component)toilet).transform.position = new Vector3(171.3982f, 14.215f, -60.5732f); GameObject sittingPoint = new GameObject("SittingPoint"); sittingPoint.transform.parent = ((Component)toilet).transform; sittingPoint.transform.localPosition = new Vector3(0f, -0.24f, 0.2f); Transform val = ((Component)toilet).transform.Find("Golden Toilet/Toilet/Particle System"); val.localPosition = new Vector3(0f, 0.6772f, 0.0364f); val.rotation = Quaternion.Euler(90f, 0f, 0f); ParticleSystem particleSystem = ((Component)val).gameObject.GetComponent(); particleSystem.main.startColor = MinMaxGradient.op_Implicit(new Color(0.4129f, 0.2529f, 0.1529f, 1f)); yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } ((Component)toilet).gameObject.SetActive(true); particleSystem.Play(); ((Component)DriveByEvent.thomasInstance).transform.position = sittingPoint.transform.position; ((Component)DriveByEvent.thomasInstance).transform.localRotation = Quaternion.Euler(351.6206f, 250.0409f, 1.4658f); NetworkObject floorLamp = Object.Instantiate(buildablesMap["FloorLamp"], base.roomTransform); ((Component)floorLamp).transform.position = new Vector3(172.3888f, 14.245f, -59.9603f); ToggleableItem lampToggle = ((Component)floorLamp).GetComponent(); yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } ((Component)floorLamp).gameObject.SetActive(true); lampToggle.Toggle(); ItemInstance defaultInstance = new Func(Registry.GetItem)("goldbar").GetDefaultInstance(1); GameObject goldBarTemplate = null; StorableItemInstance val2 = ((Il2CppObjectBase)defaultInstance).TryCast(); if (val2 != null && (Object)(object)val2.StoredItem != (Object)null) { GameObject gameObject = ((Component)((Component)val2.StoredItem).transform.Find("Gold bar")).gameObject; if ((Object)(object)gameObject != (Object)null) { goldBarTemplate = Object.Instantiate(gameObject); } } if ((Object)(object)goldBarTemplate == (Object)null) { yield break; } BoxCollider val3 = goldBarTemplate.AddComponent(); val3.size = new Vector3(0.05f, 0.05f, 0.2f); val3.center = new Vector3(0f, 0.025f, 0f); goldBarTemplate.transform.localScale = new Vector3(5f, 5f, 5f); var array = new[] { new { pos = new Vector3(168.3982f, 14.41f, -60.3f), rot = Quaternion.Euler(17f, 0f, 8f) }, new { pos = new Vector3(168.3982f, 14.215f, -60.5732f), rot = Quaternion.Euler(0f, 63f, 0f) }, new { pos = new Vector3(169.9482f, 14.215f, -60.5732f), rot = Quaternion.Euler(0f, 4f, 0f) }, new { pos = new Vector3(170.9482f, 14.215f, -61.5732f), rot = Quaternion.Euler(0f, 140f, 0f) }, new { pos = new Vector3(169.7982f, 14.215f, -61.5732f), rot = Quaternion.Euler(0f, 98f, 0f) }, new { pos = new Vector3(170.2982f, 14.455f, -61.4732f), rot = Quaternion.Euler(0f, 70f, 0f) }, new { pos = new Vector3(170.3982f, 14.215f, -60.5732f), rot = Quaternion.Euler(0f, 0f, 0f) }, new { pos = new Vector3(170.1982f, 14.455f, -60.5732f), rot = Quaternion.Euler(0f, 92f, 0f) }, new { pos = new Vector3(170.1982f, 14.455f, -60.1732f), rot = Quaternion.Euler(0f, 85f, 0f) }, new { pos = new Vector3(170.1982f, 14.455f, -60.9732f), rot = Quaternion.Euler(0f, 92f, 0f) }, new { pos = new Vector3(170.3982f, 14.695f, -60.5732f), rot = Quaternion.Euler(0f, 0f, 0f) }, new { pos = new Vector3(170.1282f, 14.885f, -60.5732f), rot = Quaternion.Euler(0f, 0f, 103f) } }; foreach (var anon in array) { GameObject obj = Object.Instantiate(goldBarTemplate, base.roomTransform); obj.transform.position = anon.pos; obj.transform.rotation = anon.rot; obj.SetActive(true); } Rigidbody obj2 = goldBarTemplate.AddComponent(); obj2.angularDrag = 0.98f; obj2.drag = 0.2f; obj2.mass = 2.3f; obj2.maxAngularVelocity = 3f; obj2.maxLinearVelocity = 7f; PhysicMaterial val4 = new PhysicMaterial(); val4.bounceCombine = (PhysicMaterialCombine)3; val4.bounciness = 0.03f; val4.dynamicFriction = 0.096f; val4.staticFriction = 0.03f; val4.frictionCombine = (PhysicMaterialCombine)2; ((Collider)val3).material = val4; goldBarTemplate.transform.localScale = new Vector3(3.6f, 3.6f, 3.6f); int physicsGoldBarCount = 9; for (int j = 0; j < physicsGoldBarCount; j++) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } GameObject val5 = Object.Instantiate(goldBarTemplate, base.roomTransform); val5.transform.position = new Vector3(169.7678f + Random.Range(-0.6f, 0.6f), 15f + 0.1f * (float)j, -58.9568f + Random.Range(-0.6f, 0.6f)); val5.transform.rotation = Quaternion.Euler((Random.Range(0, 2) == 0) ? 0f : 30f, Random.Range(0f, 359f), (Random.Range(0, 2) == 0) ? 0f : 120f); val5.SetActive(true); if (Random.Range(0, 2) == 0) { val5.transform.localScale = goldBarTemplate.transform.localScale - new Vector3(0.8f, 0.8f, 0.8f); } } for (int j = 0; j < physicsGoldBarCount; j++) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } GameObject val6 = Object.Instantiate(goldBarTemplate, base.roomTransform); val6.transform.position = new Vector3(172.4147f + Random.Range(-0.6f, 0.6f), 15f + 0.1f * (float)j, -58.9158f + Random.Range(-0.6f, 0.6f)); val6.transform.rotation = Quaternion.Euler((Random.Range(0, 2) == 0) ? 0f : 30f, Random.Range(0f, 359f), (Random.Range(0, 2) == 0) ? 0f : 120f); val6.SetActive(true); if (Random.Range(0, 2) == 0) { val6.transform.localScale = goldBarTemplate.transform.localScale - new Vector3(0.8f, 0.8f, 0.8f); } } Object.Destroy((Object)(object)goldBarTemplate); } } public static readonly List upstairsRoomCenters = new List { new Vector3(170.7373f, 14.25f, -53.7164f), new Vector3(170.7373f, 14.25f, -60.0944f), new Vector3(156.7373f, 14.25f, -60.0944f), new Vector3(156.7373f, 14.25f, -53.7164f) }; public static readonly List downstairsRoomCenters = new List { new Vector3(157.1746f, 10.5f, -56.9532f), new Vector3(169.755f, 10.5f, -56.9532f) }; public static readonly List lootSafeSpawns = new List { new SafeSpawnSpot(new Vector3(153.63f, 14.42f, -56.13f), new Vector3(0f, 0f, 0f)), new SafeSpawnSpot(new Vector3(159.43f, 14.42f, -57.73f), new Vector3(0f, 90f, 0f)), new SafeSpawnSpot(new Vector3(173.43f, 14.42f, -57.89f), new Vector3(0f, 180f, 0f)), new SafeSpawnSpot(new Vector3(166.56f, 14.42f, -51.41f), new Vector3(0f, 75f, 0f)) }; public static Dictionary buildablesMap = new Dictionary { { "CoffeeTable", null }, { "DisplayCabinet", null }, { "FloorLamp", null }, { "GrandfatherClock", null }, { "Jukebox_Built", null }, { "MetalSquareTable", null }, { "MixingStation_Built", null }, { "Painting_Rapscallion", null }, { "SingleBed", null }, { "Small Safe", null }, { "TV_Built", null }, { "WoodSquareTable", null }, { "GoldenToilet", null } }; public static StorageEntity questSafe = null; public static Action onSafeBuilt; public static Jukebox activeJukebox = null; public static List roomsGenerated = new List(); public static List nonRoomObjects = new List(); public static bool goldenRoomWasGenerated = false; private static Quaternion doorOrigRot; public static IEnumerator SetupManor() { Manor val = Object.FindObjectOfType(true); if ((Object)(object)val == (Object)null) { yield break; } AudioClip open = null; AudioClip close = null; Transform val2 = ((Component)val).transform.Find("Doors"); if (!((Object)(object)val2 != (Object)null)) { yield break; } if (val2.childCount > 0) { Transform child = val2.GetChild(0); for (int i = 0; i < child.childCount; i++) { if (((Object)child.GetChild(i)).name.ToLower().Contains("audio source")) { if (((Object)child.GetChild(i)).name.ToLower().Contains("closet_heavy_open")) { AudioSource component = ((Component)child.GetChild(i)).gameObject.GetComponent(); open = ((component != null) ? component.clip : null); } else if (((Object)child.GetChild(i)).name.ToLower().Contains("door_close")) { AudioSource component2 = ((Component)child.GetChild(i)).gameObject.GetComponent(); close = ((component2 != null) ? component2.clip : null); } } } } ((Component)val2).gameObject.SetActive(false); Transform val3 = val.OriginalContainer.transform.Find("MansionDoor (1)"); if ((Object)(object)val3 == (Object)null) { yield break; } Transform doorContainer = val3.Find("Container"); if ((Object)(object)doorContainer == (Object)null) { yield break; } Transform val4 = val.OriginalContainer.transform.Find("MansionDoor"); if ((Object)(object)val4 == (Object)null) { yield break; } Transform val5 = val4.Find("Container"); if ((Object)(object)val5 == (Object)null) { yield break; } ((Behaviour)((Component)val5.GetChild(0)).GetComponent()).enabled = false; ((Behaviour)((Component)val5.GetChild(1)).GetComponent()).enabled = false; doorOrigRot = ((Component)doorContainer).transform.localRotation; InteractableObject exteriorIntObj = ((Component)doorContainer.GetChild(0)).GetComponent(); InteractableObject interiorIntObj = ((Component)doorContainer.GetChild(1)).GetComponent(); UnityAction doorInteractedAction = null; exteriorIntObj.message = "Open Door"; doorInteractedAction = UnityAction.op_Implicit((Action)onDoorInteracted); exteriorIntObj.onInteractStart.AddListener(doorInteractedAction); exteriorIntObj.MaxInteractionRange = 2f; UnityAction interiorDoorInteractedAction = null; interiorDoorInteractedAction = UnityAction.op_Implicit((Action)onInteriorDoorInteracted); interiorIntObj.onInteractStart.AddListener(interiorDoorInteractedAction); interiorIntObj.MaxInteractionRange = 3f; interiorIntObj.message = "Leave Manor"; List list = new List { val.OriginalContainer.transform.GetChild(3), val.OriginalContainer.transform.GetChild(4), val.OriginalContainer.transform.GetChild(5) }; foreach (Transform item in list) { ((Component)item).gameObject.SetActive(true); ToggleableLight[] lights = Il2CppArrayBase.op_Implicit(((Component)item).GetComponentsInChildren()); if (lights.Length == 0) { continue; } yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } ToggleableLight[] array = lights; foreach (ToggleableLight light in array) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } light.isOn = true; } } onSafeBuilt = delegate { CartelEnforcer.coros.Add(MelonCoroutines.Start(PrepareSafe())); }; CartelEnforcer.coros.Add(MelonCoroutines.Start(GenerateRooms())); void onDoorInteracted() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if ((int)EndGameQuest.activeManorQuest.QuestEntry_BreakIn.State == 1) { CartelEnforcer.coros.Add(MelonCoroutines.Start(LerpDoorRotation(doorContainer, (Action)EndGameQuest.activeManorQuest.QuestEntry_BreakIn.Complete, open, close))); CartelEnforcer.coros.Add(MelonCoroutines.Start(DoorEnterAnimation(enterBuilding: true))); CartelEnforcer.coros.Add(MelonCoroutines.Start(OnDoorFirstEntered())); if ((Delegate)(object)doorInteractedAction != (Delegate)null) { exteriorIntObj.onInteractStart.RemoveListener(doorInteractedAction); doorInteractedAction = null; } } } void onInteriorDoorInteracted() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 if ((int)EndGameQuest.activeManorQuest.QuestEntry_EscapeManor.State == 1 || (int)EndGameQuest.activeManorQuest.QuestEntry_SearchResidence.State == 1 || (int)EndGameQuest.activeManorQuest.QuestEntry_DefeatManorGoons.State == 1) { CartelEnforcer.coros.Add(MelonCoroutines.Start(LerpDoorRotation(doorContainer, null, open, close))); CartelEnforcer.coros.Add(MelonCoroutines.Start(DoorEnterAnimation(enterBuilding: false))); if ((Delegate)(object)interiorDoorInteractedAction != (Delegate)null) { interiorIntObj.onInteractStart.RemoveListener(interiorDoorInteractedAction); interiorDoorInteractedAction = null; } } } } public static IEnumerator InitManorItemRef() { NetworkManager val = Object.FindObjectOfType(true); PrefabObjects spawnablePrefabs = val.SpawnablePrefabs; List keys = new List(buildablesMap.Keys); for (int i = 0; i < spawnablePrefabs.GetObjectCount(); i++) { yield return CartelEnforcer.Wait01; if (!CartelEnforcer.registered) { yield break; } if (keys.Count == 0) { break; } NetworkObject val2 = spawnablePrefabs.GetObject(true, i); string text = ((val2 != null) ? ((Object)((Component)val2).gameObject).name : null); if (text.Contains("Safe_Built")) { NetworkObject val3 = Object.Instantiate(val2); ((Component)val3).gameObject.SetActive(false); ((Component)val3).transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); ((Component)val3).transform.rotation = Quaternion.Euler(0f, 0f, 90f); if ((Object)(object)buildablesMap["Small Safe"] == (Object)null) { buildablesMap["Small Safe"] = val3; } keys.Remove("Small Safe"); continue; } string text2 = string.Empty; foreach (string item in keys) { if ((Object)(object)buildablesMap[item] == (Object)null && text.Contains(item) && !text.Contains("BoxSUV")) { buildablesMap[item] = val2; text2 = item; break; } } if (text2 != string.Empty) { keys.Remove(text2); } } foreach (KeyValuePair item2 in buildablesMap) { _ = item2; } } public static void ResetManorItemRef() { foreach (string item in buildablesMap.Keys.ToList()) { buildablesMap[item] = null; } questSafe = null; activeJukebox = null; onSafeBuilt = null; goldenRoomWasGenerated = false; roomsGenerated.Clear(); nonRoomObjects.Clear(); EndGameQuest.manorGoons.Clear(); EndGameQuest.manorGoonGuids.Clear(); } public static IEnumerator GenerateRooms() { bool flag = false; bool flag2 = false; if (Random.Range(0f, 1f) < 0.75f) { flag = true; if (Random.Range(0f, 1f) < 0.5f) { flag2 = true; } } DownstairsKitchenRoom downstairsKitchenRoom = new DownstairsKitchenRoom(); downstairsKitchenRoom.roomCenter = downstairsRoomCenters[0]; downstairsKitchenRoom.roomRotation = Vector3.zero; downstairsKitchenRoom.roomTransform = new GameObject("CE_ManorKitchenRoom").transform; downstairsKitchenRoom.canGenerateSafe = false; downstairsKitchenRoom.waitInstantiateEach = CartelEnforcer.Wait05; roomsGenerated.Add(downstairsKitchenRoom); DownstairsLivingRoom downstairsLivingRoom = new DownstairsLivingRoom(); downstairsLivingRoom.roomCenter = downstairsRoomCenters[1]; downstairsLivingRoom.roomRotation = Vector3.zero; downstairsLivingRoom.roomTransform = new GameObject("CE_ManorLivingRoom").transform; downstairsLivingRoom.canGenerateSafe = false; downstairsLivingRoom.waitInstantiateEach = CartelEnforcer.Wait05; roomsGenerated.Add(downstairsLivingRoom); int num = 1; if (Random.Range(0, 1000) == 0 || CartelEnforcer.currentConfig.debugMode) { ExceedinglyRareGoldenRoomWithThomasTakingAShitOnAGoldenToilet exceedinglyRareGoldenRoomWithThomasTakingAShitOnAGoldenToilet = new ExceedinglyRareGoldenRoomWithThomasTakingAShitOnAGoldenToilet(); exceedinglyRareGoldenRoomWithThomasTakingAShitOnAGoldenToilet.roomTransform = new GameObject("CE_ToiletRoom").transform; exceedinglyRareGoldenRoomWithThomasTakingAShitOnAGoldenToilet.roomCenter = upstairsRoomCenters[num]; exceedinglyRareGoldenRoomWithThomasTakingAShitOnAGoldenToilet.roomRotation = Vector3.zero; exceedinglyRareGoldenRoomWithThomasTakingAShitOnAGoldenToilet.canGenerateSafe = false; roomsGenerated.Add(exceedinglyRareGoldenRoomWithThomasTakingAShitOnAGoldenToilet); Quest_InfiltrateManor activeManorQuest = EndGameQuest.activeManorQuest; ((Quest)activeManorQuest).CompletionXP = ((Quest)activeManorQuest).CompletionXP + 1500; } else { num = -1; } UpstairsLivingRoom upstairsLivingRoom = new UpstairsLivingRoom(); int num2 = Random.Range(0, upstairsRoomCenters.Count); if (num2 == num) { num2 = (num2 + 1) % upstairsRoomCenters.Count; } upstairsLivingRoom.roomCenter = upstairsRoomCenters[num2]; upstairsLivingRoom.roomRotation = Vector3.zero; upstairsLivingRoom.roomTransform = new GameObject("CE_ManorUpstairLiving").transform; upstairsLivingRoom.canGenerateSafe = flag2 && flag; upstairsLivingRoom.waitInstantiateEach = CartelEnforcer.Wait05; roomsGenerated.Add(upstairsLivingRoom); UpstairsBedRoom upstairsBedRoom = new UpstairsBedRoom(); int num3 = Random.Range(0, upstairsRoomCenters.Count); while (num3 == num2 || num3 == num) { num3 = (num3 + 1) % upstairsRoomCenters.Count; } upstairsBedRoom.roomCenter = upstairsRoomCenters[num3]; upstairsBedRoom.roomRotation = Vector3.zero; upstairsBedRoom.roomTransform = new GameObject("CE_ManorUpstairBed").transform; upstairsBedRoom.canGenerateSafe = !flag2 && flag; upstairsBedRoom.waitInstantiateEach = CartelEnforcer.Wait05; roomsGenerated.Add(upstairsBedRoom); foreach (RoomDesignBase item in roomsGenerated) { CartelEnforcer.coros.Add(MelonCoroutines.Start(item.SpawnDesign())); } NetworkObject clock = Object.Instantiate(buildablesMap["GrandfatherClock"]); ((Component)clock).transform.position = new Vector3(161.5f, 10.5f, -56f); ((Component)clock).transform.rotation = Quaternion.Euler(0f, 90f, 0f); NetworkObject val = Object.Instantiate(buildablesMap["Painting_Rapscallion"]); ((Component)val).transform.position = new Vector3(161.28f, 12.465f, -59f); ((Component)val).transform.rotation = Quaternion.Euler(0f, 90f, 0f); nonRoomObjects.Add(((Component)clock).gameObject); nonRoomObjects.Add(((Component)val).gameObject); if (!flag) { int index = Random.Range(0, lootSafeSpawns.Count); NetworkObject nob = Object.Instantiate(buildablesMap["Small Safe"]); questSafe = ((Component)nob).GetComponent(); ((Component)nob).transform.position = lootSafeSpawns[index].spawnSpot; ((Component)nob).transform.rotation = Quaternion.Euler(lootSafeSpawns[index].eulerAngles.x, lootSafeSpawns[index].eulerAngles.y, 90f); nonRoomObjects.Add(((Component)nob).gameObject); yield return CartelEnforcer.Wait05; ((Component)nob).gameObject.SetActive(true); yield return CartelEnforcer.Wait05; ((Component)nob).gameObject.SetActive(true); if (onSafeBuilt != null) { onSafeBuilt(); } } yield return CartelEnforcer.Wait2; foreach (GameObject nonRoomObject in nonRoomObjects) { nonRoomObject.SetActive(true); } Transform val2 = ((Component)clock).transform.Find("Grandfather Clock"); Animation val3 = default(Animation); if ((Object)(object)val2 != (Object)null && ((Component)val2).TryGetComponent(ref val3)) { val3.Play(); } } public static IEnumerator PrepareSafe() { onSafeBuilt = null; Action onOpenedAction = null; onOpenedAction = Action.op_Implicit((Action)SecondaryTrigger); StorageEntity obj = questSafe; obj.onOpened += onOpenedAction; questSafe.StorageEntitySubtitle = "Thomas' Safe"; Func func = Registry.GetItem; int num = 5; int num2 = 0; if (Random.Range(0f, 1f) > 0.666f) { ItemInstance defaultInstance = func("m1911").GetDefaultInstance(1); questSafe.InsertItem(defaultInstance, true); num2++; } if (Random.Range(0f, 1f) > 0.9f) { ItemInstance defaultInstance2 = func("cocaine").GetDefaultInstance(Random.Range(12, 20)); questSafe.InsertItem(defaultInstance2, true); num2++; } ItemInstance defaultInstance3 = func("m1911mag").GetDefaultInstance(1); questSafe.InsertItem(defaultInstance3, true); num2++; bool flag = false; if (Random.Range(0f, 1f) > 0.3f && num2 <= num) { int num3 = Random.Range(3, 7); ItemInstance defaultInstance4 = func("goldbar").GetDefaultInstance(num3); questSafe.InsertItem(defaultInstance4, true); flag = true; num2++; } if (num2 <= num && !flag) { ItemInstance defaultInstance5 = func("cash").GetDefaultInstance(1); CashInstance val = ((Il2CppObjectBase)defaultInstance5).TryCast(); if (val != null) { val.Balance = 1000f; } questSafe.InsertItem(defaultInstance5, true); num2++; } if (Random.Range(0f, 1f) > 0.4f && num2 <= num) { ItemInstance defaultInstance6 = func("silverwatch").GetDefaultInstance(1); questSafe.InsertItem(defaultInstance6, true); num2++; } if (Random.Range(0f, 1f) > 0.4f && num2 <= num) { ItemInstance defaultInstance7 = func("silverchain").GetDefaultInstance(1); questSafe.InsertItem(defaultInstance7, true); } void SecondaryTrigger() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if ((int)EndGameQuest.activeManorQuest.QuestEntry_SearchResidence.State == 1) { EndGameQuest.activeManorQuest.QuestEntry_SearchResidence.Complete(); } if ((Delegate)(object)onOpenedAction != (Delegate)null) { StorageEntity obj2 = questSafe; obj2.onOpened -= onOpenedAction; onOpenedAction = null; } } yield break; } public static IEnumerator CleanupManor() { yield return CartelEnforcer.Wait60; if (!CartelEnforcer.registered) { yield break; } Manor val = Object.FindObjectOfType(true); Transform val2 = ((Component)val).transform.Find("Doors"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(true); } Transform val3 = val.OriginalContainer.transform.Find("MansionDoor (1)"); if ((Object)(object)val3 == (Object)null) { Transform val4 = val3.Find("Container"); if (!((Object)(object)val4 == (Object)null)) { ((Component)val4).transform.localRotation = doorOrigRot; } } List list = new List { val.OriginalContainer.transform.GetChild(3), val.OriginalContainer.transform.GetChild(4), val.OriginalContainer.transform.GetChild(5) }; foreach (Transform item in list) { ((Component)item).gameObject.SetActive(false); ToggleableLight[] lights = Il2CppArrayBase.op_Implicit(((Component)item).GetComponentsInChildren()); if (lights.Length == 0) { continue; } yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } ToggleableLight[] array = lights; foreach (ToggleableLight light in array) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } light.isOn = false; } } foreach (CartelGoon goon in EndGameQuest.manorGoons) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { ((NPC)goon).NPCData.Health.MaxHealth = 100f; ((NPC)goon).Health.Health = 100f; ((NPC)goon).Behaviour.CombatBehaviour.GiveUpRange = EndGameQuest.activeManorQuest.GiveUpRange; ((NPC)goon).Behaviour.CombatBehaviour.GiveUpAfterSuccessfulHits = EndGameQuest.activeManorQuest.GiveUpAfterSuccessfulHits; ((NPC)goon).Behaviour.CombatBehaviour.DefaultSearchTime = EndGameQuest.activeManorQuest.DefaultSearchTime; ((Component)((NPC)goon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); ((NPC)goon).Behaviour.ScheduleManager.EnableSchedule(); if (goon.IsGoonSpawned) { goon.Despawn(); } continue; } yield break; } if (goldenRoomWasGenerated) { ((Component)DriveByEvent.thomasInstance).transform.localPosition = DriveByEvent.localOrigin; ((Component)DriveByEvent.thomasInstance).transform.localRotation = DriveByEvent.localRotation; } foreach (RoomDesignBase room in roomsGenerated) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { Object.Destroy((Object)(object)((Component)room.roomTransform).gameObject); continue; } yield break; } foreach (GameObject go in nonRoomObjects) { yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { Object.Destroy((Object)(object)go); continue; } yield break; } ResetManorItemRef(); } public static IEnumerator LerpDoorRotation(Transform tr, Action cb, AudioClip open, AudioClip close) { AudioSource source = ((Component)tr).gameObject.AddComponent(); source.volume = 0.2f; source.clip = open; Quaternion targetRotation = Quaternion.Euler(0f, 75f, 0f); Quaternion startRotation = tr.localRotation; float duration = 1.5f; float elapsedTime = 0f; source.Play(); while (elapsedTime < duration && CartelEnforcer.registered) { float num = elapsedTime / duration; tr.localRotation = Quaternion.Lerp(startRotation, targetRotation, num); elapsedTime += Time.deltaTime; yield return null; } tr.localRotation = targetRotation; yield return (object)new WaitForSeconds(3.8f); if (CartelEnforcer.registered) { duration = 1f; elapsedTime = 0f; while (elapsedTime < duration && CartelEnforcer.registered) { float num2 = elapsedTime / duration; tr.localRotation = Quaternion.Lerp(targetRotation, startRotation, num2); elapsedTime += Time.deltaTime; yield return null; } source.clip = close; source.Play(); tr.localRotation = startRotation; cb?.Invoke(); Object.Destroy((Object)(object)source); } } public static IEnumerator DoorEnterAnimation(bool enterBuilding) { Singleton.Instance.ExitAll(); PlayerSingleton.Instance.SetCanLook(false); PlayerSingleton.Instance.CanMove = false; Transform playerTr = ((Component)PlayerSingleton.Instance).transform.root; Vector3 sidePos = new Vector3(162.7173f, 11.1317f, -48.8222f); Quaternion sideRot = Quaternion.Euler(0f, enterBuilding ? 160f : 0f, 0f); Vector3 insidePos = new Vector3(163.4521f, 11.465f, -51.942f); Quaternion insideRot = Quaternion.Euler(0f, enterBuilding ? 185f : 10f, 0f); float elapsed = 0f; float dur = 1f; Vector3 startPos = playerTr.position; Quaternion startRot = playerTr.rotation; Vector3 startOrigin = (enterBuilding ? sidePos : insidePos); Quaternion startOriginRot = (enterBuilding ? sideRot : insideRot); while (elapsed < dur && CartelEnforcer.registered) { float num = elapsed / dur; playerTr.position = Vector3.Lerp(startPos, startOrigin, num); playerTr.rotation = Quaternion.Slerp(startRot, startOriginRot, num); elapsed += Time.deltaTime; yield return null; } yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } elapsed = 0f; dur = 3f; startPos = playerTr.position; startRot = playerTr.rotation; Vector3 nextPos = (enterBuilding ? insidePos : sidePos); Quaternion nextRot = (enterBuilding ? insideRot : sideRot); while (elapsed < dur && CartelEnforcer.registered) { float num2 = elapsed / dur; playerTr.position = Vector3.Lerp(startPos, nextPos, num2); playerTr.rotation = Quaternion.Slerp(startRot, nextRot, num2); elapsed += Time.deltaTime; yield return null; } playerTr.position = nextPos; playerTr.rotation = nextRot; yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { elapsed = 0f; dur = 0.5f; startRot = playerTr.rotation; while (elapsed < dur && CartelEnforcer.registered) { float num3 = elapsed / dur; playerTr.rotation = Quaternion.Slerp(startRot, Quaternion.Euler(0f, enterBuilding ? 0f : 165f, 0f), num3); elapsed += Time.deltaTime; yield return null; } PlayerSingleton.Instance.SetCanLook(true); PlayerSingleton.Instance.CanMove = true; } } public static IEnumerator OnDoorFirstEntered() { if (Singleton.Instance.IsAnyTrackPlaying) { Singleton.Instance.StopAndDisableTracks(); } if ((Object)(object)activeJukebox == (Object)null) { yield break; } int num = 0; for (int i = 0; i < ((Il2CppArrayBase)(object)activeJukebox.TrackList).Length; i++) { if (((Il2CppArrayBase)(object)activeJukebox.TrackList)[i] != null && ((Il2CppArrayBase)(object)activeJukebox.TrackList)[i].TrackName.ToLower().Contains("royalty in loyalty")) { num = i; break; } } activeJukebox.PlayTrack(num); EndGameQuest.activeManorQuest.isJukeboxPlaying = true; yield return CartelEnforcer.Wait2; if (CartelEnforcer.registered) { Jukebox obj = activeJukebox; obj.onStateChanged += Action.op_Implicit((Action)OnJukeboxStateChange); } } public static void OnJukeboxStateChange() { if (EndGameQuest.activeManorQuest.isJukeboxPlaying) { EndGameQuest.activeManorQuest.isJukeboxPlaying = false; if (!((Object)(object)activeJukebox == (Object)null)) { activeJukebox.SetVolume(0, false); } } } } [HarmonyPatch(typeof(Dealer), "TryRobDealer")] public static class DealerRobberyPatch { private static bool IsPlayerNearby(Dealer dealer, float maxDistance = 120f) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(((Component)dealer).transform.position, ((Component)Player.Local).transform.position) < maxDistance; } private static void Original(Dealer __instance) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown float num = 0f; Enumerator enumerator = ((NPC)__instance).Inventory.ItemSlots.GetEnumerator(); while (enumerator.MoveNext()) { ItemSlot current = enumerator.Current; if (current.ItemInstance != null) { StorableItemDefinition val = ((Il2CppObjectBase)current.ItemInstance.Definition).TryCast(); if ((Object)(object)val != (Object)null) { num = Mathf.Max(num, val.CombatUtility); } } } float num2 = Random.Range(0f, 1f); num2 = Mathf.Lerp(num2, 1f, num * 0.5f); if (num2 > 0.67f) { ((NPC)__instance).MSGConversation.SendMessage(new Message(((NPC)__instance).DialogueHandler.Database.GetLine((EDialogueModule)6, "dealer_rob_defended"), (ESenderType)1, false, -1), true, true); return; } if (num2 > 0.25f) { ((NPC)__instance).MSGConversation.SendMessage(new Message(((NPC)__instance).DialogueHandler.Database.GetLine((EDialogueModule)6, "dealer_rob_partially_defended"), (ESenderType)1, false, -1), true, true); List list = new List(); float num3 = 1f - Mathf.InverseLerp(0.25f, 0.67f, num2); for (int i = 0; i < ((NPC)__instance).Inventory.ItemSlots.Count; i++) { if (((NPC)__instance).Inventory.ItemSlots[i].ItemInstance != null) { float num4 = num3 * 0.8f; if (Random.Range(0f, 1f) < num4) { int num5 = Mathf.RoundToInt((float)((BaseItemInstance)((NPC)__instance).Inventory.ItemSlots[i].ItemInstance).Quantity * num3); list.Add(((NPC)__instance).Inventory.ItemSlots[i].ItemInstance.GetCopy(num5)); ((NPC)__instance).Inventory.ItemSlots[i].ChangeQuantity(-num5, false); } } } __instance.TryMoveOverflowItems(); float num6 = __instance.Cash * num3; __instance.ChangeCash(0f - num6); SummarizeLosses(__instance, list, num6); return; } ((NPC)__instance).MSGConversation.SendMessage(new Message(((NPC)__instance).DialogueHandler.Database.GetLine((EDialogueModule)6, "dealer_rob_loss"), (ESenderType)1, false, -1), true, true); List list2 = new List(); enumerator = ((NPC)__instance).Inventory.ItemSlots.GetEnumerator(); while (enumerator.MoveNext()) { ItemSlot current2 = enumerator.Current; if (current2.ItemInstance != null) { list2.Add(current2.ItemInstance.GetCopy(((BaseItemInstance)current2.ItemInstance).Quantity)); } } ((NPC)__instance).Inventory.Clear(); foreach (ItemSlot item in (Il2CppArrayBase)(object)__instance.overflowSlots) { if (item.ItemInstance != null) { list2.Add(item.ItemInstance.GetCopy(((BaseItemInstance)item.ItemInstance).Quantity)); item.ClearStoredInstance(false); } } float cash = __instance.Cash; __instance.ChangeCash(0f - cash); SummarizeLosses(__instance, list2, cash); static void SummarizeLosses(Dealer val4, List items, float num7) { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if (items.Count != 0 || !(num7 <= 0f)) { CartelEnforcer.coros.Add(MelonCoroutines.Start(CartelInventory.CartelStealsItems(items))); CartelInventory.cartelCashAmount += num7; List list3 = new List(); for (int j = 0; j < items.Count; j++) { string text = ((BaseItemInstance)items[j]).Quantity + "x "; ProductItemInstance val2 = ((Il2CppObjectBase)items[j]).TryCast(); if (val2 != null && (Object)(object)val2.AppliedPackaging != (Object)null) { text = text + ((BaseItemDefinition)val2.AppliedPackaging).Name + " of "; } text += ((BaseItemDefinition)items[j].Definition).Name; QualityItemInstance val3 = ((Il2CppObjectBase)items[j]).TryCast(); if (val3 != null) { text = text + " (" + ((object)val3.Quality/*cast due to .constrained prefix*/).ToString() + " quality)"; } list3.Add(text); } if (num7 > 0f) { list3.Add(MoneyManager.FormatAmount(num7, false, false) + " cash"); } string text2 = "This is what they got:\n" + string.Join("\n", list3); ((NPC)val4).MSGConversation.SendMessage(new Message(text2, (ESenderType)1, true, -1), false, true); } } } [HarmonyPrefix] public static bool Prefix(Dealer __instance) { if (((NPC)__instance).RelationData.Unlocked && __instance.IsRecruited && !((NPC)__instance).Health.IsDead && !((NPC)__instance).Health.IsKnockedOut && !((NPC)__instance).isInBuilding) { if (IsPlayerNearby(__instance) && CartelEnforcer.currentConfig.realRobberyEnabled && NetworkSingleton.Instance.GoonPool.unspawnedGoons.Count > 0) { CartelEnforcer.coros.Add(MelonCoroutines.Start(DealerRobbery.RobberyCombatCoroutine(__instance))); } else if (CartelEnforcer.currentConfig.defaultRobberyEnabled) { Original(__instance); } } return false; } } public static class DealerRobbery { public static IEnumerator RobberyCombatCoroutine(Dealer dealer) { EMapRegion region = (EMapRegion)0; for (int i = 0; i < ((Il2CppArrayBase)(object)Singleton.Instance.Regions).Length; i++) { if (((Il2CppArrayBase)(object)Singleton.Instance.Regions)[i].RegionBounds.IsPointInsidePolygon(((NPC)dealer).CenterPointTransform.position)) { region = ((Il2CppArrayBase)(object)Singleton.Instance.Regions)[i].Region; } } _ = Vector3.zero; int maxAttempts = 6; int j = 0; Vector3 val2 = default(Vector3); do { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } Vector3 onUnitSphere = Random.onUnitSphere; onUnitSphere.y = 0f; ((Vector3)(ref onUnitSphere)).Normalize(); float num = Random.Range(8f, 16f); Vector3 val = ((Component)dealer).transform.position + onUnitSphere * num; ((NPC)dealer).Movement.GetClosestReachablePoint(val, ref val2); j++; } while (val2 == Vector3.zero && j <= maxAttempts); if (val2 == Vector3.zero) { yield break; } CartelGoon goon = NetworkSingleton.Instance.GoonPool.SpawnGoon(val2); if ((Object)(object)goon == (Object)null) { yield break; } string text = Random.Range(0, 5) switch { 0 => "HELP BOSS!! Benzies are trying to ROB ME!!", 1 => "BOSS!! I'm getting robbed!", 2 => "I'm being jumped, come back me up!", 3 => "Benzies set me up!! Come help quick!", 4 => "Help, boss! I'm getting ambushed!", _ => "HELP BOSS!! Benzies are trying to ROB ME!!", }; ((NPC)dealer).MSGConversation.SendMessage(new Message(text, (ESenderType)1, false, -1), true, true); if (Random.Range(0f, 1f) > 0.7f) { ((NPC)goon).Behaviour.CombatBehaviour.SetWeapon("Avatar/Equippables/M1911"); if ((Object)(object)((NPC)goon).Behaviour.CombatBehaviour.currentWeapon != (Object)null) { AvatarRangedWeapon val3 = ((Il2CppObjectBase)((NPC)goon).Behaviour.CombatBehaviour.currentWeapon).TryCast(); if ((Object)(object)val3 != (Object)null) { val3.AimTime_Max = 0.33f; val3.AimTime_Min = 0.1f; val3.CanShootWhileMoving = true; ((AvatarWeapon)val3).MinUseRange = 0.1f; } } } else if (AmbushOverrides.MeleeWeapons != null && AmbushOverrides.MeleeWeapons.Length != 0) { ((NPC)goon).Behaviour.CombatBehaviour.SetDefaultWeapon(AmbushOverrides.MeleeWeapons[Random.Range(0, AmbushOverrides.MeleeWeapons.Length)]); AvatarMeleeWeapon val4 = null; if ((Object)(object)((NPC)goon).Behaviour.CombatBehaviour._defaultWeapon != (Object)null) { val4 = ((Il2CppObjectBase)((NPC)goon).Behaviour.CombatBehaviour._defaultWeapon).TryCast(); } if ((Object)(object)val4 != (Object)null) { val4.AttackRadius = 2.8f; val4.AttackRange = 3.5f; ((AvatarWeapon)val4).MaxUseRange = 3.5f; ((AvatarWeapon)val4).MinUseRange = 0.01f; ((AvatarWeapon)val4).CooldownDuration = 1.2f; val4.Damage = 44f; } } ((NPC)goon).Movement.Warp(val2); yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { ((NPC)dealer).Behaviour.CombatBehaviour.SetTarget(((Component)goon).GetComponent().NetworkObject); ((Behaviour)((NPC)dealer).Behaviour.CombatBehaviour).Enable_Networked(); ((NPC)goon).NPCData.Health.MaxHealth = 160f; ((NPC)goon).Health.Health = 160f; goon.AttackEntity(((Component)((NetworkBehaviour)dealer).NetworkObject).GetComponent(), true); CartelEnforcer.coros.Add(MelonCoroutines.Start(StateRobberyCombat(dealer, goon, region))); } } public static IEnumerator StateRobberyCombat(Dealer dealer, CartelGoon goon, EMapRegion region) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) bool changeInfluence = InfluenceOverrides.ShouldChangeInfluence(region); int maxWaitSec = 60; float elapsed = 0f; float num = 159f; while (!((NPC)dealer).Health.IsDead && !((NPC)dealer).Health.IsKnockedOut && !((NPC)goon).Health.IsDead && !((NPC)goon).Health.IsKnockedOut && num <= 160f && elapsed < (float)maxWaitSec) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } num = Vector3.Distance(Player.Local.CenterPointTransform.position, ((NPC)dealer).CenterPointTransform.position); elapsed += 0.5f; } if (((NPC)dealer).Health.IsDead || !((NPC)dealer).IsConscious || ((NPC)dealer).Health.IsKnockedOut) { ((NPC)goon).Inventory.Clear(); ((NPC)goon).Behaviour.ScheduleManager.DisableSchedule(); ((Component)((NPC)goon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { yield break; } if (((NPC)goon).Health.IsDead || !((NPC)goon).IsConscious || ((NPC)goon).Health.IsKnockedOut) { CartelEnforcer.coros.Add(MelonCoroutines.Start(EndBodyLootPrematurely(goon))); yield break; } ((NPC)goon).Movement.FacePoint(((NPC)dealer).CenterPointTransform.position, 0.3f); ((NPC)goon).Movement.SetDestination(((NPC)dealer).CenterPoint); float num2 = 10f; int n = 0; while (num2 > 2f && n < 24) { n++; yield return CartelEnforcer.Wait025; if (!CartelEnforcer.registered) { yield break; } if (((NPC)goon).Health.IsDead || !((NPC)goon).IsConscious || ((NPC)goon).Health.IsKnockedOut) { CartelEnforcer.coros.Add(MelonCoroutines.Start(EndBodyLootPrematurely(goon))); yield break; } num2 = Vector3.Distance(((NPC)goon).CenterPoint, ((NPC)dealer).CenterPoint); } ((NPC)goon).Avatar.Animation.SetCrouched(true); ((NPC)goon).Movement.Stop(); int availableSlots = 0; for (int i = 0; i < ((NPC)goon).Inventory.ItemSlots.Count; i++) { if (((NPC)goon).Inventory.ItemSlots[i].ItemInstance == null) { availableSlots++; } } int takenSlots = 0; for (int j = 0; j < ((NPC)dealer).Inventory.ItemSlots.Count; j++) { if (takenSlots >= availableSlots) { break; } yield return CartelEnforcer.Wait025; if (!CartelEnforcer.registered) { yield break; } if (((NPC)goon).Health.IsDead || !((NPC)goon).IsConscious || ((NPC)goon).Health.IsKnockedOut) { CartelEnforcer.coros.Add(MelonCoroutines.Start(EndBodyLootPrematurely(goon))); yield break; } if (((NPC)dealer).Inventory.ItemSlots[j].ItemInstance != null) { int num3 = Mathf.Max(1, Mathf.RoundToInt((float)((BaseItemInstance)((NPC)dealer).Inventory.ItemSlots[j].ItemInstance).Quantity * 0.6f)); ItemInstance copy = ((NPC)dealer).Inventory.ItemSlots[j].ItemInstance.GetCopy(num3); if (((NPC)goon).Inventory.CanItemFit(copy)) { ((NPC)dealer).Inventory.ItemSlots[j].ChangeQuantity(-num3, false); ((NPC)goon).Inventory.InsertItem(copy, true); takenSlots++; } } } dealer.TryMoveOverflowItems(); ((NPC)goon).SetAnimationTrigger("GrabItem"); yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } if (((NPC)goon).Health.IsDead || !((NPC)goon).IsConscious || ((NPC)goon).Health.IsKnockedOut) { CartelEnforcer.coros.Add(MelonCoroutines.Start(EndBodyLootPrematurely(goon))); yield break; } if (takenSlots < availableSlots && dealer.Cash > 1f) { int num4 = availableSlots - takenSlots; float num5 = Mathf.Clamp(Mathf.Round(dealer.Cash * Random.Range(0.6f, 0.95f)), 1f, 1000f * (float)num4); dealer.ChangeCash(0f - num5); ((NPC)goon).Inventory.AddCash(num5); ((NPC)goon).SetAnimationTrigger("GrabItem"); } ((NPC)goon).Avatar.Animation.SetCrouched(false); CartelEnforcer.coros.Add(MelonCoroutines.Start(NavigateGoonEsacpe(goon, region, changeInfluence))); } else if (((NPC)goon).Health.IsDead || !((NPC)goon).IsConscious || ((NPC)goon).Health.IsKnockedOut) { ((NPC)dealer).MSGConversation.SendMessage(new Message(((NPC)dealer).DialogueHandler.Database.GetLine((EDialogueModule)6, "dealer_rob_defended"), (ESenderType)1, false, -1), true, true); ((Behaviour)((NPC)dealer).Behaviour.CombatBehaviour).Disable_Networked((NetworkConnection)null); CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnSoon(goon))); if (changeInfluence) { NetworkSingleton.Instance.Influence.ChangeInfluence(region, CartelEnforcer.influenceConfig.robberyGoonDead); } } else if (Vector3.Distance(Player.Local.CenterPointTransform.position, ((NPC)goon).CenterPointTransform.position) > 160f) { ((NPC)dealer).MSGConversation.SendMessage(new Message(((NPC)dealer).DialogueHandler.Database.GetLine((EDialogueModule)6, "dealer_rob_defended"), (ESenderType)1, false, -1), true, true); ((Behaviour)((NPC)dealer).Behaviour.CombatBehaviour).Disable_Networked((NetworkConnection)null); ((Behaviour)((NPC)goon).Behaviour.CombatBehaviour).Disable_Networked((NetworkConnection)null); CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnSoon(goon, instant: true))); if (changeInfluence) { NetworkSingleton.Instance.Influence.ChangeInfluence(region, CartelEnforcer.influenceConfig.robberyPlayerEscape); } } else if (elapsed >= 60f) { ((NPC)dealer).MSGConversation.SendMessage(new Message(((NPC)dealer).DialogueHandler.Database.GetLine((EDialogueModule)6, "dealer_rob_defended"), (ESenderType)1, false, -1), true, true); ((Behaviour)((NPC)dealer).Behaviour.CombatBehaviour).Disable_Networked((NetworkConnection)null); ((Behaviour)((NPC)goon).Behaviour.CombatBehaviour).Disable_Networked((NetworkConnection)null); CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnSoon(goon, instant: true))); } } public static IEnumerator EndBodyLootPrematurely(CartelGoon goon) { yield return CartelEnforcer.Wait60; if (CartelEnforcer.registered) { CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnSoon(goon, instant: true))); yield return null; } } public static IEnumerator DespawnSoon(CartelGoon goon, bool instant = false) { if (!instant) { yield return CartelEnforcer.Wait60; } if (CartelEnforcer.registered) { if (goon.IsGoonSpawned) { goon.Despawn(); } ((NPC)goon).NPCData.Health.MaxHealth = 100f; ((NPC)goon).Health.Health = 100f; ((NPC)goon).Behaviour.ScheduleManager.EnableSchedule(); ((Component)((NPC)goon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); yield return null; } } public static IEnumerator NavigateGoonEsacpe(CartelGoon goon, EMapRegion region, bool changeInfluence) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!CartelEnforcer.registered) { yield break; } float num = 150f; NPCEnterableBuilding val = null; StaticDoor val2 = null; Vector3 val3 = Vector3.zero; CartelDealer[] allCartelDealers = DealerActivity.allCartelDealers; foreach (CartelDealer val4 in allCartelDealers) { if (!((Object)(object)((Dealer)val4).Home != (Object)null) || ((Dealer)val4).Home.Doors == null || ((Il2CppArrayBase)(object)((Dealer)val4).Home.Doors).Length <= 0) { continue; } StaticDoor val5 = ((Il2CppArrayBase)(object)((Dealer)val4).Home.Doors)[0]; if (!((Object)(object)val5 == (Object)null) && !((Object)(object)val5.AccessPoint == (Object)null)) { float num2 = Vector3.Distance(val5.AccessPoint.position, ((NPC)goon).CenterPointTransform.position); if (num2 < num) { val2 = val5; val = ((Dealer)val4).Home; val3 = val2.AccessPoint.position; num = num2; } } } if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val == (Object)null)) { for (int j = 0; j < ((NPC)goon).Behaviour.ScheduleManager.ActionList.Count; j++) { NPCEvent_StayInBuilding val6 = ((Il2CppObjectBase)((NPC)goon).Behaviour.ScheduleManager.ActionList[j]).TryCast(); if ((Object)(object)val6 != (Object)null) { val6.Door = val2; val6.Building = val; } } } ((NPC)goon).Behaviour.ScheduleManager.EnableSchedule(); ((Behaviour)((NPC)goon).Behaviour.CombatBehaviour).Disable_Networked((NetworkConnection)null); ((NPC)goon).Behaviour.GetBehaviour("Follow Schedule").Enable(); Vector3 closest = default(Vector3); ((NPC)goon).Movement.GetClosestReachablePoint(val3, ref closest); CartelEnforcer.coros.Add(MelonCoroutines.Start(ApplyAdrenalineRush(goon))); bool isFleeing = false; if (val3 == Vector3.zero || !((NPC)goon).Movement.CanGetTo(closest, 1f)) { float num3 = default(float); ((NPC)goon).Behaviour.FleeBehaviour.SetEntityToFlee(((NetworkBehaviour)PlayerManager.GetClosestPlayer(((NPC)goon).CenterPointTransform.position, ref num3, (List)null)).NetworkObject); ((Behaviour)((NPC)goon).Behaviour.FleeBehaviour).Enable_Networked(); isFleeing = true; } else { ((NPC)goon).Movement.SetDestination(closest); } float elapsedNav = 0f; float remainingDist = 100f; for (; elapsedNav < 60f; elapsedNav += 0.5f) { if (!((NPC)goon).IsConscious) { break; } if (!goon.IsGoonSpawned) { break; } if (((NPC)goon).Health.IsDead) { break; } if (((NPC)goon).Health.IsKnockedOut) { break; } if (((NPC)goon).isInBuilding) { break; } yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } if (!isFleeing) { float num4 = Vector3.Distance(closest, ((NPC)goon).CenterPointTransform.position); if (num4 < remainingDist) { remainingDist = num4; } if (Vector3.Distance(closest, ((NPC)goon).CenterPointTransform.position) < 3f) { break; } } } if (!((NPC)goon).Health.IsDead && !((NPC)goon).Health.IsKnockedOut && remainingDist < 5f) { EscapeEndSuccess(changeInfluence, region, goon); } else if (((NPC)goon).Health.IsDead || ((NPC)goon).Health.IsKnockedOut) { if (changeInfluence) { NetworkSingleton.Instance.Influence.ChangeInfluence(region, CartelEnforcer.influenceConfig.robberyGoonEscapeDead); } CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnSoon(goon))); } else if (elapsedNav >= 60f && goon.IsGoonSpawned) { EscapeEndSuccess(changeInfluence, region, goon); } yield return null; } public static void EscapeEndSuccess(bool changeInfluence, EMapRegion region, CartelGoon goon) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (changeInfluence) { NetworkSingleton.Instance.Influence.ChangeInfluence(region, CartelEnforcer.influenceConfig.robberyGoonEscapeSuccess); } List list = new List(); CashInstance val = null; for (int i = 0; i < ((NPC)goon).Inventory.ItemSlots.Count; i++) { if (((NPC)goon).Inventory.ItemSlots[i].ItemInstance != null) { val = ((Il2CppObjectBase)((NPC)goon).Inventory.ItemSlots[i].ItemInstance).TryCast(); if (val != null) { CartelInventory.cartelCashAmount += val.Balance; val = null; continue; } val = null; } if (((NPC)goon).Inventory.ItemSlots[i].ItemInstance != null) { int num = Mathf.Min(((BaseItemInstance)((NPC)goon).Inventory.ItemSlots[i].ItemInstance).Quantity, 20); list.Add(((NPC)goon).Inventory.ItemSlots[i].ItemInstance.GetCopy(num)); } } if (list.Count > 0) { CartelEnforcer.coros.Add(MelonCoroutines.Start(CartelInventory.CartelStealsItems(list, Callback))); } CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnSoon(goon, instant: true))); void Callback() { if ((Object)(object)goon != (Object)null) { ((NPC)goon).Inventory.Clear(); } } } public static IEnumerator ApplyAdrenalineRush(CartelGoon goon) { float origWalk = ((NPC)goon).Movement.WalkSpeed; float origRun = ((NPC)goon).Movement.RunSpeed; ((NPC)goon).NPCData.Movement.WalkSpeed = ((NPC)goon).Movement.WalkSpeed * 3.5f; ((NPC)goon).NPCData.Movement.SprintSpeed = ((NPC)goon).Movement.RunSpeed * 2.5f; ((NPC)goon).Movement.MoveSpeedMultiplier = 1.4f; ((NPC)goon).Health.Health = Mathf.Round(Mathf.Lerp(((NPC)goon).Health.Health, ((NPC)goon).Health.MaxHealth, 0.15f)); for (int i = 0; i < 50; i++) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } ((NPC)goon).NPCData.Movement.WalkSpeed = Mathf.Lerp(((NPC)goon).Movement.WalkSpeed, origWalk, 0.025f); ((NPC)goon).NPCData.Movement.SprintSpeed = Mathf.Lerp(((NPC)goon).Movement.RunSpeed, origRun, 0.025f); ((NPC)goon).Movement.MoveSpeedMultiplier = Mathf.Lerp(((NPC)goon).Movement.MoveSpeedMultiplier, 1f, 0.025f); } ((NPC)goon).NPCData.Movement.WalkSpeed = origWalk; ((NPC)goon).NPCData.Movement.SprintSpeed = origRun; ((NPC)goon).Movement.MoveSpeedMultiplier = 1f; } } public static class SabotageEvent { public class SabotageEventLocation { public Business business { get; private set; } public int hoursUntilEnabled { get; set; } public Tuple bombLocation { get; private set; } public Tuple fireLocation { get; private set; } public List sabotagerSpawns { get; private set; } public SabotageEventLocation(Business business, Tuple bombLocation, Tuple fireLocation, List sabotagerSpawns) { this.business = business; this.bombLocation = bombLocation; this.fireLocation = fireLocation; this.sabotagerSpawns = sabotagerSpawns; hoursUntilEnabled = CartelEnforcer.eventCooldowns.SabotageCooldowns.First((KeyValuePair x) => x.Key == ((Property)business).PropertyName).Value; } public void HourPass() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 if (InstanceFinder.IsServer && ((Property)business).IsOwned && (int)NetworkSingleton.Instance.Status == 2) { hoursUntilEnabled = Mathf.Clamp(hoursUntilEnabled - 1, 0, int.MaxValue); } } } public static GameObject intBomb = null; public static InteractableObject bombInteractable = null; public static CartelGoon sabotager = null; public static Light bombLight = null; public static Material bombCubeMat = null; public static AudioSource bombSound = null; public static GameObject reactiveFire = null; public static FlickeringLight fireLight = null; public static FireCollisionHandler fireHandler = null; public static List locations = new List(); public static List burningPlayers = new List(); public static int interactionsUntilDefuse = 6; public static bool bombDefused = false; public static bool sabotageEventActive = false; private static readonly float maxExplosionDistance = 7f; private static readonly float maxConcussionDistance = 12f; private static readonly float maxExplosionDmg = 500f; private static readonly float impactForce = 1450f; private static readonly float maxFireTickDamage = 8f; private static readonly float minFireTickDamage = 2f; private static readonly int fireTicks = 2; public static void PopulateBombLocations() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) Enumerator enumerator = Business.Businesses.GetEnumerator(); while (enumerator.MoveNext()) { Business current = enumerator.Current; if (((Property)current).PropertyName == "Laundromat") { locations.Add(new SabotageEventLocation(current, new Tuple(new Vector3(-27.75f, 0.59f, 22.8f), new Vector3(0f, 0f, 0f)), new Tuple(new Vector3(-26.9f, -0.4f, 25.09f), new Vector3(0f, 65f, 0f)), new List { new Vector3(-43.82f, 1.46f, 49.71f), new Vector3(-7.46f, 1.36f, 10.72f), new Vector3(-11.14f, 1.46f, 67.1f) })); } else if (((Property)current).PropertyName == "Post Office") { locations.Add(new SabotageEventLocation(current, new Tuple(new Vector3(47.94f, 0.15f, -0.45f), new Vector3(0f, 0f, 0f)), new Tuple(new Vector3(47.8f, 0f, -1.15f), new Vector3(0f, 90f, 0f)), new List { new Vector3(56.62f, 1.36f, -25.8f), new Vector3(7.77f, 1.36f, 19.38f), new Vector3(65.3f, 1.45f, 33.3f) })); } else if (((Property)current).PropertyName == "Taco Ticklers") { locations.Add(new SabotageEventLocation(current, new Tuple(new Vector3(-34f, 0.24f, 78.38f), new Vector3(90f, 270f, 0f)), new Tuple(new Vector3(-34f, -0.3f, 80f), new Vector3(0f, 15f, 0f)), new List { new Vector3(-30.13f, 1.45f, 97.5f), new Vector3(-43.82f, 1.46f, 49.71f), new Vector3(-11.14f, 1.46f, 67.1f) })); } } } public static void PrepareBombFXObjects() { //IL_007e: 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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) Transform obj = ((Component)Object.FindObjectOfType()).transform.Find("Destroyed RV/FX"); reactiveFire = Object.Instantiate((obj != null) ? ((Component)obj).gameObject : null); if (reactiveFire.gameObject.activeSelf) { reactiveFire.SetActive(false); } ((Object)reactiveFire).name = "CartelEnforcer_ReactiveFire"; fireLight = reactiveFire.GetComponentInChildren(); BoxCollider obj2 = reactiveFire.AddComponent(); obj2.size = new Vector3(2.7f, 3f, 8.3f); obj2.center = new Vector3(0.4f, 0f, 0f); ((Collider)obj2).isTrigger = true; reactiveFire.AddComponent().isKinematic = true; fireHandler = reactiveFire.AddComponent(); GameObject val = null; ItemInstance defaultInstance = new Func(Registry.GetItem)("bomb").GetDefaultInstance(1); StorableItemInstance val2 = null; val2 = ((Il2CppObjectBase)defaultInstance).TryCast(); if (val2 != null && (Object)(object)val2.StoredItem != (Object)null) { val = ((Component)val2.StoredItem).gameObject; } intBomb = Object.Instantiate(val); intBomb.SetActive(false); ((Object)intBomb).name = "CartelEnforcer_InteractableBomb"; ((Component)intBomb.transform.Find("Bomb/bomb")).gameObject.AddComponent(); bombInteractable = intBomb.AddComponent(); bombInteractable.message = "x 6 - Defuse bomb"; bombInteractable.onInteractStart.AddListener(UnityAction.op_Implicit((Action)OnBombInteract)); Transform transform = new GameObject("BombLight").transform; transform.parent = intBomb.transform; transform.localPosition = new Vector3(0f, 0.23f, 0f); bombLight = ((Component)transform).gameObject.AddComponent(); bombLight.color = Color.red; bombLight.intensity = 1.8f; bombLight.range = 0.4f; bombLight.type = (LightType)2; bombCubeMat = new Material(Shader.Find("Universal Render Pipeline/Lit")); bombCubeMat.color = Color.grey; GameObject obj3 = GameObject.CreatePrimitive((PrimitiveType)3); obj3.transform.parent = intBomb.transform; ((Renderer)obj3.GetComponent()).material = bombCubeMat; obj3.transform.localScale = new Vector3(0.023f, 0.01f, 0.01f); obj3.transform.position = new Vector3(0f, 0.052f, -0.016f); bombSound = intBomb.AddComponent(); bombSound.maxDistance = 7f; bombSound.minDistance = 1f; bombSound.pitch = 0.8f; bombSound.spatialize = true; bombSound.spatialBlend = 1f; bombSound.spread = 0.7f; bombSound.rolloffMode = (AudioRolloffMode)1; bombSound.velocityUpdateMode = (AudioVelocityUpdateMode)2; bombSound.volume = 0.12f; PoliceChatterVO val3 = Object.FindObjectOfType(true); if ((Object)(object)val3 == (Object)null) { return; } AudioSourceController startEndBeep = val3.StartEndBeep; if ((Object)(object)startEndBeep != (Object)null) { AudioSource audioSource = startEndBeep._audioSource; if ((Object)(object)audioSource != (Object)null && (Object)(object)audioSource.clip != (Object)null) { bombSound.clip = audioSource.clip; } } static void OnBombInteract() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) bombInteractable.message = $"x {interactionsUntilDefuse} - Defuse bomb"; if (interactionsUntilDefuse > 0) { interactionsUntilDefuse--; } else { bombLight.intensity = 1.8f; bombLight.color = Color.green; bombCubeMat.color = Color.green; bombDefused = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnBombSoon())); } } } public static IEnumerator EvaluateBombEvent() { float influenceRequirement = FrequencyOverrides.GetByID("Sabotage").InfluenceRequirement; float num = default(float); while (true) { yield return CartelEnforcer.Wait60; if (!CartelEnforcer.registered) { break; } if (!CartelEnforcer.currentConfig.businessSabotage) { continue; } if (!InstanceFinder.IsServer) { break; } if ((int)NetworkSingleton.Instance.Status != 2 || Singleton.Instance.IsSaving || CartelEnforcer.isSaving || sabotageEventActive || NetworkSingleton.Instance.GoonPool.UnspawnedGoonCount == 0) { continue; } SabotageEventLocation sabotageEventLocation = null; foreach (SabotageEventLocation location in locations) { if (location.hoursUntilEnabled != 0) { continue; } if (influenceRequirement >= 0f) { EMapRegion val = Singleton.Instance.GetRegionFromPosition(((Component)location.business).transform.position); if ((int)val == 0) { val = (EMapRegion)2; } if (NetworkSingleton.Instance.Influence.GetRegionData(val).Influence < influenceRequirement) { continue; } } if (location.business.LaunderingOperations.Count != 0 && location.business.currentLaunderTotal > location.business.appliedLaunderLimit * 0.5f) { sabotageEventLocation = location; break; } Player closestPlayer = PlayerManager.GetClosestPlayer(location.bombLocation.Item1, ref num, (List)null); if (num < 20f && (Object)(object)closestPlayer.CurrentBusiness != (Object)null && (Object)(object)closestPlayer.CurrentBusiness == (Object)(object)location.business && ((Property)location.business).IsOwned) { sabotageEventLocation = location; break; } } if (sabotageEventLocation == null) { continue; } int activityHours = FrequencyOverrides.GetActivityHours("Sabotage"); if (activityHours == 0) { float num2 = 0f; Enumerator enumerator2 = NetworkSingleton.Instance.Influence.regionInfluence.GetEnumerator(); while (enumerator2.MoveNext()) { RegionInfluenceData current2 = enumerator2.Current; num2 += current2.Influence; } float num3 = num2 / (float)NetworkSingleton.Instance.Influence.regionInfluence.Count; int num4 = Mathf.RoundToInt(Mathf.Lerp(16f, 37f, num3)); int num5 = Mathf.RoundToInt(Mathf.Lerp(38f, 64f, num3)); sabotageEventLocation.hoursUntilEnabled = Random.Range(num4, num5); } else { sabotageEventLocation.hoursUntilEnabled = activityHours; } sabotageEventActive = true; CartelEnforcer.coros.Add(MelonCoroutines.Start(GoonPlantBomb(sabotageEventLocation))); } } public static IEnumerator GoonPlantBomb(SabotageEventLocation location) { Vector3 val = location.sabotagerSpawns[Random.Range(0, location.sabotagerSpawns.Count)]; CartelGoon goon = (sabotager = NetworkSingleton.Instance.GoonPool.SpawnGoon(val)); ((NPC)goon).Movement.WarpToNavMesh(); ((Component)((NPC)goon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(false); ((NPC)goon).Behaviour.ScheduleManager.DisableSchedule(); ((NPC)goon).Movement.SetDestination(location.bombLocation.Item1); ((NPC)goon).Movement.MoveSpeedMultiplier = 1.3f; float num = 50f; int n = 0; while (num > 2f && n < 120) { n++; yield return CartelEnforcer.Wait025; if (!CartelEnforcer.registered) { yield break; } if (((NPC)goon).Health.IsDead || !((NPC)goon).IsConscious || ((NPC)goon).Health.IsKnockedOut) { EventEnded(location, CartelEnforcer.influenceConfig.sabotageGoonKilled); sabotageEventActive = false; CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnGoonSoon(goon))); yield break; } num = Vector3.Distance(((NPC)goon).CenterPoint, location.bombLocation.Item1); } if (n >= 120 && num > 2f) { sabotageEventActive = false; CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnGoonSoon(goon))); yield break; } ((NPC)goon).Movement.Stop(); ((NPC)goon).Movement.FacePoint(location.bombLocation.Item1, 0.4f); yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } if (((NPC)goon).Health.IsDead || !((NPC)goon).IsConscious || ((NPC)goon).Health.IsKnockedOut) { EventEnded(location, CartelEnforcer.influenceConfig.sabotageGoonKilled); sabotageEventActive = false; CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnGoonSoon(goon))); yield break; } ((NPC)goon).Avatar.Animation.SetCrouched(true); yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } if (((NPC)goon).Health.IsDead || !((NPC)goon).IsConscious || ((NPC)goon).Health.IsKnockedOut) { EventEnded(location, CartelEnforcer.influenceConfig.sabotageGoonKilled); sabotageEventActive = false; CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnGoonSoon(goon))); yield break; } ((NPC)goon).SetAnimationTrigger("GrabItem"); SpawnBomb(location); Singleton.Instance.SendNotification(((Property)location.business).PropertyName, "Sabotage alert!", NetworkSingleton.Instance.LaunderingNotificationIcon, 10f, true); yield return CartelEnforcer.Wait05; if (CartelEnforcer.registered) { ((NPC)goon).Avatar.Animation.SetCrouched(false); ((Component)((NPC)goon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); ((NPC)goon).Behaviour.ScheduleManager.EnableSchedule(); ((NPC)goon).Movement.MoveSpeedMultiplier = 1.6f; CartelEnforcer.coros.Add(MelonCoroutines.Start(DespawnGoonSoon(goon))); yield return null; } } public static void SpawnBomb(SabotageEventLocation location) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) bombDefused = false; interactionsUntilDefuse = Random.Range(26, 68); bombCubeMat.color = Color.grey; bombLight.intensity = 0f; intBomb.transform.SetPositionAndRotation(location.bombLocation.Item1, Quaternion.Euler(location.bombLocation.Item2)); intBomb.SetActive(true); bombInteractable.message = $"x {interactionsUntilDefuse} - Defuse bomb"; CartelEnforcer.coros.Add(MelonCoroutines.Start(BombActivated(location))); } public static IEnumerator DespawnBombSoon() { yield return CartelEnforcer.Wait10; intBomb.SetActive(false); bombCubeMat.color = Color.grey; bombLight.intensity = 0f; bombSound.volume = 0.1f; yield return null; } public static IEnumerator BombActivated(SabotageEventLocation location) { int maxWaitSecs = 120; int timeWaited = 0; float num = 50f; bool proximityInitiated = false; int ticksInProximity = 0; int maxTicksInProximity = 7; bool timeInitiated = false; while (!timeInitiated && !bombDefused) { PlayerManager.GetClosestPlayer(location.bombLocation.Item1, ref num, (List)null); if (!proximityInitiated) { proximityInitiated = num < 6f; timeInitiated = timeWaited >= maxWaitSecs; } if (proximityInitiated) { if (ticksInProximity % 2 == 0) { bombCubeMat.color = Color.grey; bombLight.intensity = 0f; } else { bombCubeMat.color = Color.red; bombLight.intensity = 1.8f; bombLight.color = Color.red; } bombSound.Play(); ticksInProximity++; if (ticksInProximity >= maxTicksInProximity) { break; } } yield return CartelEnforcer.Wait2; if (!CartelEnforcer.registered) { yield break; } timeWaited += 2; } yield return CartelEnforcer.Wait05; if (bombDefused) { EventEnded(location, CartelEnforcer.influenceConfig.sabotageBombDefused); sabotageEventActive = false; } else { CartelEnforcer.coros.Add(MelonCoroutines.Start(ExplosionEvent(location))); yield return null; } } public static IEnumerator ExplosionEvent(SabotageEventLocation location) { intBomb.SetActive(false); bombCubeMat.color = Color.grey; bombLight.intensity = 0f; bombSound.volume = 0.1f; reactiveFire.transform.SetPositionAndRotation(location.fireLocation.Item1, Quaternion.Euler(location.fireLocation.Item2)); reactiveFire.SetActive(true); bool playerConcussed = false; float num = default(float); Player player = PlayerManager.GetClosestPlayer(location.bombLocation.Item1, ref num, (List)null); IDamageable component = ((Component)player).GetComponent(); if (num <= maxExplosionDistance && component != null) { ProcessExplosionImpact(player.CenterPointTransform.position, component); } if (num <= maxConcussionDistance) { playerConcussed = true; player.Seizure = true; player.Disoriented = true; } List npcsFleeing = new List(); Enumerator enumerator = NPCManager.NPCRegistry.GetEnumerator(); while (enumerator.MoveNext()) { NPC current = enumerator.Current; if (!((NetworkBehaviour)current).IsSpawned || current.isInBuilding || current.IsInVehicle) { continue; } num = Vector3.Distance(intBomb.transform.position, current.CenterPoint); if (num <= maxExplosionDistance) { IDamageable component2 = ((Component)current).GetComponent(); if (component2 != null) { ProcessExplosionImpact(current.CenterPoint, component2); if (!current.Health.IsDead && !current.Health.IsKnockedOut) { current.Behaviour.FleeBehaviour.FleeMode = (EFleeMode)1; current.Behaviour.FleeBehaviour.SetPointToFlee(intBomb.transform.position); ((Behaviour)current.Behaviour.FleeBehaviour).Enable_Networked(); npcsFleeing.Add(current); } } } else if (num <= maxConcussionDistance) { current.SetPanicked_Server(); } } Enumerator enumerator2 = location.business.LaunderingOperations.GetEnumerator(); while (enumerator2.MoveNext()) { LaunderingOperation current2 = enumerator2.Current; current2.amount = 0f; current2.completionTime_Minutes = 1; } yield return CartelEnforcer.Wait5; if (!CartelEnforcer.registered) { yield break; } if (playerConcussed) { player.Seizure = false; player.Disoriented = false; } EventEnded(location, CartelEnforcer.influenceConfig.sabotageBombExploded); yield return CartelEnforcer.Wait10; if (!CartelEnforcer.registered) { yield break; } foreach (NPC item in npcsFleeing) { if (((Behaviour)item.Behaviour.FleeBehaviour).Active) { ((Behaviour)item.Behaviour.FleeBehaviour).Disable_Networked((NetworkConnection)null); } if (Random.Range(0f, 1f) > 0.33f) { item.SetPanicked_Server(); } } npcsFleeing.Clear(); yield return CartelEnforcer.Wait10; if (!CartelEnforcer.registered) { yield break; } float currentScale = 1f; float targetScale = 0.05f; float scaleDownStep = 0.025f; float maxIntensity = 14f; float minIntensity = 10f; while (currentScale >= targetScale) { yield return CartelEnforcer.Wait025; if (!CartelEnforcer.registered) { yield break; } currentScale -= scaleDownStep; reactiveFire.transform.localScale = new Vector3(currentScale, currentScale, currentScale); fireLight.maxIntensity = Mathf.Clamp(Mathf.SmoothStep(maxIntensity, -2f, 1f - currentScale), 0f, maxIntensity); fireLight.minIntensity = Mathf.Clamp(Mathf.SmoothStep(minIntensity, -2f, 1f - currentScale), 0f, minIntensity); } reactiveFire.SetActive(false); reactiveFire.transform.localScale = new Vector3(1f, 1f, 1f); fireLight.maxIntensity = 14f; fireLight.minIntensity = 10f; sabotageEventActive = false; bombDefused = false; yield return null; } public static void ProcessExplosionImpact(Vector3 receivePosition, IDamageable recipient) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_007f: Expected O, but got Unknown Vector3 val = intBomb.transform.position - receivePosition; float num = 1f / ((Vector3)(ref val)).sqrMagnitude; float num2 = Mathf.Clamp(impactForce * num, 0f, 350f); float num3 = Mathf.Clamp(maxExplosionDmg * num, 0f, 200f); val = receivePosition - intBomb.transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; Impact val2 = new Impact(receivePosition, normalized, num2, num3, (EImpactType)4, (NetworkObject)null); recipient.SendImpact(val2); } public static IEnumerator SetPlayerBurning(Player player, Collider coll) { if (burningPlayers.Contains(player)) { yield break; } burningPlayers.Add(player); int successiveBurns = 0; do { successiveBurns++; int currentTicks = fireTicks * successiveBurns; for (int i = 0; i < currentTicks; i++) { yield return CartelEnforcer.Wait05; if (!CartelEnforcer.registered) { yield break; } if (!player.Health.IsAlive) { break; } float num = Random.Range(minFireTickDamage, maxFireTickDamage); num *= (float)successiveBurns; player.Health.TakeDamage(num, true, true); } } while (fireHandler.inCollision.Contains(player)); if (burningPlayers.Contains(player)) { burningPlayers.Remove(player); } yield return null; } public static IEnumerator DespawnGoonSoon(CartelGoon goon) { yield return CartelEnforcer.Wait30; if (CartelEnforcer.registered) { ((Component)((NPC)goon).Behaviour.ScheduleManager.ActionList[0]).gameObject.SetActive(true); ((NPC)goon).Behaviour.ScheduleManager.EnableSchedule(); goon.Despawn(); ((NPC)goon).Movement.MoveSpeedMultiplier = 1f; sabotager = null; yield return null; } } public static void EventEnded(SabotageEventLocation location, float influenceChange) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) EMapRegion val = Singleton.Instance.GetRegionFromPosition(((Component)location.business).transform.position); if (InstanceFinder.IsServer) { if ((int)val == 0) { val = (EMapRegion)2; } NetworkSingleton.Instance.Influence.ChangeInfluence(val, influenceChange); } } public static void ReduceSabotageHours() { if (locations == null || locations.Count == 0 || Singleton.Instance.IsSaving || CartelEnforcer.isSaving || !CartelEnforcer.currentConfig.businessSabotage) { return; } foreach (SabotageEventLocation location in locations) { location.HourPass(); } } } [RegisterTypeInIl2Cpp] public class FireCollisionHandler : MonoBehaviour { public List inCollision = new List(); public FireCollisionHandler(IntPtr ptr) : base(ptr) { } public FireCollisionHandler() : base(ClassInjector.DerivedConstructorPointer()) { ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this); } private void OnTriggerEnter(Collider other) { if (((Component)other).gameObject.layer != 6) { return; } Player componentInParent = ((Component)other).gameObject.GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null)) { if (!inCollision.Contains(componentInParent)) { inCollision.Add(componentInParent); } CartelEnforcer.coros.Add(MelonCoroutines.Start(SabotageEvent.SetPlayerBurning(componentInParent, other))); } } private void OnTriggerExit(Collider other) { if (((Component)other).gameObject.layer == 6) { Player componentInParent = ((Component)other).gameObject.GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null) && inCollision.Contains(componentInParent)) { inCollision.Remove(componentInParent); } } } private void OnDisable() { inCollision.Clear(); } } }