Decompiled source of NomapPrinter v1.1.7
NomapPrinter.dll
Decompiled 10 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: Guid("ba601320-0ece-4b27-b2a4-a1fe1ba817b3")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyProduct("NomapPrinter")] [assembly: AssemblyCompany("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("NomapPrinter")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] public class MapImageGeneration { private static Color32[] m_mapTexture; private static Color[] m_forestTexture; private static Color32[] m_heightmap; private static bool[] m_exploration; private static bool[] m_mapData; private static int m_textureSize; private static int mapSizeFactor; private static Color32[] space; private static int spaceRes; private Color32[] result; public Color32[] output; public static readonly Color32 yellowMap = new Color32((byte)203, (byte)155, (byte)87, byte.MaxValue); public static readonly Color32 m_oceanColor = new Color32((byte)20, (byte)100, byte.MaxValue, byte.MaxValue); public static void Initialize(Color32[] biomes, Color[] forests, Color32[] height, bool[] exploration, int texture_size, bool[] mapData) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) m_mapTexture = biomes; m_forestTexture = forests; m_heightmap = height; m_exploration = exploration; m_textureSize = texture_size; m_mapData = mapData; mapSizeFactor = m_textureSize / Minimap.instance.m_textureSize; if (spaceRes == 0) { Texture texture = ((Graphic)Minimap.instance.m_mapImageLarge).material.GetTexture("_SpaceTex"); spaceRes = texture.width; RenderTexture temporary = RenderTexture.GetTemporary(spaceRes, spaceRes, 24); Graphics.Blit(texture, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(spaceRes, spaceRes, (TextureFormat)4, false, false); val.ReadPixels(new Rect(0f, 0f, (float)spaceRes, (float)spaceRes), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); space = val.GetPixels32(); Object.Destroy((Object)(object)val); } } public static void DeInitialize() { m_mapTexture = null; m_forestTexture = null; m_heightmap = null; m_exploration = null; m_mapData = null; } public IEnumerator GenerateOldMap(int graduationHeight) { output = null; yield return GenerateOceanTexture(m_heightmap, m_mapTexture, 0.25f); Color32[] oceanTexture = result; yield return ReplaceAbyssWithColor(m_mapTexture, new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue), yellowMap); Color32[] outtex9 = result; yield return OverlayTexture(outtex9, oceanTexture); outtex9 = result; yield return GetSolidColour(yellowMap); Color32[] offYellow = result; yield return LerpTextures(outtex9, offYellow); outtex9 = result; yield return LerpTextures(outtex9, offYellow); outtex9 = result; yield return LerpTextures(outtex9, offYellow); outtex9 = result; yield return AddPerlinNoise(outtex9, 128, 16); outtex9 = result; yield return ApplyForestMaskTexture(outtex9, m_forestTexture, 0.95f); outtex9 = result; yield return GenerateContourMap(m_heightmap, graduationHeight, 128); Color32[] contours = result; yield return OverlayTexture(outtex9, contours); outtex9 = result; yield return StylizeFog(m_exploration); Color32[] fog = result; yield return OverlayTexture(outtex9, fog, allMap: true); outtex9 = result; output = outtex9; } public IEnumerator GenerateChartMap(int graduationHeight) { output = null; yield return GenerateOceanTexture(m_heightmap, m_mapTexture, 0.15f); Color32[] oceanTexture = result; yield return ReplaceAbyssWithColor(m_mapTexture, new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue), yellowMap); Color32[] outtex7 = result; yield return OverlayTexture(outtex7, oceanTexture); outtex7 = result; yield return GetSolidColour(yellowMap); Color32[] offYellow = result; yield return LerpTextures(outtex7, offYellow); outtex7 = result; yield return AddPerlinNoise(outtex7, 128, 16); outtex7 = result; yield return ApplyForestMaskTexture(outtex7, m_forestTexture); outtex7 = result; yield return GenerateContourMap(m_heightmap, graduationHeight, 128); Color32[] contours = result; yield return OverlayTexture(outtex7, contours); outtex7 = result; yield return StylizeFog(m_exploration); Color32[] fog = result; yield return OverlayTexture(outtex7, fog, allMap: true); outtex7 = result; output = outtex7; } public IEnumerator GenerateSatelliteImage() { output = null; yield return GenerateOceanTexture(m_heightmap, m_mapTexture); Color32[] oceanTexture2 = result; yield return AddPerlinNoise(oceanTexture2, 4, 64); oceanTexture2 = result; yield return ReplaceAbyssWithSpace(m_mapTexture, new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue)); Color32[] outtex7 = result; yield return OverlayTexture(outtex7, oceanTexture2); outtex7 = result; yield return CreateShadowMap(m_heightmap, 23); Color32[] shadowmap = result; yield return DarkenTextureLinear(outtex7, 20); outtex7 = result; yield return ApplyForestMaskTexture(outtex7, m_forestTexture); outtex7 = result; yield return GenerateContourMap(m_heightmap, 128, 64); Color32[] contours = result; yield return OverlayTexture(outtex7, contours); outtex7 = result; yield return OverlayTexture(outtex7, shadowmap); outtex7 = result; yield return StylizeFog(m_exploration); Color32[] fog = result; yield return OverlayTexture(outtex7, fog, allMap: true); outtex7 = result; output = outtex7; } public IEnumerator GenerateTopographicalMap(int graduationHeight) { output = null; yield return GenerateOceanTexture(m_heightmap, m_mapTexture); Color32[] oceanTexture2 = result; yield return AddPerlinNoise(oceanTexture2, 4, 64); oceanTexture2 = result; yield return ReplaceAbyssWithSpace(m_mapTexture, new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue)); Color32[] outtex7 = result; yield return OverlayTexture(outtex7, oceanTexture2); outtex7 = result; yield return CreateShadowMap(m_heightmap, 23); Color32[] shadowmap = result; yield return DarkenTextureLinear(outtex7, 20); outtex7 = result; yield return ApplyForestMaskTexture(outtex7, m_forestTexture); outtex7 = result; yield return GenerateContourMap(m_heightmap, graduationHeight, 128); Color32[] contours = result; yield return OverlayTexture(outtex7, contours); outtex7 = result; yield return OverlayTexture(outtex7, shadowmap); outtex7 = result; yield return StylizeFog(m_exploration); Color32[] fog = result; yield return OverlayTexture(outtex7, fog, allMap: true); outtex7 = result; output = outtex7; } private IEnumerator OverlayTexture(Color32[] array1, Color32[] array2, bool allMap = false) { Color32[] output = (Color32[])(object)new Color32[m_textureSize * m_textureSize]; Color workingColor; Thread internalThread = new Thread((ThreadStart)delegate { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_textureSize * m_textureSize; i++) { if (allMap || m_mapData[i]) { float a = Color32.op_Implicit(array2[i]).a; float a2 = Color32.op_Implicit(array1[i]).a; workingColor = Color.Lerp(Color32.op_Implicit(array1[i]), Color32.op_Implicit(array2[i]), a); workingColor.a = a + a2; if (workingColor.a > 1f) { workingColor.a = 1f; } output[i] = Color32.op_Implicit(workingColor); } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = output; } private IEnumerator LerpTextures(Color32[] array1, Color32[] array2) { Color32[] output = (Color32[])(object)new Color32[m_textureSize * m_textureSize]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_textureSize * m_textureSize; i++) { if (m_mapData[i]) { int num = array2[i].a - array1[i].a; int num2 = Math.Min(array1[i].a + array2[i].a, 255); int num3 = ((array1[i].a > array2[i].a) ? array1[i].a : array2[i].a) * 2; float num4 = (float)num / (float)num3 + 0.5f; output[i] = Color32.Lerp(array1[i], array2[i], num4); output[i].a = (byte)num2; } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = output; } private IEnumerator DarkenTextureLinear(Color32[] array, byte d) { Color32[] output = (Color32[])(object)new Color32[m_textureSize * m_textureSize]; Thread internalThread = new Thread((ThreadStart)delegate { for (int i = 0; i < m_textureSize * m_textureSize; i++) { if (m_mapData[i]) { int num = array[i].r - d; if (num < 0) { num = 0; } output[i].r = (byte)num; num = array[i].g - d; if (num < 0) { num = 0; } output[i].g = (byte)num; num = array[i].b - d; if (num < 0) { num = 0; } output[i].b = (byte)num; output[i].a = array[i].a; } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = output; } private IEnumerator CreateShadowMap(Color32[] heightmap, byte intensity) { yield return CreateHardShadowMap(heightmap, intensity); Color32[] hardshadows = result; yield return CreateSoftShadowMap(heightmap); Color32[] softshadows = result; yield return LerpTextures(softshadows, hardshadows); } private IEnumerator CreateSoftShadowMap(Color32[] input) { Color32[] output = (Color32[])(object)new Color32[input.Length]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_textureSize; i++) { for (int j = 0; j < m_textureSize; j++) { int num = i * m_textureSize + j; if (m_mapData[num]) { int num2 = ((i > 0) ? (input[num].r - input[(i - 1) * m_textureSize + j].r) : 0); num2 *= 8; byte b = (byte)Math.Abs(num2); byte b2 = (byte)((num2 >= 0) ? byte.MaxValue : 0); output[num] = new Color32(b2, b2, b2, b); } } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = output; } private IEnumerator CreateHardShadowMap(Color32[] input, byte intensity) { Color32[] output = (Color32[])(object)new Color32[input.Length]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) bool[] array = new bool[m_textureSize * m_textureSize]; for (int i = 0; i < m_textureSize * m_textureSize; i++) { array[i] = false; } for (int j = 0; j < m_textureSize; j++) { for (int k = 0; k < m_textureSize; k++) { int num = j * m_textureSize + k; if (m_mapData[num]) { if (!array[num]) { output[num] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)0); for (int l = 1; j + l < m_textureSize && input[num].r > input[(j + l) * m_textureSize + k].r + l * 2; l++) { array[(j + l) * m_textureSize + k] = true; } } else { output[num] = new Color32((byte)0, (byte)0, (byte)0, intensity); } } } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = output; } private IEnumerator GenerateOceanTexture(Color32[] input, Color32[] biomeColor, float oceanLerpTarget = 0.1f) { Color32[] output = (Color32[])(object)new Color32[input.Length]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_textureSize * m_textureSize; i++) { if (m_mapData[i]) { if (input[i].b == 0) { output[i] = Color32.op_Implicit(Color.clear); } else { int num = i / m_textureSize / (8 * mapSizeFactor) - 128; int num2 = i % m_textureSize / (8 * mapSizeFactor) - 128; int num3 = num * num / 128 + num2 * num2 / 512; if (num < 0) { output[i].r = (byte)(10 + num3); output[i].g = (byte)(136 - num3 / 4); output[i].b = 193; } else { output[i].r = (byte)(10 + num3 / 2); output[i].g = 136; output[i].b = (byte)(193 - num3 / 2); } output[i].a = (byte)Math.Min(input[i].b * 16 + 128, 255); if (Color32.op_Implicit(biomeColor[i]) == Color.blue) { output[i] = Color32.Lerp(output[i], m_oceanColor, oceanLerpTarget); } } } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = output; } private IEnumerator GetPerlin(int tightness, byte damping) { Color32[] array = (Color32[])(object)new Color32[m_textureSize * m_textureSize]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_textureSize; i++) { for (int j = 0; j < m_textureSize; j++) { float num = Mathf.PerlinNoise((float)i / (float)tightness, (float)j / (float)tightness); num = (num - 0.5f) / (float)(int)damping + 0.5f; array[i * m_textureSize + j] = Color32.op_Implicit(new Color(num, num, num, 0.2f)); } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = array; } private IEnumerator StylizeFog(bool[] exploration) { yield return GetPerlin(128, 16); Color32[] noise = result; Color32[] output = (Color32[])(object)new Color32[m_textureSize * m_textureSize]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_textureSize * m_textureSize; i++) { if (!exploration[i]) { output[i] = new Color32((byte)(203 + (noise[i].r - 128)), (byte)(155 + (noise[i].g - 128)), (byte)(87 + (noise[i].b - 128)), byte.MaxValue); } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = output; } private IEnumerator GenerateContourMap(Color32[] start, int graduations, byte alpha) { Color32[] input = (Color32[])(object)new Color32[start.Length]; Color32[] output = (Color32[])(object)new Color32[input.Length]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: 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_019a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_textureSize * m_textureSize; i++) { int num = ((start[i].b <= 0) ? Math.Min(start[i].r + graduations, 255) : 0); input[i].r = (byte)num; } for (int j = 1; j < m_textureSize - 1; j++) { int num2 = j * m_textureSize; for (int k = 1; k < m_textureSize - 1; k++) { int num3 = num2 + k; int num4 = input[num2 + k].r / graduations; output[num3] = Color32.op_Implicit(Color.clear); if (m_mapData[num3]) { for (int l = -1; l < 2; l++) { int num5 = l * m_textureSize; for (int m = -1; m < 2; m++) { if (l != 0 || m != 0) { int num6 = num3 + num5 + m; int num7 = input[num6].r / graduations; if (num7 < num4) { byte b = alpha; if (num4 % 5 - 1 != 0) { b /= 2; } if (l == 0 || m == 0 || output[num3].a == b) { output[num3] = new Color32((byte)0, (byte)0, (byte)0, b); break; } output[num3] = new Color32((byte)0, (byte)0, (byte)0, (byte)(b / 2)); } } } } } } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = output; } private IEnumerator AddPerlinNoise(Color32[] input, int tightness, byte damping) { Color32[] array = (Color32[])(object)new Color32[m_textureSize * m_textureSize]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_0034: 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_003e: 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_007c: 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_008e: 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) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_textureSize; i++) { for (int j = 0; j < m_textureSize; j++) { int num = i * m_textureSize + j; if (m_mapData[num]) { Color val = Color32.op_Implicit(input[num]); float num2 = Mathf.PerlinNoise((float)i / (float)tightness, (float)j / (float)tightness); num2 = (num2 - 0.5f) / (float)(int)damping; array[num] = Color32.op_Implicit(new Color(val.r + num2, val.g + num2, val.b + num2, val.a)); } } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = array; } private IEnumerator GetSolidColour(Color32 TexColour) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[m_textureSize * m_textureSize]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < array.Length; i++) { if (m_mapData[i]) { array[i] = TexColour; } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = array; } private IEnumerator ReplaceAbyssWithColor(Color32[] input, Color32 from, Color32 to) { //IL_0015: 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) //IL_001c: 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) Color32[] output = (Color32[])(object)new Color32[input.Length]; Thread internalThread = new Thread((ThreadStart)delegate { //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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < input.Length; i++) { if (!m_mapData[i]) { output[i] = to; } else if (input[i].r == from.r && input[i].g == from.g && input[i].b == from.b) { output[i] = to; } else { output[i] = input[i]; } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = output; } private IEnumerator ReplaceAbyssWithSpace(Color32[] input, Color32 from) { //IL_0015: 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) Color32[] output = (Color32[])(object)new Color32[input.Length]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_004a: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_textureSize; i++) { for (int j = 0; j < m_textureSize; j++) { int num = i * m_textureSize + j; if (!m_mapData[num]) { output[num] = space[i % spaceRes * spaceRes + j % spaceRes]; } else if (input[num].r == from.r && input[num].g == from.g && input[num].b == from.b) { output[num] = space[i % spaceRes * spaceRes + j % spaceRes]; } else { output[num] = input[num]; } } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = output; } private IEnumerator ApplyForestMaskTexture(Color32[] array, Color[] forestMask, float forestColorFactor = 0.9f) { Color32[] output = (Color32[])(object)new Color32[m_textureSize * m_textureSize]; Thread internalThread = new Thread((ThreadStart)delegate { //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) for (int i = 0; i < m_textureSize * m_textureSize; i++) { if (m_mapData[i]) { if (forestMask[i].r == 0f) { output[i] = array[i]; } else { float num = 1f - (1f - forestColorFactor) * forestMask[i].r; if (forestMask[i].g > 0f) { output[i].g = (byte)(array[i].g + (byte)(forestMask[i].g * forestMask[i].b * 255f)); } output[i].r = (byte)((float)(int)array[i].r * num); output[i].g = (byte)((float)(int)array[i].g * num); output[i].b = (byte)((float)(int)array[i].b * num); output[i].a = array[i].a; } } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } result = output; } } namespace NomapPrinter { [BepInPlugin("shudnal.NomapPrinter", "Nomap Printer", "1.1.7")] public class NomapPrinter : BaseUnityPlugin { public enum MapType { BirdsEye, Topographical, Chart, OldChart, Vanilla } public enum MapSize { Small = 1, Normal = 2, Smooth = 4 } public enum MapStorage { Character, LocalFolder, LoadFromSharedFile } public enum MapWindow { Hide, ShowEverywhere, ShowNearTheTable, ShowOnInteraction } [HarmonyPatch(typeof(Player), "Save")] public static class Player_Save_SaveMapData { public static bool Prefix(Player __instance) { SaveMapToPlayer(__instance); return true; } } [HarmonyPatch(typeof(Player), "Load")] public static class Player_Load_LoadMapData { public static void Postfix(Player __instance) { if (LoadMapFromPlayer(__instance)) { ResetViewerContentSize(); mapTextureIsReady = true; } } } [HarmonyPatch(typeof(Hud), "Awake")] private class Hud_Awake_AddIngameView { private static void Postfix(Hud __instance) { if (modEnabled.Value && !Object.op_Implicit((Object)(object)GameObject.Find("NomapPrinter_Parent"))) { AddIngameView(__instance.m_rootObject.transform); } } } [HarmonyPatch(typeof(WorldGenerator), "Initialize")] public static class WorldGenerator_Initialize_Patch { public static void Postfix(World world) { game_world = world; saveFieldKey = "NomapPrinter_MapTexture_" + world.m_name; } } [HarmonyPriority(0)] [HarmonyPatch(typeof(MapTable), "OnRead")] public static class MapTable_OnRead_ReadDiscoveriesInteraction { private static void Postfix(MapTable __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!modEnabled.Value || !PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, true, false)) { return; } if (mapWindow.Value == MapWindow.ShowOnInteraction) { if (!mapTextureIsReady) { ShowMessage(messageNotReady.Value, (MessageType)2); } else { instance.DisplayingWindow = true; } } else if (tablePartsSwap.Value) { ShowInteractiveMap(); } else { GenerateMap(); } } } [HarmonyPatch(typeof(MapTable), "OnWrite")] [HarmonyPriority(0)] public static class MapTable_OnWrite_RecordDiscoveriesInteraction { private static void Postfix(MapTable __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (modEnabled.Value && PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, true, false)) { if (tablePartsSwap.Value || mapWindow.Value == MapWindow.ShowOnInteraction) { GenerateMap(); } else { ShowInteractiveMap(); } } } } [HarmonyPatch(typeof(Minimap), "IsOpen")] [HarmonyPriority(0)] public static class Minimap_IsOpen_EmulateMinimapOpenStatus { private static void Postfix(ref bool __result) { if (modEnabled.Value) { __result = __result || instance.DisplayingWindow; } } } [HarmonyPatch(typeof(Minimap), "ShowPinNameInput")] [HarmonyPriority(0)] public static class Minimap_ShowPinNameInput_PreventPinAddition { private static bool Prefix() { if (!modEnabled.Value) { return true; } return !allowInteractiveMapOnWrite.Value || !preventPinAddition.Value; } } private class MapGeneration : MonoBehaviour { public bool working = false; private static Texture2D iconSpriteTexture; private static readonly List<KeyValuePair<Vector3, string>> pinsToPrint = new List<KeyValuePair<Vector3, string>>(); private static int iconSize = 16; private static int textureSize; private static Texture2D noClouds; public IEnumerator Go() { working = true; if (mapType.Value != MapType.Vanilla) { ShowMessage(messageStart.Value, (MessageType)2); yield return PrepareTerrainData(); ShowMessage(messageSaving.Value, (MessageType)2); MapImageGeneration.Initialize(m_mapTexture, m_forestTexture, m_heightmap, m_exploration, textureSize, m_mapData); MapImageGeneration imageGen = new MapImageGeneration(); switch (mapType.Value) { case MapType.BirdsEye: yield return imageGen.GenerateSatelliteImage(); break; case MapType.Topographical: yield return imageGen.GenerateTopographicalMap(graduationLinesDensity.Value); break; default: yield return imageGen.GenerateChartMap(graduationLinesDensity.Value); break; case MapType.OldChart: yield return imageGen.GenerateOldMap(graduationLinesDensity.Value); break; } ApplyMapTexture(mapType.Value, imageGen.output); } else { ShowMessage(messageSaving.Value, (MessageType)2); yield return GetVanillaMap(2048 * (int)mapSize.Value); } if (saveMapToFile.Value) { string filename = filePath.Value; if (Utility.IsNullOrWhiteSpace(filename)) { filename = Path.Combine(localPath, "screenshots", $"{mapType.Value}.{game_world.m_name}.png"); } else { FileAttributes attr = File.GetAttributes(filename); if (attr.HasFlag(FileAttributes.Directory)) { filename = Path.Combine(filename, $"{mapType.Value}.{game_world.m_name}.png"); } } string filepath = Path.GetDirectoryName(filename); Thread internalThread = new Thread((ThreadStart)delegate { try { Directory.CreateDirectory(filepath); Log("Writing " + filename); File.WriteAllBytes(filename, ImageConversion.EncodeToPNG(mapTexture)); } catch (Exception message) { Log(message); } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } ShowMessage(messageSavedTo.Value + " " + filepath, (MessageType)1); } Log("Finished Map Draw"); ShowMessage(messageReady.Value, (MessageType)2); MapImageGeneration.DeInitialize(); m_mapTexture = null; m_forestTexture = null; m_heightmap = null; m_exploration = null; m_mapData = null; working = false; } private IEnumerator PrepareTerrainData() { int mapSizeFactor = ((mapSize.Value != MapSize.Smooth) ? 1 : 2); float m_pixelSize = Minimap.instance.m_pixelSize / (float)mapSizeFactor; textureSize = Minimap.instance.m_textureSize * mapSizeFactor; int num = textureSize / 2; float num2 = m_pixelSize / 2f; Color32[] biomeColor = (Color32[])(object)new Color32[textureSize * textureSize]; Color[] forest = (Color[])(object)new Color[textureSize * textureSize]; Color32[] heightmap = (Color32[])(object)new Color32[textureSize * textureSize]; bool[] exploration = new bool[textureSize * textureSize]; bool[] mapData = new bool[textureSize * textureSize]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Invalid comparison between Unknown and I4 //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < textureSize; i++) { for (int j = 0; j < textureSize; j++) { int num3 = i * textureSize + j; exploration[num3] = IsExplored(j / mapSizeFactor, i / mapSizeFactor); if (exploration[num3]) { for (int k = -2 * mapSizeFactor; k <= 2 * mapSizeFactor; k++) { for (int l = -2 * mapSizeFactor; l <= 2 * mapSizeFactor; l++) { if (i + k >= 0 && j + l >= 0 && i + k < textureSize && j + l < textureSize) { mapData[(i + k) * textureSize + j + l] = true; } } } } } } Color mask = default(Color); for (int m = 0; m < textureSize; m++) { float num4 = (float)(m - num) * m_pixelSize + num2; for (int n = 0; n < textureSize; n++) { float num5 = (float)(n - num) * m_pixelSize + num2; int num6 = m * textureSize + n; if (mapData[num6]) { Biome biome = WorldGenerator.instance.GetBiome(num5, num4); float biomeHeight = WorldGenerator.instance.GetBiomeHeight(biome, num5, num4, ref mask, false); float num7 = biomeHeight - ZoneSystem.instance.m_waterLevel; forest[num6] = GetMaskColor(num5, num4, num7, biome, mask); if (biomeHeight < abyss_depth) { biomeColor[num6] = Color32.op_Implicit(Color.black); } else { if (num7 > 0f) { heightmap[num6] = Color32.op_Implicit(new Color(num7 / Mathf.Pow(2f, (float)(heightmapFactor.Value + 1)), 0f, 0f)); } else { heightmap[num6] = Color32.op_Implicit(new Color(0f, 0f, num7 / (0f - Mathf.Pow(2f, (float)(heightmapFactor.Value + (((int)biome == 2) ? 1 : 0)))))); } biomeColor[num6] = Color32.op_Implicit(GetPixelColor(biome, biomeHeight)); } } } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } m_mapTexture = biomeColor; m_forestTexture = forest; m_heightmap = heightmap; m_exploration = exploration; m_mapData = mapData; } private static IEnumerator GetVanillaMap(int resolution) { bool wasOpen = Minimap.instance.m_largeRoot.activeSelf; if (!wasOpen) { bool nomap = Game.m_noMap; if (nomap) { Game.m_noMap = false; } Minimap.instance.inputDelay = 0.5f; Minimap.instance.SetMapMode((MapMode)2); Minimap.instance.CenterMap(Vector3.zero); if (nomap) { Game.m_noMap = true; } } if ((Object)(object)noClouds == (Object)null) { noClouds = new Texture2D(1, 1); noClouds.SetPixels((Color[])(object)new Color[1] { Color.clear }); noClouds.Apply(false); } Material material = Minimap.instance.m_mapLargeShader; Texture clouds = material.GetTexture("_CloudTex"); material.SetTexture("_CloudTex", (Texture)(object)noClouds); bool m_showSharedMapData = Minimap.instance.m_showSharedMapData; bool replaceSharedMapToggle = showSharedMap.Value != Minimap.instance.m_showSharedMapData; if (replaceSharedMapToggle) { material.SetFloat("_SharedFade", showSharedMap.Value ? 1f : 0f); } Color[] fogTex = Minimap.instance.m_fogTexture.GetPixels(); bool combineFog = !preserveSharedMapFog.Value && showSharedMap.Value; if (combineFog) { Color[] pixels = Minimap.instance.m_fogTexture.GetPixels(); for (int i = 0; i < pixels.Length; i++) { if (pixels[i].g == 0f && pixels[i].r != 0f) { pixels[i].r = pixels[i].g; } } Minimap.instance.m_fogTexture.SetPixels(pixels); Minimap.instance.m_fogTexture.Apply(); } GameObject mapPanelObject = InitMapPanel(material); RenderTexture renderTexture = new RenderTexture(resolution, resolution, 24); GameObject cameraObject = new GameObject { layer = 19 }; Camera camera = cameraObject.AddComponent<Camera>(); camera.targetTexture = renderTexture; camera.orthographic = true; camera.rect = new Rect(0f, 0f, (float)resolution, (float)resolution); camera.nearClipPlane = 0f; camera.farClipPlane = 100f; camera.orthographicSize = 50f; camera.cullingMask = 524288; camera.Render(); EnvSetup env = EnvMan.instance.GetCurrentEnvironment(); float m_sunAngle = env.m_sunAngle; float m_smoothDayFraction = EnvMan.instance.m_smoothDayFraction; Vector3 m_dirLight = ((Component)EnvMan.instance.m_dirLight).transform.forward; EnvMan.instance.m_smoothDayFraction = 0.5f; env.m_sunAngle = 60f; EnvMan.instance.SetEnv(env, 1f, 0f, 0f, 0f, 0f); ((Component)EnvMan.instance.m_dirLight).transform.forward = Vector3.down; yield return (object)new WaitForEndOfFrame(); EnvMan.instance.m_smoothDayFraction = 0.5f; env.m_sunAngle = 60f; EnvMan.instance.SetEnv(env, 1f, 0f, 0f, 0f, Time.fixedDeltaTime); RenderTexture.active = renderTexture; mapTexture.Reinitialize(resolution, resolution, (TextureFormat)3, false); mapTexture.ReadPixels(new Rect(0f, 0f, (float)resolution, (float)resolution), 0, 0); if (showPins.Value) { Color32[] map = mapTexture.GetPixels32(); GetPinsToPrint(); AddPinsOnMap(map, resolution); mapTexture.SetPixels32(map); } mapTexture.Apply(); ResetViewerContentSize(); RenderTexture.active = null; Object.Destroy((Object)(object)mapPanelObject); Object.Destroy((Object)(object)cameraObject); Object.Destroy((Object)(object)renderTexture); material.SetTexture("_CloudTex", clouds); EnvMan.instance.m_smoothDayFraction = m_smoothDayFraction; env.m_sunAngle = m_sunAngle; ((Component)EnvMan.instance.m_dirLight).transform.forward = m_dirLight; if (replaceSharedMapToggle) { material.SetFloat("_SharedFade", m_showSharedMapData ? 1f : 0f); } if (combineFog) { Minimap.instance.m_fogTexture.SetPixels(fogTex); Minimap.instance.m_fogTexture.Apply(); } if (!wasOpen) { Minimap.instance.SetMapMode((MapMode)1); } } private static GameObject InitMapPanel(Material material) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown Vector3[] vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-50f, -50f, 10f), new Vector3(50f, -50f, 10f), new Vector3(-50f, 50f, 10f), new Vector3(50f, 50f, 10f) }; int[] triangles = new int[6] { 0, 2, 1, 2, 3, 1 }; Vector3[] normals = (Vector3[])(object)new Vector3[4] { -Vector3.forward, -Vector3.forward, -Vector3.forward, -Vector3.forward }; Vector2[] uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 1f), new Vector2(1f, 1f) }; GameObject val = new GameObject(); MeshRenderer val2 = val.AddComponent<MeshRenderer>(); ((Renderer)val2).sharedMaterial = material; MeshFilter val3 = val.AddComponent<MeshFilter>(); val3.mesh = new Mesh { vertices = vertices, triangles = triangles, normals = normals, uv = uv }; val.layer = 19; return val; } private static void ApplyMapTexture(MapType mapType, Color32[] map) { DoubleMapSize(ref map, out var mapSize); if (NomapPrinter.mapSize.Value == MapSize.Normal) { DoubleMapSize(ref map, out mapSize); } if (showPins.Value) { GetPinsToPrint(); AddPinsOnMap(map, mapSize); } mapTexture.Reinitialize(mapSize, mapSize, (TextureFormat)3, false); mapTexture.SetPixels32(map); mapTexture.Apply(); ResetViewerContentSize(); mapTextureIsReady = true; } private static void DoubleMapSize(ref Color32[] map, out int mapSize) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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) int num = (int)Math.Sqrt(map.Length); mapSize = num * 2; Color32[] array = (Color32[])(object)new Color32[mapSize * mapSize]; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { Color32 val = map[i * num + j]; array[i * 2 * mapSize + j * 2] = val; array[i * 2 * mapSize + j * 2 + 1] = val; array[(i * 2 + 1) * mapSize + j * 2] = val; array[(i * 2 + 1) * mapSize + j * 2 + 1] = val; } } map = array; } private static Color GetPixelColor(Biome biome, float height) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected I4, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Invalid comparison between Unknown and I4 //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Invalid comparison between Unknown and I4 //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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if (height < abyss_depth) { return Color.black; } if ((int)biome <= 16) { switch (biome - 1) { default: if ((int)biome != 8) { if ((int)biome != 16) { break; } return Minimap.instance.m_heathColor; } return Minimap.instance.m_blackforestColor; case 0: return Minimap.instance.m_meadowsColor; case 1: return Minimap.instance.m_swampColor; case 3: return Minimap.instance.m_mountainColor; case 2: break; } } else if ((int)biome <= 64) { if ((int)biome == 32) { return Minimap.instance.m_ashlandsColor; } if ((int)biome == 64) { return new Color(0.85f, 0.85f, 1f); } } else { if ((int)biome == 256) { return Color.blue; } if ((int)biome == 512) { return new Color(0.3f, 0.2f, 0.3f); } } return Color.black; } private static Color GetMaskColor(float wx, float wy, float height, Biome biome, Color mask) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Invalid comparison between Unknown and I4 //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_0092: Invalid comparison between Unknown and I4 //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_007c: Invalid comparison between Unknown and I4 //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); ((Color)(ref val))..ctor(0f, 0f, 0f, 0f); Color val2 = default(Color); ((Color)(ref val2))..ctor(1f, 0f, 0f, 0f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.75f, 0f, 0f, 0f); if (height < 0f) { return val; } if ((int)biome <= 8) { if ((int)biome == 1) { return (!WorldGenerator.InForest(new Vector3(wx, 0f, wy))) ? val : val2; } if ((int)biome == 8) { return (mapType.Value == MapType.OldChart) ? val2 : val3; } } else { if ((int)biome == 16) { return (!(WorldGenerator.GetForestFactor(new Vector3(wx, 0f, wy)) < 0.8f)) ? val : val2; } if ((int)biome == 512) { float forestFactor = WorldGenerator.GetForestFactor(new Vector3(wx, 0f, wy)); return new Color(0.5f + 0.5f * mask.a, 1f - Utils.SmoothStep(1.1f, 1.3f, forestFactor), 0.04f, 0f); } } return val; } private static void AddPinsOnMap(Color32[] map, int mapSize) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); foreach (KeyValuePair<Vector3, string> item in pinsToPrint) { Minimap.instance.WorldToMapPoint(item.Key, ref num, ref num2); if (num >= 1f || num2 >= 1f || num <= 0f || num2 <= 0f) { continue; } Color32[] array = pinIcons[item.Value]; if (array == null) { continue; } int num3 = Math.Max((int)(num * (float)mapSize) - iconSize / 2, 0); int num4 = Math.Max((int)(num2 * (float)mapSize) - iconSize / 2, 0); for (int i = 0; i < iconSize; i++) { for (int j = 0; j < iconSize; j++) { int num5 = (num4 + i) * mapSize + num3 + j; Color32 val = array[i * iconSize + j]; if (mapType.Value == MapType.Chart || mapType.Value == MapType.OldChart) { val = Color32.Lerp(val, MapImageGeneration.yellowMap, 0.33f * (float)(int)val.a / 255f); } map[num5] = Color32.Lerp(map[num5], val, (float)(int)val.a / 255f); map[num5].a = byte.MaxValue; } } } } private static bool IsExplored(int x, int y) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Color pixel = Minimap.instance.m_fogTexture.GetPixel(x, y); return pixel.r == 0f || (showSharedMap.Value && pixel.g == 0f); } private static void GetPinsToPrint() { //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) pinsToPrint.Clear(); if (!showPins.Value || (Object)(object)Minimap.instance == (Object)null) { return; } int x = default(int); int y = default(int); foreach (PinData pin in Minimap.instance.m_pins) { if (((Object)pin.m_icon).name != "mapicon_start" && !showEveryPin.Value) { if ((showNonCheckedPins.Value && pin.m_checked) || (showMyPins.Value && pin.m_ownerID != 0)) { continue; } if (showExploredPins.Value) { Minimap.instance.WorldToPixel(pin.m_pos, ref x, ref y); if (!IsExplored(x, y) && (!IsMerchantPin(((Object)pin.m_icon).name) || !showMerchantPins.Value)) { continue; } } } if (IsShowablePinIcon(pin)) { pinsToPrint.Add(new KeyValuePair<Vector3, string>(pin.m_pos, ((Object)pin.m_icon).name)); } } } private static bool IsIconConfiguredShowable(string pinIcon) { if (showEveryPin.Value) { return true; } return pinIcon switch { "mapicon_boss_colored" => showPinBoss.Value, "mapicon_fire" => showPinFire.Value, "mapicon_hammer" => showPinHammer.Value, "mapicon_hildir" => showPinHildir.Value, "mapicon_hildir1" => showPinHildirQuest.Value, "mapicon_hildir2" => showPinHildirQuest.Value, "mapicon_hildir3" => showPinHildirQuest.Value, "mapicon_house" => showPinHouse.Value, "mapicon_pin" => showPinPin.Value, "mapicon_portal" => showPinPortal.Value, "mapicon_start" => showPinStart.Value, "mapicon_trader" => showPinTrader.Value, "mapicon_bed" => showPinBed.Value, "mapicon_death" => showPinDeath.Value, "mapicon_eventarea" => showPinEpicLoot.Value, "MapIconBounty" => showPinEpicLoot.Value, "TreasureMapIcon" => showPinEpicLoot.Value, _ => false, }; } private static bool IsMerchantPin(string pinIcon) { return pinIcon switch { "mapicon_hildir" => true, "mapicon_hildir1" => true, "mapicon_hildir2" => true, "mapicon_hildir3" => true, "mapicon_trader" => true, "MapIconBounty" => showPinEpicLoot.Value, "TreasureMapIcon" => showPinEpicLoot.Value, "mapicon_eventarea" => showPinEpicLoot.Value, _ => false, }; } private static bool IsShowablePinIcon(PinData pin) { if ((Object)(object)pin.m_icon == (Object)null) { return false; } bool flag = IsIconConfiguredShowable(((Object)pin.m_icon).name); if (flag && !pinIcons.ContainsKey(((Object)pin.m_icon).name) && !AddPinIconToCache(pin.m_icon)) { return false; } return flag; } private static bool AddPinIconToCache(Sprite icon) { Color32[] iconPixels = GetIconPixels(icon, iconSize, iconSize); if (iconPixels == null || iconPixels.Length <= 1) { return false; } pinIcons.Add(((Object)icon).name, iconPixels); return true; } private static Color32[] GetIconPixels(Sprite icon, int targetX, int targetY) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) Texture2D textureFromSprite = GetTextureFromSprite(icon); if ((Object)(object)textureFromSprite == (Object)null) { return null; } RenderTexture temporary = RenderTexture.GetTemporary(targetX, targetY, 24); Graphics.Blit((Texture)(object)textureFromSprite, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(targetX, targetY, (TextureFormat)4, false, false); val.ReadPixels(new Rect(0f, 0f, (float)targetX, (float)targetY), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Color32[] pixels = val.GetPixels32(); Object.Destroy((Object)(object)val); return pixels; } private static Texture2D GetTextureFromSprite(Sprite sprite) { //IL_0042: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sprite.texture == (Object)null) { return null; } if (((Texture)sprite.texture).width == 0 || ((Texture)sprite.texture).height == 0) { return null; } Rect val = sprite.rect; if (((Rect)(ref val)).width != (float)((Texture)sprite.texture).width) { val = sprite.rect; int num = (int)((Rect)(ref val)).width; val = sprite.rect; int num2 = (int)((Rect)(ref val)).height; Texture2D val2 = new Texture2D(num, num2); Color[] pixels = Enumerable.Repeat<Color>(new Color(0f, 0f, 0f, 0f), num * num2).ToArray(); Texture2D obj = GetIconSpriteTexture(sprite.texture); val = sprite.textureRect; int num3 = (int)((Rect)(ref val)).x; val = sprite.textureRect; int num4 = (int)((Rect)(ref val)).y; val = sprite.textureRect; int num5 = (int)((Rect)(ref val)).width; val = sprite.textureRect; Color[] pixels2 = obj.GetPixels(num3, num4, num5, (int)((Rect)(ref val)).height); val2.SetPixels(pixels); int num6 = (int)sprite.textureRectOffset.x; int num7 = (int)sprite.textureRectOffset.y; val = sprite.textureRect; int num8 = (int)((Rect)(ref val)).width; val = sprite.textureRect; val2.SetPixels(num6, num7, num8, (int)((Rect)(ref val)).height, pixels2); val2.Apply(); return val2; } return GetReadableTexture(sprite.texture); } private static Texture2D GetIconSpriteTexture(Texture2D texture2D) { if ((Object)(object)iconSpriteTexture == (Object)null) { iconSpriteTexture = GetReadableTexture(texture2D); } return iconSpriteTexture; } private static Texture2D GetReadableTexture(Texture2D texture) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown RenderTexture temporary = RenderTexture.GetTemporary(((Texture)texture).width, ((Texture)texture).height, 24); Graphics.Blit((Texture)(object)texture, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(((Texture)texture).width, ((Texture)texture).height, (TextureFormat)4, false, false); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Texture2D val2 = new Texture2D(((Texture)texture).width, ((Texture)texture).height); val2.SetPixels(val.GetPixels()); val2.Apply(); return val2; } public static void InitIconSize() { int num = 32; if (mapSize.Value == MapSize.Small) { num = 16; } num = Mathf.CeilToInt((float)num * pinScale.Value); if (iconSize != num) { pinIcons.Clear(); iconSize = num; } } } public sealed class ValueChangedEventArgs<TValue> : EventArgs { public TValue NewValue { get; } public ValueChangedEventArgs(TValue newValue) { NewValue = newValue; } } private const string pluginID = "shudnal.NomapPrinter"; private const string pluginName = "Nomap Printer"; private const string pluginVersion = "1.1.7"; private readonly Harmony harmony = new Harmony("shudnal.NomapPrinter"); internal static readonly ConfigSync configSync = new ConfigSync("shudnal.NomapPrinter") { DisplayName = "Nomap Printer", CurrentVersion = "1.1.7", MinimumRequiredVersion = "1.1.7" }; private static ConfigEntry<bool> modEnabled; private static ConfigEntry<bool> configLocked; private static ConfigEntry<bool> loggingEnabled; private static ConfigEntry<bool> saveMapToFile; private static ConfigEntry<string> filePath; private static ConfigEntry<MapWindow> mapWindow; private static ConfigEntry<bool> allowInteractiveMapOnWrite; private static ConfigEntry<bool> showSharedMap; private static ConfigEntry<bool> preventPinAddition; private static ConfigEntry<float> showNearTheTableDistance; private static ConfigEntry<int> showMapBasePiecesRequirement; private static ConfigEntry<int> showMapComfortRequirement; private static ConfigEntry<MapStorage> mapStorage; private static ConfigEntry<string> localFolder; private static ConfigEntry<string> sharedFile; private static ConfigEntry<MapType> mapType; private static ConfigEntry<MapSize> mapSize; private static ConfigEntry<float> mapDefaultScale; private static ConfigEntry<float> mapMinimumScale; private static ConfigEntry<float> mapMaximumScale; private static ConfigEntry<int> heightmapFactor; private static ConfigEntry<int> graduationLinesDensity; private static ConfigEntry<float> pinScale; private static ConfigEntry<bool> preserveSharedMapFog; private static ConfigEntry<bool> showPins; private static ConfigEntry<bool> showExploredPins; private static ConfigEntry<bool> showMyPins; private static ConfigEntry<bool> showNonCheckedPins; private static ConfigEntry<bool> showMerchantPins; private static ConfigEntry<bool> showEveryPin; private static ConfigEntry<bool> showPinStart; private static ConfigEntry<bool> showPinTrader; private static ConfigEntry<bool> showPinHildir; private static ConfigEntry<bool> showPinHildirQuest; private static ConfigEntry<bool> showPinBoss; private static ConfigEntry<bool> showPinFire; private static ConfigEntry<bool> showPinHouse; private static ConfigEntry<bool> showPinHammer; private static ConfigEntry<bool> showPinPin; private static ConfigEntry<bool> showPinPortal; private static ConfigEntry<bool> showPinBed; private static ConfigEntry<bool> showPinDeath; private static ConfigEntry<bool> showPinEpicLoot; private static ConfigEntry<string> messageStart; private static ConfigEntry<string> messageSaving; private static ConfigEntry<string> messageReady; private static ConfigEntry<string> messageSavedTo; private static ConfigEntry<string> messageNotReady; private static ConfigEntry<string> messageNotEnoughBasePieces; private static ConfigEntry<string> messageNotEnoughComfort; private static ConfigEntry<bool> tablePartsSwap; private static readonly CustomSyncedValue<string> mapDataFromFile = new CustomSyncedValue<string>(configSync, "mapDataFromFile", ""); public static World game_world; public static float abyss_depth = -100f; private static Color32[] m_mapTexture; private static Color[] m_forestTexture; private static Color32[] m_heightmap; private static bool[] m_exploration; private static bool[] m_mapData; private MapGeneration maker; private static NomapPrinter instance; private static string localPath; private static readonly Dictionary<string, Color32[]> pinIcons = new Dictionary<string, Color32[]>(); public static GameObject parentObject; public static GameObject mapContent; public static RectTransform content; public static Texture2D mapTexture = new Texture2D(4096, 4096, (TextureFormat)3, false); private static bool mapWindowInitialized = false; private static bool mapTextureIsReady = false; private bool _displayingWindow = false; private PropertyInfo _curLockState; private PropertyInfo _curVisible; private int _previousCursorLockState; private bool _previousCursorVisible; private static string saveFieldKey; private static DirectoryInfo pluginFolder; private static FileSystemWatcher fileSystemWatcher; private static string mapFileName; public bool CanOperateMap { get { if (mapWindow.Value == MapWindow.Hide || mapWindow.Value == MapWindow.ShowOnInteraction) { return false; } if (DisplayingWindow) { return true; } Player localPlayer = Player.m_localPlayer; return !((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead() && !((Character)localPlayer).InCutscene() && !((Character)localPlayer).IsTeleporting() && ((Object)(object)Chat.instance == (Object)null || !Chat.instance.HasFocus()) && !Console.IsVisible() && !Menu.IsVisible() && (Object)(object)TextViewer.instance != (Object)null && !TextViewer.instance.IsVisible() && !TextInput.IsVisible() && !Minimap.IsOpen(); } } public bool DisplayingWindow { get { return _displayingWindow; } set { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (_displayingWindow == value) { return; } if (value && mapWindow.Value == MapWindow.ShowNearTheTable) { value = false; List<Piece> list = new List<Piece>(); Piece.GetAllPiecesInRadius(((Component)Player.m_localPlayer).transform.position, showNearTheTableDistance.Value, list); MapTable val = default(MapTable); foreach (Piece item in list) { value = ((Component)item).TryGetComponent<MapTable>(ref val); if (value) { break; } } if (!value) { ShowMessage("$piece_toofar", (MessageType)2); } } if (value && (mapWindow.Value == MapWindow.ShowNearTheTable || mapWindow.Value == MapWindow.ShowOnInteraction)) { if (value && showMapBasePiecesRequirement.Value > 0 && Player.m_localPlayer.GetBaseValue() < showMapBasePiecesRequirement.Value) { value = false; ShowMessage(string.Format(messageNotEnoughBasePieces.Value, Player.m_localPlayer.GetBaseValue(), showMapBasePiecesRequirement.Value), (MessageType)2); } if (value && showMapComfortRequirement.Value > 0 && Player.m_localPlayer.GetComfortLevel() < showMapComfortRequirement.Value) { value = false; ShowMessage(string.Format(messageNotEnoughComfort.Value, Player.m_localPlayer.GetComfortLevel(), showMapComfortRequirement.Value), (MessageType)2); } } _displayingWindow = value; if (_displayingWindow) { if (_curLockState != null) { _previousCursorLockState = (int)_curLockState.GetValue(null, null); _previousCursorVisible = (bool)_curVisible.GetValue(null, null); } } else if (!_previousCursorVisible || _previousCursorLockState != 0) { SetUnlockCursor(_previousCursorLockState, _previousCursorVisible); } parentObject.SetActive(_displayingWindow); this.DisplayingWindowChanged?.Invoke(this, new ValueChangedEventArgs<bool>(value)); } } public event EventHandler<ValueChangedEventArgs<bool>> DisplayingWindowChanged; private void Awake() { harmony.PatchAll(); instance = this; maker = new MapGeneration(); pluginFolder = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent; ConfigInit(); configSync.AddLockingConfigEntry<bool>(configLocked); mapDataFromFile.ValueChanged += LoadMapFromSharedValue; Game.isModded = true; } private void OnDestroy() { instance = null; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } private void OnGUI() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 if (!DisplayingWindow) { return; } SetUnlockCursor(0, cursorVisible: true); if (!Event.current.isMouse) { return; } if ((int)Event.current.type == 0) { if (Input.GetMouseButtonDown(1)) { ZoomMap(0f); } else if (Input.GetMouseButtonDown(2)) { CenterMap(); } } Input.ResetInputAxes(); } private void Start() { Type typeFromHandle = typeof(Cursor); _curLockState = typeFromHandle.GetProperty("lockState", BindingFlags.Static | BindingFlags.Public); _curVisible = typeFromHandle.GetProperty("visible", BindingFlags.Static | BindingFlags.Public); } private void Update() { if (!modEnabled.Value || !mapWindowInitialized || !Game.m_noMap) { return; } if (CanOperateMap && (ZInput.GetButtonUp("Map") || ZInput.GetButtonUp("JoyMap"))) { if (!mapTextureIsReady) { ShowMessage(messageNotReady.Value, (MessageType)2); } else { DisplayingWindow = !DisplayingWindow; } } if (DisplayingWindow && ZInput.GetKeyDown((KeyCode)27, true)) { DisplayingWindow = false; } if (DisplayingWindow) { float axis = ZInput.GetAxis("Mouse ScrollWheel"); if (axis != 0f) { ZoomMap(axis); } Input.ResetInputAxes(); } } private static void ZoomMap(float increment) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) float num = increment / 2f; if (num == 0f) { num = mapDefaultScale.Value - ((Transform)content).localScale.x; } int num2 = ((mapSize.Value == MapSize.Small) ? 1 : 2); int num3 = ((mapType.Value != MapType.Vanilla) ? 1 : 2); float num4 = Mathf.Max(mapMinimumScale.Value, 0.1f) * 2f * (float)num3 / (float)num2; float num5 = Mathf.Min(mapMaximumScale.Value, 2f) * (float)num3 * (float)num2; Vector2 val = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(content, Vector2.op_Implicit(Input.mousePosition), (Camera)null, ref val); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(((Transform)content).localScale.x, ((Transform)content).localScale.y, ((Transform)content).localScale.z); float num6 = Mathf.Clamp(val2.x + num, num4, num5); ((Vector3)(ref val2)).Set(num6, num6, 0f); if (((Transform)content).localScale.x != val2.x) { ((Transform)content).localScale = val2; RectTransform obj = content; obj.anchoredPosition -= val * num; } } private static void CenterMap() { //IL_0006: 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) ((Transform)content).localPosition = Vector2.op_Implicit(Vector2.zero); } private static void ResetViewerContentSize() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_007f: Unknown result type (might be due to invalid IL or missing references) if (content.sizeDelta.x != (float)((Texture)mapTexture).width) { content.sizeDelta = new Vector2((float)((Texture)mapTexture).width, (float)((Texture)mapTexture).height); mapContent.GetComponent<Image>().sprite = Sprite.Create(mapTexture, new Rect(0f, 0f, (float)((Texture)mapTexture).width, (float)((Texture)mapTexture).height), Vector2.zero); ZoomMap(0f); CenterMap(); } } public static void Log(object message) { if (loggingEnabled.Value) { ((BaseUnityPlugin)instance).Logger.LogInfo(message); } } private void ConfigInit() { config("General", "NexusID", 2505, "Nexus mod ID for updates", synchronizedSetting: false); modEnabled = config("General", "Enabled", defaultValue: true, "Print map on table interaction"); configLocked = config("General", "Lock Configuration", defaultValue: true, "Configuration is locked and can be changed by server admins only."); loggingEnabled = config("Logging", "Enabled", defaultValue: false, "Enable logging. [Not Synced with Server]", synchronizedSetting: false); mapWindow = config("Map", "Ingame map", MapWindow.ShowEverywhere, "Where to show ingame map"); allowInteractiveMapOnWrite = config("Map", "Show interactive map on record discoveries", defaultValue: false, "Show interactive original game map on record discoveries part of map table used"); showSharedMap = config("Map", "Show shared map", defaultValue: true, "Show parts of the map shared by others"); preventPinAddition = config("Map", "Prevent adding pins on interactive map", defaultValue: false, "Prevent creating pin when using interactive map"); showNearTheTableDistance = config("Map restrictions", "Show map near the table when distance is less than", 10f, "Distance to nearest map table for map to be shown"); showMapBasePiecesRequirement = config("Map restrictions", "Show map when base pieces near the player is more than", 0, "Count of base pieces surrounding the player should be more than that for map to be shown"); showMapComfortRequirement = config("Map restrictions", "Show map when player comfort is more than", 0, "Player comfort buff should be more than that for map to be shown"); saveMapToFile = config("Map save", "Save to file", defaultValue: false, "Save generated map to file. Works in normal map mode. You can set exact file name or folder name [Not Synced with Server]", synchronizedSetting: false); filePath = config("Map save", "Save to file path", "", "File path used to save generated map. [Not Synced with Server]", synchronizedSetting: false); mapStorage = config("Map storage", "Data storage", MapStorage.Character, "Type of storage for map data. Default is save map data to character file."); localFolder = config("Map storage", "Local folder", "", "Save and load map data from local folder. If relative path is set then the folder will be created at ...\\AppData\\LocalLow\\IronGate\\Valheim"); sharedFile = config("Map storage", "Shared file", "", "Load map from the file name instead of generating one. File should be available on the server."); mapType = config("Map style", "Map type", MapType.Chart, "Type of generated map"); mapSize = config("Map style", "Map size", MapSize.Normal, "Resolution of generated map. More details means smoother lines but more data will be stored"); mapDefaultScale = config("Map style", "Map zoom default scale", 0.7f, "Default scale of opened map, more is closer, less is farther."); mapMinimumScale = config("Map style", "Map zoom minimum scale", 0.25f, "Minimum scale of opened map, more is closer, less is farther."); mapMaximumScale = config("Map style", "Map zoom maximum scale", 1f, "Maximum scale of opened map, more is closer, less is farther."); heightmapFactor = config("Map style extended", "Heightmap factor", 8, "Heightmap details factor"); graduationLinesDensity = config("Map style extended", "Graduation line density", 8, "Graduation lines density"); pinScale = config("Map style extended", "Pin scale", 1f, "Pin scale"); preserveSharedMapFog = config("Map style extended", "Preserve shared map fog tint for vanilla map", defaultValue: true, "Generate Vanilla map with shared map fog tint"); messageStart = config("Messages", "Drawing begin", "Remembering travels...", "Center message when drawing is started. [Not Synced with Server]", synchronizedSetting: false); messageSaving = config("Messages", "Drawing end", "Drawing map...", "Center message when saving file is started. [Not Synced with Server]", synchronizedSetting: false); messageReady = config("Messages", "Saved", "Map is ready", "Center message when file is saved. [Not Synced with Server]", synchronizedSetting: false); messageSavedTo = config("Messages", "Saved to", "Map saved to", "Top left message with file name. [Not Synced with Server]", synchronizedSetting: false); messageNotReady = config("Messages", "Not ready", "Map is not drawn yet", "Center message on trying to open a not ready map. [Not Synced with Server]", synchronizedSetting: false); messageNotEnoughBasePieces = config("Messages", "Not enough base pieces", "Not enough base pieces ({0} of {1})", "Center message on trying to open a map with failed base pieces requirement check. [Not Synced with Server]", synchronizedSetting: false); messageNotEnoughComfort = config("Messages", "Not enough comfort", "Not enough comfort ({0} of {1})", "Center message on trying to open a map with failed comfort requirement check. [Not Synced with Server]", synchronizedSetting: false); showPins = config("Pins", "Show map pins", defaultValue: true, "Show pins on drawed map"); showExploredPins = config("Pins", "Show only explored pins", defaultValue: true, "Only show pins on explored part of the map"); showMerchantPins = config("Pins", "Show merchants pins always", defaultValue: true, "Show merchant pins even in unexplored part of the map"); showMyPins = config("Pins", "Show only my pins", defaultValue: true, "Only show your pins on the map"); showNonCheckedPins = config("Pins", "Show only unchecked pins", defaultValue: true, "Only show pins that doesn't checked (have no red cross)"); showEveryPin = config("Pins list", "Show all pins", defaultValue: false, "Show all pins"); showPinStart = config("Pins list", "Show Start pins", defaultValue: true, "Show Start pin on drawed map"); showPinTrader = config("Pins list", "Show Haldor pins", defaultValue: true, "Show Haldor pin on drawed map"); showPinHildir = config("Pins list", "Show Hildir pins", defaultValue: true, "Show Hildir pin on drawed map"); showPinHildirQuest = config("Pins list", "Show Hildir quest pins", defaultValue: true, "Show Hildir quest pins on drawed map"); showPinBoss = config("Pins list", "Show Boss pins", defaultValue: true, "Show Boss pins on drawed map"); showPinFire = config("Pins list", "Show Fire pins", defaultValue: true, "Show Fire pins on drawed map"); showPinHouse = config("Pins list", "Show House pins", defaultValue: true, "Show House pins on drawed map"); showPinHammer = config("Pins list", "Show Hammer pins", defaultValue: true, "Show Hammer pins on drawed map"); showPinPin = config("Pins list", "Show Pin pins", defaultValue: true, "Show Pin pins on drawed map"); showPinPortal = config("Pins list", "Show Portal pins", defaultValue: true, "Show Portal pins on drawed map"); showPinBed = config("Pins list", "Show Bed pins", defaultValue: false, "Show Bed pins on drawed map"); showPinDeath = config("Pins list", "Show Death pins", defaultValue: false, "Show Death pins on drawed map"); showPinEpicLoot = config("Pins list", "Show Epic Loot pins", defaultValue: true, "Show Epic Loot pins on drawed map"); tablePartsSwap = config("Table", "Swap interaction behaviour on map table parts", defaultValue: false, "Make \"Read map\" part to open interactive map and \"Record discoveries\" part to generate map. +\nDoesn't work in Show On Interaction map mode [Not Synced with Server]", synchronizedSetting: false); localPath = Utils.GetSaveDataPath((FileSource)1); MapGeneration.InitIconSize(); SetupMapFileWatcher(); } private void ConfigUpdate() { ((BaseUnityPlugin)this).Config.Reload(); ConfigInit(); } private ConfigEntry<T> config<T>(string group, string name, T defaultValue, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, defaultValue, description); SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val; } private ConfigEntry<T> config<T>(string group, string name, T defaultValue, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } private static void SetupMapFileWatcher() { if (mapStorage.Value == MapStorage.LoadFromSharedFile && !Utility.IsNullOrWhiteSpace(sharedFile.Value)) { if (fileSystemWatcher != null) { fileSystemWatcher.Dispose(); fileSystemWatcher = null; } fileSystemWatcher = new FileSystemWatcher { Path = Path.GetDirectoryName(sharedFile.Value), Filter = Path.GetFileName(sharedFile.Value) }; if (Utility.IsNullOrWhiteSpace(fileSystemWatcher.Path)) { fileSystemWatcher.Path = pluginFolder.FullName; } mapFileName = Path.Combine(fileSystemWatcher.Path, fileSystemWatcher.Filter); fileSystemWatcher.Changed += ReadMapFromFile; fileSystemWatcher.Created += ReadMapFromFile; fileSystemWatcher.Renamed += ReadMapFromFile; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; Log("Setup watcher " + mapFileName); ReadMapFromFile(null, null); } } private static void ReadMapFromFile(object sender, FileSystemEventArgs eargs) { string value = ""; if (!File.Exists(mapFileName)) { Log("Can't find file (" + mapFileName + ")!"); return; } try { value = Convert.ToBase64String(File.ReadAllBytes(mapFileName)); } catch (Exception ex) { Log("Error reading file (" + mapFileName + ")! Error: " + ex.Message); } mapDataFromFile.AssignLocalValue(value); } private static void LoadMapFromSharedValue() { if (LoadMapFromFileData()) { ResetViewerContentSize(); mapTextureIsReady = true; } } private static bool LoadMapFromFileData() { if (Utility.IsNullOrWhiteSpace(mapDataFromFile.Value)) { return false; } try { ImageConversion.LoadImage(mapTexture, Convert.FromBase64String(mapDataFromFile.Value)); mapTexture.Apply(); } catch (Exception arg) { Log($"Loading map error. Invalid printed map texture: {arg}"); return false; } return true; } private static string LocalFileName(Player player) { return Path.Combine(localPath, localFolder.Value, "shudnal.NomapPrinter." + player.GetPlayerName() + "." + game_world.m_name + ".png"); } private static bool LoadMapFromLocalFile(Player player) { if (mapStorage.Value != MapStorage.LocalFolder) { return false; } string text = LocalFileName(player); if (!File.Exists(text)) { Log("Can't find file (" + text + ")!"); return false; } try { Log("Loading nomap data from " + text); ImageConversion.LoadImage(mapTexture, File.ReadAllBytes(text)); mapTexture.Apply(); } catch (Exception arg) { Log($"Loading map error. Invalid printed map texture: {arg}"); return false; } return true; } private static void SaveMapToLocalFile(Player player) { if (mapStorage.Value != MapStorage.LocalFolder) { return; } string text = LocalFileName(player); try { Directory.CreateDirectory(Path.GetDirectoryName(text)); Log("Saving nomap data to " + text); File.WriteAllBytes(text, ImageConversion.EncodeToPNG(mapTexture)); } catch (Exception arg) { Log($"Saving map to local file error:\n{arg}"); } } private static void ShowMessage(string text, MessageType type = 2) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!Utility.IsNullOrWhiteSpace(text)) { MessageHud.instance.ShowMessage(type, text, 1, (Sprite)null); } } private void SetUnlockCursor(int lockState, bool cursorVisible) { if (_curLockState != null) { _curLockState.SetValue(null, lockState, null); _curVisible.SetValue(null, cursorVisible, null); } } private static void SaveValue(Player player, string key, string value) { if (player.m_customData.ContainsKey(key)) { player.m_customData[key] = value; } else { player.m_customData.Add(key, value); } } private static void DeleteValue(Player player, string key) { player.m_customData.Remove(key); } private static bool LoadValue(Player player, string key, out string value) { if (player.m_customData.TryGetValue(key, out value)) { return true; } return false; } private static bool LoadMapFromPlayer(Player player) { if (!modEnabled.Value) { return false; } if ((Object)(object)player == (Object)null) { return false; } if ((Object)(object)player != (Object)(object)Player.m_localPlayer) { return false; } if (LoadMapFromLocalFile(player)) { return true; } if (!LoadValue(player, saveFieldKey, out var value)) { return false; } try { ImageConversion.LoadImage(mapTexture, Convert.FromBase64String(value)); mapTexture.Apply(); } catch (Exception arg) { Log($"Loading map error. Invalid printed map texture: {arg}"); DeleteMapFromPlayer(player); return false; } return true; } private static void DeleteMapFromPlayer(Player player) { if (modEnabled.Value && !((Object)(object)player == (Object)null) && !((Object)(object)player != (Object)(object)Player.m_localPlayer)) { DeleteValue(player, saveFieldKey); } } private static void SaveMapToPlayer(Player player) { if (!modEnabled.Value || (Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return; } if (mapTextureIsReady && mapStorage.Value == MapStorage.Character) { try { SaveValue(player, saveFieldKey, Convert.ToBase64String(ImageConversion.EncodeToPNG(mapTexture))); } catch (Exception arg) { Log($"Saving map error. Invalid printed map texture: {arg}"); DeleteMapFromPlayer(player); } } else { DeleteMapFromPlayer(player); } SaveMapToLocalFile(player); } public static void AddIngameView(Transform parentTransform) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) parentObject = new GameObject("NomapPrinter_Parent", new Type[1] { typeof(RectTransform) }); parentObject.transform.SetParent(parentTransform, false); parentObject.layer = LayerMask.NameToLayer("UI"); RectTransform component = parentObject.GetComponent<RectTransform>(); component.anchoredPosition = Vector2.zero; component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.sizeDelta = Vector2.zero; GameObject val = new GameObject("NomapPrinter_ScrollView", new Type[1] { typeof(RectTransform) }); val.layer = LayerMask.NameToLayer("UI"); val.transform.SetParent(parentObject.transform, false); RectTransform component2 = val.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.sizeDelta = new Vector2(-300f, -200f); ((Graphic)val.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.4f); ScrollRect val2 = val.AddComponent<ScrollRect>(); GameObject val3 = new GameObject("NomapPrinter_ViewPort", new Type[1] { typeof(RectTransform) }); val3.layer = LayerMask.NameToLayer("UI"); val3.transform.SetParent(val.transform, false); val3.AddComponent<RectMask2D>(); ((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0f); RectTransform component3 = val3.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.sizeDelta = new Vector2(-12f, -12f); component3.anchoredPosition = Vector2.zero; mapContent = new GameObject("NomapPrinter_Map", new Type[1] { typeof(RectTransform) }); mapContent.layer = LayerMask.NameToLayer("UI"); content = mapContent.GetComponent<RectTransform>(); ((Transform)content).SetParent(val3.transform); content.sizeDelta = new Vector2((float)((Texture)mapTexture).width, (float)((Texture)mapTexture).height); content.anchoredPosition = Vector2.zero; ZoomMap(0f); Image val4 = mapContent.AddComponent<Image>(); val4.sprite = Sprite.Create(mapTexture, new Rect(0f, 0f, (float)((Texture)mapTexture).width, (float)((Texture)mapTexture).height), Vector2.zero); val4.preserveAspect = true; val2.scrollSensitivity = 0f; val2.content = content; val2.viewport = component3; val2.horizontal = true; val2.vertical = true; val2.inertia = false; val2.movementType = (MovementType)2; mapWindowInitialized = true; parentObject.SetActive(false); Log("Ingame drawed map added to hud"); } private static void GenerateMap() { if (saveMapToFile.Value || Game.m_noMap) { instance.ConfigUpdate(); if ((saveMapToFile.Value || mapStorage.Value != MapStorage.LoadFromSharedFile) && !instance.maker.working) { ((MonoBehaviour)instance).StartCoroutine(instance.maker.Go()); } } } private static void ShowInteractiveMap() { if (Game.m_noMap) { instance.ConfigUpdate(); if (allowInteractiveMapOnWrite.Value) { Game.m_noMap = false; Minimap.instance.inputDelay = 1f; Minimap.instance.SetMapMode((MapMode)2); Game.m_noMap = true; } } } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [Microsoft.CodeAnalysis.Embedded] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[]