using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
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.0.0")]
public sealed class Plugin : BasePlugin
{
public const string VER = "1.0.0";
internal static ManualLogSource L = 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 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_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
L = ((BasePlugin)this).Log;
PlaceScale = ((BasePlugin)this).Config.Bind<float>("Icons", "PlaceIconScale", 2f, "Size of shop, business and building icons on the map (1 = vanilla).");
PlayerScale = ((BasePlugin)this).Config.Bind<float>("Icons", "PlayerIconScale", 2f, "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", 2f, "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 while it is closed, so reopening the map does not redraw them.");
Harmony val = new Harmony("sm3gm.sod.mapimprovements");
val.PatchAll(typeof(IconPatches));
val.PatchAll(typeof(MapPatches));
ManualLogSource l = L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Map Improvements ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded");
}
l.LogInfo(val2);
}
}
[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
{
private static int frame = -1;
private static int callsThisFrame;
internal static bool MapOpen;
[HarmonyPatch(typeof(MapAddressButtonController), "UnloadMapImage")]
[HarmonyPrefix]
private static bool Unload()
{
if (!Plugin.KeepImages.Value || MapOpen)
{
return true;
}
int frameCount = Time.frameCount;
if (frameCount != frame)
{
frame = frameCount;
callsThisFrame = 0;
}
if (++callsThisFrame > 8)
{
Plugin.Allowed++;
return true;
}
Plugin.Kept++;
return false;
}
[HarmonyPatch(typeof(MapController), "OpenMap")]
[HarmonyPostfix]
private static void Open()
{
MapOpen = true;
}
[HarmonyPatch(typeof(MapAddressButtonController), "GenerateMapImage")]
[HarmonyPrefix]
private static void GenPre()
{
Plugin.Sw.Restart();
}
[HarmonyPatch(typeof(MapAddressButtonController), "GenerateMapImage")]
[HarmonyPostfix]
private static void GenPost()
{
Plugin.Built++;
Plugin.BuildMs += Plugin.Sw.Elapsed.TotalMilliseconds;
}
[HarmonyPatch(typeof(MapController), "CloseMap")]
[HarmonyPostfix]
private static void Close()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
MapOpen = false;
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(57, 4, 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);
}
l.LogInfo(val);
}
}
}