using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using ConditionalConfigSync; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using NomapPrinter; using Splatform; using TMPro; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Serialization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Nomap Printer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Nomap Printer")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ba601320-0ece-4b27-b2a4-a1fe1ba817b3")] [assembly: AssemblyFileVersion("1.5.3")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.5.3.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LocalizationManager { [PublicAPI] public class Localizer { private const string defaultLanguage = "English"; private static readonly Dictionary>> PlaceholderProcessors; private static readonly Dictionary> loadedTexts; private static readonly ConditionalWeakTable localizationLanguage; private static readonly List> localizationObjects; private static BaseUnityPlugin? _plugin; private static readonly List fileExtensions; private static BaseUnityPlugin Plugin { get { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (_plugin == null) { IEnumerable source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out string value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out Dictionary> value2)) { text = value2.Aggregate(text, (string current, KeyValuePair> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder(string key, string placeholder, ConfigEntry config, Func? convertConfigValue = null) where T : notnull { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary>(); } config.SettingChanged += delegate { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List> list = new List>(); foreach (WeakReference localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference item in list) { localizationObjects.Remove(item); } } public static IEnumerator Load() { yield return (object)new WaitUntil((Func)(() => PlatformManager.DistributionPlatform != null && PlatformInitializer.PreferencesInitialized)); if (string.IsNullOrEmpty(PlatformPrefs.GetString("language", ""))) { PlatformPrefs.SetString("language", "English"); } LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); } private static void LoadLocalization(Localization __instance, string language) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference(__instance)); } localizationLanguage.Add(__instance, language); Dictionary localizationFiles = new Dictionary(); string[] prefixes = new string[2] { Plugin.Info.Metadata.Name + ".", Plugin.Info.Metadata.Name.Replace(" ", "") + "." }; Scan(Paths.ConfigPath, warn: true); Scan(Paths.PluginPath, warn: false); byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + Plugin.Info.Metadata.Name + ". Expected an embedded resource Translations/English.json or Translations/English.yml."); } Dictionary dictionary = ((BuilderSkeleton)new DeserializerBuilder()).IgnoreFields().Build().Deserialize>(Encoding.UTF8.GetString(array)); if (dictionary == null) { throw new Exception("Localization for mod " + Plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text = null; if (language != "English") { if (localizationFiles.ContainsKey(language)) { text = File.ReadAllText(localizationFiles[language]); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text = Encoding.UTF8.GetString(array2); } } } if (text == null && localizationFiles.ContainsKey("English")) { text = File.ReadAllText(localizationFiles["English"]); } if (text != null) { Dictionary dictionary2; try { dictionary2 = ((BuilderSkeleton)new DeserializerBuilder()).IgnoreFields().Build().Deserialize>(text) ?? new Dictionary(); } catch (Exception arg) { global::NomapPrinter.NomapPrinter.LogInfo($"Failed to deserialize localization for language '{language}'. Using base localization only.\n{arg}"); dictionary2 = new Dictionary(); } foreach (KeyValuePair item in dictionary2) { dictionary[item.Key] = item.Value; } } loadedTexts[language] = dictionary; foreach (KeyValuePair item2 in dictionary) { UpdatePlaceholderText(__instance, item2.Key); } void Scan(string root, bool warn) { foreach (string item3 in from f in Directory.GetFiles(root, "*.*", SearchOption.AllDirectories) where fileExtensions.Contains(Path.GetExtension(f)) select f) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item3); string[] array3 = prefixes; foreach (string text2 in array3) { if (fileNameWithoutExtension.StartsWith(text2)) { string text3 = fileNameWithoutExtension.Substring(text2.Length); if (!string.IsNullOrWhiteSpace(text3)) { if (localizationFiles.ContainsKey(text3)) { if (warn) { global::NomapPrinter.NomapPrinter.LogInfo("Duplicate localization '" + text3 + "' for " + Plugin.Info.Metadata.Name + ". Skipping " + item3); } } else { localizationFiles[text3] = item3; } } break; } } } } } static Localizer() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown PlaceholderProcessors = new Dictionary>>(); loadedTexts = new Dictionary>(); localizationLanguage = new ConditionalWeakTable(); localizationObjects = new List>(); fileExtensions = new List { ".json", ".yml" }; Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static byte[]? LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } public static byte[]? ReadEmbeddedFileBytes(string resourceFileName, Assembly? containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault((string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace NomapPrinter { internal static class InteractiveMap { [HarmonyPatch(typeof(Minimap), "SetMapMode")] private static class Minimap_SetMapMode_ResetInteractiveState { private static void Prefix(Minimap __instance, MapMode mode) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 if (active && (int)__instance.m_mode == 2 && (int)mode != 2) { SaveCurrentMapCenter(__instance, Player.m_localPlayer); } } private static void Postfix(Minimap __instance) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 if (active && (int)__instance.m_mode != 2) { ResetHiddenPins(__instance); active = false; } } } [HarmonyPatch(typeof(Minimap), "OnDestroy")] private static class Minimap_OnDestroy_ResetInteractiveState { private static void Postfix() { hiddenPins.Clear(); active = false; } } [HarmonyPatch(typeof(Minimap), "UpdateMap")] private static class Minimap_UpdateMap_KeepConfiguredCenter { private static void Prefix(Minimap __instance, Player player) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_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_004d: Unknown result type (might be due to invalid IL or missing references) if (IsOpen && NomapPrinter.doNotCenterInteractiveMapOnPlayer.Value && !((Object)(object)player == (Object)null)) { Vector3 position = ((Component)player).transform.position; __instance.m_mapOffset += lastPlayerPosition - position; lastPlayerPosition = position; } } private static void Postfix(Minimap __instance, Player player) { if (IsOpen) { SaveCurrentMapCenter(__instance, player); } } } [HarmonyPatch(typeof(Minimap), "UpdatePlayerMarker")] private static class Minimap_UpdatePlayerMarker_ApplyInteractiveVisibility { private static void Postfix(Minimap __instance) { ApplyPlayerMarkerVisibility(__instance); } } [HarmonyPatch(typeof(Minimap), "DelayActivation")] private static class Minimap_DelayActivation_KeepFilteredPinNamesHidden { private static void Postfix(GameObject go, ref IEnumerator __result) { if (__result != null) { __result = KeepPinNameHidden(__result, go); } } } [HarmonyPatch(typeof(Minimap), "UpdatePins")] private static class Minimap_UpdatePins_ApplyInteractiveFilters { private static void Postfix(Minimap __instance) { if (!IsOpen || __instance.m_pins == null) { return; } foreach (PinData pin in __instance.m_pins) { if (NomapPrinter.applyPinFiltersToInteractiveMap.Value && !MapMaker.ShouldShowPin(pin)) { hiddenPins.Add(pin); HidePinVisuals(pin); } else if (hiddenPins.Remove(pin)) { __instance.DestroyPinMarker(pin); __instance.m_pinUpdateRequired = true; } } } } private static readonly HashSet hiddenPins = new HashSet(); private static bool active; private static Vector3 lastPlayerPosition; private static bool hasLastMapCenter; private static Vector3 lastMapCenter; internal static bool IsOpen => active && (Object)(object)Minimap.instance != (Object)null && (int)Minimap.instance.m_mode == 2; public static void Show() { //IL_006d: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00b8: 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) Minimap instance = Minimap.instance; Player localPlayer = Player.m_localPlayer; if ((Object)(object)instance == (Object)null || (Object)(object)localPlayer == (Object)null) { return; } active = true; bool noMap = Game.m_noMap; try { Game.m_noMap = false; instance.inputDelay = 1f; instance.SetMapMode((MapMode)2); } catch { active = false; throw; } finally { Game.m_noMap = noMap; } lastPlayerPosition = ((Component)localPlayer).transform.position; if (NomapPrinter.doNotCenterInteractiveMapOnPlayer.Value) { Vector3 val = (hasLastMapCenter ? lastMapCenter : Vector3.zero); instance.m_mapOffset = val - lastPlayerPosition; instance.CenterMap(val); lastMapCenter = val; hasLastMapCenter = true; } ApplyPlayerMarkerVisibility(instance); instance.m_pinUpdateRequired = true; instance.UpdatePins(); } private static void ApplyPlayerMarkerVisibility(Minimap minimap) { if (IsOpen && NomapPrinter.hidePlayerMarkerOnInteractiveMap.Value) { if ((Object)(object)minimap.m_largeMarker != (Object)null) { ((Component)minimap.m_largeMarker).gameObject.SetActive(false); } if ((Object)(object)minimap.m_largeShipMarker != (Object)null) { ((Component)minimap.m_largeShipMarker).gameObject.SetActive(false); } } } private static void HidePinVisuals(PinData pin) { if (pin != null) { if ((Object)(object)pin.m_uiElement != (Object)null) { ((Component)pin.m_uiElement).gameObject.SetActive(false); } PinNameData namePinData = pin.m_NamePinData; if ((Object)(object)((namePinData != null) ? namePinData.PinNameGameObject : null) != (Object)null) { pin.m_NamePinData.PinNameGameObject.SetActive(false); } } } private static bool ShouldKeepPinNameHidden(GameObject pinNameGameObject) { if (!IsOpen || !NomapPrinter.applyPinFiltersToInteractiveMap.Value || (Object)(object)pinNameGameObject == (Object)null) { return false; } foreach (PinData hiddenPin in hiddenPins) { object obj; if (hiddenPin == null) { obj = null; } else { PinNameData namePinData = hiddenPin.m_NamePinData; obj = ((namePinData != null) ? namePinData.PinNameGameObject : null); } if ((Object)obj == (Object)(object)pinNameGameObject) { return true; } } return false; } private static IEnumerator KeepPinNameHidden(IEnumerator original, GameObject pinNameGameObject) { try { while (original.MoveNext()) { yield return original.Current; if (ShouldKeepPinNameHidden(pinNameGameObject)) { pinNameGameObject.SetActive(false); } } if (ShouldKeepPinNameHidden(pinNameGameObject)) { pinNameGameObject.SetActive(false); } } finally { if (original is IDisposable disposable) { disposable.Dispose(); } } } private static void ResetHiddenPins(Minimap minimap) { foreach (PinData hiddenPin in hiddenPins) { if (hiddenPin != null) { minimap.DestroyPinMarker(hiddenPin); } } hiddenPins.Clear(); } private static void SaveCurrentMapCenter(Minimap minimap, Player player) { //IL_002c: 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_003c: Unknown result type (might be due to invalid IL or missing references) if (NomapPrinter.doNotCenterInteractiveMapOnPlayer.Value && !((Object)(object)minimap == (Object)null) && !((Object)(object)player == (Object)null)) { lastMapCenter = ((Component)player).transform.position + minimap.m_mapOffset; hasLastMapCenter = true; } } internal static void ResetSession() { //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_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) hiddenPins.Clear(); active = false; hasLastMapCenter = false; lastMapCenter = Vector3.zero; lastPlayerPosition = Vector3.zero; } } 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; private static Color32[] contours; private static int contoursRes; 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)(() => (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; contours = null; } public static void SetFogTexture(Texture2D fog) { SetFogTexture(fog.GetPixels32()); } public static void SetContoursTexture(Color32[] newContours) { contours = (Color32[])(object)new Color32[newContours.Length]; contoursRes = (int)Math.Sqrt(newContours.Length); newContours.CopyTo(contours, 0); } 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[] outtex = Result; yield return OverlayTexture(outtex, oceanTexture); outtex = Result; yield return GetSolidColour(yellowMap); Color32[] offYellow = Result; yield return LerpTextures(outtex, offYellow); outtex = Result; yield return LerpTextures(outtex, offYellow); outtex = Result; yield return LerpTextures(outtex, offYellow); outtex = Result; yield return AddPerlinNoise(outtex, 128, 16); outtex = Result; yield return ApplyForestMaskTexture(outtex, ForestTexture, 0.95f); outtex = Result; yield return GenerateContourMap(Heightmap, graduationHeight, 128); Color32[] contours = Result; yield return OverlayTexture(outtex, contours); } public static IEnumerator GenerateChartMap(int graduationHeight) { yield return GenerateOceanTexture(Heightmap, MapTexture, 0.15f); Color32[] oceanTexture = Result; yield return ReplaceAbyssWithColor(MapTexture, abyssColor, yellowMap); Color32[] outtex = Result; yield return OverlayTexture(outtex, oceanTexture); outtex = Result; yield return GetSolidColour(yellowMap); Color32[] offYellow = Result; yield return LerpTextures(outtex, offYellow); outtex = Result; yield return AddPerlinNoise(outtex, 128, 16); outtex = Result; yield return ApplyForestMaskTexture(outtex, ForestTexture); outtex = Result; yield return GenerateContourMap(Heightmap, graduationHeight, 128); Color32[] contours = Result; yield return OverlayTexture(outtex, contours); } public static IEnumerator GenerateSatelliteImage() { yield return GenerateOceanTexture(Heightmap, MapTexture); Color32[] oceanTexture = Result; yield return AddPerlinNoise(oceanTexture, 4, 64); oceanTexture = Result; yield return ReplaceAbyssWithSpace(MapTexture, abyssColor); Color32[] outtex = Result; yield return OverlayTexture(outtex, oceanTexture); outtex = Result; yield return CreateShadowMap(Heightmap, 23); Color32[] shadowmap = Result; yield return DarkenTextureLinear(outtex, 20); outtex = Result; yield return ApplyForestMaskTexture(outtex, ForestTexture); outtex = Result; yield return GenerateContourMap(Heightmap, 128, 64); Color32[] contours = Result; yield return OverlayTexture(outtex, contours); outtex = Result; yield return OverlayTexture(outtex, shadowmap); } public static IEnumerator GenerateTopographicalMap(int graduationHeight) { yield return GenerateOceanTexture(Heightmap, MapTexture); Color32[] oceanTexture = Result; yield return AddPerlinNoise(oceanTexture, 4, 64); oceanTexture = Result; yield return ReplaceAbyssWithSpace(MapTexture, abyssColor); Color32[] outtex = Result; yield return OverlayTexture(outtex, oceanTexture); outtex = Result; yield return CreateShadowMap(Heightmap, 23); Color32[] shadowmap = Result; yield return DarkenTextureLinear(outtex, 20); outtex = Result; yield return ApplyForestMaskTexture(outtex, ForestTexture); outtex = Result; yield return GenerateContourMap(Heightmap, graduationHeight, 128); Color32[] contours = Result; yield return OverlayTexture(outtex, contours); outtex = Result; yield return OverlayTexture(outtex, 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 int[] BuildExploredIntegral() { int textureSize = TextureSize; int num = textureSize + 1; int[] array = new int[num * num]; for (int i = 1; i <= textureSize; i++) { int num2 = i * num; int num3 = (i - 1) * num; int num4 = (i - 1) * textureSize; for (int j = 1; j <= textureSize; j++) { int num5 = (ExploredData[num4 + j - 1] ? 1 : 0); array[num2 + j] = num5 + array[num2 + j - 1] + array[num3 + j] - array[num3 + j - 1]; } } return array; } private static bool IsNearExplored(int[] integral, int x, int y, int range) { return GetExploredCount(integral, x, y, range) > 0; } private static int GetExploredCount(int[] integral, int x, int y, int range) { int textureSize = TextureSize; int num = textureSize + 1; int num2 = Math.Max(0, x - range); int num3 = Math.Min(textureSize - 1, x + range); int num4 = Math.Max(0, y - range); int num5 = Math.Min(textureSize - 1, y + range); int num6 = num2; int num7 = num4; int num8 = num3 + 1; int num9 = num5 + 1; return integral[num8 * num + num9] - integral[num6 * num + num9] - integral[num8 * num + num7] + integral[num6 * num + num7]; } private static float GetContourDistanceAlpha(int[] exploredIntegral, int x, int y, int contourDistance, float contourAlphaMax) { int num = Math.Max(1, contourDistance); int num2 = Math.Max(num + 1, contourDistance * 2); int exploredCount = GetExploredCount(exploredIntegral, x, y, num); if (exploredCount > 0) { return contourAlphaMax; } int exploredCount2 = GetExploredCount(exploredIntegral, x, y, num2); if (exploredCount2 <= 0) { return 0f; } int num3 = (num * 2 + 1) * (num * 2 + 1); int num4 = (num2 * 2 + 1) * (num2 * 2 + 1); int num5 = Math.Max(1, num4 - num3); float num6 = (float)(exploredCount2 - exploredCount) / (float)num5; float num7 = Mathf.Clamp01(num6 * 5f); float num8 = Mathf.Pow(num7, 1.5f); return contourAlphaMax * num8; } private static IEnumerator StylizeFog() { bool customFog = fog != null; if (!customFog) { yield return GetPerlin(128, 16); fog = Result; fogRes = TextureSize; } float contourAlphaFactor = Math.Max(0f, NomapPrinter.fogContoursAlpha.Value); int contourDistance = Math.Max(0, NomapPrinter.fogContoursDistance.Value); bool haveContours = NomapPrinter.fogContoursEnabled.Value && contours != null && contourDistance > 0; int[] exploredIntegral = (haveContours ? BuildExploredIntegral() : null); 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) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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); } if (haveContours && IsNearExplored(exploredIntegral, i, j, contourDistance * 2)) { Color32 val2 = contours[i % contoursRes * contoursRes + j % contoursRes]; if (val2.a > 0) { float contourDistanceAlpha = GetContourDistanceAlpha(exploredIntegral, i, j, contourDistance, contourAlphaFactor); float num2 = (float)(int)val2.a / 255f * contourDistanceAlpha; Result[num] = Color32.Lerp(Result[num], val2, num2); Result[num].a = byte.MaxValue; } } } } } }); internalThread.Start(); while (internalThread.IsAlive) { yield return null; } } public 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 = 2; public long worldUID; public Thread[] threads; public bool initialized = false; public Texture2D m_mapTexture; public Texture2D m_forestTexture; public Texture2D m_heightmap; public Texture2D m_contoursTexture; 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)(() => 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((IEnumerable)threads, (Action)delegate(Thread thread) { thread.Start(); }); } yield return (object)new WaitWhile((Func)(() => 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; yield return MapGenerator.GenerateContourMap(m_heightmapArray, 8, 128); m_contoursTexture = new Texture2D(TextureSize, TextureSize, (TextureFormat)4, false) { name = "NomapPrinter_m_contoursTexture", wrapMode = (TextureWrapMode)1 }; m_contoursTexture.SetPixels32(MapGenerator.Result); m_contoursTexture.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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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); int num = val.ReadInt(); if (2 != num) { 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()); if ((Object)(object)m_contoursTexture == (Object)null) { m_contoursTexture = new Texture2D(2, 2); } ImageConversion.LoadImage(m_contoursTexture, 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(2); 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)); val.Write(ImageConversion.EncodeToPNG(m_contoursTexture)); 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); Object.Destroy((Object)(object)m_contoursTexture); } } 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 pinIcons = new Dictionary(); private static readonly Dictionary pinIconsDouble = new Dictionary(); private static Texture2D iconSpriteTexture; private static int iconSize = 32; private static long worldUID; private static Texture2D noClouds; private static bool[] exploration; private static Color32[] cachedContours; private static long cachedContoursWorldUID; private static int cachedContoursTextureSize; private static Color32[] stripeBuffer; private static int GetPinGroup(PinType type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected I4, but got Unknown switch ((int)type) { case 4: case 7: case 10: case 12: case 13: return 0; case 0: case 1: case 2: case 3: case 6: return 1; case 5: case 9: case 11: return 3; case 14: case 15: case 16: return 4; case 8: return 5; default: return 2; } } 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)); } public static void PreloadExploredMap() { worldUID = ZNet.instance.GetWorldUID(); if (exploredMapData == null) { exploredMapData = new ExploredMapData(); } if (NomapPrinter.mapType.Value != NomapPrinter.MapType.Vanilla) { if (exploredMapData.LoadExploredMap()) { NomapPrinter.LogInfo($"Preloaded map data for world {worldUID} {ZNet.instance.GetWorldName()}"); } if (NomapPrinter.fogContoursEnabled.Value && NomapPrinter.fogContoursDistance.Value > 0) { ((MonoBehaviour)NomapPrinter.instance).StartCoroutine(PrepareFogContours()); } } } 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_start", (MessageType)2); yield return GetVanillaMap(2048 * (int)NomapPrinter.mapSize.Value, haveExploration); } } else { if (!pregeneration) { NomapPrinter.ShowMessage("$nomapprinter_start", (MessageType)2); } if (!exploredMapData.LoadExploredMap()) { yield return PrepareTerrainData(); if (!pregeneration) { NomapPrinter.ShowMessage("$nomapprinter_saving", (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)(() => (Object)(object)Player.m_localPlayer != (Object)null)); if (haveExploration) { if (NomapPrinter.fogContoursEnabled.Value && NomapPrinter.fogContoursDistance.Value > 0) { yield return PrepareFogContours(); } 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_ready", (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_savedto " + filepath, (MessageType)1); } NomapPrinter.LogInfo("Finished Map Draw"); isWorking = false; } private static IEnumerator PrepareTerrainData() { yield return (object)new WaitUntil((Func)(() => 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 HasCachedContours() { return cachedContours != null && cachedContoursWorldUID == worldUID && cachedContoursTextureSize == WorldMapData.TextureSize; } private static void CacheContours(Color32[] contourData) { if (contourData != null && contourData.Length != 0) { cachedContours = (Color32[])(object)new Color32[contourData.Length]; contourData.CopyTo(cachedContours, 0); cachedContoursWorldUID = worldUID; cachedContoursTextureSize = WorldMapData.TextureSize; } } private static IEnumerator PrepareFogContours() { if (HasCachedContours()) { MapGenerator.SetContoursTexture(cachedContours); yield break; } if (worldMapData == null || !worldMapData.initialized || (Object)(object)worldMapData.m_contoursTexture == (Object)null) { yield return PrepareTerrainData(); } if (!((Object)(object)worldMapData?.m_contoursTexture == (Object)null)) { CacheContours(worldMapData.m_contoursTexture.GetPixels32()); MapGenerator.SetContoursTexture(cachedContours); } } 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)(() => (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.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_saving", (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(); ((Renderer)val2).sharedMaterial = material; MeshFilter val3 = val.AddComponent(); 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); } yield return ApplyMapTextureStriped(map, mapResolution); MapViewer.SetMapIsReady(); } private static IEnumerator ApplyMapTextureStriped(Color32[] map, int mapResolution) { if (((Texture)mapTexture).width != mapResolution || ((Texture)mapTexture).height != mapResolution) { mapTexture.Reinitialize(mapResolution, mapResolution, (TextureFormat)3, false); } int pixelsPerStripe = mapResolution * 64; int stripeCount = mapResolution / 64; if (stripeBuffer == null || stripeBuffer.Length != pixelsPerStripe) { stripeBuffer = (Color32[])(object)new Color32[pixelsPerStripe]; } for (int stripeIndex = 0; stripeIndex < stripeCount; stripeIndex++) { int y = stripeIndex * 64; int sourceOffset = y * mapResolution; Array.Copy(map, sourceOffset, stripeBuffer, 0, pixelsPerStripe); mapTexture.SetPixels32(0, y, mapResolution, 64, stripeBuffer); yield return null; } mapTexture.Apply(false); } 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 % 64 == 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_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; IL_00fa: result = new Color(0.639f, 0.447f, 0.345f); goto IL_0146; IL_0146: if (1 == 0) { } return result; } 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 + 4000f) * 100.0; return (float)(((double)DUtils.Length(x, y + 4000f) - (12000.0 + num)) / 300.0); } private static IEnumerator AddPinsOnMap(Color32[] map, int mapSize) { List> pinTexts = new List>(); float mx = default(float); float my = default(float); foreach (PinData pin in GetPinsToPrint()) { Minimap.instance.WorldToMapPoint(pin.m_pos, ref mx, ref my); if (mx >= 1f || my >= 1f || mx <= 0f || my <= 0f) { continue; } bool doubleSizeIcon = NomapPrinter.showPinsDoubleSize.Value && pin.m_doubleSize && NomapPrinter.mapSize.Value == NomapPrinter.MapSize.Smooth; Color32[] iconPixels = (doubleSizeIcon ? pinIconsDouble[((Object)pin.m_icon).name] : pinIcons[((Object)pin.m_icon).name]); int size = (doubleSizeIcon ? (iconSize * 2) : iconSize); if (iconPixels != null) { int posX = (int)(mx * (float)mapSize); int posY = (int)(my * (float)mapSize); int iconmx = Math.Max(posX - size / 2, 0); int iconmy = Math.Max(posY - size / 2, 0); for (int row = 0; row < size; row++) { for (int col = 0; col < size; col++) { int pos = (iconmy + row) * mapSize + iconmx + col; Color32 iconPix = iconPixels[row * size + col]; if (iconPix.a != 0 && NomapPrinter.pinsHildirQuestColored.Value) { byte alpha = iconPix.a; if ((int)pin.m_type == 14) { iconPix = Color32.Lerp(iconPix, Color32.op_Implicit(NomapPrinter.pinsHildirQuestPin1Color.Value), 0.5f); } else if ((int)pin.m_type == 15) { iconPix = Color32.Lerp(iconPix, Color32.op_Implicit(NomapPrinter.pinsHildirQuestPin2Color.Value), 0.5f); } else if ((int)pin.m_type == 16) { iconPix = Color32.Lerp(iconPix, Color32.op_Implicit(NomapPrinter.pinsHildirQuestPin3Color.Value), 0.5f); } iconPix.a = alpha; } 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; } } pinTexts.Add(Tuple.Create(posX, posY - (doubleSizeIcon ? ((int)((float)size * 0.7f)) : size) - NomapPrinter.pinTextOffset.Value, GetPinName(pin))); } yield return null; } if (NomapPrinter.pinTextEnabled.Value) { yield return MapPinTexts.DrawPinTexts(map, mapSize, pinTexts); } } private static string GetPinName(PinData pin) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 if (!Utility.IsNullOrWhiteSpace(pin.m_name) || !NomapPrinter.showMerchantPinsNames.Value) { return pin.m_name; } if ((int)pin.m_type != 8) { return ""; } string name = ((Object)pin.m_icon).name; if (1 == 0) { } string result = name switch { "mapicon_hildir" => "$npc_hildir", "mapicon_trader" => "$npc_haldor", "mapicon_bogwitch_camp" => "$npc_bogwitch", _ => "", }; if (1 == 0) { } return result; } private static bool IsExplored(int x, int y) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) Texture2D val = Minimap.instance?.m_fogTexture; if ((Object)(object)val == (Object)null || x < 0 || y < 0 || x >= ((Texture)val).width || y >= ((Texture)val).height) { return false; } return IsExploredColor(val.GetPixel(x, y)); } 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 bool IsPinToShowNotOwner(PinData pin) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected I4, but got Unknown PinType type = pin.m_type; if (1 == 0) { } bool result = (type - 8) switch { 1 => true, 6 => true, 7 => true, 8 => true, 0 => true, _ => false, }; if (1 == 0) { } return result; } private static List GetPinsToPrint() { List list = new List(); if ((Object)(object)Minimap.instance == (Object)null) { return list; } foreach (PinData pin in Minimap.instance.m_pins) { if (ShouldShowPin(pin) && (pinIcons.ContainsKey(((Object)pin.m_icon).name) || AddPinIconToCache(pin.m_icon))) { list.Add(pin); } } return (from x in list.Select((PinData pin, int index) => (pin: pin, index: index)) orderby GetPinGroup(x.pin.m_type), x.index select x.pin).ToList(); } internal static bool ShouldShowPin(PinData pin) { //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Invalid comparison between Unknown and I4 //IL_01ae: 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) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) if (!NomapPrinter.showPins.Value || (Object)(object)Minimap.instance == (Object)null) { return false; } if ((Object)(object)pin?.m_icon == (Object)null) { return false; } if (((Object)pin.m_icon).name != "mapicon_start" && !NomapPrinter.showEveryPin.Value) { if (NomapPrinter.showNonCheckedPins.Value && pin.m_checked) { return false; } long num = (((Object)(object)Player.m_localPlayer != (Object)null) ? Player.m_localPlayer.GetPlayerID() : 0); if (NomapPrinter.showMyPins.Value && pin.m_ownerID != 0L && pin.m_ownerID != num && !IsPinToShowNotOwner(pin)) { return false; } if (NomapPrinter.showExploredPins.Value) { int x = default(int); int y = default(int); Minimap.instance.WorldToPixel(pin.m_pos, ref x, ref y); if (!IsExplored(x, y) && (!IsMerchantPin(((Object)pin.m_icon).name) || !NomapPrinter.showMerchantPins.Value)) { return false; } } } if (!IsIconConfiguredShowable(((Object)pin.m_icon).name)) { return false; } if ((int)pin.m_type == 4 && NomapPrinter.showLastDeathPin.Value && !NomapPrinter.showPinDeath.Value) { Game instance = Game.instance; PlayerProfile val = ((instance != null) ? instance.GetPlayerProfile() : null); if (val == null || pin.m_pos != val.GetDeathPoint()) { return false; } } return true; } 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 || NomapPrinter.showLastDeathPin.Value, "mapicon_eventarea" => NomapPrinter.showPinEpicLoot.Value && NomapPrinter.epicLootIsLoaded, "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 && NomapPrinter.epicLootIsLoaded, _ => false, }; if (1 == 0) { } return result; } private static bool AddPinIconToCache(Sprite icon) { GetIconPixels(icon, iconSize, out var pixels1x, out var pixels2x); if (pixels1x == null || pixels1x.Length <= 1) { return false; } pinIcons[((Object)icon).name] = pixels1x; pinIconsDouble[((Object)icon).name] = pixels2x; return true; } private static Color32[] BlitAndRead(Texture source, int size) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) RenderTexture active = RenderTexture.active; RenderTexture temporary = RenderTexture.GetTemporary(size, size, 0); ((Texture)temporary).filterMode = (FilterMode)1; Graphics.Blit(source, temporary); RenderTexture.active = temporary; Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); val.ReadPixels(new Rect(0f, 0f, (float)size, (float)size), 0, 0); val.Apply(); Color32[] pixels = val.GetPixels32(); Object.Destroy((Object)(object)val); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); return pixels; } private static void GetIconPixels(Sprite icon, int baseSize, out Color32[] pixels1x, out Color32[] pixels2x) { pixels1x = null; pixels2x = null; Texture2D textureFromSprite = GetTextureFromSprite(icon); if (!((Object)(object)textureFromSprite == (Object)null)) { pixels2x = BlitAndRead((Texture)(object)textureFromSprite, baseSize * 2); pixels1x = BlitAndRead((Texture)(object)textureFromSprite, baseSize); } } 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.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(); pinIconsDouble.Clear(); iconSize = num; } } } internal static class MapPinTexts { private struct CachedText { public Color32[] Pixels; public int Width; public int Height; } private const int TextLayer = 31; private const string TextObjectName = "MapTMPText"; private const string TextCamObjectName = "MapTMPTextCam"; private static TMP_FontAsset defaultFontAsset = null; private static GameObject textGO; private static TextMeshPro tmp; private static GameObject camGO; private static Camera cam; private static RenderTexture rt; private static Texture2D readTex; private static readonly Dictionary textCache = new Dictionary(); internal static void ClearPinFont() { defaultFontAsset = null; textCache.Clear(); } private static void EnsureFontAsset() { if ((Object)(object)defaultFontAsset != (Object)null) { return; } TMP_FontAsset val = null; Minimap instance = Minimap.instance; object obj; if (instance == null) { obj = null; } else { GameObject pinNamePrefab = instance.m_pinNamePrefab; if (pinNamePrefab == null) { obj = null; } else { TMP_Text componentInChildren = pinNamePrefab.GetComponentInChildren(); obj = ((componentInChildren != null) ? componentInChildren.font : null); } } TMP_FontAsset val2 = (TMP_FontAsset)obj; if (val2 != null) { val = val2; } if (!Utility.IsNullOrWhiteSpace(NomapPrinter.pinTextFont.Value)) { TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll(); foreach (TMP_FontAsset val3 in array) { if (((Object)val3).name.Contains(NomapPrinter.pinTextFont.Value, StringComparison.OrdinalIgnoreCase)) { defaultFontAsset = val3; return; } if ((Object)(object)val == (Object)null && ((Object)val3).name.Contains("Fallback", StringComparison.OrdinalIgnoreCase)) { val = val3; } } } if (!((Object)(object)defaultFontAsset == (Object)null)) { return; } defaultFontAsset = val; if (!Utility.IsNullOrWhiteSpace(NomapPrinter.pinTextFont.Value)) { if ((Object)(object)defaultFontAsset != (Object)null) { NomapPrinter.LogInfo("Unable to find font " + NomapPrinter.pinTextFont.Value + ", falling back to " + ((Object)defaultFontAsset).name); } else { NomapPrinter.LogInfo("Unable to find font " + NomapPrinter.pinTextFont.Value + " or fallback font"); } } } private static void EnsureRenderObjects() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //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_00a1: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)textGO == (Object)null) { textGO = new GameObject("MapTMPText") { layer = 31 }; TMP_FontAsset val = TMP_Settings.defaultFontAsset; TMP_Settings.defaultFontAsset = defaultFontAsset; tmp = textGO.AddComponent(); TMP_Settings.defaultFontAsset = val; ((TMP_Text)tmp).alignment = (TextAlignmentOptions)514; ((TMP_Text)tmp).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)tmp).richText = false; } if ((Object)(object)camGO == (Object)null) { camGO = new GameObject("MapTMPTextCam") { layer = 31 }; cam = camGO.AddComponent(); cam.orthographic = true; cam.clearFlags = (CameraClearFlags)2; cam.backgroundColor = Color.clear; cam.cullingMask = int.MinValue; } } private static void ChangeRenderObjectsVisibility(bool active = true) { GameObject obj = textGO; if (obj != null) { obj.SetActive(active); } GameObject obj2 = camGO; if (obj2 != null) { obj2.SetActive(active); } } private static void EnsureRenderTargets(int width, int height) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown if (width <= 0 || height <= 0) { return; } if ((Object)(object)rt == (Object)null || ((Texture)rt).width != width || ((Texture)rt).height != height) { RenderTexture obj = rt; if (obj != null) { obj.Release(); } rt = new RenderTexture(width, height, 0, (RenderTextureFormat)0); } if ((Object)(object)readTex == (Object)null || ((Texture)readTex).width != width || ((Texture)readTex).height != height) { if ((Object)(object)readTex != (Object)null) { Object.Destroy((Object)(object)readTex); } readTex = new Texture2D(width, height, (TextureFormat)4, false); } } private static string BuildCacheKey(string text) { //IL_0029: 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_0052: 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_0080: Unknown result type (might be due to invalid IL or missing references) return $"{text}|{NomapPrinter.pinTextSize.Value}|{NomapPrinter.pinTextFontStyle.Value}|{NomapPrinter.pinTextFontColor.Value.r},{NomapPrinter.pinTextFontColor.Value.g},{NomapPrinter.pinTextFontColor.Value.b},{NomapPrinter.pinTextFontColor.Value.a}"; } private static Color32[] RenderText(string text, out int width, out int height) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) width = 0; height = 0; if (Utility.IsNullOrWhiteSpace(text)) { return null; } if ((Object)(object)defaultFontAsset == (Object)null) { return null; } string key = BuildCacheKey(text); if (textCache.TryGetValue(key, out var value)) { width = value.Width; height = value.Height; return value.Pixels; } ((TMP_Text)tmp).font = defaultFontAsset; ((TMP_Text)tmp).text = text; ((TMP_Text)tmp).fontSize = NomapPrinter.pinTextSize.Value * 10; ((TMP_Text)tmp).fontStyle = NomapPrinter.pinTextFontStyle.Value; ((Graphic)tmp).color = NomapPrinter.pinTextFontColor.Value; ((TMP_Text)tmp).ForceMeshUpdate(false, false); Bounds textBounds = ((TMP_Text)tmp).textBounds; width = Mathf.CeilToInt(((Bounds)(ref textBounds)).size.x); height = Mathf.CeilToInt(((Bounds)(ref textBounds)).size.y); if (width <= 0 || height <= 0) { return null; } textGO.transform.position = new Vector3(0f - ((Bounds)(ref textBounds)).center.x, 0f - ((Bounds)(ref textBounds)).center.y, 0f); EnsureRenderTargets(width, height); float num = (((Bounds)(ref textBounds)).min.y + ((Bounds)(ref textBounds)).max.y) * 0.5f; ((Component)cam).transform.position = new Vector3(0f, num, -10f); cam.orthographicSize = (float)height / 2f; cam.targetTexture = rt; RenderTexture.active = rt; cam.Render(); readTex.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0); readTex.Apply(); RenderTexture.active = null; Color32[] pixels = readTex.GetPixels32(); textCache[key] = new CachedText { Pixels = pixels, Width = width, Height = height }; return pixels; } private static void DrawTextLayer(Color32[] map, int mapSize, Color32[] textPixels, int w, int h, int startX, int startY, Color32 color) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //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) for (int i = 0; i < h; i++) { int num = startY + i; if (num < 0 || num >= mapSize) { continue; } int num2 = num * mapSize; int num3 = i * w; for (int j = 0; j < w; j++) { int num4 = startX + j; if (num4 >= 0 && num4 < mapSize) { Color32 val = textPixels[num3 + j]; if (val.a != 0) { int num5 = num2 + num4; Color32 val2 = color; val2.a = (byte)(val.a * color.a / 255); map[num5] = Color32.Lerp(map[num5], val2, (float)(int)val2.a / 255f); map[num5].a = byte.MaxValue; } } } } } private static void DrawTextOnMap(Color32[] map, int mapSize, string text, int centerX, int topY) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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) int width; int height; Color32[] array = RenderText(text, out width, out height); if (array == null) { return; } int num = centerX - width / 2; DrawTextLayer(map, mapSize, array, width, height, num + 1, topY - 1, new Color32((byte)0, (byte)0, (byte)0, (byte)120)); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (i != 0 || j != 0) { DrawTextLayer(map, mapSize, array, width, height, num + i, topY + j, new Color32((byte)0, (byte)0, (byte)0, (byte)200)); } } } DrawTextLayer(map, mapSize, array, width, height, num, topY, Color32.op_Implicit(Color.white)); } internal static IEnumerator DrawPinTexts(Color32[] map, int mapSize, List> pinTexts) { EnsureFontAsset(); EnsureRenderObjects(); ChangeRenderObjectsVisibility(); foreach (Tuple pin in pinTexts) { string localized = Localization.instance.Localize(pin.Item3); DrawTextOnMap(map, mapSize, localized, pin.Item1, pin.Item2); yield return null; } ChangeRenderObjectsVisibility(active: false); } } 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(); } if (NomapPrinter.mapStorage.Value == NomapPrinter.MapStorage.LocalFolder) { MapMaker.PreloadExploredMap(); } } } } [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 { [HarmonyPriority(800)] public static bool Prefix() { return !PreventInteractiveMapPinChanges(); } } [HarmonyPatch(typeof(Minimap), "OnMapDblClick")] public static class Minimap_OnMapDblClick_PreventPinAddition { [HarmonyPriority(800)] public static bool Prefix() { return !PreventInteractiveMapPinChanges(); } } [HarmonyPatch(typeof(Minimap), "OnMapLeftClick")] public static class Minimap_OnMapLeftClick_PreventPinStateChange { [HarmonyPriority(800)] public static bool Prefix() { return !PreventInteractiveMapPinChanges(); } } [HarmonyPatch(typeof(Minimap), "OnMapRightClick")] public static class Minimap_OnMapRightClick_PreventPinRemoval { [HarmonyPriority(800)] public static bool Prefix() { return !PreventInteractiveMapPinChanges(); } } [HarmonyPatch(typeof(Minimap), "RemovePin", new Type[] { typeof(Vector3), typeof(float) })] public static class Minimap_RemovePin_PreventPinRemoval { [HarmonyPriority(800)] public static bool Prefix(ref bool __result) { if (!PreventInteractiveMapPinChanges()) { return true; } __result = false; return false; } } private readonly struct InteractivePinState { public readonly PinData Pin; public readonly bool Checked; public readonly long OwnerID; public InteractivePinState(PinData pin) { Pin = pin; Checked = pin.m_checked; OwnerID = pin.m_ownerID; } } [HarmonyPatch(typeof(Minimap), "UpdateMap")] public static class Minimap_UpdateMap_PreventGamepadPinStateChange { private static void Prefix(Minimap __instance, out List __state) { __state = null; if (!PreventInteractiveMapPinChanges() || __instance.m_pins == null || !ZInput.GetButtonDown("JoyTabLeft")) { return; } __state = new List(__instance.m_pins.Count); foreach (PinData pin in __instance.m_pins) { __state.Add(new InteractivePinState(pin)); } } private static void Postfix(Minimap __instance, List __state) { if (__state == null || __instance.m_pins == null) { return; } bool flag = false; foreach (InteractivePinState item in __state) { if (item.Pin != null && __instance.m_pins.Contains(item.Pin)) { if (item.Pin.m_checked != item.Checked) { item.Pin.m_checked = item.Checked; flag = true; } if (item.Pin.m_ownerID != item.OwnerID) { item.Pin.m_ownerID = item.OwnerID; flag = true; } } } if (flag) { __instance.m_pinUpdateRequired = true; } } } private static bool mapWindowInitialized = false; public static GameObject parentObject; public static GameObject mapContent; public static RectTransform content; public static RectTransform viewport; public static Image mapImage; 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 list = new List(); 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(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($"$nomapprinter_notenoughbasepieces: {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($"$nomapprinter_notenoughcomfort: {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 != NomapPrinter.MapWindow.Hide && 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; ((CustomSyncedValueBase)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.6f * NomapPrinter.mapMouseScrollSpeed.Value; 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_notready", (MessageType)2); } else { DisplayingWindow = true; } } public static void ShowInteractiveMap() { if (Game.m_noMap && NomapPrinter.allowInteractiveMapOnWrite.Value) { InteractiveMap.Show(); } } public static void SetupSharedMapFileWatcher() { if (!Utility.IsNullOrWhiteSpace(NomapPrinter.sharedFile.Value)) { fileSystemWatcher?.Dispose(); fileSystemWatcher = null; fileSystemWatcher = new FileSystemWatcher { Path = Path.GetDirectoryName(NomapPrinter.sharedFile.Value), Filter = Path.GetFileName(NomapPrinter.sharedFile.Value) }; if (Utility.IsNullOrWhiteSpace(fileSystemWatcher.Path)) { fileSystemWatcher.Path = pluginFolder.FullName; } string text = Path.Combine(fileSystemWatcher.Path, fileSystemWatcher.Filter); fileSystemWatcher.Changed += MapFileChanged; fileSystemWatcher.Created += MapFileChanged; fileSystemWatcher.Renamed += MapFileChanged; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = NomapPrinter.mapStorage.Value == NomapPrinter.MapStorage.LoadFromSharedFile; NomapPrinter.LogInfo("Watcher " + (fileSystemWatcher.EnableRaisingEvents ? "active" : "inactive") + ": " + text); AssignMapDataFromSharedFile(text); } } public static void SetMapIsReady(bool ready = true) { mapTextureIsReady = ready; ResetContent(); } public static bool IsMapReady() { return mapTextureIsReady; } private static void SetUnlockCursor(int lockState, bool cursorVisible) { if (_curLockState != null) { _curLockState.SetValue(null, lockState, null); _curVisible.SetValue(null, cursorVisible, null); } } private static void ZoomMap(float increment) { //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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_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) if (increment.Equals(0f)) { ResetZoomToDefault(); } else { if (ZInput.IsMouseActive() && !RectTransformUtility.RectangleContainsScreenPoint(viewport, Vector2.op_Implicit(UnityInput.Current.mousePosition))) { return; } float num = increment / 2f; (float minScale, float maxScale) scaleLimits = GetScaleLimits(); float item = scaleLimits.minScale; float item2 = scaleLimits.maxScale; float num2 = Mathf.Clamp(((Transform)content).localScale.x + num, item, item2); if (((Transform)content).localScale.x != num2) { ((Transform)content).localScale = Vector2.op_Implicit(new Vector2(num2, num2)); if (ZInput.IsMouseActive()) { Vector2 val = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(content, Vector2.op_Implicit(UnityInput.Current.mousePosition), (Camera)null, ref val); RectTransform obj = content; ((Transform)obj).localPosition = ((Transform)obj).localPosition - new Vector3(val.x, val.y) * num; } else if (ZInput.IsGamepadActive()) { Vector2 val2 = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(content, new Vector2((float)(Screen.width / 2), (float)(Screen.height / 2)), (Camera)null, ref val2); RectTransform obj2 = content; ((Transform)obj2).localPosition = ((Transform)obj2).localPosition - new Vector3(val2.x, val2.y) * num; } } } } private static (float minScale, float maxScale) GetScaleLimits() { float num = Mathf.Max(NomapPrinter.mapMinimumScale.Value, (NomapPrinter.mapSize.Value == NomapPrinter.MapSize.Normal) ? 0.4f : 0.25f); float num2 = Mathf.Min(NomapPrinter.mapMaximumScale.Value, 2f); if (num > num2) { NomapPrinter.LogWarning($"Map zoom limits are conflicting (min: {num}, max: {num2}). Values were swapped."); float num3 = num2; num2 = num; num = num3; } return (minScale: num, maxScale: num2); } private static void ResetZoomToDefault() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) (float minScale, float maxScale) scaleLimits = GetScaleLimits(); float item = scaleLimits.minScale; float item2 = scaleLimits.maxScale; float num = Mathf.Clamp(NomapPrinter.mapDefaultScale.Value, item, item2); ((Transform)content).localScale = new Vector3(num, num, 1f); } private static void CenterMap() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) ((Transform)content).localPosition = Vector3.zero; content.anchoredPosition = Vector2.op_Implicit(Vector3.zero); } private static void MoveMap(float deltaX, float deltaY, float dt) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) RectTransform obj = content; ((Transform)obj).localPosition = ((Transform)obj).localPosition + new Vector3(deltaX, deltaY) * dt * 1000f * NomapPrinter.mapGamepadMoveSpeed.Value; } private static void ResetContent() { //IL_0017: 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_0048: 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) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (mapWindowInitialized) { float x = ((Transform)content).localScale.x; Vector3 localPosition = ((Transform)content).localPosition; content.sizeDelta = new Vector2((float)((Texture)mapTexture).width, (float)((Texture)mapTexture).height); InitMapSprite(); if (NomapPrinter.retainMapFocusAndScale.Value) { (float minScale, float maxScale) scaleLimits = GetScaleLimits(); float item = scaleLimits.minScale; float item2 = scaleLimits.maxScale; float num = Mathf.Clamp(x, item, item2); ((Transform)content).localScale = new Vector3(num, num, 1f); ((Transform)content).localPosition = localPosition; } else { ResetZoomToDefault(); CenterMap(); } } } private static void AddIngameView(Transform parentTransform) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_004d: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) parentObject = new GameObject("NomapPrinter_Parent", new Type[1] { typeof(RectTransform) }) { layer = layerUI }; parentObject.transform.SetParent(parentTransform, false); RectTransform component = parentObject.GetComponent(); component.anchoredPosition = Vector2.zero; component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.sizeDelta = Vector2.zero; GameObject val = new GameObject("NomapPrinter_ScrollView", new Type[1] { typeof(RectTransform) }) { layer = layerUI }; val.transform.SetParent(parentObject.transform, false); RectTransform component2 = val.GetComponent(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.sizeDelta = new Vector2(-300f, -200f); ((Graphic)val.AddComponent()).color = new Color(0f, 0f, 0f, 0.4f); ScrollRect val2 = val.AddComponent(); GameObject val3 = new GameObject("NomapPrinter_ViewPort", new Type[1] { typeof(RectTransform) }) { layer = layerUI }; val3.transform.SetParent(val.transform, false); val3.AddComponent(); ((Graphic)val3.AddComponent()).color = new Color(0f, 0f, 0f, 0f); viewport = val3.GetComponent(); viewport.anchorMin = Vector2.zero; viewport.anchorMax = Vector2.one; viewport.sizeDelta = new Vector2(-12f, -12f); viewport.anchoredPosition = Vector2.zero; mapContent = new GameObject("NomapPrinter_Map", new Type[1] { typeof(RectTransform) }) { layer = layerUI }; mapContent.transform.SetParent(val3.transform); content = mapContent.GetComponent(); content.sizeDelta = new Vector2((float)((Texture)mapTexture).width, (float)((Texture)mapTexture).height); content.anchoredPosition = Vector2.zero; ResetZoomToDefault(); mapImage = mapContent.AddComponent(); mapImage.preserveAspect = true; InitMapSprite(); val2.scrollSensitivity = 0f; val2.content = content; val2.viewport = viewport; val2.horizontal = true; val2.vertical = true; val2.inertia = false; val2.movementType = (MovementType)2; mapWindowInitialized = true; parentObject.SetActive(false); NomapPrinter.LogInfo("Ingame drawed map added to hud"); } private static void InitMapSprite() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_009d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)mapImage.sprite)) { Rect rect = mapImage.sprite.rect; if (((Rect)(ref rect)).width == (float)((Texture)mapTexture).width) { return; } } if (Object.op_Implicit((Object)(object)mapImage.sprite)) { Object.Destroy((Object)(object)mapImage.sprite); } mapImage.sprite = Sprite.Create(mapTexture, new Rect(0f, 0f, (float)((Texture)mapTexture).width, (float)((Texture)mapTexture).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); } private static void MapFileChanged(object sender, FileSystemEventArgs eargs) { AssignMapDataFromSharedFile(eargs.FullPath); } private static void AssignMapDataFromSharedFile(string filename) { string text = ""; if (File.Exists(filename)) { try { text = Convert.ToBase64String(File.ReadAllBytes(filename)); } catch (Exception ex) { NomapPrinter.LogInfo("Error reading file (" + filename + ")! Error: " + ex.Message); } } else { NomapPrinter.LogInfo("Can't find file (" + filename + ")!"); } NomapPrinter.mapDataFromFile.AssignLocalValue(text); } private static void LoadMapFromSharedValue() { if (LoadMapFromSharedFile()) { SetMapIsReady(); } } private static bool LoadMapFromSharedFile() { if (NomapPrinter.mapStorage.Value != NomapPrinter.MapStorage.LoadFromSharedFile || Utility.IsNullOrWhiteSpace(NomapPrinter.mapDataFromFile.Value)) { return false; } try { ImageConversion.LoadImage(mapTexture, Convert.FromBase64String(NomapPrinter.mapDataFromFile.Value)); mapTexture.Apply(); } catch (Exception arg) { NomapPrinter.LogInfo($"Loading map error. Invalid printed map texture: {arg}"); return false; } return true; } private static string SanitizeFilePart(string value, string fallback) { if (string.IsNullOrWhiteSpace(value) || value.Trim('.') == string.Empty) { return fallback; } char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { value = value.Replace(oldChar, '_'); } return value; } private static string LocalFileName(Player player) { string text = SanitizeFilePart((player != null) ? player.GetPlayerName() : null, "UnknownPlayer"); ZNet instance = ZNet.instance; string text2 = SanitizeFilePart((instance != null) ? instance.GetWorldName() : null, "UnknownWorld"); string path = (Utility.IsNullOrWhiteSpace(NomapPrinter.localFolder.Value) ? "shudnal.NomapPrinter" : NomapPrinter.localFolder.Value); return Path.Combine(NomapPrinter.LocalPath, path, "shudnal.NomapPrinter." + text + "." + text2 + ".png"); } private static bool LoadMapFromLocalFile(Player player) { string text = LocalFileName(player); if (!File.Exists(text)) { NomapPrinter.LogInfo("Can't find file (" + text + ")!"); return false; } try { NomapPrinter.LogInfo("Loading nomap data from " + text); ImageConversion.LoadImage(mapTexture, File.ReadAllBytes(text)); mapTexture.Apply(); } catch (Exception arg) { NomapPrinter.LogInfo($"Loading map error. Invalid printed map texture: {arg}"); return false; } return true; } private static void SaveMapToLocalFile(Player player) { if (!NomapPrinter.modEnabled.Value || (Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer || NomapPrinter.mapStorage.Value != NomapPrinter.MapStorage.LocalFolder || !IsMapReady()) { return; } string text = LocalFileName(player); try { Directory.CreateDirectory(Path.GetDirectoryName(text)); NomapPrinter.LogInfo("Saving nomap data to " + text); File.WriteAllBytes(text, ImageConversion.EncodeToPNG(mapTexture)); } catch (Exception arg) { NomapPrinter.LogInfo($"Saving map to local file error:\n{arg}"); } } private static bool PreventInteractiveMapPinChanges() { return NomapPrinter.modEnabled.Value && NomapPrinter.preventPinChanges.Value && InteractiveMap.IsOpen; } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("shudnal.NomapPrinter", "Nomap Printer", "1.5.3")] public class NomapPrinter : BaseUnityPlugin { public enum MapType { BirdsEye, Topographical, Chart, OldChart, Vanilla } public enum MapSize { Normal = 2, Smooth = 4 } public enum MapStorage { Character, LocalFolder, LoadFromSharedFile } public enum MapWindow { Hide, ShowEverywhere, ShowNearTheTable, ShowOnInteraction } [HarmonyPatch(typeof(MapTable), "OnRead", new Type[] { typeof(Switch), typeof(Humanoid), typeof(ItemData), typeof(bool) })] public static class MapTable_OnRead_ReadDiscoveriesInteraction { public static void Postfix(MapTable __instance, ItemData item) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (modEnabled.Value && item == null && !MapTable_OnWrite_RecordDiscoveriesInteraction.isCalled && PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, true, false)) { MapMaker.SavePlayerExploration(); if (mapWindow.Value == MapWindow.ShowOnInteraction) { MapViewer.ShowMap(); } else if (tablePartsSwap.Value) { MapViewer.ShowInteractiveMap(); } else if (mapStorage.Value != MapStorage.LoadFromSharedFile) { MapMaker.GenerateMap(); } } } } [HarmonyPatch(typeof(MapTable), "OnWrite")] public static class MapTable_OnWrite_RecordDiscoveriesInteraction { public static bool isCalled; public static void Prefix() { isCalled = true; } public static void Postfix(MapTable __instance, ItemData item) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) isCalled = false; if (modEnabled.Value && item == null && PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, true, false)) { MapMaker.SavePlayerExploration(); if ((tablePartsSwap.Value || mapWindow.Value == MapWindow.ShowOnInteraction) && mapStorage.Value != MapStorage.LoadFromSharedFile) { MapMaker.GenerateMap(); } else { MapViewer.ShowInteractiveMap(); } } } } [HarmonyPatch(typeof(Player), "Load")] public static class Player_Load_DeleteDeprecatedData { private const string dataPrefix = "NomapPrinter_MapTexture_"; public static void Postfix(Player __instance) { CollectionExtensions.Do>((IEnumerable>)__instance.m_customData.Where((KeyValuePair data) => data.Key.StartsWith("NomapPrinter_MapTexture_")).ToList(), (Action>)delegate(KeyValuePair data) { __instance.m_customData.Remove(data.Key); }); } } [HarmonyPatch(typeof(ZoneSystem), "Start")] public static class ZoneSystem_Start_CustomTexturesWatcherEnable { public static void Postfix() { InteractiveMap.ResetSession(); SetupConfigWatcher(enabled: true); } } [HarmonyPatch(typeof(ZoneSystem), "OnDestroy")] public static class ZoneSystem_OnDestroy_CustomTexturesWatcherDisable { public static void Postfix() { InteractiveMap.ResetSession(); SetupConfigWatcher(enabled: false); } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static EventHandler <>9__103_0; public static EventHandler <>9__103_1; public static EventHandler <>9__103_2; public static EventHandler <>9__103_3; public static EventHandler <>9__103_4; public static EventHandler <>9__103_5; public static EventHandler <>9__103_6; public static EventHandler <>9__103_7; public static EventHandler <>9__103_8; public static EventHandler <>9__103_9; public static EventHandler <>9__103_10; public static EventHandler <>9__103_11; public static EventHandler <>9__103_12; public static ConsoleEvent <>9__104_0; public static Func <>9__104_2; public static ConsoleOptionsFetcher <>9__104_1; internal void b__103_0(object sender, EventArgs args) { ReadTextureFiles(); } internal void b__103_1(object sender, EventArgs args) { ReadTextureFiles(); } internal void b__103_2(object sender, EventArgs args) { ReadTextureFiles(); } internal void b__103_3(object sender, EventArgs args) { ReadTextureFiles(); } internal void b__103_4(object sender, EventArgs args) { ReadTextureFiles(); } internal void b__103_5(object sender, EventArgs args) { ReadTextureFiles(); } internal void b__103_6(object sender, EventArgs args) { ReadTextureFiles(); } internal void b__103_7(object sender, EventArgs args) { ReadTextureFiles(); } internal void b__103_8(object sender, EventArgs args) { MapMaker.ResetExploredMap(); } internal void b__103_9(object sender, EventArgs args) { MapMaker.ResetExploredMap(); } internal void b__103_10(object sender, EventArgs args) { MapViewer.SetupSharedMapFileWatcher(); } internal void b__103_11(object sender, EventArgs args) { MapViewer.SetupSharedMapFileWatcher(); } internal void b__103_12(object s, EventArgs e) { MapPinTexts.ClearPinFont(); } internal void b__104_0(ConsoleEventArgs args) { if (args.Length >= 2) { string text = args.FullLine.Substring(args[0].Length + 1).Trim(); if (Utility.IsNullOrWhiteSpace(Path.GetDirectoryName(text))) { text = Path.Combine(configDirectory, text); } string path = Path.ChangeExtension(text, ".zpack"); File.WriteAllBytes(path, MapMaker.ExploredMapData.GetPackedImageData(File.ReadAllBytes(text))); args.Context.AddString("Saved packed file " + Path.GetFileName(path) + "\n"); } else { args.Context.AddString("Syntax: repackpng [filename]"); } } internal List b__104_1() { return (from file in new DirectoryInfo(configDirectory).GetFiles("*.png") select file.Name).ToList(); } internal string b__104_2(FileInfo file) { return file.Name; } } public const string pluginID = "shudnal.NomapPrinter"; public const string pluginName = "Nomap Printer"; public const string pluginVersion = "1.5.3"; private readonly Harmony harmony = new Harmony("shudnal.NomapPrinter"); internal static readonly ConfigSync configSync = new ConfigSync("shudnal.NomapPrinter") { DisplayName = "Nomap Printer", CurrentVersion = "1.5.3", MinimumRequiredVersion = "1.5.3", ModRequired = false }; public static ConfigEntry modEnabled; public static ConfigEntry configLocked; public static ConfigEntry loggingEnabled; public static ConfigEntry saveMapToFile; public static ConfigEntry filePath; public static ConfigEntry mapWindow; public static ConfigEntry allowInteractiveMapOnWrite; public static ConfigEntry showSharedMap; public static ConfigEntry preventPinChanges; public static ConfigEntry applyPinFiltersToInteractiveMap; public static ConfigEntry hidePlayerMarkerOnInteractiveMap; public static ConfigEntry doNotCenterInteractiveMapOnPlayer; public static ConfigEntry useCustomExploredLayer; public static ConfigEntry useCustomUnderFogLayer; public static ConfigEntry useCustomOverFogLayer; public static ConfigEntry useCustomFogLayer; public static ConfigEntry syncExploredLayerFromServer; public static ConfigEntry syncUnderFogLayerFromServer; public static ConfigEntry syncOverFogLayerFromServer; public static ConfigEntry syncFogLayerFromServer; public static ConfigEntry showNearTheTableDistance; public static ConfigEntry showMapBasePiecesRequirement; public static ConfigEntry showMapComfortRequirement; public static ConfigEntry mapStorage; public static ConfigEntry localFolder; public static ConfigEntry sharedFile; public static ConfigEntry mapType; public static ConfigEntry mapSize; public static ConfigEntry mapDefaultScale; public static ConfigEntry mapMinimumScale; public static ConfigEntry mapMaximumScale; public static ConfigEntry retainMapFocusAndScale; public static ConfigEntry pinScale; public static ConfigEntry preserveSharedMapFog; public static ConfigEntry worldSize; public static ConfigEntry mapGamepadZoomSpeed; public static ConfigEntry mapGamepadMoveSpeed; public static ConfigEntry mapSizeMultiplier; public static ConfigEntry mapMouseScrollSpeed; public static ConfigEntry fogContoursEnabled; public static ConfigEntry fogContoursDistance; public static ConfigEntry fogContoursAlpha; public static ConfigEntry showPins; public static ConfigEntry showExploredPins; public static ConfigEntry showMyPins; public static ConfigEntry showNonCheckedPins; public static ConfigEntry showMerchantPins; public static ConfigEntry showPinsDoubleSize; public static ConfigEntry showMerchantPinsNames; public static ConfigEntry pinsHildirQuestColored; public static ConfigEntry pinsHildirQuestPin1Color; public static ConfigEntry pinsHildirQuestPin2Color; public static ConfigEntry pinsHildirQuestPin3Color; public static ConfigEntry pinTextEnabled; public static ConfigEntry pinTextSize; public static ConfigEntry pinTextFont; public static ConfigEntry pinTextFontStyle; public static ConfigEntry pinTextFontColor; public static ConfigEntry pinTextOffset; public static ConfigEntry showEveryPin; public static ConfigEntry showPinStart; public static ConfigEntry showPinTrader; public static ConfigEntry showPinHildir; public static ConfigEntry showPinHildirQuest; public static ConfigEntry showPinBogWitch; public static ConfigEntry showPinBoss; public static ConfigEntry showPinFire; public static ConfigEntry showPinHouse; public static ConfigEntry showPinHammer; public static ConfigEntry showPinPin; public static ConfigEntry showPinPortal; public static ConfigEntry showPinBed; public static ConfigEntry showPinDeath; public static ConfigEntry showPinEpicLoot; public static ConfigEntry showLastDeathPin; public static ConfigEntry tablePartsSwap; public static readonly CustomSyncedValue mapDataFromFile = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "mapDataFromFile", "", 0, (IEqualityComparer)null); public static readonly CustomSyncedValue customLayerExplored = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom explored layer", "", 0, (IEqualityComparer)null); public static readonly CustomSyncedValue customLayerFog = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom fog layer", "", 0, (IEqualityComparer)null); public static readonly CustomSyncedValue customLayerOverfog = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom overfog layer", "", 0, (IEqualityComparer)null); public static readonly CustomSyncedValue customLayerUnderfog = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom underfog layer", "", 0, (IEqualityComparer)null); public static NomapPrinter instance; private static string _localPath = null; public static string cacheDirectory; public static string configDirectory; public const string epicLootGUID = "randyknapp.mods.epicloot"; public static bool epicLootIsLoaded; public static FileSystemWatcher configFolderWatcher; public static string LocalPath => _localPath ?? (_localPath = Utils.GetSaveDataPath((FileSource)1)); private void Awake() { harmony.PatchAll(); instance = this; ConfigInit(); ((ConditionalConfigSync)configSync).AddLockingConfigEntry(configLocked); Game.isModded = true; ((CustomSyncedValueBase)customLayerExplored).ValueChanged += MapMaker.ResetExploredMapOnTextureChange; epicLootIsLoaded = Chainloader.PluginInfos.ContainsKey("randyknapp.mods.epicloot"); } private void Start() { MapViewer.Start(); } private void Update() { if (modEnabled.Value && Game.m_noMap) { MapViewer.Update(); } } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } instance = null; } private void ConfigInit() { //IL_07bf: Unknown result type (might be due to invalid IL or missing references) //IL_07f3: Unknown result type (might be due to invalid IL or missing references) //IL_0827: Unknown result type (might be due to invalid IL or missing references) //IL_08bc: Unknown result type (might be due to invalid IL or missing references) modEnabled = serverConfig("General", "Enabled", defaultValue: true, "Print map on table interaction"); configLocked = serverConfig("General", "Lock Configuration", defaultValue: true, "Configuration is locked and can be changed by server admins only."); loggingEnabled = config("Logging", "Enabled", defaultValue: false, "Enable logging.", synchronizedSetting: false); mapWindow = config("Map", "Ingame map", MapWindow.ShowEverywhere, "Where to show ingame map"); allowInteractiveMapOnWrite = config("Map", "Show interactive map on record discoveries", defaultValue: false, "Show interactive original game map on record discoveries part of map table used"); showSharedMap = config("Map", "Show shared map", defaultValue: true, "Show parts of the map shared by others"); preventPinChanges = config("Map", "Prevent changing pins on interactive map", defaultValue: false, "Prevent adding, removing, checking, or taking ownership of pins when using the interactive map"); applyPinFiltersToInteractiveMap = config("Map", "Apply pin visibility settings to interactive map", defaultValue: true, "Apply Nomap Printer pin visibility rules to the interactive map"); hidePlayerMarkerOnInteractiveMap = config("Map", "Hide player marker on interactive map", defaultValue: false, "Hide player and controlled ship position markers on the interactive map"); doNotCenterInteractiveMapOnPlayer = config("Map", "Do not center interactive map on player", defaultValue: false, "Keep the interactive map centered on the last viewed world position during the current world session. The first opening starts at the world center"); useCustomExploredLayer = serverConfig("Map custom layers", "Explored map - Enable layer", defaultValue: false, "Use custom explored map layer if it was found in config folder or shared from server"); syncExploredLayerFromServer = serverConfig("Map custom layers", "Explored map - Share from server", defaultValue: false, "Share explored map layer from server to clients. \nFile with size more than 7MB will most likely not be loaded with default data rate of 150KB/s.\nSafest way is to share explored world as packed file and place it into mod config folder on the clients"); useCustomUnderFogLayer = serverConfig("Map custom layers", "Under fog - Enable layer", defaultValue: false, "Use custom under fog map layer if it was found in config folder or shared from server"); syncUnderFogLayerFromServer = serverConfig("Map custom layers", "Under fog - Share from server", defaultValue: false, "Enable server to clients sharing of layer data"); useCustomOverFogLayer = serverConfig("Map custom layers", "Over fog - Enable layer", defaultValue: false, "Use custom over fog map layer if it was found in config folder or shared from server"); syncOverFogLayerFromServer = serverConfig("Map custom layers", "Over fog - Share from server", defaultValue: false, "Enable server to clients sharing of layer data"); useCustomFogLayer = serverConfig("Map custom layers", "Fog texture - Enable layer", defaultValue: false, "Use custom fog texture if it was found in config folder or shared from server"); syncFogLayerFromServer = serverConfig("Map custom layers", "Fog texture - Share from server", defaultValue: false, "Enable server to clients sharing of fog texture"); useCustomExploredLayer.SettingChanged += delegate { ReadTextureFiles(); }; useCustomUnderFogLayer.SettingChanged += delegate { ReadTextureFiles(); }; useCustomOverFogLayer.SettingChanged += delegate { ReadTextureFiles(); }; useCustomFogLayer.SettingChanged += delegate { ReadTextureFiles(); }; syncExploredLayerFromServer.SettingChanged += delegate { ReadTextureFiles(); }; syncUnderFogLayerFromServer.SettingChanged += delegate { ReadTextureFiles(); }; syncOverFogLayerFromServer.SettingChanged += delegate { ReadTextureFiles(); }; syncFogLayerFromServer.SettingChanged += delegate { ReadTextureFiles(); }; useCustomExploredLayer.SettingChanged += delegate { MapMaker.ResetExploredMap(); }; syncExploredLayerFromServer.SettingChanged += delegate { MapMaker.ResetExploredMap(); }; showNearTheTableDistance = config("Map restrictions", "Show map near the table when distance is less than", 10f, "Distance to nearest map table for map to be shown (only for \"Show Near The Table\" map mode)"); showMapBasePiecesRequirement = config("Map restrictions", "Show map when base pieces near the player is more than", 0, "Count of base pieces surrounding the player should be more than that for map to be shown"); showMapComfortRequirement = config("Map restrictions", "Show map when player comfort is more than", 0, "Player comfort buff should be more than that for map to be shown"); saveMapToFile = config("Map save", "Save to file", defaultValue: false, "Save generated map to file. Works in normal map mode. You can set exact file name or folder name", synchronizedSetting: false); filePath = config("Map save", "Save to file path", "", "File path used to save generated map.", synchronizedSetting: false); mapStorage = config("Map storage", "Data storage", MapStorage.LocalFolder, "Type of storage for map data. Default is save map data to local folder."); localFolder = config("Map storage", "Local folder", "", "Save and load map data from local folder. If relative path is set then the folder will be created at %appdata%..\\..\\LocalLow\\IronGate\\Valheim"); sharedFile = config("Map storage", "Shared file", "", "Load map from the file name instead of generating one. File should be available on the server."); mapStorage.SettingChanged += delegate { MapViewer.SetupSharedMapFileWatcher(); }; sharedFile.SettingChanged += delegate { MapViewer.SetupSharedMapFileWatcher(); }; mapType = config("Map style", "Map type", MapType.Chart, "Type of generated map"); mapSize = config("Map style", "Map size", MapSize.Smooth, "Resolution of generated map. More details means smoother lines but more data will be stored"); mapDefaultScale = config("Map style", "Map zoom default scale", 0.7f, "Default scale of opened map, more is closer, less is farther."); mapMinimumScale = config("Map style", "Map zoom minimum scale", 0.25f, "Minimum scale of opened map, more is closer, less is farther."); mapMaximumScale = config("Map style", "Map zoom maximum scale", 2f, "Maximum scale of opened map, more is closer, less is farther."); retainMapFocusAndScale = config("Map style", "Retain map focus and scale", defaultValue: true, "Retain current map position and scale when map texture is refreshed."); pinScale = config("Map style extended", "Pin scale", 1f, "Pin scale"); preserveSharedMapFog = config("Map style extended", "Preserve shared map fog tint for vanilla map", defaultValue: true, "Generate Vanilla map with shared map fog tint"); worldSize = config("Map style extended", "World size", 10500f, "Land outside of that radius will be ignored"); mapGamepadZoomSpeed = config("Map style extended", "Map gamepad zoom speed", 1f, "Speed of map zoom while using gamepad.", synchronizedSetting: false); mapGamepadMoveSpeed = config("Map style extended", "Map gamepad move speed", 1f, "Speed of map move while using gamepad.", synchronizedSetting: false); mapSizeMultiplier = config("Map style extended", "Map size multiplier", 1f, "Use similar multiplier as in EWSize mod. Map size multiplier should also match world radius to get correct results."); mapMouseScrollSpeed = config("Map style extended", "Map mouse scroll speed", 1f, "Multiplier of mouse scroll.", synchronizedSetting: false); fogContoursEnabled = config("Map style - Fog contours", "Enabled", defaultValue: true, "Enable terrain contours over unexplored fog."); fogContoursDistance = config("Map style - Fog contours", "Distance", 24, "Distance in pixels where terrain contours are drawn over unexplored fog."); fogContoursAlpha = config("Map style - Fog contours", "Alpha", 0.12f, "Transparency of contours drawn over unexplored fog."); showPins = config("Pins", "Show map pins", defaultValue: true, "Show pins on drawed map"); showExploredPins = config("Pins", "Show only explored pins", defaultValue: true, "Only show pins on explored part of the map"); showMerchantPins = config("Pins", "Show merchants pins always", defaultValue: true, "Show merchant pins even in unexplored part of the map"); showMyPins = config("Pins", "Show only my pins", defaultValue: true, "Only show your pins on the map"); showNonCheckedPins = config("Pins", "Show only unchecked pins", defaultValue: true, "Only show pins that doesn't checked (have no red cross)"); showPinsDoubleSize = config("Pins", "Show static pins in double size", defaultValue: true, "Show pins of the Sacrificial Stones, traders and other important pins in double size (vanilla game behaviour)"); showMerchantPinsNames = config("Pins", "Show merchants names", defaultValue: true, "Show names of the traders"); pinsHildirQuestColored = config("Pins - Hildir quests", "Color Hildir pins", defaultValue: false, "Show Hildir pins in different colors. Useful if you disable pin texts."); pinsHildirQuestPin1Color = config("Pins - Hildir quests", "Color of Smouldering Tomb", new Color(0.894f, 0.294f, 0.035f, 1f), "Pin color is tinted by selected color"); pinsHildirQuestPin2Color = config("Pins - Hildir quests", "Color of Howling Cavern", new Color(0.204f, 0.345f, 0.827f, 1f), "Pin color is tinted by selected color"); pinsHildirQuestPin3Color = config("Pins - Hildir quests", "Color of Sealed Tower", new Color(0.118f, 0.729f, 0.035f, 1f), "Pin color is tinted by selected color"); pinTextEnabled = config("Pins - Text", "Enabled", defaultValue: true, "Enabled pin texts"); pinTextSize = config("Pins - Text", "Font size", 20, "Font size"); pinTextFont = config("Pins - Text", "Font", "", "Font override. Default font is pin font."); pinTextFontStyle = config("Pins - Text", "Font style", (FontStyles)1, "Font style"); pinTextFontColor = config("Pins - Text", "Font color", Color.white, "Font color"); pinTextOffset = config("Pins - Text", "Text offset", 1, "From icon bottom"); pinTextFont.SettingChanged += delegate { MapPinTexts.ClearPinFont(); }; showEveryPin = config("Pins list", "Show all pins", defaultValue: false, "Show all pins"); showPinStart = config("Pins list", "Show Start pins", defaultValue: true, "Show Start pin on drawed map"); showPinTrader = config("Pins list", "Show Haldor pins", defaultValue: true, "Show Haldor pin on drawed map"); showPinHildir = config("Pins list", "Show Hildir pins", defaultValue: true, "Show Hildir pin on drawed map"); showPinHildirQuest = config("Pins list", "Show Hildir quest pins", defaultValue: true, "Show Hildir quest pins on drawed map"); showPinBogWitch = config("Pins list", "Show Bog Witch pins", defaultValue: true, "Show Bog Witch pin on drawed map"); showPinBoss = config("Pins list", "Show Boss pins", defaultValue: true, "Show Boss pins on drawed map"); showPinFire = config("Pins list", "Show Fire pins", defaultValue: true, "Show Fire pins on drawed map"); showPinHouse = config("Pins list", "Show House pins", defaultValue: true, "Show House pins on drawed map"); showPinHammer = config("Pins list", "Show Hammer pins", defaultValue: true, "Show Hammer pins on drawed map"); showPinPin = config("Pins list", "Show Pin pins", defaultValue: true, "Show Pin pins on drawed map"); showPinPortal = config("Pins list", "Show Portal pins", defaultValue: true, "Show Portal pins on drawed map"); showPinBed = config("Pins list", "Show Bed pins", defaultValue: false, "Show Bed pins on drawed map"); showPinDeath = config("Pins list", "Show Death pins", defaultValue: false, "Show Death pins on drawed map"); showPinEpicLoot = config("Pins list", "Show Epic Loot pins", defaultValue: true, "Show Epic Loot pins on drawed map"); showLastDeathPin = config("Pins list", "Show Last Death pin", defaultValue: true, "Show pin where you died last time"); tablePartsSwap = config("Table", "Swap interaction behaviour on map table parts", defaultValue: false, "Make \"Read map\" part to open interactive map and \"Record discoveries\" part to generate map. +\nDoesn't work in Show On Interaction map mode", synchronizedSetting: false); cacheDirectory = Path.Combine(Paths.CachePath, "shudnal.NomapPrinter"); configDirectory = Path.Combine(Paths.ConfigPath, "shudnal.NomapPrinter"); InitTerminalCommands(); ((MonoBehaviour)this).StartCoroutine(Localizer.Load()); } public void InitTerminalCommands() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0051: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown object obj = <>c.<>9__104_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { if (args.Length >= 2) { string text = args.FullLine.Substring(args[0].Length + 1).Trim(); if (Utility.IsNullOrWhiteSpace(Path.GetDirectoryName(text))) { text = Path.Combine(configDirectory, text); } string path = Path.ChangeExtension(text, ".zpack"); File.WriteAllBytes(path, MapMaker.ExploredMapData.GetPackedImageData(File.ReadAllBytes(text))); args.Context.AddString("Saved packed file " + Path.GetFileName(path) + "\n"); } else { args.Context.AddString("Syntax: repackpng [filename]"); } }; <>c.<>9__104_0 = val; obj = (object)val; } object obj2 = <>c.<>9__104_1; if (obj2 == null) { ConsoleOptionsFetcher val2 = () => (from file in new DirectoryInfo(configDirectory).GetFiles("*.png") select file.Name).ToList(); <>c.<>9__104_1 = val2; obj2 = (object)val2; } new ConsoleCommand("repackpng", "Repack png file into nonhumanreadable format", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)obj2, true, false, false); } private ConfigEntry config(string group, string name, T defaultValue, ConfigDescription description, bool synchronizedSetting = true) { return ((ConditionalConfigSync)configSync).AddConfigEntry(((BaseUnityPlugin)this).Config, group, name, defaultValue, description, (ConfigSyncMode)1, synchronizedSetting).SourceConfig; } private ConfigEntry serverConfig(string group, string name, T defaultValue, ConfigDescription description) { return ((ConditionalConfigSync)configSync).AddConfigEntry(((BaseUnityPlugin)this).Config, group, name, defaultValue, description, (ConfigSyncMode)0, true).SourceConfig; } private ConfigEntry config(string group, string name, T defaultValue, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty()), synchronizedSetting); } private ConfigEntry serverConfig(string group, string name, T defaultValue, string description) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return serverConfig(group, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty())); } public static void LogInfo(object message) { if (loggingEnabled.Value) { ((BaseUnityPlugin)instance).Logger.LogInfo(message); } } public static void LogWarning(object data) { if (loggingEnabled.Value) { ((BaseUnityPlugin)instance).Logger.LogWarning(data); } } public static void ShowMessage(string text, MessageType type = (MessageType)2) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!Utility.IsNullOrWhiteSpace(text) && !((Object)(object)MessageHud.instance == (Object)null)) { MessageHud.instance.ShowMessage(type, text, 1, (Sprite)null, false); } } public static void SetupConfigWatcher(bool enabled) { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { if (configFolderWatcher == null) { Directory.CreateDirectory(configDirectory); configFolderWatcher = new FileSystemWatcher(configDirectory); configFolderWatcher.Changed += ReadTextureFile; configFolderWatcher.Created += ReadTextureFile; configFolderWatcher.Deleted += ReadTextureFile; configFolderWatcher.Renamed += ReadTextureFile; configFolderWatcher.IncludeSubdirectories = true; configFolderWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; } configFolderWatcher.EnableRaisingEvents = enabled; ClearCustomTextures(); if (enabled) { ReadTextureFiles(initial: true); } } } private static void ClearCustomTextures() { customLayerExplored.AssignLocalValue(""); customLayerFog.AssignLocalValue(""); customLayerUnderfog.AssignLocalValue(""); customLayerOverfog.AssignLocalValue(""); } private static void ReadTextureFiles(bool initial = false) { foreach (FileInfo item in new DirectoryInfo(configDirectory).EnumerateFiles("*", SearchOption.AllDirectories)) { ReadCustomTexture(item.Name, item.FullName, initial); } } private static void ReadTextureFile(object sender, FileSystemEventArgs eargs) { ReadCustomTexture(eargs.Name, eargs.FullPath); if (eargs is RenamedEventArgs) { ReadCustomTexture((eargs as RenamedEventArgs).OldName, eargs.FullPath, initial: true); } } private static void ReadCustomTexture(string filename, string fullname, bool initial = false) { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { AssignCustomSyncedValue(customLayerExplored, initial, (useCustomExploredLayer.Value && syncExploredLayerFromServer.Value) ? MapMaker.GetTextureString(filename, fullname, "explored") : ""); AssignCustomSyncedValue(customLayerFog, initial, (useCustomFogLayer.Value && syncFogLayerFromServer.Value) ? MapMaker.GetTextureString(filename, fullname, "fog") : ""); AssignCustomSyncedValue(customLayerOverfog, initial, (useCustomOverFogLayer.Value && syncOverFogLayerFromServer.Value) ? MapMaker.GetTextureString(filename, fullname, "overfog") : ""); AssignCustomSyncedValue(customLayerUnderfog, initial, (useCustomUnderFogLayer.Value && syncUnderFogLayerFromServer.Value) ? MapMaker.GetTextureString(filename, fullname, "underfog") : ""); } } private static void AssignCustomSyncedValue(CustomSyncedValue syncedValue, bool initial, string content) { if (content != null) { if (content == "") { syncedValue.AssignLocalValue(content); } else if (initial) { syncedValue.AssignLocalValueAndNotify(content); } else { syncedValue.AssignLocalValueIfChanged(content); } } } } }