Decompiled source of TheControlRoomFix v1.3.0
ControlRoomFix.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ControlRoomFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9f9e3cd60375136d2da8a65d40c2d9d799ca3dc4")] [assembly: AssemblyProduct("ControlRoomFix")] [assembly: AssemblyTitle("ControlRoomFix")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 ControlRoomFix { [HarmonyPatch(typeof(CitizenCreator), "StartLoading")] internal static class CitizenGenerationPatch { [HarmonyPrefix] private static void Prefix() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (!Plugin.EnableCityHallGenerationFix.Value) { return; } try { CityHallGenerationFix.Apply(); } catch (Exception ex) { ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(50, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not prepare duplicate City Hall generation: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logSource.LogError(val); } } } internal static class CityHallGenerationFix { private const string CityHallName = "CityHall"; private static CompanyPreset? rememberedPreset; private static int originalMinimum; private static int originalMaximum; internal static void Apply() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown CityData instance = CityData.Instance; if (((instance != null) ? instance.addressDirectory : null) == null) { Plugin.LogSource.LogWarning((object)"City Hall generation fix skipped because addresses are not ready."); return; } CompanyPreset val = null; int num = 0; for (int i = 0; i < instance.addressDirectory.Count; i++) { NewAddress val2 = instance.addressDirectory[i]; if (IsCityHallCompanyAddress(val2)) { num++; if (val == null) { val = val2.addressPreset.company; } } } if ((SoCustomComparison)(object)val == (SoCustomComparison)null || num == 0) { Plugin.LogSource.LogInfo((object)"City Hall generation fix found no eligible City Hall company addresses."); return; } RememberOriginalLimits(val); int num2 = Math.Max(originalMinimum, num); int num3 = Math.Max(originalMaximum, num); val.minimumNumber = num2; val.maximumNumber = num3; ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(92, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("City Hall generation fix found "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" eligible addresses; "); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ControlRoomScanner.PresetName((Object)(object)val)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' company limits "); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("changed from "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(originalMinimum); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".."); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(originalMaximum); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" to "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".."); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num3); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } logSource.LogInfo(val3); } internal static void LogResult() { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown CityData instance = CityData.Instance; if (((instance != null) ? instance.addressDirectory : null) == null) { return; } HashSet<int> hashSet = new HashSet<int>(); int num = 0; int num2 = 0; for (int i = 0; i < instance.addressDirectory.Count; i++) { NewAddress val = instance.addressDirectory[i]; object obj; if (val == null) { obj = null; } else { NewBuilding building = ((NewGameLocation)val).building; obj = ((building != null) ? building.preset : null); } if ((SoCustomComparison)obj != (SoCustomComparison)null && ControlRoomScanner.PresetName((Object)(object)((NewGameLocation)val).building.preset).Equals("CityHall", StringComparison.OrdinalIgnoreCase)) { hashSet.Add(((NewGameLocation)val).building.buildingID); } if (IsCityHallCompanyAddress(val)) { num++; Company company = val.company; if ((SoCustomComparison)(object)((company != null) ? company.preset : null) != (SoCustomComparison)null && ControlRoomScanner.PresetName((Object)(object)company.preset).Equals("CityHall", StringComparison.OrdinalIgnoreCase)) { num2++; } } } string text = ((num > 0 && num2 == num) ? "OK" : "BROKEN"); ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(83, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] City Hall generation: buildings="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(hashSet.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("eligibleCompanyAddresses="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("assignedCompanies="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } logSource.LogInfo(val2); } private static bool IsCityHallCompanyAddress(NewAddress? address) { object obj; if (address == null) { obj = null; } else { NewBuilding building = ((NewGameLocation)address).building; obj = ((building != null) ? building.preset : null); } if ((SoCustomComparison)obj != (SoCustomComparison)null && ControlRoomScanner.PresetName((Object)(object)((NewGameLocation)address).building.preset).Equals("CityHall", StringComparison.OrdinalIgnoreCase)) { AddressPreset addressPreset = address.addressPreset; if ((SoCustomComparison)(object)((addressPreset != null) ? addressPreset.company : null) != (SoCustomComparison)null) { return ControlRoomScanner.PresetName((Object)(object)address.addressPreset.company).Equals("CityHall", StringComparison.OrdinalIgnoreCase); } } return false; } private static void RememberOriginalLimits(CompanyPreset preset) { if (!((SoCustomComparison)(object)rememberedPreset == (SoCustomComparison)(object)preset)) { rememberedPreset = preset; originalMinimum = preset.minimumNumber; originalMaximum = preset.maximumNumber; } } } [HarmonyPatch(typeof(CityConstructor), "GenerateNewCity")] internal static class ControlRoomCountPatch { [HarmonyPrefix] private static void Prefix() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown try { ControlRoomCountFix.Apply(); } catch (Exception ex) { ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not raise control room counts: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logSource.LogError(val); } } } internal static class ControlRoomCountFix { internal static void Apply() { //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) HashSet<string> hashSet = (from name in Plugin.GuaranteedControlRoomBuildings.Value.Split(',') select name.Trim() into name where name.Length > 0 select name).ToHashSet<string>(StringComparer.OrdinalIgnoreCase); if (hashSet.Count == 0) { return; } int num = 0; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val; foreach (BuildingPreset item in Resources.FindObjectsOfTypeAll<BuildingPreset>()) { if ((SoCustomComparison)(object)item == (SoCustomComparison)null || !hashSet.Contains(((Object)item).name)) { continue; } Vector2 controlRoomRange = item.controlRoomRange; if (!(controlRoomRange.x >= 1f) || !(controlRoomRange.y >= 1f)) { item.controlRoomRange = new Vector2(Mathf.Max(1f, controlRoomRange.x), Mathf.Max(1f, controlRoomRange.y)); num++; ManualLogSource logSource = Plugin.LogSource; val = new BepInExInfoLogInterpolatedStringHandler(26, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Control rooms for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)item).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(controlRoomRange.x); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("-"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(controlRoomRange.y); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(item.controlRoomRange.x); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("-"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(item.controlRoomRange.y); } logSource.LogInfo(val); } } ManualLogSource logSource2 = Plugin.LogSource; val = new BepInExInfoLogInterpolatedStringHandler(65, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Guaranteed control rooms: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" building types raised for the new city"); } logSource2.LogInfo(val); } } [HarmonyPatch(typeof(InteriorCreator), "StartLoading")] internal static class InteriorGenerationPatch { [HarmonyPrefix] private static void Prefix() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown if (Plugin.DumpInteractablePipeline.Value) { InteractableCreationTrace.Phase = "interior-start"; VanillaInteractableApiProbe.LogCityConstructorState(); Plugin.LogSource.LogInfo((object)"[probe] InteriorCreator.StartLoading prefix; this is generateInteriors. Watch for later LoadObjects / CreateInteractables traces."); } if (!Plugin.EnableGenerationFix.Value) { return; } try { ControlRoomGenerationFix.Apply(); } catch (Exception ex) { ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(52, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not prepare ControlRoom furniture generation: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logSource.LogError(val); } } [HarmonyPostfix] private static void Postfix() { if (Plugin.DumpInteractablePipeline.Value) { InteractableCreationTrace.Phase = "interior-end"; Plugin.LogSource.LogInfo((object)"[probe] InteriorCreator.StartLoading postfix; interiors finished. The next vanilla object-load stage should follow if this is a new city."); VanillaInteractableApiProbe.LogCityConstructorState(); } } } internal static class ControlRoomGenerationFix { private const string ControlRoomClassName = "ControlRoom"; internal static void Apply() { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown Toolbox instance = Toolbox.Instance; if (((instance != null) ? instance.allFurnitureClusters : null) == null) { Plugin.LogSource.LogWarning((object)"ControlRoom generation fix skipped because furniture presets are not ready."); return; } int num = 0; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val5; for (int i = 0; i < Toolbox.Instance.allFurnitureClusters.Count; i++) { FurnitureCluster val = Toolbox.Instance.allFurnitureClusters[i]; if ((SoCustomComparison)(object)val == (SoCustomComparison)null || !val.skipIfNoAddressInhabitants || !TryGetControlRoomClass(val, out RoomClassPreset controlRoomClass) || (SoCustomComparison)(object)controlRoomClass == (SoCustomComparison)null) { continue; } FurnitureCluster val2 = val; if (val2.dontSkipNoInhabitantsIfIn == null) { List<RoomClassPreset> val3 = (val2.dontSkipNoInhabitantsIfIn = new List<RoomClassPreset>()); } if (!ContainsRoomClass(val.dontSkipNoInhabitantsIfIn, "ControlRoom")) { val.dontSkipNoInhabitantsIfIn.Add(controlRoomClass); num++; ManualLogSource logSource = Plugin.LogSource; val5 = new BepInExInfoLogInterpolatedStringHandler(46, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("ControlRoom generation fix enabled cluster "); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("'"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ControlRoomScanner.PresetName((Object)(object)val)); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("'."); } logSource.LogInfo(val5); } } ManualLogSource logSource2 = Plugin.LogSource; val5 = new BepInExInfoLogInterpolatedStringHandler(56, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("ControlRoom generation fix prepared "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" furniture clusters."); } logSource2.LogInfo(val5); } private static bool TryGetControlRoomClass(FurnitureCluster cluster, out RoomClassPreset? controlRoomClass) { controlRoomClass = null; if (cluster.allowedRoomFilters == null) { return false; } for (int i = 0; i < cluster.allowedRoomFilters.Count; i++) { RoomTypeFilter obj = cluster.allowedRoomFilters[i]; List<RoomClassPreset> val = ((obj != null) ? obj.roomClasses : null); if (val == null) { continue; } for (int j = 0; j < val.Count; j++) { RoomClassPreset val2 = val[j]; if ((SoCustomComparison)(object)val2 != (SoCustomComparison)null && ControlRoomScanner.PresetName((Object)(object)val2).Equals("ControlRoom", StringComparison.OrdinalIgnoreCase)) { controlRoomClass = val2; return true; } } } return false; } private static bool ContainsRoomClass(List<RoomClassPreset> classes, string className) { for (int i = 0; i < classes.Count; i++) { RoomClassPreset val = classes[i]; if ((SoCustomComparison)(object)val != (SoCustomComparison)null && ControlRoomScanner.PresetName((Object)(object)val).Equals(className, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } } internal static class ControlRoomScanner { private static readonly string[] EssentialNameParts = new string[6] { "crunch", "computer", "blueprint", "buildingplan", "residentfile", "residentrecord" }; internal static void Run() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown if (!IsCityReady()) { Plugin.LogSource.LogWarning((object)"Skipped control-room scan because city loading or pre-simulation is still active."); return; } int num = 0; int num2 = 0; RoomConfiguration val = null; Enumerator<int, NewRoom> enumerator = CityData.Instance.roomDictionary.GetEnumerator(); while (enumerator.MoveNext()) { NewRoom value = enumerator.Current.Value; if (!((SoCustomComparison)(object)((value != null) ? value.preset : null) == (SoCustomComparison)null) && !(PresetName((Object)(object)value.preset) != "ControlRoom")) { num++; if (val == null) { val = value.preset; } if (LogRoom(value)) { num2++; } } } ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(60, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Control-room scan complete: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" rooms lack essential contents."); } logSource.LogInfo(val2); if (Plugin.DumpEligiblePresets.Value && (SoCustomComparison)(object)val != (SoCustomComparison)null) { VanillaPresetScanner.Dump(val); } } private static bool IsCityReady() { if ((Object)(object)CityData.Instance != (Object)null && (Object)(object)CityConstructor.Instance != (Object)null && !CityConstructor.Instance.loadingOperationActive && !CityConstructor.Instance.preSimActive && CityConstructor.Instance.isLoaded && (Object)(object)SessionData.Instance != (Object)null) { return SessionData.Instance.startedGame; } return false; } private static bool LogRoom(NewRoom room) { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown List<string> list = new List<string>(); List<string> list2 = new List<string>(); bool hasMicroCruncher = false; bool hasBlueprints = false; if (room.individualFurniture != null) { for (int i = 0; i < room.individualFurniture.Count; i++) { FurnitureLocation val = room.individualFurniture[i]; if (!((SoCustomComparison)(object)((val != null) ? val.furniture : null) == (SoCustomComparison)null)) { string item = PresetName((Object)(object)val.furniture); list.Add(item); AddInteractables(val.integratedInteractables, list2, ref hasMicroCruncher, ref hasBlueprints); AddInteractables(val.spawnedInteractables, list2, ref hasMicroCruncher, ref hasBlueprints); } } } if (room.worldObjects != null) { Enumerator<Interactable> enumerator = room.worldObjects.GetEnumerator(); while (enumerator.MoveNext()) { Interactable current = enumerator.Current; if (!((SoCustomComparison)(object)((current != null) ? current.preset : null) == (SoCustomComparison)null)) { list2.Add(PresetName((Object)(object)current.preset)); } } } bool num = hasMicroCruncher && hasBlueprints; string text = (num ? "OK" : "BROKEN"); ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(57, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] ControlRoom roomID="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" name='"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(room.name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("nodes="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(room.nodes?.Count ?? 0); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("furniture="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(list.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" objects="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(list2.Count); } logSource.LogInfo(val2); LogScanCompany(room); ManualLogSource logSource2 = Plugin.LogSource; val2 = new BepInExInfoLogInterpolatedStringHandler(13, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" furniture: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(JoinNames(list)); } logSource2.LogInfo(val2); ManualLogSource logSource3 = Plugin.LogSource; val2 = new BepInExInfoLogInterpolatedStringHandler(11, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" objects: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(JoinNames(list2)); } logSource3.LogInfo(val2); return !num; } private static void LogScanCompany(NewRoom room) { //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown string text = "null"; try { text = room.roomID.ToString(); } catch { text = "null"; } string text2 = "null"; string text3 = "null"; string text4 = "null"; string text5 = "null"; NewAddress val = null; try { val = (((Object)(object)room.gameLocation != (Object)null) ? ((Il2CppObjectBase)room.gameLocation).TryCast<NewAddress>() : null); } catch { val = null; } Company val2 = null; if ((Object)(object)val != (Object)null) { try { val2 = val.company; } catch { val2 = null; } } if (val2 != null) { try { text2 = val2.name ?? "null"; } catch { text2 = "null"; } try { text3 = val2.companyID.ToString(); } catch { text3 = "null"; } List<Occupation> val3 = null; try { val3 = val2.companyRoster; } catch { val3 = null; } if (val3 != null) { try { text4 = val3.Count.ToString(); } catch { text4 = "null"; } } try { text5 = val2.GetNumberOfFilledJobs().ToString(); } catch { text5 = "null"; } } ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(40, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[scan] room="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" company="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text2); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" id="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text3); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("posts="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text4); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" filled="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text5); } logSource.LogInfo(val4); } private static void AddInteractables(List<Interactable>? interactables, List<string> names, ref bool hasMicroCruncher, ref bool hasBlueprints) { if (interactables == null) { return; } for (int i = 0; i < interactables.Count; i++) { Interactable val = interactables[i]; if (!((SoCustomComparison)(object)((val != null) ? val.preset : null) == (SoCustomComparison)null)) { string text = PresetName((Object)(object)val.preset); names.Add(text); if (text == "MicroCruncher") { hasMicroCruncher = true; } if (text == "Blueprints") { hasBlueprints = true; } } } } private static bool IsEssential(string name) { string text = name.Replace("_", "").Replace(" ", ""); for (int i = 0; i < EssentialNameParts.Length; i++) { if (text.IndexOf(EssentialNameParts[i], StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } private static string JoinNames(List<string> names) { if (names.Count == 0) { return "<none>"; } names.Sort(StringComparer.OrdinalIgnoreCase); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < names.Count; i++) { if (i > 0) { stringBuilder.Append(", "); } stringBuilder.Append(names[i]); } return stringBuilder.ToString(); } internal static string PresetName(Object preset) { if (!(preset != (Object)null)) { return "<null>"; } return preset.name ?? "<unnamed>"; } } internal static class ExistingCityRepair { private static readonly string[] RequiredClusterNames = new string[3] { "DeskAgainstWall", "Shelf", "WallClock" }; private static readonly string[] FilingCabinetClusterNames = new string[2] { "FilingCabinetTall", "FilingCabinetShort" }; private static bool skipFill; internal static void Run() { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown if ((Object)(object)GenerationController.Instance == (Object)null || (Object)(object)Toolbox.Instance == (Object)null) { Plugin.LogSource.LogWarning((object)"Existing-city repair skipped because generation systems are not ready."); return; } ControlRoomGenerationFix.Apply(); int num = 0; Enumerator<int, NewRoom> enumerator = CityData.Instance.roomDictionary.GetEnumerator(); while (enumerator.MoveNext()) { NewRoom value = enumerator.Current.Value; if ((SoCustomComparison)(object)((value != null) ? value.preset : null) == (SoCustomComparison)null || !ControlRoomScanner.PresetName((Object)(object)value.preset).Equals("ControlRoom", StringComparison.OrdinalIgnoreCase) || HasMicroCruncher(value)) { continue; } CreateMissingDeskInteractables(value); int num2 = 0; for (int i = 0; i < RequiredClusterNames.Length; i++) { if (TryAddMissingCluster(value, RequiredClusterNames[i])) { num2++; } } if (TryAddOneFilingCabinet(value)) { num2++; } if (num2 > 0) { num++; } } ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(48, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Existing-city ControlRoom repair changed "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" rooms."); } logSource.LogInfo(val); } private static bool TryAddOneFilingCabinet(NewRoom room) { if (HasAnyFilingCabinet(room)) { return false; } for (int i = 0; i < FilingCabinetClusterNames.Length; i++) { if (TryAddMissingCluster(room, FilingCabinetClusterNames[i])) { return true; } } return false; } private static bool HasAnyFilingCabinet(NewRoom room) { for (int i = 0; i < FilingCabinetClusterNames.Length; i++) { if (HasCluster(room, FilingCabinetClusterNames[i])) { return true; } } return false; } internal static bool AddExtraCluster(NewRoom room, string clusterName) { skipFill = true; try { return TryAddMissingCluster(room, clusterName, allowDuplicate: true); } finally { skipFill = false; } } private static bool TryAddMissingCluster(NewRoom room, string clusterName, bool allowDuplicate = false) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown if (!allowDuplicate && HasCluster(room, clusterName)) { return false; } FurnitureCluster val = FindCluster(clusterName); bool flag = default(bool); if ((SoCustomComparison)(object)val == (SoCustomComparison)null) { ManualLogSource logSource = Plugin.LogSource; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(46, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Cannot repair room "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": cluster '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(clusterName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' was not found."); } logSource.LogWarning(val2); return false; } bool flag2 = false; FurnitureClusterLocation bestFurnitureClusterLocation = GenerationController.Instance.GetBestFurnitureClusterLocation(room, val, false, false); if (bestFurnitureClusterLocation == null && clusterName == "DeskAgainstWall") { flag2 = true; bestFurnitureClusterLocation = GenerationController.Instance.GetBestFurnitureClusterLocation(room, val, false, true); } if (bestFurnitureClusterLocation == null) { ManualLogSource logSource2 = Plugin.LogSource; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(38, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("No valid '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(clusterName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' placement in ControlRoom "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } logSource2.LogWarning(val2); return false; } LogChosenFurniture(room, clusterName, bestFurnitureClusterLocation, "before-prefer"); if (clusterName == "DeskAgainstWall") { PreferDeskPresetWithMicroCruncher(bestFurnitureClusterLocation); } ManualLogSource logSource3 = Plugin.LogSource; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(62, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[repair-before-add] ControlRoom "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" cluster='"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(clusterName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' "); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("ignoreLimitations="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>(flag2); } logSource3.LogInfo(val3); room.AddFurniture(bestFurnitureClusterLocation, true, true, true, flag2, (DesignStylePreset)null); CreateInteractables(room, bestFurnitureClusterLocation); LogChosenFurniture(room, clusterName, bestFurnitureClusterLocation, "after-add"); ManualLogSource logSource4 = Plugin.LogSource; val3 = new BepInExInfoLogInterpolatedStringHandler(25, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Added '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(clusterName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' to ControlRoom "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(flag2 ? " using fallback placement" : ""); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } logSource4.LogInfo(val3); return true; } private static void CreateInteractables(NewRoom room, FurnitureClusterLocation clusterLocation) { if (clusterLocation.clusterList == null) { return; } NewGameLocation gameLocation = room.gameLocation; NewAddress address = (NewAddress)(object)((gameLocation is NewAddress) ? gameLocation : null); for (int i = 0; i < clusterLocation.clusterList.Count; i++) { FurnitureLocation val = clusterLocation.clusterList[i]; if (val != null) { CreateInteractables(val, address); if (!skipFill) { SpawnedLayerFill.FillSpawnedLayer(val, room.roomID); } } } } private static void CreateMissingDeskInteractables(NewRoom room) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown if (room.individualFurniture == null) { return; } NewGameLocation gameLocation = room.gameLocation; NewAddress address = (NewAddress)(object)((gameLocation is NewAddress) ? gameLocation : null); bool flag = default(bool); for (int i = 0; i < room.individualFurniture.Count; i++) { FurnitureLocation val = room.individualFurniture[i]; object obj; if (val == null) { obj = null; } else { FurnitureClusterLocation cluster = val.cluster; obj = ((cluster != null) ? cluster.cluster : null); } if (!((SoCustomComparison)obj == (SoCustomComparison)null) && ControlRoomScanner.PresetName((Object)(object)val.cluster.cluster).Equals("DeskAgainstWall", StringComparison.OrdinalIgnoreCase) && !ContainsMicroCruncher(val.integratedInteractables) && (val.integratedInteractables?.Count ?? 0) <= 0) { Plugin.LogSource.LogInfo((object)($"[repair-before-existing-desk] ControlRoom {room.roomID} " + FurnitureInteractableAudit.Describe(val))); CreateInteractables(val, address); SpawnedLayerFill.FillSpawnedLayer(val, room.roomID); ManualLogSource logSource = Plugin.LogSource; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(51, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Created missing desk interactables in ControlRoom "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } logSource.LogInfo(val2); } } } private static void CreateInteractables(FurnitureLocation furniture, NewAddress? address) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown if ((Object)(object)address != (Object)null) { furniture.AssignOwner(address, false); } ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[repair-before-create] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(FurnitureInteractableAudit.Describe(furniture)); } logSource.LogInfo(val); furniture.CreateInteractables(); furniture.UpdateIntegratedObjectOwnership(); furniture.SpawnObject(true); ManualLogSource logSource2 = Plugin.LogSource; val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[repair-after-create] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(FurnitureInteractableAudit.Describe(furniture)); } logSource2.LogInfo(val); if (Plugin.TryAlternateInteractableOrdering.Value && !FurnitureInteractableAudit.HasIntegratedInstances(furniture)) { TryAlternateInteractableOrdering(furniture); } } private static void TryAlternateInteractableOrdering(FurnitureLocation furniture) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown Plugin.LogSource.LogInfo((object)"[repair-order-probe] current AssignOwner -> CreateInteractables -> UpdateIntegratedObjectOwnership -> SpawnObject left integrated=0; trying SpawnObject -> CreateInteractables."); furniture.SpawnObject(true); furniture.CreateInteractables(); furniture.UpdateIntegratedObjectOwnership(); ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[repair-after-spawn-first] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(FurnitureInteractableAudit.Describe(furniture)); } logSource.LogInfo(val); if (FurnitureInteractableAudit.HasIntegratedInstances(furniture)) { return; } int value = FurnitureInteractableAudit.PresetDefinitionCount(furniture.furniture); Plugin.LogSource.LogInfo((object)("[repair-order-probe] spawn-first still integrated=0; " + $"presetIntegrated={value}. Invoking parameterless " + "FurnitureLocation methods whose names mention interactables.")); foreach (MethodInfo item in VanillaInteractableApiProbe.ParameterlessInteractableMethods(furniture)) { if (item.Name.Equals("CreateInteractables", StringComparison.Ordinal) || item.Name.Equals("SpawnObject", StringComparison.Ordinal) || item.Name.Equals("UpdateIntegratedObjectOwnership", StringComparison.Ordinal)) { continue; } try { InteractableCreationTrace.Phase = "repair-invoke-" + item.Name; item.Invoke(furniture, Array.Empty<object>()); Plugin.LogSource.LogInfo((object)("[repair-after-invoke " + item.Name + "] " + FurnitureInteractableAudit.Describe(furniture))); } catch (Exception ex) { ManualLogSource logSource2 = Plugin.LogSource; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[repair-order-probe] "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(item.Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } logSource2.LogWarning(val2); } if (FurnitureInteractableAudit.HasIntegratedInstances(furniture)) { ManualLogSource logSource3 = Plugin.LogSource; val = new BepInExInfoLogInterpolatedStringHandler(56, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[repair-order-probe] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(item.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" produced integrated interactables."); } logSource3.LogInfo(val); return; } } InteractableCreationTrace.Phase = "repair"; } private static void LogChosenFurniture(NewRoom room, string clusterName, FurnitureClusterLocation location, string phase) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown if (location.clusterList == null) { Plugin.LogSource.LogInfo((object)($"[repair-chosen {phase}] ControlRoom {room.roomID} cluster='{clusterName}' " + "clusterList=<none>")); return; } ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(48, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[repair-chosen "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(phase); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ControlRoom "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" cluster='"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(clusterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("pieces="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(location.clusterList.Count); } logSource.LogInfo(val); for (int i = 0; i < location.clusterList.Count; i++) { FurnitureLocation val2 = location.clusterList[i]; if (val2 != null) { ManualLogSource logSource2 = Plugin.LogSource; val = new BepInExInfoLogInterpolatedStringHandler(19, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[repair-chosen "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(phase); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(FurnitureInteractableAudit.Describe(val2)); } logSource2.LogInfo(val); if (clusterName == "DeskAgainstWall" && (SoCustomComparison)(object)val2.furniture != (SoCustomComparison)null && !FurnitureInteractableAudit.PresetDefines(val2.furniture, "MicroCruncher")) { Plugin.LogSource.LogWarning((object)($"[repair-chosen {phase}] DeskAgainstWall selected furniture '{ControlRoomScanner.PresetName((Object)(object)val2.furniture)}' " + "with no MicroCruncher preset definition.")); } } } } private static void PreferDeskPresetWithMicroCruncher(FurnitureClusterLocation location) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown if (!Plugin.PreferWorkingDeskPreset.Value || location.clusterList == null) { return; } FurniturePreset val = WorkingReferenceAudit.FindDeskPresetWithMicroCruncher(); if ((SoCustomComparison)(object)val == (SoCustomComparison)null) { Plugin.LogSource.LogWarning((object)"[repair-prefer] no Toolbox furniture preset defines a MicroCruncher."); return; } Plugin.LogSource.LogInfo((object)("[repair-prefer] candidate " + FurnitureInteractableAudit.DescribeFurniturePreset(val))); bool flag = default(bool); for (int i = 0; i < location.clusterList.Count; i++) { FurnitureLocation val2 = location.clusterList[i]; if (val2 != null && !FurnitureInteractableAudit.PresetDefines(val2.furniture, "MicroCruncher")) { string text = (((SoCustomComparison)(object)val2.furniture != (SoCustomComparison)null) ? ControlRoomScanner.PresetName((Object)(object)val2.furniture) : "<null>"); val2.furniture = val; ManualLogSource logSource = Plugin.LogSource; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(66, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[repair-prefer] replaced furniture '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' with "); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ControlRoomScanner.PresetName((Object)(object)val)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' before AddFurniture."); } logSource.LogInfo(val3); } } } private static FurnitureCluster? FindCluster(string name) { for (int i = 0; i < Toolbox.Instance.allFurnitureClusters.Count; i++) { FurnitureCluster val = Toolbox.Instance.allFurnitureClusters[i]; if ((SoCustomComparison)(object)val != (SoCustomComparison)null && ControlRoomScanner.PresetName((Object)(object)val).Equals(name, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } private static bool HasCluster(NewRoom room, string clusterName) { if (room.individualFurniture == null) { return false; } for (int i = 0; i < room.individualFurniture.Count; i++) { FurnitureLocation obj = room.individualFurniture[i]; object obj2; if (obj == null) { obj2 = null; } else { FurnitureClusterLocation cluster = obj.cluster; obj2 = ((cluster != null) ? cluster.cluster : null); } FurnitureCluster val = (FurnitureCluster)obj2; if ((SoCustomComparison)(object)val != (SoCustomComparison)null && ControlRoomScanner.PresetName((Object)(object)val).Equals(clusterName, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private static bool HasMicroCruncher(NewRoom room) { if (room.individualFurniture == null) { return false; } for (int i = 0; i < room.individualFurniture.Count; i++) { FurnitureLocation val = room.individualFurniture[i]; if (val != null && (ContainsMicroCruncher(val.integratedInteractables) || ContainsMicroCruncher(val.spawnedInteractables))) { return true; } } return false; } private static bool ContainsMicroCruncher(List<Interactable>? interactables) { if (interactables == null) { return false; } for (int i = 0; i < interactables.Count; i++) { Interactable val = interactables[i]; if ((SoCustomComparison)(object)((val != null) ? val.preset : null) != (SoCustomComparison)null && ControlRoomScanner.PresetName((Object)(object)val.preset).Equals("MicroCruncher", StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } } internal static class FurnitureInteractableAudit { internal static void LogControlRooms(string phase) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown CityData instance = CityData.Instance; bool flag = default(bool); if (((instance != null) ? instance.roomDictionary : null) == null) { ManualLogSource logSource = Plugin.LogSource; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(60, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Interactable audit '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(phase); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' skipped because the city is not ready."); } logSource.LogWarning(val); return; } int num = 0; int num2 = 0; Enumerator<int, NewRoom> enumerator = CityData.Instance.roomDictionary.GetEnumerator(); ManualLogSource logSource2 = Plugin.LogSource; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("=== Interactable audit "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(phase); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ==="); } logSource2.LogInfo(val2); while (enumerator.MoveNext()) { NewRoom value = enumerator.Current.Value; if (!((SoCustomComparison)(object)((value != null) ? value.preset : null) == (SoCustomComparison)null) && ControlRoomScanner.PresetName((Object)(object)value.preset).Equals("ControlRoom", StringComparison.OrdinalIgnoreCase)) { num++; num2 += LogRoom(value, phase); } } ManualLogSource logSource3 = Plugin.LogSource; val2 = new BepInExInfoLogInterpolatedStringHandler(56, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("=== Interactable audit "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(phase); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" complete: rooms="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("furniture="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ==="); } logSource3.LogInfo(val2); } internal static int LogRoom(NewRoom room, string phase) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val; if (room.individualFurniture == null) { ManualLogSource logSource = Plugin.LogSource; val = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(phase); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ControlRoom roomID="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" furniture=<none>"); } logSource.LogInfo(val); return 0; } ManualLogSource logSource2 = Plugin.LogSource; val = new BepInExInfoLogInterpolatedStringHandler(33, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(phase); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ControlRoom roomID="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("furniture="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(room.individualFurniture.Count); } logSource2.LogInfo(val); for (int i = 0; i < room.individualFurniture.Count; i++) { FurnitureLocation val2 = room.individualFurniture[i]; if (val2 != null) { ManualLogSource logSource3 = Plugin.LogSource; val = new BepInExInfoLogInterpolatedStringHandler(5, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(phase); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Describe(val2)); } logSource3.LogInfo(val); } } return room.individualFurniture.Count; } internal static string Describe(FurnitureLocation location) { string value = (((SoCustomComparison)(object)location.furniture != (SoCustomComparison)null) ? ControlRoomScanner.PresetName((Object)(object)location.furniture) : "<null>"); FurnitureClusterLocation cluster = location.cluster; string value2 = (((SoCustomComparison)(object)((cluster != null) ? cluster.cluster : null) != (SoCustomComparison)null) ? ControlRoomScanner.PresetName((Object)(object)location.cluster.cluster) : "<none>"); return $"id={ReadId(location)} furniture='{value}' cluster='{value2}' presetIntegrated={DescribePresetDefinitions(location.furniture)} locationIntegrated={DescribeInteractables(location.integratedInteractables)} locationSpawned={DescribeInteractables(location.spawnedInteractables)}"; } internal static bool HasIntegratedInstances(FurnitureLocation location) { return (location.integratedInteractables?.Count ?? 0) > 0; } internal static int PresetDefinitionCount(object? furniture) { return CountIl2CppList(ReadMember(furniture, "integratedInteractables")); } internal static bool PresetDefines(object? furniture, string namePart) { List<string> list = NamesFromUnknownList(ReadMember(furniture, "integratedInteractables")); for (int i = 0; i < list.Count; i++) { if (list[i].IndexOf(namePart, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } internal static string DescribeFurniturePreset(object? furniture) { Object val = (Object)((furniture is Object) ? furniture : null); string text = ((val != null) ? ControlRoomScanner.PresetName(val) : "<null>"); return "furniture='" + text + "' presetIntegrated=" + DescribePresetDefinitions(furniture); } internal static string DescribePresetDefinitions(object? furniture) { if (furniture == null) { return "0[]"; } List<string> list = NamesFromUnknownList(ReadMember(furniture, "integratedInteractables")); int value = CountIl2CppList(ReadMember(furniture, "subObjects")); return $"{list.Count}[{JoinNames(list)}] subObjects={value}"; } private static string DescribeInteractables(List<Interactable>? interactables) { List<string> list = new List<string>(); if (interactables != null) { for (int i = 0; i < interactables.Count; i++) { Interactable val = interactables[i]; list.Add(((SoCustomComparison)(object)((val != null) ? val.preset : null) != (SoCustomComparison)null) ? ControlRoomScanner.PresetName((Object)(object)val.preset) : "<null>"); } } return $"{list.Count}[{JoinNames(list)}]"; } private static List<string> NamesFromUnknownList(object? list) { List<string> list2 = new List<string>(); int num = CountIl2CppList(list); for (int i = 0; i < num; i++) { list2.Add(NameFromUnknownItem(IndexIl2CppList(list, i))); } return list2; } private static string NameFromUnknownItem(object? item) { if (item == null) { return "<null>"; } object? obj = ReadMember(item, "preset"); Object val = (Object)((obj is Object) ? obj : null); if (val != null) { return ControlRoomScanner.PresetName(val); } Object val2 = (Object)((item is Object) ? item : null); if (val2 != null) { return ControlRoomScanner.PresetName(val2); } return item.GetType().Name; } private static object? ReadMember(object? target, string name) { if (target == null) { return null; } Type type = target.GetType(); PropertyInfo property = type.GetProperty(name); if (property != null) { return property.GetValue(target); } return type.GetField(name)?.GetValue(target); } private static int CountIl2CppList(object? list) { if (list == null) { return 0; } object obj = ReadMember(list, "Count"); if (obj is int) { return (int)obj; } return 0; } private static object? IndexIl2CppList(object? list, int index) { return list?.GetType().GetProperty("Item")?.GetValue(list, new object[1] { index }); } private static string ReadId(FurnitureLocation location) { string[] array = new string[4] { "id", "furnitureID", "furnID", "idnt" }; foreach (string text in array) { object obj = ReadMember(location, text); if (obj != null) { return $"{text}={obj}"; } } return "id=<unknown>"; } private static string JoinNames(List<string> names) { if (names.Count == 0) { return ""; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < names.Count; i++) { if (i > 0) { stringBuilder.Append(','); } stringBuilder.Append(names[i]); } return stringBuilder.ToString(); } } [HarmonyPatch(typeof(MurderController), "OnStartGame")] internal static class GameStartedPatch { [HarmonyPostfix] private static void Postfix() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown if (Plugin.DumpInteractablePipeline.Value) { InteractableCreationTrace.Phase = "before-repair"; VanillaInteractableApiProbe.LogCityConstructorState(); WorkingReferenceAudit.LogReferences(); FurnitureInteractableAudit.LogControlRooms("before-repair"); } bool flag = default(bool); if (Plugin.RepairExistingControlRooms.Value) { try { InteractableCreationTrace.Phase = "repair"; ExistingCityRepair.Run(); } catch (Exception ex) { ManualLogSource logSource = Plugin.LogSource; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Existing-city ControlRoom repair failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logSource.LogError(val); } } if (Plugin.HireForVacantControlRooms.Value) { try { VacantPostHiring.Run(); } catch (Exception ex2) { ManualLogSource logSource2 = Plugin.LogSource; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(35, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Vacant control-room hiring failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex2); } logSource2.LogError(val); } } if (Plugin.DumpInteractablePipeline.Value) { InteractableCreationTrace.Phase = "after-repair"; FurnitureInteractableAudit.LogControlRooms("after-repair"); } try { InteractableCreationTrace.Phase = "roster"; if (Plugin.FileEveryResident.Value) { RosterSplit.Run(); } } catch (Exception ex3) { ManualLogSource logSource3 = Plugin.LogSource; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ResidentRoster one-drawer limit failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex3); } logSource3.LogError(val); } try { InteractableCreationTrace.Phase = "scan"; ControlRoomScanner.Run(); CityHallGenerationFix.LogResult(); } catch (Exception ex4) { ManualLogSource logSource4 = Plugin.LogSource; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Post-generation diagnostic pass failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex4); } logSource4.LogError(val); } InteractableCreationTrace.Phase = "post-start"; } } internal static class InteractableCreationTrace { internal static string Phase { get; set; } = "startup"; public static void Postfix(object __instance, MethodBase __originalMethod) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown if (Plugin.DumpInteractablePipeline.Value && !(__originalMethod == null)) { string text = __originalMethod.DeclaringType?.Name ?? "<unknown>"; FurnitureLocation val = (FurnitureLocation)((__instance is FurnitureLocation) ? __instance : null); string text2 = ((val != null) ? FurnitureInteractableAudit.Describe(val) : (__instance?.ToString() ?? "<static>")); ManualLogSource logSource = Plugin.LogSource; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(17, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[trace] "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(__originalMethod.Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" phase="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Phase); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text2); } logSource.LogInfo(val2); } } } internal static class ManualCabinetPlacement { private const string Furniture = "FilingCabinet"; private static FurniturePreset? preset; private static Dictionary<Vector2, int>? angleForWall; internal static bool TryPlaceTall(NewRoom room) { //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Expected O, but got Unknown //IL_02f0: 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_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) if (((room != null) ? room.nodes : null) == null || !Learn()) { return false; } HashSet<long> hashSet = new HashSet<long>(); HashSet<(long, Vector2)> hashSet2 = new HashSet<(long, Vector2)>(); List<FurnitureLocation> individualFurniture = room.individualFurniture; int num = 0; while (individualFurniture != null && num < individualFurniture.Count) { FurnitureLocation val = individualFurniture[num]; object obj; if (val == null) { obj = null; } else { FurniturePreset furniture = val.furniture; obj = ((furniture != null) ? ((Object)furniture).name : null); } if (obj == null) { obj = ""; } string text = (string)obj; if (val != null && !text.StartsWith("Static") && !text.StartsWith("LeaningPoint")) { bool flag = text.StartsWith("Wall") || text.StartsWith("Shelf"); List<NewNode> coversNodes = val.coversNodes; int num2 = 0; while (coversNodes != null && num2 < coversNodes.Count) { if (coversNodes[num2] != null) { if (flag) { foreach (KeyValuePair<Vector2, int> item in angleForWall) { if (item.Value == val.angle) { hashSet2.Add((((Il2CppObjectBase)coversNodes[num2]).Pointer.ToInt64(), item.Key)); } } } else { hashSet.Add(((Il2CppObjectBase)coversNodes[num2]).Pointer.ToInt64()); } } num2++; } } num++; } HashSet<long> hashSet3 = new HashSet<long>(); List<NewNode> list = new List<NewNode>(); Enumerator<NewNode> enumerator2 = room.nodes.GetEnumerator(); while (enumerator2.MoveNext()) { NewNode current2 = enumerator2.Current; if (current2 == null) { continue; } list.Add(current2); Dictionary<NewNode, NodeAccess> accessToOtherNodes = current2.accessToOtherNodes; if (accessToOtherNodes == null) { continue; } Enumerator<NewNode, NodeAccess> enumerator3 = accessToOtherNodes.GetEnumerator(); while (enumerator3.MoveNext()) { NodeAccess value = enumerator3.Current.Value; if (!((Object)(object)((value != null) ? value.door : null) == (Object)null)) { hashSet3.Add(((Il2CppObjectBase)current2).Pointer.ToInt64()); if (enumerator3.Current.Key != null) { hashSet3.Add(((Il2CppObjectBase)enumerator3.Current.Key).Pointer.ToInt64()); } } } } foreach (NewNode item2 in list) { long num3 = ((Il2CppObjectBase)item2).Pointer.ToInt64(); if ((hashSet.Contains(num3) ? "furniture" : (hashSet3.Contains(num3) ? "door" : (item2.isObstacle ? "obstacle" : (item2.noAccess ? "no access" : ((item2.wallDict == null || item2.wallDict.Count == 0) ? "no wall" : null))))) != null) { continue; } Enumerator<Vector2, NewWall> enumerator5 = item2.wallDict.GetEnumerator(); while (enumerator5.MoveNext()) { Vector2 key = enumerator5.Current.Key; if (angleForWall.TryGetValue(key, out var value2) && !hashSet2.Contains((num3, key)) && Place(room, item2, value2, key) != null) { return true; } } } ManualLogSource logSource = Plugin.LogSource; bool flag2 = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(70, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[manual] room "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": no free wall tile found for a filing cabinet ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(list.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" tiles)."); } logSource.LogWarning(val2); return false; } internal static bool SwapShortForTall(NewRoom room, Func<Interactable, bool> isRoster) { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_0157: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) if (((room != null) ? room.individualFurniture : null) == null || !Learn()) { return false; } List<FurnitureLocation> individualFurniture = room.individualFurniture; bool flag = default(bool); for (int i = 0; i < individualFurniture.Count; i++) { FurnitureLocation val = individualFurniture[i]; object obj; if (val == null) { obj = null; } else { FurniturePreset furniture = val.furniture; obj = ((furniture != null) ? ((Object)furniture).name : null); } if ((string?)obj != "ShortFilingCabinet" || val.anchorNode == null || val.cluster == null) { continue; } List<Interactable> list = new List<Interactable>(); List<Interactable> spawnedInteractables = val.spawnedInteractables; int num = 0; while (spawnedInteractables != null && num < spawnedInteractables.Count) { Interactable val2 = spawnedInteractables[num]; if (val2 != null) { if (isRoster(val2)) { try { val2.Delete(); } catch { } } else { list.Add(val2); } } num++; } FurniturePreset furniture2 = val.furniture; NewNode anchorNode = val.anchorNode; int angle = val.angle; ManualLogSource logSource = Plugin.LogSource; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(58, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[manual] room "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": swapping short cabinet "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(val.id); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" for a tall one at "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Vector3Int>(anchorNode.nodeCoord); } logSource.LogInfo(val3); val.cluster.DeleteFurniture(val.id, true, (RemoveInteractablesOption)0); FurnitureLocation val4 = Place(room, anchorNode, angle, Vector2.zero); if (val4 == null) { ManualLogSource logSource2 = Plugin.LogSource; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(68, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[manual] room "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(": tall cabinet did not fit, putting the short one back"); } logSource2.LogWarning(val5); val4 = Place(room, anchorNode, angle, Vector2.zero, furniture2); } CarryOver(room, list, val4, anchorNode); if (val4 != null) { FurniturePreset furniture3 = val4.furniture; return ((furniture3 != null) ? ((Object)furniture3).name : null) == "FilingCabinet"; } return false; } return false; } private static void CarryOver(NewRoom room, List<Interactable> items, FurnitureLocation? target, NewNode node) { //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_0115: 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_012e: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown object obj; if (target == null) { obj = null; } else { FurniturePreset furniture = target.furniture; obj = ((furniture != null) ? furniture.subObjects : null); } List<SubObject> val = (List<SubObject>)obj; int num = 0; bool flag = default(bool); foreach (Interactable item in items) { try { SubObject val2 = null; while (val != null && num < val.Count && val2 == null) { SubObject val3 = val[num++]; if (val3 != null && (val3.parent == null || !val3.parent.Contains("Drawer"))) { val2 = val3; } } if (val2 != null) { item.ConvertToFurnitureSpawnedObject(target, val2, true, true); ManualLogSource logSource = Plugin.LogSource; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(46, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[manual] room "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": moved "); BepInExInfoLogInterpolatedStringHandler obj2 = val4; InteractablePreset obj3 = item.preset; ((BepInExLogInterpolatedStringHandler)obj2).AppendFormatted<string>((obj3 != null) ? ((Object)obj3).name : null); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" onto the new cabinet ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(val2.parent); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(")"); } logSource.LogInfo(val4); } else { item.ConvertToWorldObject(false); item.MoveInteractable(node.position + new Vector3(0f, 0.05f, 0f), Vector3.zero, true); ManualLogSource logSource2 = Plugin.LogSource; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(44, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[manual] room "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": set "); BepInExInfoLogInterpolatedStringHandler obj4 = val4; InteractablePreset obj5 = item.preset; ((BepInExLogInterpolatedStringHandler)obj4).AppendFormatted<string>((obj5 != null) ? ((Object)obj5).name : null); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" down by the new cabinet"); } logSource2.LogInfo(val4); } } catch (Exception ex) { ManualLogSource logSource3 = Plugin.LogSource; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(33, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[manual] room "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(": could not move "); object obj6; if (item == null) { obj6 = null; } else { InteractablePreset obj7 = item.preset; obj6 = ((obj7 != null) ? ((Object)obj7).name : null); } ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>((string)obj6); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message); } logSource3.LogWarning(val5); } } } private static FurnitureLocation? Place(NewRoom room, NewNode node, int angle, Vector2 wallSide, FurniturePreset? usePreset = null) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_003d: 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_007d: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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) bool flag = default(bool); try { FurniturePlacement val = new FurniturePlacement(); val.preset = usePreset ?? preset; val.anchorNode = node; val.coversNodes = new List<NewNode>(); val.coversNodes.Add(node); val.angle = angle; val.offset = Vector3.zero; FurnitureLocation val2 = room.AddFurnitureCustom(val); if (val2 == null) { return null; } try { if (!val2.createdInteractables) { val2.CreateInteractables(); } } catch { } ManualLogSource logSource = Plugin.LogSource; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(47, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[manual] room "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": placed "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)val.preset).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" at node "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Vector3Int>(node.nodeCoord); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", wall "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Vector2>(wallSide); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", angle "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(angle); } logSource.LogInfo(val3); return val2; } catch (Exception ex) { ManualLogSource logSource2 = Plugin.LogSource; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(36, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[manual] room "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": placing at "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Vector3Int>(node.nodeCoord); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" failed: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message); } logSource2.LogWarning(val4); return null; } } private static bool Learn() { //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) if (angleForWall != null) { if ((SoCustomComparison)(object)preset != (SoCustomComparison)null) { return angleForWall.Count > 0; } return false; } angleForWall = new Dictionary<Vector2, int>(); Dictionary<Vector2, Dictionary<int, int>> dictionary = new Dictionary<Vector2, Dictionary<int, int>>(); Enumerator<int, NewRoom> enumerator = CityData.Instance.roomDictionary.GetEnumerator(); while (enumerator.MoveNext()) { NewRoom value = enumerator.Current.Value; List<FurnitureLocation> val = ((value != null) ? value.individualFurniture : null); int num = 0; while (val != null && num < val.Count) { FurnitureLocation val2 = val[num]; if (!((SoCustomComparison)(object)((val2 != null) ? val2.furniture : null) == (SoCustomComparison)null) && !(((Object)val2.furniture).name != "FilingCabinet") && !val2.userPlaced) { NewNode anchorNode = val2.anchorNode; if (((anchorNode != null) ? anchorNode.wallDict : null) != null) { if (preset == null) { preset = val2.furniture; } if (val2.anchorNode.wallDict.Count == 1) { Enumerator<Vector2, NewWall> enumerator2 = val2.anchorNode.wallDict.GetEnumerator(); while (enumerator2.MoveNext()) { if (!dictionary.TryGetValue(enumerator2.Current.Key, out var value2)) { value2 = (dictionary[enumerator2.Current.Key] = new Dictionary<int, int>()); } value2[val2.angle] = ((!value2.TryGetValue(val2.angle, out var value3)) ? 1 : (value3 + 1)); } } } } num++; } } foreach (KeyValuePair<Vector2, Dictionary<int, int>> item in dictionary) { int value4 = 0; int num2 = -1; foreach (KeyValuePair<int, int> item2 in item.Value) { if (item2.Value > num2) { value4 = item2.Key; num2 = item2.Value; } } angleForWall[item.Key] = value4; } if ((SoCustomComparison)(object)preset != (SoCustomComparison)null) { return angleForWall.Count > 0; } return false; } } [BepInPlugin("sm3gm.sod.controlroomfix", "Control Room Fix", "1.3.0")] public sealed class Plugin : BasePlugin { public const string PluginGuid = "sm3gm.sod.controlroomfix"; public const string PluginName = "Control Room Fix"; public const string PluginVersion = "1.3.0"; internal static ManualLogSource LogSource { get; private set; } internal static ConfigEntry<bool> DumpEligiblePresets { get; private set; } internal static ConfigEntry<bool> DumpInteractablePipeline { get; private set; } internal static ConfigEntry<bool> TryAlternateInteractableOrdering { get; private set; } internal static ConfigEntry<bool> PreferWorkingDeskPreset { get; private set; } internal static ConfigEntry<bool> EnableGenerationFix { get; private set; } internal static ConfigEntry<bool> RepairExistingControlRooms { get; private set; } internal static ConfigEntry<bool> HireForVacantControlRooms { get; private set; } internal static ConfigEntry<bool> EnableCityHallGenerationFix { get; private set; } internal static ConfigEntry<bool> FileEveryResident { get; private set; } internal static ConfigEntry<int> ResidentsPerDrawer { get; private set; } internal static ConfigEntry<string> GuaranteedControlRoomBuildings { get; private set; } public override void Load() { //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown LogSource = ((BasePlugin)this).Log; EnableGenerationFix = ((BasePlugin)this).Config.Bind<bool>("Fixes", "EnableControlRoomGenerationFix", true, "Allow functional furniture to generate in otherwise uninhabited ControlRoom addresses."); GuaranteedControlRoomBuildings = ((BasePlugin)this).Config.Bind<string>("Fixes", "GuaranteedControlRoomBuildings", "CityHall,Townhouse,TownhouseShops", "Building types that get at least one control room in new cities. These have control room floor designs but the game builds none in them. Comma separated; empty = the game's own counts. Existing cities are not changed."); RepairExistingControlRooms = ((BasePlugin)this).Config.Bind<bool>("Fixes", "RepairExistingControlRooms", true, "Add missing vanilla functional clusters when an existing broken city is loaded."); HireForVacantControlRooms = ((BasePlugin)this).Config.Bind<bool>("Fixes", "HireForVacantControlRooms", true, "Give a control room's company one employee when all its posts are vacant, so its computer has a login. Re-applied on every load; nothing is saved."); EnableCityHallGenerationFix = ((BasePlugin)this).Config.Bind<bool>("Fixes", "EnableDuplicateCityHallLimitExperiment", false, "Experimental: raise CityHall company limits to eligible address count."); FileEveryResident = ((BasePlugin)this).Config.Bind<bool>("Fixes", "FileEveryResident", true, "Every resident of a building gets a folder in its control room's filing cabinets, spread over as many drawers as needed (short cabinets too, extra cabinets if the room runs out). Off = vanilla (only some residents, in the building's own drawer)."); ResidentsPerDrawer = ((BasePlugin)this).Config.Bind<int>("Fixes", "ResidentsPerDrawer", 14, "How many resident folders go in one drawer."); DumpEligiblePresets = ((BasePlugin)this).Config.Bind<bool>("Diagnostics", "DumpEligiblePresets", false, "Log furniture clusters and presets eligible for ControlRoom rooms."); DumpInteractablePipeline = ((BasePlugin)this).Config.Bind<bool>("Diagnostics", "DumpInteractablePipeline", false, "Log vanilla furniture/interactable APIs and before/after repair counts."); TryAlternateInteractableOrdering = ((BasePlugin)this).Config.Bind<bool>("Fixes", "TryAlternateInteractableOrdering", true, "If CreateInteractables leaves integrated=0, try SpawnObject-first and other parameterless interactable methods."); PreferWorkingDeskPreset = ((BasePlugin)this).Config.Bind<bool>("Fixes", "PreferWorkingDeskPreset", true, "If DeskAgainstWall picks a furniture preset with no MicroCruncher, assign a Toolbox desk preset that defines one."); Harmony.CreateAndPatchAll(typeof(GameStartedPatch), "sm3gm.sod.controlroomfix"); Harmony.CreateAndPatchAll(typeof(InteriorGenerationPatch), "sm3gm.sod.controlroomfix"); Harmony.CreateAndPatchAll(typeof(CitizenGenerationPatch), "sm3gm.sod.controlroomfix"); Harmony.CreateAndPatchAll(typeof(ControlRoomCountPatch), "sm3gm.sod.controlroomfix"); bool flag = default(bool); if (DumpInteractablePipeline.Value) { try { VanillaInteractableApiProbe.DumpAndTrace(); } catch (Exception ex) { ManualLogSource logSource = LogSource; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Vanilla interactable API probe failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logSource.LogError(val); } } ManualLogSource logSource2 = LogSource; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(138, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Control Room Fix"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.3.0"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded; fixes: "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("ControlRoom generation="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(EnableGenerationFix.Value ? "enabled" : "disabled"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("existing ControlRooms="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(RepairExistingControlRooms.Value ? "enabled" : "disabled"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("file every resident="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(FileEveryResident.Value ? "enabled" : "disabled"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("duplicate City Hall="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(EnableCityHallGenerationFix.Value ? "enabled" : "disabled"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("interactable pipeline dump="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(DumpInteractablePipeline.Value ? "enabled" : "disabled"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } logSource2.LogInfo(val2); } } internal static class RosterSplit { private const string RosterPreset = "ResidentRoster"; private const int MaxExtraCabinets = 8; internal static void Run() { //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Expected O, but got Unknown //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown CityData instance = CityData.Instance; if (((instance != null) ? instance.roomDictionary : null) == null) { return; } int num = Math.Max(1, Plugin.ResidentsPerDrawer.Value); int num2 = 0; int num3 = 0; int cabinetsAdded = 0; int num4 = 0; int num5 = 0; HashSet<int> hashSet = new HashSet<int>(); Enumerator<int, NewRoom> enumerator = CityData.Instance.roomDictionary.GetEnumerator(); bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2; while (enumerator.MoveNext()) { NewRoom value = enumerator.Current.Value; if ((SoCustomComparison)(object)((value != null) ? value.preset : null) == (SoCustomComparison)null || (Object)(object)value.building == (Object)null || !ControlRoomScanner.PresetName((Object)(object)value.preset).Equals("ControlRoom", StringComparison.OrdinalIgnoreCase) || !hashSet.Add(value.building.buildingID)) { continue; } try { List<Human> list = Residents(value.building); if (list.Count == 0) { continue; } int num6 = (list.Count + num - 1) / num; RemoveOverlappingCabinets(value); List<Interactable> list2 = FindRosterDrawers(value); num3 += AddDrawers(value, list2, num6, ref cabinetsAdded); for (int i = 0; i < list2.Count; i++) { List<Human> range = list.GetRange(Math.Min(i * num, list.Count), Math.Max(0, Math.Min(num, list.Count - i * num))); EvidenceMultiPage val = RosterFor(value.building, i); if (val != null) { num5 += Fill(val, range); num4 += range.Count; list2[i].evidence = (Evidence)(object)val; } } num2++; ManualLogSource logSource = Plugin.LogSource; val2 = new BepInExInfoLogInterpolatedStringHandler(58, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[roster] building "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)value.building).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(list.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" residents, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num6); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" drawers needed, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(list2.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" in room "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(value.roomID); } logSource.LogInfo(val2); } catch (Exception ex) { ManualLogSource logSource2 = Plugin.LogSource; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(23, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[roster] room "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(value.roomID); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); } logSource2.LogWarning(val3); } } ManualLogSource logSource3 = Plugin.LogSource; val2 = new BepInExInfoLogInterpolatedStringHandler(89, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[roster] "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" buildings, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num4); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" residents filed, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num5); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" new resident files, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" drawers and "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(cabinetsAdded); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" cabinets added."); } logSource3.LogInfo(val2); } private static List<Human> Residents(NewBuilding building) { List<(int, string, Human)> list = new List<(int, string, Human)>(); HashSet<int> hashSet = new HashSet<int>(); List<NewAddress> addressDirectory = CityData.Instance.addressDirectory; for (int i = 0; i < addressDirectory.Count; i++) { NewAddress val = addressDirectory[i]; if ((Object)(object)((val != null) ? ((NewGameLocation)val).building : null) == (Object)null || ((NewGameLocation)val).building.buildingID != building.buildingID || val.inhabitants == null) { continue; } int item = 0; try { item = (((Object)(object)((NewGameLocation)val).floor != (Object)null) ? ((NewGameLocation)val).floor.floor : 0); } catch { } for (int j = 0; j < val.inhabitants.Count; j++) { Human val2 = val.inhabitants[j]; if (!((Object)(object)((val2 != null) ? val2.home : null) == (Object)null) && val2.home.id == val.id && ((Actor)val2).evidenceEntry != null && hashSet.Add(val2.humanID)) { list.Add((item, ((Object)val).name ?? "", val2)); } } } list.Sort(((int floor, string addr, Human h) x, (int floor, string addr, Human h) y) => (x.floor == y.floor) ? string.CompareOrdinal(x.addr, y.addr) : x.floor.CompareTo(y.floor)); List<Human> list2 = new List<Human>(list.Count); foreach (var item2 in list) { list2.Add(item2.Item3); } return list2; } private static void RemoveOverlappingCabinets(NewRoom room) { //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown List<FurnitureLocation> individualFurniture = room.individualFurniture; if (individualFurniture == null) { return; } List<FurnitureLocation> list = new List<FurnitureLocation>(); for (int i = 0; i < individualFurniture.Count; i++) { FurnitureLocation val = individualFurniture[i]; if ((SoCustomComparison)(object)((val != null) ? val.furniture : null) == (SoCustomComparison)null || Tier(((Object)val.furniture).name) > 1 || !OnlyRosters(val)) { continue; } for (int j = 0; j < individualFurniture.Count; j++) { FurnitureLocation val2 = individualFurniture[j]; object obj; if (val2 == null) { obj = null; } else { FurniturePreset furniture = val2.furniture; obj = ((furniture != null) ? ((Object)furniture).name : null); } if (obj == null) { obj = ""; } string text = (string)obj; if (val2 != null && j != i && !text.StartsWith("Static") && !text.StartsWith("LeaningPoint") && !text.StartsWith("Wall") && !text.StartsWith("Shelf") && (Tier(text) > 1 || !OnlyRosters(val2) || val2.id <= val.id) && SharesTile(val, val2)) { list.Add(val); break; } } } bool flag = default(bool); foreach (FurnitureLocation item in list) { try { ManualLogSource logSource = Plugin.LogSource; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(38, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[roster] room "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(room.roomID); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": removing overlapping "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)item.furniture).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(item.id); } logSource.LogInfo(val3); FurnitureClusterLocation cluster = item.cluster; if (cluster != null) { cluster.DeleteFurniture(item.id, true, (RemoveInteractablesOption)1); } } catch (Exception ex) { ManualLogSource logSource2 = Plugin.LogSource; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(36, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[roster] could not remove cabinet "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(item.id); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message); } logSource2.LogWarning(val4); } } } private static bool SharesTile(FurnitureLocation x, FurnitureLocation y) { List<NewNode> coversNodes = x.coversNodes; List<NewNode> coversNodes2 = y.coversNodes; int