using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using SOD.Common.BepInEx;
using TMPro;
using UnityEngine;
[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("GovernmentLockdown")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Plugin that enhances the security of the government database in Shadows of Doubt.")]
[assembly: AssemblyFileVersion("0.8.2.0")]
[assembly: AssemblyInformationalVersion("0.8.2")]
[assembly: AssemblyProduct("GovernmentLockdown")]
[assembly: AssemblyTitle("GovernmentLockdown")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.8.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace GovernmentLockdown
{
[BepInPlugin("GovernmentLockdown", "GovernmentLockdown", "0.8.2")]
public class GovernmentLockdownPlugin : PluginController<GovernmentLockdownPlugin>
{
public static ConfigEntry<bool> RemoveUnsecureSecurityApp;
public static ConfigEntry<bool> RemoveUnsecureSurveillanceApp;
public override void Load()
{
((PluginController<GovernmentLockdownPlugin, IEmptyBindings>)(object)this).Load();
Utilities.Log("Plugin GovernmentLockdown is loaded!", (LogLevel)16);
((PluginController<GovernmentLockdownPlugin, IEmptyBindings>)(object)this).Harmony.PatchAll();
Utilities.Log("Plugin GovernmentLockdown is patched!", (LogLevel)16);
BindConfig();
}
private void BindConfig()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
RemoveUnsecureSecurityApp = base.Config.Bind<bool>("Options", "Remove Unsecure Security App", true, new ConfigDescription("Removes the security app from city hall offices if they aren't secure.", (AcceptableValueBase)null, Array.Empty<object>()));
RemoveUnsecureSurveillanceApp = base.Config.Bind<bool>("Options", "Remove Unsecure Surveillance App", true, new ConfigDescription("Removes the surveillance app from city hall offices if they aren't secure.", (AcceptableValueBase)null, Array.Empty<object>()));
}
}
public enum MunicipalComputerType
{
NotMunicipal,
EnforcersInsecure,
EnforcersSecure,
HospitalInsecure,
HospitalSecure,
LobbyInsecure,
LobbySecure
}
public static class Utilities
{
public const bool DEBUG_BUILD = false;
public static void Log(string message, LogLevel level = 16)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Invalid comparison between Unknown and I4
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
if ((int)level == 32)
{
bool flag = false;
}
else
{
PluginController<GovernmentLockdownPlugin, IEmptyBindings>.Log.Log(level, (object)message);
}
}
public static MunicipalComputerType GetMunicipalComputerType(CruncherAppContent app)
{
object obj;
if (app == null)
{
obj = null;
}
else
{
ComputerController controller = app.controller;
if (controller == null)
{
obj = null;
}
else
{
InteractableController ic = controller.ic;
if (ic == null)
{
obj = null;
}
else
{
Interactable interactable = ic.interactable;
obj = ((interactable != null) ? interactable.node : null);
}
}
}
NewNode val = (NewNode)obj;
object obj2;
if (val == null)
{
obj2 = null;
}
else
{
NewGameLocation gameLocation = val.gameLocation;
if (gameLocation == null)
{
obj2 = null;
}
else
{
NewAddress thisAsAddress = gameLocation.thisAsAddress;
obj2 = ((thisAsAddress != null) ? thisAsAddress.addressPreset : null);
}
}
AddressPreset val2 = (AddressPreset)obj2;
object obj3;
if (val == null)
{
obj3 = null;
}
else
{
NewRoom room = val.room;
obj3 = ((room != null) ? room.preset : null);
}
RoomConfiguration val3 = (RoomConfiguration)obj3;
if (val == null || (SoCustomComparison)(object)val2 == (SoCustomComparison)null || (SoCustomComparison)(object)val3 == (SoCustomComparison)null)
{
return MunicipalComputerType.NotMunicipal;
}
bool flag = val3.escalationLevelNormal != 0;
return ((SoCustomComparison)val2).presetName switch
{
"CityHallLobby" => flag ? MunicipalComputerType.LobbySecure : MunicipalComputerType.LobbyInsecure,
"EnforcerOffice" => (!flag) ? MunicipalComputerType.EnforcersInsecure : MunicipalComputerType.EnforcersSecure,
"HospitalWard" => flag ? MunicipalComputerType.HospitalSecure : MunicipalComputerType.HospitalInsecure,
_ => MunicipalComputerType.NotMunicipal,
};
}
}
[HarmonyPatch(typeof(DatabaseApp), "UpdateSearch")]
public class DatabaseSearchPatch
{
[HarmonyPrefix]
private static bool Prefix(DatabaseApp __instance)
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Expected I4, but got Unknown
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Expected O, but got Unknown
List<OSMultiOption> val = new List<OSMultiOption>();
string text = string.Empty;
if (SearchIsValid(__instance.searchString))
{
List<Citizen> results = new List<Citizen>();
string search = __instance.searchString.ToLower();
object obj;
if (__instance == null)
{
obj = null;
}
else
{
ComputerController controller = ((CruncherAppContent)__instance).controller;
if (controller == null)
{
obj = null;
}
else
{
InteractableController ic = controller.ic;
if (ic == null)
{
obj = null;
}
else
{
Interactable interactable = ic.interactable;
if (interactable == null)
{
obj = null;
}
else
{
NewNode node = interactable.node;
obj = ((node != null) ? node.gameLocation : null);
}
}
}
}
NewGameLocation location = (NewGameLocation)obj;
CitizenPool citizenPool = __instance.citizenPool;
CitizenPool val2 = citizenPool;
switch ((int)val2)
{
case 0:
FindInAllCitizens(search, ref results);
break;
case 1:
FindInCompanyCitizens(search, location, ref results);
break;
case 2:
FindInBuildingCitizens(search, location, ref results);
break;
}
Enumerator<Citizen> enumerator = results.GetEnumerator();
while (enumerator.MoveNext())
{
Citizen current = enumerator.Current;
OSMultiOption val3 = new OSMultiOption();
val3.text = ((Human)current).GetCitizenName();
val3.human = (Human)(object)current;
val.Add(val3);
}
}
else
{
text = "<color=\"red\">";
}
((TMP_Text)__instance.searchText).text = Strings.Get("computer", "Database Search", (Casing)0, false, false, false, (Human)null) + ": " + text + __instance.searchString + "_";
__instance.list.UpdateElements(val);
__instance.UpdateSelected();
return false;
}
private static void FindInAllCitizens(string search, ref List<Citizen> results)
{
Enumerator<Citizen> enumerator = CityData.Instance.citizenDirectory.GetEnumerator();
while (enumerator.MoveNext())
{
Citizen current = enumerator.Current;
if (((Human)current).GetCitizenName().ToLower().Contains(search))
{
results.Add(current);
}
}
}
private static void FindInCompanyCitizens(string search, NewGameLocation location, ref List<Citizen> results)
{
Enumerator<Citizen> enumerator = CityData.Instance.citizenDirectory.GetEnumerator();
while (enumerator.MoveNext())
{
Citizen current = enumerator.Current;
object obj;
if (current == null)
{
obj = null;
}
else
{
Occupation job = ((Human)current).job;
obj = ((job != null) ? job.employer : null);
}
if (obj != null && !((Object)(object)((Human)current).job.employer.address != (Object)(object)location) && ((Human)current).GetCitizenName().ToLower().Contains(search))
{
results.Add(current);
}
}
}
private static void FindInBuildingCitizens(string search, NewGameLocation location, ref List<Citizen> results)
{
Enumerator<Citizen> enumerator = CityData.Instance.citizenDirectory.GetEnumerator();
while (enumerator.MoveNext())
{
Citizen current = enumerator.Current;
if (!((Object)(object)((current != null) ? ((Human)current).home : null) == (Object)null) && !((Object)(object)((NewGameLocation)((Human)current).home).building != (Object)(object)location.building) && ((Human)current).GetCitizenName().ToLower().Contains(search))
{
results.Add(current);
}
}
}
private static bool SearchIsValid(string search)
{
if (string.IsNullOrEmpty(search))
{
return false;
}
int num = 0;
foreach (char c in search)
{
if (!char.IsWhiteSpace(c))
{
num++;
if (num >= 2)
{
return true;
}
}
}
return false;
}
}
[HarmonyPatch(typeof(DesktopIconController), "Setup")]
public class MedDatabaseIconLabelPatch
{
[HarmonyPostfix]
private static void Postfix(DesktopIconController __instance, DesktopApp newDesktop, CruncherAppPreset newApp)
{
if (!(((SoCustomComparison)newApp).presetName != "GovDatabase"))
{
MunicipalComputerType municipalComputerType = Utilities.GetMunicipalComputerType((CruncherAppContent)(object)newDesktop);
MunicipalComputerType municipalComputerType2 = municipalComputerType;
if ((uint)(municipalComputerType2 - 3) <= 1u)
{
((TMP_Text)__instance.iconText).text = "Med Database";
}
}
}
}
[HarmonyPatch(typeof(DatabaseApp), "OnPrintEntry")]
public class MedDatabasePrintingPatch
{
[HarmonyPrefix]
private static bool Prefix(DatabaseApp __instance)
{
MunicipalComputerType municipalComputerType = Utilities.GetMunicipalComputerType((CruncherAppContent)(object)__instance);
MunicipalComputerType municipalComputerType2 = municipalComputerType;
MunicipalComputerType municipalComputerType3 = municipalComputerType2;
if ((uint)(municipalComputerType3 - 3) > 1u)
{
return true;
}
OnMedicalDatabasePrint(__instance);
return false;
}
private static void OnMedicalDatabasePrint(DatabaseApp app)
{
//IL_004b: 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_014b: 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_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: 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_0124: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)app.selectedHuman == (Object)null)
{
AudioController.Instance.PlayWorldOneShot(AudioControls.Instance.computerInvalidPasscode, (Actor)(object)Player.Instance, ((CruncherAppContent)app).controller.ic.interactable.node, ((CruncherAppContent)app).controller.ic.interactable.wPos, (Interactable)null, (List<FMODParam>)null, 1f, (List<NewNode>)null, false, (SoundMaterialOverride)null, false);
return;
}
Human selectedHuman = app.selectedHuman;
Game.Log(Object.op_Implicit("Print " + ((selectedHuman != null) ? ((Object)selectedHuman).ToString() : null)), 2);
((CruncherAppContent)app).controller.SetTimedLoading(Toolbox.Instance.Rand(0.5f, 1f, false), 0.33f);
if (((CruncherAppContent)app).controller.printedDocument != null || ((CruncherAppContent)app).controller.printTimer > 0f)
{
AudioController.Instance.PlayWorldOneShot(AudioControls.Instance.computerInvalidPasscode, (Actor)(object)Player.Instance, ((CruncherAppContent)app).controller.ic.interactable.node, ((CruncherAppContent)app).controller.ic.interactable.wPos, (Interactable)null, (List<FMODParam>)null, 1f, (List<NewNode>)null, false, (SoundMaterialOverride)null, false);
return;
}
((CruncherAppContent)app).controller.printTimer = 1f;
Vector3 localPosition = ((CruncherAppContent)app).controller.printerParent.localPosition;
((CruncherAppContent)app).controller.printerParent.localPosition = new Vector3(localPosition.x, localPosition.y, -0.05f);
AudioController.Instance.PlayWorldOneShot(AudioControls.Instance.computerPrint, (Actor)(object)Player.Instance, ((CruncherAppContent)app).controller.ic.interactable.node, ((CruncherAppContent)app).controller.ic.interactable.wPos, (Interactable)null, (List<FMODParam>)null, 1f, (List<NewNode>)null, false, (SoundMaterialOverride)null, false);
((CruncherAppContent)app).controller.printedDocument = InteractableCreator.Instance.CreateWorldInteractable(app.ddsPrintout, app.selectedHuman, app.selectedHuman, app.selectedHuman, ((CruncherAppContent)app).controller.printerParent.position, ((Component)((CruncherAppContent)app).controller.ic).transform.eulerAngles, (List<Passed>)null, (Object)null, "");
if (((CruncherAppContent)app).controller.printedDocument != null)
{
((CruncherAppContent)app).controller.printedDocument.MarkAsTrash(true, false, 0f);
}
Action action = ((CruncherAppContent)app).OnPlayerTakePrint;
Interactable printedDocument = ((CruncherAppContent)app).controller.printedDocument;
printedDocument.OnRemovedFromWorld += RemovedFromWorld.op_Implicit(action);
}
}
[HarmonyPatch(typeof(DatabaseApp), "OnSetup")]
public class MedDatabasePrintsBirthCertificatesPatch
{
private static InteractablePreset _printedCitizensReport;
private static InteractablePreset _printedEmployeeReport;
private static InteractablePreset _printedResidentReport;
private static InteractablePreset _printedBirthCertificate;
[HarmonyPostfix]
private static void Postfix(DatabaseApp __instance)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected I4, but got Unknown
CachePresets();
ComputerAutoTextController component = ((Component)__instance.titleText).gameObject.GetComponent<ComputerAutoTextController>();
if ((Object)(object)component != (Object)null)
{
Object.DestroyImmediate((Object)(object)component);
}
((TMP_Text)__instance.titleText).overflowMode = (TextOverflowModes)0;
((TMP_Text)__instance.titleText).enableWordWrapping = false;
CitizenPool citizenPool = __instance.citizenPool;
CitizenPool val = citizenPool;
switch ((int)val)
{
case 0:
{
MunicipalComputerType municipalComputerType = Utilities.GetMunicipalComputerType((CruncherAppContent)(object)__instance);
MunicipalComputerType municipalComputerType2 = municipalComputerType;
if ((uint)(municipalComputerType2 - 3) <= 1u)
{
((TMP_Text)__instance.titleText).text = "Medical Database";
__instance.ddsPrintout = _printedBirthCertificate;
}
else
{
((TMP_Text)__instance.titleText).text = "Citizens Database";
__instance.ddsPrintout = _printedCitizensReport;
}
break;
}
case 1:
((TMP_Text)__instance.titleText).text = "Employee Database";
__instance.ddsPrintout = _printedEmployeeReport;
break;
case 2:
((TMP_Text)__instance.titleText).text = "Residents Database";
__instance.ddsPrintout = _printedResidentReport;
break;
}
}
private static void CachePresets()
{
if ((SoCustomComparison)(object)_printedCitizensReport == (SoCustomComparison)null)
{
_printedCitizensReport = Toolbox.Instance.GetInteractablePreset("PrintedCitizenFile");
}
if ((SoCustomComparison)(object)_printedEmployeeReport == (SoCustomComparison)null)
{
_printedEmployeeReport = Toolbox.Instance.GetInteractablePreset("PrintedEmployeeRecord");
}
if ((SoCustomComparison)(object)_printedResidentReport == (SoCustomComparison)null)
{
_printedResidentReport = Toolbox.Instance.GetInteractablePreset("PrintedResidentsFile");
}
if ((SoCustomComparison)(object)_printedBirthCertificate == (SoCustomComparison)null && (SoCustomComparison)(object)_printedCitizensReport != (SoCustomComparison)null)
{
_printedBirthCertificate = Object.Instantiate<InteractablePreset>(Toolbox.Instance.GetInteractablePreset("BirthCertificate"));
_printedBirthCertificate.readingEnabled = false;
_printedBirthCertificate.attemptToStoreInFolder = null;
_printedBirthCertificate.actionsPreset.Clear();
Enumerator<InteractableActionsPreset> enumerator = _printedCitizensReport.actionsPreset.GetEnumerator();
while (enumerator.MoveNext())
{
InteractableActionsPreset current = enumerator.Current;
_printedBirthCertificate.actionsPreset.Add(current);
}
}
}
}
[HarmonyPatch(typeof(DesktopApp), "UpdateIcons")]
public class MunicipalDesktopFilterPatch
{
private static List<CruncherAppPreset> ReversedApps = new List<CruncherAppPreset>();
[HarmonyPrefix]
private static bool Prefix(DesktopApp __instance)
{
MunicipalComputerType municipalComputerType = Utilities.GetMunicipalComputerType((CruncherAppContent)(object)__instance);
if (municipalComputerType == MunicipalComputerType.NotMunicipal)
{
return true;
}
ReversedApps.Clear();
object obj;
if (__instance == null)
{
obj = null;
}
else
{
ComputerController controller = ((CruncherAppContent)__instance).controller;
if (controller == null)
{
obj = null;
}
else
{
InteractableController ic = controller.ic;
if (ic == null)
{
obj = null;
}
else
{
Interactable interactable = ic.interactable;
if (interactable == null)
{
obj = null;
}
else
{
InteractablePreset preset = interactable.preset;
obj = ((preset != null) ? preset.additionalApps : null);
}
}
}
}
List<CruncherAppPreset> val = (List<CruncherAppPreset>)obj;
if (val == null)
{
return true;
}
for (int num = val.Count - 1; num >= 0; num--)
{
CruncherAppPreset val2 = val._items[num];
ReversedApps.Add(val2);
switch (((SoCustomComparison)val2).presetName)
{
case "Surveillance":
if (municipalComputerType != MunicipalComputerType.EnforcersSecure && GovernmentLockdownPlugin.RemoveUnsecureSurveillanceApp.Value)
{
val.RemoveAt(num);
}
break;
case "Security":
if (municipalComputerType != MunicipalComputerType.EnforcersSecure && GovernmentLockdownPlugin.RemoveUnsecureSecurityApp.Value)
{
val.RemoveAt(num);
}
break;
case "GovDatabase":
{
MunicipalComputerType municipalComputerType2 = municipalComputerType;
MunicipalComputerType municipalComputerType3 = municipalComputerType2;
if (municipalComputerType3 != MunicipalComputerType.EnforcersSecure && municipalComputerType3 != MunicipalComputerType.HospitalSecure)
{
val.RemoveAt(num);
}
break;
}
}
}
return true;
}
[HarmonyPostfix]
private static void Postfix(DesktopApp __instance)
{
if (Utilities.GetMunicipalComputerType((CruncherAppContent)(object)__instance) == MunicipalComputerType.NotMunicipal)
{
return;
}
object obj;
if (__instance == null)
{
obj = null;
}
else
{
ComputerController controller = ((CruncherAppContent)__instance).controller;
if (controller == null)
{
obj = null;
}
else
{
InteractableController ic = controller.ic;
if (ic == null)
{
obj = null;
}
else
{
Interactable interactable = ic.interactable;
if (interactable == null)
{
obj = null;
}
else
{
InteractablePreset preset = interactable.preset;
obj = ((preset != null) ? preset.additionalApps : null);
}
}
}
}
List<CruncherAppPreset> val = (List<CruncherAppPreset>)obj;
if (val != null)
{
val.Clear();
for (int num = ReversedApps.Count - 1; num >= 0; num--)
{
val.Add(ReversedApps._items[num]);
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "GovernmentLockdown";
public const string PLUGIN_NAME = "GovernmentLockdown";
public const string PLUGIN_VERSION = "0.8.2";
}
}