using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; 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 Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("TheInspector")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+716a7a61af29415a5f69791ad6ef0d1b94c1f69e")] [assembly: AssemblyProduct("TheInspector")] [assembly: AssemblyTitle("TheInspector")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TheInspector { internal static class ArrestReactions { private sealed class FreezeWatch { internal Vector3 LastPosition; internal float NextSampleTime; internal int SamplesLeft; } private const float GawkLookRank = 100f; private const int FreezeSampleCount = 6; private const float FreezeSampleInterval = 0.5f; private const float FreezeDriftTolerance = 0.25f; internal static readonly HashSet Surrendering = new HashSet(); internal static readonly HashSet Gawking = new HashSet(); private static readonly Dictionary FreezeWatches = new Dictionary(); internal static bool IsRedHandedMurderer(NewAIController ai) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 if ((Object)(object)ai == (Object)null) { return false; } List killerForMurders = ai.killerForMurders; if (killerForMurders == null) { return false; } Enumerator enumerator = killerForMurders.GetEnumerator(); while (enumerator.MoveNext()) { Murder current = enumerator.Current; if (current != null && (int)current.state == 5) { return true; } } return false; } internal static bool ShouldSurrender(Actor victim, Actor fromWho) { if (!InspectorConfig.CivilianReactionsEnabled.Value) { return false; } if ((Object)(object)fromWho == (Object)null || !fromWho.isPlayer) { return false; } if (InspectorConfig.RedHandedMurderException.Value && IsRedHandedMurderer((victim != null) ? victim.ai : null)) { return false; } return true; } internal static void BreakGawk(Actor actor) { if (!((Object)(object)actor == (Object)null) && Gawking.Remove(actor)) { ClearOrientationOverride(actor); } } private static void ClearOrientationOverride(Actor actor) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) NewAIController val = ((actor != null) ? actor.ai : null); if (!((Object)(object)val == (Object)null)) { val.facingActive = false; val.faceTransform = null; val.faceTransformOffset = Vector3.zero; val.lookAtTransform = null; val.lookAtTransformRank = 0f; } } internal static void BeginArrest(Actor victim) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)victim == (Object)null) { return; } BreakGawk(victim); Surrendering.Add(victim); PinPath(victim); FreezeWatches[victim] = new FreezeWatch { LastPosition = ((Component)victim).transform.position, NextSampleTime = Time.time + 0.5f, SamplesLeft = 6 }; ApplySurrenderState(victim); Player instance = Player.Instance; if ((Object)(object)instance == (Object)null) { return; } CityData instance2 = CityData.Instance; List val = ((instance2 != null) ? instance2.citizenDirectory : null); if (val == null) { return; } float value = InspectorConfig.GawkRadius.Value; Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Citizen current = enumerator.Current; if (!((Object)(object)current == (Object)null) && !((Actor)current).isDead && !((Object)(object)current == (Object)(object)victim) && !Surrendering.Contains((Actor)(object)current) && !Gawking.Contains((Actor)(object)current) && Vector3.Distance(((Component)current).transform.position, ((Component)instance).transform.position) <= value) { Gawking.Add((Actor)(object)current); } } ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(52, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Arrest initiated on "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)victim).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("; "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Gawking.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" nearby citizen(s) gawking."); } logger.LogDebug(val2); } private static void PinPath(Actor actor) { NewAIController val = ((actor != null) ? actor.ai : null); if (!((Object)(object)val == (Object)null)) { NewNode currentNode = actor.currentNode; if (currentNode != null && val.currentDestinationNode != currentNode) { val.SetDestinationNode(currentNode, false); } } } private static void FreezeInPlace(Actor actor) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)actor.ai != (Object)null) { actor.ai.currentDestinationPositon = ((Component)actor).transform.position; } } private static void ApplySurrenderState(Actor victim) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Invalid comparison between Unknown and I4 //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Invalid comparison between Unknown and I4 FreezeInPlace(victim); NewAIController ai = victim.ai; if ((Object)(object)ai != (Object)null) { ai.inFleeState = false; ai.movementAmount = 0f; ai.doIMove = false; if ((Object)(object)ai.persuitTarget != (Object)null) { ai.CancelPersue(); } } victim.isRunning = false; victim.isMoving = false; CitizenAnimationController animationController = victim.animationController; if ((Object)(object)animationController != (Object)null) { if ((int)animationController.armsBoolAnimationState == 11) { animationController.SetArmsBoolState((ArmsBoolSate)1); } if ((int)animationController.idleAnimationState != 14) { animationController.SetIdleAnimationState((IdleAnimationState)14); } } } private static void EndSurrender(Actor victim) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 Surrendering.Remove(victim); FreezeWatches.Remove(victim); CitizenAnimationController animationController = victim.animationController; if ((Object)(object)animationController != (Object)null && (int)animationController.idleAnimationState == 14) { animationController.SetIdleAnimationState((IdleAnimationState)0); } } private static void ApplyGawkState(Actor gawker, Transform playerTransform) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) FreezeInPlace(gawker); NewAIController ai = gawker.ai; if (!((Object)(object)ai == (Object)null)) { ai.SetLookAtTransform(playerTransform, 100f); if ((Object)(object)ai.faceTransform != (Object)(object)playerTransform) { ai.SetFacingTransform(playerTransform, Vector3.zero); } } } private static void SampleFreeze(Actor victim) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) if (FreezeWatches.TryGetValue(victim, out var value) && value.SamplesLeft > 0 && !(Time.time < value.NextSampleTime)) { value.SamplesLeft--; value.NextSampleTime = Time.time + 0.5f; Vector3 position = ((Component)victim).transform.position; float num = Vector3.Distance(position, value.LastPosition); value.LastPosition = position; NewAIController ai = victim.ai; CitizenAnimationController animationController = victim.animationController; object obj; if (ai == null) { obj = null; } else { NewAIGoal currentGoal = ai.currentGoal; obj = ((currentGoal != null) ? currentGoal.name : null); } if (obj == null) { obj = ""; } string value2 = (string)obj; bool value3 = (Object)(object)ai != (Object)null && ai.currentDestinationNode == victim.currentNode; string text = $"[{"CalebScott.TheInspector"}] Surrender hold on {((Object)victim).name}: drift={num:F2}m flee={((ai != null) ? new bool?(ai.inFleeState) : ((bool?)null))} running={victim.isRunning} moving={victim.isMoving} doIMove={((ai != null) ? new bool?(ai.doIMove) : ((bool?)null))} movementAmount={((ai != null) ? new float?(ai.movementAmount) : ((float?)null)):F2} spooked={((ai != null) ? new float?(ai.spooked) : ((float?)null)):F1} nerve={victim.currentNerve:F1} atDest={value3} goal='{value2}' arms={((animationController != null) ? new ArmsBoolSate?(animationController.armsBoolAnimationState) : ((ArmsBoolSate?)null))} idle={((animationController != null) ? new IdleAnimationState?(animationController.idleAnimationState) : ((IdleAnimationState?)null))}"; if (num > 0.25f) { Plugin.Logger.LogWarning((object)(text + " -- STILL MOVING")); } else { Plugin.Logger.LogDebug((object)text); } } } internal static void TickActor(NewAIController ai) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) Human val = ((ai != null) ? ai.human : null); if ((Object)(object)val == (Object)null) { return; } if (((Actor)val).isDead) { EndSurrender((Actor)(object)val); Gawking.Remove((Actor)(object)val); return; } Player instance = Player.Instance; if ((Object)(object)instance == (Object)null) { return; } Vector3 position = ((Component)instance).transform.position; if (Surrendering.Contains((Actor)(object)val)) { if (Vector3.Distance(((Component)val).transform.position, position) > InspectorConfig.SurrenderReleaseDistance.Value) { EndSurrender((Actor)(object)val); return; } ApplySurrenderState((Actor)(object)val); SampleFreeze((Actor)(object)val); } else if (Gawking.Contains((Actor)(object)val)) { if (Vector3.Distance(((Component)val).transform.position, position) > InspectorConfig.GawkReleaseDistance.Value) { BreakGawk((Actor)(object)val); } else { ApplyGawkState((Actor)(object)val, ((Component)instance).transform); } } } internal static bool IsHardFrozen(Actor actor) { if ((Object)(object)actor == (Object)null) { return false; } if (!InspectorConfig.CivilianReactionsEnabled.Value || !InspectorConfig.SurrenderHardFreeze.Value) { return false; } return Surrendering.Contains(actor); } } [HarmonyPatch(typeof(Actor), "RecieveDamage")] internal static class Actor_RecieveDamage_Patch { [HarmonyPrefix] private static void Prefix(Actor __instance, Actor fromWho, ref bool alertSurrounding) { if (ArrestReactions.ShouldSurrender(__instance, fromWho)) { alertSurrounding = false; } } [HarmonyPostfix] private static void Postfix(Actor __instance, Actor fromWho) { if (InspectorConfig.CivilianReactionsEnabled.Value) { ArrestReactions.BreakGawk(__instance); } if (ArrestReactions.ShouldSurrender(__instance, fromWho)) { ArrestReactions.BeginArrest(__instance); } } } [HarmonyPatch(typeof(NewAIController), "SetInCombat")] internal static class NewAIController_SetInCombat_Patch { [HarmonyPrefix] private static bool Prefix(NewAIController __instance, bool val) { if (!val || !InspectorConfig.CivilianReactionsEnabled.Value) { return true; } return (Object)(object)__instance.human == (Object)null || !ArrestReactions.Surrendering.Contains((Actor)(object)__instance.human); } } [HarmonyPatch(typeof(CitizenAnimationController), "SetInCombat")] internal static class CitizenAnimationController_SetInCombat_Patch { [HarmonyPrefix] private static bool Prefix(CitizenAnimationController __instance, bool val) { if (!val || !InspectorConfig.CivilianReactionsEnabled.Value) { return true; } Actor component = ((Component)__instance).gameObject.GetComponent(); return (Object)(object)component == (Object)null || !ArrestReactions.Surrendering.Contains(component); } } [HarmonyPatch(typeof(NewAIController), "StartAttack")] internal static class NewAIController_StartAttack_Patch { private static readonly Random Roll = new Random(); [HarmonyPrefix] private static bool Prefix(NewAIController __instance, Actor newAttackTarget) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown if (!InspectorConfig.CivilianReactionsEnabled.Value) { return true; } if ((Object)(object)newAttackTarget == (Object)null || !newAttackTarget.isPlayer) { return true; } if (InspectorConfig.RedHandedMurderException.Value && ArrestReactions.IsRedHandedMurderer(__instance)) { return true; } if ((!((Object)(object)__instance.human != (Object)null) || !ArrestReactions.Surrendering.Contains((Actor)(object)__instance.human)) && Roll.NextDouble() < (double)InspectorConfig.BystanderFleeChance.Value) { __instance.inFleeState = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(51, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Bystander flees instead of attacking the player."); } logger.LogDebug(val); } __instance.CancelCombat(); return false; } } [HarmonyPatch(typeof(NewAIController), "MovementUpdate")] internal static class NewAIController_MovementUpdate_Patch { [HarmonyPrefix] private static bool Prefix(NewAIController __instance) { return !ArrestReactions.IsHardFrozen((Actor)(object)__instance.human); } [HarmonyPostfix] private static void Postfix(NewAIController __instance) { if (!InspectorConfig.CivilianReactionsEnabled.Value) { return; } if (!InspectorConfig.RedHandedMurderException.Value || !ArrestReactions.IsRedHandedMurderer(__instance)) { Actor attackTarget = __instance.attackTarget; if ((Object)(object)attackTarget != (Object)null && attackTarget.isPlayer) { __instance.CancelCombat(); } } ArrestReactions.TickActor(__instance); } } internal static class GameSession { internal static string InstanceId { get { try { if ((Object)(object)CityData.Instance == (Object)null) { return null; } string currentGameInstanceID = CityData.Instance.GetCurrentGameInstanceID(); return string.IsNullOrWhiteSpace(currentGameInstanceID) ? null : currentGameInstanceID; } catch { return null; } } } internal static string StillLoading() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) try { CityConstructor instance = CityConstructor.Instance; if ((Object)(object)instance != (Object)null) { if (instance.loadingOperationActive) { return $"the loader is still running, state {instance.loadState}"; } if (instance.preSimActive) { return "the pre-simulation is still running"; } if (!instance.isLoaded) { return "the city loader has not reported the city as loaded"; } } } catch { } try { SessionData instance2 = SessionData.Instance; if ((Object)(object)instance2 != (Object)null && !instance2.startedGame) { return "the session has not started the game yet"; } } catch { } return null; } } [HarmonyPatch(typeof(FirstPersonItemController), "OnConsumableFinished")] internal static class CigaretteRefillPatch { [HarmonyPrefix] private static bool Prefix(Interactable consumableFinished) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown if (!InventoryConfig.Enabled.Value || !InventoryConfig.InfiniteUseEnabled.Value) { return true; } if (consumableFinished == null) { return true; } if (!SlotConfig.TrackedSlots.TryGetValue(SlotConfig.LockedItem.Cigarettes, out var value) || value == null) { return true; } Interactable interactable = value.GetInteractable(); if (interactable == null || interactable.id != consumableFinished.id) { return true; } try { float num = (((SoCustomComparison)(object)consumableFinished.preset != (SoCustomComparison)null) ? consumableFinished.preset.consumableAmount : 1f); consumableFinished.SetExtraStateValue(num, true); } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Inventory] Cigarette refill failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } logger.LogError(val); } return false; } } internal static class LockedSlotRefiller { internal static void RefillIfEmpty(FirstPersonItemController controller, SlotConfig.LockedItem item) { if (!InventoryConfig.Enabled.Value || !InventoryConfig.InfiniteUseEnabled.Value || !SlotConfig.TrackedSlots.TryGetValue(item, out var value) || value == null || ItemFactory.IsSlotFilled(value)) { return; } SlotConfig.LockedItemDef lockedItemDef = SlotConfig.Find(item); if (lockedItemDef != null) { Player val; try { val = ((Component)controller).GetComponent(); } catch { val = null; } if (!((Object)(object)val == (Object)null)) { ItemFactory.FillSlot(controller, val, value, lockedItemDef); } } } } [HarmonyPatch(typeof(FirstPersonItemController), "PlaceDoorWedge")] internal static class DoorWedgeRefillPatch { [HarmonyPostfix] private static void Postfix(FirstPersonItemController __instance) { LockedSlotRefiller.RefillIfEmpty(__instance, SlotConfig.LockedItem.DoorStopper); } } [HarmonyPatch(typeof(FirstPersonItemController), "PlaceCodebreaker")] internal static class CodebreakerRefillPatch { [HarmonyPostfix] private static void Postfix(FirstPersonItemController __instance) { LockedSlotRefiller.RefillIfEmpty(__instance, SlotConfig.LockedItem.Codebreaker); } } internal static class InspectorConfig { internal static ConfigEntry Enabled; internal static ConfigEntry CivilianReactionsEnabled; internal static ConfigEntry BystanderFleeChance; internal static ConfigEntry RedHandedMurderException; internal static ConfigEntry SurrenderHardFreeze; internal static ConfigEntry SurrenderReleaseDistance; internal static ConfigEntry GawkRadius; internal static ConfigEntry GawkReleaseDistance; internal static void Bind(ConfigFile config) { Enabled = config.Bind("General", "Enabled", true, "When true, the player is immune to all illegal-status detection (trespassing, assault, theft, breaking and entering, tampering, vandalism) and is never targeted/investigated by security cameras or sentry turrets."); CivilianReactionsEnabled = config.Bind("CivilianReactions", "Enabled", true, "When true, anyone the player hits surrenders instead of fighting back, and nearby witnesses never attack the player either."); BystanderFleeChance = config.Bind("CivilianReactions", "BystanderFleeChance", 0.3f, "Fraction (0-1) of nearby witnesses who flee instead of just watching when the player hits someone."); RedHandedMurderException = config.Bind("CivilianReactions", "RedHandedMurderException", true, "When true, a murderer caught actively committing a murder keeps vanilla fight/flee behavior instead of surrendering."); SurrenderHardFreeze = config.Bind("CivilianReactions", "SurrenderHardFreeze", true, "When true, a surrendering NPC's movement tick is suppressed entirely so they kneel where they stand instead of running off with their arms up. Turn off to fall back to the softer freeze if the hard hold ever looks wrong."); SurrenderReleaseDistance = config.Bind("CivilianReactions", "SurrenderReleaseDistance", 10f, "How far away (in meters) the player has to get from a surrendering NPC before they get up and resume normal behavior."); GawkRadius = config.Bind("CivilianReactions", "GawkRadius", 15f, "Radius (in meters) around the player, at the moment an arrest is initiated, within which civilians turn to gawk at the player."); GawkReleaseDistance = config.Bind("CivilianReactions", "GawkReleaseDistance", 20f, "How far away (in meters) the player has to get from a gawking civilian before they resume normal behavior."); } } internal static class InventoryConfig { internal static ConfigEntry Enabled; internal static ConfigEntry InfiniteUseEnabled; internal static ConfigEntry ModularSlotCount; internal static ConfigEntry SwapInventoryRows; internal static void Bind(ConfigFile config) { Enabled = config.Bind("Inventory", "Enabled", true, "Master switch for the inventory overhaul: 9 locked tool slots (keys 1-9) plus a resized modular row."); InfiniteUseEnabled = config.Bind("Inventory", "InfiniteUseEnabled", true, "When true, the 9 locked tool slots can never be dropped, and consumable ones (cigarettes, door stopper, code breaker) refill instantly on use."); ModularSlotCount = config.Bind("Inventory", "ModularSlotCount", 6, "Number of free/modular inventory slots (vanilla default is 4)."); SwapInventoryRows = config.Bind("Inventory", "SwapInventoryRows", true, "When true, the modular row renders above the locked tool row in the inventory screen instead of below it."); } } [HarmonyPatch(typeof(FirstPersonItemController), "Start")] internal static class InventorySetupStartPatch { [HarmonyPostfix] private static void Postfix(FirstPersonItemController __instance) { InventorySetup.Ensure(__instance); } } [HarmonyPatch(typeof(FirstPersonItemController), "Update")] internal static class InventorySetupUpdatePatch { [HarmonyPostfix] private static void Postfix(FirstPersonItemController __instance) { InventorySetup.Ensure(__instance); } } internal static class InventorySetup { private const int SettleFrames = 180; private const int StableFrames = 150; private const int MaxWaitFrames = 1800; private const int ResizeDelayFrames = 30; private static FirstPersonItemController _boundController; private static string _sessionId; private static int _frames; private static int _sizeRequest; private static int _lastSlotCount; private static int _stableSince; private static int _discrepancyFrames; private static bool _setupStarted; private static bool _loggedComplete; private static bool _loggedDiagnostic; internal static void Ensure(FirstPersonItemController controller) { //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Expected O, but got Unknown //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Expected O, but got Unknown //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Expected O, but got Unknown //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Expected O, but got Unknown //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Expected O, but got Unknown //IL_060e: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown if (!InventoryConfig.Enabled.Value || (Object)(object)controller == (Object)null) { return; } Player val; try { val = ((Component)controller).GetComponent(); } catch { val = null; } if ((Object)(object)val == (Object)null) { return; } string instanceId = GameSession.InstanceId; if (instanceId == null) { return; } if ((Object)(object)_boundController != (Object)(object)controller || _sessionId != instanceId) { _boundController = controller; _sessionId = instanceId; SlotConfig.Reset(); ItemFactory.ResetSession(); _frames = 0; _sizeRequest = 0; _lastSlotCount = -1; _stableSince = 0; _discrepancyFrames = 0; _setupStarted = false; _loggedComplete = false; _loggedDiagnostic = false; } if (_frames++ < 180) { return; } bool flag = default(bool); if (!_setupStarted) { int num = ((controller.slots != null) ? controller.slots.Count : 0); if (num != _lastSlotCount) { _lastSlotCount = num; _stableSince = _frames; } if (_frames - _stableSince < 150 && _frames < 1800) { return; } _setupStarted = true; ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(70, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Inventory] Slot list settled at "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" slots after "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(_frames); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" frames; starting setup."); } logger.LogInfo(val2); } ItemFactory.LogPresetDumpOnce(); ItemFactory.CurrentFrame = _frames; try { int num2 = ItemFactory.PurgeOrphanedRuntimeItems(controller, val); if (num2 > 0) { ManualLogSource logger2 = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(64, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Inventory] Purged "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" orphaned runtime items from Actor.inventory."); } logger2.LogWarning(val3); } } catch (Exception ex) { ManualLogSource logger3 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Inventory] Purge failed: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex); } logger3.LogError(val4); } int num3 = SlotConfig.ReservedCount(); int num4 = InventoryConfig.ModularSlotCount.Value + num3; try { int num5 = ItemFactory.CountNonStaticSlots(controller); if (num5 != num4) { if (++_discrepancyFrames >= 30) { _discrepancyFrames = 0; if (_sizeRequest == 0) { _sizeRequest = num4; } _sizeRequest += num4 - num5; if (_sizeRequest < 1) { _sizeRequest = 1; } if (_sizeRequest > 40) { _sizeRequest = 40; } controller.SetSlotSize(_sizeRequest); } } else { _discrepancyFrames = 0; } } catch (Exception ex2) { ManualLogSource logger4 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(32, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Inventory] SetSlotSize failed: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex2); } logger4.LogError(val4); } StaticSlot[] unwantedNativeStatics = SlotConfig.UnwantedNativeStatics; foreach (StaticSlot val5 in unwantedNativeStatics) { try { if (ItemFactory.FindStaticSlot(controller, val5) != null) { controller.RemoveSpecificStaticSlot(val5); } } catch (Exception ex3) { ManualLogSource logger5 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(32, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Inventory] Removing '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val5); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' failed: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex3); } logger5.LogError(val4); } } if (SlotConfig.DeselectSlot == null || !ItemFactory.SlotStillExists(controller, SlotConfig.DeselectSlot)) { SlotConfig.DeselectSlot = ItemFactory.FindHolsterSlot(controller); } if (SlotConfig.DeselectSlot != null && SlotConfig.DeselectSlot.hotkey != "0") { SlotConfig.DeselectSlot.hotkey = "0"; } bool flag2 = true; SlotConfig.LockedItemDef[] items = SlotConfig.Items; foreach (SlotConfig.LockedItemDef lockedItemDef in items) { try { if (!EnsureItem(controller, val, lockedItemDef)) { flag2 = false; } } catch (Exception ex4) { ManualLogSource logger6 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(33, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Inventory] Setup for '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(lockedItemDef.Item); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' failed: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex4); } logger6.LogError(val4); } } try { int num6 = ItemFactory.DeduplicateAgainstReserved(controller, val); if (num6 > 0) { ManualLogSource logger7 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(77, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Inventory] Cleared "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num6); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" duplicate slot reference(s) restored by the save loader."); } logger7.LogInfo(val2); } } catch (Exception ex5) { ManualLogSource logger8 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Inventory] Dedupe failed: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex5); } logger8.LogError(val4); } if (!flag2 && !_loggedDiagnostic && _frames > 1080) { _loggedDiagnostic = true; Plugin.Logger.LogWarning((object)"[Inventory] Setup incomplete; dumping state."); DumpSlots(controller, "incomplete"); ItemFactory.DumpInventoryList(val); } if (flag2 && !_loggedComplete) { _loggedComplete = true; ManualLogSource logger9 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(68, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Inventory] Setup complete: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(SlotConfig.TrackedSlots.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(SlotConfig.Items.Length); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" tools, nonStatic="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ItemFactory.CountNonStaticSlots(controller)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (reserved "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" + free "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(InventoryConfig.ModularSlotCount.Value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } logger9.LogInfo(val2); DumpSlots(controller, "post-setup"); ItemFactory.DumpInventoryList(val); } } private static bool EnsureItem(FirstPersonItemController controller, Player player, SlotConfig.LockedItemDef def) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) SlotConfig.TrackedSlots.TryGetValue(def.Item, out var value); if (value != null && !ItemFactory.SlotStillExists(controller, value)) { SlotConfig.Untrack(def.Item, value); value = null; } if (value == null) { if (def.NativeStatic.HasValue) { value = ItemFactory.FindStaticSlot(controller, def.NativeStatic.Value) ?? controller.AddSpecificStaticSlot(def.NativeStatic.Value); } else { InteractablePreset preset = ItemFactory.ResolvePreset(def); value = ItemFactory.FindSlotHoldingPreset(controller, preset, null) ?? ItemFactory.ClaimReservedSlot(controller); } if (value == null) { return false; } value.hotkey = def.Hotkey; SlotConfig.Track(def.Item, value); } if (value.hotkey != def.Hotkey) { value.hotkey = def.Hotkey; } if (def.NativeStatic.HasValue) { return true; } if (ItemFactory.IsSlotFilled(value)) { return true; } return ItemFactory.FillSlot(controller, player, value, def); } internal static void DumpSlots(FirstPersonItemController controller, string label) { //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(53, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Inventory] --- slot dump ["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(label); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(controller.slots.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" slots, nonStatic="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ItemFactory.CountNonStaticSlots(controller)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") ---"); } logger.LogInfo(val); for (int i = 0; i < controller.slots.Count; i++) { InventorySlot val2 = controller.slots[i]; if (val2 == null) { ManualLogSource logger2 = Plugin.Logger; val = new BepInExInfoLogInterpolatedStringHandler(11, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] "); } logger2.LogInfo(val); continue; } Interactable interactable = val2.GetInteractable(); InventorySquareController spawnedSegment = val2.spawnedSegment; string text = "no-segment"; if ((Object)(object)spawnedSegment != (Object)null) { text = (((Object)(object)((Component)spawnedSegment).transform.parent != (Object)null) ? $"{((Object)((Component)spawnedSegment).transform.parent).name}#{((Component)spawnedSegment).transform.GetSiblingIndex()}" : "no-parent"); } string text2 = ((interactable == null) ? "" : (((SoCustomComparison)(object)interactable.preset == (SoCustomComparison)null) ? "" : ((Object)interactable.preset).name)); string text3 = (SlotConfig.LockedSlots.Contains(val2) ? " RESERVED" : ""); ManualLogSource logger3 = Plugin.Logger; val = new BepInExInfoLogInterpolatedStringHandler(43, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] isStatic="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val2.isStatic); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" hotkey='"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val2.hotkey); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' id="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val2.interactableID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" item="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" segment="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text3); } logger3.LogInfo(val); } } catch (Exception ex) { ManualLogSource logger4 = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(30, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Inventory] Slot dump failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex); } logger4.LogWarning(val3); } } } internal static class ItemFactory { private static bool _dumpedPresetNames; internal const int RuntimeIdFloor = 100000000; private const int MaxTotalGrants = 40; private const int MaxGrantsPerItem = 2; private const int GrantCooldownFrames = 150; private static int _totalGrants; private static readonly Dictionary LastGrantFrame = new Dictionary(); private static readonly Dictionary GrantCount = new Dictionary(); private static readonly HashSet CapWarned = new HashSet(); internal static int CurrentFrame; internal static void LogPresetDumpOnce() { //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown if (_dumpedPresetNames) { return; } Toolbox instance = Toolbox.Instance; if ((Object)(object)instance == (Object)null) { return; } _dumpedPresetNames = true; bool flag = default(bool); try { Dictionary objectPresetDictionary = instance.objectPresetDictionary; if (objectPresetDictionary == null) { return; } ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(72, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Inventory] objectPresetDictionary has "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(objectPresetDictionary.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" entries. Resolving target items:"); } logger.LogInfo(val); SlotConfig.LockedItemDef[] items = SlotConfig.Items; foreach (SlotConfig.LockedItemDef lockedItemDef in items) { if (lockedItemDef.PresetNameCandidates != null) { InteractablePreset val2 = ResolvePreset(lockedItemDef); ManualLogSource logger2 = Plugin.Logger; val = new BepInExInfoLogInterpolatedStringHandler(8, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(lockedItemDef.Item); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((SoCustomComparison)(object)val2 != (SoCustomComparison)null) ? ((Object)val2).name : "UNRESOLVED"); } logger2.LogInfo(val); } } } catch (Exception ex) { ManualLogSource logger3 = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Inventory] Preset dump failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex); } logger3.LogWarning(val3); } } internal static InteractablePreset ResolvePreset(SlotConfig.LockedItemDef def) { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown Toolbox instance = Toolbox.Instance; if ((Object)(object)instance == (Object)null || def.PresetNameCandidates == null) { return null; } Dictionary objectPresetDictionary = instance.objectPresetDictionary; if (objectPresetDictionary == null) { return null; } string[] presetNameCandidates = def.PresetNameCandidates; InteractablePreset val = default(InteractablePreset); foreach (string text in presetNameCandidates) { if (objectPresetDictionary.TryGetValue(text, ref val) && (SoCustomComparison)(object)val != (SoCustomComparison)null) { return val; } } bool flag = default(bool); if (def.FallbackKeywords != null) { Enumerator enumerator = objectPresetDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; string key = current.Key; if (key == null) { continue; } string text2 = key.ToLowerInvariant(); string[] fallbackKeywords = def.FallbackKeywords; foreach (string value in fallbackKeywords) { if (text2.Contains(value)) { ManualLogSource logger = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(68, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Inventory] '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(def.Item); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' preset not found by exact name; using fuzzy match '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(key); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'."); } logger.LogWarning(val2); return current.Value; } } } } ManualLogSource logger2 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(74, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Inventory] Could not resolve a preset for '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(def.Item); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' - that slot will stay empty."); } logger2.LogError(val3); return null; } internal static bool IsSlotFilled(InventorySlot slot) { if (slot == null || slot.interactableID == -1) { return false; } try { return slot.GetInteractable() != null; } catch { return false; } } internal static InventorySlot FindSlotHoldingId(FirstPersonItemController controller, int id) { if (((controller != null) ? controller.slots : null) == null) { return null; } for (int i = 0; i < controller.slots.Count; i++) { InventorySlot val = controller.slots[i]; if (val != null && val.interactableID == id) { return val; } } return null; } internal static int DeduplicateAgainstReserved(FirstPersonItemController controller, Player player) { if (((controller != null) ? controller.slots : null) == null) { return 0; } HashSet hashSet = new HashSet(); foreach (InventorySlot lockedSlot in SlotConfig.LockedSlots) { if (lockedSlot != null && lockedSlot.interactableID != -1) { hashSet.Add(lockedSlot.interactableID); } } int num = 0; for (int i = 0; i < controller.slots.Count; i++) { InventorySlot val = controller.slots[i]; if (val != null && !SlotConfig.LockedSlots.Contains(val) && val != SlotConfig.DeselectSlot) { bool flag = val.interactableID != -1 && hashSet.Contains(val.interactableID); if (flag) { val.interactableID = -1; num++; } if (!string.IsNullOrEmpty(val.hotkey)) { val.hotkey = ""; } if (flag && (Object)(object)val.spawnedSegment != (Object)null) { val.spawnedSegment.OnUpdateContent(); } } } List val2 = ((player != null) ? ((Actor)player).inventory : null); if (val2 != null) { HashSet hashSet2 = new HashSet(); for (int num2 = val2.Count - 1; num2 >= 0; num2--) { Interactable val3 = val2[num2]; if (val3 == null) { val2.RemoveAt(num2); } else if (!hashSet2.Add(val3.id)) { val2.RemoveAt(num2); } } } return num; } internal static int PurgeOrphanedRuntimeItems(FirstPersonItemController controller, Player player) { if ((Object)(object)player == (Object)null || ((controller != null) ? controller.slots : null) == null) { return 0; } List inventory = ((Actor)player).inventory; if (inventory == null) { return 0; } int num = 0; for (int num2 = inventory.Count - 1; num2 >= 0; num2--) { Interactable val = inventory[num2]; if (val == null) { inventory.RemoveAt(num2); num++; } else if (val.id >= 100000000 && FindSlotHoldingId(controller, val.id) == null) { inventory.RemoveAt(num2); num++; } } return num; } internal static InventorySlot FindHolsterSlot(FirstPersonItemController controller) { return FindStaticSlot(controller, (StaticSlot)1); } internal static InventorySlot ClaimReservedSlot(FirstPersonItemController controller) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 if (((controller != null) ? controller.slots : null) == null) { return null; } for (int num = controller.slots.Count - 1; num >= 0; num--) { InventorySlot val = controller.slots[num]; if (val != null && (int)val.isStatic <= 0 && !SlotConfig.LockedSlots.Contains(val) && !IsSlotFilled(val)) { return val; } } return null; } internal static void DumpInventoryList(Player player) { //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown bool flag = default(bool); try { List val = ((player != null) ? ((Actor)player).inventory : null); if (val == null) { Plugin.Logger.LogInfo((object)"[Inventory] Actor.inventory is null."); return; } ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Inventory] --- Actor.inventory ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" items) ---"); } logger.LogInfo(val2); for (int i = 0; i < val.Count; i++) { Interactable val3 = val[i]; ManualLogSource logger2 = Plugin.Logger; val2 = new BepInExInfoLogInterpolatedStringHandler(19, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" inv["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] id="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted((val3 != null) ? val3.id.ToString() : "null"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" preset="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((SoCustomComparison)(object)((val3 != null) ? val3.preset : null) != (SoCustomComparison)null) ? ((Object)val3.preset).name : ""); } logger2.LogInfo(val2); } } catch (Exception ex) { ManualLogSource logger3 = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(35, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Inventory] Inventory dump failed: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex); } logger3.LogWarning(val4); } } internal static bool SlotStillExists(FirstPersonItemController controller, InventorySlot slot) { if (((controller != null) ? controller.slots : null) == null || slot == null) { return false; } for (int i = 0; i < controller.slots.Count; i++) { if (controller.slots[i] == slot) { return true; } } return false; } internal static int CountNonStaticSlots(FirstPersonItemController controller) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 if (((controller != null) ? controller.slots : null) == null) { return 0; } int num = 0; for (int i = 0; i < controller.slots.Count; i++) { InventorySlot val = controller.slots[i]; if (val != null && (int)val.isStatic == 0) { num++; } } return num; } internal static InventorySlot FindStaticSlot(FirstPersonItemController controller, StaticSlot staticType) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (((controller != null) ? controller.slots : null) == null) { return null; } for (int i = 0; i < controller.slots.Count; i++) { InventorySlot val = controller.slots[i]; if (val != null && val.isStatic == staticType) { return val; } } return null; } internal static InventorySlot FindSlotHoldingPreset(FirstPersonItemController controller, InteractablePreset preset, InventorySlot exclude) { if (((controller != null) ? controller.slots : null) == null || (SoCustomComparison)(object)preset == (SoCustomComparison)null) { return null; } for (int i = 0; i < controller.slots.Count; i++) { InventorySlot val = controller.slots[i]; if (val != null && val != exclude && IsSlotFilled(val)) { Interactable interactable = val.GetInteractable(); if (interactable != null && (SoCustomComparison)(object)interactable.preset != (SoCustomComparison)null && ((Object)interactable.preset).name == ((Object)preset).name) { return val; } } } return null; } internal static void ResetSession() { _totalGrants = 0; CurrentFrame = 0; LastGrantFrame.Clear(); GrantCount.Clear(); CapWarned.Clear(); } private static void RequestGrant(FirstPersonItemController controller, Player player, SlotConfig.LockedItemDef def, InteractablePreset preset) { //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown if (_totalGrants >= 40) { WarnCapped(def, $"the session-wide grant cap of {40} has been reached"); return; } GrantCount.TryGetValue(def.Item, out var value); if (value >= 2) { WarnCapped(def, $"it has already been granted {value} time(s) this session, the per-item cap"); return; } LastGrantFrame.TryGetValue(def.Item, out var value2); if (value2 != 0 && CurrentFrame - value2 < 150) { return; } LastGrantFrame[def.Item] = CurrentFrame; GrantCount[def.Item] = value + 1; _totalGrants++; Interactable val = null; bool flag = default(bool); try { InteractableCreator instance = InteractableCreator.Instance; if ((Object)(object)instance == (Object)null) { return; } Vector3 position = ((Component)controller).transform.position; val = instance.CreateWorldInteractable(preset, (Human)(object)player, (Human)null, (Human)null, position, Vector3.zero, (List)null, (Object)null, ""); if (val == null) { ManualLogSource logger = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Inventory] '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(def.Item); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': CreateWorldInteractable returned null."); } logger.LogWarning(val2); return; } RegisterInLookups(val); bool flag2 = controller.PickUpItem(val, false, false, false, false, false); InventorySlot val3 = FindSlotHoldingId(controller, val.id); if (val3 != null && IsSlotFilled(val3)) { ManualLogSource logger2 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(56, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Inventory] '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(def.Item); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("': granted "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Object)preset).name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" (id="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val.id); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("); adopt pass will move it."); } logger2.LogInfo(val4); return; } ManualLogSource logger3 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(82, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[Inventory] '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(def.Item); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("': grant REJECTED (pickUp="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(flag2); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", landed="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(val3 != null); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", id="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(val.id); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("). Deleting to avoid clutter."); } logger3.LogError(val5); TryDelete(val); } catch (Exception ex) { ManualLogSource logger4 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[Inventory] '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(def.Item); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("': grant failed: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(ex); } logger4.LogError(val5); TryDelete(val); } } private static void WarnCapped(SlotConfig.LockedItemDef def, string why) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (CapWarned.Add(def.Item)) { ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(92, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Inventory] '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(def.Item); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': not granted because "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(why); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Its slot will stay empty for the rest of this session."); } logger.LogWarning(val); } } private static void RegisterInLookups(Interactable item) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown try { CityData instance = CityData.Instance; if (!((Object)(object)instance == (Object)null)) { List interactableDirectory = instance.interactableDirectory; if (interactableDirectory != null && !interactableDirectory.Contains(item)) { interactableDirectory.Add(item); } Dictionary savableInteractableDictionary = instance.savableInteractableDictionary; if (savableInteractableDictionary != null && !savableInteractableDictionary.ContainsKey(item.id)) { savableInteractableDictionary.Add(item.id, item); } } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Inventory] Lookup registration failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } logger.LogWarning(val); } } private static void TryDelete(Interactable item) { if (item == null) { return; } try { item.SafeDelete(true); } catch { } } internal static bool FillSlot(FirstPersonItemController controller, Player player, InventorySlot slot, SlotConfig.LockedItemDef def) { //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown if (slot == null) { return false; } if (IsSlotFilled(slot)) { return true; } InteractablePreset val = ResolvePreset(def); if ((SoCustomComparison)(object)val == (SoCustomComparison)null) { return false; } bool flag = default(bool); try { InventorySlot val2 = FindSlotHoldingPreset(controller, val, slot); if (val2 != null) { Interactable interactable = val2.GetInteractable(); int interactableID = val2.interactableID; val2.interactableID = -1; if ((Object)(object)val2.spawnedSegment != (Object)null) { val2.spawnedSegment.OnUpdateContent(); } AttachToSlot(slot, interactable, interactableID); if (IsSlotFilled(slot)) { ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(52, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Inventory] '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(def.Item); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("': adopted "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((Object)val).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (id="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(interactableID); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(") into its locked slot."); } logger.LogInfo(val3); return true; } slot.interactableID = -1; AttachToSlot(val2, interactable, interactableID); ManualLogSource logger2 = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(73, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Inventory] '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(def.Item); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("': adopt of id="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(interactableID); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" was rejected; returned to its original slot."); } logger2.LogWarning(val4); return false; } } catch (Exception ex) { ManualLogSource logger3 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[Inventory] '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(def.Item); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("': adopt failed: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(ex); } logger3.LogError(val5); return false; } RequestGrant(controller, player, def, val); return false; } private static void AttachToSlot(InventorySlot slot, Interactable item, int id) { slot.interactableID = id; if (item != null) { slot.SetSegmentContent(item); } if (slot.interactableID != id) { slot.interactableID = id; } if ((Object)(object)slot.spawnedSegment != (Object)null) { slot.spawnedSegment.OnUpdateContent(); } } } [HarmonyPatch(typeof(FirstPersonItemController), "EmptySlot")] internal static class LockedSlotGuardPatches { [HarmonyPrefix] private static bool Prefix(InventorySlot emptySlot) { if (!InventoryConfig.Enabled.Value || !InventoryConfig.InfiniteUseEnabled.Value) { return true; } if (emptySlot != null && SlotConfig.LockedSlots.Contains(emptySlot)) { return false; } return true; } } internal static class Office { internal static NewRoom Room; internal static NewBuilding CityHall; internal static NewAddress CityHallAddress; internal static NewAddress OfficeAddress; private static string _originalAddressName; private static bool _loggedRename; internal static FurnitureLocation Desk; internal static Interactable Computer; internal static InteractablePreset ComputerPreset; internal static SubObject ComputerSlot; internal static bool Built; private const int MaxBuildAttempts = 3; private const int RetryCooldownFrames = 180; private static int _buildAttempts; private static int _retryAt; private static bool _gaveUp; private static string _cachedRoomName; private static string _cachedRoomNameSource; internal static ManualLogSource Log => Plugin.Logger; internal static void Reset() { Room = null; CityHall = null; CityHallAddress = null; OfficeAddress = null; _originalAddressName = null; _loggedRename = false; Desk = null; Computer = null; ComputerPreset = null; ComputerSlot = null; Built = false; _buildAttempts = 0; _retryAt = 0; _gaveUp = false; _cachedRoomName = null; _cachedRoomNameSource = null; OfficeBuilder.ResetSession(); } internal static string RoomName() { string text = OfficeConfig.TitleWord + "\u0001" + (((Object)(object)Player.Instance != (Object)null) ? ((Human)Player.Instance).GetCitizenName() : ""); if (_cachedRoomName == null || _cachedRoomNameSource != text) { _cachedRoomName = OfficeConfig.OfficeRoomName(); _cachedRoomNameSource = text; } return _cachedRoomName; } internal static bool IsOffice(NewRoom room) { return (Object)(object)room != (Object)null && (Object)(object)Room != (Object)null && ((Il2CppObjectBase)room).Pointer == ((Il2CppObjectBase)Room).Pointer; } internal static bool IsInCityHall(NewRoom room) { if ((Object)(object)room == (Object)null || (Object)(object)CityHall == (Object)null || (Object)(object)room.building == (Object)null) { return false; } return ((Il2CppObjectBase)room.building).Pointer == ((Il2CppObjectBase)CityHall).Pointer; } internal static void Build(int frame) { //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Expected O, but got Unknown //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Expected O, but got Unknown if (Built || _gaveUp || frame < _retryAt) { return; } _retryAt = frame + 180; bool flag = default(bool); if (_buildAttempts >= 3) { _gaveUp = true; ManualLogSource log = Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(87, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office setup failed "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" times; giving up for this session rather than retrying forever."); } log.LogError(val); return; } _buildAttempts++; try { OfficeLocator.Result result = OfficeLocator.Locate(); if (_buildAttempts == 1 || (Object)(object)result.Office != (Object)null) { OfficeLocator.LogSurvey(result); } if ((Object)(object)result.Office == (Object)null) { ManualLogSource log2 = Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(51, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office setup attempt "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_buildAttempts); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" found no room to convert. "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(result.Failure); } log2.LogError(val); return; } string text = OfficeLocator.RejectReason(result.Office); if (text != null && !result.OfficeWasPinned) { ManualLogSource log3 = Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(116, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Refusing to convert "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(DescribeRoom(result.Office)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Nothing was modified. Pin a suitable room with OfficeRoomNameContains or RoomIdOverride."); } log3.LogError(val); _gaveUp = true; return; } if (text != null) { ManualLogSource log4 = Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(98, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] The pinned office room would normally be rejected ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("), but it was chosen by hand, so proceeding."); } log4.LogWarning(val2); } CityHall = result.Building; CityHallAddress = (((Object)(object)result.LobbyLocation != (Object)null) ? result.LobbyLocation.thisAsAddress : null); Room = result.Office; if (OfficeConfig.DryRun.Value) { Built = true; ManualLogSource log5 = Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(96, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] DryRun is on. Would have converted "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(DescribeRoom(Room)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" into '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(RoomName()); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'. Nothing was modified. Set DryRun=false to apply."); } log5.LogWarning(val2); return; } OfficeBuilder.ClearPreviousOccupant(Room); OfficeBuilder.PlaceDeskAndComputer(Room, result); OfficeWindows.Apply(Room, CityHall); OfficeBuilder.RegisterForDecorating(Room); ApplyRoomIdentity(); Built = true; ManualLogSource log6 = Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(44, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Office ready: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(RoomName()); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (roomID "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(Room.roomID); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("). desk="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted((Desk != null) ? "yes" : "no"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" computer="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted((Computer != null) ? ((Object)Computer.preset).name : "none"); } log6.LogInfo(val3); } catch (Exception ex) { ManualLogSource log7 = Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(32, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office setup attempt "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_buildAttempts); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log7.LogError(val); } } internal static void Maintain() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown if (!Built || (Object)(object)Room == (Object)null || OfficeConfig.DryRun.Value) { return; } try { ApplyRoomIdentity(); OfficeBuilder.RegisterForDecorating(Room); if (OfficeBuilder.TerminalNeedsAdoption) { OfficeBuilder.AdoptRealTerminalConfig(); } } catch (Exception ex) { ManualLogSource log = Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(34, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office maintenance pass threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } private static void ApplyRoomIdentity() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown if ((Object)(object)Room == (Object)null) { return; } string text = RoomName(); if (Room.name != text) { Room.name = text; if (Room.name != text) { ManualLogSource log = Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(56, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Room name write rejected: wanted '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("', room reports '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Room.name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'."); } log.LogWarning(val); } } if (OfficeConfig.NameScope.Value == OfficeNameScope.Address) { ApplyAddressIdentity(text); } } private static void ApplyAddressIdentity(string wanted) { //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown NewAddress val = OfficeAddress; if ((Object)(object)val == (Object)null && (Object)(object)Room.gameLocation != (Object)null) { val = Room.gameLocation.thisAsAddress; } if ((Object)(object)val == (Object)null) { return; } OfficeAddress = val; bool flag = default(bool); try { Company company = val.company; if (company != null && company.name != wanted) { if (_originalAddressName == null) { _originalAddressName = company.name; } company.name = wanted; company.shortName = wanted; } Evidence evidenceEntry = (Evidence)(object)((NewGameLocation)val).evidenceEntry; if (evidenceEntry != null && ((CaseComponent)evidenceEntry).name != wanted) { if (_originalAddressName == null) { _originalAddressName = ((CaseComponent)evidenceEntry).name; } ((CaseComponent)evidenceEntry).name = wanted; evidenceEntry.AddOrSetCustomName((DataKey)0, wanted); } if (_loggedRename) { return; } _loggedRename = true; string text = ((val.company != null) ? val.company.name : ""); string text2 = ((((NewGameLocation)val).evidenceEntry != null) ? ((CaseComponent)((NewGameLocation)val).evidenceEntry).name : ""); ManualLogSource log = Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(89, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Renamed the office location from '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(_originalAddressName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': company now '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("', evidence now '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'. Room reports '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Room.GetName()); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'."); } log.LogInfo(val2); if (text != wanted || text2 != wanted) { ManualLogSource log2 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(96, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Location rename did not fully stick - wanted '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(wanted); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'. The map or door may still show the old name."); } log2.LogWarning(val3); } } catch (Exception ex) { ManualLogSource log3 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(39, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Renaming the office location threw: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log3.LogWarning(val3); } } internal static string DescribeRoom(NewRoom room) { if ((Object)(object)room == (Object)null) { return ""; } string value = (((SoCustomComparison)(object)room.preset != (SoCustomComparison)null) ? ((Object)room.preset).name : ""); string value2 = (((SoCustomComparison)(object)room.roomType != (SoCustomComparison)null) ? ((Object)room.roomType).name : ""); int value3 = ((room.individualFurniture != null) ? room.individualFurniture.Count : (-1)); int value4 = ((room.furniture != null) ? room.furniture.Count : (-1)); return $"roomID={room.roomID} name='{room.name}' config='{value}' type='{value2}' furniture={value3} clusters={value4}"; } internal static void DumpRoomContents(NewRoom room) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Expected O, but got Unknown if ((Object)(object)room == (Object)null) { return; } ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("--- contents of "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(DescribeRoom(room)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ---"); } log.LogInfo(val); List individualFurniture = room.individualFurniture; if (individualFurniture != null) { for (int i = 0; i < individualFurniture.Count; i++) { FurnitureLocation val2 = individualFurniture[i]; if (val2 != null) { string text = (((SoCustomComparison)(object)val2.furniture != (SoCustomComparison)null) ? ((Object)val2.furniture).name : ""); int num = ((val2.spawnedInteractables != null) ? val2.spawnedInteractables.Count : 0); int num2 = ((val2.integratedInteractables != null) ? val2.integratedInteractables.Count : 0); ManualLogSource log2 = Log; val = new BepInExInfoLogInterpolatedStringHandler(56, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" furniture["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' angle="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val2.angle); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" userPlaced="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val2.userPlaced); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" spawned="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" integrated="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num2); } log2.LogInfo(val); } } } List belongsTo = room.belongsTo; if (belongsTo != null && belongsTo.Count > 0) { StringBuilder stringBuilder = new StringBuilder(); for (int j = 0; j < belongsTo.Count; j++) { if (!((Object)(object)belongsTo[j] == (Object)null)) { if (stringBuilder.Length > 0) { stringBuilder.Append(", "); } stringBuilder.Append(belongsTo[j].GetCitizenName()); } } ManualLogSource log3 = Log; val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" room belongs to: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(stringBuilder); } log3.LogInfo(val); } else { Log.LogInfo((object)" room belongs to: nobody"); } foreach (Interactable item in EnumerateWorldObjects(room)) { string text2 = (((SoCustomComparison)(object)item.preset != (SoCustomComparison)null) ? ((Object)item.preset).name : ""); string text3 = (((Object)(object)item.belongsTo != (Object)null) ? item.belongsTo.GetCitizenName() : "-"); ManualLogSource log4 = Log; val = new BepInExInfoLogInterpolatedStringHandler(26, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" object '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' id="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(item.id); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" belongsTo="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text3); } log4.LogInfo(val); } } internal static List RoomNodes(NewRoom room) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown List list = new List(); if ((Object)(object)room == (Object)null || room.nodes == null) { return list; } try { Enumerator enumerator = room.nodes.GetEnumerator(); while (enumerator.MoveNext()) { NewNode current = enumerator.Current; if (current != null) { list.Add(current); } } } catch (Exception ex) { ManualLogSource log = Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(35, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Could not enumerate room.nodes: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } return list; } internal static Vector3 RoomCentre(NewRoom room) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) List list = RoomNodes(room); if (list.Count == 0) { return Vector3.zero; } Vector3 val = Vector3.zero; for (int i = 0; i < list.Count; i++) { val += list[i].position; } return val / (float)list.Count; } internal static List EnumerateWorldObjects(NewRoom room) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown List list = new List(); if ((Object)(object)room == (Object)null || room.worldObjects == null) { return list; } try { Enumerator enumerator = room.worldObjects.GetEnumerator(); while (enumerator.MoveNext()) { Interactable current = enumerator.Current; if (current != null) { list.Add(current); } } } catch (Exception ex) { ManualLogSource log = Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(42, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Could not enumerate room.worldObjects: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } return list; } } internal static class OfficeBuilder { private const int MaxSurplusTerminalDeletes = 8; private static string _lastPasswordLog; private const int ScanSliceSize = 4000; private static int _scanCursor; private static bool _terminalAdopted; private static bool _loggedAppRules; private const int MaxRepairsPerSession = 40; private static int _repairs; internal static bool TerminalNeedsAdoption => OfficeConfig.PlaceDesk.Value && !_terminalAdopted && Office.Computer != null; internal static void ResetSession() { _scanCursor = 0; _terminalAdopted = false; _loggedAppRules = false; _lastPasswordLog = null; _repairs = 0; OfficeWindows.ResetSession(); } internal static bool IsAlreadyConverted(NewRoom room) { List individualFurniture = room.individualFurniture; if (individualFurniture != null) { for (int i = 0; i < individualFurniture.Count; i++) { if (individualFurniture[i] != null && individualFurniture[i].userPlaced) { return true; } } } return !string.IsNullOrEmpty(room.name) && room.name.EndsWith("'s Office", StringComparison.OrdinalIgnoreCase); } internal static void ClearPreviousOccupant(NewRoom room) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown bool flag = default(bool); if (!OfficeConfig.ClearExistingContents.Value) { ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(79, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ClearExistingContents is off; leaving the room's original contents in place."); } log.LogInfo(val); return; } bool value = OfficeConfig.ForceClearOnce.Value; if (IsAlreadyConverted(room) && !value) { ManualLogSource log2 = Office.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(242, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] The office has already been converted in an earlier session; skipping the clear so the desk and anything the player has placed survive. If it still has the previous occupant's furniture in it, set ForceClearOnce=true to clear it once more."); } log2.LogInfo(val); return; } if (value) { ManualLogSource log3 = Office.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(91, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ForceClearOnce is set; clearing the office again. Furniture you placed yourself is kept."); } log3.LogInfo(val); ClearForceClearFlag(); } RemovePersonalObjects(room); RemoveOccupantFurniture(room); TransferRoomOwnership(room); } private static void ClearForceClearFlag() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown try { OfficeConfig.ForceClearOnce.Value = false; if (OfficeConfig.File != null) { OfficeConfig.File.Save(); } } catch (Exception ex) { ManualLogSource log = Office.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(133, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Could not write ForceClearOnce back to the config file ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); set it to false by hand or the office will be re-cleared on every load."); } log.LogWarning(val); } } private static void RemovePersonalObjects(NewRoom room) { //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown HashSet hashSet = ParsePresetNames(OfficeConfig.RemoveObjectPresets.Value); if (hashSet.Count == 0) { return; } List list = Office.EnumerateWorldObjects(room); int num = 0; int num2 = 0; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2; for (int i = 0; i < list.Count; i++) { Interactable val = list[i]; if (val == null || (SoCustomComparison)(object)val.preset == (SoCustomComparison)null || !hashSet.Contains(((Object)val.preset).name.ToLowerInvariant())) { continue; } try { if (!val.IsSafeToDelete(false)) { num2++; ManualLogSource log = Office.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(107, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Left '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)val.preset).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' (id "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") in place - the game reports it isn't safe to delete (it's referenced by a case or window)."); } log.LogInfo(val2); } else { val.SafeDelete(false); num++; } } catch (Exception ex) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(22, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Deleting '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((Object)val.preset).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' threw: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log2.LogWarning(val3); } } int num3 = 0; foreach (Interactable item in Office.EnumerateWorldObjects(room)) { if ((SoCustomComparison)(object)item.preset != (SoCustomComparison)null && hashSet.Contains(((Object)item.preset).name.ToLowerInvariant())) { num3++; } } ManualLogSource log3 = Office.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(71, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Personal objects: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" deleted, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" refused, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" still present after the pass."); } log3.LogInfo(val2); } private static void RemoveOccupantFurniture(NewRoom room) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown int num = FurnitureCount(room); bool flag = default(bool); try { room.RemoveAllInhabitantFurniture(true, (RemoveInteractablesOption)1); } catch (Exception ex) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(39, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] RemoveAllInhabitantFurniture threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } int num2 = FurnitureCount(room); ManualLogSource log2 = Office.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(87, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Occupant furniture: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" pieces before, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" after the game's own inhabitant-furniture pass."); } log2.LogInfo(val2); StripRemainingFurniture(room); } private static void StripRemainingFurniture(NewRoom room) { //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Expected O, but got Unknown //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Expected O, but got Unknown HashSet keep = ParsePresetNames(OfficeConfig.KeepFurniturePresets.Value); int num = Math.Max(0, OfficeConfig.MaxClearedFurniture.Value); List list = new List(); List list2 = new List(); List individualFurniture = room.individualFurniture; bool flag = default(bool); if (individualFurniture == null) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(74, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] The office room lists no furniture collection at all; nothing to strip."); } log.LogWarning(val); return; } for (int i = 0; i < individualFurniture.Count; i++) { FurnitureLocation val2 = individualFurniture[i]; if (val2 != null && !((SoCustomComparison)(object)val2.furniture == (SoCustomComparison)null)) { string text = KeepReason(val2, keep); if (text != null) { list2.Add(((Object)val2.furniture).name + " (" + text + ")"); } else { list.Add(val2); } } } BepInExInfoLogInterpolatedStringHandler val3; if (list.Count == 0) { ManualLogSource log2 = Office.Log; val3 = new BepInExInfoLogInterpolatedStringHandler(59, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Nothing left to strip from the office; "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(list2.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" piece(s) kept: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(Join(list2)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } log2.LogInfo(val3); return; } if (list.Count > num) { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(161, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" pieces of furniture are due for deletion but MaxClearedFurniture is "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; only the first "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" will go. Raise the cap if the office is meant to be emptied completely."); } log3.LogWarning(val); list.RemoveRange(num, list.Count - num); } int num2 = 0; for (int j = 0; j < list.Count; j++) { try { list[j].Delete(true, (RemoveInteractablesOption)1); num2++; } catch (Exception ex) { ManualLogSource log4 = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(22, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Deleting '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((SoCustomComparison)(object)list[j].furniture != (SoCustomComparison)null) ? ((Object)list[j].furniture).name : "?"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log4.LogWarning(val); } } List list3 = new List(); List individualFurniture2 = room.individualFurniture; if (individualFurniture2 != null) { for (int k = 0; k < individualFurniture2.Count; k++) { FurnitureLocation val4 = individualFurniture2[k]; if (val4 != null && !((SoCustomComparison)(object)val4.furniture == (SoCustomComparison)null) && KeepReason(val4, keep) == null) { list3.Add(((Object)val4.furniture).name); } } } ManualLogSource log5 = Office.Log; val3 = new BepInExInfoLogInterpolatedStringHandler(72, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Stripped the office: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" of "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" piece(s) deleted, room now lists "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(FurnitureCount(room)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(". Kept "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(list2.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(Join(list2)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } log5.LogInfo(val3); if (list3.Count > 0) { ManualLogSource log6 = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(137, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(list3.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" piece(s) refused to delete and are still in the office: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Join(list3)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Add them to KeepFurniturePresets if they are meant to stay, or report them."); } log6.LogWarning(val); } } private static string KeepReason(FurnitureLocation f, HashSet keep) { if (f.userPlaced) { return "placed by you"; } FurniturePreset furniture = f.furniture; if (keep.Contains(((Object)furniture).name.ToLowerInvariant())) { return "in KeepFurniturePresets"; } if (furniture.alterAreaLighting || furniture.lightAmount > 0f) { return "lights the room"; } return null; } private static int FurnitureCount(NewRoom room) { return (room.individualFurniture != null) ? room.individualFurniture.Count : (-1); } private static string Join(List names) { if (names.Count == 0) { return "none"; } if (names.Count <= 16) { return string.Join(", ", names); } return string.Join(", ", names.GetRange(0, 16)) + $", +{names.Count - 16} more"; } private static void TransferRoomOwnership(NewRoom room) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown List belongsTo = room.belongsTo; if (belongsTo == null) { return; } int count = belongsTo.Count; bool flag = default(bool); try { belongsTo.Clear(); if ((Object)(object)Player.Instance != (Object)null) { room.AddOwner((Human)(object)Player.Instance); } } catch (Exception ex) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(37, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Reassigning room ownership threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); return; } bool flag2 = false; List belongsTo2 = room.belongsTo; if (belongsTo2 != null && (Object)(object)Player.Instance != (Object)null) { for (int i = 0; i < belongsTo2.Count; i++) { if ((Object)(object)belongsTo2[i] != (Object)null && ((Il2CppObjectBase)belongsTo2[i]).Pointer == ((Il2CppObjectBase)Player.Instance).Pointer) { flag2 = true; } } } if (flag2) { ManualLogSource log2 = Office.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(62, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Room ownership moved from "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" previous owner(s) to the player."); } log2.LogInfo(val2); } else { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(98, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Room ownership write did not stick - the room still reports "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(belongsTo2?.Count ?? (-1)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" owner(s), none of them the player."); } log3.LogWarning(val); } } private static HashSet ParsePresetNames(string csv) { HashSet hashSet = new HashSet(); if (string.IsNullOrEmpty(csv)) { return hashSet; } string[] array = csv.Split(','); foreach (string text in array) { string text2 = text.Trim().ToLowerInvariant(); if (text2.Length > 0) { hashSet.Add(text2); } } return hashSet; } internal static void PlaceDeskAndComputer(NewRoom room, OfficeLocator.Result located) { //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Expected O, but got Unknown //IL_06b8: Unknown result type (might be due to invalid IL or missing references) //IL_06bf: Expected O, but got Unknown //IL_0945: Unknown result type (might be due to invalid IL or missing references) //IL_094c: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0737: Unknown result type (might be due to invalid IL or missing references) //IL_073e: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Expected O, but got Unknown //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_0607: Expected O, but got Unknown //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Expected O, but got Unknown //IL_07c6: Unknown result type (might be due to invalid IL or missing references) //IL_07cb: Unknown result type (might be due to invalid IL or missing references) //IL_0a02: Unknown result type (might be due to invalid IL or missing references) //IL_0a09: Expected O, but got Unknown //IL_0825: Unknown result type (might be due to invalid IL or missing references) //IL_082c: Expected O, but got Unknown //IL_08a2: Unknown result type (might be due to invalid IL or missing references) //IL_08a9: Expected O, but got Unknown //IL_08ef: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Expected O, but got Unknown if (!OfficeConfig.PlaceDesk.Value) { return; } OfficeLocator.ComputerInfo computerInfo = ChooseComputer(located); bool flag = default(bool); if (computerInfo == null || (SoCustomComparison)(object)computerInfo.Preset == (SoCustomComparison)null) { ManualLogSource log = Office.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(118, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] No computer preset could be resolved; skipping desk placement so the office isn't left with a desk and no terminal."); } log.LogError(val); return; } FurniturePreset val2 = computerInfo.Desk; SubObject slot = computerInfo.Slot; string value = OfficeConfig.DeskPresetName.Value; if (!string.IsNullOrEmpty(value)) { FurniturePreset val3 = FindFurniturePreset(value); if ((SoCustomComparison)(object)val3 != (SoCustomComparison)null) { val2 = val3; slot = FindSlotForComputer(val3, computerInfo.Preset); if (slot == null) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(88, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] DeskPresetName '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' has no slot that accepts '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Object)computerInfo.Preset).name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("'; the computer will not be placed on it."); } log2.LogWarning(val4); } } else { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(104, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] DeskPresetName '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' matched no furniture preset; using the desk the game itself uses for this computer."); } log3.LogWarning(val4); } } BepInExInfoLogInterpolatedStringHandler val5; if ((SoCustomComparison)(object)val2 == (SoCustomComparison)null) { val2 = FindDeskWithComputerSlot(out slot); if ((SoCustomComparison)(object)val2 != (SoCustomComparison)null) { ManualLogSource log4 = Office.Log; val5 = new BepInExInfoLogInterpolatedStringHandler(99, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] No computer in the world was linked to furniture yet; using '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(((Object)val2).name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("', found by its '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(OfficeConfig.ComputerSlotClassName.Value); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' sub-object slot."); } log4.LogInfo(val5); } } if ((SoCustomComparison)(object)val2 == (SoCustomComparison)null) { ManualLogSource log5 = Office.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(90, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] No desk could be resolved for computer '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)computerInfo.Preset).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'. Set DeskPresetName to choose one explicitly."); } log5.LogError(val); return; } ManualLogSource log6 = Office.Log; val5 = new BepInExInfoLogInterpolatedStringHandler(86, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Using desk '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(((Object)val2).name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' and computer '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(((Object)computerInfo.Preset).name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' (slot '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted((slot != null && (SoCustomComparison)(object)slot.preset != (SoCustomComparison)null) ? ((Object)slot.preset).name : "none"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("'), copied from "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(computerInfo.Count); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" real machine(s) in this city."); } log6.LogInfo(val5); FurnitureLocation val6 = FindExistingDesk(room, val2); if (OfficeConfig.DeskChosenByPlayer && string.Equals(((Object)val2).name, OfficeConfig.DeskPresetName.Value, StringComparison.OrdinalIgnoreCase) && val6 != null && (SoCustomComparison)(object)val6.furniture != (SoCustomComparison)null && ((Il2CppObjectBase)val6.furniture).Pointer != ((Il2CppObjectBase)val2).Pointer) { ManualLogSource log7 = Office.Log; val5 = new BepInExInfoLogInterpolatedStringHandler(68, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] DeskPresetName asks for '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(((Object)val2).name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' but the office has a '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(((Object)val6.furniture).name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("'; replacing it."); } log7.LogInfo(val5); try { val6.Delete(true, (RemoveInteractablesOption)1); } catch (Exception ex) { ManualLogSource log8 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(37, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Deleting the previous desk threw: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex.Message); } log8.LogWarning(val4); } val6 = null; } if (val6 != null && (SoCustomComparison)(object)val6.furniture != (SoCustomComparison)null && ((Il2CppObjectBase)val6.furniture).Pointer != ((Il2CppObjectBase)val2).Pointer) { SubObject val7 = FindSlotForComputer(val6.furniture, computerInfo.Preset); if (val7 != null) { ManualLogSource log9 = Office.Log; val5 = new BepInExInfoLogInterpolatedStringHandler(114, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] The office already has a '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(((Object)val6.furniture).name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' this mod placed in an earlier session; keeping it rather than adding a second desk."); } log9.LogInfo(val5); val2 = val6.furniture; slot = val7; } else { ManualLogSource log10 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(113, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] The office already has a '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Object)val6.furniture).name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' from an earlier session, but it has no slot that accepts '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Object)computerInfo.Preset).name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("'. Replacing it with '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Object)val2).name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("'."); } log10.LogWarning(val4); try { val6.Delete(true, (RemoveInteractablesOption)1); } catch (Exception ex2) { ManualLogSource log11 = Office.Log; val4 = new BepInExWarningLogInterpolatedStringHandler(32, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Deleting the old desk threw: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex2.Message); } log11.LogWarning(val4); } val6 = null; } } NewNode door = FindRoomDoorNode(room); NewNode val8 = FindDeskAnchorNode(room, door, val6); if (val8 == null) { ManualLogSource log12 = Office.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(81, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] The office room has no node that accepts new furniture; cannot place the desk."); } log12.LogError(val); return; } int num = ComputeDoorFacingAngle(val8, door); FurnitureLocation val9 = val6; if (val9 != null) { string text = $"node {((val9.anchorNode != null) ? ((object)val9.anchorNode.nodeCoord/*cast due to .constrained prefix*/).ToString() : "?")} angle {val9.angle}"; if (!OfficeConfig.RepositionDeskOnLoad.Value) { ManualLogSource log13 = Office.Log; val5 = new BepInExInfoLogInterpolatedStringHandler(101, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Keeping the existing office desk at "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" (RepositionDeskOnLoad is off, so this is its permanent home)."); } log13.LogInfo(val5); } else if (!IsDeskWhereWeWantIt(val9, val8, num)) { ManualLogSource log14 = Office.Log; val5 = new BepInExInfoLogInterpolatedStringHandler(64, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Existing desk is at "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", want node "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(val8.nodeCoord); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" angle "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("; moving it this once."); } log14.LogInfo(val5); try { val9.Delete(true, (RemoveInteractablesOption)1); } catch (Exception ex3) { ManualLogSource log15 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(38, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Deleting the misplaced desk threw: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex3.Message); } log15.LogWarning(val4); } val9 = null; } if (OfficeConfig.RepositionDeskOnLoad.Value) { ClearRepositionFlag(); } } if (val9 == null) { val9 = PlaceDesk(room, val2, val8, num); } if (val9 == null) { return; } Office.Desk = val9; Office.ComputerPreset = computerInfo.Preset; Office.ComputerSlot = slot; if (slot == null) { ManualLogSource log16 = Office.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(95, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] No sub-object slot available for the computer; the desk was placed but the terminal was not."); } log16.LogError(val); } else { EnsureComputer(room, val9, slot, computerInfo.Preset, deepScan: true); } } private static OfficeLocator.ComputerInfo ChooseComputer(OfficeLocator.Result located) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Expected O, but got Unknown string configured = OfficeConfig.ComputerPresetName.Value; bool flag = default(bool); if (!string.IsNullOrEmpty(configured)) { OfficeLocator.ComputerInfo computerInfo = located.Computers.Find((OfficeLocator.ComputerInfo c) => (SoCustomComparison)(object)c.Preset != (SoCustomComparison)null && string.Equals(((Object)c.Preset).name, configured, StringComparison.OrdinalIgnoreCase)); if (computerInfo != null) { return computerInfo; } InteractablePreset val = LookupInteractablePreset(configured); BepInExWarningLogInterpolatedStringHandler val2; if ((SoCustomComparison)(object)val != (SoCustomComparison)null) { ManualLogSource log = Office.Log; val2 = new BepInExWarningLogInterpolatedStringHandler(117, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] ComputerPresetName '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(configured); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' exists but no example of it was found in this city, so there is no desk arrangement to copy."); } log.LogWarning(val2); return new OfficeLocator.ComputerInfo { Preset = val }; } ManualLogSource log2 = Office.Log; val2 = new BepInExWarningLogInterpolatedStringHandler(86, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] ComputerPresetName '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(configured); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' is not a known object preset; falling back to auto-detection."); } log2.LogWarning(val2); } OfficeLocator.ComputerInfo computerInfo2 = null; for (int num = 0; num < located.Computers.Count; num++) { OfficeLocator.ComputerInfo computerInfo3 = located.Computers[num]; if ((SoCustomComparison)(object)computerInfo3.Preset == (SoCustomComparison)null || (SoCustomComparison)(object)computerInfo3.Desk == (SoCustomComparison)null) { continue; } if (computerInfo2 == null) { computerInfo2 = computerInfo3; } else if (computerInfo3.AddressRestrictedApps != computerInfo2.AddressRestrictedApps) { if (computerInfo3.AddressRestrictedApps) { computerInfo2 = computerInfo3; } } else if (computerInfo3.Count > computerInfo2.Count) { computerInfo2 = computerInfo3; } } if (computerInfo2 == null) { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(161, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] No computer anywhere in the city was found sitting on furniture; falling back to the generic cruncher preset, which may not carry the government database app."); } log3.LogWarning(val2); InteractablePreset val3 = (((Object)(object)InteriorControls.Instance != (Object)null) ? InteriorControls.Instance.cruncher : null); return ((SoCustomComparison)(object)val3 != (SoCustomComparison)null) ? new OfficeLocator.ComputerInfo { Preset = val3 } : null; } return computerInfo2; } private static InteractablePreset LookupInteractablePreset(string name) { Dictionary val = (((Object)(object)Toolbox.Instance != (Object)null) ? Toolbox.Instance.objectPresetDictionary : null); if (val == null) { return null; } InteractablePreset val2 = null; return val.TryGetValue(name, ref val2) ? val2 : null; } private static FurniturePreset FindFurniturePreset(string name) { List val = (((Object)(object)Toolbox.Instance != (Object)null) ? Toolbox.Instance.allFurniture : null); if (val == null) { return null; } for (int i = 0; i < val.Count; i++) { if ((SoCustomComparison)(object)val[i] != (SoCustomComparison)null && string.Equals(((Object)val[i]).name, name, StringComparison.OrdinalIgnoreCase)) { return val[i]; } } return null; } private static FurniturePreset FindDeskWithComputerSlot(out SubObject slot) { slot = null; List val = (((Object)(object)Toolbox.Instance != (Object)null) ? Toolbox.Instance.allFurniture : null); if (val == null) { return null; } string value = OfficeConfig.ComputerSlotClassName.Value; FurniturePreset val2 = null; SubObject val3 = null; for (int i = 0; i < val.Count; i++) { FurniturePreset val4 = val[i]; if ((SoCustomComparison)(object)val4 == (SoCustomComparison)null || val4.subObjects == null) { continue; } SubObject val5 = null; for (int j = 0; j < val4.subObjects.Count; j++) { if (val5 != null) { break; } SubObject val6 = val4.subObjects[j]; if (val6 != null && (SoCustomComparison)(object)val6.preset != (SoCustomComparison)null && string.Equals(((Object)val6.preset).name, value, StringComparison.OrdinalIgnoreCase)) { val5 = val6; } } if (val5 != null) { bool flag = ((Object)val4).name.IndexOf("desk", StringComparison.OrdinalIgnoreCase) >= 0; if ((SoCustomComparison)(object)val2 == (SoCustomComparison)null || (flag && ((Object)val2).name.IndexOf("desk", StringComparison.OrdinalIgnoreCase) < 0)) { val2 = val4; val3 = val5; } } } slot = val3; return val2; } private static SubObject FindSlotForComputer(FurniturePreset desk, InteractablePreset computerPreset) { if (desk.subObjects == null) { return null; } string value = OfficeConfig.ComputerSlotClassName.Value; for (int i = 0; i < desk.subObjects.Count; i++) { SubObject val = desk.subObjects[i]; if (val == null || (SoCustomComparison)(object)val.preset == (SoCustomComparison)null) { continue; } if (string.Equals(((Object)val.preset).name, value, StringComparison.OrdinalIgnoreCase)) { return val; } if (computerPreset.subObjectClasses == null) { continue; } for (int j = 0; j < computerPreset.subObjectClasses.Count; j++) { SubObjectClassPreset val2 = computerPreset.subObjectClasses[j]; if ((SoCustomComparison)(object)val2 != (SoCustomComparison)null && ((Il2CppObjectBase)val2).Pointer == ((Il2CppObjectBase)val.preset).Pointer) { return val; } } } return null; } private static FurnitureLocation FindExistingDesk(NewRoom room, FurniturePreset deskPreset) { //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown List individualFurniture = room.individualFurniture; if (individualFurniture == null) { return null; } FurnitureLocation val = null; List list = new List(); for (int i = 0; i < 2; i++) { if (val != null) { break; } if (list.Count != 0) { break; } for (int j = 0; j < individualFurniture.Count; j++) { FurnitureLocation val2 = individualFurniture[j]; if (val2 != null && !((SoCustomComparison)(object)val2.furniture == (SoCustomComparison)null) && val2.userPlaced && ((i == 0) ? (((Il2CppObjectBase)val2.furniture).Pointer == ((Il2CppObjectBase)deskPreset).Pointer) : HasComputerSlot(val2.furniture))) { if (val == null) { val = val2; } else { list.Add(val2); } } } } if (list.Count > 0) { ManualLogSource log = Office.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(73, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Found "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" duplicate office desk(s) from previous sessions; deleting them."); } log.LogWarning(val3); for (int k = 0; k < list.Count && k < 32; k++) { try { list[k].Delete(true, (RemoveInteractablesOption)1); } catch (Exception ex) { ManualLogSource log2 = Office.Log; val3 = new BepInExWarningLogInterpolatedStringHandler(36, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Deleting a duplicate desk threw: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log2.LogWarning(val3); } } } return val; } private static bool HasComputerSlot(FurniturePreset preset) { if (preset.subObjects == null) { return false; } string value = OfficeConfig.ComputerSlotClassName.Value; for (int i = 0; i < preset.subObjects.Count; i++) { SubObject val = preset.subObjects[i]; if (val != null && (SoCustomComparison)(object)val.preset != (SoCustomComparison)null && string.Equals(((Object)val.preset).name, value, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private static void ClearRepositionFlag() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown bool flag = default(bool); try { OfficeConfig.RepositionDeskOnLoad.Value = false; if (OfficeConfig.File != null) { OfficeConfig.File.Save(); } ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(125, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] RepositionDeskOnLoad has been set back to false. The desk will not be moved again - wherever you put it is where it stays."); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(126, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Could not write RepositionDeskOnLoad back to the config file ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("); set it to false by hand or the desk will keep being moved."); } log2.LogWarning(val2); } } private static bool IsDeskWhereWeWantIt(FurnitureLocation desk, NewNode anchor, int angle) { if (desk.anchorNode == null || anchor == null) { return false; } return ((Il2CppObjectBase)desk.anchorNode).Pointer == ((Il2CppObjectBase)anchor).Pointer && desk.angle == angle; } private static FurnitureLocation PlaceDesk(NewRoom room, FurniturePreset deskPreset, NewNode anchor, int angle) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) List val = new List(); val.Add(anchor); FurniturePlacement val2 = new FurniturePlacement { preset = deskPreset, anchorNode = anchor, coversNodes = val, angle = angle, offset = Vector3.zero }; FurnitureLocation val3; bool flag = default(bool); try { val3 = room.AddFurnitureCustom(val2); } catch (Exception ex) { ManualLogSource log = Office.Log; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(46, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] AddFurnitureCustom threw placing the desk: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex); } log.LogError(val4); return null; } if (val3 == null) { ManualLogSource log2 = Office.Log; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(77, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] AddFurnitureCustom returned null; the desk was not placed at node "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(anchor.nodeCoord); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" angle "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(angle); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("."); } log2.LogError(val4); return null; } val3.userPlaced = true; try { val3.SpawnObject(true); val3.CreateInteractables(); } catch (Exception ex2) { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(35, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Spawning the desk object threw: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(ex2.Message); } log3.LogWarning(val5); } bool flag2 = false; List individualFurniture = room.individualFurniture; if (individualFurniture != null) { for (int i = 0; i < individualFurniture.Count; i++) { if (individualFurniture[i] != null && ((Il2CppObjectBase)individualFurniture[i]).Pointer == ((Il2CppObjectBase)val3).Pointer) { flag2 = true; } } } if (!flag2) { ManualLogSource log4 = Office.Log; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(97, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] The desk was created but the room does not list it; deleting it rather than leaving an orphan."); } log4.LogError(val4); try { val3.Delete(true, (RemoveInteractablesOption)1); } catch { } return null; } ManualLogSource log5 = Office.Log; BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(76, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("] Desk placed at node "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(anchor.nodeCoord); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(anchor.position); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("), angle "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(angle); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(", placement="); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(OfficeConfig.DeskPosition.Value); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(", roomCentre="); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(Office.RoomCentre(room)); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(", spawnedObject="); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(((Object)(object)val3.spawnedObject != (Object)null) ? "yes" : "no"); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("."); } log5.LogInfo(val6); return val3; } internal static NewNode FindRoomDoorNode(NewRoom room) { //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) List entrances = room.entrances; if (entrances == null || entrances.Count == 0) { return null; } NewNode val = null; NewNode val2 = null; for (int i = 0; i < entrances.Count; i++) { NodeAccess val3 = entrances[i]; if (val3 == null || val3.fromNode == null || val3.toNode == null) { continue; } bool flag = (Object)(object)val3.fromNode.room != (Object)null && ((Il2CppObjectBase)val3.fromNode.room).Pointer == ((Il2CppObjectBase)room).Pointer; bool flag2 = (Object)(object)val3.toNode.room != (Object)null && ((Il2CppObjectBase)val3.toNode.room).Pointer == ((Il2CppObjectBase)room).Pointer; if (flag || flag2) { NewNode val4 = (flag ? val3.fromNode : val3.toNode); NewRoom val5 = (flag ? val3.toNode.room : val3.fromNode.room); if (val2 == null) { val2 = val4; } if (((Object)(object)val5 == (Object)null || (Object)(object)val5.gameLocation == (Object)null || (Object)(object)room.gameLocation == (Object)null || ((Il2CppObjectBase)val5.gameLocation).Pointer != ((Il2CppObjectBase)room.gameLocation).Pointer) && val == null) { val = val4; } } } if (val == null && val2 != null) { ManualLogSource log = Office.Log; bool flag3 = default(bool); BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(92, 2, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("] No doorway out of the office's own address was found; measuring desk depth from "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(val2.nodeCoord); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" instead."); } log.LogInfo(val6); } return val ?? val2; } private static NewNode FindDeskAnchorNode(NewRoom room, NewNode door, FurnitureLocation existingDesk) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Expected O, but got Unknown //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0578: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Expected O, but got Unknown //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) NewNode val = ((existingDesk != null) ? existingDesk.anchorNode : null); List list = Office.RoomNodes(room); if (list.Count == 0) { return null; } DeskPlacement value = OfficeConfig.DeskPosition.Value; Vector3 val2 = Office.RoomCentre(room); Vector3 val3 = val2 - ((door != null) ? door.position : val2); val3.y = 0f; bool flag = ((Vector3)(ref val3)).sqrMagnitude > 0.0001f; if (flag) { val3 = ((Vector3)(ref val3)).normalized; } Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(val3.z, 0f, 0f - val3.x); float num = 0f; if (flag) { for (int i = 0; i < list.Count; i++) { Vector3 val5 = list[i].position - door.position; val5.y = 0f; num = Math.Max(num, Vector3.Dot(val5, val3)); } } float num2 = num * Mathf.Clamp01(OfficeConfig.DeskDepthFraction.Value); NewNode val6 = null; NewNode val7 = null; float num3 = float.NegativeInfinity; for (int j = 0; j < list.Count; j++) { NewNode val8 = list[j]; if (val7 == null) { val7 = val8; } bool flag2 = val != null && ((Il2CppObjectBase)val8).Pointer == ((Il2CppObjectBase)val).Pointer; if (val8.allowNewFurniture || flag2) { float num4; if (value == DeskPlacement.Centre) { num4 = 0f - Vector3.Distance(val8.position, val2); } else if (value == DeskPlacement.FarFromDoor || !flag) { num4 = ((door != null) ? Vector3.Distance(val8.position, door.position) : 0f); } else { Vector3 val9 = val8.position - door.position; val9.y = 0f; float num5 = Vector3.Dot(val9, val3); Vector3 val10 = val8.position - val2; val10.y = 0f; float num6 = Math.Abs(Vector3.Dot(val10, val4)); num4 = ((value == DeskPlacement.DepthFraction) ? (0f - (Math.Abs(num5 - num2) + 1.5f * num6)) : (num5 - 2f * num6)); } if (num4 > num3) { num3 = num4; val6 = val8; } } } bool flag3 = default(bool); if (val6 != null && flag && value == DeskPlacement.DepthFraction) { Vector3 val11 = val6.position - door.position; val11.y = 0f; float num7 = Vector3.Dot(val11, val3); ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val12 = new BepInExInfoLogInterpolatedStringHandler(82, 7, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val12).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val12).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val12).AppendLiteral("] Desk depth: door at "); ((BepInExLogInterpolatedStringHandler)val12).AppendFormatted(door.nodeCoord); ((BepInExLogInterpolatedStringHandler)val12).AppendLiteral(", room runs "); ((BepInExLogInterpolatedStringHandler)val12).AppendFormatted(num, "F1"); ((BepInExLogInterpolatedStringHandler)val12).AppendLiteral("m from it, target "); ((BepInExLogInterpolatedStringHandler)val12).AppendFormatted(OfficeConfig.DeskDepthFraction.Value, "P0"); ((BepInExLogInterpolatedStringHandler)val12).AppendLiteral(" = "); ((BepInExLogInterpolatedStringHandler)val12).AppendFormatted(num2, "F1"); ((BepInExLogInterpolatedStringHandler)val12).AppendLiteral("m, chosen node "); ((BepInExLogInterpolatedStringHandler)val12).AppendFormatted(val6.nodeCoord); ((BepInExLogInterpolatedStringHandler)val12).AppendLiteral(" sits at "); ((BepInExLogInterpolatedStringHandler)val12).AppendFormatted(num7, "F1"); ((BepInExLogInterpolatedStringHandler)val12).AppendLiteral("m."); } log.LogInfo(val12); if (OfficeConfig.VerboseDiagnostics.Value) { StringBuilder stringBuilder = new StringBuilder(); for (int k = 0; k < list.Count; k++) { Vector3 val13 = list[k].position - door.position; val13.y = 0f; Vector3 val14 = list[k].position - val2; val14.y = 0f; if (stringBuilder.Length > 0) { stringBuilder.Append("; "); } StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(18, 4, stringBuilder2); handler.AppendFormatted(list[k].nodeCoord); handler.AppendLiteral(" depth="); handler.AppendFormatted(Vector3.Dot(val13, val3), "F1"); handler.AppendLiteral(" lat="); handler.AppendFormatted(Math.Abs(Vector3.Dot(val14, val4)), "F1"); handler.AppendLiteral(" free="); handler.AppendFormatted(list[k].allowNewFurniture); stringBuilder2.Append(ref handler); } ManualLogSource log2 = Office.Log; val12 = new BepInExInfoLogInterpolatedStringHandler(17, 2, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val12).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val12).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val12).AppendLiteral("] Office nodes: "); ((BepInExLogInterpolatedStringHandler)val12).AppendFormatted(stringBuilder); } log2.LogInfo(val12); } } if (val6 == null && val7 != null) { val6 = val7; ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val15 = new BepInExWarningLogInterpolatedStringHandler(66, 2, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val15).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val15).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val15).AppendLiteral("] No node in the office allows new furniture; using node "); ((BepInExLogInterpolatedStringHandler)val15).AppendFormatted(val6.nodeCoord); ((BepInExLogInterpolatedStringHandler)val15).AppendLiteral(" anyway."); } log3.LogWarning(val15); } return val6; } private static int ComputeDoorFacingAngle(NewNode anchor, NewNode door) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) int num = 0; if (door != null) { Vector3 val = anchor.position - door.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.0001f) { float num2 = Mathf.Atan2(val.x, val.z) * 57.29578f; num = Mathf.RoundToInt(num2 / 90f) * 90; } } num += OfficeConfig.DeskAngleOffset.Value; num %= 360; if (num < 0) { num += 360; } return num; } internal static void EnsureComputer(NewRoom room, FurnitureLocation desk, SubObject slot, InteractablePreset computerPreset, bool deepScan) { //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown if ((Object)(object)room == (Object)null || desk == null || slot == null || (SoCustomComparison)(object)computerPreset == (SoCustomComparison)null) { return; } List list = new List(); foreach (Interactable item in CollectComputers(room, desk, computerPreset, deepScan)) { FurnitureLocation furnitureParent = item.furnitureParent; if (furnitureParent == null || ((Il2CppObjectBase)furnitureParent).Pointer == ((Il2CppObjectBase)desk).Pointer) { list.Add(item); } } Interactable val = ChooseTerminal(list); if (val != null && list.Count > 1) { DeleteSurplusTerminals(list, val, desk, computerPreset); } if (val != null && (val.furnitureParent == null || ((Il2CppObjectBase)val.furnitureParent).Pointer != ((Il2CppObjectBase)desk).Pointer)) { bool flag = default(bool); try { val.ConvertToFurnitureSpawnedObject(desk, slot, true, true); ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(47, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Re-attached office terminal id "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" to the desk."); } log.LogInfo(val2); } catch (Exception ex) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(36, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Re-attaching terminal id "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val.id); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" threw: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log2.LogWarning(val3); val = null; } } if (val == null) { val = PlaceComputer(desk, slot, computerPreset); } if (val != null) { ApplyPasswordSource(val, room, computerPreset); Office.Computer = val; LogAppInstallRules(room, computerPreset); } } private static Interactable ChooseTerminal(List candidates) { Interactable val = null; int num = int.MinValue; for (int i = 0; i < candidates.Count; i++) { Interactable val2 = candidates[i]; int num2 = 0; try { if ((Object)(object)val2.belongsTo != (Object)null || val2.passwordSource != null) { num2 += 4; } if (val2.furnitureParent != null) { num2 += 2; } } catch { num2 = -2147483647; } if (val == null || num2 > num || (num2 == num && val2.id < val.id)) { val = val2; num = num2; } } return val; } private static void DeleteSurplusTerminals(List all, Interactable keep, FurnitureLocation desk, InteractablePreset computerPreset) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Expected O, but got Unknown int num = 0; int num2 = 0; bool flag = default(bool); for (int i = 0; i < all.Count; i++) { if (num >= 8) { break; } Interactable val = all[i]; if (((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)keep).Pointer) { continue; } try { if (!val.IsSafeToDelete(false)) { num2++; continue; } val.SafeDelete(false); num++; } catch (Exception ex) { num2++; ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(47, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Deleting surplus office terminal id "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log.LogWarning(val2); } } int num3 = 0; List spawnedInteractables = desk.spawnedInteractables; if (spawnedInteractables != null) { for (int j = 0; j < spawnedInteractables.Count; j++) { Interactable val3 = spawnedInteractables[j]; if (val3 != null && (SoCustomComparison)(object)val3.preset != (SoCustomComparison)null && ((Il2CppObjectBase)val3.preset).Pointer == ((Il2CppObjectBase)computerPreset).Pointer) { num3++; } } } ManualLogSource log2 = Office.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(101, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] The office had "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(all.Count); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" terminals where it should have 1; kept id "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(keep.id); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", deleted "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", refused "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(". Desk now carries "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("."); } log2.LogInfo(val4); if (num3 > 1) { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(138, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] The desk still lists "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" terminals after the cleanup pass. Pick the spare one up and drop it somewhere outside the office, or report this."); } log3.LogWarning(val2); } } private static List CollectComputers(NewRoom room, FurnitureLocation desk, InteractablePreset computerPreset, bool deepScan) { List found = new List(); HashSet seen = new HashSet(); List spawnedInteractables = desk.spawnedInteractables; if (spawnedInteractables != null) { for (int i = 0; i < spawnedInteractables.Count; i++) { Consider(spawnedInteractables[i]); } } foreach (Interactable item in Office.EnumerateWorldObjects(room)) { Consider(item); } if (!deepScan) { return found; } List val = (((Object)(object)CityData.Instance != (Object)null) ? CityData.Instance.interactableDirectory : null); if (val == null) { return found; } for (int j = 0; j < val.Count; j++) { Interactable val2 = val[j]; if (val2 != null && !((SoCustomComparison)(object)val2.preset == (SoCustomComparison)null) && !(((Il2CppObjectBase)val2.preset).Pointer != ((Il2CppObjectBase)computerPreset).Pointer) && ((val2.furnitureParent != null && ((Il2CppObjectBase)val2.furnitureParent).Pointer == ((Il2CppObjectBase)desk).Pointer) || (val2.node != null && (Object)(object)val2.node.room != (Object)null && ((Il2CppObjectBase)val2.node.room).Pointer == ((Il2CppObjectBase)room).Pointer))) { Consider(val2); } } return found; void Consider(Interactable obj) { if (obj != null && !((SoCustomComparison)(object)obj.preset == (SoCustomComparison)null) && !(((Il2CppObjectBase)obj.preset).Pointer != ((Il2CppObjectBase)computerPreset).Pointer) && seen.Add(((Il2CppObjectBase)obj).Pointer)) { found.Add(obj); } } } private static void ApplyPasswordSource(Interactable computer, NewRoom room, InteractablePreset computerPreset) { //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown bool flag = default(bool); try { Object val = null; RoomPasswordPreference passwordSource = computerPreset.passwordSource; RoomPasswordPreference val2 = passwordSource; string value; if ((int)val2 != 1) { if ((int)val2 == 2) { val = (Object)(object)(((Object)(object)room.gameLocation != (Object)null) ? room.gameLocation.thisAsAddress : null); value = "office address"; } else { value = "owner"; } } else { val = (Object)(object)room; value = "office room"; } if (val != null) { computer.SetPasswordSource(val); } Passcode passwordSource2 = computer.GetPasswordSource(); string text = ""; if (passwordSource2 != null && passwordSource2.digits != null) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < passwordSource2.digits.Count; i++) { stringBuilder.Append(passwordSource2.digits[i]); } text = stringBuilder.ToString(); } string text2 = $"Terminal id {computer.id}: passwordSource={computerPreset.passwordSource} via {value}, passcode digits={text}, belongsTo={(((Object)(object)computer.belongsTo != (Object)null) ? computer.belongsTo.GetCitizenName() : "nobody")}."; if (!(text2 != _lastPasswordLog)) { return; } _lastPasswordLog = text2; ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(3, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text2); } log.LogInfo(val3); if (text == "") { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(103, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] The office terminal still resolves no passcode, so its login screen cannot be satisfied by any code."); } log2.LogWarning(val4); } } catch (Exception ex) { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(49, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Setting the terminal's password source threw: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex.Message); } log3.LogWarning(val4); } } private static Interactable PlaceComputer(FurnitureLocation desk, SubObject slot, InteractablePreset computerPreset) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Expected O, but got Unknown Interactable val; bool flag = default(bool); try { val = InteractableCreator.Instance.CreateFurnitureSpawnedInteractable(computerPreset, desk, slot, (Human)null, (Human)null, (Human)null, (List)null, (LightingPreset)null, (Object)null, ""); } catch (Exception ex) { ManualLogSource log = Office.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(66, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] CreateFurnitureSpawnedInteractable threw placing the computer: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log.LogError(val2); return null; } if (val == null) { ManualLogSource log2 = Office.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(44, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] The computer interactable came back null."); } log2.LogError(val2); return null; } bool flag2 = false; List spawnedInteractables = desk.spawnedInteractables; if (spawnedInteractables != null) { for (int i = 0; i < spawnedInteractables.Count; i++) { if (spawnedInteractables[i] != null && ((Il2CppObjectBase)spawnedInteractables[i]).Pointer == ((Il2CppObjectBase)val).Pointer) { flag2 = true; } } } bool flag3 = (Object)(object)CityData.Instance != (Object)null && CityData.Instance.savableInteractableDictionary != null && CityData.Instance.savableInteractableDictionary.ContainsKey(val.id); if (!flag2) { ManualLogSource log3 = Office.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(91, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] The computer (id "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") is not listed on the desk; deleting it rather than leaving an orphan."); } log3.LogError(val2); try { val.SafeDelete(false); } catch { } return null; } ManualLogSource log4 = Office.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(97, 8, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Computer '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((Object)computerPreset).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' placed on the desk (id "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val.id); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", savable="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(flag3); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("). Apps: boot='"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(Name(computerPreset.bootApp)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' login='"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(Name(computerPreset.logInApp)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' desktop='"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(Name(computerPreset.desktopApp)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' additional="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted((computerPreset.additionalApps != null) ? computerPreset.additionalApps.Count : 0); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } log4.LogInfo(val3); if (OfficeConfig.VerboseDiagnostics.Value && computerPreset.additionalApps != null) { for (int j = 0; j < computerPreset.additionalApps.Count; j++) { CruncherAppPreset val4 = computerPreset.additionalApps[j]; if (!((SoCustomComparison)(object)val4 == (SoCustomComparison)null)) { ManualLogSource log5 = Office.Log; val3 = new BepInExInfoLogInterpolatedStringHandler(94, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] app '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((Object)val4).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' alwaysInstalled="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val4.alwaysInstalled); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" companyOnly="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val4.companyOnly); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" onlyIfOwner="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val4.onlyIfOwner); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" onlyIfResidential="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val4.onlyIfResidential); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" addressRestrictions="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted((val4.onlyInAddresses != null) ? val4.onlyInAddresses.Count : 0); } log5.LogInfo(val3); } } } return val; } private static string Name(CruncherAppPreset app) { return ((SoCustomComparison)(object)app != (SoCustomComparison)null) ? ((Object)app).name : "-"; } internal static void AdoptRealTerminalConfig() { //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown Interactable computer = Office.Computer; if (computer == null || (SoCustomComparison)(object)computer.preset == (SoCustomComparison)null) { return; } List val = (((Object)(object)CityData.Instance != (Object)null) ? CityData.Instance.interactableDirectory : null); if (val == null) { _terminalAdopted = true; return; } int num = Math.Min(_scanCursor + 4000, val.Count); bool flag = default(bool); for (int i = _scanCursor; i < num; i++) { Interactable val2 = val[i]; if (val2 == null || (SoCustomComparison)(object)val2.preset == (SoCustomComparison)null || ((Il2CppObjectBase)val2).Pointer == ((Il2CppObjectBase)computer).Pointer || ((Il2CppObjectBase)val2.preset).Pointer != ((Il2CppObjectBase)computer.preset).Pointer || ((Object)(object)val2.belongsTo == (Object)null && val2.passwordSource == null)) { continue; } try { if (val2.passwordSource != null) { computer.SetPasswordSource(val2.passwordSource); } if ((Object)(object)val2.belongsTo != (Object)null) { computer.SetOwner(val2.belongsTo, false); } _terminalAdopted = true; ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(105, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Office terminal now matches working terminal id "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val2.id); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": owner '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((Object)(object)val2.belongsTo != (Object)null) ? val2.belongsTo.GetCitizenName() : "nobody"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("', password source "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted((val2.passwordSource != null) ? "copied" : "none"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(". Ours resolves passcode "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(DescribePasscode(computer)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } log.LogInfo(val3); return; } catch (Exception ex) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(41, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Copying terminal configuration threw: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex.Message); } log2.LogWarning(val4); _terminalAdopted = true; return; } } _scanCursor = num; if (_scanCursor >= val.Count) { _terminalAdopted = true; ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(145, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Searched all "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val.Count); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" interactables and found no other '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Object)computer.preset).name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' with an owner or password source to copy. The office terminal's login screen may still hang."); } log3.LogWarning(val4); } } private static string DescribePasscode(Interactable computer) { try { Passcode passwordSource = computer.GetPasswordSource(); if (passwordSource == null || passwordSource.digits == null) { return ""; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < passwordSource.digits.Count; i++) { stringBuilder.Append(passwordSource.digits[i]); } return (stringBuilder.Length > 0) ? stringBuilder.ToString() : ""; } catch { return ""; } } internal static void LogAppInstallRules(NewRoom room, InteractablePreset computerPreset) { //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown if (_loggedAppRules || (SoCustomComparison)(object)computerPreset == (SoCustomComparison)null || (Object)(object)room == (Object)null) { return; } _loggedAppRules = true; bool flag = default(bool); try { NewAddress val = (((Object)(object)room.gameLocation != (Object)null) ? room.gameLocation.thisAsAddress : null); string text = (((Object)(object)val != (Object)null && (SoCustomComparison)(object)val.addressPreset != (SoCustomComparison)null) ? ((Object)val.addressPreset).name : ""); ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(31, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office address preset is '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'."); } log.LogInfo(val2); if (computerPreset.additionalApps == null) { return; } for (int i = 0; i < computerPreset.additionalApps.Count; i++) { CruncherAppPreset val3 = computerPreset.additionalApps[i]; if ((SoCustomComparison)(object)val3 == (SoCustomComparison)null || val3.onlyInAddresses == null || val3.onlyInAddresses.Count == 0) { continue; } List list = new List(); bool flag2 = false; for (int j = 0; j < val3.onlyInAddresses.Count; j++) { AddressPreset val4 = val3.onlyInAddresses[j]; if (!((SoCustomComparison)(object)val4 == (SoCustomComparison)null)) { list.Add(((Object)val4).name); if (string.Equals(((Object)val4).name, text, StringComparison.OrdinalIgnoreCase)) { flag2 = true; } } } string text2 = (flag2 ? "INSTALLS HERE" : "will NOT install here"); ManualLogSource log2 = Office.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(33, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] App '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)val3).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' only installs in ["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(string.Join(", ", list)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] - "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log2.LogInfo(val2); } } catch (Exception ex) { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(38, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Reporting app install rules threw: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(ex.Message); } log3.LogWarning(val5); } } internal static void RepairMissingObjects(NewRoom room) { //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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 //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Expected O, but got Unknown //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Expected O, but got Unknown //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Expected O, but got Unknown if (!OfficeConfig.RepairMissingObjects.Value || (Object)(object)room == (Object)null || _repairs >= 40) { return; } List individualFurniture = room.individualFurniture; if (individualFurniture == null) { return; } List list = new List(); for (int i = 0; i < individualFurniture.Count; i++) { FurnitureLocation val = individualFurniture[i]; if (val != null && (Object)(object)val.spawnedObject == (Object)null) { list.Add(val); } } if (list.Count == 0) { return; } _repairs++; bool flag = default(bool); for (int j = 0; j < list.Count; j++) { try { list[j].SpawnObject(true); List spawnedInteractables = list[j].spawnedInteractables; if (spawnedInteractables == null) { continue; } for (int k = 0; k < spawnedInteractables.Count; k++) { if (spawnedInteractables[k] != null) { spawnedInteractables[k].ResetToFurnitureObject(true); } } } catch (Exception ex) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(24, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Respawning '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((SoCustomComparison)(object)list[j].furniture != (SoCustomComparison)null) ? ((Object)list[j].furniture).name : "?"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log.LogWarning(val2); } } try { room.LoadRoomStuff(true); } catch (Exception ex2) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(24, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] LoadRoomStuff threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2.Message); } log2.LogWarning(val2); } int num = 0; for (int l = 0; l < list.Count; l++) { if ((Object)(object)list[l].spawnedObject == (Object)null) { num++; } } if (num == 0) { ManualLogSource log3 = Office.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(60, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Respawned "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" office object(s) that had no model (repair "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(_repairs); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(40); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")."); } log3.LogInfo(val3); } else { ManualLogSource log4 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(68, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Tried to respawn "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" office object(s); "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" still have no model. Names: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(DescribeFurniture(list)); } log4.LogWarning(val2); } if (_repairs >= 40) { ManualLogSource log5 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(71, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Object repair cap reached; no further respawn attempts this session."); } log5.LogWarning(val2); } } private static string DescribeFurniture(List list) { List list2 = new List(); for (int i = 0; i < list.Count && i < 12; i++) { list2.Add(((SoCustomComparison)(object)list[i].furniture != (SoCustomComparison)null) ? ((Object)list[i].furniture).name : "?"); } return string.Join(", ", list2); } internal static void RegisterForDecorating(NewRoom room) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown if (!OfficeConfig.AllowDecorating.Value || (Object)(object)room == (Object)null) { return; } bool flag = default(bool); if (!room.decorEdit) { room.decorEdit = true; if (!room.decorEdit) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Setting room.decorEdit did not stick."); } log.LogWarning(val); } } NewAddress val2 = (((Object)(object)room.gameLocation != (Object)null) ? room.gameLocation.thisAsAddress : null); if ((Object)(object)val2 == (Object)null) { val2 = Office.CityHallAddress; } if ((Object)(object)val2 == (Object)null || (Object)(object)Player.Instance == (Object)null) { return; } List apartmentsOwned = Player.Instance.apartmentsOwned; if (apartmentsOwned == null) { return; } for (int i = 0; i < apartmentsOwned.Count; i++) { if ((Object)(object)apartmentsOwned[i] != (Object)null && ((Il2CppObjectBase)apartmentsOwned[i]).Pointer == ((Il2CppObjectBase)val2).Pointer) { return; } } apartmentsOwned.Add(val2); bool flag2 = false; for (int j = 0; j < apartmentsOwned.Count; j++) { if ((Object)(object)apartmentsOwned[j] != (Object)null && ((Il2CppObjectBase)apartmentsOwned[j]).Pointer == ((Il2CppObjectBase)val2).Pointer) { flag2 = true; } } if (flag2) { ManualLogSource log2 = Office.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(124, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Registered address '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(OfficeLocator.RoomDisplayName(room)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((Object)val2).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(") with the player's apartment system so the office can be decorated; player now owns "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(apartmentsOwned.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" address(es)."); } log2.LogInfo(val3); } else { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(101, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Could not register the office address for decorating; the furnishing UI will not offer the office."); } log3.LogWarning(val); } } } internal enum PlayerTitle { Inspector, Detective } internal enum DeskPlacement { DepthFraction, BackCentre, Centre, FarFromDoor } internal enum OfficeNameScope { Address, RoomOnly } internal enum WindowView { FrostedNoir, StreetView } internal static class OfficeConfig { internal static ConfigEntry Enabled; internal static ConfigEntry Title; internal static ConfigEntry CityHallBuildingPreset; internal static ConfigEntry CityHallSearchNames; internal static ConfigEntry OfficeRoomNameContains; internal static ConfigEntry RoomIdOverride; internal static ConfigEntry ExcludedRoomTypes; internal static ConfigEntry CirculationRoomTypes; internal static ConfigEntry MaxEntranceSpaceRooms; internal static ConfigEntry PreferredRoomTypes; internal static ConfigEntry PreferredRoomBonus; internal static ConfigEntry DryRun; internal static ConfigEntry ClearExistingContents; internal static ConfigEntry RemoveObjectPresets; internal static ConfigEntry KeepFurniturePresets; internal static ConfigEntry MaxClearedFurniture; internal static ConfigEntry ForceClearOnce; internal static ConfigEntry MinCityInteractables; internal static ConfigEntry MaxSetupWaitSeconds; internal static ConfigEntry PlaceDesk; internal static ConfigEntry DeskPresetName; internal static ConfigEntry DeskPosition; internal static ConfigEntry DeskDepthFraction; internal static ConfigEntry RepositionDeskOnLoad; internal static ConfigEntry DeskAngleOffset; internal static ConfigEntry ComputerPresetName; internal static ConfigEntry ComputerSlotClassName; internal static ConfigEntry NameScope; internal static ConfigEntry RepairMissingObjects; internal static ConfigEntry AllowDecorating; internal static ConfigEntry VerboseDiagnostics; internal static ConfigEntry Windows; internal static ConfigEntry View; internal static ConfigEntry WindowSections; internal const int DesiredWindows = 3; internal static ConfigEntry WindowPresetName; internal static ConfigEntry WindowFrontageName; internal static ConfigEntry PreventWallMerging; internal static ConfigEntry ClearOutsideWindows; internal static ConfigEntry MaxClearedOutside; internal static ConfigEntry ClearOutsideRadius; internal static ConfigEntry FrostedRoughness; internal static ConfigEntry FrostedHaze; internal static ConfigEntry RestoreWalls; internal static ConfigEntry OriginalWallPresets; internal static ConfigEntry WindowDiagnostics; internal static ConfigFile File; internal const string DefaultDeskPreset = "VintageDesk"; internal static bool DeskChosenByPlayer => !string.IsNullOrEmpty(DeskPresetName.Value) && DeskPresetName.Value != "VintageDesk"; internal static string TitleWord => (Title.Value == PlayerTitle.Detective) ? "Detective" : "Inspector"; internal static void Bind(ConfigFile config) { File = config; Enabled = config.Bind("Office", "Enabled", true, "When true, the first room to the right of the city hall entrance is converted into the player's official office."); Title = config.Bind("Office", "Title", PlayerTitle.Inspector, "How the player is titled in every piece of text this mod generates (the office room label, placards, notes). Inspector or Detective."); CityHallBuildingPreset = config.Bind("Office", "CityHallBuildingPreset", "", "Exact BuildingPreset name of the city hall. Leave blank to auto-detect. Every building preset in the city is printed to the log on load, so set this if auto-detection picks the wrong building."); CityHallSearchNames = config.Bind("Office", "CityHallSearchNames", "cityhall,city hall,town hall,government,municipal", "Comma-separated name fragments used as a last-resort search for the city hall, matched against building preset, address preset and address names."); OfficeRoomNameContains = config.Bind("Office", "OfficeRoomNameContains", "", "Pin the office to the room whose in-game name contains this text (e.g. the name the room already has before the mod renames it). Leave blank to auto-detect by position. This wins over auto-detection but loses to RoomIdOverride."); RoomIdOverride = config.Bind("Office", "RoomIdOverride", -1, "Force a specific room to become the office by its roomID instead of auto-detecting. -1 = auto-detect. Every room in the city hall is printed to the log with its ID and current name, so read the log if auto-detection picks the wrong room."); ExcludedRoomTypes = config.Bind("Office", "ExcludedRoomTypes", "Null,Lobby,CorporateLobby,Atrium,CorporateCorridoor,Corridor,PublicBathroom,BuildingBathroomMale,BuildingBathroomFemale,PowerRoom,StreetFrontage,Rooftop,Storeroom,BusinessStoreroom,Stairwell", "Room configs/types that are never converted into the office, whatever the layout suggests. This is a hard safety net: a room matching any of these is never cleared or renamed, so the mod cannot gut a lobby or a corridor. Rooms in a lobby address are always excluded regardless of this list."); CirculationRoomTypes = config.Bind("Office", "CirculationRoomTypes", "Null,Lobby,CorporateLobby,Atrium,CorporateCorridoor,Corridor,Stairwell", "Room configs/types treated as space you walk through rather than occupy. The entrance area is flood-filled through these from the front door, and the first non-circulation room reached on each path becomes a candidate for the office. The city hall lobby spans several rooms across two different addresses, which is why this can't just follow one address."); MaxEntranceSpaceRooms = config.Bind("Office", "MaxEntranceSpaceRooms", 24, "Hard cap on how many rooms the entrance-area flood fill will absorb, so an unusual layout can't turn the whole building into 'the lobby'."); PreferredRoomTypes = config.Bind("Office", "PreferredRoomTypes", "Reception,OfficeSpace,PrivateOffice,EnforcerOffice", "Room configs/types that are preferred when several rooms adjoin the entrance. Matching rooms get PreferredRoomBonus added to their score."); PreferredRoomBonus = config.Bind("Office", "PreferredRoomBonus", 3f, "Score bonus applied to a room whose config or type is in PreferredRoomTypes. Raise it to favour room purpose over pure left/right geometry."); DryRun = config.Bind("Office", "DryRun", false, "When true, the office room is selected and logged but nothing is cleared, placed or renamed. Use this to confirm the right room is being picked before letting the mod modify anything."); ClearExistingContents = config.Bind("Office", "ClearExistingContents", true, "When true, the previous occupant's furniture and personal objects (employee photos, name placards, work rotas) are removed from the room before it becomes the player's office."); RemoveObjectPresets = config.Bind("Office", "RemoveObjectPresets", "EmployeePhoto,NamePlacard,WorkRota,EmploymentContractWork,BusinessCard", "Comma-separated InteractablePreset names to delete from the office room when ClearExistingContents is on. Matched case-insensitively against the preset name."); KeepFurniturePresets = config.Bind("Office", "KeepFurniturePresets", "BreakerBox,Blinds", "Comma-separated FurniturePreset names that survive the clear. Everything else the previous occupant had is deleted. Furniture that lights the room is always kept regardless of this list, so the office never ends up pitch dark, and so is anything the player placed themselves."); MaxClearedFurniture = config.Bind("Office", "MaxClearedFurniture", 200, "Hard cap on how many pieces of furniture the clear will delete in one pass, so an unexpected room can't turn into an unbounded delete loop."); ForceClearOnce = config.Bind("Office", "ForceClearOnce", false, "One-shot repair for a save whose office was converted before the room was furnished, leaving the previous occupant's furniture in place. Set true to clear the office again on the next load - anything you placed yourself is kept - after which the mod sets this back to false itself."); MinCityInteractables = config.Bind("Office", "MinCityInteractables", 500, "The office is not built until the city's object directory holds at least this many interactables. On a new game the mod used to run while the city was still being generated: every room reported zero furniture, so the clear had nothing to delete and the generator then furnished the room around the mod's desk. A city mid-generation has a couple of dozen objects; a finished one has thousands."); MaxSetupWaitSeconds = config.Bind("Office", "MaxSetupWaitSeconds", 300, "How long to wait for the city to finish generating before building the office anyway. Only a backstop: if this expires the office is built against a possibly unfinished city and the log says so loudly."); PlaceDesk = config.Bind("Office", "PlaceDesk", true, "When true, a desk with a working computer on it is placed in the office, oriented towards the door."); DeskPresetName = config.Bind("Office", "DeskPresetName", "VintageDesk", "Exact FurniturePreset name to use for the office desk. Defaults to the vintage desk so the office looks the same in every city - copying whichever desk the local computers happened to sit on gave a different desk every playthrough. Leave blank to go back to that copy-the-city behaviour. Every valid name is listed in the log on load, on the line beginning 'furniture preset(s) have a Computer slot'. Naming a desk other than the default replaces one already standing in the office, so it takes effect on an existing save."); DeskPosition = config.Bind("Office", "DeskPosition", DeskPlacement.DepthFraction, "Where the desk goes. DepthFraction = DeskDepthFraction of the way from the door to the far wall, centred left-to-right. BackCentre = hard against the far wall, centred. Centre = the middle of the room. FarFromDoor = whichever spot is furthest from the door, corners included."); DeskDepthFraction = config.Bind("Office", "DeskDepthFraction", 0.6f, "Used by DeskPosition=DepthFraction. How far into the room the desk sits, as a fraction of the distance from the door to the far wall. 0.5 is halfway; 0.6 leaves clear floor in front of the desk for visitor chairs while keeping the door's swing clear."); RepositionDeskOnLoad = config.Bind("Office", "RepositionDeskOnLoad", false, "One-shot. Set true to have an existing desk moved to the DeskPosition spot on the next load; the mod then sets this back to false itself, so the desk is never dragged around again and wherever you leave it is where it stays. A brand new desk is always placed at the DeskPosition spot regardless of this setting."); DeskAngleOffset = config.Bind("Office", "DeskAngleOffset", 0, "Extra rotation in degrees (0, 90, 180 or 270) applied on top of the computed door-facing angle, in case the desk model's front faces a different way than expected."); ComputerPresetName = config.Bind("Office", "ComputerPresetName", "", "Exact InteractablePreset name to use for the office computer. Leave blank to copy whichever computer preset the rest of the city hall already uses, so it gets the same government database profile."); ComputerSlotClassName = config.Bind("Office", "ComputerSlotClassName", "Computer", "Name of the furniture sub-object class that holds a computer. Used to find a suitable desk when no real example can be read from the world yet (object links aren't populated during early loading)."); NameScope = config.Bind("Office", "NameScope", OfficeNameScope.Address, "How far the office's name is written into the game's own data. Address = rename the location itself, so the map, the door, evidence and the phone book all call it the player's office - note this renames the whole business the room belongs to, including its other rooms. RoomOnly = leave the location alone and only relabel the room and its door."); RepairMissingObjects = config.Bind("Office", "RepairMissingObjects", true, "When true, furniture and objects in the office that exist in the game's data but have no spawned model - which happens after moving them with the decorating tools - are respawned automatically."); AllowDecorating = config.Bind("Office", "AllowDecorating", true, "When true, the office is registered with the game's own apartment decorating/furnishing system so the player can redecorate it and buy furniture for it exactly like their apartment."); VerboseDiagnostics = config.Bind("Office", "VerboseDiagnostics", true, "When true, dump the full city hall room/furniture/computer survey to the BepInEx log on load. Needed to diagnose a wrong room pick or a missing preset; harmless to leave on."); Windows = config.Bind("Office Windows", "Windows", true, "When true, windows are cut into the office's exterior back wall - the wall you face walking in through the door. This is the one thing this mod does that writes into saved city geometry rather than into objects standing in a room, so read RestoreWalls before turning it on for a save you care about."); View = config.Bind("Office Windows", "View", WindowView.FrostedNoir, "What the office windows look like. FrostedNoir = obscured glass, so the alley outside reads as soft light and shapes rather than detail - the classic private-office look. StreetView = ordinary clear glass looking out at the alley. Both are real windows onto the real city; the difference is only the glass."); WindowSections = config.Bind("Office Windows", "WindowSections", "", "Place the windows by hand instead of letting the mod centre three of them. Comma-separated section numbers counted left to right along the back wall, e.g. '1,2,3'. The log lists every section with its number and position on load, so read that line, pick the ones you want and put them here. Use this if a city produces an office whose back wall the automatic centring does not suit. Leave blank for the normal three centred windows."); WindowPresetName = config.Bind("Office Windows", "WindowPresetName", "", "Exact DoorPairPreset name to use for the window sections. Leave blank to copy whichever window preset the rest of the city hall already uses, so the office matches its own building. Every window-class preset the game has is listed in the log on load."); WindowFrontageName = config.Bind("Office Windows", "WindowFrontageName", "LargeRectangleWindowBlinds", "Exact WallFrontagePreset name for the glass and its dressing, used when the building declines to supply one - a Reception room config declares no frontage for a large window, so this is the normal path rather than a fallback. LargeRectangleWindowBlinds and LargeRectangleWindowCurtains are the two keyed to the large rectangular window. Every valid name is listed in the log on load. Blank leaves the opening unglazed."); PreventWallMerging = config.Bind("Office Windows", "PreventWallMerging", true, "Keeps each window section out of the game's merged wall runs. Neighbouring wall sections are combined into one long slab drawn by a single section, and a window sitting inside somebody else's slab is a window nothing draws. Set false if the windows start looking wrong at the edges."); ClearOutsideWindows = config.Bind("Office Windows", "ClearOutsideWindows", true, "Clears street furniture standing on the pavement directly outside each window, so the view out is not a bin or a planter. Only the single square outside each window is touched, and anything you placed yourself is left alone. The log lists what was out there whether or not this is on."); ClearOutsideRadius = config.Bind("Office Windows", "ClearOutsideRadius", 6f, "How far out from each window, in metres, street clutter is cleared. Only what is in front of the window counts, never behind it. The pavement square against the glass is always cleared; raise this to also take out things standing further into the alley - pylons, fire escapes, skips - that block the view of the buildings opposite. Anything you placed yourself is always left alone."); MaxClearedOutside = config.Bind("Office Windows", "MaxClearedOutside", 30, "Hard limit on how many things ClearOutsideWindows will delete in one pass, so an unusual street cannot turn into a runaway clear-out."); FrostedRoughness = config.Bind("Office Windows", "FrostedRoughness", 0.55f, "Only used by View=FrostedNoir. How smooth the glass is, 0 to 1. Low values scatter the view heavily, high values leave it sharp. Around 0.2 hides the street almost completely, 0.55 blurs it while streetlights and moving figures still read, and above 0.8 it is nearly a plain window. Works together with FrostedHaze - turning both up closes the window off."); FrostedHaze = config.Bind("Office Windows", "FrostedHaze", 0.25f, "Only used by View=FrostedNoir. How milky the glass is, 0 to 1, on top of the blur. A little keeps the warm streetlight colour in the pane; too much turns it into a flat panel with nothing behind it. Set to 0 for blur alone."); RestoreWalls = config.Bind("Office Windows", "RestoreWalls", false, "One-shot undo. Set true to put the office's original wall presets back on the next load, after which the mod sets this back to false itself. Use this to get a save back to solid walls; it reads the presets recorded in OriginalWallPresets."); OriginalWallPresets = config.Bind("Office Windows", "OriginalWallPresets", "", "Written by the mod, not by hand. Records 'wallID=presetName' for every wall the windows replaced, so RestoreWalls can put the room back exactly as it was. Clearing this makes a restore fall back to the game's standard interior wall."); WindowDiagnostics = config.Bind("Office Windows", "WindowDiagnostics", false, "When true, dump the office's full wall survey - every wall's ID, facing, outside flag and current preset - plus every window-class preset and wall frontage the game has. Off by default because it is several hundred lines per load. Turn it on if the windows land somewhere odd in your city: the survey is what identifies the wall and the section numbers to put in WindowSections. Failures are always logged regardless of this setting."); } internal static string TitledPlayerName() { string text = null; try { if ((Object)(object)Player.Instance != (Object)null) { text = ((Human)Player.Instance).GetCitizenName(); } } catch { text = null; } return string.IsNullOrEmpty(text) ? TitleWord : (TitleWord + " " + text); } internal static string OfficeRoomName() { return TitledPlayerName() + "'s Office"; } } internal static class OfficeLocator { internal sealed class BuildingInfo { internal NewBuilding Building; internal string PresetName = ""; internal int RoomCount; internal int ComputerCount; internal int RestrictedAppComputerCount; internal readonly HashSet Apps = new HashSet(); internal readonly HashSet AddressNames = new HashSet(); } internal sealed class DeskUsage { internal FurniturePreset Preset; internal SubObject Slot; internal int Count; } internal sealed class ComputerInfo { internal InteractablePreset Preset; internal readonly Dictionary DeskUsages = new Dictionary(); internal FurniturePreset Desk; internal SubObject Slot; internal int Count; internal int CountInCityHall; internal bool AddressRestrictedApps; internal void ResolveDesk() { DeskUsage deskUsage = null; foreach (KeyValuePair deskUsage2 in DeskUsages) { DeskUsage value = deskUsage2.Value; if (!((SoCustomComparison)(object)value.Preset == (SoCustomComparison)null) && (deskUsage == null || value.Count > deskUsage.Count || (value.Count == deskUsage.Count && string.CompareOrdinal(((Object)value.Preset).name, ((Object)deskUsage.Preset).name) < 0))) { deskUsage = value; } } if (deskUsage != null) { Desk = deskUsage.Preset; Slot = deskUsage.Slot; } } internal string DescribeDesks() { List list = new List(); foreach (KeyValuePair deskUsage in DeskUsages) { if ((SoCustomComparison)(object)deskUsage.Value.Preset != (SoCustomComparison)null) { list.Add($"{((Object)deskUsage.Value.Preset).name} x{deskUsage.Value.Count}"); } } list.Sort(StringComparer.OrdinalIgnoreCase); return (list.Count > 0) ? string.Join(", ", list) : ""; } } internal sealed class Candidate { internal NewRoom Room; internal Vector3 DoorPosition; internal Vector3 Centre; internal float RightAmount; internal float ForwardAmount; internal float TypeBonus; internal float Score; internal string Rejected; } internal sealed class Result { internal readonly List Buildings = new List(); internal readonly List Computers = new List(); internal NewBuilding Building; internal string HowFound = "not found"; internal NewGameLocation LobbyLocation; internal readonly List EntranceSpace = new List(); internal NewRoom EntryRoom; internal NewNode InsideEntranceNode; internal NewNode OutsideEntranceNode; internal Vector3 Forward; internal Vector3 Right; internal NewRoom Office; internal bool OfficeWasPinned; internal readonly List Candidates = new List(); internal readonly List Notes = new List(); internal string Failure; internal void Note(string note) { Notes.Add(note); } } internal static Result Locate() { Result result = new Result(); SurveyBuildings(result); SurveyComputers(result); result.Building = FindCityHall(result); if ((Object)(object)result.Building == (Object)null) { result.Failure = "Could not identify the city hall. The building survey above lists every building preset in this city - set CityHallBuildingPreset, or pin the room with OfficeRoomNameContains / RoomIdOverride."; return result; } FindStreetEntrance(result); NewRoom val = FindPinnedRoom(result); if ((Object)(object)val != (Object)null) { result.Office = val; result.OfficeWasPinned = true; return result; } if (result.InsideEntranceNode == null) { return result; } CollectCandidates(result); for (int i = 0; i < result.Candidates.Count; i++) { if (result.Candidates[i].Rejected == null) { result.Office = result.Candidates[i].Room; break; } } if ((Object)(object)result.Office == (Object)null && result.Failure == null) { result.Failure = "Every room adjoining the city hall entrance was rejected as unsuitable (lobby, corridor, bathroom, power room and similar are never converted). Pin the room with OfficeRoomNameContains or RoomIdOverride."; } return result; } private static void SurveyBuildings(Result result) { List val = (((Object)(object)CityData.Instance != (Object)null) ? CityData.Instance.roomDirectory : null); if (val == null) { result.Note("CityData.roomDirectory is null."); return; } Dictionary dictionary = new Dictionary(); for (int i = 0; i < val.Count; i++) { NewRoom val2 = val[i]; if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.building == (Object)null)) { BuildingInfo orAdd = GetOrAdd(dictionary, val2.building); orAdd.RoomCount++; string text = LocationName(val2.gameLocation); if (text != null) { orAdd.AddressNames.Add(text); } } } foreach (KeyValuePair item in dictionary) { result.Buildings.Add(item.Value); } } private static BuildingInfo GetOrAdd(Dictionary map, NewBuilding building) { if (!map.TryGetValue(((Il2CppObjectBase)building).Pointer, out var value)) { value = new BuildingInfo { Building = building, PresetName = (((SoCustomComparison)(object)building.preset != (SoCustomComparison)null) ? ((Object)building.preset).name : "") }; map[((Il2CppObjectBase)building).Pointer] = value; } return value; } private static void SurveyComputers(Result result) { List val = (((Object)(object)CityData.Instance != (Object)null) ? CityData.Instance.interactableDirectory : null); if (val == null) { result.Note("CityData.interactableDirectory is null; cannot find any computers."); return; } Dictionary dictionary = new Dictionary(); Dictionary dictionary2 = new Dictionary(); for (int i = 0; i < result.Buildings.Count; i++) { dictionary2[((Il2CppObjectBase)result.Buildings[i].Building).Pointer] = result.Buildings[i]; } for (int j = 0; j < val.Count; j++) { Interactable val2 = val[j]; if (val2 == null || (SoCustomComparison)(object)val2.preset == (SoCustomComparison)null || !IsComputer(val2.preset)) { continue; } if (!dictionary.TryGetValue(((Il2CppObjectBase)val2.preset).Pointer, out var value)) { value = new ComputerInfo { Preset = val2.preset }; value.AddressRestrictedApps = HasAddressRestrictedApp(val2.preset); dictionary[((Il2CppObjectBase)val2.preset).Pointer] = value; } value.Count++; if (val2.furnitureParent != null && (SoCustomComparison)(object)val2.furnitureParent.furniture != (SoCustomComparison)null && val2.subObject != null) { FurniturePreset furniture = val2.furnitureParent.furniture; if (!value.DeskUsages.TryGetValue(((Il2CppObjectBase)furniture).Pointer, out var value2)) { value2 = new DeskUsage { Preset = furniture, Slot = val2.subObject }; value.DeskUsages[((Il2CppObjectBase)furniture).Pointer] = value2; } value2.Count++; } NewRoom val3 = ResolveRoom(val2); if ((Object)(object)val3 != (Object)null && (Object)(object)val3.building != (Object)null && dictionary2.TryGetValue(((Il2CppObjectBase)val3.building).Pointer, out var value3)) { value3.ComputerCount++; CollectAppNames(val2.preset, value3.Apps); if (value.AddressRestrictedApps) { value3.RestrictedAppComputerCount++; } } } foreach (KeyValuePair item in dictionary) { item.Value.ResolveDesk(); result.Computers.Add(item.Value); } result.Computers.Sort(delegate(ComputerInfo a, ComputerInfo b) { int num = b.Count.CompareTo(a.Count); return (num != 0) ? num : string.CompareOrdinal(((SoCustomComparison)(object)a.Preset != (SoCustomComparison)null) ? ((Object)a.Preset).name : "", ((SoCustomComparison)(object)b.Preset != (SoCustomComparison)null) ? ((Object)b.Preset).name : ""); }); result.Buildings.Sort((BuildingInfo a, BuildingInfo b) => b.RestrictedAppComputerCount.CompareTo(a.RestrictedAppComputerCount)); } private static NewRoom ResolveRoom(Interactable obj) { if (obj.node != null && (Object)(object)obj.node.room != (Object)null) { return obj.node.room; } if ((Object)(object)obj.worldObjectRoomParent != (Object)null) { return obj.worldObjectRoomParent; } if (obj.furnitureParent != null && obj.furnitureParent.anchorNode != null) { return obj.furnitureParent.anchorNode.room; } return null; } internal static bool IsComputer(InteractablePreset preset) { if ((SoCustomComparison)(object)preset.bootApp != (SoCustomComparison)null || (SoCustomComparison)(object)preset.logInApp != (SoCustomComparison)null || (SoCustomComparison)(object)preset.desktopApp != (SoCustomComparison)null) { return true; } return preset.additionalApps != null && preset.additionalApps.Count > 0; } private static bool HasAddressRestrictedApp(InteractablePreset preset) { if (IsRestricted(preset.bootApp) || IsRestricted(preset.logInApp) || IsRestricted(preset.desktopApp)) { return true; } if (preset.additionalApps != null) { for (int i = 0; i < preset.additionalApps.Count; i++) { if (IsRestricted(preset.additionalApps[i])) { return true; } } } return false; } private static bool IsRestricted(CruncherAppPreset app) { return (SoCustomComparison)(object)app != (SoCustomComparison)null && app.onlyInAddresses != null && app.onlyInAddresses.Count > 0; } private static void CollectAppNames(InteractablePreset preset, HashSet into) { NoteApp(preset.bootApp, into); NoteApp(preset.logInApp, into); NoteApp(preset.desktopApp, into); if (preset.additionalApps != null) { for (int i = 0; i < preset.additionalApps.Count; i++) { NoteApp(preset.additionalApps[i], into); } } } private static void NoteApp(CruncherAppPreset app, HashSet into) { if ((SoCustomComparison)(object)app != (SoCustomComparison)null) { into.Add(IsRestricted(app) ? (((Object)app).name + "*") : ((Object)app).name); } } private static string LocationName(NewGameLocation location) { if ((Object)(object)location == (Object)null) { return null; } try { if (location.evidenceEntry != null && !string.IsNullOrEmpty(((CaseComponent)location.evidenceEntry).name)) { return ((CaseComponent)location.evidenceEntry).name; } NewAddress thisAsAddress = location.thisAsAddress; if ((Object)(object)thisAsAddress != (Object)null && thisAsAddress.company != null && !string.IsNullOrEmpty(thisAsAddress.company.name)) { return thisAsAddress.company.name; } } catch { } return null; } private static NewBuilding FindCityHall(Result result) { string configured = OfficeConfig.CityHallBuildingPreset.Value; if (!string.IsNullOrEmpty(configured)) { BuildingInfo buildingInfo = result.Buildings.Find((BuildingInfo b) => string.Equals(b.PresetName, configured, StringComparison.OrdinalIgnoreCase)); if (buildingInfo != null) { result.HowFound = "CityHallBuildingPreset='" + configured + "'"; return buildingInfo.Building; } result.Note("CityHallBuildingPreset '" + configured + "' matched no building in this city."); } BuildingPreset routinePreset = (((Object)(object)RoutineControls.Instance != (Object)null) ? RoutineControls.Instance.cityHall : null); if ((SoCustomComparison)(object)routinePreset != (SoCustomComparison)null) { BuildingInfo buildingInfo2 = result.Buildings.Find((BuildingInfo b) => string.Equals(b.PresetName, ((Object)routinePreset).name, StringComparison.OrdinalIgnoreCase)); if (buildingInfo2 != null) { result.HowFound = "RoutineControls.cityHall preset name '" + ((Object)routinePreset).name + "'"; return buildingInfo2.Building; } result.Note("No building uses RoutineControls.cityHall's preset name '" + ((Object)routinePreset).name + "'."); } if (result.Buildings.Count > 0 && result.Buildings[0].RestrictedAppComputerCount > 0) { BuildingInfo buildingInfo3 = result.Buildings[0]; result.HowFound = $"most address-restricted computer apps ({buildingInfo3.RestrictedAppComputerCount} machines in preset '{buildingInfo3.PresetName}')"; return buildingInfo3.Building; } foreach (string term in Split(OfficeConfig.CityHallSearchNames.Value)) { BuildingInfo buildingInfo4 = result.Buildings.Find((BuildingInfo b) => Contains(b.PresetName, term) || ContainsAny(b.AddressNames, term)); if (buildingInfo4 != null) { result.HowFound = $"name search term '{term}' matched preset '{buildingInfo4.PresetName}'"; return buildingInfo4.Building; } } return null; } private static NewRoom FindPinnedRoom(Result result) { //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) int overrideId = OfficeConfig.RoomIdOverride.Value; if (overrideId >= 0) { NewRoom val = FindRoom((NewRoom r) => r.roomID == overrideId); if ((Object)(object)val != (Object)null) { result.HowFound += $"; room pinned by RoomIdOverride={overrideId}"; return val; } result.Note($"RoomIdOverride is {overrideId} but no room has that ID."); } string wantedName = OfficeConfig.OfficeRoomNameContains.Value; if (string.IsNullOrEmpty(wantedName)) { return null; } List list = FindRooms((NewRoom r) => (Object)(object)r.building != (Object)null && ((Il2CppObjectBase)r.building).Pointer == ((Il2CppObjectBase)result.Building).Pointer && r.roomID >= 0 && Contains(RoomDisplayName(r), wantedName)); if (list.Count == 0) { result.Note("OfficeRoomNameContains '" + wantedName + "' matched no room in the city hall."); return null; } NewRoom val2 = null; float num = float.NegativeInfinity; int num2; if (result.InsideEntranceNode == null) { num2 = 0; } else { Vector3Int nodeCoord = result.InsideEntranceNode.nodeCoord; num2 = ((Vector3Int)(ref nodeCoord)).z; } int floor = num2; Vector3 val3 = ((result.InsideEntranceNode != null) ? result.InsideEntranceNode.position : Vector3.zero); for (int num3 = 0; num3 < list.Count; num3++) { NewRoom val4 = list[num3]; float num4 = (OnFloor(val4, floor) ? 1000f : 0f); if (result.InsideEntranceNode != null) { num4 -= Vector3.Distance(Office.RoomCentre(val4), val3); } result.Note($"OfficeRoomNameContains match: roomID={val4.roomID} '{RoomDisplayName(val4)}' centre={Office.RoomCentre(val4)} score={num4:F1}"); if (num4 > num) { num = num4; val2 = val4; } } string text = RejectReason(val2); if (text != null) { result.Note("WARNING: the pinned room would normally be rejected (" + text + "). Honouring the pin anyway because it was set by hand."); } result.HowFound += $"; room pinned by OfficeRoomNameContains='{wantedName}' ({list.Count} match(es))"; return val2; } internal static string RoomDisplayName(NewRoom room) { if ((Object)(object)room == (Object)null) { return null; } try { string name = room.GetName(); if (!string.IsNullOrEmpty(name)) { return name; } } catch { } return room.name; } private static List FindRooms(Predicate match) { List list = new List(); List val = (((Object)(object)CityData.Instance != (Object)null) ? CityData.Instance.roomDirectory : null); if (val == null) { return list; } for (int i = 0; i < val.Count; i++) { NewRoom val2 = val[i]; if ((Object)(object)val2 != (Object)null && match(val2)) { list.Add(val2); } } return list; } private static NewRoom FindRoom(Predicate match) { List val = (((Object)(object)CityData.Instance != (Object)null) ? CityData.Instance.roomDirectory : null); if (val == null) { return null; } for (int i = 0; i < val.Count; i++) { NewRoom val2 = val[i]; if ((Object)(object)val2 != (Object)null && match(val2)) { return val2; } } return null; } internal static string RejectReason(NewRoom room) { if ((Object)(object)room == (Object)null) { return "null room"; } if (room.isNullRoom || room.isBaseNullRoom) { return "placeholder room"; } if ((Object)(object)room.gameLocation != (Object)null && room.gameLocation.isOutside) { return "outdoors"; } if ((Object)(object)room.gameLocation != (Object)null && room.gameLocation.isLobby) { return "belongs to a lobby address"; } string text = (((SoCustomComparison)(object)room.preset != (SoCustomComparison)null) ? ((Object)room.preset).name : null); string text2 = (((SoCustomComparison)(object)room.roomType != (SoCustomComparison)null) ? ((Object)room.roomType).name : null); foreach (string item in Split(OfficeConfig.ExcludedRoomTypes.Value)) { if (string.Equals(text, item, StringComparison.OrdinalIgnoreCase)) { return "room config '" + text + "' is excluded"; } if (string.Equals(text2, item, StringComparison.OrdinalIgnoreCase)) { return "room type '" + text2 + "' is excluded"; } } return null; } private static float TypeBonus(NewRoom room) { string a = (((SoCustomComparison)(object)room.preset != (SoCustomComparison)null) ? ((Object)room.preset).name : null); string a2 = (((SoCustomComparison)(object)room.roomType != (SoCustomComparison)null) ? ((Object)room.roomType).name : null); foreach (string item in Split(OfficeConfig.PreferredRoomTypes.Value)) { if (string.Equals(a, item, StringComparison.OrdinalIgnoreCase) || string.Equals(a2, item, StringComparison.OrdinalIgnoreCase)) { return OfficeConfig.PreferredRoomBonus.Value; } } return 0f; } private static bool FindStreetEntrance(Result result) { //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) List val = (((Object)(object)CityData.Instance != (Object)null) ? CityData.Instance.roomDirectory : null); if (val == null || (Object)(object)result.Building == (Object)null) { result.Failure = "Cannot look for a street entrance without a room directory and a building."; return false; } NewNode val2 = null; NewNode val3 = null; NewRoom val4 = null; int num = int.MinValue; for (int i = 0; i < val.Count; i++) { NewRoom val5 = val[i]; if ((Object)(object)val5 == (Object)null || (Object)(object)val5.building == (Object)null || ((Il2CppObjectBase)val5.building).Pointer != ((Il2CppObjectBase)result.Building).Pointer || val5.entrances == null) { continue; } for (int j = 0; j < val5.entrances.Count; j++) { NodeAccess val6 = val5.entrances[j]; if (val6 == null || val6.fromNode == null || val6.toNode == null) { continue; } bool flag = IsOutside(val6.fromNode); if (flag != IsOutside(val6.toNode)) { NewNode val7 = (flag ? val6.toNode : val6.fromNode); NewNode val8 = (flag ? val6.fromNode : val6.toNode); int num2 = 0; if ((Object)(object)val5.gameLocation != (Object)null && val5.gameLocation.isLobby) { num2 += 1000; } int num3 = num2; Vector3Int nodeCoord = val7.nodeCoord; num2 = num3 - ((Vector3Int)(ref nodeCoord)).z * 10; if (num2 > num) { num = num2; val2 = val7; val3 = val8; val4 = val5; } } } } if (val2 == null) { result.Failure = "The building identified as the city hall has no doorway between an indoor and an outdoor node."; return false; } Vector3 val9 = val2.position - val3.position; val9.y = 0f; if (((Vector3)(ref val9)).sqrMagnitude < 0.0001f) { result.Failure = "The main entrance's inside and outside nodes share a position; cannot derive a facing direction."; return false; } result.InsideEntranceNode = val2; result.OutsideEntranceNode = val3; result.EntryRoom = val4; result.Forward = ((Vector3)(ref val9)).normalized; result.Right = new Vector3(result.Forward.z, 0f, 0f - result.Forward.x); result.LobbyLocation = (((Object)(object)val4 != (Object)null) ? val4.gameLocation : null); CollectEntranceSpace(result); return true; } private static void CollectEntranceSpace(Result result) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) result.EntranceSpace.Add(result.EntryRoom); HashSet hashSet = new HashSet { ((Il2CppObjectBase)result.EntryRoom).Pointer }; Queue queue = new Queue(); queue.Enqueue(result.EntryRoom); Vector3Int nodeCoord = result.InsideEntranceNode.nodeCoord; int z = ((Vector3Int)(ref nodeCoord)).z; int num = Math.Max(1, OfficeConfig.MaxEntranceSpaceRooms.Value); while (queue.Count > 0 && result.EntranceSpace.Count < num) { NewRoom val = queue.Dequeue(); List entrances = val.entrances; if (entrances == null) { continue; } for (int i = 0; i < entrances.Count; i++) { NodeAccess val2 = entrances[i]; if (val2 != null && val2.fromNode != null && val2.toNode != null) { NewRoom val3 = (((Object)(object)val2.fromNode.room != (Object)null && ((Il2CppObjectBase)val2.fromNode.room).Pointer == ((Il2CppObjectBase)val).Pointer) ? val2.toNode.room : val2.fromNode.room); if (!((Object)(object)val3 == (Object)null) && hashSet.Add(((Il2CppObjectBase)val3).Pointer) && !((Object)(object)val3.building == (Object)null) && !(((Il2CppObjectBase)val3.building).Pointer != ((Il2CppObjectBase)result.Building).Pointer) && (!((Object)(object)val3.gameLocation != (Object)null) || !val3.gameLocation.isOutside) && OnFloor(val3, z) && IsCirculation(val3)) { result.EntranceSpace.Add(val3); queue.Enqueue(val3); } } } } } private static bool IsCirculation(NewRoom room) { string a = (((SoCustomComparison)(object)room.preset != (SoCustomComparison)null) ? ((Object)room.preset).name : null); string a2 = (((SoCustomComparison)(object)room.roomType != (SoCustomComparison)null) ? ((Object)room.roomType).name : null); if (room.isNullRoom || room.isBaseNullRoom) { return true; } foreach (string item in Split(OfficeConfig.CirculationRoomTypes.Value)) { if (string.Equals(a, item, StringComparison.OrdinalIgnoreCase) || string.Equals(a2, item, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private static bool OnFloor(NewRoom room, int floor) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) List list = Office.RoomNodes(room); for (int i = 0; i < list.Count; i++) { Vector3Int nodeCoord = list[i].nodeCoord; if (((Vector3Int)(ref nodeCoord)).z == floor) { return true; } } return list.Count == 0; } private static void CollectCandidates(Result result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) Vector3 position = result.InsideEntranceNode.position; HashSet hashSet = new HashSet(); HashSet hashSet2 = new HashSet(); for (int i = 0; i < result.EntranceSpace.Count; i++) { hashSet2.Add(((Il2CppObjectBase)result.EntranceSpace[i]).Pointer); } for (int j = 0; j < result.EntranceSpace.Count; j++) { NewRoom val = result.EntranceSpace[j]; List entrances = val.entrances; if (entrances == null) { continue; } for (int k = 0; k < entrances.Count; k++) { NodeAccess val2 = entrances[k]; if (val2 != null && val2.fromNode != null && val2.toNode != null) { NewRoom val3 = (((Object)(object)val2.fromNode.room != (Object)null && ((Il2CppObjectBase)val2.fromNode.room).Pointer == ((Il2CppObjectBase)val).Pointer) ? val2.toNode.room : val2.fromNode.room); if (!((Object)(object)val3 == (Object)null) && !hashSet2.Contains(((Il2CppObjectBase)val3).Pointer) && !((Object)(object)val3.building == (Object)null) && !(((Il2CppObjectBase)val3.building).Pointer != ((Il2CppObjectBase)result.Building).Pointer) && hashSet.Add(((Il2CppObjectBase)val3).Pointer)) { Vector3 val4 = (val2.fromNode.position + val2.toNode.position) * 0.5f; Vector3 val5 = Office.RoomCentre(val3); Vector3 val6 = val4 - position; val6.y = 0f; Vector3 val7 = val5 - position; val7.y = 0f; float num = Vector3.Dot(val6, result.Right) * 0.75f + Vector3.Dot(val7, result.Right) * 0.25f; float num2 = Vector3.Dot(val6, result.Forward); float num3 = TypeBonus(val3); result.Candidates.Add(new Candidate { Room = val3, DoorPosition = val4, Centre = val5, RightAmount = num, ForwardAmount = num2, TypeBonus = num3, Score = num - 0.25f * Math.Abs(num2) + num3, Rejected = RejectReason(val3) }); } } } } result.Candidates.Sort((Candidate a, Candidate b) => b.Score.CompareTo(a.Score)); } private static bool IsOutside(NewNode node) { return (Object)(object)node.gameLocation != (Object)null && node.gameLocation.isOutside; } internal static List Split(string csv) { List list = new List(); if (string.IsNullOrEmpty(csv)) { return list; } string[] array = csv.Split(','); foreach (string text in array) { string text2 = text.Trim(); if (text2.Length > 0) { list.Add(text2); } } return list; } private static bool Contains(string haystack, string needle) { return haystack != null && haystack.IndexOf(needle, StringComparison.OrdinalIgnoreCase) >= 0; } private static bool ContainsAny(HashSet haystacks, string needle) { foreach (string haystack in haystacks) { if (Contains(haystack, needle)) { return true; } } return false; } private static void LogUsableDesks() { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown List val = (((Object)(object)Toolbox.Instance != (Object)null) ? Toolbox.Instance.allFurniture : null); if (val == null) { Office.Log.LogInfo((object)"Toolbox.allFurniture is null; cannot list the desks DeskPresetName accepts."); return; } string value = OfficeConfig.ComputerSlotClassName.Value; List list = new List(); for (int i = 0; i < val.Count; i++) { FurniturePreset val2 = val[i]; if ((SoCustomComparison)(object)val2 == (SoCustomComparison)null || val2.subObjects == null) { continue; } for (int j = 0; j < val2.subObjects.Count; j++) { SubObject val3 = val2.subObjects[j]; if (val3 != null && (SoCustomComparison)(object)val3.preset != (SoCustomComparison)null && string.Equals(((Object)val3.preset).name, value, StringComparison.OrdinalIgnoreCase)) { list.Add(((Object)val2).name); break; } } } list.Sort(StringComparer.OrdinalIgnoreCase); ManualLogSource log = Office.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(87, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" furniture preset(s) have a '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' slot and are therefore valid values for DeskPresetName: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(string.Join(", ", list)); } log.LogInfo(val4); } internal static void LogSurvey(Result result) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Expected O, but got Unknown //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Expected O, but got Unknown //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Expected O, but got Unknown //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Expected O, but got Unknown //IL_05d7: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Expected O, but got Unknown //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Expected O, but got Unknown //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Expected O, but got Unknown //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Expected O, but got Unknown //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_0654: Expected O, but got Unknown //IL_059f: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Expected O, but got Unknown //IL_06cc: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Unknown result type (might be due to invalid IL or missing references) //IL_0854: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Expected O, but got Unknown //IL_08a0: Unknown result type (might be due to invalid IL or missing references) ManualLogSource log = Office.Log; log.LogInfo((object)"=== Inspector office: city survey ==="); ManualLogSource val = log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(126, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.Computers.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" distinct computer preset(s) in the city ('*' = has an address-restricted app, i.e. a government-database style install rule):"); } val.LogInfo(val2); for (int i = 0; i < result.Computers.Count; i++) { ComputerInfo computerInfo = result.Computers[i]; string text = (((SoCustomComparison)(object)computerInfo.Desk != (SoCustomComparison)null) ? ((Object)computerInfo.Desk).name : ""); string text2 = ((computerInfo.Slot != null && (SoCustomComparison)(object)computerInfo.Slot.preset != (SoCustomComparison)null) ? ((Object)computerInfo.Slot.preset).name : ""); ManualLogSource val3 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(50, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)computerInfo.Preset).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(computerInfo.AddressRestrictedApps ? "*" : ""); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" x"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(computerInfo.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" most often on furniture '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' in slot class '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'"); } val3.LogInfo(val2); ManualLogSource val4 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(15, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" seen on: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(computerInfo.DescribeDesks()); } val4.LogInfo(val2); } LogUsableDesks(); ManualLogSource val5 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.Buildings.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" building(s) with rooms:"); } val5.LogInfo(val2); for (int j = 0; j < result.Buildings.Count; j++) { BuildingInfo buildingInfo = result.Buildings[j]; if (buildingInfo.ComputerCount == 0 && !OfficeConfig.VerboseDiagnostics.Value) { continue; } ManualLogSource val6 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(52, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" preset='"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(buildingInfo.PresetName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' rooms="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(buildingInfo.RoomCount); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" computers="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(buildingInfo.ComputerCount); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" restrictedAppMachines="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(buildingInfo.RestrictedAppComputerCount); } val6.LogInfo(val2); if (buildingInfo.Apps.Count > 0) { ManualLogSource val7 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(12, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" apps: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(string.Join(", ", buildingInfo.Apps)); } val7.LogInfo(val2); } } foreach (string note in result.Notes) { ManualLogSource val8 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(8, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" note: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(note); } val8.LogInfo(val2); } if ((Object)(object)result.Building == (Object)null) { ManualLogSource val9 = log; BepInExErrorLogInterpolatedStringHandler val10 = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val10).AppendLiteral("City hall not identified. "); ((BepInExLogInterpolatedStringHandler)val10).AppendFormatted(result.Failure); } val9.LogError(val10); return; } ManualLogSource val11 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(25, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("City hall identified by "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.HowFound); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } val11.LogInfo(val2); if (result.InsideEntranceNode != null) { ManualLogSource val12 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(52, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Entrance: outside "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.OutsideEntranceNode.nodeCoord); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" -> inside "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.InsideEntranceNode.nodeCoord); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" at "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.InsideEntranceNode.position); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("; forward "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.Forward); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", right "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.Right); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } val12.LogInfo(val2); ManualLogSource val13 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(56, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Entrance space is "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.EntranceSpace.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" room(s) sharing the lobby address '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(LocationName(result.LobbyLocation)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("':"); } val13.LogInfo(val2); for (int k = 0; k < result.EntranceSpace.Count; k++) { ManualLogSource val14 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(12, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Office.DescribeRoom(result.EntranceSpace[k])); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" centre="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Office.RoomCentre(result.EntranceSpace[k])); } val14.LogInfo(val2); } } ManualLogSource val15 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.Candidates.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" room(s) adjoin the entrance space, best first:"); } val15.LogInfo(val2); for (int l = 0; l < result.Candidates.Count; l++) { Candidate candidate = result.Candidates[l]; string text3 = ((candidate.Rejected != null) ? ("REJECTED (" + candidate.Rejected + ")") : "eligible"); ManualLogSource val16 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(6, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(l); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Office.DescribeRoom(candidate.Room)); } val16.LogInfo(val2); ManualLogSource val17 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(55, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" door="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(candidate.DoorPosition); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" centre="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(candidate.Centre); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" right="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(candidate.RightAmount, "F2"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" forward="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(candidate.ForwardAmount, "F2"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" typeBonus="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(candidate.TypeBonus, "F2"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" score="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(candidate.Score, "F2"); } val17.LogInfo(val2); } if (OfficeConfig.VerboseDiagnostics.Value) { log.LogInfo((object)"All rooms in the city hall:"); List val18 = (((Object)(object)CityData.Instance != (Object)null) ? CityData.Instance.roomDirectory : null); if (val18 != null) { for (int m = 0; m < val18.Count; m++) { NewRoom val19 = val18[m]; if (!((Object)(object)val19 == (Object)null) && !((Object)(object)val19.building == (Object)null) && !(((Il2CppObjectBase)val19.building).Pointer != ((Il2CppObjectBase)result.Building).Pointer) && val19.roomID >= 0) { ManualLogSource val20 = log; val2 = new BepInExInfoLogInterpolatedStringHandler(29, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" roomID="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val19.roomID); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" display='"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(RoomDisplayName(val19)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' centre="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Office.RoomCentre(val19)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Office.DescribeRoom(val19)); } val20.LogInfo(val2); } } } } if (result.Failure != null) { log.LogWarning((object)result.Failure); } log.LogInfo((object)(((Object)(object)result.Office != (Object)null) ? ("Selected office room: " + Office.DescribeRoom(result.Office)) : "No office room selected; nothing will be modified.")); if (OfficeConfig.VerboseDiagnostics.Value && (Object)(object)result.Office != (Object)null) { Office.DumpRoomContents(result.Office); } } } [HarmonyPatch(typeof(FirstPersonItemController), "Update")] internal static class OfficeBootstrapPatch { [HarmonyPostfix] private static void Postfix() { OfficeBootstrap.Tick(); } } internal static class OfficeBootstrap { private const int SettleFrames = 300; private const int MaintainInterval = 120; private const int WaitLogInterval = 600; private static int _frames; private static string _instanceId; private static bool _loggedProceedingAnyway; internal static void Tick() { if (!OfficeConfig.Enabled.Value) { return; } if (!WorldIsReady()) { _frames = 0; return; } if (GameSession.InstanceId == null) { _frames = 0; return; } DetectSessionChange(); if (_frames++ < 300) { return; } if (!Office.Built) { if (ReadyToBuild()) { Office.Build(_frames); } } else if (_frames % 120 == 0) { Office.Maintain(); } } private static bool ReadyToBuild() { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown string text = WhatWeAreWaitingFor(); if (text == null) { return true; } int num = Math.Max(0, OfficeConfig.MaxSetupWaitSeconds.Value) * 60; bool flag = default(bool); if (_frames - 300 >= num) { if (!_loggedProceedingAnyway) { _loggedProceedingAnyway = true; ManualLogSource logger = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(205, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Waited "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(OfficeConfig.MaxSetupWaitSeconds.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s and the city still looks unfinished ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("). Building the office anyway - if it comes out with the previous occupant's furniture still in it, raise MaxSetupWaitSeconds or lower MinCityInteractables."); } logger.LogWarning(val); } return true; } if (_frames % 600 == 0) { ManualLogSource logger2 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(73, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Holding off on office setup until the city has finished generating ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } logger2.LogInfo(val2); } return false; } private static string WhatWeAreWaitingFor() { string text = GameSession.StillLoading(); if (text != null) { return text; } int num = CityObjectCount(); int value = OfficeConfig.MinCityInteractables.Value; if (num < value) { return $"the city holds {num} object(s), fewer than the {value} that mean it is furnished"; } return null; } private static int CityObjectCount() { try { return (((Object)(object)CityData.Instance != (Object)null) ? CityData.Instance.interactableDirectory : null)?.Count ?? 0; } catch { return 0; } } private static bool WorldIsReady() { try { return (Object)(object)Player.Instance != (Object)null && (Object)(object)Toolbox.Instance != (Object)null && (Object)(object)RoutineControls.Instance != (Object)null && (Object)(object)InteriorControls.Instance != (Object)null && (Object)(object)InteractableCreator.Instance != (Object)null && (Object)(object)CityData.Instance != (Object)null && CityData.Instance.roomDirectory != null && CityData.Instance.roomDirectory.Count > 0; } catch { return false; } } private static void DetectSessionChange() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown string instanceId = GameSession.InstanceId; if (instanceId == null || _instanceId == instanceId) { return; } if (_instanceId != null) { ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(56, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] City instance changed ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_instanceId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(instanceId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); resetting office state."); } logger.LogInfo(val); Office.Reset(); _frames = 0; _loggedProceedingAnyway = false; } _instanceId = instanceId; } } [HarmonyPatch(typeof(NewRoom), "GetName")] internal static class NewRoom_GetName_Patch { [HarmonyPostfix] private static void Postfix(NewRoom __instance, ref string __result) { if (OfficeConfig.Enabled.Value && Office.IsOffice(__instance)) { __result = Office.RoomName(); } } } internal static class OfficeDoorNaming { internal static bool LeadsIntoOffice(NewDoor door) { if (!OfficeConfig.Enabled.Value || (Object)(object)Office.Room == (Object)null || (Object)(object)door == (Object)null) { return false; } if (Office.IsOffice(door.playerOtherSideRoom)) { return true; } try { NewRoom val = (((Object)(object)Player.Instance != (Object)null) ? ((Actor)Player.Instance).currentRoom : null); if ((Object)(object)val == (Object)null) { return false; } NewNode infontNode = door.GetInfontNode(); NewNode behindNode = door.GetBehindNode(); NewRoom val2 = ((infontNode != null) ? infontNode.room : null); NewRoom val3 = ((behindNode != null) ? behindNode.room : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { return false; } NewRoom room = ((((Il2CppObjectBase)val2).Pointer == ((Il2CppObjectBase)val).Pointer) ? val3 : val2); return Office.IsOffice(room); } catch { return false; } } } [HarmonyPatch(typeof(NewDoor), "GetName")] internal static class NewDoor_GetName_Patch { [HarmonyPostfix] private static void Postfix(NewDoor __instance, ref string __result) { if (OfficeDoorNaming.LeadsIntoOffice(__instance)) { __result = Office.RoomName(); } } } [HarmonyPatch(typeof(NewDoor), "GetNameForParent")] internal static class NewDoor_GetNameForParent_Patch { [HarmonyPostfix] private static void Postfix(NewDoor __instance, ref string __result) { if (OfficeDoorNaming.LeadsIntoOffice(__instance)) { __result = Office.RoomName(); } } } internal static class OfficeDecorRedirect { internal static NewRoom Substitute(NewRoom room) { if (!OfficeConfig.Enabled.Value || !OfficeConfig.AllowDecorating.Value || (Object)(object)Office.Room == (Object)null) { return room; } if ((Object)(object)room == (Object)null || !Office.IsInCityHall(room) || Office.IsOffice(room)) { return room; } return Office.Room; } } [HarmonyPatch(typeof(FurnishingsController), "Setup")] internal static class FurnishingsController_Setup_Patch { [HarmonyPostfix] private static void Postfix(FurnishingsController __instance) { __instance.room = OfficeDecorRedirect.Substitute(__instance.room); } } [HarmonyPatch(typeof(FurnishingsController), "OnEnable")] internal static class FurnishingsController_OnEnable_Patch { [HarmonyPostfix] private static void Postfix(FurnishingsController __instance) { __instance.room = OfficeDecorRedirect.Substitute(__instance.room); } } [HarmonyPatch(typeof(DecorController), "Setup")] internal static class DecorController_Setup_Patch { [HarmonyPostfix] private static void Postfix(DecorController __instance) { __instance.room = OfficeDecorRedirect.Substitute(__instance.room); } } [HarmonyPatch(typeof(DecorController), "OnEnable")] internal static class DecorController_OnEnable_Patch { [HarmonyPostfix] private static void Postfix(DecorController __instance) { __instance.room = OfficeDecorRedirect.Substitute(__instance.room); } } [HarmonyPatch(typeof(PlayerApartmentController), "ExecutePlacement")] internal static class PlayerApartment_ExecutePlacement_Patch { [HarmonyPostfix] private static void Postfix() { if (Office.Built && !((Object)(object)Office.Room == (Object)null)) { OfficeBuilder.RepairMissingObjects(Office.Room); if (Office.Desk != null && Office.ComputerSlot != null && (SoCustomComparison)(object)Office.ComputerPreset != (SoCustomComparison)null) { OfficeBuilder.EnsureComputer(Office.Room, Office.Desk, Office.ComputerSlot, Office.ComputerPreset, deepScan: false); } } } } [HarmonyPatch(typeof(PlayerApartmentController), "RemoveFromStorage")] internal static class PlayerApartment_RemoveFromStorage_Patch { [HarmonyPostfix] private static void Postfix() { if (Office.Built && (Object)(object)Office.Room != (Object)null) { OfficeBuilder.RepairMissingObjects(Office.Room); } } } [HarmonyPatch(typeof(PlayerApartmentController), "RemoveItemFromStorage")] internal static class PlayerApartment_RemoveItemFromStorage_Patch { [HarmonyPostfix] private static void Postfix() { if (Office.Built && (Object)(object)Office.Room != (Object)null) { OfficeBuilder.RepairMissingObjects(Office.Room); } } } [HarmonyPatch(typeof(PlayerApartmentController), "SetFurniturePlacementMode")] internal static class PlayerApartment_SetFurniturePlacementMode_Patch { [HarmonyPrefix] private static void Prefix(ref NewRoom forRoom) { forRoom = OfficeDecorRedirect.Substitute(forRoom); } } [HarmonyPatch(typeof(PlayerApartmentController), "SetDecoratingMode")] internal static class PlayerApartment_SetDecoratingMode_Patch { [HarmonyPrefix] private static void Prefix(ref NewRoom forRoom) { forRoom = OfficeDecorRedirect.Substitute(forRoom); } } internal static class OfficeWindows { private static bool _applied; private static bool _loggedCatalogue; private static readonly Dictionary _originals = new Dictionary(); private static readonly string[] PreferredWindows = new string[4] { "WindowLargeRectangle", "WindowLargeArch", "WindowMediumRectangle", "WindowDiner" }; internal static void ResetSession() { _applied = false; _loggedCatalogue = false; _originals.Clear(); } internal static void Apply(NewRoom room, NewBuilding building) { //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Expected O, but got Unknown //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Expected O, but got Unknown if ((Object)(object)room == (Object)null) { return; } bool flag = default(bool); try { LoadRecordedOriginals(); if (OfficeConfig.RestoreWalls.Value) { Restore(room); } else { if (!OfficeConfig.Windows.Value || _applied) { return; } _applied = true; List list = CollectWalls(room); if (list.Count == 0) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(80, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: the office room reports no walls at all. Nothing was changed."); } log.LogWarning(val); return; } if (OfficeConfig.WindowDiagnostics.Value) { LogPresetCatalogue(); } string description; List list2 = ChooseBackWallRun(room, list, out description); if (OfficeConfig.WindowDiagnostics.Value) { LogWallSurvey(room, list, list2, description); } if (list2.Count == 0) { ManualLogSource log2 = Office.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(135, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: no exterior wall run was found to cut ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(description); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("). Nothing was changed - the wall survey above lists every wall the room has."); } log2.LogError(val2); return; } int num = 3; if (num > list2.Count) { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(85, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" windows asked for but the back wall only has "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(list2.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" section(s). Using "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(list2.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log3.LogWarning(val); num = list2.Count; } LogSections(list2); List list3 = PickSections(list2, num); DoorPairPreset val3 = ChooseWindowPreset(); if ((ScriptableObjectIDSystem)(object)val3 == (ScriptableObjectIDSystem)null) { ManualLogSource log4 = Office.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(139, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: could not resolve a window DoorPairPreset. Nothing was changed. Set WindowPresetName by hand from the preset list above."); } log4.LogError(val2); return; } ManualLogSource log5 = Office.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(87, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Office windows: cutting "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(list3.Count); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" window(s) into the "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(description); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" using preset '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Object)val3).name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' (sectionClass="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val3.sectionClass); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("). View="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(OfficeConfig.View.Value); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("."); } log5.LogInfo(val4); RevertOthersInRun(list2, list3); List list4 = new List(); for (int i = 0; i < list3.Count; i++) { if (Glaze(list3[i], val3, room, building)) { list4.Add(list3[i]); } } SaveRecordedOriginals(); if (list4.Count == 0) { ManualLogSource log6 = Office.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(68, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: every wall swap was rejected. Nothing to rebuild."); } log6.LogError(val2); } else { UpdateSegments(list2); Rebuild(room); Verify(room, list4, val3); ClearOutside(list4); ApplyViewMode(list4); } } } catch (Exception ex) { ManualLogSource log7 = Office.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log7.LogError(val2); } } private static List CollectWalls(NewRoom room) { HashSet hashSet = new HashSet(); List list = new List(); List list2 = Office.RoomNodes(room); for (int i = 0; i < list2.Count; i++) { List walls = list2[i].walls; if (walls == null) { continue; } int count = walls.Count; for (int j = 0; j < count; j++) { NewWall val = walls[j]; if (val != null && hashSet.Add(val.id)) { list.Add(val); } } } return list; } private static Vector3 OutwardDirection(NewWall wall) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (wall.node != null) { Vector3 val = wall.position - wall.node.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.0001f) { return ((Vector3)(ref val)).normalized; } } Vector2 wallOffset = wall.wallOffset; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(wallOffset.x, 0f, wallOffset.y); return (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val2)).normalized : Vector3.zero; } private static string FacingKey(NewWall wall) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) Vector2 wallOffset = wall.wallOffset; return $"{Mathf.RoundToInt(wallOffset.x * 2f)},{Mathf.RoundToInt(wallOffset.y * 2f)}"; } private static bool FacesOutside(NewWall wall) { NewWall val = ((wall != null) ? wall.otherWall : null); NewRoom val2 = ((val != null && val.node != null) ? val.node.room : null); if ((Object)(object)val2 == (Object)null) { return false; } try { return val2.IsOutside(); } catch { return false; } } private static List ChooseBackWallRun(NewRoom room, List walls, out string description) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) NewNode val = OfficeBuilder.FindRoomDoorNode(room); Vector3 val2 = Office.RoomCentre(room); Vector3 val3 = ((val != null) ? (val2 - val.position) : Vector3.zero); val3.y = 0f; bool flag = ((Vector3)(ref val3)).sqrMagnitude > 0.0001f; if (flag) { val3 = ((Vector3)(ref val3)).normalized; } Dictionary> dictionary = new Dictionary>(); for (int i = 0; i < walls.Count; i++) { NewWall val4 = walls[i]; if (FacesOutside(val4) && !((Object)(object)val4.door != (Object)null)) { string key = FacingKey(val4); if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = new List()); } value.Add(val4); } } if (dictionary.Count == 0) { description = "no wall opening onto the outside without a door already in it"; return new List(); } List list2 = null; float num = float.NegativeInfinity; string value2 = null; Vector3 val5 = Vector3.zero; foreach (KeyValuePair> item in dictionary) { Vector3 val6 = Vector3.zero; for (int j = 0; j < item.Value.Count; j++) { val6 += OutwardDirection(item.Value[j]); } val6.y = 0f; if (((Vector3)(ref val6)).sqrMagnitude > 0.0001f) { val6 = ((Vector3)(ref val6)).normalized; } float num2 = (flag ? Vector3.Dot(val6, val3) : 0f) + (float)item.Value.Count * 0.01f; if (num2 > num) { num = num2; list2 = item.Value; value2 = item.Key; val5 = val6; } } Vector3 lateral = new Vector3(val5.z, 0f, 0f - val5.x); list2.Sort((NewWall a, NewWall b) => Vector3.Dot(a.position, lateral).CompareTo(Vector3.Dot(b.position, lateral))); description = (flag ? $"back wall (facing {value2}, {list2.Count} section(s), dot={num:F2} against the way in from the door)" : $"longest exterior wall (facing {value2}, {list2.Count} section(s)) - no door was found to measure from"); return list2; } private static void LogSections(List run) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < run.Count; i++) { if (stringBuilder.Length > 0) { stringBuilder.Append(" "); } Vector3 position = run[i].position; stringBuilder.Append('[').Append(i).Append("] ") .Append(position.x.ToString("F1")) .Append(',') .Append(position.z.ToString("F1")); } ManualLogSource log = Office.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(129, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: the back wall has "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(run.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" section(s), numbered left to right: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(stringBuilder); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Name them in WindowSections to place windows by hand."); } log.LogInfo(val); } private static List PickSections(List run, int want) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown string value = OfficeConfig.WindowSections.Value; if (string.IsNullOrEmpty(value)) { return CentreBlock(run, want); } List list = new List(); HashSet hashSet = new HashSet(); string[] array = value.Split(new char[2] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); bool flag = default(bool); for (int i = 0; i < array.Length; i++) { if (!int.TryParse(array[i].Trim(), out var result)) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(72, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: WindowSections entry '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(array[i]); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' is not a number; ignoring it."); } log.LogWarning(val); } else if (result < 0 || result >= run.Count) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(97, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: WindowSections asks for section "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(result); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" but this wall only has "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(run.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (0 to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(run.Count - 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); ignoring it."); } log2.LogWarning(val); } else if (hashSet.Add(result)) { list.Add(run[result]); } } if (list.Count == 0) { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(105, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: WindowSections='"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' named no usable section, so falling back to centring "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(want); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" automatically."); } log3.LogWarning(val); return CentreBlock(run, want); } ManualLogSource log4 = Office.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(102, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: placing "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" window(s) by hand from WindowSections='"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("', ignoring the automatic centring."); } log4.LogInfo(val2); return list; } private static List CentreBlock(List run, int want) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (run.Count == 0 || want <= 0) { return list; } if (want >= run.Count) { list.AddRange(run); return list; } Vector3 val = Vector3.zero; for (int i = 0; i < run.Count; i++) { val += run[i].position; } val /= (float)run.Count; int num = 0; float num2 = float.PositiveInfinity; for (int j = 0; j < run.Count; j++) { Vector3 val2 = run[j].position - val; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num2) { num2 = sqrMagnitude; num = j; } } if (want % 2 == 1) { list.Add(run[num]); } int num3 = 1; while (list.Count < want) { int num4 = num - num3; int num5 = num + num3; bool flag = num4 >= 0; bool flag2 = num5 < run.Count; if (!flag && !flag2) { break; } if (want % 2 == 1) { if (flag && list.Count < want) { list.Add(run[num4]); } if (flag2 && list.Count < want) { list.Add(run[num5]); } } else { int num6 = num - num3; int num7 = num + num3; if (num6 >= 0 && list.Count < want) { list.Add(run[num6]); } if (num7 < run.Count && list.Count < want) { list.Add(run[num7]); } } num3++; } list.Sort((NewWall a, NewWall b) => run.IndexOf(a).CompareTo(run.IndexOf(b))); return list; } private static DoorPairPreset ChooseWindowPreset() { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) string value = OfficeConfig.WindowPresetName.Value; bool flag = default(bool); if (!string.IsNullOrEmpty(value)) { DoorPairPreset val = FindPresetByName(value); BepInExWarningLogInterpolatedStringHandler val2; if ((ScriptableObjectIDSystem)(object)val != (ScriptableObjectIDSystem)null) { if (!IsWindowClass(val)) { ManualLogSource log = Office.Log; val2 = new BepInExWarningLogInterpolatedStringHandler(105, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)val).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' is section "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.sectionClass); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", not a window class. Installing it anyway because it was named by hand."); } log.LogWarning(val2); } return val; } ManualLogSource log2 = Office.Log; val2 = new BepInExWarningLogInterpolatedStringHandler(97, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: WindowPresetName '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' matched no DoorPairPreset. Falling back to auto-detection."); } log2.LogWarning(val2); } for (int i = 0; i < PreferredWindows.Length; i++) { DoorPairPreset val3 = FindPresetByName(PreferredWindows[i]); if (!((ScriptableObjectIDSystem)(object)val3 == (ScriptableObjectIDSystem)null)) { ManualLogSource log3 = Office.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(111, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Office windows: using '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Object)val3).name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' - first available of the known-good window presets. Override with WindowPresetName."); } log3.LogInfo(val4); return val3; } } ManualLogSource log4 = Office.Log; BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(132, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Office windows: none of the known window presets ("); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(string.Join(", ", PreferredWindows)); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(") exist in this build. Set WindowPresetName by hand from the preset list above."); } log4.LogError(val5); return null; } private static bool IsWindowClass(DoorPairPreset preset) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 return (ScriptableObjectIDSystem)(object)preset != (ScriptableObjectIDSystem)null && ((int)preset.sectionClass == 1 || (int)preset.sectionClass == 2); } private static DoorPairPreset FindPresetByName(string name) { foreach (DoorPairPreset item in AllPresets()) { if (string.Equals(((Object)item).name, name, StringComparison.OrdinalIgnoreCase)) { return item; } } return null; } private static List AllPresets() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown List list = new List(); try { AssetLoader instance = AssetLoader.Instance; if (instance == null) { return list; } List allDoorPairPresets = instance.GetAllDoorPairPresets(); if (allDoorPairPresets == null) { return list; } int count = allDoorPairPresets.Count; for (int i = 0; i < count; i++) { if ((ScriptableObjectIDSystem)(object)allDoorPairPresets[i] != (ScriptableObjectIDSystem)null) { list.Add(allDoorPairPresets[i]); } } } catch (Exception ex) { ManualLogSource log = Office.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(58, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: reading the DoorPairPreset list threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } return list; } private static bool Glaze(NewWall wall, DoorPairPreset preset, NewRoom room, NewBuilding building) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown if (wall == null || (ScriptableObjectIDSystem)(object)preset == (ScriptableObjectIDSystem)null) { return false; } string text = (((ScriptableObjectIDSystem)(object)wall.preset != (ScriptableObjectIDSystem)null) ? ((Object)wall.preset).name : ""); if (!((ScriptableObjectIDSystem)(object)wall.preset != (ScriptableObjectIDSystem)null) || !IsWindowClass(wall.preset)) { RecordOriginal(wall, text); } bool flag = default(bool); try { wall.SetDoorPairPreset(preset, true, false, true); } catch (Exception ex) { ManualLogSource log = Office.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(53, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: SetDoorPairPreset threw on wall "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); return false; } string text2 = (((ScriptableObjectIDSystem)(object)wall.preset != (ScriptableObjectIDSystem)null) ? ((Object)wall.preset).name : ""); if (text2 != ((Object)preset).name) { ManualLogSource log2 = Office.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(74, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: wall "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" rejected the swap - wanted '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)preset).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("', reads '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' (was '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("')."); } log2.LogError(val); return false; } if (OfficeConfig.PreventWallMerging.Value) { try { wall.optimizationOverride = true; } catch (Exception ex2) { ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(64, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: could not set optimizationOverride on wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2.Message); } log3.LogWarning(val2); } } EnsureFrontage(wall, preset, room, building); ManualLogSource log4 = Office.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(45, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Office windows: wall "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' -> '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("', frontage="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(FrontageCount(wall)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } log4.LogInfo(val3); return true; } private static void EnsureFrontage(NewWall wall, DoorPairPreset preset, NewRoom room, NewBuilding building) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Expected O, but got Unknown //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05ac: Expected O, but got Unknown //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Expected O, but got Unknown //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Expected O, but got Unknown //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Expected O, but got Unknown //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Expected O, but got Unknown if (FrontageCount(wall) > 0) { return; } bool flag = default(bool); if ((Object)(object)building != (Object)null && (Object)(object)room != (Object)null && (SoCustomComparison)(object)room.preset != (SoCustomComparison)null) { try { List val = building.SelectFrontage(room.preset, preset); if (val != null && val.Count > 0) { wall.frontagePresets = val; wall.SpawnFrontage(false, (MaterialKey)null); if (FrontageCount(wall) > 0) { return; } } } catch (Exception ex) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(51, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: SelectFrontage threw for wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log.LogWarning(val2); } } FrontageSetting val3 = FindDonorFrontage(wall, room); if (val3 != null) { try { FrontageSetting val4 = new FrontageSetting { preset = val3.preset, matKey = val3.matKey, colors = val3.colors, offset = val3.offset }; List val5 = new List(); val5.Add(val4); wall.frontagePresets = val5; wall.SpawnFrontage(false, (MaterialKey)null); if (FrontageCount(wall) > 0) { ManualLogSource log2 = Office.Log; BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(86, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("] Office windows: glazed wall "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" by copying a real window's glass - preset '"); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(((SoCustomComparison)(object)val3.preset != (SoCustomComparison)null) ? ((Object)val3.preset).name : ""); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("', matKey "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted((val3.matKey != (MaterialKey)null) ? "copied" : "absent on the donor too"); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("."); } log2.LogInfo(val6); return; } ManualLogSource log3 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(96, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: copied frontage did not stick on wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("; falling back to building one by name."); } log3.LogWarning(val2); } catch (Exception ex2) { ManualLogSource log4 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(67, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: copying a real window's glass onto wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2.Message); } log4.LogWarning(val2); } } string value = OfficeConfig.WindowFrontageName.Value; if (string.IsNullOrEmpty(value)) { ManualLogSource log5 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(137, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" got no frontage from the building, no window to copy, and WindowFrontageName is blank, so it stays an open hole."); } log5.LogWarning(val2); return; } WallFrontagePreset val7 = FindFrontageByName(value); if ((SoCustomComparison)(object)val7 == (SoCustomComparison)null) { ManualLogSource log6 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(146, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: WindowFrontageName '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' matched no WallFrontagePreset, so wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" stays an open hole. The frontage list above has every valid name."); } log6.LogWarning(val2); return; } try { FrontageSetting val8 = new FrontageSetting { preset = val7, offset = Vector3.zero }; List val9 = new List(); val9.Add(val8); wall.frontagePresets = val9; wall.SpawnFrontage(false, (MaterialKey)null); if (FrontageCount(wall) > 0) { ManualLogSource log7 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(145, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: glazed wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" with a hand-built '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)val7).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' and no material key - this is the version that came out as an open hole, so expect no glass."); } log7.LogWarning(val2); } else { ManualLogSource log8 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(62, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: hand-built frontage did not stick on wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log8.LogWarning(val2); } } catch (Exception ex3) { ManualLogSource log9 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(45, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: hand-glazing wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex3.Message); } log9.LogWarning(val2); } } private static FrontageSetting FindDonorFrontage(NewWall exclude, NewRoom room) { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown FrontageSetting val = FindDonorIn(Office.RoomNodes(room), exclude); if (val != null) { return val; } try { List val2 = (((Object)(object)CityData.Instance != (Object)null) ? CityData.Instance.roomDirectory : null); if (val2 == null) { return null; } NewBuilding val3 = (((Object)(object)room != (Object)null) ? room.building : null); int count = val2.Count; for (int i = 0; i < count; i++) { NewRoom val4 = val2[i]; if (!((Object)(object)val4 == (Object)null) && !((Object)(object)val4.building == (Object)null) && !((Object)(object)val3 == (Object)null) && !(((Il2CppObjectBase)val4.building).Pointer != ((Il2CppObjectBase)val3).Pointer)) { val = FindDonorIn(Office.RoomNodes(val4), exclude); if (val != null) { return val; } } } } catch (Exception ex) { ManualLogSource log = Office.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(70, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Office windows: searching the building for a window to copy threw: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(ex.Message); } log.LogWarning(val5); } return null; } private static FrontageSetting FindDonorIn(List nodes, NewWall exclude) { for (int i = 0; i < nodes.Count; i++) { List walls = nodes[i].walls; if (walls == null) { continue; } int count = walls.Count; for (int j = 0; j < count; j++) { NewWall val = walls[j]; if (val == null || val.id == exclude.id || (ScriptableObjectIDSystem)(object)val.preset == (ScriptableObjectIDSystem)null || !IsWindowClass(val.preset)) { continue; } List frontagePresets = val.frontagePresets; if (frontagePresets != null && frontagePresets.Count != 0) { FrontageSetting val2 = frontagePresets[0]; if (val2 != null && (SoCustomComparison)(object)val2.preset != (SoCustomComparison)null) { return val2; } } } } return null; } private static WallFrontagePreset FindFrontageByName(string name) { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown try { Toolbox instance = Toolbox.Instance; if ((Object)(object)instance == (Object)null || instance.wallFrontageStyleRef == null) { return null; } Enumerator>> enumerator = instance.wallFrontageStyleRef.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair>> current = enumerator.Current; if (current.Value == null) { continue; } Enumerator> enumerator2 = current.Value.GetEnumerator(); while (enumerator2.MoveNext()) { KeyValuePair> current2 = enumerator2.Current; List value = current2.Value; if (value == null) { continue; } int count = value.Count; for (int i = 0; i < count; i++) { WallFrontagePreset val = value[i]; if ((SoCustomComparison)(object)val != (SoCustomComparison)null && string.Equals(((Object)val).name, name, StringComparison.OrdinalIgnoreCase)) { return val; } } } } } catch (Exception ex) { ManualLogSource log = Office.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(59, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: searching the frontage catalogue threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log.LogWarning(val2); } return null; } private static int FrontageCount(NewWall wall) { return (wall != null && wall.frontagePresets != null) ? wall.frontagePresets.Count : 0; } private static void ClearOutside(List windows) { //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Expected O, but got Unknown //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Expected O, but got Unknown bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val; if (!OfficeConfig.ClearOutsideWindows.Value) { ManualLogSource log = Office.Log; val = new BepInExInfoLogInterpolatedStringHandler(106, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: ClearOutsideWindows is off, so whatever is standing outside the windows was left alone."); } log.LogInfo(val); return; } int num = Math.Max(0, OfficeConfig.MaxClearedOutside.Value); int num2 = 0; for (int i = 0; i < windows.Count; i++) { NewWall val2 = windows[i]; NewWall otherWall = val2.otherWall; NewNode val3 = ((otherWall != null) ? otherWall.node : null); if (val3 == null) { ManualLogSource log2 = Office.Log; val = new BepInExInfoLogInterpolatedStringHandler(94, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: wall "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val2.id); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has no node on the far side, so there is nothing outside it to clear."); } log2.LogInfo(val); continue; } string text = (((Object)(object)val3.room != (Object)null) ? val3.room.name : ""); ManualLogSource log3 = Office.Log; val = new BepInExInfoLogInterpolatedStringHandler(48, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: outside wall "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val2.id); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is node "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val3.nodeCoord); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" in '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'."); } log3.LogInfo(val); float reach = Mathf.Max(0f, OfficeConfig.ClearOutsideRadius.Value); List list = new List(); HashSet hashSet = new HashSet(); foreach (NewNode item in NodesWithinReach(val3, val2, reach)) { LogNodeContents(item); List individualFurniture = item.individualFurniture; if (individualFurniture == null) { continue; } int count = individualFurniture.Count; for (int j = 0; j < count; j++) { FurnitureLocation val4 = individualFurniture[j]; if (val4 != null && !((SoCustomComparison)(object)val4.furniture == (SoCustomComparison)null) && !val4.userPlaced && hashSet.Add(((Il2CppObjectBase)val4).Pointer)) { list.Add(val4); } } } for (int k = 0; k < list.Count; k++) { if (num2 >= num) { break; } string text2 = (((SoCustomComparison)(object)list[k].furniture != (SoCustomComparison)null) ? ((Object)list[k].furniture).name : "?"); try { list[k].Delete(true, (RemoveInteractablesOption)1); num2++; ManualLogSource log4 = Office.Log; val = new BepInExInfoLogInterpolatedStringHandler(49, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: cleared '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' from outside wall "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val2.id); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log4.LogInfo(val); } catch (Exception ex) { ManualLogSource log5 = Office.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(53, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Office windows: could not clear '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' outside wall "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(val2.id); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(ex.Message); } log5.LogWarning(val5); } } if (num2 >= num && list.Count > 0) { ManualLogSource log6 = Office.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(88, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Office windows: hit the MaxClearedOutside limit of "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("; anything left outside stays put."); } log6.LogWarning(val5); } } ManualLogSource log7 = Office.Log; val = new BepInExInfoLogInterpolatedStringHandler(74, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: cleared "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" item(s) from the pavement outside the windows."); } log7.LogInfo(val); } private static List NodesWithinReach(NewNode from, NewWall wall, float reach) { //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) List list = new List { from }; if (reach <= 0.01f || (Object)(object)from.room == (Object)null) { return list; } Vector3 val = OutwardDirection(wall); Vector3 position = wall.position; try { foreach (NewNode item in Office.RoomNodes(from.room)) { if (item != null && !(((Il2CppObjectBase)item).Pointer == ((Il2CppObjectBase)from).Pointer)) { Vector3 val2 = item.position - position; val2.y = 0f; if (!(((Vector3)(ref val2)).magnitude > reach) && !(Vector3.Dot(val2, val) <= 0f)) { list.Add(item); } } } } catch (Exception ex) { ManualLogSource log = Office.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(54, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Office windows: sweeping the street outside threw: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log.LogWarning(val3); } return list; } private static void LogNodeContents(NewNode node) { //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown bool flag = default(bool); try { List individualFurniture = node.individualFurniture; StringBuilder stringBuilder = new StringBuilder(); if (individualFurniture != null) { int count = individualFurniture.Count; for (int i = 0; i < count; i++) { if (individualFurniture[i] != null && !((SoCustomComparison)(object)individualFurniture[i].furniture == (SoCustomComparison)null)) { if (stringBuilder.Length > 0) { stringBuilder.Append(", "); } stringBuilder.Append(((Object)individualFurniture[i].furniture).name).Append(individualFurniture[i].userPlaced ? " (yours)" : ""); } } } List interactables = node.interactables; StringBuilder stringBuilder2 = new StringBuilder(); if (interactables != null) { int count2 = interactables.Count; for (int j = 0; j < count2; j++) { if (interactables[j] != null && !((SoCustomComparison)(object)interactables[j].preset == (SoCustomComparison)null)) { if (stringBuilder2.Length > 0) { stringBuilder2.Append(", "); } stringBuilder2.Append(((Object)interactables[j].preset).name); } } } ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(57, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: furniture out there: ["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(stringBuilder); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] objects: ["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(stringBuilder2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]"); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(50, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: listing what is outside threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log2.LogWarning(val2); } } private static int SpawnedRoomIndex(GenerationController generator, NewRoom room) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown try { List spawnedRooms = generator.spawnedRooms; if (spawnedRooms == null) { return -1; } int count = spawnedRooms.Count; for (int i = 0; i < count; i++) { if ((Object)(object)spawnedRooms[i] != (Object)null && ((Il2CppObjectBase)spawnedRooms[i]).Pointer == ((Il2CppObjectBase)room).Pointer) { return i; } } } catch (Exception ex) { ManualLogSource log = Office.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(73, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: looking the office up in the spawned-room list threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } return -1; } private static void UpdateSegments(List run) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown int num = 0; bool flag = default(bool); for (int i = 0; i < run.Count; i++) { try { run[i].UpdateSegmentData(); num++; } catch (Exception ex) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(53, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: UpdateSegmentData threw on wall "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(run[i].id); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } ManualLogSource log2 = Office.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(72, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: recomputed wall segments for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(run.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" section(s) of the run."); } log2.LogInfo(val2); } private static void Rebuild(NewRoom room) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown bool flag = default(bool); try { GenerationController instance = GenerationController.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)room.floor == (Object)null) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(130, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: no GenerationController or floor to rebuild through; the windows will appear the next time this save is loaded."); } log.LogWarning(val); } else { instance.UpdateGeometryFloor(room.floor, "TheInspector office windows"); Office.Log.LogWarning((object)"[CalebScott.TheInspector] Office windows: the windows are in the city data now, but they are drawn when the game builds the room from a save. Save this game and load that save to see them. This applies to a brand new city as much as an existing one, and walking out of the room and back in is not enough."); } } catch (Exception ex) { ManualLogSource log2 = Office.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(170, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: queueing the geometry rebuild threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(". The wall data is already changed, so the windows should still appear on the next load; RestoreWalls undoes them."); } log2.LogError(val2); } } private static void Verify(NewRoom room, List changed, DoorPairPreset wanted) { //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) int num = 0; List list = new List(); bool flag = default(bool); for (int i = 0; i < changed.Count; i++) { NewWall val = changed[i]; string text = (((ScriptableObjectIDSystem)(object)val.preset != (ScriptableObjectIDSystem)null) ? ((Object)val.preset).name : ""); if (text == ((Object)wanted).name) { num++; } else { list.Add($"{val.id}->'{text}'"); } int num2 = ((val.spawnedFrontage != null) ? val.spawnedFrontage.Count : (-1)); ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(72, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" at "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.position); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" reads '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("', "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("frontagePresets="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(FrontageCount(val)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" spawnedFrontage="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); } log.LogInfo(val2); } LogRoomWindows(room); int num3 = ((room.windows != null) ? room.windows.Count : (-1)); int num4 = ((room.windowsWithUVData != null) ? room.windowsWithUVData.Count : (-1)); if (list.Count == 0) { ManualLogSource log2 = Office.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(79, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(changed.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" held after the rebuild. Room reports windows="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" withUVData="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num4); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log2.LogInfo(val2); return; } ManualLogSource log3 = Office.Log; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(98, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Office windows: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(changed.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" wall(s) did not keep the window preset - "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(string.Join(", ", list)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(". Room reports windows="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" withUVData="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num4); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } log3.LogError(val3); } private static void ApplyViewMode(List windows) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown WindowView value = OfficeConfig.View.Value; bool flag = default(bool); for (int i = 0; i < windows.Count; i++) { NewWall val = windows[i]; List list = FrontageRenderers(val); int count = list.Count; list.AddRange(FrontageRenderers(val.otherWall)); if (list.Count > count) { ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(103, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" has "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" pane part(s) inside and "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(list.Count - count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" on the street side; both get the same treatment."); } log.LogInfo(val2); } if (list.Count == 0) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(97, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Office windows: wall "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val.id); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" has no frontage renderer to work with, so View="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" cannot be applied to it."); } log2.LogWarning(val3); continue; } if (OfficeConfig.WindowDiagnostics.Value) { for (int j = 0; j < list.Count; j++) { LogRenderer(val, list[j]); } } WakeGlass(val, list); if (value == WindowView.FrostedNoir) { FrostGlass(val, list); } } } private static void WakeGlass(NewWall wall, List renderers) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown int num = 0; bool flag2 = default(bool); for (int i = 0; i < renderers.Count; i++) { Renderer val = renderers[i]; try { Il2CppReferenceArray sharedMaterials = val.sharedMaterials; bool flag = false; if (sharedMaterials != null) { for (int j = 0; j < ((Il2CppArrayBase)(object)sharedMaterials).Length; j++) { if ((Object)(object)((Il2CppArrayBase)(object)sharedMaterials)[j] != (Object)null && IsGlass(((Il2CppArrayBase)(object)sharedMaterials)[j])) { flag = true; } } } if (flag) { if (!((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); num++; } if (!val.enabled) { val.enabled = true; num++; } } } catch (Exception ex) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(51, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: waking the pane on wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log.LogWarning(val2); } } if (num > 0) { ManualLogSource log2 = Office.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(137, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Office windows: switched the glass back on for wall "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" change(s)) - it had spawned disabled, which is why the window was an open hole."); } log2.LogInfo(val3); } } private static void FrostGlass(NewWall wall, List renderers) { //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Expected O, but got Unknown //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(OfficeConfig.FrostedRoughness.Value); int num2 = 0; List list = new List(); bool flag = default(bool); for (int i = 0; i < renderers.Count; i++) { try { Il2CppReferenceArray materials = renderers[i].materials; if (materials == null) { continue; } for (int j = 0; j < ((Il2CppArrayBase)(object)materials).Length; j++) { Material val = ((Il2CppArrayBase)(object)materials)[j]; if (!((Object)(object)val == (Object)null) && IsGlass(val)) { num2++; if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", num); list.Add($"_Smoothness={num:F2}"); } float num3 = Mathf.Clamp01(OfficeConfig.FrostedHaze.Value); if (num3 > 0f && val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", new Color(0.88f, 0.86f, 0.82f, num3)); list.Add($"_BaseColor haze={num3:F2}"); } if (val.HasProperty("_ThicknessMultiplier")) { val.SetFloat("_ThicknessMultiplier", 0.02f); list.Add("_ThicknessMultiplier"); } if (val.HasProperty("_RefractionModel")) { val.SetFloat("_RefractionModel", 3f); list.Add("_RefractionModel=thin"); } if (val.HasProperty("_Ior")) { val.SetFloat("_Ior", 1.45f); list.Add("_Ior"); } if (val.HasProperty("_TransmittanceColor")) { val.SetColor("_TransmittanceColor", new Color(0.82f, 0.8f, 0.74f)); list.Add("_TransmittanceColor"); } val.DisableKeyword("_REFRACTION_PLANE"); val.DisableKeyword("_REFRACTION_SPHERE"); val.EnableKeyword("_REFRACTION_THIN"); } } } catch (Exception ex) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(53, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: frosting the pane on wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" threw: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log.LogWarning(val2); } } if (num2 == 0) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(84, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" has no glass material to frost, so it stays a plain window."); } log2.LogWarning(val2); } else { Office.Log.LogInfo((object)($"[{"CalebScott.TheInspector"}] Office windows: frosted {num2} pane(s) in place on wall {wall.id} - {((list.Count > 0) ? string.Join(", ", list) : "no properties took")}. " + "If the street still looks sharp, rough refraction is disabled in this build's HDRP asset and the panel route is the one to use.")); } } private static int Count(List list) { return list?.Count ?? (-1); } private static void LogRoomWindows(NewRoom room) { //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { List val = (((Object)(object)room != (Object)null) ? room.windows : null); BepInExInfoLogInterpolatedStringHandler val2; if (val == null) { ManualLogSource log = Office.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: the room has no window list at all."); } log.LogInfo(val2); return; } int count = val.Count; ManualLogSource log2 = Office.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(61, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: the room's own window list holds "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" wall(s):"); } log2.LogInfo(val2); for (int i = 0; i < count; i++) { NewWall val3 = val[i]; if (val3 == null) { Office.Log.LogInfo((object)" "); continue; } ManualLogSource log3 = Office.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(55, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" at "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.position); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" preset='"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((ScriptableObjectIDSystem)(object)val3.preset != (ScriptableObjectIDSystem)null) ? ((Object)val3.preset).name : ""); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("windowUV="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted((val3.windowUV != null) ? "yes" : "no"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" uvHorizontal="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.windowUVHorizonalPosition); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("frontage="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(FrontageCount(val3)); } log3.LogInfo(val2); } } catch (Exception ex) { ManualLogSource log4 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(57, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Office windows: dumping the room's window list threw: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex.Message); } log4.LogWarning(val4); } } private static bool IsGlass(Material material) { string name = ((Object)material).name; if (string.IsNullOrEmpty(name)) { return false; } return name.IndexOf("glass", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("pane", StringComparison.OrdinalIgnoreCase) >= 0; } private static List FrontageRenderers(NewWall wall) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown List list = new List(); List val = ((wall != null) ? wall.spawnedFrontage : null); if (val == null) { return list; } try { int count = val.Count; for (int i = 0; i < count; i++) { GameObject val2 = val[i]; if ((Object)(object)val2 == (Object)null) { continue; } Il2CppArrayBase componentsInChildren = val2.GetComponentsInChildren(true); if (componentsInChildren == null) { continue; } for (int j = 0; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[j] != (Object)null) { list.Add(componentsInChildren[j]); } } } } catch (Exception ex) { ManualLogSource log = Office.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(66, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Office windows: collecting frontage renderers for wall "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" threw: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log.LogWarning(val3); } return list; } private static void LogRenderer(NewWall wall, Renderer renderer) { //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { StringBuilder stringBuilder = new StringBuilder(); Il2CppReferenceArray sharedMaterials = renderer.sharedMaterials; if (sharedMaterials != null) { for (int i = 0; i < ((Il2CppArrayBase)(object)sharedMaterials).Length; i++) { if (stringBuilder.Length > 0) { stringBuilder.Append(", "); } Material val = ((Il2CppArrayBase)(object)sharedMaterials)[i]; if ((Object)(object)val == (Object)null) { stringBuilder.Append(""); } else { stringBuilder.Append('\'').Append(((Object)val).name).Append("' shader='") .Append(((Object)(object)val.shader != (Object)null) ? ((Object)val.shader).name : "") .Append('\''); } } } ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(83, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Office windows: wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" frontage renderer '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)renderer).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("active="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Component)renderer).gameObject.activeInHierarchy); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" enabled="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(renderer.enabled); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("bounds="); Bounds bounds = renderer.bounds; ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Bounds)(ref bounds)).size); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" materials=["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(stringBuilder); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("]"); } log.LogInfo(val2); } catch (Exception ex) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(64, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Office windows: logging a frontage renderer for wall "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(wall.id); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" threw: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log2.LogWarning(val3); } } private static void RevertOthersInRun(List run, List chosen) { //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Expected O, but got Unknown //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown //IL_029d: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); for (int i = 0; i < chosen.Count; i++) { hashSet.Add(chosen[i].id); } DoorPairPreset val = (((Object)(object)InteriorControls.Instance != (Object)null) ? InteriorControls.Instance.wallNormal : null); int num = 0; bool flag2 = default(bool); for (int j = 0; j < run.Count; j++) { NewWall val2 = run[j]; if (hashSet.Contains(val2.id) || (ScriptableObjectIDSystem)(object)val2.preset == (ScriptableObjectIDSystem)null || !IsWindowClass(val2.preset)) { continue; } string name = ((Object)val2.preset).name; DoorPairPreset val3 = null; if (_originals.TryGetValue(val2.id, out var value)) { val3 = FindPresetByName(value); } bool flag = (ScriptableObjectIDSystem)(object)val3 != (ScriptableObjectIDSystem)null; if ((ScriptableObjectIDSystem)(object)val3 == (ScriptableObjectIDSystem)null) { val3 = val; } if ((ScriptableObjectIDSystem)(object)val3 == (ScriptableObjectIDSystem)null) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(137, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Office windows: wall "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val2.id); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" is a leftover window but there is nothing to close it with - no record of it and no InteriorControls.wallNormal."); } log.LogWarning(val4); continue; } try { val2.SetDoorPairPreset(val3, true, false, true); } catch (Exception ex) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(51, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Office windows: closing leftover window "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val2.id); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" threw: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex.Message); } log2.LogWarning(val4); continue; } if ((ScriptableObjectIDSystem)(object)val2.preset != (ScriptableObjectIDSystem)null && ((Object)val2.preset).name == ((Object)val3).name) { num++; _originals.Remove(val2.id); ManualLogSource log3 = Office.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(57, 6, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Office windows: closed leftover window "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(val2.id); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" at "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(val2.position); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' -> '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(((Object)val3).name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("'"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(flag ? "" : " (no record of its original, so the standard wall was used)"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("."); } log3.LogInfo(val5); } else { ManualLogSource log4 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(63, 4, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Office windows: wall "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val2.id); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" would not close - reads '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((ScriptableObjectIDSystem)(object)val2.preset != (ScriptableObjectIDSystem)null) ? ((Object)val2.preset).name : ""); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("', wanted '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Object)val3).name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("'."); } log4.LogWarning(val4); } } if (num > 0) { ManualLogSource log5 = Office.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(86, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Office windows: closed "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" leftover window(s) so the run holds exactly the "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(chosen.Count); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" asked for."); } log5.LogInfo(val5); } } private static void RecordOriginal(NewWall wall, string presetName) { if (!string.IsNullOrEmpty(presetName) && !(presetName == "")) { _originals[wall.id] = presetName; } } private static void LoadRecordedOriginals() { if (_originals.Count > 0) { return; } string value = OfficeConfig.OriginalWallPresets.Value; if (string.IsNullOrEmpty(value)) { return; } string[] array = value.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { int num = array[i].IndexOf('='); if (num > 0 && num != array[i].Length - 1 && int.TryParse(array[i].Substring(0, num).Trim(), out var result)) { _originals[result] = array[i].Substring(num + 1).Trim(); } } } private static void SaveRecordedOriginals() { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair original in _originals) { if (stringBuilder.Length > 0) { stringBuilder.Append(';'); } stringBuilder.Append(original.Key).Append('=').Append(original.Value); } string text = stringBuilder.ToString(); if (OfficeConfig.OriginalWallPresets.Value == text) { return; } OfficeConfig.OriginalWallPresets.Value = text; try { ConfigFile file = OfficeConfig.File; if (file != null) { file.Save(); } } catch (Exception ex) { ManualLogSource log = Office.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(134, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Office windows: could not write the original wall presets to the config: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". RestoreWalls will fall back to the game's standard wall."); } log.LogWarning(val); } } private static void Restore(NewRoom room) { //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Expected O, but got Unknown //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown List list = CollectWalls(room); DoorPairPreset val = (((Object)(object)InteriorControls.Instance != (Object)null) ? InteriorControls.Instance.wallNormal : null); int num = 0; List list2 = new List(); for (int i = 0; i < list.Count; i++) { NewWall val2 = list[i]; if ((ScriptableObjectIDSystem)(object)val2.preset == (ScriptableObjectIDSystem)null || !IsWindowClass(val2.preset)) { continue; } DoorPairPreset val3 = null; if (_originals.TryGetValue(val2.id, out var value)) { val3 = FindPresetByName(value); } if ((ScriptableObjectIDSystem)(object)val3 == (ScriptableObjectIDSystem)null) { val3 = val; } if ((ScriptableObjectIDSystem)(object)val3 == (ScriptableObjectIDSystem)null) { list2.Add($"{val2.id} (nothing to restore to)"); continue; } try { val2.SetDoorPairPreset(val3, true, false, true); } catch (Exception ex) { list2.Add($"{val2.id} ({ex.Message})"); continue; } if ((ScriptableObjectIDSystem)(object)val2.preset != (ScriptableObjectIDSystem)null && ((Object)val2.preset).name == ((Object)val3).name) { num++; continue; } list2.Add($"{val2.id} (reads '{(((ScriptableObjectIDSystem)(object)val2.preset != (ScriptableObjectIDSystem)null) ? ((Object)val2.preset).name : "")}')"); } if (num > 0) { Rebuild(room); } OfficeConfig.RestoreWalls.Value = false; OfficeConfig.OriginalWallPresets.Value = ""; bool flag = default(bool); try { ConfigFile file = OfficeConfig.File; if (file != null) { file.Save(); } } catch (Exception ex2) { ManualLogSource log = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(141, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Office windows: could not clear RestoreWalls in the config ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex2.Message); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("). Set it back to false by hand or the walls will be restored again next load."); } log.LogWarning(val4); } _originals.Clear(); if (list2.Count > 0) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(64, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] Office windows: restored "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" wall(s); "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(list2.Count); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" could not be put back - "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(string.Join(", ", list2)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("."); } log2.LogWarning(val4); } else { ManualLogSource log3 = Office.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(88, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] Office windows: restored "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" wall(s) to their original presets and cleared RestoreWalls."); } log3.LogInfo(val5); } } private static void LogWallSurvey(NewRoom room, List walls, List run, string runDescription) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); for (int i = 0; i < run.Count; i++) { hashSet.Add(run[i].id); } NewNode val = OfficeBuilder.FindRoomDoorNode(room); ManualLogSource log = Office.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("--- office wall survey: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Office.DescribeRoom(room)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ---"); } log.LogInfo(val2); ManualLogSource log2 = Office.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(41, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" room centre="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Office.RoomCentre(room)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" door="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted((val != null) ? ((object)val.nodeCoord/*cast due to .constrained prefix*/).ToString() : ""); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" windows="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted((room.windows != null) ? room.windows.Count : (-1)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" withUVData="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted((room.windowsWithUVData != null) ? room.windowsWithUVData.Count : (-1)); } log2.LogInfo(val2); ManualLogSource log3 = Office.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(14, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" chosen run: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(runDescription); } log3.LogInfo(val2); for (int j = 0; j < walls.Count; j++) { NewWall val3 = walls[j]; string text = (((ScriptableObjectIDSystem)(object)val3.preset != (ScriptableObjectIDSystem)null) ? ((Object)val3.preset).name : ""); string text2 = (((ScriptableObjectIDSystem)(object)val3.preset != (ScriptableObjectIDSystem)null) ? ((object)val3.preset.sectionClass/*cast due to .constrained prefix*/).ToString() : "-"); string text3 = DescribeOtherSide(val3); string text4 = (hashSet.Contains(val3.id) ? " <== BACK WALL" : ""); ManualLogSource log4 = Office.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(120, 15, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" wall "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.id); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" node="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted((val3.node != null) ? ((object)val3.node.nodeCoord/*cast due to .constrained prefix*/).ToString() : ""); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" offset="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.wallOffset); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" pos="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.position); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("facesOutside="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(FacesOutside(val3)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" isExterior="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.isExterior); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" short="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.isShortWall); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" door="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)(object)val3.door != (Object)null) ? "yes" : "no"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("windowUV="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted((val3.windowUV != null) ? "yes" : "no"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" uvH="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.windowUVHorizonalPosition); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("preset='"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' section="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" frontage="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(FrontageCount(val3)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" otherSide="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text3); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text4); } log4.LogInfo(val2); } } private static string DescribeOtherSide(NewWall wall) { NewWall otherWall = wall.otherWall; if (otherWall == null) { return ""; } NewRoom val = ((otherWall.node != null) ? otherWall.node.room : null); if (!((Object)(object)val == (Object)null)) { string value = (((Object)(object)val.gameLocation != (Object)null) ? ((Object)val.gameLocation).name : ""); return $"wall {otherWall.id} in '{val.name}' ({value}) outside={val.IsOutside()}"; } return $"wall {otherWall.id} (no room)"; } private static void LogPresetCatalogue() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) if (_loggedCatalogue) { return; } _loggedCatalogue = true; List list = new List(); foreach (DoorPairPreset item in AllPresets()) { if (IsWindowClass(item)) { list.Add(item); } } list.Sort((DoorPairPreset a, DoorPairPreset b) => string.CompareOrdinal(((Object)a).name, ((Object)b).name)); ManualLogSource log = Office.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("--- window presets available ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") ---"); } log.LogInfo(val); for (int num = 0; num < list.Count; num++) { DoorPairPreset val2 = list[num]; ManualLogSource log2 = Office.Log; val = new BepInExInfoLogInterpolatedStringHandler(62, 8, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)val2).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' section="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val2.sectionClass); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("long="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Count(val2.parentWallsLong)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Count(val2.childWallsLong)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("short="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Count(val2.parentWallsShort)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Count(val2.childWallsShort)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("optimizeSections="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val2.optimizeSections); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" canFeatureDoor="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(val2.canFeatureDoor); } log2.LogInfo(val); } LogFrontageCatalogue(); } private static void LogFrontageCatalogue() { //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Expected O, but got Unknown //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Expected O, but got Unknown bool flag = default(bool); try { Toolbox instance = Toolbox.Instance; if ((Object)(object)instance == (Object)null || instance.wallFrontageStyleRef == null) { Office.Log.LogInfo((object)"--- wall frontages: Toolbox.wallFrontageStyleRef is not populated ---"); return; } HashSet hashSet = new HashSet(); List list = new List(); Enumerator>> enumerator = instance.wallFrontageStyleRef.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair>> current = enumerator.Current; if (current.Value == null) { continue; } Enumerator> enumerator2 = current.Value.GetEnumerator(); while (enumerator2.MoveNext()) { KeyValuePair> current2 = enumerator2.Current; List value = current2.Value; if (value == null) { continue; } int count = value.Count; for (int i = 0; i < count; i++) { WallFrontagePreset val = value[i]; if (!((SoCustomComparison)(object)val == (SoCustomComparison)null) && hashSet.Add(((Object)val).name)) { string value2 = (((SoCustomComparison)(object)current2.Key != (SoCustomComparison)null) ? ((Object)current2.Key).name : ""); list.Add($" '{((Object)val).name}' class={value2} isRainyWindow={val.isRainyWindow} regularGlass={(((Object)(object)val.regularGlass != (Object)null) ? ((Object)val.regularGlass).name : "-")} rainyGlass={(((Object)(object)val.rainyGlass != (Object)null) ? ((Object)val.rainyGlass).name : "-")}"); } } } } list.Sort(StringComparer.Ordinal); ManualLogSource log = Office.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("--- wall frontages available ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") ---"); } log.LogInfo(val2); for (int j = 0; j < list.Count; j++) { Office.Log.LogInfo((object)list[j]); } } catch (Exception ex) { ManualLogSource log2 = Office.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(57, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] Office windows: walking the frontage catalogue threw: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log2.LogWarning(val3); } } } [HarmonyPatch(typeof(Player), "IsTrespassing")] internal static class Player_IsTrespassing_Patch { [HarmonyPrefix] private static bool Prefix(out int trespassEscalation, ref bool __result) { trespassEscalation = 0; if (!InspectorConfig.Enabled.Value) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Player), "UpdateIllegalStatus")] internal static class Player_UpdateIllegalStatus_Patch { [HarmonyPostfix] private static void Postfix(Player __instance) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown if (!InspectorConfig.Enabled.Value) { return; } bool flag = ((Actor)__instance).isTrespassing || ((Actor)__instance).illegalStatus || ((Actor)__instance).illegalActionActive || ((Actor)__instance).illegalAreaActive; ((Actor)__instance).isTrespassing = false; ((Actor)__instance).illegalStatus = false; ((Actor)__instance).illegalActionActive = false; ((Actor)__instance).illegalAreaActive = false; ((Actor)__instance).trespassingEscalation = 0; if (flag) { ManualLogSource logger = Plugin.Logger; bool flag2 = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(43, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Cleared illegal status flags for player."); } logger.LogDebug(val); } } } [HarmonyPatch(typeof(NewGameLocation), "AddEscalation")] internal static class NewGameLocation_AddEscalation_Patch { [HarmonyPrefix] private static bool Prefix(Actor actor) { if (!InspectorConfig.Enabled.Value) { return true; } return (Object)(object)actor == (Object)null || !actor.isPlayer; } } [HarmonyPatch(typeof(SecuritySystem), "OnInvestigate")] internal static class SecuritySystem_OnInvestigate_Patch { [HarmonyPrefix] private static bool Prefix(Actor newTarget) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (!InspectorConfig.Enabled.Value) { return true; } if ((Object)(object)newTarget != (Object)null && newTarget.isPlayer) { ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(57, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Blocked a security system investigation of the player."); } logger.LogDebug(val); return false; } return true; } } [HarmonyPatch(typeof(SecuritySystem), "CreateEvidence")] internal static class SecuritySystem_CreateEvidence_Patch { [HarmonyPrefix] private static bool Prefix(SecuritySystem __instance) { if (!InspectorConfig.Enabled.Value) { return true; } return (Object)(object)__instance.trackingTarget == (Object)null || !__instance.trackingTarget.isPlayer; } } [HarmonyPatch(typeof(SecuritySystem), "Update")] internal static class SecuritySystem_Update_Patch { [HarmonyPostfix] private static void Postfix(SecuritySystem __instance) { if (InspectorConfig.Enabled.Value && (Object)(object)__instance.trackingTarget != (Object)null && __instance.trackingTarget.isPlayer) { __instance.trackingTarget = null; __instance.acquiredTarget = false; } } } [BepInPlugin("CalebScott.TheInspector", "The Inspector - Overhaul Mod", "1.1.1")] public class Plugin : BasePlugin { public const string PLUGIN_GUID = "CalebScott.TheInspector"; internal static ManualLogSource Logger; public override void Load() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown Logger = ((BasePlugin)this).Log; InspectorConfig.Bind(((BasePlugin)this).Config); InventoryConfig.Bind(((BasePlugin)this).Config); OfficeConfig.Bind(((BasePlugin)this).Config); Harmony val = new Harmony("CalebScott.TheInspector"); val.PatchAll(); ManualLogSource logger = Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(89, 9, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("CalebScott.TheInspector"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("The Inspector - Overhaul Mod"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("1.1.1"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded. "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("immunity="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(InspectorConfig.Enabled.Value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("civilianReactions="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(InspectorConfig.CivilianReactionsEnabled.Value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("inventory="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(InventoryConfig.Enabled.Value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (modularSlots="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(InventoryConfig.ModularSlotCount.Value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("), "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("office="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(OfficeConfig.Enabled.Value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (title="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(OfficeConfig.TitleWord); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")"); } logger.LogInfo(val2); } } internal static class SlotConfig { internal enum LockedItem { Truncheon, Fists, PrintScanner, Codebreaker, Watch, Camera, DoorStopper, Handcuffs, Cigarettes } internal class LockedItemDef { public LockedItem Item; public string Hotkey; public StaticSlot? NativeStatic; public string[] PresetNameCandidates; public string[] FallbackKeywords; } internal static readonly LockedItemDef[] Items = new LockedItemDef[9] { new LockedItemDef { Item = LockedItem.Truncheon, Hotkey = "1", PresetNameCandidates = new string[1] { "Truncheon" }, FallbackKeywords = new string[2] { "truncheon", "baton" } }, new LockedItemDef { Item = LockedItem.Fists, Hotkey = "2", NativeStatic = (StaticSlot)3 }, new LockedItemDef { Item = LockedItem.PrintScanner, Hotkey = "3", NativeStatic = (StaticSlot)5, PresetNameCandidates = new string[1] { "PrintScanner" }, FallbackKeywords = new string[1] { "printscanner" } }, new LockedItemDef { Item = LockedItem.Codebreaker, Hotkey = "4", PresetNameCandidates = new string[1] { "Codebreaker" }, FallbackKeywords = new string[1] { "codebreaker" } }, new LockedItemDef { Item = LockedItem.Watch, Hotkey = "5", NativeStatic = (StaticSlot)2 }, new LockedItemDef { Item = LockedItem.Camera, Hotkey = "6", PresetNameCandidates = new string[1] { "Camera" }, FallbackKeywords = new string[1] { "camera" } }, new LockedItemDef { Item = LockedItem.DoorStopper, Hotkey = "7", PresetNameCandidates = new string[1] { "DoorWedge" }, FallbackKeywords = new string[1] { "doorwedge" } }, new LockedItemDef { Item = LockedItem.Handcuffs, Hotkey = "8", PresetNameCandidates = new string[1] { "Handcuffs" }, FallbackKeywords = new string[1] { "handcuff" } }, new LockedItemDef { Item = LockedItem.Cigarettes, Hotkey = "9", PresetNameCandidates = new string[1] { "Cigarettes" }, FallbackKeywords = new string[1] { "cigarettes" } } }; internal static readonly StaticSlot[] UnwantedNativeStatics = (StaticSlot[])(object)new StaticSlot[1] { (StaticSlot)4 }; internal const StaticSlot ManualStaticValue = (StaticSlot)1; internal const string DeselectHotkey = "0"; internal static InventorySlot DeselectSlot; internal static readonly Dictionary TrackedSlots = new Dictionary(); internal static readonly HashSet LockedSlots = new HashSet(); internal static void Track(LockedItem item, InventorySlot slot) { TrackedSlots[item] = slot; LockedSlots.Add(slot); } internal static void Untrack(LockedItem item, InventorySlot slot) { TrackedSlots.Remove(item); if (slot != null) { LockedSlots.Remove(slot); } } internal static int ReservedCount() { int num = 0; LockedItemDef[] items = Items; foreach (LockedItemDef lockedItemDef in items) { if (!lockedItemDef.NativeStatic.HasValue) { num++; } } return num; } internal static void Reset() { TrackedSlots.Clear(); LockedSlots.Clear(); DeselectSlot = null; } internal static bool TryGetItem(InventorySlot slot, out LockedItem item) { if (slot != null) { foreach (KeyValuePair trackedSlot in TrackedSlots) { if (trackedSlot.Value == slot) { item = trackedSlot.Key; return true; } } } item = LockedItem.Truncheon; return false; } internal static LockedItemDef Find(LockedItem item) { LockedItemDef[] items = Items; foreach (LockedItemDef lockedItemDef in items) { if (lockedItemDef.Item == item) { return lockedItemDef; } } return null; } } [HarmonyPatch(typeof(BioScreenController), "SetInventoryOpen")] internal static class InventoryOpenArrangePatch { [HarmonyPostfix] private static void Postfix(BioScreenController __instance, bool val) { if (val) { UiArranger.Arrange(__instance); } } } [HarmonyPatch(typeof(BioScreenController), "UpdateButtons")] internal static class InventoryUpdateArrangePatch { [HarmonyPostfix] private static void Postfix(BioScreenController __instance) { UiArranger.Arrange(__instance); } } internal static class UiArranger { private const int LockedColumns = 5; private static bool _loggedLayout; private static bool _dumpedLate; internal static void Arrange(BioScreenController bio) { //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Invalid comparison between Unknown and I4 if (!InventoryConfig.Enabled.Value || !InventoryConfig.SwapInventoryRows.Value || (Object)(object)bio == (Object)null) { return; } bool flag = default(bool); try { RectTransform equipmentParentRect = bio.equipmentParentRect; RectTransform itemsParentRect = bio.itemsParentRect; if ((Object)(object)equipmentParentRect == (Object)null || (Object)(object)itemsParentRect == (Object)null) { return; } FirstPersonItemController playerController = GetPlayerController(); if (((playerController != null) ? playerController.slots : null) == null) { return; } if (!_loggedLayout) { _loggedLayout = true; LogRect("equipmentParentRect (top strip)", equipmentParentRect); LogRect("itemsParentRect (bottom grid)", itemsParentRect); ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Inventory] nothingSquare parent = "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(DescribeParent(bio.nothingSquare)); } logger.LogInfo(val); } GridLayoutGroup component = ((Component)itemsParentRect).GetComponent(); if ((Object)(object)component != (Object)null) { component.constraintCount = 5; } int sibling = 0; SlotConfig.LockedItemDef[] items = SlotConfig.Items; foreach (SlotConfig.LockedItemDef lockedItemDef in items) { if (SlotConfig.TrackedSlots.TryGetValue(lockedItemDef.Item, out var value) && value != null) { PlaceLockedSlot(value, itemsParentRect, ref sibling); } } if (SlotConfig.DeselectSlot != null) { PlaceLockedSlot(SlotConfig.DeselectSlot, itemsParentRect, ref sibling); } for (int j = 0; j < playerController.slots.Count; j++) { InventorySlot val2 = playerController.slots[j]; if (val2 != null && (int)val2.isStatic <= 0 && !SlotConfig.LockedSlots.Contains(val2)) { InventorySquareController spawnedSegment = val2.spawnedSegment; if (!((Object)(object)spawnedSegment == (Object)null)) { MoveTo(((Component)spawnedSegment).transform, equipmentParentRect, -1); } } } if (!_dumpedLate && SlotConfig.TrackedSlots.Count == SlotConfig.Items.Length) { _dumpedLate = true; InventorySetup.DumpSlots(playerController, "inventory-open"); } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(31, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Inventory] UI arrange failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex); } logger2.LogError(val3); } } private static void PlaceLockedSlot(InventorySlot slot, RectTransform bottomGrid, ref int sibling) { InventorySquareController spawnedSegment = slot.spawnedSegment; if ((Object)(object)spawnedSegment == (Object)null) { return; } MoveTo(((Component)spawnedSegment).transform, bottomGrid, sibling++); try { if (ItemFactory.IsSlotFilled(slot)) { Interactable interactable = slot.GetInteractable(); if (interactable != null) { slot.SetSegmentContent(interactable); } } spawnedSegment.OnUpdateContent(); spawnedSegment.UpdateHotkeyDisplay(); if (SlotConfig.LockedSlots.Contains(slot) && (Object)(object)spawnedSegment.equipmentIcon != (Object)null) { ((Component)spawnedSegment.equipmentIcon).gameObject.SetActive(true); } } catch { } } private static void MoveTo(Transform t, RectTransform parent, int siblingIndex) { if ((Object)(object)t.parent != (Object)(object)parent) { t.SetParent((Transform)(object)parent, false); } if (siblingIndex >= 0 && t.GetSiblingIndex() != siblingIndex) { t.SetSiblingIndex(siblingIndex); } } private static FirstPersonItemController GetPlayerController() { try { Player instance = Player.Instance; return ((Object)(object)instance != (Object)null) ? ((Component)instance).GetComponent() : null; } catch { return null; } } private static string DescribeParent(InventorySquareController square) { if ((Object)(object)square == (Object)null) { return ""; } Transform parent = ((Component)square).transform.parent; return ((Object)(object)parent != (Object)null) ? ((Object)parent).name : ""; } private static void LogRect(string label, RectTransform rt) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) GridLayoutGroup component = ((Component)rt).GetComponent(); HorizontalLayoutGroup component2 = ((Component)rt).GetComponent(); ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(78, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Inventory] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(label); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": name="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)rt).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", anchoredPos="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(rt.anchoredPosition); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", sizeDelta="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(rt.sizeDelta); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Grid="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)(object)component != (Object)null) ? $"constraint={component.constraint}/{component.constraintCount} cell={component.cellSize}" : "none"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Horizontal="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)(object)component2 != (Object)null) ? "present" : "none"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", childCount="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Transform)rt).childCount); } logger.LogInfo(val); } } internal static class PluginInfo { internal const string Guid = "CalebScott.TheInspector"; internal const string Name = "The Inspector - Overhaul Mod"; internal const string Version = "1.1.1"; } }