Decompiled source of NomapPrinter v1.3.9
NomapPrinter.dll
Decompiled 2 weeks 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.Text; 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: AssemblyTitle("NomapPrinter")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyProduct("NomapPrinter")] [assembly: AssemblyCompany("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [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: Guid("ba601320-0ece-4b27-b2a4-a1fe1ba817b3")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace NomapPrinter { internal static class CustomSyncedValuesSynchronizer { private static readonly Queue<IEnumerator> coroutines = new Queue<IEnumerator>(); private static readonly WaitWhile waitForServerUpdate = new WaitWhile((Func<bool>)(() => ConfigSync.ProcessingServerUpdate)); public static void AssignValueSafe<T>(this CustomSyncedValue<T> syncedValue, T value) { AddToQueue(AssignAfterServerUpdate(syncedValue, value, assignIfChanged: false)); } public static void AssignValueSafe<T>(this CustomSyncedValue<T> syncedValue, Func<T> function) { AddToQueue(AssignAfterServerUpdate(syncedValue, function, assignIfChanged: false)); } public static void AssignValueIfChanged<T>(this CustomSyncedValue<T> syncedValue, T value) { AddToQueue(AssignAfterServerUpdate(syncedValue, value, assignIfChanged: true)); } public static void AssignValueIfChanged<T>(this CustomSyncedValue<T> syncedValue, Func<T> function) { AddToQueue(AssignAfterServerUpdate(syncedValue, function, assignIfChanged: true)); } private static IEnumerator AssignAfterServerUpdate<T>(CustomSyncedValue<T> syncedValue, Func<T> function, bool assignIfChanged) { yield return AssignAfterServerUpdate(syncedValue, function(), assignIfChanged); } private static IEnumerator AssignAfterServerUpdate<T>(CustomSyncedValue<T> syncedValue, T value, bool assignIfChanged) { if (!assignIfChanged || !syncedValue.Value.Equals(value)) { yield return waitForServerUpdate; syncedValue.AssignLocalValue(value); } } private static void AddToQueue(IEnumerator coroutine) { coroutines.Enqueue(coroutine); if (coroutines.Count == 1) { ((MonoBehaviour)NomapPrinter.instance).StartCoroutine(CoroutineCoordinator()); } } private static IEnumerator CoroutineCoordinator() { while (true) { if (coroutines.Count > 0) { yield return ((MonoBehaviour)NomapPrinter.instance).StartCoroutine(coroutines.Peek()); coroutines.Dequeue(); } else if (coroutines.Count == 0) { break; } } } } internal static class MapGenerator { private const int _textureSize = 4096; private static bool[] _exploredData; private static Color32[] _mapTexture; private static Color[] _forestTexture; private static Color32[] _heightmap; private static Color32[] _result; private static Color32[] space; private static int spaceRes; private static Color32[] fog; private static int fogRes; public static readonly Color32 yellowMap = new Color32((byte)203, (byte)155, (byte)87, byte.MaxValue); public static readonly Color32 oceanColor = new Color32((byte)20, (byte)100, byte.MaxValue, byte.MaxValue); public static readonly Color32 abyssColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue); public static readonly Color32 lavaColor = new Color32((byte)205, (byte)51, (byte)15, byte.MaxValue); public static readonly Color32 northColor = new Color32((byte)170, (byte)173, (byte)194, byte.MaxValue); public static readonly Color32 mistColor = new Color32((byte)217, (byte)140, (byte)166, byte.MaxValue); public static readonly Color clearMask = new Color(0f, 0f, 0f, 1f); public static int TextureSize => (int)(4096f * NomapPrinter.mapSizeMultiplier.Value); private static Color32[] MapTexture { get { if (_mapTexture == null) { _mapTexture = (Color32[])(object)new Color32[TextureSize * TextureSize]; } return _mapTexture; } set { _mapTexture = value; } } private static Color[] ForestTexture { get { if (_forestTexture == null) { _forestTexture = (Color[])(object)new Color[TextureSize * TextureSize]; } return _forestTexture; } set { _forestTexture = value; } } private static Color32[] Heightmap { get { if (_heightmap == null) { _heightmap = (Color32[])(object)new Color32[TextureSize * TextureSize]; } return _heightmap; } set { _heightmap = value; } } private static bool[] ExploredData { get { if (_exploredData == null) { _exploredData = new bool[TextureSize * TextureSize]; } return _exploredData; } set { _exploredData = value; } } public static Color32[] Result { get { if (_result == null) { _result = (Color32[])(object)new Color32[TextureSize * TextureSize]; } return _result; } set { _result = value; } } public static IEnumerator Initialize() { if (spaceRes == 0 && (NomapPrinter.mapType.Value == NomapPrinter.MapType.BirdsEye || NomapPrinter.mapType.Value == NomapPrinter.MapType.Topographical)) { yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Minimap.instance != (Object)null && (Object)(object)Minimap.instance.m_mapLargeShader != (Object)null)); Texture spaceTex = Minimap.instance.m_mapLargeShader.GetTexture("_SpaceTex"); spaceRes = spaceTex.width; RenderTexture tmp = RenderTexture.GetTemporary(spaceRes, spaceRes, 24); Graphics.Blit(spaceTex, tmp); RenderTexture previous = RenderTexture.active; RenderTexture.active = tmp; Texture2D tex = new Texture2D(spaceRes, spaceRes, (TextureFormat)4, false, false); tex.ReadPixels(new Rect(0f, 0f, (float)spaceRes, (float)spaceRes), 0, 0); tex.Apply(); RenderTexture.active = previous; RenderTexture.ReleaseTemporary(tmp); space = tex.GetPixels32(); Object.Destroy((Object)(object)tex); } } public static void InitializeTextures(Texture2D biomes, Texture2D forests, Texture2D height) { MapTexture = biomes.GetPixels32(); ForestTexture = forests.GetPixels(); Heightmap = height.GetPixels32(); } public static void DeInitializeTextures() { MapTexture = null; ForestTexture = null; Heightmap = null; Result = null; fog = null; } public static void SetFogTexture(Texture2D fog) { SetFogTexture(fog.GetPixels32()); } public static void SetFogTexture(Color32[] newFog) { fog = (Color32[])(object)new Color32[newFog.Length]; fogRes = (int)Math.Sqrt(newFog.Length); newFog.CopyTo(fog, 0); } public static void SetMapTexture(Texture2D map) { SetMapTexture(map.GetPixels32()); } public static void SetMapTexture(Color32[] map) { map.CopyTo(MapTexture, 0); } public static IEnumerator OverlayTextureOnMap(Texture2D texture) { texture.GetPixels32().CopyTo(Result, 0); yield return OverlayResultOnMap(); } public static IEnumerator OverlayExplorationFog(bool[] exploration) { for (int i = 0; i < ExploredData.Length; i++) { ExploredData[i] = false; } if (exploration.Length == ExploredData.Length) { exploration.CopyTo(ExploredData, 0); } else { int targetSize = (int)Math.Sqrt(ExploredData.Length); int currentSize = (int)Math.Sqrt(exploration.Length); for (int row = 0; row < currentSize; row++) { for (int col = 0; col < currentSize; col++) { if (exploration[row * currentSize + col]) { SetExploredData(row * 2 * targetSize + col * 2); SetExploredData(row * 2 * targetSize + col * 2 + 1); SetExploredData((row * 2 + 1) * targetSize + col * 2); SetExploredData((row * 2 + 1) * targetSize + col * 2 + 1); } } } } yield return StylizeFog(); yield return OverlayResultOnMap(); static void SetExploredData(int position) { if (position < ExploredData.Length) { ExploredData[position] = true; } } } public static IEnumerator GenerateOldMap(int graduationHeight) { yield return GenerateOceanTexture(Heightmap, MapTexture, 0.25f); Color32[] oceanTexture = Result; yield return ReplaceAbyssWithColor(MapTexture, abyssColor, 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 LerpTextures(outtex7, offYellow); outtex7 = Result; yield return LerpTextures(outtex7, offYellow); outtex7 = Result; yield return AddPerlinNoise(outtex7, 128, 16); outtex7 = Result; yield return ApplyForestMaskTexture(outtex7, ForestTexture, 0.95f); outtex7 = Result; yield return GenerateContourMap(Heightmap, graduationHeight, 128); Color32[] contours = Result; yield return OverlayTexture(outtex7, contours); } public static IEnumerator GenerateChartMap(int graduationHeight) { yield return GenerateOceanTexture(Heightmap, MapTexture, 0.15f); Color32[] oceanTexture = Result; yield return ReplaceAbyssWithColor(MapTexture, abyssColor, yellowMap); Color32[] outtex5 = Result; yield return OverlayTexture(outtex5, oceanTexture); outtex5 = Result; yield return GetSolidColour(yellowMap); Color32[] offYellow = Result; yield return LerpTextures(outtex5, offYellow); outtex5 = Result; yield return AddPerlinNoise(outtex5, 128, 16); outtex5 = Result; yield return ApplyForestMaskTexture(outtex5, ForestTexture); outtex5 = Result; yield return GenerateContourMap(Heightmap, graduationHeight, 128); Color32[] contours = Result; yield return OverlayTexture(outtex5, contours); } public static IEnumerator GenerateSatelliteImage() { yield return GenerateOceanTexture(Heightmap, MapTexture); Color32[] oceanTexture2 = Result; yield return AddPerlinNoise(oceanTexture2, 4, 64); oceanTexture2 = Result; yield return ReplaceAbyssWithSpace(MapTexture, abyssColor); Color32[] outtex5 = Result; yield return OverlayTexture(outtex5, oceanTexture2); outtex5 = Result; yield return CreateShadowMap(Heightmap, 23); Color32[] shadowmap = Result; yield return DarkenTextureLinear(outtex5, 20); outtex5 = Result; yield return ApplyForestMaskTexture(outtex5, ForestTexture); outtex5 = Result; yield return GenerateContourMap(Heightmap, 128, 64); Color32[] contours = Result; yield return OverlayTexture(outtex5, contours); outtex5 = Result; yield return OverlayTexture(outtex5, shadowmap); } public static IEnumerator GenerateTopographicalMap(int graduationHeight) { yield return GenerateOceanTexture(Heightmap, MapTexture); Color32[] oceanTexture2 = Result; yield return AddPerlinNoise(oceanTexture2, 4, 64); oceanTexture2 = Result; yield return ReplaceAbyssWithSpace(MapTexture, abyssColor); Color32[] outtex5 = Result; yield return OverlayTexture(outtex5, oceanTexture2); outtex5 = Result; yield return CreateShadowMap(Heightmap, 23); Color32[] shadowmap = Result; yield return DarkenTextureLinear(outtex5, 20); outtex5 = Result; yield return ApplyForestMaskTexture(outtex5, ForestTexture); outtex5 = Result; yield return GenerateContourMap(Heightmap, graduationHeight, 128); Color32[] contours = Result; yield return OverlayTexture(outtex5, contours); outtex5 = Result; yield return OverlayTexture(outtex5, shadowmap); } private static IEnumerator OverlayResultOnMap() { Thread internalThread = new Thread((ThreadStart)delegate { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_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_007e: 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) for (int i = 0; i < MapTexture.Length; i++) { Result[i] = Color32.op_Implicit(Color.Lerp(Color32.op_Implicit(MapTexture[i]), Color32.op_Implicit(Result[i]), Color32.op_Implicit(Result[i]).a)); Result[i].a = (byte)(255f * Mathf.Clamp01(Color32.op_Implicit(Result[i]).a + Color32.op_Implicit(MapTexture[i]).a)); } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } SetMapTexture(Result); } private static IEnumerator OverlayTexture(Color32[] array1, Color32[] array2) { Color32[] output = (Color32[])(object)new Color32[array1.Length]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0090: 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_0096: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < array1.Length; i++) { float a = Color32.op_Implicit(array2[i]).a; float a2 = Color32.op_Implicit(array1[i]).a; Color val = Color.Lerp(Color32.op_Implicit(array1[i]), Color32.op_Implicit(array2[i]), a); val.a = a + a2; if (val.a > 1f) { val.a = 1f; } output[i] = Color32.op_Implicit(val); } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } Result = output; } private static IEnumerator LerpTextures(Color32[] array1, Color32[] array2) { Color32[] output = (Color32[])(object)new Color32[TextureSize * TextureSize]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < TextureSize * TextureSize; 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 static IEnumerator DarkenTextureLinear(Color32[] array, byte d) { Color32[] output = (Color32[])(object)new Color32[TextureSize * TextureSize]; Thread internalThread = new Thread((ThreadStart)delegate { for (int i = 0; i < TextureSize * TextureSize; 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 static 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 static IEnumerator CreateSoftShadowMap(Color32[] input) { Color32[] output = (Color32[])(object)new Color32[input.Length]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_0077: 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) for (int i = 0; i < TextureSize; i++) { for (int j = 0; j < TextureSize; j++) { int num = i * TextureSize + j; int num2 = ((i > 0) ? (input[num].r - input[(i - 1) * 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 static IEnumerator CreateHardShadowMap(Color32[] input, byte intensity) { Color32[] output = (Color32[])(object)new Color32[input.Length]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) bool[] array = new bool[TextureSize * TextureSize]; for (int i = 0; i < TextureSize * TextureSize; i++) { array[i] = false; } for (int j = 0; j < TextureSize; j++) { for (int k = 0; k < TextureSize; k++) { int num = j * TextureSize + k; if (!array[num]) { output[num] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)0); for (int l = 1; j + l < TextureSize && input[num].r > input[(j + l) * TextureSize + k].r + l * 2; l++) { array[(j + l) * 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 static 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < TextureSize * TextureSize; i++) { if (input[i].b == 0) { output[i] = Color32.op_Implicit(Color.clear); } else { int num = i / TextureSize / 16 - 128; int num2 = i % TextureSize / 16 - 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], oceanColor, oceanLerpTarget); } } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } Result = output; } private static IEnumerator GetPerlin(int tightness, byte damping) { for (int i = 0; i < Result.Length; i++) { Result[i] = new Color32((byte)0, (byte)0, (byte)0, (byte)0); } Thread internalThread = new Thread((ThreadStart)delegate { //IL_0051: 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_005b: Unknown result type (might be due to invalid IL or missing references) for (int j = 0; j < TextureSize; j++) { for (int k = 0; k < TextureSize; k++) { float num = Mathf.PerlinNoise((float)j / (float)tightness, (float)k / (float)tightness); num = (num - 0.5f) / (float)(int)damping + 0.5f; Result[j * TextureSize + k] = Color32.op_Implicit(new Color(num, num, num, 0.2f)); } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } } private static IEnumerator StylizeFog() { bool customFog = fog != null; if (!customFog) { yield return GetPerlin(128, 16); fog = Result; fogRes = 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) //IL_0079: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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 num = i * TextureSize + j; if (!ExploredData[num]) { Color32 val = fog[i % fogRes * fogRes + j % fogRes]; if (customFog) { Result[num] = val; } else { Result[num] = new Color32((byte)(yellowMap.r + (val.r - 128)), (byte)(yellowMap.g + (val.g - 128)), (byte)(yellowMap.b + (val.b - 128)), byte.MaxValue); } } } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } } private static 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_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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < TextureSize * 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 < TextureSize - 1; j++) { int num2 = j * TextureSize; for (int k = 1; k < TextureSize - 1; k++) { int num3 = num2 + k; int num4 = input[num2 + k].r / graduations; output[num3] = Color32.op_Implicit(Color.clear); for (int l = -1; l < 2; l++) { int num5 = l * 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 static IEnumerator AddPerlinNoise(Color32[] input, int tightness, byte damping) { Thread internalThread = new Thread((ThreadStart)delegate { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008b: 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 num = i * TextureSize + j; 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; Result[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; } } private static IEnumerator GetSolidColour(Color32 TexColour) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[TextureSize * TextureSize]; Thread internalThread = new Thread((ThreadStart)delegate { //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) for (int i = 0; i < array.Length; i++) { array[i] = TexColour; } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } Result = array; } private static IEnumerator ReplaceAbyssWithColor(Color32[] input, Color32 from, Color32 to) { //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) //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_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) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < input.Length; i++) { 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 static IEnumerator ReplaceAbyssWithSpace(Color32[] input, Color32 from) { //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[] output = (Color32[])(object)new Color32[input.Length]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00a2: 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 num = i * TextureSize + j; 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 static IEnumerator ApplyForestMaskTexture(Color32[] array, Color[] forestMask, float forestColorFactor = 0.9f) { Color32[] output = (Color32[])(object)new Color32[TextureSize * TextureSize]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: 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_0269: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < TextureSize * TextureSize; i++) { if (forestMask[i] == clearMask) { output[i] = array[i]; } else { if (forestMask[i].r > 0f) { float num = 1f - (1f - forestColorFactor) * forestMask[i].r; 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); } if (forestMask[i].g > 0f) { float wy = ((float)(i / TextureSize) / (float)TextureSize - 0.5f) * 400f; float wx = ((float)(i % TextureSize) / (float)TextureSize - 0.5f) * 400f; output[i] = Color32.Lerp(array[i], mistColor, forestMask[i].g * GetMistlandsNoise(wx, wy) * 0.9f); } if (forestMask[i].b > 0f) { output[i] = Color32.Lerp(array[i], lavaColor, forestMask[i].b); } if (forestMask[i].a != 1f) { if (forestMask[i].a >= 0.5f) { output[i] = Color32.Lerp(array[i], lavaColor, (forestMask[i].a - 0.5f) / 0.5f); } if (0f <= forestMask[i].a && forestMask[i].a < 0.5f) { output[i] = Color32.Lerp(array[i], northColor, forestMask[i].a / 0.5f); } } output[i].a = array[i].a; } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } Result = output; } public static float GetMistlandsNoise(float wx, float wy) { float num = 1f * Mathf.PerlinNoise(1f * wx, 1f * wy) + 0.5f * Mathf.PerlinNoise(2f * wx, 2f * wy) + 0.25f * Mathf.PerlinNoise(4f * wx, 4f * wy) + 0.125f * Mathf.PerlinNoise(8f * wx, 8f * wy); return num / 1.875f; } } public static class MapMaker { public class WorldMapData { public const int _textureSize = 4096; public const int _pixelSize = 6; public const string cacheFileName = "worldData"; public const int version = 1; public long worldUID; public Thread[] threads; public bool initialized = false; public Texture2D m_mapTexture; public Texture2D m_forestTexture; public Texture2D m_heightmap; public static int TextureSize => (int)(4096f * NomapPrinter.mapSizeMultiplier.Value); public static int PixelSize => (int)(6f * NomapPrinter.mapSizeMultiplier.Value); public WorldMapData(long worldUID) { this.worldUID = worldUID; } public IEnumerator Init() { if (initialized) { threads = null; yield break; } if (LoadFromCache()) { NomapPrinter.LogInfo("World data loaded from cache"); initialized = true; yield break; } yield return (object)new WaitUntil((Func<bool>)(() => WorldGenerator.instance != null && (Object)(object)ZoneSystem.instance != (Object)null)); Color32[] m_mapTextureArray = (Color32[])(object)new Color32[TextureSize * TextureSize]; Color[] m_forestTextureArray = (Color[])(object)new Color[TextureSize * TextureSize]; Color32[] m_heightmapArray = (Color32[])(object)new Color32[TextureSize * TextureSize]; if (!initialized && threads == null) { threads = new Thread[4] { new Thread((ThreadStart)delegate { FillMapPart(0, 0, m_mapTextureArray, m_forestTextureArray, m_heightmapArray); }), new Thread((ThreadStart)delegate { FillMapPart(0, 1, m_mapTextureArray, m_forestTextureArray, m_heightmapArray); }), new Thread((ThreadStart)delegate { FillMapPart(1, 0, m_mapTextureArray, m_forestTextureArray, m_heightmapArray); }), new Thread((ThreadStart)delegate { FillMapPart(1, 1, m_mapTextureArray, m_forestTextureArray, m_heightmapArray); }) }; CollectionExtensions.Do<Thread>((IEnumerable<Thread>)threads, (Action<Thread>)delegate(Thread thread) { thread.Start(); }); } yield return (object)new WaitWhile((Func<bool>)(() => threads != null && threads.Any((Thread thread) => thread.IsAlive))); m_mapTexture = new Texture2D(TextureSize, TextureSize, (TextureFormat)3, false) { name = "NomapPrinter_m_mapTexture", wrapMode = (TextureWrapMode)1 }; m_forestTexture = new Texture2D(TextureSize, TextureSize, (TextureFormat)4, false) { name = "NomapPrinter_m_forestTexture", wrapMode = (TextureWrapMode)1 }; m_heightmap = new Texture2D(TextureSize, TextureSize, (TextureFormat)3, false) { name = "NomapPrinter_m_heightmap", wrapMode = (TextureWrapMode)1 }; m_mapTexture.SetPixels32(m_mapTextureArray); m_mapTexture.Apply(); yield return null; m_forestTexture.SetPixels(m_forestTextureArray); m_forestTexture.Apply(); yield return null; m_heightmap.SetPixels32(m_heightmapArray); m_heightmap.Apply(); yield return null; threads = null; initialized = true; SaveToCache(); } private void FillMapPart(int partX, int partY, Color32[] mapTextureArray, Color[] forestTextureArray, Color32[] heightmapArray) { for (int i = partX * TextureSize / 2; i < (partX + 1) * TextureSize / 2; i++) { for (int j = partY * TextureSize / 2; j < (partY + 1) * TextureSize / 2; j++) { FillMap(i, j, mapTextureArray, forestTextureArray, heightmapArray); } } } private void FillMap(int i, int j, Color32[] mapTextureArray, Color[] forestTextureArray, Color32[] heightmapArray) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_00ce: 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_00d4: 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_00ae: 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_012f: Invalid comparison between Unknown and I4 //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) float num = (float)((i - TextureSize / 2) * PixelSize) + (float)PixelSize / 2f; float num2 = (float)((j - TextureSize / 2) * PixelSize) + (float)PixelSize / 2f; int num3 = i * TextureSize + j; if (DUtils.Length(num2, num) > NomapPrinter.worldSize.Value) { mapTextureArray[num3] = MapGenerator.abyssColor; return; } Biome biome = WorldGenerator.instance.GetBiome(num2, num, 0.02f, false); Color val = default(Color); float biomeHeight = WorldGenerator.instance.GetBiomeHeight(biome, num2, num, ref val, false); if (biomeHeight < -100f) { mapTextureArray[num3] = MapGenerator.abyssColor; return; } float num4 = biomeHeight - ZoneSystem.instance.m_waterLevel; forestTextureArray[num3] = GetMaskColor(num2, num, num4, biome); if (num4 > 0f) { heightmapArray[num3] = Color32.op_Implicit(new Color(num4 / Mathf.Pow(2f, 9f), 0f, 0f)); } else { heightmapArray[num3] = Color32.op_Implicit(new Color(0f, 0f, num4 / (0f - Mathf.Pow(2f, (float)(8 + (((int)biome == 2) ? 1 : 0)))))); } mapTextureArray[num3] = Color32.op_Implicit(GetPixelColor(biome, biomeHeight)); } private string CacheFile() { return Path.Combine(CacheDirectory(), ZNet.instance.GetWorldName() + "_worldData"); } private bool LoadFromCache() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown string text = CacheFile(); if (!File.Exists(text)) { NomapPrinter.LogInfo("File not found: " + text); return false; } byte[] array; try { array = File.ReadAllBytes(text); } catch (Exception ex) { NomapPrinter.LogWarning("Error reading file (" + text + ")! Error: " + ex.Message); return false; } ZPackage val = new ZPackage(array); if (1 != val.ReadInt()) { NomapPrinter.LogWarning("World data (" + text + "): Version mismatch"); return false; } try { worldUID = val.ReadLong(); if (TextureSize != val.ReadInt()) { return false; } if (PixelSize != val.ReadInt()) { return false; } if ((Object)(object)m_mapTexture == (Object)null) { m_mapTexture = new Texture2D(2, 2); } ImageConversion.LoadImage(m_mapTexture, val.ReadByteArray()); if ((Object)(object)m_forestTexture == (Object)null) { m_forestTexture = new Texture2D(2, 2); } ImageConversion.LoadImage(m_forestTexture, val.ReadByteArray()); if ((Object)(object)m_heightmap == (Object)null) { m_heightmap = new Texture2D(2, 2); } ImageConversion.LoadImage(m_heightmap, val.ReadByteArray()); } catch (Exception ex2) { NomapPrinter.LogWarning("Error reading file (" + text + ")! Error: " + ex2.Message); DestroyTextures(); return false; } return true; } private void SaveToCache() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(1); val.Write(worldUID); val.Write(TextureSize); val.Write(PixelSize); val.Write(ImageConversion.EncodeToPNG(m_mapTexture)); val.Write(ImageConversion.EncodeToPNG(m_forestTexture)); val.Write(ImageConversion.EncodeToPNG(m_heightmap)); string text = CacheFile(); try { File.WriteAllBytes(text, val.GetArray()); } catch (Exception ex) { NomapPrinter.LogWarning("Error writing file (" + text + ")! Error: " + ex.Message); } } internal void DestroyTextures() { Object.Destroy((Object)(object)m_mapTexture); Object.Destroy((Object)(object)m_forestTexture); Object.Destroy((Object)(object)m_heightmap); } } public class ExploredMapData { public const string exploredMapFileName = "mapData"; public const int version = 2; public Texture2D exploredMap; public NomapPrinter.MapType exploredMapType; public void Init(Color32[] mapData, NomapPrinter.MapType mapType) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown int num = (int)Math.Sqrt(mapData.Length); exploredMap = new Texture2D(num, num, (TextureFormat)4, false, false); exploredMap.SetPixels32(mapData); exploredMap.Apply(false); exploredMapType = mapType; SaveExploredMap(); } private string ExploredMapFileName() { return Path.Combine(CacheDirectory(), string.Format("{0}_{1}", "mapData", exploredMapType)); } private bool LoadFromCustomFile() { if (!NomapPrinter.useCustomExploredLayer.Value) { return false; } exploredMap = GetLayerTexture("explored", NomapPrinter.syncExploredLayerFromServer.Value); return (Object)(object)exploredMap != (Object)null; } public bool LoadExploredMap() { if ((Object)(object)exploredMap != (Object)null && exploredMapType == NomapPrinter.mapType.Value) { return true; } ResetExploredMap(); return LoadFromCustomFile() || LoadExploredMapFromFile(); } public void ResetExploredMap() { if ((Object)(object)exploredMap != (Object)null) { Object.Destroy((Object)(object)exploredMap); } exploredMap = null; exploredMapType = NomapPrinter.mapType.Value; } private bool LoadExploredMapFromFile() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown string text = ExploredMapFileName(); byte[] packedImageData = GetPackedImageData(text); if (packedImageData == null) { return false; } try { exploredMap = new Texture2D(2, 2); return ImageConversion.LoadImage(exploredMap, packedImageData); } catch (Exception ex) { NomapPrinter.LogWarning("Error loading map image (" + text + ")! Error: " + ex.Message); } return false; } public static byte[] GetPackedImageData(string filename) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown if (!File.Exists(filename)) { NomapPrinter.LogInfo("File not found: " + filename); return null; } byte[] array; try { array = File.ReadAllBytes(filename); } catch (Exception ex) { NomapPrinter.LogWarning("Error reading file (" + filename + ")! Error: " + ex.Message); return null; } ZPackage val = new ZPackage(array); if (2 != val.ReadInt()) { NomapPrinter.LogWarning("World map data (" + filename + "): Version mismatch"); return null; } array = val.ReadByteArray(); byte[] bytes = new UTF8Encoding().GetBytes("shudnal.NomapPrinter"); for (int i = 0; i < array.Length; i++) { array[i] ^= bytes[i % bytes.Length]; } return array; } public static byte[] GetPackedImageData(byte[] data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(2); byte[] bytes = new UTF8Encoding().GetBytes("shudnal.NomapPrinter"); for (int i = 0; i < data.Length; i++) { data[i] ^= bytes[i % bytes.Length]; } val.Write(data); return val.GetArray(); } private void SaveExploredMap() { if ((Object)(object)exploredMap == (Object)null) { return; } string text = ExploredMapFileName(); try { File.WriteAllBytes(text, GetPackedImageData(ImageConversion.EncodeToPNG(exploredMap))); } catch (Exception ex) { NomapPrinter.LogWarning("Error writing file (" + text + ")! Error: " + ex.Message); } } } public static WorldMapData worldMapData; public static ExploredMapData exploredMapData = new ExploredMapData(); public const float abyss_depth = -100f; public const string worldDataPrefix = "NomapPrinter_Exploration_"; public const int heightmapFactor = 8; public const int graduationLinesDensity = 8; public static bool isWorking = false; private static IEnumerator worker; public static Texture2D mapTexture = new Texture2D(WorldMapData.TextureSize, WorldMapData.TextureSize, (TextureFormat)3, false); private static readonly Dictionary<string, Color32[]> pinIcons = new Dictionary<string, Color32[]>(); private static Texture2D iconSpriteTexture; private static int iconSize = 32; private static long worldUID; private static Texture2D noClouds; private static bool[] exploration; public static void ResetExploredMap() { exploredMapData?.ResetExploredMap(); } public static void ResetExploredMapOnTextureChange() { if (NomapPrinter.useCustomExploredLayer.Value) { exploredMapData?.ResetExploredMap(); } } public static void GenerateMap() { if (NomapPrinter.saveMapToFile.Value || Game.m_noMap) { if (isWorking && worker != null) { ((MonoBehaviour)NomapPrinter.instance).StopCoroutine(worker); worker = null; } worldUID = ZNet.instance.GetWorldUID(); worker = CreateMap(); ((MonoBehaviour)NomapPrinter.instance).StartCoroutine(worker); } } public static void PregenerateMap() { worldUID = ZNet.instance.GetWorldUID(); ((MonoBehaviour)NomapPrinter.instance).StartCoroutine(CreateMap(pregeneration: true)); } private static string CacheDirectory() { Directory.CreateDirectory(NomapPrinter.cacheDirectory); string text = Path.Combine(NomapPrinter.cacheDirectory, worldUID.ToString()); Directory.CreateDirectory(text); return text; } private static IEnumerator CreateMap(bool pregeneration = false) { isWorking = true; InitIconSize(); bool haveExploration = GetPlayerExploration(Player.m_localPlayer, worldUID); if (NomapPrinter.mapType.Value == NomapPrinter.MapType.Vanilla) { if (!pregeneration) { NomapPrinter.ShowMessage(NomapPrinter.messageStart.Value, (MessageType)2); yield return GetVanillaMap(2048 * (int)NomapPrinter.mapSize.Value, haveExploration); } } else { if (!pregeneration) { NomapPrinter.ShowMessage(NomapPrinter.messageStart.Value, (MessageType)2); } if (!exploredMapData.LoadExploredMap()) { yield return PrepareTerrainData(); if (!pregeneration) { NomapPrinter.ShowMessage(NomapPrinter.messageSaving.Value, (MessageType)2); } yield return MapGenerator.Initialize(); yield return PrepareMap(NomapPrinter.mapType.Value); exploredMapData.Init(MapGenerator.Result, NomapPrinter.mapType.Value); } else { NomapPrinter.LogInfo("World map data loaded from cache"); } yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Player.m_localPlayer != (Object)null)); if (haveExploration) { MapGenerator.SetMapTexture(exploredMapData.exploredMap); if (NomapPrinter.useCustomUnderFogLayer.Value) { yield return OverlayMarkingsLayer(); } if (NomapPrinter.useCustomFogLayer.Value) { OverrideFogTexture(); } yield return MapGenerator.OverlayExplorationFog(exploration); if (NomapPrinter.useCustomOverFogLayer.Value) { yield return OverlayMarkingsLayer(overFog: true); } yield return ApplyMapTexture(MapGenerator.Result); NomapPrinter.ShowMessage(NomapPrinter.messageReady.Value, (MessageType)2); } MapGenerator.DeInitializeTextures(); } if (!pregeneration && MapViewer.IsMapReady() && NomapPrinter.saveMapToFile.Value) { string filename = NomapPrinter.filePath.Value; if (Utility.IsNullOrWhiteSpace(filename)) { filename = Path.Combine(NomapPrinter.localPath, "screenshots", $"{NomapPrinter.mapType.Value}.{ZNet.instance.GetWorldName()}.png"); } else { FileAttributes attr = File.GetAttributes(filename); if (attr.HasFlag(FileAttributes.Directory)) { filename = Path.Combine(filename, $"{NomapPrinter.mapType.Value}.{ZNet.instance.GetWorldName()}.png"); } } string filepath = Path.GetDirectoryName(filename); NomapPrinter.LogInfo("Writing " + filename); Thread internalThread = new Thread((ThreadStart)delegate { Directory.CreateDirectory(filepath); File.WriteAllBytes(filename, ImageConversion.EncodeToPNG(mapTexture)); }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } NomapPrinter.ShowMessage(NomapPrinter.messageSavedTo.Value + " " + filepath, (MessageType)1); } NomapPrinter.LogInfo("Finished Map Draw"); isWorking = false; } private static IEnumerator PrepareTerrainData() { yield return (object)new WaitUntil((Func<bool>)(() => WorldGenerator.instance != null)); Stopwatch stopwatch = Stopwatch.StartNew(); long uid = ((worldUID == 0L) ? WorldGenerator.m_instance.m_world.m_uid : worldUID); worldMapData?.DestroyTextures(); NomapPrinter.LogInfo($"Preparing terrain data for world {uid} started"); worldMapData = new WorldMapData(uid); yield return worldMapData.Init(); NomapPrinter.LogInfo($"Terrain data for world {uid} is ready in {stopwatch.ElapsedMilliseconds,-4:F2} ms"); } private static IEnumerator PrepareMap(NomapPrinter.MapType mapType) { Stopwatch stopwatch = Stopwatch.StartNew(); MapGenerator.InitializeTextures(worldMapData.m_mapTexture, worldMapData.m_forestTexture, worldMapData.m_heightmap); switch (mapType) { case NomapPrinter.MapType.BirdsEye: yield return MapGenerator.GenerateSatelliteImage(); break; case NomapPrinter.MapType.Topographical: yield return MapGenerator.GenerateTopographicalMap(8); break; default: yield return MapGenerator.GenerateChartMap(8); break; case NomapPrinter.MapType.OldChart: yield return MapGenerator.GenerateOldMap(8); break; } NomapPrinter.LogInfo($"Prepared map data {mapType} for world {worldUID} in {stopwatch.ElapsedMilliseconds,-4:F2} ms"); } private static bool GetPlayerExploration(Player player, long worldUID) { if (!player.m_customData.TryGetValue(WorldDataName(worldUID), out var value)) { return false; } BitArray bitArray = new BitArray(Utils.Decompress(Convert.FromBase64String(value))); if (exploration == null || exploration.Length != bitArray.Count) { exploration = new bool[bitArray.Count]; } bitArray.CopyTo(exploration, 0); return true; } public static void SavePlayerExploration() { Stopwatch stopwatch = Stopwatch.StartNew(); exploration = Minimap.instance.m_explored.ToArray(); if (NomapPrinter.showSharedMap.Value) { for (int i = 0; i < exploration.Length; i++) { exploration[i] = exploration[i] || Minimap.instance.m_exploredOthers[i]; } } BitArray bitArray = new BitArray(exploration); byte[] array = new byte[(bitArray.Length - 1) / 8 + 1]; bitArray.CopyTo(array, 0); SaveValue(WorldDataName(ZNet.instance.GetWorldUID()), Convert.ToBase64String(Utils.Compress(array))); NomapPrinter.LogInfo($"Exploration saved in {stopwatch.ElapsedMilliseconds,-4:F2} ms"); static void SaveValue(string key, string value) { if (Player.m_localPlayer.m_customData.ContainsKey(key)) { Player.m_localPlayer.m_customData[key] = value; } else { Player.m_localPlayer.m_customData.Add(key, value); } } } private static string WorldDataName(long worldUID) { return "NomapPrinter_Exploration_" + worldUID; } private static IEnumerator GetVanillaMap(int resolution, bool haveExploration) { yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)Minimap.instance != (Object)null)); 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"); bool m_showSharedMapData = Minimap.instance.m_showSharedMapData; bool replaceSharedMapToggle = NomapPrinter.showSharedMap.Value != Minimap.instance.m_showSharedMapData; if (replaceSharedMapToggle) { material.SetFloat("_SharedFade", NomapPrinter.showSharedMap.Value ? 1f : 0f); } Color32[] fogTex = Minimap.instance.m_fogTexture.GetPixels32(); bool combineFog = !NomapPrinter.preserveSharedMapFog.Value && NomapPrinter.showSharedMap.Value; Color[] pixels = Minimap.instance.m_fogTexture.GetPixels(); for (int i = 0; i < pixels.Length; i++) { if (haveExploration && !exploration[i]) { pixels[i] = Color.white; } else if (combineFog && 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 = (RenderTexture.active = new RenderTexture(resolution, resolution, 24)); 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, Time.fixedDeltaTime); ((Component)EnvMan.instance.m_dirLight).transform.forward = Vector3.down; 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(); Texture2D mapWithClouds = new Texture2D(resolution, resolution, (TextureFormat)3, false); mapWithClouds.ReadPixels(new Rect(0f, 0f, (float)resolution, (float)resolution), 0, 0); Color32[] mapClouds = mapWithClouds.GetPixels32(); Object.Destroy((Object)(object)mapWithClouds); material.SetTexture("_CloudTex", (Texture)(object)noClouds); camera.Render(); material.SetTexture("_CloudTex", clouds); EnvMan.instance.m_smoothDayFraction = m_smoothDayFraction; env.m_sunAngle = m_sunAngle; ((Component)EnvMan.instance.m_dirLight).transform.forward = m_dirLight; EnvMan.s_lastFrame--; EnvMan.instance.FixedUpdate(); if (replaceSharedMapToggle) { material.SetFloat("_SharedFade", m_showSharedMapData ? 1f : 0f); } if (combineFog) { Minimap.instance.m_fogTexture.SetPixels32(fogTex); Minimap.instance.m_fogTexture.Apply(); } if (!wasOpen) { Minimap.instance.SetMapMode((MapMode)1); } mapTexture.Reinitialize(resolution, resolution, (TextureFormat)3, false); mapTexture.ReadPixels(new Rect(0f, 0f, (float)resolution, (float)resolution), 0, 0); RenderTexture.active = null; Object.Destroy((Object)(object)mapPanelObject); Object.Destroy((Object)(object)cameraObject); Object.Destroy((Object)(object)renderTexture); Minimap.instance.m_mapTexture.GetPixels32(); Color32[] forest = Minimap.instance.m_forestMaskTexture.GetPixels32(); int resolutionMask = ((Texture)Minimap.instance.m_mapTexture).height; Color32[] map = mapTexture.GetPixels32(); float[] lerp = new float[resolution * resolution]; Thread internalThread = new Thread((ThreadStart)delegate { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) for (int j = 0; j < resolutionMask; j++) { for (int k = 0; k < resolutionMask; k++) { int num = resolution / resolutionMask; int num2 = j * resolutionMask + k; if (!((float)(int)forest[num2].g <= 0.1f) && !((float)(int)forest[num2].r > 0f) && !((float)(int)forest[num2].b > 0f)) { lerp[j * num * resolution + k * num] = (int)forest[num2].g; for (int l = -3 * num; l <= 3 * num; l++) { for (int m = -3 * num; m <= 3 * num; m++) { int num3 = Mathf.Clamp(j * num + l, 0, resolution - 1); int num4 = Mathf.Clamp(k * num + m, 0, resolution - 1); lerp[num3 * resolution + num4] += 0.1f; } } } } } for (int n = 0; n < lerp.Length; n++) { if (lerp[n] != 0f) { map[n] = Color32.Lerp(map[n], mapClouds[n], lerp[n]); } } }); NomapPrinter.ShowMessage(NomapPrinter.messageSaving.Value, (MessageType)2); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } if (NomapPrinter.showPins.Value) { yield return AddPinsOnMap(map, resolution); } mapTexture.SetPixels32(map); mapTexture.Apply(false); MapViewer.SetMapIsReady(); } 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 IEnumerator ApplyMapTexture(Color32[] map) { int mapResolution = (int)Math.Sqrt(map.Length); if (NomapPrinter.mapSize.Value == NomapPrinter.MapSize.Smooth) { int currentMapSize = mapResolution; mapResolution = currentMapSize * 2; Color32[] doublemap = (Color32[])(object)new Color32[mapResolution * mapResolution]; yield return DoubleMapSize(map, doublemap, currentMapSize, mapResolution); map = doublemap; } if (NomapPrinter.showPins.Value) { yield return AddPinsOnMap(map, mapResolution); } mapTexture.Reinitialize(mapResolution, mapResolution, (TextureFormat)3, false); mapTexture.SetPixels32(map); mapTexture.Apply(false); MapViewer.SetMapIsReady(); } private static void OverrideFogTexture() { Texture2D layerTexture = GetLayerTexture("fog", NomapPrinter.syncFogLayerFromServer.Value); if (!((Object)(object)layerTexture == (Object)null)) { MapGenerator.SetFogTexture(layerTexture); Object.Destroy((Object)(object)layerTexture); } } private static IEnumerator OverlayMarkingsLayer(bool overFog = false) { Texture2D markings = GetLayerTexture(overFog ? "overfog" : "underfog", overFog ? NomapPrinter.syncOverFogLayerFromServer.Value : NomapPrinter.syncUnderFogLayerFromServer.Value); if (!((Object)(object)markings == (Object)null)) { yield return MapGenerator.OverlayTextureOnMap(markings); Object.Destroy((Object)(object)markings); } } private static string[] CustomTextureFileNames(string textureType, string ext) { return new string[2] { $"{NomapPrinter.mapType.Value}.{ZNet.instance.GetWorldUID()}.{textureType}.{ext}", $"{NomapPrinter.mapType.Value}.{ZNet.instance.GetWorldName()}.{textureType}.{ext}" }; } private static Texture2D GetLayerTexture(string layer, bool loadFromServer) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (!TryGetLayerData(layer, loadFromServer, out var data, out var source)) { return null; } Texture2D val = new Texture2D(2, 2); if ((data != null && data.Length == 0) || !ImageConversion.LoadImage(val, data)) { Object.Destroy((Object)(object)val); return null; } NomapPrinter.LogInfo("Loaded " + layer + " layer from " + source); return val; } private static bool TryGetLayerData(string layer, bool loadFromServer, out byte[] data, out string source) { data = null; source = null; if (loadFromServer) { string serverTextureString = GetServerTextureString(layer); if (Utility.IsNullOrWhiteSpace(serverTextureString)) { return false; } data = Convert.FromBase64String(serverTextureString); source = "server"; return true; } if (Directory.Exists(NomapPrinter.configDirectory)) { foreach (FileInfo item in new DirectoryInfo(NomapPrinter.configDirectory).EnumerateFiles("*", SearchOption.AllDirectories)) { data = GetLayerFileData(item.Name, item.FullName, layer); if (data != null) { source = "file " + item.Name; return true; } } } return false; } private static string GetServerTextureString(string layer) { if (1 == 0) { } string result = layer switch { "explored" => NomapPrinter.customLayerExplored.Value, "fog" => NomapPrinter.customLayerFog.Value, "underfog" => NomapPrinter.customLayerUnderfog.Value, "overfog" => NomapPrinter.customLayerOverfog.Value, _ => "", }; if (1 == 0) { } return result; } private static byte[] GetLayerFileData(string name, string fullname, string layer) { string[] array = CustomTextureFileNames(layer, "png"); foreach (string value in array) { if (name.Equals(value, StringComparison.OrdinalIgnoreCase)) { try { return File.ReadAllBytes(fullname); } catch (Exception ex) { NomapPrinter.LogWarning("Error reading png file (" + name + ")! Error: " + ex.Message); } } } string[] array2 = CustomTextureFileNames(layer, "zpack"); foreach (string value2 in array2) { if (name.Equals(value2, StringComparison.OrdinalIgnoreCase)) { try { return ExploredMapData.GetPackedImageData(fullname); } catch (Exception ex2) { NomapPrinter.LogWarning("Error reading packed file (" + name + ")! Error: " + ex2.Message); } } } return null; } internal static string GetTextureString(string filename, string fullname, string layer) { byte[] layerFileData = GetLayerFileData(filename, fullname, layer); if (layerFileData != null) { NomapPrinter.LogInfo("Loaded " + layer + " layer from " + filename); return Convert.ToBase64String(layerFileData); } return null; } private static IEnumerator DoubleMapSize(Color32[] map, Color32[] doublemap, int currentMapSize, int mapSize) { for (int row = 0; row < currentMapSize; row++) { for (int col = 0; col < currentMapSize; col++) { doublemap[(row * 2 + 1) * mapSize + col * 2 + 1] = (doublemap[(row * 2 + 1) * mapSize + col * 2] = (doublemap[row * 2 * mapSize + col * 2 + 1] = (doublemap[row * 2 * mapSize + col * 2] = map[row * currentMapSize + col]))); } if (row % 50 == 0) { yield return null; } } } private static Color GetPixelColor(Biome biome, float height) { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_014e: 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_0051: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Invalid comparison between Unknown and I4 //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Invalid comparison between Unknown and I4 //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Invalid comparison between Unknown and I4 //IL_014a: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00f2: 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) if (height < -100f) { return Color.black; } if (1 == 0) { } Color result; if ((int)biome <= 16) { switch (biome - 1) { case 0: goto IL_0081; case 1: goto IL_00fa; case 3: goto IL_0111; case 2: goto IL_0138; } if ((int)biome != 8) { if ((int)biome != 16) { goto IL_0138; } result = new Color(0.906f, 0.671f, 0.47f); } else { result = new Color(0.42f, 0.455f, 0.247f); } } else if ((int)biome <= 64) { if ((int)biome != 32) { if ((int)biome != 64) { goto IL_0138; } result = new Color(0.85f, 0.85f, 1f); } else { result = new Color(0.48f, 0.125f, 0.125f); } } else if ((int)biome != 256) { if ((int)biome != 512) { goto IL_0138; } result = new Color(0.3f, 0.2f, 0.3f); } else { result = Color.blue; } goto IL_0146; IL_00fa: result = new Color(0.639f, 0.447f, 0.345f); goto IL_0146; IL_0146: if (1 == 0) { } return result; IL_0138: result = Minimap.instance.GetPixelColor(biome); goto IL_0146; IL_0111: result = Color.white; goto IL_0146; IL_0081: result = new Color(0.573f, 0.655f, 0.361f); goto IL_0146; } private static Color GetMaskColor(float wx, float wy, float height, Biome biome) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00af: Invalid comparison between Unknown and I4 //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Invalid comparison between Unknown and I4 //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Invalid comparison between Unknown and I4 //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_009e: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Invalid comparison between Unknown and I4 //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Invalid comparison between Unknown and I4 //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Invalid comparison between Unknown and I4 //IL_0157: Unknown result type (might be due to invalid IL or missing references) Color clearMask = MapGenerator.clearMask; if (height <= 0f) { float num = Mathf.Clamp01(WorldGenerator.GetAshlandsOceanGradient(wx, wy)) * 0.25f; if (num > 0f) { clearMask.a = Mathf.Min(0.5f + num / 2f, 0.99f); return clearMask; } num = Mathf.Clamp01(GetDeepNorthOceanGradient(wx, wy)) * 0.5f; if (num > 0f) { clearMask.a = Mathf.Min(num / 2f, 0.49f); } return clearMask; } if ((int)biome <= 8) { if ((int)biome != 1) { if ((int)biome == 8) { clearMask.r = ((NomapPrinter.mapType.Value == NomapPrinter.MapType.OldChart) ? 1f : 0.75f); } } else { clearMask.r = (WorldGenerator.InForest(new Vector3(wx, 0f, wy)) ? 1 : 0); } } else if ((int)biome != 16) { if ((int)biome != 32) { if ((int)biome == 512) { float forestFactor = WorldGenerator.GetForestFactor(new Vector3(wx, 0f, wy)); clearMask.g = 1f - Utils.SmoothStep(1.1f, 1.3f, forestFactor); } } else { Color val = default(Color); WorldGenerator.instance.GetAshlandsHeight(wx, wy, ref val, true); clearMask.b = val.a; } } else { clearMask.r = ((WorldGenerator.GetForestFactor(new Vector3(wx, 0f, wy)) < 0.8f) ? 1 : 0); } return clearMask; } private static float GetDeepNorthOceanGradient(float x, float y) { double num = (double)WorldGenerator.WorldAngle(x, y - WorldGenerator.ashlandsYOffset) * 100.0; return (float)(((double)DUtils.Length(x, y - WorldGenerator.ashlandsYOffset) - ((double)WorldGenerator.ashlandsMinDistance + num)) / 300.0); } private static IEnumerator AddPinsOnMap(Color32[] map, int mapSize) { float mx = default(float); float my = default(float); foreach (KeyValuePair<Vector3, string> pin in GetPinsToPrint()) { Minimap.instance.WorldToMapPoint(pin.Key, ref mx, ref my); if (mx >= 1f || my >= 1f || mx <= 0f || my <= 0f) { continue; } Color32[] iconPixels = pinIcons[pin.Value]; if (iconPixels != null) { int iconmx = Math.Max((int)(mx * (float)mapSize) - iconSize / 2, 0); int iconmy = Math.Max((int)(my * (float)mapSize) - iconSize / 2, 0); for (int row = 0; row < iconSize; row++) { for (int col = 0; col < iconSize; col++) { int pos = (iconmy + row) * mapSize + iconmx + col; Color32 iconPix = iconPixels[row * iconSize + col]; if (NomapPrinter.mapType.Value == NomapPrinter.MapType.Chart || NomapPrinter.mapType.Value == NomapPrinter.MapType.OldChart) { iconPix = Color32.Lerp(iconPix, MapGenerator.yellowMap, 0.33f * (float)(int)iconPix.a / 255f); } map[pos] = Color32.Lerp(map[pos], iconPix, (float)(int)iconPix.a / 255f); map[pos].a = byte.MaxValue; } } } yield return null; } } 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) Color pixel = Minimap.instance.m_fogTexture.GetPixel(x, y); return IsExploredColor(pixel); } private static bool IsExploredColor(Color explorationPos) { //IL_0001: 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) return explorationPos.r == 0f || (NomapPrinter.showSharedMap.Value && explorationPos.g == 0f); } private static List<KeyValuePair<Vector3, string>> GetPinsToPrint() { //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) List<KeyValuePair<Vector3, string>> list = new List<KeyValuePair<Vector3, string>>(); if (!NomapPrinter.showPins.Value) { return list; } if ((Object)(object)Minimap.instance == (Object)null) { return list; } int x = default(int); int y = default(int); foreach (PinData pin in Minimap.instance.m_pins) { if (((Object)pin.m_icon).name != "mapicon_start" && !NomapPrinter.showEveryPin.Value) { if ((NomapPrinter.showNonCheckedPins.Value && pin.m_checked) || (NomapPrinter.showMyPins.Value && pin.m_ownerID != 0)) { continue; } if (NomapPrinter.showExploredPins.Value) { Minimap.instance.WorldToPixel(pin.m_pos, ref x, ref y); if (!IsExplored(x, y) && (!IsMerchantPin(((Object)pin.m_icon).name) || !NomapPrinter.showMerchantPins.Value)) { continue; } } } if (IsShowablePinIcon(pin)) { list.Add(new KeyValuePair<Vector3, string>(pin.m_pos, ((Object)pin.m_icon).name)); } } return list; } private static bool IsIconConfiguredShowable(string pinIcon) { if (NomapPrinter.showEveryPin.Value) { return true; } if (1 == 0) { } bool result = pinIcon switch { "mapicon_boss_colored" => NomapPrinter.showPinBoss.Value, "mapicon_fire" => NomapPrinter.showPinFire.Value, "mapicon_hammer" => NomapPrinter.showPinHammer.Value, "mapicon_hildir" => NomapPrinter.showPinHildir.Value, "mapicon_hildir1" => NomapPrinter.showPinHildirQuest.Value, "mapicon_hildir2" => NomapPrinter.showPinHildirQuest.Value, "mapicon_hildir3" => NomapPrinter.showPinHildirQuest.Value, "mapicon_house" => NomapPrinter.showPinHouse.Value, "mapicon_pin" => NomapPrinter.showPinPin.Value, "mapicon_portal" => NomapPrinter.showPinPortal.Value, "mapicon_start" => NomapPrinter.showPinStart.Value, "mapicon_trader" => NomapPrinter.showPinTrader.Value, "mapicon_bed" => NomapPrinter.showPinBed.Value, "mapicon_death" => NomapPrinter.showPinDeath.Value, "mapicon_eventarea" => NomapPrinter.showPinEpicLoot.Value, "MapIconBounty" => NomapPrinter.showPinEpicLoot.Value, "TreasureMapIcon" => NomapPrinter.showPinEpicLoot.Value, "mapicon_bogwitch_camp" => NomapPrinter.showPinBogWitch.Value, _ => false, }; if (1 == 0) { } return result; } private static bool IsMerchantPin(string pinIcon) { if (1 == 0) { } bool result = pinIcon switch { "mapicon_hildir" => true, "mapicon_hildir1" => true, "mapicon_hildir2" => true, "mapicon_hildir3" => true, "mapicon_trader" => true, "mapicon_bogwitch_camp" => true, "MapIconBounty" => NomapPrinter.showPinEpicLoot.Value, "TreasureMapIcon" => NomapPrinter.showPinEpicLoot.Value, "mapicon_eventarea" => NomapPrinter.showPinEpicLoot.Value, _ => false, }; if (1 == 0) { } return result; } 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_0098: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00ea: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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>(Color.clear, 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; } private static void InitIconSize() { int num = 32; num = Mathf.CeilToInt((float)num * NomapPrinter.pinScale.Value); if (iconSize != num) { pinIcons.Clear(); iconSize = num; } } } internal static class MapViewer { [HarmonyPatch(typeof(Player), "Save")] public static class Player_Save_SaveMapData { public static void Prefix(Player __instance) { SaveMapToLocalFile(__instance); } } [HarmonyPatch(typeof(Player), "Load")] public static class Player_Load_LoadMapData { public static void Postfix(Player __instance) { if (NomapPrinter.modEnabled.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { if (NomapPrinter.mapStorage.Value == NomapPrinter.MapStorage.LocalFolder && LoadMapFromLocalFile(__instance)) { SetMapIsReady(); } else if (NomapPrinter.mapStorage.Value == NomapPrinter.MapStorage.Character) { MapMaker.PregenerateMap(); } } } } [HarmonyPatch(typeof(Hud), "Awake")] public static class Hud_Awake_AddIngameView { public static void Postfix(Hud __instance) { if (NomapPrinter.modEnabled.Value) { if (!Object.op_Implicit((Object)(object)__instance.m_rootObject.transform.Find("NomapPrinter_Parent"))) { AddIngameView(__instance.m_rootObject.transform); } SetupSharedMapFileWatcher(); } } } [HarmonyPatch(typeof(Minimap), "IsOpen")] public static class Minimap_IsOpen_EmulateMinimapOpenStatus { public static void Postfix(ref bool __result) { if (NomapPrinter.modEnabled.Value && Game.m_noMap && !__result && mapWindowInitialized) { if (!DisplayingWindow) { __result = hiddenFrames <= 2; } else { __result = true; } } } } [HarmonyPatch(typeof(Minimap), "ShowPinNameInput")] public static class Minimap_ShowPinNameInput_PreventPinAddition { public static bool Prefix() { if (!NomapPrinter.modEnabled.Value) { return true; } if (!Game.m_noMap) { return true; } return !NomapPrinter.allowInteractiveMapOnWrite.Value || !NomapPrinter.preventPinAddition.Value; } } private static bool mapWindowInitialized = false; public static GameObject parentObject; public static GameObject mapContent; public static RectTransform content; public static RectTransform viewport; public static Texture2D mapTexture = MapMaker.mapTexture; private static bool mapTextureIsReady = false; private static bool _displayingWindow = false; private static PropertyInfo _curLockState; private static PropertyInfo _curVisible; private static int _previousCursorLockState; private static bool _previousCursorVisible; private static DirectoryInfo pluginFolder; private static FileSystemWatcher fileSystemWatcher; private const string objectRootName = "NomapPrinter_Parent"; private const string objectScrollViewName = "NomapPrinter_ScrollView"; private const string objectViewPortName = "NomapPrinter_ViewPort"; private const string objectMapName = "NomapPrinter_Map"; private static readonly int layerUI = LayerMask.NameToLayer("UI"); public static int hiddenFrames; private static bool DisplayingWindow { get { return _displayingWindow; } set { //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (_displayingWindow == value) { return; } if (value && NomapPrinter.mapWindow.Value == NomapPrinter.MapWindow.ShowNearTheTable) { value = false; List<Piece> list = new List<Piece>(); Piece.GetAllPiecesInRadius(((Component)Player.m_localPlayer).transform.position, NomapPrinter.showNearTheTableDistance.Value, list); MapTable val = default(MapTable); foreach (Piece item in list) { value = ((Component)item).TryGetComponent<MapTable>(ref val); if (value) { break; } } if (!value) { NomapPrinter.ShowMessage("$piece_toofar", (MessageType)2); } } if (value && NomapPrinter.showMapBasePiecesRequirement.Value > 0 && Player.m_localPlayer.GetBaseValue() < NomapPrinter.showMapBasePiecesRequirement.Value) { value = false; NomapPrinter.ShowMessage(string.Format(NomapPrinter.messageNotEnoughBasePieces.Value, Player.m_localPlayer.GetBaseValue(), NomapPrinter.showMapBasePiecesRequirement.Value), (MessageType)2); } if (value && NomapPrinter.showMapComfortRequirement.Value > 0 && Player.m_localPlayer.GetComfortLevel() < NomapPrinter.showMapComfortRequirement.Value) { value = false; NomapPrinter.ShowMessage(string.Format(NomapPrinter.messageNotEnoughComfort.Value, Player.m_localPlayer.GetComfortLevel(), NomapPrinter.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); } } private static bool CanOpenMap() { return NomapPrinter.mapWindow.Value != 0 && NomapPrinter.mapWindow.Value != NomapPrinter.MapWindow.ShowOnInteraction; } private static bool ForceCloseMap(Player player) { return (Object)(object)player == (Object)null || ((Character)player).IsDead() || ((Character)player).InCutscene() || ((Character)player).IsTeleporting(); } public static void Start() { pluginFolder = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent; NomapPrinter.mapDataFromFile.ValueChanged += LoadMapFromSharedValue; Type typeFromHandle = typeof(Cursor); _curLockState = typeFromHandle.GetProperty("lockState", BindingFlags.Static | BindingFlags.Public); _curVisible = typeFromHandle.GetProperty("visible", BindingFlags.Static | BindingFlags.Public); } public static void Update() { if (!mapWindowInitialized || ZInput.VirtualKeyboardOpen) { return; } Player localPlayer = Player.m_localPlayer; if (ForceCloseMap(localPlayer)) { DisplayingWindow = false; return; } if (DisplayingWindow) { hiddenFrames = 0; } else { hiddenFrames++; } if (DisplayingWindow) { if (ZInput.GetKeyDown((KeyCode)27, true) || ZInput.GetButtonDown("Map") || (ZInput.GetButtonDown("JoyMap") && (!ZInput.GetButton("JoyLTrigger") || !ZInput.GetButton("JoyLBumper"))) || ZInput.GetButtonDown("JoyButtonB")) { DisplayingWindow = false; } } else if (CanOpenMap() && ((Character)localPlayer).TakeInput() && (ZInput.GetButtonDown("Map") || (ZInput.GetButtonDown("JoyMap") && (!ZInput.GetButton("JoyLTrigger") || !ZInput.GetButton("JoyLBumper")) && !ZInput.GetButton("JoyAltKeys")))) { ShowMap(); } if (DisplayingWindow) { if (ZInput.IsGamepadActive()) { UpdateGamepad(Time.deltaTime); } if (ZInput.IsMouseActive()) { UpdateMouse(); } } } public static void UpdateMouse() { SetUnlockCursor(0, cursorVisible: true); if (ZInput.GetMouseButton(1)) { ZoomMap(0f); } if (ZInput.GetMouseButton(2)) { CenterMap(); } float num = ZInput.GetMouseScrollWheel() * 0.02f; if (num != 0f) { ZoomMap(num); } } public static void UpdateGamepad(float dt) { if (ZInput.GetButton("JoyRStick")) { ZoomMap(0f); } if (ZInput.GetButton("JoyLStick")) { CenterMap(); } if (ZInput.GetButton("JoyLTrigger")) { ZoomMap((0f - NomapPrinter.mapGamepadZoomSpeed.Value) * dt * 1.5f); } if (ZInput.GetButton("JoyRTrigger")) { ZoomMap(NomapPrinter.mapGamepadZoomSpeed.Value * dt * 1.5f); } MoveMap(0f - ZInput.GetJoyLeftStickX(true), ZInput.GetJoyLeftStickY(true), dt); } public static void ShowMap() { if (!IsMapReady()) { NomapPrinter.ShowMessage(NomapPrinter.messageNotReady.Value, (MessageType)2); } else { DisplayingWindow = true; } } public static void ShowInteractiveMap() { if (Game.m_noMap && NomapPrinter.allowInteractiveMapOnWrite.Value) { Game.m_noMap = false; Minimap.instance.inputDelay = 1f; Minimap.instance.SetMapMode((MapMode)2); Game.m_noMap = true; } } public static void SetupSharedMapFileWatcher() { if (!Uti