using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using GTFO.API;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
[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("BetterMaps")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterMaps")]
[assembly: AssemblyTitle("BetterMaps")]
[assembly: TargetPlatform("Windows7.0")]
[assembly: SupportedOSPlatform("Windows7.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 BetterMaps
{
[BepInPlugin("BetterMaps", "BetterMaps", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class EntryPoint : BasePlugin
{
private Harmony _Harmony = null;
private ConfigEntry<float> _BlurFactor;
private ConfigEntry<float> _OutlineFactor;
public override void Load()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
_BlurFactor = ((BasePlugin)this).Config.Bind<float>("Map Quality", "Blur Scale", 0.15f, (ConfigDescription)null);
_OutlineFactor = ((BasePlugin)this).Config.Bind<float>("Map Quality", "Outline Scale", 0.05f, (ConfigDescription)null);
_Harmony = new Harmony("BetterMaps.Harmony");
_Harmony.PatchAll();
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin has loaded with ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_Harmony.GetPatchedMethods().Count());
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" patches!");
}
Logger.Info(val);
LevelAPI.OnBuildDone += OnBuildDone;
}
private void OnBuildDone()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//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_005e: 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_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: 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_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
MapDetails current = MapDetails.Current;
current.m_mapResolution = Mathf.Min(current.m_mapResolution, current.m_mapRenderResolution);
current.m_navmesh = CreateNavMesh(flipMesh: true);
current.SetupMeshRendering();
current.m_bounds = ((Renderer)current.m_mapMeshRenderer).bounds;
Bounds bounds = current.m_bounds;
((Bounds)(ref bounds)).Expand(new Vector3(64f, 0f, 64f));
bounds = current.m_bounds;
current.s_boundsCenter = ((Bounds)(ref bounds)).center;
bounds = current.m_bounds;
current.s_boundsExtentsX = ((Bounds)(ref bounds)).extents.x;
bounds = current.m_bounds;
current.s_boundsExtentsZ = ((Bounds)(ref bounds)).extents.z;
DrawMapBasis(current);
}
private void DrawMapBasis(MapDetails md)
{
//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_000b: 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_0024: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Expected O, but got Unknown
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Expected O, but got Unknown
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
Bounds bounds = md.m_bounds;
int num = (int)((Bounds)(ref bounds)).size.x * md.m_mapRenderResolution;
bounds = md.m_bounds;
int num2 = (int)((Bounds)(ref bounds)).size.z * md.m_mapRenderResolution;
float num3 = default(float);
bool flag = default(bool);
float num4 = default(float);
md.GetClampedRes(1024, ref num, ref num2, ref num3, ref flag, ref num4);
float num5 = 0.005f * num4;
float num6 = num5 * _BlurFactor.Value;
float num7 = num5 * _OutlineFactor.Value;
int num8 = Shader.PropertyToID("_SamplingScale");
md.m_findMapOutline_Material.SetFloat(num8, num7);
md.m_SDF_Material.SetFloat(num8, num7);
md.m_blurX.SetFloat(num8, num6);
md.m_blurY.SetFloat(num8, num6);
RenderTexture val = new RenderTexture(num, num2, 16, (RenderTextureFormat)0, (RenderTextureReadWrite)1);
RenderTexture val2 = new RenderTexture(num, num2, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)1);
RenderTexture val3 = new RenderTexture(((Texture)md.m_mapTexture).width, ((Texture)md.m_mapTexture).height, 0, (RenderTextureFormat)11, (RenderTextureReadWrite)1);
((Texture)val).filterMode = (FilterMode)2;
((Texture)val2).filterMode = (FilterMode)2;
((Texture)val3).filterMode = (FilterMode)2;
val.Create();
val2.Create();
val3.Create();
CommandBuffer val4 = new CommandBuffer();
val4.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)val));
val4.ClearRenderTarget(true, true, Color.black);
val4.SetProjectionMatrix(md.m_camera.projectionMatrix);
val4.SetViewMatrix(md.m_camera.worldToCameraMatrix);
val4.DrawRenderer((Renderer)(object)md.m_mapMeshRenderer, md.m_navmeshMaterial);
val4.Blit((Texture)(object)val, RenderTargetIdentifier.op_Implicit((Texture)(object)val2), md.m_findMapOutline_Material);
val4.Blit((Texture)(object)val2, RenderTargetIdentifier.op_Implicit((Texture)(object)md.m_mapTexture), md.m_SDF_Material);
val4.Blit((Texture)(object)md.m_mapTexture, RenderTargetIdentifier.op_Implicit((Texture)(object)val3), md.m_blurX);
val4.Blit((Texture)(object)val3, RenderTargetIdentifier.op_Implicit((Texture)(object)md.m_mapTexture), md.m_blurY);
val4.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)md.m_mapTexture));
((Renderer)md.m_mapMeshRenderer).enabled = true;
Graphics.ExecuteCommandBuffer(val4);
val4.Dispose();
((Renderer)md.m_mapMeshRenderer).enabled = false;
Object.Destroy((Object)(object)((Component)md.m_mapMeshRenderer).gameObject);
md.m_mapMeshRenderer = null;
val.Release();
val2.Release();
val3.Release();
if ((Object)(object)md.m_navmesh != (Object)null)
{
Object.Destroy((Object)(object)md.m_navmesh);
md.m_navmesh = null;
}
}
private Mesh CreateNavMesh(bool flipMesh)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0055: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: 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_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_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
NavMeshTriangulation val = NavMesh.CalculateTriangulation();
Mesh val2 = new Mesh();
List<int> list = new List<int>();
for (int i = 0; i < ((Il2CppArrayBase<int>)(object)val.indices).Length; i += 3)
{
int num = ((Il2CppArrayBase<int>)(object)val.indices)[i];
int num2 = ((Il2CppArrayBase<int>)(object)val.indices)[i + 1];
int num3 = ((Il2CppArrayBase<int>)(object)val.indices)[i + 2];
Vector3 p = ((Il2CppArrayBase<Vector3>)(object)val.vertices)[num];
Vector3 p2 = ((Il2CppArrayBase<Vector3>)(object)val.vertices)[num2];
Vector3 p3 = ((Il2CppArrayBase<Vector3>)(object)val.vertices)[num3];
CalcTriangleProps(p, p2, p3, out var center, out var heightDifference);
Dimension dimensionFromPos = Dimension.GetDimensionFromPos(center);
if (dimensionFromPos != null)
{
float voxelSearchTolerance = Mathf.Max(1.5f, heightDifference * 1.5f);
if (IsPositionValid(dimensionFromPos.DimensionIndex, center, voxelSearchTolerance, out var _))
{
list.Add(num);
list.Add(num2);
list.Add(num3);
}
}
}
int num4 = Mathf.Max(((Il2CppArrayBase<Vector3>)(object)val.vertices).Length, list.Count);
val2.indexFormat = (IndexFormat)(num4 >= 65534);
val2.SetVertices(val.vertices);
if (flipMesh)
{
list.Reverse();
}
val2.SetTriangles(Il2CppStructArray<int>.op_Implicit(list.ToArray()), 0);
val2.RecalculateNormals();
return val2;
}
private void CalcTriangleProps(Vector3 p1, Vector3 p2, Vector3 p3, out Vector3 center, out float heightDifference)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//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_000b: 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_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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)
//IL_004e: 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_0060: Unknown result type (might be due to invalid IL or missing references)
center = (p1 + p2 + p3) * 0.333333f;
float num = Mathf.Min(new float[3] { p1.y, p2.y, p3.y });
float num2 = Mathf.Max(new float[3] { p1.y, p2.y, p3.y });
heightDifference = num2 - num;
}
private bool IsPositionValid(eDimensionIndex dimensionIndex, Vector3 position, float voxelSearchTolerance, out AIG_CourseNode courseNode)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: 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_003f: Unknown result type (might be due to invalid IL or missing references)
AIG_GeomorphNodeVolume val = default(AIG_GeomorphNodeVolume);
if (!AIG_GeomorphNodeVolume.TryGetGeomorphVolume(0, dimensionIndex, position, ref val))
{
courseNode = null;
return false;
}
AIG_VoxelNodePillar val2 = default(AIG_VoxelNodePillar);
if (!((AIG_NodeVolume)val).m_voxelNodeVolume.TryGetPillar(position, ref val2))
{
courseNode = null;
return false;
}
float y = position.y;
AIG_INode val3 = default(AIG_INode);
if (!val2.TryGetVoxelNode(y - voxelSearchTolerance, y + voxelSearchTolerance, ref val3))
{
courseNode = null;
return false;
}
AIG_NodeCluster val4 = default(AIG_NodeCluster);
if (!AIG_NodeCluster.TryGetNodeCluster(val3.ClusterID, ref val4))
{
courseNode = null;
return false;
}
courseNode = val4.CourseNode;
return true;
}
public override bool Unload()
{
_Harmony.UnpatchSelf();
return ((BasePlugin)this).Unload();
}
}
[HarmonyPatch(typeof(CM_MapGUIItemBase), "PlaceInGUI")]
internal static class Inject_CM_MapGUIItemBase
{
[HarmonyPatch(new Type[]
{
typeof(Vector3),
typeof(Vector3),
typeof(Vector3),
typeof(bool)
})]
private static void Prefix(ref bool adjustUpSideDown)
{
adjustUpSideDown = true;
}
}
internal static class Logger
{
private static readonly ManualLogSource _Logger;
static Logger()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
_Logger = new ManualLogSource("BetterMaps");
Logger.Sources.Add((ILogSource)(object)_Logger);
}
private static string Format(object msg)
{
return msg.ToString();
}
public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
{
_Logger.LogInfo(handler);
}
public static void Info(string str)
{
_Logger.LogMessage((object)str);
}
public static void Info(object data)
{
_Logger.LogMessage((object)Format(data));
}
public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
{
_Logger.LogDebug(handler);
}
public static void Debug(string str)
{
_Logger.LogDebug((object)str);
}
public static void Debug(object data)
{
_Logger.LogDebug((object)Format(data));
}
public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
{
_Logger.LogError(handler);
}
public static void Error(string str)
{
_Logger.LogError((object)str);
}
public static void Error(object data)
{
_Logger.LogError((object)Format(data));
}
public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
{
_Logger.LogFatal(handler);
}
public static void Fatal(string str)
{
_Logger.LogFatal((object)str);
}
public static void Fatal(object data)
{
_Logger.LogFatal((object)Format(data));
}
public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
{
_Logger.LogWarning(handler);
}
public static void Warn(string str)
{
_Logger.LogWarning((object)str);
}
public static void Warn(object data)
{
_Logger.LogWarning((object)Format(data));
}
[Conditional("DEBUG")]
public static void DebugOnly(object data)
{
_Logger.LogDebug((object)Format(data));
}
}
[GeneratedCode("VersionInfoGenerator", "2.1.3+git35c0c2a-master")]
[CompilerGenerated]
internal static class VersionInfo
{
public const string RootNamespace = "BetterMaps";
public const string Version = "1.0.0";
public const string VersionPrerelease = null;
public const string VersionMetadata = null;
public const string SemVer = "1.0.0";
public const string GitRevShort = null;
public const string GitRevLong = null;
public const string GitBranch = null;
public const string GitTag = null;
public const int GitCommitsSinceTag = 0;
public const bool GitIsDirty = false;
}
}