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.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using Archipelago.MultiClient.Net; using Archipelago.MultiClient.Net.BounceFeatures.DeathLink; using Archipelago.MultiClient.Net.Enums; using Archipelago.MultiClient.Net.Exceptions; using Archipelago.MultiClient.Net.Helpers; using Archipelago.MultiClient.Net.MessageLog.Messages; using Archipelago.MultiClient.Net.Models; using BepInEx; using BepInEx.Logging; using HarmonyLib; using HarmonyLib.Tools; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("WKRando")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+2522077aa1a7568571b193ab8b0be4ef927e6f12")] [assembly: AssemblyProduct("My first plugin")] [assembly: AssemblyTitle("WKRando")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [CompilerGenerated] internal sealed class <>z__ReadOnlyArray : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => _items.Length; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Length; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return ((ICollection)_items).Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { ((ICollection)_items).CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return ((IList)_items).IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } 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 WKRando { public class APItems { public static int ProgressiveRegions; public static int ProgressivePerkUnlocks; public static int TargetAPDebuffCount = 10; public static int TrinketSlots = 3; public static int TotalRoachesReceived; public static int TotalCreditsReceived; public static Dictionary> FacilityDict = new Dictionary> { ["GLOBAL"] = new Dictionary { ["UPG_Global_Bazaar_I2"] = false, ["UPG_Global_PerkRefresh"] = false }, ["CAMPAIGN_INTERLUDE_01"] = new Dictionary { ["UPG_Recycler"] = false, ["UPG_ItemLocker_01"] = false, ["UPG_ItemLocker_02"] = false, ["UPG_SectorMaintenance"] = false, ["UPG_Ration_T1"] = false, ["UPG_Ration_T2"] = false, ["UPG_ATM"] = false, ["UPG_Vendor_T1_01"] = false, ["UPG_Vendor_T2_01"] = false }, ["CAMPAIGN_INTERLUDE_02"] = new Dictionary { ["UPG_Recycler"] = false, ["UPG_ItemLocker_01"] = false, ["UPG_ItemLocker_02"] = false, ["UPG_Ration_T1"] = false, ["UPG_Ration_T2"] = false, ["UPG_Vendor_T1_01"] = false, ["UPG_Vendor_T2_01"] = false }, ["CAMPAIGN_INTERLUDE_03"] = new Dictionary { ["UPG_Recycler"] = false, ["UPG_ItemLocker_01"] = false, ["UPG_ItemLocker_02"] = false, ["UPG_ATM"] = false, ["UPG_Vendor_T2_01"] = false, ["UPG_Rho_Altar_Repair"] = false }, ["CAMPAIGN_INTERLUDE_04"] = new Dictionary { ["UPG_Recycler"] = false, ["UPG_ItemLocker_01"] = false, ["UPG_ItemLocker_02"] = false, ["UPG_Ration_T1"] = false, ["UPG_Ration_T2"] = false, ["UPG_Wine_T1"] = false, ["UPG_ATM"] = false, ["UPG_Vendor_T2_01"] = false } }; public static List SentLocations = new List(); public static Dictionary APtoFullFacilityUpgrade = new Dictionary { [178323456L] = "GLOBAL UPG_Global_Bazaar_I2", [178323457L] = "GLOBAL UPG_Global_StartingRoaches_T1", [178323458L] = "GLOBAL UPG_Global_StartingRoaches_T2", [178323459L] = "GLOBAL UPG_Global_StartingRoaches_T3", [178323460L] = "GLOBAL UPG_Global_Buddy_T1", [178323461L] = "GLOBAL UPG_Global_Pouch_T1", [178323462L] = "GLOBAL UPG_Global_OrnamentalHammer", [178323463L] = "GLOBAL UPG_Global_Cosmetic_WorkGloves", [178323464L] = "GLOBAL UPG_Global_Cosmetic_SpecialtyGloves", [178323465L] = "GLOBAL UPG_Global_PerkRefresh", [178327552L] = "CAMPAIGN_INTERLUDE_01 UPG_Recycler", [178327553L] = "CAMPAIGN_INTERLUDE_01 UPG_SectorMaintenance", [178327554L] = "CAMPAIGN_INTERLUDE_01 UPG_ItemLocker_01", [178327555L] = "CAMPAIGN_INTERLUDE_01 UPG_ItemLocker_02", [178327556L] = "CAMPAIGN_INTERLUDE_01 UPG_Ration_T1", [178327557L] = "CAMPAIGN_INTERLUDE_01 UPG_Ration_T2", [178327558L] = "CAMPAIGN_INTERLUDE_01 UPG_ATM", [178327559L] = "CAMPAIGN_INTERLUDE_01 UPG_Vendor_T1_01", [178327560L] = "CAMPAIGN_INTERLUDE_01 UPG_Vendor_T2_02", [178331648L] = "CAMPAIGN_INTERLUDE_02 UPG_Recycler", [178331649L] = "CAMPAIGN_INTERLUDE_02 UPG_ItemLocker_01", [178331650L] = "CAMPAIGN_INTERLUDE_02 UPG_ItemLocker_02", [178331651L] = "CAMPAIGN_INTERLUDE_02 UPG_Ration_T1", [178331652L] = "CAMPAIGN_INTERLUDE_02 UPG_Ration_T2", [178331653L] = "CAMPAIGN_INTERLUDE_02 UPG_Vendor_T1_01", [178331654L] = "CAMPAIGN_INTERLUDE_02 UPG_Vendor_T2_01", [178335744L] = "CAMPAIGN_INTERLUDE_03 UPG_Recycler", [178335745L] = "CAMPAIGN_INTERLUDE_03 UPG_ItemLocker_01", [178335746L] = "CAMPAIGN_INTERLUDE_03 UPG_ItemLocker_02", [178335747L] = "CAMPAIGN_INTERLUDE_03 UPG_ATM", [178335748L] = "CAMPAIGN_INTERLUDE_03 UPG_Vendor_T2_01", [178335749L] = "CAMPAIGN_INTERLUDE_03 UPG_Rho_Altar_Repair", [178339840L] = "CAMPAIGN_INTERLUDE_04 UPG_Recycler", [178339841L] = "CAMPAIGN_INTERLUDE_04 UPG_ItemLocker_01", [178339842L] = "CAMPAIGN_INTERLUDE_04 UPG_ItemLocker_02", [178339843L] = "CAMPAIGN_INTERLUDE_04 UPG_Ration_T1", [178339844L] = "CAMPAIGN_INTERLUDE_04 UPG_Ration_T2", [178339845L] = "CAMPAIGN_INTERLUDE_04 UPG_Wine_T1", [178339846L] = "CAMPAIGN_INTERLUDE_04 UPG_ATM", [178339847L] = "CAMPAIGN_INTERLUDE_04 UPG_Vendor_T2_01" }; public static Dictionary FullFacilityUpgradetoAP = new Dictionary { ["GLOBAL UPG_Global_Bazaar_I2"] = 178323456L, ["GLOBAL UPG_Global_StartingRoaches_T1"] = 178323457L, ["GLOBAL UPG_Global_StartingRoaches_T2"] = 178323458L, ["GLOBAL UPG_Global_StartingRoaches_T3"] = 178323459L, ["GLOBAL UPG_Global_Buddy_T1"] = 178323460L, ["GLOBAL UPG_Global_Pouch_T1"] = 178323461L, ["GLOBAL UPG_Global_OrnamentalHammer"] = 178323462L, ["GLOBAL UPG_Global_Cosmetic_WorkGloves"] = 178323463L, ["GLOBAL UPG_Global_Cosmetic_SpecialtyGloves"] = 178323464L, ["GLOBAL UPG_Global_PerkRefresh"] = 178323465L, ["CAMPAIGN_INTERLUDE_01 UPG_Recycler"] = 178327552L, ["CAMPAIGN_INTERLUDE_01 UPG_SectorMaintenance"] = 178327553L, ["CAMPAIGN_INTERLUDE_01 UPG_ItemLocker_01"] = 178327554L, ["CAMPAIGN_INTERLUDE_01 UPG_ItemLocker_02"] = 178327555L, ["CAMPAIGN_INTERLUDE_01 UPG_Ration_T1"] = 178327556L, ["CAMPAIGN_INTERLUDE_01 UPG_Ration_T2"] = 178327557L, ["CAMPAIGN_INTERLUDE_01 UPG_ATM"] = 178327558L, ["CAMPAIGN_INTERLUDE_01 UPG_Vendor_T1_01"] = 178327559L, ["CAMPAIGN_INTERLUDE_01 UPG_Vendor_T2_01"] = 178327560L, ["CAMPAIGN_INTERLUDE_02 UPG_Recycler"] = 178331648L, ["CAMPAIGN_INTERLUDE_02 UPG_ItemLocker_01"] = 178331649L, ["CAMPAIGN_INTERLUDE_02 UPG_ItemLocker_02"] = 178331650L, ["CAMPAIGN_INTERLUDE_02 UPG_Ration_T1"] = 178331651L, ["CAMPAIGN_INTERLUDE_02 UPG_Ration_T2"] = 178331652L, ["CAMPAIGN_INTERLUDE_02 UPG_Vendor_T1_01"] = 178331653L, ["CAMPAIGN_INTERLUDE_02 UPG_Vendor_T2_01"] = 178331654L, ["CAMPAIGN_INTERLUDE_03 UPG_Recycler"] = 178335744L, ["CAMPAIGN_INTERLUDE_03 UPG_ItemLocker_01"] = 178335745L, ["CAMPAIGN_INTERLUDE_03 UPG_ItemLocker_02"] = 178335746L, ["CAMPAIGN_INTERLUDE_03 UPG_ATM"] = 178335747L, ["CAMPAIGN_INTERLUDE_03 UPG_Vendor_T2_01"] = 178335748L, ["CAMPAIGN_INTERLUDE_03 UPG_Rho_Altar_Repair"] = 178335749L, ["CAMPAIGN_INTERLUDE_04 UPG_Recycler"] = 178339840L, ["CAMPAIGN_INTERLUDE_04 UPG_ItemLocker_01"] = 178339841L, ["CAMPAIGN_INTERLUDE_04 UPG_ItemLocker_02"] = 178339842L, ["CAMPAIGN_INTERLUDE_04 UPG_Ration_T1"] = 178339843L, ["CAMPAIGN_INTERLUDE_04 UPG_Ration_T2"] = 178339844L, ["CAMPAIGN_INTERLUDE_04 UPG_Wine_T1"] = 178339845L, ["CAMPAIGN_INTERLUDE_04 UPG_ATM"] = 178339846L, ["CAMPAIGN_INTERLUDE_04 UPG_Vendor_T2_01"] = 178339847L }; public static Dictionary RoomNameToAP = new Dictionary { ["M1_Silos_Storage_01"] = 179372032L, ["M1_Silos_Storage_03"] = 179372033L, ["M1_Silos_Storage_06"] = 179372034L, ["M1_Silos_Storage_09"] = 179372035L, ["M1_Silos_Storage_10"] = 179372036L, ["M1_Silos_Storage_15"] = 179372037L, ["M1_Silos_Air_02"] = 179372038L, ["M1_Silos_Air_03"] = 179372039L, ["M1_Silos_Air_04"] = 179372040L, ["M1_Silos_Air_08"] = 179372041L, ["M1_Silos_Broken_01"] = 179372042L, ["M1_Silos_Broken_04"] = 179372043L, ["M1_Silos_Broken_08"] = 179372044L, ["M1_Silos_Broken_09"] = 179372045L, ["M1_Silos_Broken_10"] = 179372046L, ["M1_Silos_Storage_04"] = 179372288L, ["M1_Silos_Storage_11"] = 179372289L, ["M1_Silos_Storage_12"] = 179372290L, ["M1_Silos_Storage_02"] = 179372544L, ["M1_Silos_Storage_08"] = 179372545L, ["M1_Silos_Storage_16"] = 179372546L, ["M1_Silos_Air_05"] = 179372547L, ["M1_Silos_Air_06"] = 179372548L, ["M1_Silos_Broken_03"] = 179372549L, ["M1_Silos_Broken_05"] = 179372550L, ["M1_Silos_Storage_05"] = 179372800L, ["M1_Silos_Storage_07"] = 179372801L, ["M1_Silos_Air_01"] = 179372802L, ["M1_Silos_Air_09"] = 179372803L, ["M1_Silos_Broken_02"] = 179372804L, ["M1_Silos_Broken_06"] = 179372805L, ["M1_Silos_Storage_13"] = 179373056L, ["M1_Silos_Storage_14"] = 179373057L, ["M1_Silos_Air_07"] = 179373058L, ["M1_Silos_Air_10"] = 179373059L, ["M1_Silos_Broken_07"] = 179373060L, ["M1_Silos_Storage_17"] = 179373312L, ["M1_Silos_Air_11"] = 179373313L, ["M1_Silos_Broken_11"] = 179373314L, ["M2_Pipeworks_Drainage_01"] = 179437568L, ["M2_Pipeworks_Drainage_02"] = 179437569L, ["M2_Pipeworks_Drainage_05"] = 179437570L, ["M2_Pipeworks_Drainage_07"] = 179437571L, ["M2_Pipeworks_Drainage_08"] = 179437572L, ["M2_Pipeworks_Drainage_09"] = 179437573L, ["M2_Pipeworks_Drainage_10"] = 179437574L, ["M2_Pipeworks_Waste_02"] = 179437824L, ["M2_Pipeworks_Waste_04"] = 179437825L, ["M2_Pipeworks_Waste_05"] = 179437826L, ["M2_Pipeworks_Organ_02"] = 179438080L, ["M2_Pipeworks_Organ_05"] = 179438081L, ["M2_Pipeworks_Organ_06"] = 179438082L, ["M2_Pipeworks_Organ_07"] = 179438083L, ["M2_Pipeworks_Drainage_03"] = 179441664L, ["M2_Pipeworks_Drainage_04"] = 179441665L, ["M2_Pipeworks_Waste_01"] = 179441920L, ["M2_Pipeworks_Organ_01"] = 179442176L, ["M2_Pipeworks_Organ_03"] = 179442177L, ["M2_Pipeworks_Drainage_06"] = 179445760L, ["M2_Pipeworks_Waste_03"] = 179446016L, ["M2_Pipeworks_Organ_04"] = 179446272L, ["M2_Pipeworks_Organ_08"] = 179446273L, ["M2_Pipeworks_Organ_09"] = 179450368L, ["M3_Habitation_Shaft_01"] = 179503104L, ["M3_Habitation_Shaft_02"] = 179503105L, ["M3_Habitation_Shaft_03"] = 179503106L, ["M3_Habitation_Shaft_04"] = 179503107L, ["M3_Habitation_Shaft_05"] = 179503108L, ["M3_Habitation_Shaft_06"] = 179503109L, ["M3_Habitation_Shaft_To_Pier"] = 179503110L, ["M3_Habitation_Pier_01"] = 179503360L, ["M3_Habitation_Pier_02"] = 179503361L, ["M3_Habitation_Lab_Lobby"] = 179503616L, ["M3_Habitation_Lab_01"] = 179503617L, ["M3_Habitation_Lab_02"] = 179503618L, ["M3_Habitation_Lab_03"] = 179503619L, ["M3_Habitation_Lab_04"] = 179503620L, ["M3_Habitation_Lab_Ending"] = 179503621L, ["M3_Habitation_Shaft_07"] = 179507200L, ["M3_Habitation_Pier_03"] = 179507456L, ["M3_Habitation_Pier_04"] = 179507457L, ["M3_Habitation_Lab_05"] = 179507712L, ["M3_Habitation_Lab_06"] = 179507713L, ["M3_Habitation_Lab_07"] = 179507714L, ["M3_Habitation_Lab_08"] = 179507715L, ["M4_Abyss_Intro_01"] = 179568640L, ["M4_Abyss_Outro_01"] = 179568641L, ["M4_Abyss_Transit_01"] = 179568897L, ["M4_Abyss_Transit_02"] = 179568898L, ["M4_Abyss_Transit_03"] = 179568899L, ["M4_Abyss_Transit_04"] = 179568900L, ["M4_Abyss_Transit_05"] = 179568901L, ["M4_Abyss_Transit_06"] = 179568902L, ["M4_Abyss_Handle_01"] = 179569152L, ["M4_Abyss_Garden_01"] = 179569408L, ["M4_Abyss_Garden_02"] = 179569409L, ["M4_Abyss_Garden_03"] = 179569410L, ["M4_Abyss_Garden_04"] = 179569411L, ["M4_Abyss_Handle_02"] = 179569664L, ["M5_Nest_Infested_01"] = 179634176L, ["M5_Nest_Infested_02"] = 179634177L, ["M5_Nest_Infested_03"] = 179634178L, ["M5_Nest_Infested_04"] = 179634179L, ["M5_Nest_Infested_05"] = 179634180L, ["M5_Nest_Infested_HunterIntro_01"] = 179634181L, ["M5_Nest_Infested_Chase_01"] = 179634182L, ["M5_Nest_Infested_Chase_02"] = 179634183L, ["M5_Nest_Trough_01"] = 179634432L, ["M5_Nest_Trough_02"] = 179634433L, ["M5_Nest_Trough_03"] = 179634434L, ["M5_Nest_Trough_04"] = 179634435L, ["M5_Nest_Trough_05"] = 179634436L, ["M5_Nest_Trough_06"] = 179634437L, ["M5_Nest_Trough_07"] = 179634438L, ["M5_Nest_Trough_08"] = 179634439L, ["M5_Nest_Trough_Ending_01"] = 179634440L, ["M5_Nest_HotZone_Intro_01"] = 179634688L, ["M5_Nest_HotZone_Outro_01"] = 179634689L, ["M5_Nest_HotZone_01"] = 179634690L, ["M5_Nest_HotZone_02"] = 179634691L, ["M5_Nest_HotZone_03"] = 179634692L, ["M5_Nest_HotZone_04"] = 179634693L, ["S1_TangledSink_Intro_01"] = 179699712L, ["S1_TangledSink_01"] = 179699713L, ["S1_TangledSink_02"] = 179699714L, ["S1_TangledSink_03"] = 179699715L, ["S1_TangledSink_04"] = 179699716L, ["S1_GarbageChute_Start_01"] = 179765248L, ["S1_GarbageChute_01"] = 179765249L, ["S1_GarbageChute_02"] = 179765250L, ["S1_GarbageChute_03"] = 179765251L, ["S1_GarbageChute_04"] = 179765252L, ["S1_GarbageChute_05"] = 179765253L, ["S1_GarbageChute_06"] = 179765254L, ["S1_GarbageChute_End_01"] = 179765255L, ["T1_Foundations_Items_01"] = 179830784L, ["T1_Foundations_Items_02"] = 179830785L, ["T1_Foundations_Items_03"] = 179830786L, ["T1_Foundations_Items_04"] = 179830787L, ["T1_Foundations_Items_05"] = 179830788L, ["T1_Foundations_Low_01"] = 179830789L, ["T1_Foundations_Low_02"] = 179830790L, ["T1_Foundations_Low_03"] = 179830791L, ["T1_Foundations_Low_04"] = 179830792L, ["T1_Foundations_Low_05"] = 179830793L, ["T1_Foundations_Low_06"] = 179830794L, ["T1_Foundations_Mastery_01"] = 179830795L, ["T1_Foundations_Mastery_02"] = 179830796L }; public static Dictionary ProgressionUnlocks = new Dictionary { ["binding_abyss"] = false, ["binding_core"] = false, ["binding_habitation"] = false, ["binding_nest"] = false, ["binding_roach"] = false, ["challenge_advancedcourse"] = false, ["challenge_boostcourse"] = false, ["challenge_commsarray"] = false, ["challenge_fracturedterritory"] = false, ["challenge_roachrun"] = false, ["challenge_shutteredrift"] = false, ["cosmetic_bloodied"] = false, ["cosmetic_crowbar"] = false, ["cosmetic_denizen"] = false, ["cosmetic_experienced"] = false, ["cosmetic_glove_leather"] = false, ["cosmetic_glove_winter"] = false, ["cosmetic_glove_wraps"] = false, ["cosmetic_hammer_alternate"] = false, ["cosmetic_hammer_mallet"] = false, ["cosmetic_hammer_mallet_christmas"] = false, ["cosmetic_hammer_pipe"] = false, ["cosmetic_hammer_wrench"] = false, ["cosmetic_hand_celestial"] = false, ["cosmetic_hand_stone"] = false, ["cosmetic_hand_sunspot"] = false, ["cosmetic_infested"] = false, ["cosmetic_inverted"] = false, ["cosmetic_maintenanceglove_new"] = false, ["cosmetic_maintenanceglove_worn"] = false, ["cosmetic_marionette"] = false, ["cosmetic_hammer_ornamental"] = false, ["cosmetic_outline"] = false, ["cosmetic_roach"] = false, ["cosmetic_scribble"] = false, ["cosmetic_skeletontattoo"] = false, ["cosmetic_streaked"] = false, ["cosmetic_xray"] = false, ["r_hardmode"] = false, ["r_10kendless"] = false, ["r_competitive"] = false, ["perk_mother"] = false, ["perk_t1"] = false, ["perk_t2"] = false, ["perk_t3"] = false, ["perk_t4"] = false, ["perk_t5"] = false, ["perk_u_adoption"] = false, ["perk_u_delta"] = false, ["perk_u_t1"] = false, ["perk_u_t2"] = false, ["perk_u_t3"] = false, ["r_abyss_t1"] = false, ["r_deepstorage_t1"] = false, ["r_habitation_t1"] = false, ["r_pipeworks_t1"] = false, ["r_pipeworks_t2"] = false, ["r_pipeworks_t3"] = false, ["r_shortcut_expulsionchute"] = false, ["r_shortcut_tangledsink"] = false, ["r_silos_t1"] = false, ["r_silos_t2"] = false, ["r_silos_t3"] = false, ["r_silos_t4"] = false, ["trinket_calmingbuddy"] = false, ["trinket_deltalabs"] = false, ["trinket_helmet"] = false, ["trinket_interlude01"] = false, ["trinket_interlude02"] = false, ["trinket_interlude03"] = false, ["trinket_interlude04"] = false, ["trinket_pouch"] = false, ["trinket_recycler"] = false, ["trinket_deepstorage"] = false, ["vendor_item_autopiton"] = false, ["vendor_item_blinkeye"] = false, ["vendor_item_explosiverebar"] = false, ["vendor_item_flaregun"] = false, ["vendor_item_flares"] = false, ["vendor_item_foodbar"] = false, ["vendor_item_10mm_ammo"] = false, ["vendor_item_injector"] = false, ["vendor_item_pills"] = false, ["vendor_item_grub"] = false }; public static Dictionary ProgressionUnlocksToAPID = new Dictionary { ["challenge_advancedcourse"] = 180355072L, ["challenge_boostcourse"] = 180355073L, ["challenge_commsarray"] = 180355074L, ["challenge_fracturedterritory"] = 180355075L, ["challenge_roachrun"] = 180355076L, ["challenge_shutteredrift"] = 180355077L, ["perk_mother"] = 180355328L, ["perk_t1"] = 180355329L, ["perk_t2"] = 180355330L, ["perk_t3"] = 180355331L, ["perk_t4"] = 180355332L, ["perk_t5"] = 180355333L, ["perk_u_adoption"] = 180355334L, ["perk_u_delta"] = 180355335L, ["perk_u_t1"] = 180355336L, ["perk_u_t2"] = 180355337L, ["perk_u_t3"] = 180355338L, ["r_abyss_t1"] = 180355584L, ["r_habitation_t1"] = 180355585L, ["r_pipeworks_t1"] = 180355586L, ["r_pipeworks_t2"] = 180355587L, ["r_pipeworks_t3"] = 180355588L, ["r_shortcut_expulsionchute"] = 180355589L, ["r_shortcut_tangledsink"] = 180355590L, ["r_silos_t1"] = 180355591L, ["r_silos_t2"] = 180355592L, ["r_silos_t3"] = 180355593L, ["r_silos_t4"] = 180355594L, ["r_deepstorage_t1"] = 180355595L, ["trinket_deltalabs"] = 180355840L, ["trinket_helmet"] = 180355841L, ["trinket_interlude02"] = 180355842L, ["trinket_interlude03"] = 180355843L, ["trinket_interlude04"] = 180355844L, ["trinket_recycler"] = 180355845L, ["vendor_item_autopiton"] = 180356096L, ["vendor_item_blinkeye"] = 180356097L, ["vendor_item_explosiverebar"] = 180356098L, ["vendor_item_flaregun"] = 180356099L, ["vendor_item_flares"] = 180356100L, ["vendor_item_foodbar"] = 180356101L, ["vendor_item_10mm_ammo"] = 180356102L, ["vendor_item_injector"] = 180356103L, ["vendor_item_pills"] = 180356104L, ["vendor_item_grubs"] = 180356105L }; public static Dictionary APIDtoProgressionUnlock = new Dictionary { [180355328L] = "perk_mother", [180355329L] = "perk_t1", [180355330L] = "perk_t2", [180355331L] = "perk_t3", [180355332L] = "perk_t4", [180355333L] = "perk_t5", [180355334L] = "perk_u_adoption", [180355335L] = "perk_u_delta", [180355336L] = "perk_u_t1", [180355337L] = "perk_u_t2", [180355338L] = "perk_u_t3", [180355584L] = "r_abyss_t1", [180355585L] = "r_habitation_t1", [180355586L] = "r_pipeworks_t1", [180355587L] = "r_pipeworks_t2", [180355588L] = "r_pipeworks_t3", [180355589L] = "r_shortcut_expulsionchute", [180355590L] = "r_shortcut_tangledsink", [180355591L] = "r_silos_t1", [180355592L] = "r_silos_t2", [180355593L] = "r_silos_t3", [180355594L] = "r_silos_t4", [180355595L] = "r_deepstorage_t1" }; public static Dictionary ModeUnlocks = new Dictionary { ["Mode Selection Button - Campaign Variant"] = true, ["Mode Selection Button - Tutorial"] = true, ["Mode Selection Button - Training Sector"] = false, ["Mode Selection Button - Endless"] = false, ["Mode Selection Button - Endless Underworks"] = false, ["Mode Selection Button - Endless Superstructure"] = false, ["Mode Selection Button - Silos"] = false, ["Mode Selection Button - Pipeworks"] = false, ["Mode Selection Button - Habitation"] = false, ["Mode Selection Button - Abyss"] = false, ["Mode Selection Button - Nest"] = false, ["Mode Selection Button - Challenge 01 - Advanced Course"] = true, ["Mode Selection Button - Challenge 02 - Shattered"] = true, ["Mode Selection Button - Challenge 03 - Roach Run"] = true, ["Mode Selection Button - Challenge 04 - Comms"] = false, ["Mode Selection Button - Challenge 05 - Shutter"] = false, ["Mode Selection Button - Challenge 06 - Boost"] = false, ["Mode Selection Button - Chimney"] = false, ["Mode Selection Button - Parasite.01"] = false }; public static Dictionary TrinketUnlocks = new Dictionary { ["Trinket_Beta"] = false, ["Trinket_Carabiner"] = false, ["Trinket_Chalk"] = false, ["Trinket_EmployeeID"] = false, ["Trinket_GoldNugget"] = false, ["Trinket_MassDamper"] = false, ["Trinket_MoonRock"] = false, ["Trinket_PhotoOfHome"] = false, ["Trinket_Pouch"] = false, ["Trinket_BagExpander"] = false, ["Trinket_Headlamp"] = false, ["Trinket_ClimbingShoes"] = false, ["Trinket_Helmet"] = false, ["Trinket_CalmingBuddy"] = false }; public static readonly Dictionary APIDtoTrinketUnlock = new Dictionary { [181403648L] = "Trinket_Beta", [181403649L] = "Trinket_Carabiner", [181403650L] = "Trinket_Chalk", [181403651L] = "Trinket_EmployeeID", [181403652L] = "Trinket_GoldNugget", [181403653L] = "Trinket_MassDamper", [181403654L] = "Trinket_MoonRock", [181403655L] = "Trinket_PhotoOfHome", [181403656L] = "Trinket_Pouch", [181403657L] = "Trinket_BagExpander", [181403658L] = "Trinket_Headlamp", [181403659L] = "Trinket_ClimbingShoes", [181403660L] = "Trinket_Helmet", [181403661L] = "Trinket_CalmingBuddy" }; public static readonly Dictionary APIDtoModeUnlock = new Dictionary { [182452224L] = "Mode Selection Button - Campaign Variant", [182452225L] = "Mode Selection Button - Training Sector", [182452226L] = "Mode Selection Button - Endless", [182452227L] = "Mode Selection Button - Endless Underworks", [182452228L] = "Mode Selection Button - Endless Superstructure", [182452229L] = "Mode Selection Button - Silos", [182452230L] = "Mode Selection Button - Pipeworks", [182452231L] = "Mode Selection Button - Habitation", [182452232L] = "Mode Selection Button - Abyss", [182452233L] = "Mode Selection Button - Nest", [182452234L] = "Mode Selection Button - Challenge 01 - Advanced Course", [182452235L] = "Mode Selection Button - Challenge 02 - Shattered", [182452236L] = "Mode Selection Button - Challenge 03 - Roach Run", [182452238L] = "Mode Selection Button - Challenge 04 - Comms", [182452239L] = "Mode Selection Button - Challenge 05 - Shutter", [182452240L] = "Mode Selection Button - Challenge 06 - Boost", [182452241L] = "Mode Selection Button - Chimney", [182452242L] = "Mode Selection Button - Parasite.01" }; public static Dictionary ChallengeMedaltoAPID = new Dictionary { ["Advanced Course 1"] = 183500800L, ["Advanced Course 2"] = 183500801L, ["Advanced Course 3"] = 183500802L, ["Advanced Course 4"] = 183500803L, ["Fractured Territory 1"] = 183500816L, ["Fractured Territory 2"] = 183500817L, ["Fractured Territory 3"] = 183500818L, ["Fractured Territory 4"] = 183500819L, ["Roach Run 1"] = 183500832L, ["Roach Run 2"] = 183500833L, ["Roach Run 3"] = 183500834L, ["Roach Run 4"] = 183500835L, ["Comms Array 1"] = 183500848L, ["Comms Array 2"] = 183500849L, ["Comms Array 3"] = 183500850L, ["Comms Array 4"] = 183500851L, ["Shuttered Rift 1"] = 183500864L, ["Shuttered Rift 2"] = 183500865L, ["Shuttered Rift 3"] = 183500866L, ["Shuttered Rift 4"] = 183500867L, ["Boost Course 1"] = 183500880L, ["Boost Course 2"] = 183500881L, ["Boost Course 3"] = 183500882L, ["Boost Course 4"] = 183500883L }; public static void ClearCampaignFacilities() { foreach (string item in FacilityDict.Keys.ToList()) { foreach (string item2 in FacilityDict[item].Keys.ToList()) { FacilityDict[item][item2] = false; } } } public static void ClearAllFlags() { ClearCampaignFacilities(); foreach (string item in ProgressionUnlocks.Keys.ToList()) { ProgressionUnlocks[item] = false; } foreach (string item2 in ModeUnlocks.Keys.ToList()) { if (item2 != "Mode Selection Button - Campaign Variant" && item2 != "Mode Selection Button - Tutorial") { ModeUnlocks[item2] = false; } } foreach (string item3 in TrinketUnlocks.Keys.ToList()) { TrinketUnlocks[item3] = false; } } public static void UpdateFromItem(ItemInfo item) { //IL_031e: 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) Sprite val = SpriteFromPath("WKRando/Assets/Archipelago_Icon.png"); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.3f, 0.3f, 0f); long itemId = item.ItemId; Plugin.Logger.LogInfo((object)("Attempting to update from AP Item: " + item.ItemDisplayName)); if (!SentLocations.Contains(itemId)) { SentLocations.Add(itemId); } if ((179306495 >= itemId && itemId >= 178327552) || itemId == 178323456 || itemId == 178323465) { string[] array = APtoFullFacilityUpgrade[itemId].Split(" "); FacilityDict[array[0]][array[1]] = true; Facility.onPurchaseUpgrade(); } else if (181403647 >= itemId && itemId >= 180355072) { ProgressionUnlocks[APIDtoProgressionUnlock[itemId]] = true; } else if (182452223 >= itemId && itemId >= 181403648) { TrinketUnlocks[APIDtoTrinketUnlock[itemId]] = true; } else if (183500799 >= itemId && itemId >= 182452224) { ModeUnlocks[APIDtoModeUnlock[itemId]] = true; } switch (itemId) { case 177209345L: Plugin.LoanAmount++; CL_GameManager.runRoaches++; TotalRoachesReceived++; break; case 177209346L: CL_GameManager.globalRoaches += 10; TotalCreditsReceived += 10; break; case 177209360L: ProgressiveRegions++; break; case 177209376L: TargetAPDebuffCount--; break; case 177209392L: ProgressivePerkUnlocks++; val2.g = 0.5f; break; case 177209408L: TrinketSlots++; break; } if (!ArchipelagoClient.Connecting) { if (item.Player.Slot != ArchipelagoClient.Slot) { CL_ProgressionManager.ShowUnlockPopup(val, "Received Item:", $"{item.ItemDisplayName} from game {item.LocationGame} at {item.LocationDisplayName}", val2, (AudioClip)null, true); } else { CL_ProgressionManager.ShowUnlockPopup(val, "Found your item!", item.ItemDisplayName + " from location " + item.LocationDisplayName, val2, (AudioClip)null, true); } } } public static List CheckFacilities() { return (from facility in StatManager.saveData.facilities from upgrade in facility.upgrades select FullFacilityUpgradetoAP[$"{facility} {upgrade}"] into id where !SentLocations.Contains(id) select id).ToList(); } public static Sprite SpriteFromPath(string localPath) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(256, 256); ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Path.Combine(Paths.PluginPath, "ConcreteConsumer-WhiteKnuckleArchipelago"), localPath))); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 10f); } } public class ArchipelagoClient { [CompilerGenerated] private static class <>O { public static ItemReceivedHandler <0>__OnItemReceive; public static MessageReceivedHandler <1>__OnMessageReceive; public static ErrorReceivedHandler <2>__OnError; public static SocketClosedHandler <3>__OnSocketClosed; public static CheckedLocationsUpdatedHandler <4>__OnLocationReceive; public static DeathLinkReceivedHandler <5>__ProcDeathlink; } private static ArchipelagoSession _session = ArchipelagoSessionFactory.CreateSession("localhost", 38281); public static string Servername = "localhost:38281"; public static string Username = string.Empty; public static string Password = string.Empty; public static string DeathMessage = "Died to Archipelago Player"; public static DeathLinkService Deathlinkservice; private static string Seed; private static bool _connectedBefore; public static bool Connecting; public static bool Connected; private static int _reconnectAttempts = 0; public static int Slot = -1; private static bool _goaled; private static Dictionary _slotData; private static Queue _items = new Queue(); private static List _locationsToSend = new List(); public event DeathLinkReceivedHandler OnDeathLinkReceived { add { } remove { } } private static void NewSession(string server) { _session = ArchipelagoSessionFactory.CreateSession(server, 38281); Plugin.ClientOptions.Server = server; } public static async Task Connect(string server = null, string user = null, string pass = null) { if (Connected) { CommandConsole.Log("Already connected to server " + Plugin.ClientOptions.Server + " as " + Plugin.ClientOptions.User); return null; } Plugin.Logger.LogInfo((object)("Connecting to " + server)); if (server != null && server != Plugin.ClientOptions.Server) { Plugin.ClientOptions.Server = server; } if (user != null && user != Plugin.ClientOptions.User) { Plugin.ClientOptions.User = user; } if (pass != null && pass != Plugin.ClientOptions.Password) { Plugin.ClientOptions.Password = pass; } NewSession(Plugin.ClientOptions.Server); IReceivedItemsHelper items = _session.Items; object obj = <>O.<0>__OnItemReceive; if (obj == null) { ItemReceivedHandler val = OnItemReceive; <>O.<0>__OnItemReceive = val; obj = (object)val; } items.ItemReceived += (ItemReceivedHandler)obj; IMessageLogHelper messageLog = _session.MessageLog; object obj2 = <>O.<1>__OnMessageReceive; if (obj2 == null) { MessageReceivedHandler val2 = OnMessageReceive; <>O.<1>__OnMessageReceive = val2; obj2 = (object)val2; } messageLog.OnMessageReceived += (MessageReceivedHandler)obj2; IArchipelagoSocketHelper socket = _session.Socket; object obj3 = <>O.<2>__OnError; if (obj3 == null) { ErrorReceivedHandler val3 = OnError; <>O.<2>__OnError = val3; obj3 = (object)val3; } socket.ErrorReceived += (ErrorReceivedHandler)obj3; IArchipelagoSocketHelper socket2 = _session.Socket; object obj4 = <>O.<3>__OnSocketClosed; if (obj4 == null) { SocketClosedHandler val4 = OnSocketClosed; <>O.<3>__OnSocketClosed = val4; obj4 = (object)val4; } socket2.SocketClosed += (SocketClosedHandler)obj4; ILocationCheckHelper locations = _session.Locations; object obj5 = <>O.<4>__OnLocationReceive; if (obj5 == null) { CheckedLocationsUpdatedHandler val5 = OnLocationReceive; <>O.<4>__OnLocationReceive = val5; obj5 = (object)val5; } locations.CheckedLocationsUpdated += (CheckedLocationsUpdatedHandler)obj5; APItems.TargetAPDebuffCount = 10; APItems.ClearAllFlags(); APItems.SentLocations.Clear(); LoginResult result; try { result = _session.TryConnectAndLogin("White Knuckle", Plugin.ClientOptions.User, (ItemsHandlingFlags)7, (Version)null, (string[])null, (string)null, (string)null, true); } catch (Exception ex) { result = (LoginResult)new LoginFailure(ex.GetBaseException().Message); } if (!result.Successful) { LoginFailure failure = (LoginFailure)result; CommandConsole.Log($"Failed to Connect to {Plugin.ClientOptions.Server} as {Plugin.ClientOptions.User}:"); string[] errors = failure.Errors; foreach (string error in errors) { CommandConsole.Log(" " + error); } ConnectionRefusedError[] errorCodes = failure.ErrorCodes; foreach (ConnectionRefusedError error2 in errorCodes) { CommandConsole.Log($" {error2}"); } await Disconnect(tryReconnect: true); return null; } Connecting = true; Connected = true; LoginSuccessful loginSuccess = (LoginSuccessful)result; Slot = loginSuccess.Slot; Seed = _session.RoomState.Seed; if (!File.Exists(Path.Combine(Application.persistentDataPath, Seed + "_save.json"))) { File.Create(Path.Combine(Application.persistentDataPath, Seed + "_save.json")); Plugin.AlterStats.UpdateSaveLocationNames(Seed); CommandConsole.hasCheated = true; CL_GameManager.runRoaches = 0; CL_GameManager.globalRoaches = 0; CL_GameManager.gMan.Restart(Array.Empty()); } else { Plugin.AlterStats.UpdateSaveLocationNames(Seed); } APItems.SentLocations.AddRange(_session.Locations.AllLocationsChecked); FixSendQueue(); foreach (ItemInfo item in _session.Items.AllItemsReceived) { _items.Enqueue(item); } CheckReceivedItems(); foreach (long item2 in APItems.SentLocations) { Plugin.Logger.LogInfo((object)$"Logged Sent Location ID: {item2}"); } Update(); FillOptions(loginSuccess.SlotData); if (!Utility.IsNullOrWhiteSpace(server)) { Plugin.ClientOptions.Server = server; } if (!Utility.IsNullOrWhiteSpace(user)) { Plugin.ClientOptions.User = user; } if (!Utility.IsNullOrWhiteSpace(pass)) { Plugin.ClientOptions.Password = pass; } Connecting = false; CommandConsole.Log($"Successfully connected to {Plugin.ClientOptions.Server} as {Plugin.ClientOptions.User}!"); CommandConsole.Log($" Slot Number: {loginSuccess.Slot}"); Plugin.ClientOptions.SaveOptions(); _connectedBefore = true; Deathlinkservice = DeathLinkProvider.CreateDeathLinkService(_session); DeathLinkService deathlinkservice = Deathlinkservice; object obj6 = <>O.<5>__ProcDeathlink; if (obj6 == null) { DeathLinkReceivedHandler val6 = DeathLinkHandler.ProcDeathlink; <>O.<5>__ProcDeathlink = val6; obj6 = (object)val6; } deathlinkservice.OnDeathLinkReceived += (DeathLinkReceivedHandler)obj6; if (Plugin.ClientOptions.Deathlink) { Deathlinkservice.EnableDeathLink(); } return null; } public static async Task Disconnect(bool tryReconnect = false) { if (_session != null) { IReceivedItemsHelper items = _session.Items; object obj = <>O.<0>__OnItemReceive; if (obj == null) { ItemReceivedHandler val = OnItemReceive; <>O.<0>__OnItemReceive = val; obj = (object)val; } items.ItemReceived -= (ItemReceivedHandler)obj; IMessageLogHelper messageLog = _session.MessageLog; object obj2 = <>O.<1>__OnMessageReceive; if (obj2 == null) { MessageReceivedHandler val2 = OnMessageReceive; <>O.<1>__OnMessageReceive = val2; obj2 = (object)val2; } messageLog.OnMessageReceived -= (MessageReceivedHandler)obj2; IArchipelagoSocketHelper socket = _session.Socket; object obj3 = <>O.<2>__OnError; if (obj3 == null) { ErrorReceivedHandler val3 = OnError; <>O.<2>__OnError = val3; obj3 = (object)val3; } socket.ErrorReceived -= (ErrorReceivedHandler)obj3; IArchipelagoSocketHelper socket2 = _session.Socket; object obj4 = <>O.<3>__OnSocketClosed; if (obj4 == null) { SocketClosedHandler val4 = OnSocketClosed; <>O.<3>__OnSocketClosed = val4; obj4 = (object)val4; } socket2.SocketClosed -= (SocketClosedHandler)obj4; ILocationCheckHelper locations = _session.Locations; object obj5 = <>O.<4>__OnLocationReceive; if (obj5 == null) { CheckedLocationsUpdatedHandler val5 = OnLocationReceive; <>O.<4>__OnLocationReceive = val5; obj5 = (object)val5; } locations.CheckedLocationsUpdated -= (CheckedLocationsUpdatedHandler)obj5; if (Deathlinkservice != null) { DeathLinkService deathlinkservice = Deathlinkservice; object obj6 = <>O.<5>__ProcDeathlink; if (obj6 == null) { DeathLinkReceivedHandler val6 = DeathLinkHandler.ProcDeathlink; <>O.<5>__ProcDeathlink = val6; obj6 = (object)val6; } deathlinkservice.OnDeathLinkReceived -= (DeathLinkReceivedHandler)obj6; Deathlinkservice = null; } APItems.TargetAPDebuffCount = 10; APItems.TrinketSlots = 3; APItems.ProgressiveRegions = 0; APItems.ProgressivePerkUnlocks = 0; Plugin.LoanAmount = 0; APItems.ClearAllFlags(); APItems.SentLocations.Clear(); CL_GameManager.globalRoaches -= APItems.TotalCreditsReceived; CL_GameManager.runRoaches -= APItems.TotalRoachesReceived; } Connected = false; _goaled = false; if (_connectedBefore && tryReconnect) { _reconnectAttempts++; if (_reconnectAttempts >= 5) { await Task.Delay(5000); _connectedBefore = false; } await Connect(); } _slotData = new Dictionary(); return null; } public static void Update() { if (Connected) { try { CheckReceivedItems(); CheckLocationsToSend(); } catch { Disconnect(); } } } private static void OnLocationReceive(ReadOnlyCollection newCheckedLocations) { lock (APItems.SentLocations) { foreach (long newCheckedLocation in newCheckedLocations) { APItems.SentLocations.Add(newCheckedLocation); } } } private static void OnItemReceive(ReceivedItemsHelper helper) { while (helper.Any()) { _items.Enqueue(helper.DequeueItem()); } } private static void OnMessageReceive(LogMessage message) { CommandConsole.Log($"[{Plugin.ClientOptions.Server}] - {message}"); } public static void Say(string[] args) { if (Connected) { _session.Say(string.Join(" ", args)); } else { CommandConsole.Log("Not currently connected to server"); } } public static void TryQueueLocation(long itemID) { _locationsToSend.Add(itemID); } private static void CheckReceivedItems() { while (_items.Any() && Connected) { ItemInfo val = _items.Dequeue(); APItems.UpdateFromItem(val); CommandConsole.Log($"Received item: {val.ItemDisplayName} from {val.LocationName} in game {val.LocationGame}"); } } public static void Goal() { if (!_goaled) { _session.SetGoalAchieved(); _goaled = true; } } private static void CheckLocationsToSend() { //IL_00bd: Expected O, but got Unknown if (!(_locationsToSend.Any() & Connected)) { return; } try { _session.Locations.CompleteLocationChecksAsync(_locationsToSend.ToArray()); List locationsToSend = _locationsToSend; _locationsToSend.Clear(); foreach (long item in locationsToSend) { Plugin.Logger.LogInfo((object)("Sent item ID: " + item)); if (!APItems.SentLocations.Contains(item)) { APItems.SentLocations.Add(item); } } ShowSentItemPopup(locationsToSend); } catch (ArchipelagoSocketClosedException ex) { ArchipelagoSocketClosedException ex2 = ex; Plugin.Logger.LogError((object)((object)ex2).ToString()); Disconnect(); } } private static async Task ShowSentItemPopup(List locationsToSend) { Dictionary infos = await _session.Locations.ScoutLocationsAsync(_locationsToSend.ToArray()); foreach (long l in locationsToSend) { if (infos[l].Player.Name != Plugin.ClientOptions.User && !Connecting) { ItemFlags flags = ((ItemInfo)infos[l]).Flags; if (1 == 0) { } string text = (int)flags switch { 0 => "Filler_Icon", 1 => "Progression_Icon", 2 => "Icon", 4 => "Trap_Icon", _ => throw new ArgumentOutOfRangeException(), }; if (1 == 0) { } Sprite val = APItems.SpriteFromPath("WKRando/Assets/Archipelago_" + text + ".png"); string text2 = $"{((ItemInfo)infos[l]).ItemDisplayName} for {infos[l].Player} from {((ItemInfo)infos[l]).LocationDisplayName}"; ItemFlags flags2 = ((ItemInfo)infos[l]).Flags; if (1 == 0) { } Color val2 = (Color)((int)flags2 switch { 0 => new Color(0.2f, 0.2f, 0.2f), 1 => new Color(0.5f, 0.5f, 0f), 2 => new Color(0.3f, 0f, 0.5f), 4 => new Color(0.5f, 0f, 0f), _ => throw new ArgumentOutOfRangeException(), }); if (1 == 0) { } CL_ProgressionManager.ShowUnlockPopup(val, "Sent Item:", text2, val2, (AudioClip)null, true); } } } private static void OnError(Exception exception, string message) { Plugin.Logger.LogError((object)exception.ToString()); CommandConsole.Log("AP " + message); Disconnect(); } private static void OnSocketClosed(string message) { Plugin.Logger.LogError((object)("AP " + message)); CommandConsole.Log("AP " + message); Disconnect(); } private static void FixSendQueue() { for (int i = 0; i < _locationsToSend.Count; i++) { if (APItems.SentLocations.Contains(_locationsToSend[i])) { _locationsToSend.RemoveAt(i); } } } private static void FillOptions(Dictionary slotData) { string text = ""; foreach (string key in slotData.Keys) { text += $"{key}: {slotData[key]}\n"; } Plugin.Logger.LogInfo((object)text); Plugin.Logger.LogInfo((object)Convert.ToString(DataStorageElement.op_Implicit(_session.DataStorage[(Scope)3, "ConnectedOnce"]))); _session.DataStorage[(Scope)3, "ConnectedOnce"].Initialize(JToken.op_Implicit(false)); Plugin.APOptions.StartingDebuffs = (slotData.TryGetValue("Starting_Debuffs", out var value) ? Convert.ToInt32(value) : 10); APItems.TargetAPDebuffCount -= 10 - Plugin.APOptions.StartingDebuffs; Plugin.APOptions.StartingTrinketSlots = ((!slotData.TryGetValue("Starting_Trinket_Slots", out var value2)) ? 1 : Convert.ToInt32(value2)); APItems.TrinketSlots += 3 - Plugin.APOptions.StartingTrinketSlots; Plugin.APOptions.EnableAllTrinkets = slotData.TryGetValue("Enable_Trinket_Randomization", out var value3) && Convert.ToBoolean(value3); Plugin.APOptions.SetGoalArea(slotData.TryGetValue("Goal_Region", out var value4) ? Convert.ToInt32(value4) : 3); if (slotData.TryGetValue("Include_Challenge_Modes", out var value5) && (int)value5 == 1) { Plugin.APOptions.UnlockChallenges(); } Plugin.ClientOptions.LoadOptions(); if (!DataStorageElement.op_Implicit(_session.DataStorage[(Scope)3, "ConnectedOnce"])) { Plugin.Logger.LogInfo((object)"First connection detecting, setting any client data"); SetClientOptions(slotData); } _session.DataStorage[(Scope)3, "ConnectedOnce"] = DataStorageElement.op_Implicit(true); } public static async Task> ScoutItemDescriptionFromID(long[] ids) { return (await _session.Locations.ScoutLocationsAsync(false, ids)).Values.ToList(); } private static void FillOptions() { } public static void SetClientOptions(string[] args) { SetClientOptions(_slotData); } public static void SetClientOptions(Dictionary slotData) { try { if (Convert.ToInt32(slotData["Deathlink"]) == 0) { Plugin.ClientOptions.EnableDeathlink(); } else if (Convert.ToInt32(slotData["Deathlink"]) == 1) { Plugin.ClientOptions.DisableDeathlink(); } } catch { Plugin.Logger.LogInfo((object)"Deathlink not found, skipping"); } try { if (Convert.ToInt32(slotData["Deathlink_Amnesty"]) != 0) { Plugin.ClientOptions.DeathlinkAmnesty = Convert.ToInt32(slotData["deathlink_amnesty"]); } } catch { Plugin.Logger.LogInfo((object)"Deathlink amnesty not found, skipping"); } try { if (Convert.ToBoolean(slotData["Include_Challenge_Modes"])) { Plugin.ClientOptions.FreeDiskVendors = true; } else { Plugin.ClientOptions.FreeDiskVendors = false; } } catch { Plugin.Logger.LogInfo((object)"Disk Vendor Cost not found, skipping"); } Plugin.ClientOptions.ServerSeed = _session.RoomState.Seed; Plugin.ClientOptions.SaveOptions(); if (Plugin.ClientOptions.Deathlink) { Deathlinkservice.EnableDeathLink(); } } } public static class CustomPerks { private static Perk _apDebuff; private static Perk _apBuff; private static Perk _apAmnesty; public static Perk ApBuff(int stacks = 1) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00d8: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown //IL_0207: 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) _apBuff = ScriptableObject.CreateInstance(); _apBuff.id = "archipelago_buff"; ((Object)_apBuff).name = "perk_ap_buff"; _apBuff.title = "Archipelago Buff"; _apBuff.description = "You feel the pull of other worlds taking you higher"; _apBuff.canStack = true; _apBuff.stackMax = 100; _apBuff.useBuff = true; _apBuff.buffMultiplier = 1f; _apBuff.multiplierCurve = AnimationCurve.Constant(0f, 1f, 1f); _apBuff.modules = new List(); _apBuff.stackAmount = stacks; _apBuff.buff = new BuffContainer { id = "archipelago_buff", desc = "", loseOverTime = false, loseRate = 0f, buffTime = 1f, multiplier = 1f, loseRateEffectedByPerks = false, buffs = new List { NewBuff("addGravity", -0.03f, -0.03f), NewBuff("addStaminaRegen", 0.04f, 0.04f), NewBuff("addStamina", 0.05f, 0.05f), NewBuff("addClimb", 0.06f, 0.06f), NewBuff("addJump", 0.05f, 0.05f), NewBuff("addSpeed", 0.06f, 0.06f) } }; Texture2D val = new Texture2D(256, 256); string path = Path.Combine(Path.Combine(Paths.PluginPath, "ConcreteConsumer-WhiteKnuckleArchipelago"), "WKRando\\Assets\\Archipelago_Perk.png"); ImageConversion.LoadImage(val, File.ReadAllBytes(path)); _apBuff.icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 900f); _apBuff.iconMat = CL_AssetManager.baseDatabase.perkAssets[62].iconMat; return _apBuff; } public static Perk ApDebuff(int stacks = 1) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) _apDebuff = ScriptableObject.CreateInstance(); _apDebuff.id = "archipelago_debuff"; ((Object)_apDebuff).name = "perk_ap_debuff"; _apDebuff.title = "Archipelago Debuff"; _apDebuff.description = "The grasp of other worlds weighs you down"; _apDebuff.flavorText = "Debuffs to all stats"; _apDebuff.stackMax = 100; _apDebuff.useBuff = true; _apDebuff.buffMultiplier = 1f; _apDebuff.multiplierCurve = CreateExponentialDecayCurve(0.98f); _apDebuff.modules = new List(); _apDebuff.stackAmount = stacks; _apDebuff.buff = new BuffContainer { id = "archipelago_debuff", desc = "", loseOverTime = false, loseRate = 0f, buffTime = 1f, multiplier = 1f, loseRateEffectedByPerks = false, buffs = new List { NewBuff("addGravity", 0.05f, 0.05f), NewBuff("addStaminaRegen", -0.01f, -0.01f), NewBuff("addStamina", -0.05f, -0.05f), NewBuff("addClimb", -0.005f, -0.005f), NewBuff("addJump", -0.005f, -0.005f), NewBuff("addSpeed", -0.03f, -0.03f) } }; Texture2D val = new Texture2D(256, 256); ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Path.Combine(Paths.PluginPath, "ConcreteConsumer-WhiteKnuckleArchipelago"), "WKRando\\Assets\\Broken_Archipelago_Perk.png"))); _apDebuff.icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 900f); _apDebuff.iconMat = CL_AssetManager.baseDatabase.perkAssets[10].iconMat; return _apDebuff; } public static Perk AmnestyStack(int stacks = 1) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_0108: 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) _apAmnesty = ScriptableObject.CreateInstance(); _apAmnesty.id = "archipelago_amnesty"; ((Object)_apAmnesty).name = "perk_ap_amnesty"; _apAmnesty.title = "Deathlink Amnesty"; _apAmnesty.description = "Receiving a specified amount of this perk will kill you!"; _apAmnesty.flavorText = "Obtained whenever someone dies in the multiworld"; _apAmnesty.stackMax = 100; _apAmnesty.useBuff = false; _apAmnesty.buffMultiplier = 0f; _apAmnesty.modules = new List(); _apAmnesty.multiplierCurve = AnimationCurve.Constant(0f, 1f, 1f); _apAmnesty.stackAmount = stacks; Texture2D val = new Texture2D(256, 256); ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Path.Combine(Paths.PluginPath, "ConcreteConsumer-WhiteKnuckleArchipelago"), "WKRando\\Assets\\Archipelago_Amnesty_Perk.png"))); _apAmnesty.icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 900f); _apAmnesty.iconMat = CL_AssetManager.baseDatabase.perkAssets[10].iconMat; return _apAmnesty; } private static Buff NewBuff(string id, float amount, float maxAmount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Buff val = new Buff(); val.id = id; val.amount = amount; val.maxAmount = maxAmount; return val; } private static AnimationCurve CreateExponentialDecayCurve(float decay, int keyFrameCount = 100) { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown Keyframe[] array = (Keyframe[])(object)new Keyframe[keyFrameCount]; float num = 1f; for (int i = 0; i < keyFrameCount; i++) { array[i] = new Keyframe((float)i / (float)(keyFrameCount - 1), num); num *= decay; } return new AnimationCurve(array); } } internal static class DeathLinkHandler { private static Sprite _amnestyIcon; public static bool deathlinkbusy; public static int DeathLinksSentSinceLast; public static void Awake() { _amnestyIcon = APItems.SpriteFromPath("WKRando/Assets/Archipelago_Deathlink_Receive.png"); } public static void ProcDeathlink(DeathLink DeathlinkObject) { DeathlinkDeath(DeathlinkObject); } public static void LocalSendDeathLink(string reason) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown Plugin.Logger.LogInfo((object)("Died to " + reason + " As Player " + Plugin.ClientOptions.User)); if (!Plugin.ClientOptions.Deathlink || ArchipelagoClient.Deathlinkservice == null || Utility.IsNullOrWhiteSpace(reason)) { Plugin.Logger.LogInfo((object)"Deathlink is disabled"); return; } ArchipelagoClient.Deathlinkservice.SendDeathLink(new DeathLink(Utility.IsNullOrWhiteSpace(Plugin.ClientOptions.User) ? "white knuckle player" : Plugin.ClientOptions.User, Plugin.ClientOptions.User + ": " + reason.ToLower())); Plugin.Logger.LogInfo((object)"Successfully sent DeathLink"); } private static void DeathlinkDeath(DeathLink DeathlinkObject) { //IL_011f: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.ClientOptions.Deathlink || Plugin.ClientOptions.DeathlinkAmnesty == 0) { return; } Plugin.Logger.LogInfo((object)"Starting Deathlink"); DeathLinksSentSinceLast++; if (DeathLinksSentSinceLast >= Plugin.ClientOptions.DeathlinkAmnesty) { deathlinkbusy = true; if (((DeathlinkObject != null) ? DeathlinkObject.Cause : null) != null) { ArchipelagoClient.DeathMessage = DeathlinkObject.Cause; } Plugin.Logger.LogInfo((object)("Killing player because of deathlink " + (((DeathlinkObject != null) ? DeathlinkObject.Source : null) ?? "Some player") + ", " + (((DeathlinkObject != null) ? DeathlinkObject.Cause : null) ?? "Unknown Cause"))); ((GameEntity)ENT_Player.playerObject).Kill("deathlink", (DamageInfo)null); DeathLinksSentSinceLast = 0; } else { Plugin.Logger.LogInfo((object)"Deathlink caught by amnesty"); CL_ProgressionManager.ShowUnlockPopup(_amnestyIcon, "Deathlink Stack Received", ((DeathlinkObject != null) ? DeathlinkObject.Cause : null) ?? "Unknown Cause", new Color(0.4f, 0.1f, 0.1f), (AudioClip)null, true); } deathlinkbusy = false; } } [BepInPlugin("com.wuckle.concsumer.name", "WKRando", "1.0.0")] [BepInProcess("White Knuckle.exe")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(ENT_Player), "Update")] private class PlayerUpdate { private static void Prefix(ENT_Player __instance) { ArchipelagoClient.Update(); try { if (ArchipelagoClient.Connected && (Object)(object)WorldLoader.instance != (Object)null && WorldLoader.instance.GetCurrentLevel().GetLevel().levelName == APOptions.GoalArea) { ArchipelagoClient.Goal(); } if ((Object)(object)WorldLoader.instance != (Object)null && APItems.RoomNameToAP.TryGetValue(WorldLoader.instance.GetCurrentLevel().GetLevel().levelName, out var value) && !APItems.SentLocations.Contains(value)) { APItems.SentLocations.Add(value); ArchipelagoClient.TryQueueLocation(value); } } catch { } int? num = ((__instance == null) ? ((int?)null) : __instance.GetPerk("archipelago_debuff")?.stackAmount); int valueOrDefault; if (!num.HasValue) { int? obj2; if (__instance == null) { obj2 = null; } else { Perk perk = __instance.GetPerk("archipelago_buff"); obj2 = ((perk != null) ? new int?(-perk.stackAmount) : ((int?)null)); } int? num2 = obj2; valueOrDefault = num2.GetValueOrDefault(); } else { valueOrDefault = num.GetValueOrDefault(); } int num3 = valueOrDefault; if (num3 != APItems.TargetAPDebuffCount && (Object)(object)__instance != (Object)null && !((GameEntity)__instance).IsDead()) { Logger.LogInfo((object)("Amount, Target: " + num3 + ", " + APItems.TargetAPDebuffCount)); __instance.RemovePerk("archipelago_buff", true); __instance.RemovePerk("archipelago_debuff", true); if (APItems.TargetAPDebuffCount > 0) { __instance.AddPerk(CL_AssetManager.GetPerkAsset("archipelago_debuff", ""), APItems.TargetAPDebuffCount, true); } else if (APItems.TargetAPDebuffCount != 0) { __instance.AddPerk(CL_AssetManager.GetPerkAsset("archipelago_buff", ""), -APItems.TargetAPDebuffCount, true); } } if (ClientOptions.DeathlinkAmnesty != 0 && (Object)(object)__instance != (Object)null && !((GameEntity)__instance).IsDead() && DeathLinkHandler.DeathLinksSentSinceLast != ((__instance == null) ? ((int?)null) : __instance.GetPerk("archipelago_amnesty")?.stackAmount).GetValueOrDefault()) { __instance.RemovePerk("archipelago_amnesty", true); __instance.AddPerk(CL_AssetManager.GetPerkAsset("archipelago_amnesty", ""), DeathLinkHandler.DeathLinksSentSinceLast, true); } } } [HarmonyPatch(typeof(FacilityUpgrade), "IsOwned")] private class AlterUpgradeCheck { private static bool Prefix(FacilityUpgrade __instance, ref bool __result, object[] __args) { string id = StatManager.saveData.GetFacility((string)__args[0]).id; if (APItems.FacilityDict.TryGetValue(id, out var value) && value.TryGetValue(__instance.id, out var value2)) { __result = value2; return false; } return true; } } [HarmonyPatch(typeof(SteamManager), "Update")] public class DisableSteamManager { private static bool Prefix() { return false; } } [HarmonyPatch] public class AlterStats { public static string SaveLocation = "Archipelago/rando_save.json"; public static string BackupSaveLocation = "Archipelago/rando_save-backup.json"; public static string ErrorBackupLocation = "Archipelago/rando_save-error-backup.json"; public static string CrashBackupLocation = "Archipelago/rando_save-backup-crash.json"; public static string QuitBackupLocation = "Archipelago/rando_save-backup-quit.json"; public static void UpdateSaveLocationNames(string seedID) { SaveLocation = "Archipelago/" + seedID + "_save.json"; if (StatManager.hasLoaded) { StatManager.instance.filePath = Path.Combine(Application.persistentDataPath, SaveLocation); } BackupSaveLocation = "Archipelago/" + seedID + "_save-backup.json"; ErrorBackupLocation = "Archipelago/" + seedID + "_save-error-backup.json"; CrashBackupLocation = "Archipelago/" + seedID + "_save-backup-crash.json"; QuitBackupLocation = "Archipelago/" + seedID + "_save-backup-quit.json"; } [HarmonyPatch(typeof(StatManager), "Awake")] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"wk_save.json", (string)null) }).Repeat((Action)delegate(CodeMatcher matcher) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown matcher.SetInstruction(new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(AlterStats), "SaveLocation"))); }, (Action)null).InstructionEnumeration(); } [HarmonyPatch(typeof(StatManager), "LoadStats")] private static void Postfix(StatManager __instance) { Logger.LogInfo((object)("Save is at: " + __instance.filePath)); } [HarmonyPatch(typeof(CL_Leaderboard), "CreateUserDataFromCurrentSession")] [HarmonyPrefix] private static bool PreventOfflineScores(ref WK_Leaderboard_UserData __result) { __result = null; return false; } } [HarmonyPatch(typeof(CommandConsole), "Awake")] private class AddCommands { private static void ChangeLoanCommand(string[] args) { if (args.Length == 0 || args[0] == "") { CommandConsole.Log("Incorrect format: Uses a single integer"); } else { LoanAmount = int.Parse(args[0]); } } public static void CheatRoachesInCommand(string[] args) { try { CL_GameManager.runRoaches = int.Parse(args[0]); } catch { CommandConsole.Log("Requires a single integer"); } } private static async void TryConnectCommand(string[] args) { if (args.Length == 0) { await ArchipelagoClient.Connect(); } else if (args.Length == 1) { await ArchipelagoClient.Connect(args[0]); } else if (args.Length == 2) { await ArchipelagoClient.Connect(args[0], args[1]); } else { await ArchipelagoClient.Connect(args[0], args[1], args[2]); } } private static void ResetAPSaveData(string[] args) { CommandConsole.Log("Resetting Save..."); File.Create(Path.Combine(Application.persistentDataPath, (ClientOptions.ServerSeed ?? "rando") + "_save.json")); } private static async void DisconnectCommand(string[] args) { await ArchipelagoClient.Disconnect(); } private static void SetDebuffs(string[] args) { if (args.Length < 1 || !int.TryParse(args[0], out var result)) { CommandConsole.Log("Requires a single integer"); } else { APItems.TargetAPDebuffCount = result; } } private static void TestPopup(string[] args) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) string text = "Test message"; if (args.Length >= 1) { text = args[0]; } CL_ProgressionManager.ShowUnlockPopup(APItems.SpriteFromPath("WKRando/Assets/Archipelago_Icon.png"), "Test Popup", text, new Color(0f, 1f, 0f), (AudioClip)null, true); } private static void ChangeClientSettings(string[] args) { for (int i = 0; i < args.Length - 1; i++) { try { switch (args[i].ToLower().Replace('-', '_')) { case "deathlink": Logger.LogInfo((object)"deathlink..."); if (args[i + 1] == "amnesty") { ClientOptions.DeathlinkAmnesty = Convert.ToInt32(args[i + 2]); Logger.LogInfo((object)("setting deathlink amnesty to " + args[i + 2])); CommandConsole.Log("setting deathlink amnesty to " + args[i + 2]); break; } if (Convert.ToBoolean(args[i + 1])) { ClientOptions.EnableDeathlink(); } else if (!Convert.ToBoolean(args[i + 1])) { ClientOptions.DisableDeathlink(); } Logger.LogInfo((object)("Setting Deathlink to " + args[i + 1])); CommandConsole.Log("Setting Deathlink to " + args[i + 1]); break; case "deathlink_amnesty": ClientOptions.DeathlinkAmnesty = Convert.ToInt32(args[i + 1]); Logger.LogInfo((object)("Setting Deathlink-amnesty to " + args[i + 1])); CommandConsole.Log("Setting Deathlink-amnesty to " + args[i + 1]); break; case "free_disk_vendors": ClientOptions.FreeDiskVendors = Convert.ToBoolean(args[i + 1]); Logger.LogInfo((object)("Setting Free-disk-vendors to " + args[i + 1])); CommandConsole.Log("Setting Free-disk-vendors to " + args[i + 1]); break; case "unlock_all_endless": ClientOptions.UnlockAllEndlessModes = Convert.ToBoolean(args[i + 1]); Logger.LogInfo((object)("Setting Unlock-all-endless to " + args[i + 1])); CommandConsole.Log("Setting Unlock-all-endless to " + args[i + 1]); break; } } catch { CommandConsole.Log("Invalid command arguments"); } } ClientOptions.SaveOptions(); } private static void TestArchipelagoDeath(string[] args) { if (args.Length >= 1) { ArchipelagoClient.DeathMessage = string.Join(" ", args); } ((GameEntity)ENT_Player.playerObject).Kill("deathlink"); } private static void Postfix() { CommandConsole.BuildCommand("setdebuff", (Action)SetDebuffs).NotCheat().Description("Sets the number of archipelago debuffs to the specified integer. Using a negative integer will apply buffs instead."); CommandConsole.BuildCommand("setloan", (Action)ChangeLoanCommand).Description("Sets the starting roach loan value to the specified value"); CommandConsole.BuildCommand("connect", (Action)TryConnectCommand).NotCheat().Description("Attempts to connect to Archipelago Server \n") .OverValue((Func)(() => "\n Servername: " + (Utility.IsNullOrWhiteSpace(ClientOptions.Server) ? "none" : ClientOptions.Server) + " " + "\n Username: " + (Utility.IsNullOrWhiteSpace(ClientOptions.User) ? "none" : ClientOptions.User) + " \n Password: " + (Utility.IsNullOrWhiteSpace(ClientOptions.Password) ? "none" : new string('*', ClientOptions.Password.Length)))); CommandConsole.BuildCommand("resetapsave", (Action)ResetAPSaveData).Description("Deprecated command"); CommandConsole.BuildCommand("say", (Action)ArchipelagoClient.Say).NotCheat().Description("Sends a message to the archipelago client."); CommandConsole.BuildCommand("disconnect", (Action)DisconnectCommand).NotCheat().Description("Disconnects from the Archipelago Server"); CommandConsole.BuildCommand("testpopup", (Action)TestPopup).NotCheat(); CommandConsole.BuildCommand("ResetClientOptions", (Action)ArchipelagoClient.SetClientOptions).NotCheat().Description("Resets your client options back to what is listed in the yaml"); CommandConsole.BuildCommand("ChangeClientOptions", (Action)ChangeClientSettings).NotCheat().Description("Changes options, use ListOptions to get a list of the ones you can change, spaces and both dashes work") .AutocompleteCustom((Action)delegate(CommandAutocomplete autocomplete) { if (autocomplete.activeArg < 0 || autocomplete.activeArg > 1) { autocomplete.Reject(); } else if (autocomplete.activeArg == 0) { autocomplete.FromArrayWithDesc((IReadOnlyList>)new List<(string, string)> { ("deathlink", $"Sets deathlink with true or false: {ClientOptions.Deathlink}"), ("deathlink-amnesty", $"Sets receive amnesty with integer: {ClientOptions.DeathlinkAmnesty}"), ("free-disk-vendors", $"Sets whether or not disk vendors are free: {ClientOptions.FreeDiskVendors}"), ("unlock-all-endless", $"Unlocks all endless modes: {ClientOptions.UnlockAllEndlessModes}") }); } else if (autocomplete.activeArg == 1) { string text = autocomplete.args[0]; if (text == "deathlink" || text == "free-disk-vendors") { autocomplete.FromArray((IReadOnlyList)new <>z__ReadOnlyArray(new string[2] { "true", "false" })); } } }); CommandConsole.BuildCommand("TestArchipelagoDeath", (Action)TestArchipelagoDeath).Description("Kills the player with the specified death message"); Logger.LogInfo((object)"Successfully Injected Commands"); } } [HarmonyPatch(typeof(UI_CapsuleButton), "CheckAchievement")] private class PatchModeUIButtons { private static Dictionary areaChecker = new Dictionary { ["Mode Selection Button - Endless"] = "none", ["Mode Selection Button - Endless Underworks"] = "none", ["Mode Selection Button - Endless Superstructure"] = "none", ["Mode Selection Button - Silos"] = "ldc-silos-breakroom-totaltimesreached", ["Mode Selection Button - Pipeworks"] = "ldc-interlude-lockdown-totaltimesreached", ["Mode Selection Button - Habitation"] = "ldc-m3_shaft_safearea-totaltimesreached", ["Mode Selection Button - Abyss"] = "ldc-interlude-evacuation-totaltimesreached", ["Mode Selection Button - Nest"] = "ldc-interlude-symbiosis-start-totaltimesreached" }; private static Dictionary progressiveReqs = new Dictionary { ["Mode Selection Button - Endless"] = 4, ["Mode Selection Button - Endless Underworks"] = 1, ["Mode Selection Button - Endless Superstructure"] = 2, ["Mode Selection Button - Silos"] = 0, ["Mode Selection Button - Pipeworks"] = 1, ["Mode Selection Button - Habitation"] = 2, ["Mode Selection Button - Abyss"] = 3, ["Mode Selection Button - Nest"] = 4 }; private static bool Prefix(UI_CapsuleButton __instance) { if (APItems.ModeUnlocks.TryGetValue(((Object)__instance).name, out var value)) { if (areaChecker.TryGetValue(((Object)__instance).name, out var value2) && progressiveReqs.TryGetValue(((Object)__instance).name, out var value3) && ((StatManager.GetTotalStatisticInt(value2) > 0 && APItems.ProgressiveRegions >= value3) || ClientOptions.UnlockAllEndlessModes)) { value = true; } if (__instance.unlockIcon != null) { ((Component)__instance.unlockIcon).gameObject.SetActive(!value); } if (__instance.group != null) { __instance.group.interactable = value; __instance.group.alpha = (value ? 1f : 0.5f); } __instance.button.interactable = value; return false; } return true; } } [HarmonyPatch(typeof(Cosmetic_Base), "IsUnlocked")] private class PatchCosmeticBaseIsUnlocked { private static bool Prefix(ref bool __result) { __result = true; return false; } } [HarmonyPatch(typeof(UI_FacilityMenu_Button), "Refresh")] private class PatchMainMenuFacilityButtons { private static void Postfix(UI_FacilityMenu_Button __instance) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected I4, but got Unknown if ((Object)(object)__instance == (Object)null) { return; } Logger.LogInfo((object)((Object)__instance.upgrade).name); if (!ArchipelagoClient.Connected) { __instance.tooltip.tip = "DISCONNECTED\nConnect to the archipelago server to purchase facility upgrades"; __instance.lockRoot.SetActive(true); __instance.isLocked = true; return; } __instance.lockRoot.SetActive(false); __instance.isLocked = false; ((Component)__instance.icon).gameObject.SetActive(true); if (_nameToScoutedItem.TryGetValue("GLOBAL " + ((Object)__instance.upgrade).name, out var value)) { ItemFlags flags = ((ItemInfo)value).Flags; ItemFlags val = flags; switch ((int)val) { case 1: __instance.tooltip.tip = "Progression Item\nThis item is classified as progression to some player in this multiworld."; __instance.icon.sprite = APItems.SpriteFromPath("WKRando/Assets/Archipelago_Progression_Icon.png"); break; case 2: __instance.tooltip.tip = "Useful Item\nThis item is classified as useful to some player in this multiworld."; __instance.icon.sprite = APItems.SpriteFromPath("WKRando/Assets/Archipelago_Icon.png"); break; case 0: __instance.tooltip.tip = "Filler Item\nThis item is classified as useful to some player in this multiworld."; __instance.icon.sprite = APItems.SpriteFromPath("WKRando/Assets/Archipelago_Filler_Icon.png"); break; case 4: __instance.tooltip.tip = "Trap Item\nThis item is classified as a trap to some player in this multiworld."; __instance.icon.sprite = APItems.SpriteFromPath("WKRando/Assets/Archipelago_Trap_Icon.png"); break; } __instance.purchasedRoot.SetActive(APItems.SentLocations.Contains(((ItemInfo)value).LocationId)); } else { __instance.tooltip.tip = "This is an unknown archipelago item!"; __instance.icon.sprite = APItems.SpriteFromPath("WKRando/Assets/Archipelago_Icon.png"); } Upgrade upgrade = StatManager.saveData.GetFacility(__instance.facility.id).GetUpgrade(__instance.upgrade.id); if (upgrade != null && upgrade.owned) { __instance.isSelected = true; __instance.purchasedRoot.SetActive(true); return; } __instance.isSelected = false; __instance.purchasedRoot.SetActive(false); if (!__instance.isLocked && __instance.upgrade.cost > StatManager.saveData.GetRoachBankByID("campaign").value) { __instance.tooltip.tip = "CANNOT AFFORD\n\n" + __instance.tooltip.tip; __instance.expensiveRoot.gameObject.SetActive(true); ((Component)__instance.icon).gameObject.SetActive(false); __instance.isLocked = true; } } } [HarmonyPatch(typeof(FacilityMenu), "FillUpgrades")] private class PatchScoutFromFacilityMenu { private static void Prefix(FacilityMenu __instance) { if (!ArchipelagoClient.Connected) { return; } List list = new List(); List list2 = new List(); foreach (FacilityUpgrade upgrade in __instance.globalFacility.upgrades) { Logger.LogInfo((object)("Detected Global Upgrade " + upgrade.id)); if (APItems.FullFacilityUpgradetoAP.TryGetValue("GLOBAL " + upgrade.id, out var value)) { list.Add(value); list2.Add("GLOBAL " + upgrade.id); } } UpdateScoutedItems(list, list2); } } [HarmonyPatch(typeof(SteamManager), "Update")] private class DisableSteamLeaderboardUploads { private static bool Prefix() { return false; } } [HarmonyPatch] private class PatchUnlocks { [HarmonyPatch(typeof(ProgressionUnlock), "CheckUnlock")] private static bool Prefix(ProgressionUnlock __instance, ref bool __result) { bool flag = (__instance.state = APItems.ProgressionUnlocks[__instance.id]); if ((Object)(object)CL_GameManager.gMan != (Object)null) { CL_GameManager.SetGameFlag("unlock_" + ((Object)__instance).name, flag, "", false, false); } __result = flag; return false; } [HarmonyPatch(typeof(CL_ProgressionManager), "HasProgressionUnlock")] [HarmonyPrefix] private static bool Prefix(CL_ProgressionManager __instance, ref bool __result, object[] __args) { __result = CL_ProgressionManager.progressionDict != null && CL_ProgressionManager.progressionDict.ContainsKey((string)__args[0]) && CL_ProgressionManager.progressionDict[(string)__args[0]].CheckUnlock(); return false; } } [HarmonyPatch(typeof(App_PerkPage), "CheckIronKnuckle")] private class PatchPerksPage { private static bool Prefix(App_PerkPage __instance) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown string levelName = WorldLoader.instance.GetCurrentLevel().GetLevel().levelName; int progressivePerkUnlocks = APItems.ProgressivePerkUnlocks; bool flag = ((levelName == "Campaign_Interlude_Silo_To_Pipeworks_01" || levelName == "Campaign_Interlude_Sink_To_Pipeworks_01") ? true : false); bool flag2 = flag && progressivePerkUnlocks < 1; bool flag3 = flag2; if (!flag3) { bool flag4 = ((levelName == "M3_Habitation_Shaft_Intro" || levelName == "Campaign_Interlude_Chute_To_Habitation") ? true : false); flag3 = flag4 && progressivePerkUnlocks < 2; } if (flag3 || (levelName == "Campaign_Interlude_Abyss_To_Nest_01_SafeArea" && progressivePerkUnlocks < 3)) { __instance.window.os.messageManager.CreateMessage(new Message_Packet { type = "default", closeText = "Quit", closeFunction = __instance.window.CloseApp, message = $"Perks for this sector are disabled by Archipelago!\nCurrent progressive perk count is {APItems.ProgressivePerkUnlocks}", screenPos = new Vector2(0f, 0f) }); return false; } return true; } } [HarmonyPatch(typeof(App_Unlocker))] private class PatchShortcutUnlock { [HarmonyPatch("Start")] private static void Postfix(App_Unlocker __instance) { __instance.password = "impossible passcode uwu you can't unlock this no matter what you do!"; if (((__instance.saveFlagOnUnlock == "unlockedsink") & APItems.ProgressionUnlocks["r_shortcut_tangledsink"]) || ((__instance.window.file.fileInfo.data.Split(",")[0].Split(":")[1] == "chutecode") & APItems.ProgressionUnlocks["r_shortcut_expulsionchute"])) { __instance.authorizationCost = 0; __instance.CheckAuthorize(); } } } [HarmonyPatch(typeof(Trinket), "IsUnlocked")] private class PatchTrinketUnlock { private static bool Prefix(Trinket __instance, ref bool __result) { if (APItems.TrinketUnlocks.TryGetValue(((Object)__instance).name, out var value)) { __result = APOptions.EnableAllTrinkets || value; return false; } return true; } } [HarmonyPatch(typeof(UI_TrinketPicker))] private class PatchPips { [HarmonyPatch("UpdateTrinketActivation")] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0003: 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: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null) }).Advance(2).SetInstruction(new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(APItems), "TrinketSlots"))) .InstructionEnumeration(); } [HarmonyPatch("UpdatePips")] private static void Prefix(object[] __args) { __args[0] = APItems.TrinketSlots; } } [HarmonyPatch(typeof(Item))] private class RemoveUnlockPopup { [HarmonyPatch("SendUnlockMessage")] private static bool Prefix() { return false; } } [HarmonyPatch(typeof(CL_Button), "Interact", new Type[] { })] private class PatchFacilityButtons { private static bool Prefix(CL_Button __instance) { Logger.LogInfo((object)((Object)__instance).name); string levelName = WorldLoader.instance.GetCurrentLevel().GetLevel().levelName; int progressiveRegions = APItems.ProgressiveRegions; Logger.LogInfo((object)("Current Progressive Region Count: " + progressiveRegions)); if (progressiveRegions < 1 && ((levelName == "Campaign_Interlude_Silo_To_Pipeworks_01" && ((Object)__instance).name == "Button.002") || (levelName == "Campaign_Interlude_Sink_To_Pipeworks_01" && ((Object)__instance).name == "Prop_Button_02_Switch.01"))) { return false; } if (progressiveRegions < 2 && ((levelName == "M3_Habitation_Shaft_Intro" && ((Object)__instance).name == "Prop_Button_03_Door") || (levelName == "Campaign_Interlude_Chute_To_Habitation" && ((Object)__instance).name == "Prop_Button_04"))) { return false; } if (progressiveRegions < 3 && levelName == "Campaign_Interlude_Habitation_To_Abyss_01" && ((Object)__instance).name == "Prop_Button_03.01") { return false; } return !((progressiveRegions < 4) & (levelName == "Campaign_Interlude_Abyss_To_Nest_01_SafeArea")) || !(((Object)__instance).name == "Prop_Button_03"); } } [HarmonyPatch(typeof(CL_GameManager), "Awake")] private class PatchCommandConsole { private static void Prefix() { } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] private class PatchCommands { private static void Postfix() { Loaded = true; } private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0003: 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: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)null, (string)null) }).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(Plugin), "LoanAmount"))).InstructionEnumeration(); } } [HarmonyPatch(typeof(Facility), "HasUpgrade")] private class Force20RoachConditional { private static bool Prefix(ref bool __result, object[] __args) { if ((string)__args[0] == "UPG_Global_StartingRoaches_T3") { __result = true; return false; } return true; } } [HarmonyPatch(typeof(CL_GameManager), "OnDestroy")] private class UnloadgMan { private static void Prefix() { Loaded = false; } } [HarmonyPatch(typeof(FacilityUpgrade), "Purchase", new Type[] { typeof(Facility) })] private class PatchPurchase { private static void Prefix(FacilityUpgrade __instance, object[] __args) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) long itemID = APItems.FullFacilityUpgradetoAP[((Facility)__args[0]).id + " " + __instance.id]; ArchipelagoClient.TryQueueLocation(itemID); } } [HarmonyPatch(typeof(CL_AssetManager), "Initialize")] private class PatchPerks { private static void Postfix() { CL_AssetManager.baseDatabase.perkAssets.AddRange(new <>z__ReadOnlyArray((Perk[])(object)new Perk[3] { CustomPerks.ApBuff(), CustomPerks.ApDebuff(), CustomPerks.AmnestyStack() })); } } [HarmonyPatch(typeof(App_Facility_Card), "CheckLock")] private class PatchPerkRefresh { private static bool Prefix(App_Facility_Card __instance) { //IL_009e: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected I4, but got Unknown if (!ArchipelagoClient.Connected) { __instance.lockedObject.SetActive(true); __instance.tooltip.tip = "LOCKED\nDisconnected from Archipelago!\nConnect to purchase upgrades!"; __instance.locked = true; } else { __instance.lockedObject.SetActive(false); __instance.locked = false; if (_nameToScoutedItem != null && _nameToScoutedItem.TryGetValue(__instance.facility.id + " " + __instance.upgrade.id, out var value)) { ((Component)__instance.art).gameObject.SetActive(true); ItemFlags flags = ((ItemInfo)value).Flags; ItemFlags val = flags; switch ((int)val) { case 1: __instance.tooltip.tip = "Progression Item\nThis item is classified as progression to some player in this multiworld."; __instance.art.sprite = APItems.SpriteFromPath("WKRando/Assets/Archipelago_Progression_Icon.png"); break; case 2: __instance.tooltip.tip = "Useful Item\nThis item is classified as useful to some player in this multiworld."; __instance.art.sprite = APItems.SpriteFromPath("WKRando/Assets/Archipelago_Icon.png"); break; case 0: __instance.tooltip.tip = "Filler Item\nThis item is classified as useful to some player in this multiworld."; __instance.art.sprite = APItems.SpriteFromPath("WKRando/Assets/Archipelago_Filler_Icon.png"); break; case 4: __instance.tooltip.tip = "Trap Item\nThis item is classified as a trap to some player in this multiworld."; __instance.art.sprite = APItems.SpriteFromPath("WKRando/Assets/Archipelago_Trap_Icon.png"); break; } __instance.purchasedObject.SetActive(APItems.SentLocations.Contains(((ItemInfo)value).LocationId)); } else { __instance.tooltip.tip = "Some archipelago item probably (scouting failed :( )"; } } return false; } } [HarmonyPatch(typeof(App_FacilitySlotHolder), "Start")] private class PatchSlotHolder { private static void Prefix(App_FacilitySlotHolder __instance) { if (!ArchipelagoClient.Connected || (Object)(object)__instance.window == (Object)null) { return; } Logger.LogInfo((object)"Attempting to scout facility upgrades"); Facility facilityAsset = CL_AssetManager.GetFacilityAsset(__instance.window.os.worldInterface.facilityID, ""); Facility globalFacility = __instance.globalFacility; List locationsToScout = new List(); List list = new List(); foreach (FacilityUpgrade upgrade in facilityAsset.GetUpgrades()) { if (APItems.FullFacilityUpgradetoAP.TryGetValue(facilityAsset.id + " " + upgrade.id, out var value)) { locationsToScout.Add(value); list.Add(facilityAsset.id + " " + upgrade.id); } } foreach (FacilityUpgrade upgrade2 in globalFacility.GetUpgrades()) { Logger.LogInfo((object)("Detected Global Upgrade " + upgrade2.id)); if (APItems.FullFacilityUpgradetoAP.TryGetValue("GLOBAL " + upgrade2.id, out var value2)) { locationsToScout.Add(value2); list.Add("GLOBAL " + upgrade2.id); } } List result = Task.Run(async () => await ArchipelagoClient.ScoutItemDescriptionFromID(locationsToScout.ToArray())).GetAwaiter().GetResult(); for (int num = 0; num < list.Count; num++) { if (!_nameToScoutedItem.TryGetValue(list[num], out var value3)) { _nameToScoutedItem.Add(list[num], result[num]); } else if (value3 != result[num]) { _nameToScoutedItem.Remove(list[num]); _nameToScoutedItem.Add(list[num], result[num]); } } } } [HarmonyPatch(typeof(ENV_Vendor_Disk), "Update")] private class PatchDiskVendorCost { private static void Prefix(ENV_Vendor_Disk __instance) { if (ClientOptions.FreeDiskVendors && __instance.cost != 0) { __instance.cost = 0; } } } [HarmonyPatch(typeof(MenuManager), "Start")] private class PatchChallengeChecks { private static void Prefix() { if (ArchipelagoClient.Connected) { ChallengeQueue(); } } private static void ChallengeQueue() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) foreach (M_Gamemode gamemodeAsset in CL_AssetManager.GetFullCombinedAssetDatabase().gamemodeAssets) { if (!(((object)gamemodeAsset.gamemodeModule).GetType() == typeof(GamemodeModule_Challenge))) { continue; } foreach (Medal medal in ((GamemodeModule_Challenge)gamemodeAsset.gamemodeModule).medals) { if (medal.scoreRequirement < 1f) { medal.scoreRequirement = 1f; } } } foreach (M_Gamemode gamemodeAsset2 in CL_AssetManager.GetFullCombinedAssetDatabase().gamemodeAssets) { int num = ChallengeMode.GetMedalRankFromGamemode(gamemodeAsset2); int num2 = 0; while (num2 < num) { Logger.LogInfo((object)$"Detected medal: {gamemodeAsset2.gamemodeName} rank {num}"); if (APItems.ChallengeMedaltoAPID.TryGetValue($"{gamemodeAsset2.gamemodeName} {num}", out var value) && !APItems.SentLocations.Contains(value)) { ArchipelagoClient.TryQueueLocation(value); } num--; } } } } [HarmonyPatch(typeof(CL_LocalizationManager), "GetLocalization")] private class PatchDeathmessage { private static bool Prefix(ref string __result, object[] __args) { if ((string)__args[0] == "deathmessages" && (string)__args[1] == "deathlink") { __result = ArchipelagoClient.DeathMessage; return false; } if ((string)__args[0] == "deathmessages") { DeathLinkHandler.LocalSendDeathLink(CL_LocalizationManager.currentLocalization.GetLine((string)__args[0], (string)__args[1])); } return true; } } [HarmonyPatch] private class PatchUnlockPopups { [HarmonyPatch(typeof(Item), "SendUnlockMessage")] [HarmonyPrefix] private static bool RemoveItemProgressPopup() { return false; } [HarmonyPatch(typeof(CL_ProgressionManager), "UpdateUnlocks")] [HarmonyPrefix] private static bool RemoveProgressionPopups() { return false; } } [HarmonyPatch(typeof(SteamManager), "UploadGamemodeResults")] private class PatchSteamUpload { private static bool Prefix() { return false; } } public class APOptions { public static int StartingDebuffs = 10; public static int StartingTrinketSlots = 1; public static bool EnableAllTrinkets; public static string GoalArea = "M5_Nest_Trough_Ending_01"; public static void SetGoalArea(int i) { switch (i) { case 1: GoalArea = "Campaign_Interlude_Silo_To_Pipeworks_01"; break; case 2: GoalArea = "M3_Habitation_Shaft_Intro"; break; case 3: GoalArea = "Campaign_Interlude_Habitation_To_Abyss_01"; break; case 4: GoalArea = "Campaign_Interlude_Abyss_To_Nest_01_SafeArea"; break; case 5: GoalArea = "M5_Nest_Trough_Ending_01"; break; } } public static void UnlockChallenges() { foreach (string item in APItems.ModeUnlocks.Keys.ToList()) { if (item.Contains("Challenge")) { APItems.ModeUnlocks[item] = true; } } } } public class CLoptions { public bool Deathlink = false; public int DeathlinkAmnesty = 0; public bool FreeDiskVendors = false; public bool UnlockAllEndlessModes = false; public string ServerSeed; public string Server = ""; public string User = ""; public string Password = ""; public void EnableDeathlink() { if (ArchipelagoClient.Deathlinkservice == null) { CommandConsole.Log("No deathlink object present"); return; } Deathlink = true; ArchipelagoClient.Deathlinkservice.EnableDeathLink(); } public void DisableDeathlink() { Deathlink = false; ArchipelagoClient.Deathlinkservice.DisableDeathLink(); } public void SaveOptions() { File.WriteAllText(Application.persistentDataPath + "\\Archipelago\\ClientOptions.json", JsonUtility.ToJson((object)ClientOptions)); Logger.LogInfo((object)("Saving client options as " + JsonUtility.ToJson((object)ClientOptions))); } public void LoadOptions() { string text = File.ReadAllText(Application.persistentDataPath + "\\Archipelago\\ClientOptions.json"); Logger.LogInfo((object)("Loading client options as: " + text)); ClientOptions = JsonUtility.FromJson(text) ?? new CLoptions(); } public static void ListClientSettings(string[] args) { CommandConsole.Log($"Deathlink: {ClientOptions.Deathlink} \nDeathlink Amnesty: {ClientOptions.DeathlinkAmnesty}"); } } internal static ManualLogSource Logger; public static int LoanAmount = 0; public static bool Loaded; public static CLoptions ClientOptions; private static Dictionary _nameToScoutedItem = new Dictionary(); private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("com.wuckle.concsumer.name"); HarmonyFileLog.Enabled = true; if (!Directory.Exists(Application.persistentDataPath + "\\Archipelago")) { Directory.CreateDirectory(Path.Combine(Application.persistentDataPath, "Archipelago")); } if (!File.Exists(Application.persistentDataPath + "\\Archipelago\\ClientOptions.json")) { ClientOptions = new CLoptions(); ClientOptions.SaveOptions(); } else { ClientOptions = new CLoptions(); ClientOptions.LoadOptions(); if (ClientOptions == null) { ClientOptions = new CLoptions(); } if (ClientOptions?.ServerSeed != null && !Utility.IsNullOrWhiteSpace(ClientOptions.ServerSeed)) { AlterStats.UpdateSaveLocationNames(ClientOptions.ServerSeed); } } DeathLinkHandler.Awake(); val.PatchAll(Assembly.GetExecutingAssembly()); Logger.LogInfo((object)"Archipelago plugin Loaded"); } public static async void UpdateScoutedItems(List locationsToScout, List upgradeNames) { try { List descriptions = await ArchipelagoClient.ScoutItemDescriptionFromID(locationsToScout.ToArray()); for (int i = 0; i < upgradeNames.Count; i++) { if (!_nameToScoutedItem.TryGetValue(upgradeNames[i], out var info)) { _nameToScoutedItem.Add(upgradeNames[i], descriptions[i]); } else if (info != descriptions[i]) { _nameToScoutedItem.Remove(upgradeNames[i]); _nameToScoutedItem.Add(upgradeNames[i], descriptions[i]); } info = null; } } catch (Exception ex) { Exception e = ex; Logger.LogError((object)e.ToString()); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "WKRando"; public const string PLUGIN_NAME = "My first plugin"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }