using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SoDMapImprovements")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("SoDMapImprovements")]
[assembly: AssemblyTitle("SoDMapImprovements")]
[assembly: AssemblyVersion("0.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace SoDMapImprovements
{
[BepInPlugin("sm3gm.sod.mapimprovements", "Map Improvements", "1.3.3")]
public sealed class Plugin : BasePlugin
{
public const string VER = "1.3.3";
internal static ManualLogSource L = null;
internal static ConfigEntry<float> GhostAlpha = null;
internal static ConfigEntry<float> ZoomOut = null;
internal static ConfigEntry<float> OtherFloorAlpha = null;
internal static ConfigEntry<bool> StartZoomedOut = null;
internal static ConfigEntry<string> BodyMarkers = null;
internal static ConfigEntry<float> PlaceScale = null;
internal static ConfigEntry<float> PlayerScale = null;
internal static ConfigEntry<float> TrackedScale = null;
internal static ConfigEntry<bool> KeepImages = null;
internal static ConfigEntry<int> MaxImages = null;
internal static ConfigEntry<int> ReleaseAsks = null;
internal static ConfigEntry<float> VendingScale = null;
internal static ConfigEntry<string> FurnitureIcons = null;
internal static int Built;
internal static int Kept;
internal static int Allowed;
internal static double BuildMs;
internal static readonly Stopwatch Sw = new Stopwatch();
public override void Load()
{
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Expected O, but got Unknown
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Expected O, but got Unknown
L = ((BasePlugin)this).Log;
PlaceScale = ((BasePlugin)this).Config.Bind<float>("Icons", "PlaceIconScale", 3f, "Size of shop, business and building icons on the map (1 = vanilla).");
PlayerScale = ((BasePlugin)this).Config.Bind<float>("Icons", "PlayerIconScale", 3f, "Size of your own marker on the map (1 = vanilla). Left alone when another mod already resizes it.");
TrackedScale = ((BasePlugin)this).Config.Bind<float>("Icons", "TrackedIconScale", 3f, "Size of markers for tracked people and objects (1 = vanilla).");
KeepImages = ((BasePlugin)this).Config.Bind<bool>("Map", "KeepDrawnBuildings", true, "Keep buildings drawn on the map, so scrolling back or reopening the map does not redraw them.");
ReleaseAsks = ((BasePlugin)this).Config.Bind<int>("Map", "ReleaseAfterAsksPerFrame", 12, "A kept building is let go only when the game asks to unload it this many times in one frame (it asks 3 times as a matter of course).");
MaxImages = ((BasePlugin)this).Config.Bind<int>("Map", "MaxDrawnBuildings", 3000, "How many drawn buildings are kept at most. Past this, buildings out of view are unloaded again as in the base game. Lower it if the game uses too much memory.");
VendingScale = ((BasePlugin)this).Config.Bind<float>("Icons", "FurnitureIconScale", 3f, "Size of the extra map icons for vending machines and the other furniture below, in floor tiles (0 = off).");
FurnitureIcons = ((BasePlugin)this).Config.Bind<string>("Icons", "FurnitureWithIcons", "VendingMachine,ColaMachine,SnackMachine,CigaretteMachine,ElGenMachine,PoliceAutomat", "Furniture that gets its own map icon: a part of the internal furniture or furniture class name, comma separated.");
BodyMarkers = ((BasePlugin)this).Config.Bind<string>("Icons", "BodyMarkers", "Found", "Mark bodies on the map, with a faded marker on the other floors of their building. Found = only bodies that have been found, All = every body (gives away murders nobody has found yet), Off.");
GhostAlpha = ((BasePlugin)this).Config.Bind<float>("Icons", "ControlRoomsOnAllFloors", 0.45f, "Control rooms get the camera icon on their own floor, and a faded one on every other floor of their building, so they are easy to find. 0 = off, 1 = not faded.");
ZoomOut = ((BasePlugin)this).Config.Bind<float>("Map", "ZoomOutFactor", 2.5f, "How much further out you can zoom the map (2.5 = two and a half times as far as the game allows). 1 = the game's own limit.");
StartZoomedOut = ((BasePlugin)this).Config.Bind<bool>("Map", "StartZoomedOut", true, "The first time you open the map after loading a city, it starts fully zoomed out. After that it keeps the zoom you left it at.");
OtherFloorAlpha = ((BasePlugin)this).Config.Bind<float>("Icons", "TrackedOnOtherFloorsOpacity", 0.75f, "How solid the markers of tracked people are while they are on another floor than the one you are looking at (0 = the game's own faded look, 1 = not faded at all).");
if (Math.Abs(VendingScale.Value - 2.5f) < 0.001f)
{
VendingScale.Value = 2f;
}
if (FurnitureIcons.Value == "Vending" || FurnitureIcons.Value == "VendingMachine,ColaMachine,SnackMachine,CigaretteMachine")
{
FurnitureIcons.Value = (string)((ConfigEntryBase)FurnitureIcons).DefaultValue;
}
Harmony val = new Harmony("sm3gm.sod.mapimprovements");
ConfigEntry<int> val2 = ((BasePlugin)this).Config.Bind<int>("Internal", "IconSizeVersion", 1, "Used by the mod to apply a change of default sizes once. No need to edit.");
if (val2.Value < 2)
{
ConfigEntry<float>[] array = new ConfigEntry<float>[4] { PlaceScale, PlayerScale, TrackedScale, VendingScale };
foreach (ConfigEntry<float> val3 in array)
{
if (Mathf.Approximately(val3.Value, 2f))
{
val3.Value = 3f;
}
}
val2.Value = 2;
}
val.PatchAll(typeof(IconPatches));
val.PatchAll(typeof(MapPatches));
val.PatchAll(typeof(FurnitureIconsPatch));
val.PatchAll(typeof(ControlRoomGhosts));
val.PatchAll(typeof(BodyMarkersPatch));
val.PatchAll(typeof(ZoomOutPatch));
val.PatchAll(typeof(TrackedFadePatch));
ManualLogSource l = L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Map Improvements ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>("1.3.3");
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" loaded");
}
l.LogInfo(val4);
}
}
[HarmonyPatch]
internal static class IconPatches
{
private static int logged;
private static float lastPlayer = -1f;
private static bool toldOther;
private static void ScalePlace(MapAddressButtonController b)
{
//IL_0033: 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_005d: Expected O, but got Unknown
try
{
Image val = ((b != null) ? b.typeIcon : null);
if ((Object)(object)val == (Object)null)
{
return;
}
float value = Plugin.PlaceScale.Value;
((Transform)((Graphic)val).rectTransform).localScale = new Vector3(value, value, 1f);
if (logged++ < 3)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(32, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ICONS] place icon '");
NewGameLocation gameLocation = b.gameLocation;
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>((gameLocation != null) ? ((Object)gameLocation).name : null);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' scaled to ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(value);
}
l.LogInfo(val2);
}
}
catch
{
}
}
[HarmonyPatch(typeof(MapAddressButtonController), "Setup")]
[HarmonyPostfix]
private static void Setup(MapAddressButtonController __instance)
{
ScalePlace(__instance);
}
[HarmonyPatch(typeof(MapAddressButtonController), "UpdateIcon")]
[HarmonyPostfix]
private static void UpdateIcon(MapAddressButtonController __instance)
{
ScalePlace(__instance);
}
[HarmonyPatch(typeof(MapController), "AddNewTrackedObject")]
[HarmonyPrefix]
private static void Tracked(ref Vector2 size)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
size *= Plugin.TrackedScale.Value;
}
[HarmonyPatch(typeof(MapController), "OpenMap")]
[HarmonyPostfix]
private static void Open(MapController __instance)
{
//IL_0021: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
try
{
RectTransform playerCharacterRect = __instance.playerCharacterRect;
float value = Plugin.PlayerScale.Value;
if ((Object)(object)playerCharacterRect == (Object)null)
{
return;
}
float x = ((Transform)playerCharacterRect).localScale.x;
if (Mathf.Abs(x - 1f) < 0.01f || Mathf.Abs(x - lastPlayer) < 0.01f)
{
((Transform)playerCharacterRect).localScale = new Vector3(value, value, 1f);
lastPlayer = value;
}
else if (!toldOther)
{
toldOther = true;
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(63, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ICONS] player marker already sized ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(x, "0.##");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" by another mod; left alone");
}
l.LogInfo(val);
}
}
catch
{
}
}
}
[HarmonyPatch]
internal static class MapPatches
{
internal static bool MapOpen;
private static readonly Dictionary<IntPtr, int> loaded = new Dictionary<IntPtr, int>();
private static readonly Dictionary<IntPtr, int> asks = new Dictionary<IntPtr, int>();
private static int order;
private static int askFrame = -1;
internal static int MaxAsks;
private static bool toldLimit;
private static bool reused;
private static int Reused;
private static int Rebuilt;
[HarmonyPatch(typeof(MapAddressButtonController), "UnloadMapImage")]
[HarmonyPrefix]
private static bool Unload(MapAddressButtonController __instance)
{
IntPtr pointer = ((Il2CppObjectBase)__instance).Pointer;
int frameCount = Time.frameCount;
if (frameCount != askFrame)
{
askFrame = frameCount;
asks.Clear();
}
if (!Plugin.KeepImages.Value || loaded.Count > Plugin.MaxImages.Value)
{
return Release(pointer);
}
int value;
int num = ((!asks.TryGetValue(pointer, out value)) ? 1 : (value + 1));
if (num > MaxAsks)
{
MaxAsks = num;
}
if (num >= Plugin.ReleaseAsks.Value)
{
return Release(pointer);
}
asks[pointer] = num;
Plugin.Kept++;
try
{
MapController instance = MapController.Instance;
if ((Object)(object)instance != (Object)null && instance.mapUpdateList != null)
{
instance.mapUpdateList.Remove(__instance);
}
}
catch
{
}
return false;
}
private static bool Release(IntPtr key)
{
loaded.Remove(key);
asks.Remove(key);
Plugin.Allowed++;
return true;
}
[HarmonyPatch(typeof(MapController), "OpenMap")]
[HarmonyPostfix]
private static void Open()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
MapOpen = true;
try
{
Game instance = Game.Instance;
if (!((Object)(object)instance != (Object)null) || !Plugin.KeepImages.Value || instance.maxDrawnMapIcons >= Plugin.MaxImages.Value)
{
return;
}
if (!toldLimit)
{
toldLimit = true;
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MAP] game keeps ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(instance.maxDrawnMapIcons);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" buildings drawn, raised to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Plugin.MaxImages.Value);
}
l.LogInfo(val);
}
instance.maxDrawnMapIcons = Plugin.MaxImages.Value;
}
catch (Exception ex)
{
Plugin.L.LogWarning((object)("[MAP] drawn limit: " + ex.Message));
}
}
[HarmonyPatch(typeof(MapAddressButtonController), "GenerateMapImage")]
[HarmonyPrefix]
private static bool GenPre(MapAddressButtonController __instance)
{
reused = false;
try
{
if (Plugin.KeepImages.Value && loaded.ContainsKey(((Il2CppObjectBase)__instance).Pointer) && (Object)(object)__instance.tex != (Object)null && (Object)(object)__instance.generatedImage != (Object)null && (Object)(object)__instance.generatedImage.sprite != (Object)null)
{
if (!__instance.rebuildImage)
{
((Behaviour)__instance.generatedImage).enabled = true;
if (!((Component)__instance.generatedImage).gameObject.activeSelf)
{
((Component)__instance.generatedImage).gameObject.SetActive(true);
}
reused = true;
Reused++;
return false;
}
Rebuilt++;
}
}
catch
{
}
Plugin.Sw.Restart();
return true;
}
[HarmonyPatch(typeof(MapAddressButtonController), "GenerateMapImage")]
[HarmonyPostfix]
private static void GenPost(MapAddressButtonController __instance)
{
if (reused)
{
reused = false;
return;
}
loaded[((Il2CppObjectBase)__instance).Pointer] = ++order;
asks.Remove(((Il2CppObjectBase)__instance).Pointer);
Plugin.Built++;
Plugin.BuildMs += Plugin.Sw.Elapsed.TotalMilliseconds;
}
[HarmonyPatch(typeof(MapController), "CloseMap")]
[HarmonyPostfix]
private static void Close()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
MapOpen = false;
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(149, 8, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MAP] drawn so far ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Plugin.Built);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(Plugin.BuildMs, "0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms), unloads skipped ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Plugin.Kept);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", let through ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Plugin.Allowed);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", kept now ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(loaded.Count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", most asks in a frame ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(MaxAsks);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", kept pictures shown again ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Reused);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", redrawn for new information ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Rebuilt);
}
l.LogInfo(val);
}
}
[HarmonyPatch]
internal static class FurnitureIconsPatch
{
private static CityData? builtFor;
private static readonly Dictionary<IntPtr, Sprite> sprites = new Dictionary<IntPtr, Sprite>();
private static readonly SortedDictionary<string, int> seenNames = new SortedDictionary<string, int>();
private static readonly Dictionary<IntPtr, RectTransform> holders = new Dictionary<IntPtr, RectTransform>();
[HarmonyPatch(typeof(MapController), "OpenMap")]
[HarmonyPostfix]
private static void Open(MapController __instance)
{
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
//IL_039c: Expected O, but got Unknown
//IL_045b: Unknown result type (might be due to invalid IL or missing references)
//IL_0462: Expected O, but got Unknown
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: 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_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
try
{
float value = Plugin.VendingScale.Value;
CityData instance = CityData.Instance;
if (value <= 0f || (Object)(object)instance == (Object)null || instance.roomDirectory == null || builtFor == instance)
{
return;
}
builtFor = instance;
string[] array = (from x in Plugin.FurnitureIcons.Value.Split(',')
select x.Trim() into x
where x.Length > 0
select x).ToArray();
if (array.Length == 0)
{
return;
}
int num = 0;
int num2 = 0;
SortedDictionary<string, int> sortedDictionary = new SortedDictionary<string, int>();
for (int num3 = 0; num3 < instance.roomDirectory.Count; num3++)
{
NewRoom obj = instance.roomDirectory[num3];
List<FurnitureLocation> val = ((obj != null) ? obj.individualFurniture : null);
int num4 = 0;
while (val != null && num4 < val.Count)
{
FurnitureLocation val2 = val[num4];
FurniturePreset val3 = ((val2 != null) ? val2.furniture : null);
if (!((SoCustomComparison)(object)val3 == (SoCustomComparison)null) && val2.anchorNode != null)
{
string text = ((Object)val3).name ?? "";
if ((Object)(object)val3.map != (Object)null)
{
seenNames[text] = ((!seenNames.TryGetValue(text, out var value2)) ? 1 : (value2 + 1));
}
string text2 = text;
int num5 = 0;
while (val2.furnitureClasses != null && num5 < val2.furnitureClasses.Count)
{
string text3 = text2;
FurnitureClass obj2 = val2.furnitureClasses[num5];
text2 = text3 + "|" + ((obj2 != null) ? ((Object)obj2).name : null);
num5++;
}
bool flag = false;
string[] array2 = array;
foreach (string value3 in array2)
{
if (text2.IndexOf(value3, StringComparison.OrdinalIgnoreCase) >= 0)
{
flag = true;
break;
}
}
if (flag)
{
Vector3Int nodeCoord = val2.anchorNode.nodeCoord;
if (!__instance.mapLayers.ContainsKey(((Vector3Int)(ref nodeCoord)).z))
{
num2++;
}
else
{
MapLayer val4 = __instance.mapLayers[((Vector3Int)(ref nodeCoord)).z];
if ((Object)(object)val4.baseContainer == (Object)null)
{
num2++;
}
else
{
Vector2 val5 = __instance.NodeCoordToMap(new Vector3((float)((Vector3Int)(ref nodeCoord)).x, (float)((Vector3Int)(ref nodeCoord)).y, (float)((Vector3Int)(ref nodeCoord)).z));
Vector2 val6 = __instance.NodeCoordToMap(new Vector3((float)(((Vector3Int)(ref nodeCoord)).x + 1), (float)((Vector3Int)(ref nodeCoord)).y, (float)((Vector3Int)(ref nodeCoord)).z)) - val5;
float magnitude = ((Vector2)(ref val6)).magnitude;
GameObject val7 = new GameObject("MapImprovementsIcon");
RectTransform obj3 = val7.AddComponent<RectTransform>();
((Transform)obj3).SetParent((Transform)(object)HolderFor(val4.baseContainer), false);
val6 = (obj3.anchorMin = (obj3.anchorMax = new Vector2(0f, 0f)));
obj3.pivot = new Vector2(0.5f, 0.5f);
obj3.anchoredPosition = val5;
obj3.sizeDelta = new Vector2(magnitude * value, magnitude * value);
Image obj4 = val7.AddComponent<Image>();
((Graphic)obj4).raycastTarget = false;
obj4.sprite = SpriteFor(val3);
obj4.preserveAspect = true;
num++;
sortedDictionary[text] = ((!sortedDictionary.TryGetValue(text, out var value4)) ? 1 : (value4 + 1));
}
}
}
}
num4++;
}
}
bool flag2 = default(bool);
BepInExInfoLogInterpolatedStringHandler val10;
foreach (KeyValuePair<string, int> item in sortedDictionary)
{
ManualLogSource l = Plugin.L;
val10 = new BepInExInfoLogInterpolatedStringHandler(21, 2, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val10).AppendLiteral("[ICONS] ");
((BepInExLogInterpolatedStringHandler)val10).AppendFormatted<string>(item.Key);
((BepInExLogInterpolatedStringHandler)val10).AppendLiteral(": ");
((BepInExLogInterpolatedStringHandler)val10).AppendFormatted<int>(item.Value);
((BepInExLogInterpolatedStringHandler)val10).AppendLiteral(" on the map");
}
l.LogInfo(val10);
}
Plugin.L.LogInfo((object)("[ICONS] furniture with a map symbol: " + string.Join(", ", seenNames.Select<KeyValuePair<string, int>, string>((KeyValuePair<string, int> kv) => kv.Key + " " + kv.Value))));
seenNames.Clear();
ManualLogSource l2 = Plugin.L;
val10 = new BepInExInfoLogInterpolatedStringHandler(30, 2, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val10).AppendLiteral("[ICONS] ");
((BepInExLogInterpolatedStringHandler)val10).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val10).AppendLiteral(" furniture icons added");
((BepInExLogInterpolatedStringHandler)val10).AppendFormatted<string>((num2 > 0) ? $", {num2} skipped (no map floor)" : "");
}
l2.LogInfo(val10);
}
catch (Exception ex)
{
Plugin.L.LogError((object)("[ICONS] furniture icons: " + ex));
}
}
internal static RectTransform HolderFor(RectTransform baseC)
{
//IL_0024: 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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
if (holders.TryGetValue(((Il2CppObjectBase)baseC).Pointer, out RectTransform value) && (Object)(object)value != (Object)null)
{
return value;
}
value = new GameObject("MapImprovementsIcons").AddComponent<RectTransform>();
((Transform)value).SetParent(((Transform)baseC).parent, false);
((Transform)value).SetSiblingIndex(((Transform)baseC).GetSiblingIndex() + 1);
value.anchorMin = baseC.anchorMin;
value.anchorMax = baseC.anchorMax;
value.pivot = baseC.pivot;
value.anchoredPosition = baseC.anchoredPosition;
value.sizeDelta = baseC.sizeDelta;
((Transform)value).localScale = ((Transform)baseC).localScale;
((Transform)value).localRotation = ((Transform)baseC).localRotation;
holders[((Il2CppObjectBase)baseC).Pointer] = value;
return value;
}
internal static Sprite? SpriteFor(FurniturePreset p)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
Texture2D map = p.map;
if ((Object)(object)map == (Object)null)
{
return null;
}
if (sprites.TryGetValue(((Il2CppObjectBase)map).Pointer, out Sprite value) && (Object)(object)value != (Object)null)
{
return value;
}
value = Sprite.Create(map, new Rect(0f, 0f, (float)((Texture)map).width, (float)((Texture)map).height), new Vector2(0.5f, 0.5f));
sprites[((Il2CppObjectBase)map).Pointer] = value;
return value;
}
}
[HarmonyPatch]
internal static class ControlRoomGhosts
{
private static CityData? builtFor;
private static readonly Regex Security = new Regex("secur|cctv|camera|monitor|surveil", RegexOptions.IgnoreCase);
[HarmonyPatch(typeof(MapController), "OpenMap")]
[HarmonyPostfix]
private static void Open(MapController __instance)
{
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0929: Unknown result type (might be due to invalid IL or missing references)
//IL_0930: Expected O, but got Unknown
//IL_069d: Unknown result type (might be due to invalid IL or missing references)
//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
//IL_06ca: Unknown result type (might be due to invalid IL or missing references)
//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
//IL_06e1: 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_06eb: Unknown result type (might be due to invalid IL or missing references)
//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0702: Unknown result type (might be due to invalid IL or missing references)
//IL_0707: Unknown result type (might be due to invalid IL or missing references)
//IL_0731: Unknown result type (might be due to invalid IL or missing references)
//IL_0736: Unknown result type (might be due to invalid IL or missing references)
//IL_0737: Unknown result type (might be due to invalid IL or missing references)
//IL_073e: Unknown result type (might be due to invalid IL or missing references)
//IL_0750: Unknown result type (might be due to invalid IL or missing references)
//IL_075b: Unknown result type (might be due to invalid IL or missing references)
//IL_0788: Unknown result type (might be due to invalid IL or missing references)
//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
//IL_08c2: Unknown result type (might be due to invalid IL or missing references)
//IL_082a: Unknown result type (might be due to invalid IL or missing references)
//IL_0821: Unknown result type (might be due to invalid IL or missing references)
//IL_082f: Unknown result type (might be due to invalid IL or missing references)
//IL_0836: Unknown result type (might be due to invalid IL or missing references)
//IL_0843: Unknown result type (might be due to invalid IL or missing references)
//IL_0851: Unknown result type (might be due to invalid IL or missing references)
//IL_087e: Unknown result type (might be due to invalid IL or missing references)
//IL_0885: Unknown result type (might be due to invalid IL or missing references)
//IL_088c: Unknown result type (might be due to invalid IL or missing references)
//IL_0895: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_04da: Unknown result type (might be due to invalid IL or missing references)
//IL_04e1: Expected O, but got Unknown
//IL_0469: Unknown result type (might be due to invalid IL or missing references)
//IL_046e: Unknown result type (might be due to invalid IL or missing references)
//IL_0489: Unknown result type (might be due to invalid IL or missing references)
//IL_048d: Unknown result type (might be due to invalid IL or missing references)
//IL_0492: Unknown result type (might be due to invalid IL or missing references)
//IL_0497: Unknown result type (might be due to invalid IL or missing references)
//IL_049c: Unknown result type (might be due to invalid IL or missing references)
//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
try
{
float num = Mathf.Clamp01(Plugin.GhostAlpha.Value);
CityData instance = CityData.Instance;
if (num <= 0f || (Object)(object)instance == (Object)null || builtFor == instance || __instance.mapLayers == null)
{
return;
}
FurniturePreset val = null;
foreach (FurniturePreset item3 in Resources.FindObjectsOfTypeAll<FurniturePreset>())
{
if ((SoCustomComparison)(object)item3 != (SoCustomComparison)null && ((Object)item3).name == "SecurityCamera" && (Object)(object)item3.map != (Object)null)
{
val = item3;
break;
}
}
Sprite val2 = null;
foreach (Sprite item4 in Resources.FindObjectsOfTypeAll<Sprite>())
{
if ((Object)(object)item4 != (Object)null && ((Object)item4).name == "IconCamera")
{
val2 = item4;
break;
}
}
SortedDictionary<string, int> sortedDictionary = new SortedDictionary<string, int>();
Color? val3 = null;
Scene scene;
foreach (MapAddressButtonController item5 in Resources.FindObjectsOfTypeAll<MapAddressButtonController>())
{
if ((Object)(object)item5 == (Object)null)
{
continue;
}
scene = ((Component)item5).gameObject.scene;
if (!((Scene)(ref scene)).IsValid() || (Object)(object)item5.typeIcon == (Object)null || (Object)(object)item5.typeIcon.sprite == (Object)null)
{
continue;
}
string text = ((Object)item5.typeIcon.sprite).name;
if (text == "IconCamera")
{
string text2 = text;
NewGameLocation gameLocation = item5.gameLocation;
object obj;
if (gameLocation == null)
{
obj = null;
}
else
{
NewAddress thisAsAddress = gameLocation.thisAsAddress;
if (thisAsAddress == null)
{
obj = null;
}
else
{
AddressPreset addressPreset = thisAsAddress.addressPreset;
obj = ((addressPreset != null) ? ((Object)addressPreset).name : null);
}
}
if (obj == null)
{
obj = "?";
}
text = text2 + " (" + (string?)obj + ")";
}
sortedDictionary[text] = ((!sortedDictionary.TryGetValue(text, out var value)) ? 1 : (value + 1));
if (!val3.HasValue)
{
val3 = ((Graphic)item5.typeIcon).color;
}
}
Plugin.L.LogInfo((object)("[ICONS] map icons in use: " + string.Join(", ", sortedDictionary.Select((KeyValuePair<string, int> kv) => kv.Key + " " + kv.Value))));
HashSet<IntPtr> hashSet = new HashSet<IntPtr>();
int num2 = 0;
int num3 = 0;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val9;
foreach (MapAddressButtonController item6 in Resources.FindObjectsOfTypeAll<MapAddressButtonController>())
{
if ((Object)(object)item6 == (Object)null)
{
continue;
}
scene = ((Component)item6).gameObject.scene;
if (!((Scene)(ref scene)).IsValid())
{
continue;
}
NewGameLocation gameLocation2 = item6.gameLocation;
NewAddress val4 = ((gameLocation2 != null) ? gameLocation2.thisAsAddress : null);
if ((Object)(object)val4 == (Object)null || (SoCustomComparison)(object)val4.addressPreset == (SoCustomComparison)null || ((Object)val4.addressPreset).name != "ControlRoom" || !hashSet.Add(((Il2CppObjectBase)val4).Pointer))
{
continue;
}
num2++;
int num4 = (((Object)(object)((NewGameLocation)val4).floor != (Object)null) ? ((NewGameLocation)val4).floor.floor : int.MinValue);
List<(Vector3, FurniturePreset)> list = new List<(Vector3, FurniturePreset)>();
SortedSet<string> sortedSet = new SortedSet<string>();
int num5 = 0;
while (((NewGameLocation)val4).rooms != null && num5 < ((NewGameLocation)val4).rooms.Count)
{
NewRoom obj2 = ((NewGameLocation)val4).rooms[num5];
List<FurnitureLocation> val5 = ((obj2 != null) ? obj2.individualFurniture : null);
int num6 = 0;
while (val5 != null && num6 < val5.Count)
{
FurnitureLocation val6 = val5[num6];
FurniturePreset val7 = ((val6 != null) ? val6.furniture : null);
if (!((SoCustomComparison)(object)val7 == (SoCustomComparison)null) && !((Object)(object)val7.map == (Object)null) && val6.anchorNode != null)
{
sortedSet.Add(((Object)val7).name);
if (Security.IsMatch(((Object)val7).name ?? ""))
{
list.Add((Vector3Int.op_Implicit(val6.anchorNode.nodeCoord), val7));
}
}
num6++;
}
num5++;
}
if (list.Count == 0 && (SoCustomComparison)(object)val != (SoCustomComparison)null && ((NewGameLocation)val4).nodes != null && ((NewGameLocation)val4).nodes.Count > 0)
{
Vector3 val8 = Vector3.zero;
Enumerator<NewNode> enumerator4 = ((NewGameLocation)val4).nodes.GetEnumerator();
while (enumerator4.MoveNext())
{
NewNode current5 = enumerator4.Current;
val8 += Vector3Int.op_Implicit(current5.nodeCoord);
}
list.Add((val8 / (float)((NewGameLocation)val4).nodes.Count, val));
}
if (num2 <= 3)
{
ManualLogSource l = Plugin.L;
val9 = new BepInExInfoLogInterpolatedStringHandler(81, 6, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("[ICONS] control room '");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<string>(((Object)val4).name);
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("' floor ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<int>(num4);
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(", picture '");
BepInExInfoLogInterpolatedStringHandler obj3 = val9;
Sprite evidenceIconLarge = val4.addressPreset.evidenceIconLarge;
((BepInExLogInterpolatedStringHandler)obj3).AppendFormatted<string>((evidenceIconLarge != null) ? ((Object)evidenceIconLarge).name : null);
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("': furniture with map symbols ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<string>(string.Join(", ", sortedSet));
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("; markers ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<int>(list.Count);
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<string>((list.Count > 0) ? (" (" + ((Object)list[0].Item2).name + ")") : "");
}
l.LogInfo(val9);
}
int num7 = int.MaxValue;
int num8 = int.MinValue;
try
{
NewBuilding building = ((NewGameLocation)val4).building;
Dictionary<int, NewFloor> val10 = ((building != null) ? building.floors : null);
if (val10 != null)
{
Enumerator<int, NewFloor> enumerator5 = val10.GetEnumerator();
while (enumerator5.MoveNext())
{
KeyValuePair<int, NewFloor> current6 = enumerator5.Current;
num7 = Math.Min(num7, current6.Key);
num8 = Math.Max(num8, current6.Key);
}
}
}
catch
{
}
Enumerator<int, MapLayer> enumerator6 = __instance.mapLayers.GetEnumerator();
while (enumerator6.MoveNext())
{
KeyValuePair<int, MapLayer> current7 = enumerator6.Current;
int key = current7.Key;
if ((Object)(object)current7.Value.baseContainer == (Object)null || (num7 <= num8 && (key < num7 || key > num8)))
{
continue;
}
float num9 = ((key == num4) ? 1f : num);
foreach (var item7 in list)
{
Vector3 item = item7.Item1;
FurniturePreset item2 = item7.Item2;
Vector2 val11 = __instance.NodeCoordToMap(new Vector3(item.x, item.y, (float)key));
Vector2 val12 = __instance.NodeCoordToMap(new Vector3(item.x + 1f, item.y, (float)key)) - val11;
float magnitude = ((Vector2)(ref val12)).magnitude;
GameObject val13 = new GameObject("MapImprovementsControlRoom");
RectTransform obj5 = val13.AddComponent<RectTransform>();
((Transform)obj5).SetParent((Transform)(object)FurnitureIconsPatch.HolderFor(current7.Value.baseContainer), false);
val12 = (obj5.anchorMin = (obj5.anchorMax = new Vector2(0f, 0f)));
obj5.pivot = new Vector2(0.5f, 0.5f);
obj5.anchoredPosition = val11;
float num10 = Math.Max(1f, Plugin.VendingScale.Value) * 1.5f;
obj5.sizeDelta = new Vector2(magnitude * num10, magnitude * num10);
Image val16 = val13.AddComponent<Image>();
((Graphic)val16).raycastTarget = false;
val16.preserveAspect = true;
Sprite evidenceIconLarge2 = val4.addressPreset.evidenceIconLarge;
if ((Object)(object)evidenceIconLarge2 != (Object)null)
{
val16.sprite = evidenceIconLarge2;
((Graphic)val16).color = new Color(0.06f, 0.2f, 0.31f, num9);
}
else if ((Object)(object)val2 != (Object)null)
{
val16.sprite = val2;
Color val17 = (Color)(((??)val3) ?? new Color(0.12f, 0.12f, 0.3f, 1f));
if (0.3f * val17.r + 0.59f * val17.g + 0.11f * val17.b > 0.5f)
{
((Color)(ref val17))..ctor(0.12f, 0.12f, 0.3f, 1f);
}
((Graphic)val16).color = new Color(val17.r, val17.g, val17.b, num9);
}
else
{
val16.sprite = FurnitureIconsPatch.SpriteFor(item2);
((Graphic)val16).color = new Color(1f, 1f, 1f, num9);
}
num3++;
}
}
}
if (num3 > 0)
{
builtFor = instance;
}
ManualLogSource l2 = Plugin.L;
val9 = new BepInExInfoLogInterpolatedStringHandler(91, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("[ICONS] control rooms: ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<int>(num2);
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(" found, ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<int>(num3);
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(" faded markers on other floors, camera symbol ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<string>(((SoCustomComparison)(object)val != (SoCustomComparison)null) ? "found" : "not found");
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(", camera icon ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<string>(((Object)(object)val2 != (Object)null) ? "found" : "not found");
}
l2.LogInfo(val9);
}
catch (Exception ex)
{
Plugin.L.LogError((object)("[ICONS] control room markers: " + ex));
}
}
}
[HarmonyPatch]
internal static class BodyMarkersPatch
{
private static readonly List<GameObject> made = new List<GameObject>();
private static readonly HashSet<int> skipped = new HashSet<int>();
private static readonly HashSet<int> marked = new HashSet<int>();
private static Sprite? icon;
private static bool looked;
[HarmonyPatch(typeof(MapController), "OpenMap")]
[HarmonyPostfix]
private static void Open(MapController __instance)
{
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Expected O, but got Unknown
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_033d: Unknown result type (might be due to invalid IL or missing references)
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_035b: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_0365: Unknown result type (might be due to invalid IL or missing references)
//IL_036a: Unknown result type (might be due to invalid IL or missing references)
//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
//IL_03d8: Expected O, but got Unknown
//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
//IL_05d0: Expected O, but got Unknown
//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
//IL_04b7: Expected O, but got Unknown
//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0501: Unknown result type (might be due to invalid IL or missing references)
//IL_050c: Unknown result type (might be due to invalid IL or missing references)
//IL_0539: Unknown result type (might be due to invalid IL or missing references)
//IL_0580: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
try
{
foreach (GameObject item in made)
{
if ((Object)(object)item != (Object)null)
{
Object.Destroy((Object)(object)item);
}
}
made.Clear();
string text = (Plugin.BodyMarkers.Value ?? "Found").Trim();
if (text.Equals("Off", StringComparison.OrdinalIgnoreCase))
{
return;
}
bool flag = text.Equals("All", StringComparison.OrdinalIgnoreCase);
CityData instance = CityData.Instance;
if (((instance != null) ? instance.citizenDirectory : null) == null || __instance.mapLayers == null)
{
return;
}
if (!looked)
{
looked = true;
icon = FindIcon();
}
float num = Mathf.Clamp(Plugin.GhostAlpha.Value, 0.15f, 1f);
int num2 = 0;
bool flag2 = default(bool);
for (int i = 0; i < instance.citizenDirectory.Count; i++)
{
Citizen val = instance.citizenDirectory[i];
if ((Object)(object)val == (Object)null || !((Actor)val).isDead)
{
continue;
}
if (((Human)val).removedFromWorld)
{
if (!skipped.Add(((Human)val).humanID))
{
continue;
}
string text2 = "";
try
{
Death death = ((Human)val).death;
object obj;
if (death == null)
{
obj = null;
}
else
{
NewGameLocation deathLocation = death.GetDeathLocation();
obj = ((deathLocation != null) ? ((Object)deathLocation).name : null);
}
if (obj == null)
{
obj = "";
}
text2 = (string)obj;
}
catch
{
}
ManualLogSource l = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(54, 3, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ICONS] not marked: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Human)val).GetCitizenName());
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", taken away (died at ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>((text2.Length > 0) ? text2 : "unknown");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", reported ");
BepInExInfoLogInterpolatedStringHandler obj3 = val2;
Death death2 = ((Human)val).death;
((BepInExLogInterpolatedStringHandler)obj3).AppendFormatted<bool>(death2 != null && death2.reported);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
}
l.LogInfo(val2);
}
else
{
if (!flag && (((Human)val).death == null || !((Human)val).death.reported))
{
continue;
}
NewNode currentNode = ((Actor)val).currentNode;
if (currentNode == null)
{
continue;
}
Vector3Int nodeCoord = currentNode.nodeCoord;
int z = ((Vector3Int)(ref nodeCoord)).z;
int num3 = z;
int num4 = z;
try
{
NewBuilding building = currentNode.building;
Dictionary<int, NewFloor> val3 = ((building != null) ? building.floors : null);
if (val3 != null)
{
Enumerator<int, NewFloor> enumerator2 = val3.GetEnumerator();
while (enumerator2.MoveNext())
{
KeyValuePair<int, NewFloor> current2 = enumerator2.Current;
num3 = Math.Min(num3, current2.Key);
num4 = Math.Max(num4, current2.Key);
}
}
}
catch
{
}
Enumerator<int, MapLayer> enumerator3;
try
{
if ((Object)(object)currentNode.building == (Object)null)
{
enumerator3 = __instance.mapLayers.GetEnumerator();
while (enumerator3.MoveNext())
{
KeyValuePair<int, MapLayer> current3 = enumerator3.Current;
num3 = Math.Min(num3, current3.Key);
num4 = Math.Max(num4, current3.Key);
}
}
}
catch
{
}
Vector2 anchoredPosition = __instance.RealPosToMap(((Component)val).transform.position);
nodeCoord = currentNode.nodeCoord;
float num5 = ((Vector3Int)(ref nodeCoord)).x + 1;
nodeCoord = currentNode.nodeCoord;
Vector2 val4 = __instance.NodeCoordToMap(new Vector3(num5, (float)((Vector3Int)(ref nodeCoord)).y, (float)z));
nodeCoord = currentNode.nodeCoord;
float num6 = ((Vector3Int)(ref nodeCoord)).x;
nodeCoord = currentNode.nodeCoord;
Vector2 val5 = val4 - __instance.NodeCoordToMap(new Vector3(num6, (float)((Vector3Int)(ref nodeCoord)).y, (float)z));
float magnitude = ((Vector2)(ref val5)).magnitude;
num2++;
if (marked.Add(((Human)val).humanID))
{
string text3 = "";
try
{
Death death3 = ((Human)val).death;
object obj6;
if (death3 == null)
{
obj6 = null;
}
else
{
NewGameLocation deathLocation2 = death3.GetDeathLocation();
obj6 = ((deathLocation2 != null) ? ((Object)deathLocation2).name : null);
}
if (obj6 == null)
{
obj6 = "";
}
text3 = (string)obj6;
}
catch
{
}
ManualLogSource l2 = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(37, 3, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ICONS] marked: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Human)val).GetCitizenName());
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", lies at ");
BepInExInfoLogInterpolatedStringHandler obj8 = val2;
NewGameLocation currentGameLocation = ((Actor)val).currentGameLocation;
((BepInExLogInterpolatedStringHandler)obj8).AppendFormatted<string>(((currentGameLocation != null) ? ((Object)currentGameLocation).name : null) ?? "?");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (died at ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>((text3.Length > 0) ? text3 : "unknown");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
}
l2.LogInfo(val2);
}
enumerator3 = __instance.mapLayers.GetEnumerator();
while (enumerator3.MoveNext())
{
KeyValuePair<int, MapLayer> current4 = enumerator3.Current;
int key = current4.Key;
if (!((Object)(object)current4.Value.baseContainer == (Object)null) && key >= num3 && key <= num4)
{
GameObject val6 = new GameObject("MapImprovementsBody");
RectTransform obj9 = val6.AddComponent<RectTransform>();
((Transform)obj9).SetParent((Transform)(object)FurnitureIconsPatch.HolderFor(current4.Value.baseContainer), false);
val5 = (obj9.anchorMin = (obj9.anchorMax = new Vector2(0f, 0f)));
obj9.pivot = new Vector2(0.5f, 0.5f);
obj9.anchoredPosition = anchoredPosition;
float num7 = Math.Max(1f, Plugin.VendingScale.Value) * 1.5f;
obj9.sizeDelta = new Vector2(magnitude * num7, magnitude * num7);
Image obj10 = val6.AddComponent<Image>();
((Graphic)obj10).raycastTarget = false;
obj10.preserveAspect = true;
obj10.sprite = icon;
((Graphic)obj10).color = new Color(0.55f, 0.05f, 0.05f, (key == z) ? 1f : num);
made.Add(val6);
}
}
}
}
if (num2 > 0)
{
ManualLogSource l3 = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(34, 3, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ICONS] ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" bodies marked (");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("), icon '");
BepInExInfoLogInterpolatedStringHandler obj11 = val2;
Sprite? obj12 = icon;
((BepInExLogInterpolatedStringHandler)obj11).AppendFormatted<string>(((obj12 != null) ? ((Object)obj12).name : null) ?? "plain square");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
}
l3.LogInfo(val2);
}
}
catch (Exception ex)
{
Plugin.L.LogError((object)("[ICONS] body markers: " + ex));
}
}
private static Sprite? FindIcon()
{
foreach (Sprite item in Resources.FindObjectsOfTypeAll<Sprite>())
{
if ((Object)(object)item != (Object)null && ((Object)item).name == "IconDeath")
{
return item;
}
}
string[] array = new string[8] { "death", "skull", "corpse", "body", "dead", "murder", "victim", "crime" };
List<string> list = new List<string>();
Sprite result = null;
int num = int.MaxValue;
foreach (Sprite item2 in Resources.FindObjectsOfTypeAll<Sprite>())
{
if ((Object)(object)item2 == (Object)null || ((Object)item2).name == null)
{
continue;
}
string text = ((Object)item2).name.ToLowerInvariant();
for (int i = 0; i < array.Length; i++)
{
if (text.Contains(array[i]))
{
if (list.Count < 30)
{
list.Add(((Object)item2).name);
}
if (i < num || (i == num && text.StartsWith("icon")))
{
result = item2;
num = i;
}
break;
}
}
}
Plugin.L.LogInfo((object)("[ICONS] body icon candidates: " + string.Join(", ", list)));
return result;
}
}
[HarmonyPatch]
internal static class ZoomOutPatch
{
private static Vector2 original;
private static bool have;
private static bool logged;
private static object? zoomedFor;
[HarmonyPatch(typeof(MapController), "OpenMap")]
[HarmonyPostfix]
private static void Open(MapController __instance)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Expected O, but got Unknown
try
{
ZoomContent zoomController = __instance.zoomController;
if ((Object)(object)zoomController == (Object)null)
{
return;
}
if (!have)
{
original = zoomController.zoomLimit;
have = true;
}
float num = Mathf.Max(1f, Plugin.ZoomOut.Value);
zoomController.zoomLimit = new Vector2(original.x / num, original.y);
bool flag = default(bool);
if (!logged)
{
logged = true;
ManualLogSource l = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ZOOM] map zoom limit ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector2>(original);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector2>(zoomController.zoomLimit);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (x");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "0.##");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" further out)");
}
l.LogInfo(val);
}
CityData instance = CityData.Instance;
if (Plugin.StartZoomedOut.Value && (Object)(object)instance != (Object)null && instance != zoomedFor)
{
zoomedFor = instance;
zoomController.SetZoom(zoomController.zoomLimit.x);
ManualLogSource l2 = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ZOOM] new city: map starts zoomed out at ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(zoomController.zoom, "0.###");
}
l2.LogInfo(val);
}
}
catch (Exception ex)
{
Plugin.L.LogError((object)("[ZOOM] " + ex));
}
}
}
[HarmonyPatch]
internal static class TrackedFadePatch
{
private static int logs;
private static Type? crType;
private static MethodInfo? getAlpha;
private static MethodInfo? setAlpha;
private static bool failed;
private static readonly Dictionary<IntPtr, object> wrappers = new Dictionary<IntPtr, object>();
private static bool Init()
{
if (crType != null)
{
return true;
}
if (failed)
{
return false;
}
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
if (!(assembly.GetName().Name != "UnityEngine.UIModule"))
{
crType = assembly.GetType("UnityEngine.CanvasRenderer", throwOnError: false);
break;
}
}
if (crType != null)
{
getAlpha = crType.GetMethod("GetAlpha", Type.EmptyTypes);
setAlpha = crType.GetMethod("SetAlpha", new Type[1] { typeof(float) });
}
if (crType == null || getAlpha == null || setAlpha == null)
{
failed = true;
Plugin.L.LogWarning((object)"[TRACK] CanvasRenderer not found, markers keep the game's fading");
return false;
}
return true;
}
[HarmonyPatch(typeof(MapController), "UpdateTrackedObject")]
[HarmonyPostfix]
private static void After(RectTransform mapObj)
{
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Expected O, but got Unknown
try
{
float num = Mathf.Clamp01(Plugin.OtherFloorAlpha.Value);
if (num <= 0f || (Object)(object)mapObj == (Object)null || !Init())
{
return;
}
if (!wrappers.TryGetValue(((Il2CppObjectBase)mapObj).Pointer, out object value))
{
Component component = ((Component)mapObj).GetComponent("CanvasRenderer");
if ((Object)(object)component == (Object)null)
{
return;
}
value = Activator.CreateInstance(crType, ((Il2CppObjectBase)component).Pointer);
if (wrappers.Count > 400)
{
wrappers.Clear();
}
wrappers[((Il2CppObjectBase)mapObj).Pointer] = value;
}
float num2 = (float)getAlpha.Invoke(value, null);
if (!(num2 > 0.01f) || !(num2 < num))
{
return;
}
setAlpha.Invoke(value, new object[1] { num });
if (logs++ < 6)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(40, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TRACK] faded marker '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)mapObj).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' raised from ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num2, "0.00");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "0.00");
}
l.LogInfo(val);
}
}
catch (Exception ex)
{
if (logs++ < 6)
{
Plugin.L.LogError((object)("[TRACK] " + ex.Message));
}
}
}
}
}