-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNomapPrinter.cs
502 lines (403 loc) · 26.8 KB
/
NomapPrinter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
using BepInEx.Configuration;
using BepInEx;
using HarmonyLib;
using ServerSync;
using System;
using System.Linq;
using System.IO;
using static Terminal;
using BepInEx.Bootstrap;
namespace NomapPrinter
{
[BepInDependency(epicLootGUID, BepInDependency.DependencyFlags.SoftDependency)]
[BepInPlugin(pluginID, pluginName, pluginVersion)]
public class NomapPrinter : BaseUnityPlugin
{
public const string pluginID = "shudnal.NomapPrinter";
public const string pluginName = "Nomap Printer";
public const string pluginVersion = "1.3.11";
private readonly Harmony harmony = new Harmony(pluginID);
internal static readonly ConfigSync configSync = new ConfigSync(pluginID) { DisplayName = pluginName, CurrentVersion = pluginVersion, MinimumRequiredVersion = pluginVersion };
public static ConfigEntry<bool> modEnabled;
public static ConfigEntry<bool> configLocked;
public static ConfigEntry<bool> loggingEnabled;
public static ConfigEntry<bool> saveMapToFile;
public static ConfigEntry<string> filePath;
public static ConfigEntry<MapWindow> mapWindow;
public static ConfigEntry<bool> allowInteractiveMapOnWrite;
public static ConfigEntry<bool> showSharedMap;
public static ConfigEntry<bool> preventPinAddition;
public static ConfigEntry<bool> useCustomExploredLayer;
public static ConfigEntry<bool> useCustomUnderFogLayer;
public static ConfigEntry<bool> useCustomOverFogLayer;
public static ConfigEntry<bool> useCustomFogLayer;
public static ConfigEntry<bool> syncExploredLayerFromServer;
public static ConfigEntry<bool> syncUnderFogLayerFromServer;
public static ConfigEntry<bool> syncOverFogLayerFromServer;
public static ConfigEntry<bool> syncFogLayerFromServer;
public static ConfigEntry<float> showNearTheTableDistance;
public static ConfigEntry<int> showMapBasePiecesRequirement;
public static ConfigEntry<int> showMapComfortRequirement;
public static ConfigEntry<MapStorage> mapStorage;
public static ConfigEntry<string> localFolder;
public static ConfigEntry<string> sharedFile;
public static ConfigEntry<MapType> mapType;
public static ConfigEntry<MapSize> mapSize;
public static ConfigEntry<float> mapDefaultScale;
public static ConfigEntry<float> mapMinimumScale;
public static ConfigEntry<float> mapMaximumScale;
public static ConfigEntry<float> pinScale;
public static ConfigEntry<bool> preserveSharedMapFog;
public static ConfigEntry<float> worldSize;
public static ConfigEntry<float> mapGamepadZoomSpeed;
public static ConfigEntry<float> mapGamepadMoveSpeed;
public static ConfigEntry<float> mapSizeMultiplier;
public static ConfigEntry<bool> showPins;
public static ConfigEntry<bool> showExploredPins;
public static ConfigEntry<bool> showMyPins;
public static ConfigEntry<bool> showNonCheckedPins;
public static ConfigEntry<bool> showMerchantPins;
public static ConfigEntry<bool> showEveryPin;
public static ConfigEntry<bool> showPinStart;
public static ConfigEntry<bool> showPinTrader;
public static ConfigEntry<bool> showPinHildir;
public static ConfigEntry<bool> showPinHildirQuest;
public static ConfigEntry<bool> showPinBogWitch;
public static ConfigEntry<bool> showPinBoss;
public static ConfigEntry<bool> showPinFire;
public static ConfigEntry<bool> showPinHouse;
public static ConfigEntry<bool> showPinHammer;
public static ConfigEntry<bool> showPinPin;
public static ConfigEntry<bool> showPinPortal;
public static ConfigEntry<bool> showPinBed;
public static ConfigEntry<bool> showPinDeath;
public static ConfigEntry<bool> showPinEpicLoot;
public static ConfigEntry<bool> showLastDeathPin;
public static ConfigEntry<string> messageStart;
public static ConfigEntry<string> messageSaving;
public static ConfigEntry<string> messageReady;
public static ConfigEntry<string> messageSavedTo;
public static ConfigEntry<string> messageNotReady;
public static ConfigEntry<string> messageNotEnoughBasePieces;
public static ConfigEntry<string> messageNotEnoughComfort;
public static ConfigEntry<bool> tablePartsSwap;
public static readonly CustomSyncedValue<string> mapDataFromFile = new CustomSyncedValue<string>(configSync, "mapDataFromFile", "");
public static readonly CustomSyncedValue<string> customLayerExplored = new CustomSyncedValue<string>(configSync, "Custom explored layer", "");
public static readonly CustomSyncedValue<string> customLayerFog = new CustomSyncedValue<string>(configSync, "Custom fog layer", "");
public static readonly CustomSyncedValue<string> customLayerOverfog = new CustomSyncedValue<string>(configSync, "Custom overfog layer", "");
public static readonly CustomSyncedValue<string> customLayerUnderfog = new CustomSyncedValue<string>(configSync, "Custom underfog layer", "");
public static NomapPrinter instance;
public static string localPath;
public static string cacheDirectory;
public static string configDirectory;
public const string epicLootGUID = "randyknapp.mods.epicloot";
public static bool epicLootIsLoaded;
public static FileSystemWatcher configFolderWatcher;
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
}
void Awake()
{
harmony.PatchAll();
instance = this;
ConfigInit();
_ = configSync.AddLockingConfigEntry(configLocked);
Game.isModded = true;
customLayerExplored.ValueChanged += new Action(MapMaker.ResetExploredMapOnTextureChange);
epicLootIsLoaded = Chainloader.PluginInfos.ContainsKey(epicLootGUID);
}
void Start()
{
MapViewer.Start();
}
void Update()
{
if (!modEnabled.Value)
return;
if (!Game.m_noMap)
return;
MapViewer.Update();
}
void OnDestroy()
{
harmony?.UnpatchSelf();
instance = null;
}
private void ConfigInit()
{
config("General", "NexusID", 2505, "Nexus mod ID for updates", false);
modEnabled = config("General", "Enabled", true, "Print map on table interaction");
configLocked = config("General", "Lock Configuration", defaultValue: true, "Configuration is locked and can be changed by server admins only.");
loggingEnabled = config("Logging", "Enabled", false, "Enable logging. [Not Synced with Server]", false);
mapWindow = config("Map", "Ingame map", MapWindow.ShowEverywhere, "Where to show ingame map");
allowInteractiveMapOnWrite = config("Map", "Show interactive map on record discoveries", false, "Show interactive original game map on record discoveries part of map table used");
showSharedMap = config("Map", "Show shared map", true, "Show parts of the map shared by others");
preventPinAddition = config("Map", "Prevent adding pins on interactive map", false, "Prevent creating pin when using interactive map");
useCustomExploredLayer = config("Map custom layers", "Explored map - Enable layer", false, "Use custom explored map layer if it was found in config folder or shared from server");
syncExploredLayerFromServer = config("Map custom layers", "Explored map - Share from server", 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 = config("Map custom layers", "Under fog - Enable layer", false, "Use custom under fog map layer if it was found in config folder or shared from server");
syncUnderFogLayerFromServer = config("Map custom layers", "Under fog - Share from server", false, "Enable server to clients sharing of layer data");
useCustomOverFogLayer = config("Map custom layers", "Over fog - Enable layer", false, "Use custom over fog map layer if it was found in config folder or shared from server");
syncOverFogLayerFromServer = config("Map custom layers", "Over fog - Share from server", false, "Enable server to clients sharing of layer data");
useCustomFogLayer = config("Map custom layers", "Fog texture - Enable layer", false, "Use custom fog texture if it was found in config folder or shared from server");
syncFogLayerFromServer = config("Map custom layers", "Fog texture - Share from server", false, "Enable server to clients sharing of fog texture");
useCustomExploredLayer.SettingChanged += (sender, args) => ReadTextureFiles();
useCustomUnderFogLayer.SettingChanged += (sender, args) => ReadTextureFiles();
useCustomOverFogLayer.SettingChanged += (sender, args) => ReadTextureFiles();
useCustomFogLayer.SettingChanged += (sender, args) => ReadTextureFiles();
syncExploredLayerFromServer.SettingChanged += (sender, args) => ReadTextureFiles();
syncUnderFogLayerFromServer.SettingChanged += (sender, args) => ReadTextureFiles();
syncOverFogLayerFromServer.SettingChanged += (sender, args) => ReadTextureFiles();
syncFogLayerFromServer.SettingChanged += (sender, args) => ReadTextureFiles();
useCustomExploredLayer.SettingChanged += (sender, args) => MapMaker.ResetExploredMap();
syncExploredLayerFromServer.SettingChanged += (sender, args) => MapMaker.ResetExploredMap();
showNearTheTableDistance = config("Map restrictions", "Show map near the table when distance is less than", defaultValue: 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", defaultValue: 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", defaultValue: 0, "Player comfort buff should be more than that for map to be shown");
saveMapToFile = config("Map save", "Save to file", false, "Save generated map to file. Works in normal map mode. You can set exact file name or folder name [Not Synced with Server]", false);
filePath = config("Map save", "Save to file path", "", "File path used to save generated map. [Not Synced with Server]", 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 += (sender, args) => MapViewer.SetupSharedMapFileWatcher();
sharedFile.SettingChanged += (sender, args) => MapViewer.SetupSharedMapFileWatcher();
mapType = config("Map style", "Map type", MapType.Chart, "Type of generated map");
mapSize = config("Map style", "Map size", MapSize.Normal, "Resolution of generated map. More details means smoother lines but more data will be stored");
mapDefaultScale = config("Map style", "Map zoom default scale", 0.7f, "Default scale of opened map, more is closer, less is farther.");
mapMinimumScale = config("Map style", "Map zoom minimum scale", 0.25f, "Minimum scale of opened map, more is closer, less is farther.");
mapMaximumScale = config("Map style", "Map zoom maximum scale", 2.0f, "Maximum scale of opened map, more is closer, less is farther.");
pinScale = config("Map style extended", "Pin scale", 1.0f, "Pin scale");
preserveSharedMapFog = config("Map style extended", "Preserve shared map fog tint for vanilla map", 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. [Not Synced with Server]", false);
mapGamepadMoveSpeed = config("Map style extended", "Map gamepad move speed", 1f, "Speed of map move while using gamepad. [Not Synced with Server]", 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.");
messageStart = config("Messages", "Drawing begin", "Remembering travels...", "Center message when drawing is started. [Not Synced with Server]", false);
messageSaving = config("Messages", "Drawing end", "Drawing map...", "Center message when saving file is started. [Not Synced with Server]", false);
messageReady = config("Messages", "Saved", "Map is ready", "Center message when file is saved. [Not Synced with Server]", false);
messageSavedTo = config("Messages", "Saved to", "Map saved to", "Top left message with file name. [Not Synced with Server]", false);
messageNotReady = config("Messages", "Not ready", "Map is not drawn yet", "Center message on trying to open a not ready map. [Not Synced with Server]", false);
messageNotEnoughBasePieces = config("Messages", "Not enough base pieces", "Not enough base pieces ({0} of {1})", "Center message on trying to open a map with failed base pieces requirement check. [Not Synced with Server]", false);
messageNotEnoughComfort = config("Messages", "Not enough comfort", "Not enough comfort ({0} of {1})", "Center message on trying to open a map with failed comfort requirement check. [Not Synced with Server]", false);
showPins = config("Pins", "Show map pins", true, "Show pins on drawed map");
showExploredPins = config("Pins", "Show only explored pins", true, "Only show pins on explored part of the map");
showMerchantPins = config("Pins", "Show merchants pins always", true, "Show merchant pins even in unexplored part of the map");
showMyPins = config("Pins", "Show only my pins", true, "Only show your pins on the map");
showNonCheckedPins = config("Pins", "Show only unchecked pins", true, "Only show pins that doesn't checked (have no red cross)");
showEveryPin = config("Pins list", "Show all pins", false, "Show all pins");
showPinStart = config("Pins list", "Show Start pins", true, "Show Start pin on drawed map");
showPinTrader = config("Pins list", "Show Haldor pins", true, "Show Haldor pin on drawed map");
showPinHildir = config("Pins list", "Show Hildir pins", true, "Show Hildir pin on drawed map");
showPinHildirQuest = config("Pins list", "Show Hildir quest pins", true, "Show Hildir quest pins on drawed map");
showPinBogWitch = config("Pins list", "Show Bog Witch pins", true, "Show Bog Witch pin on drawed map");
showPinBoss = config("Pins list", "Show Boss pins", true, "Show Boss pins on drawed map");
showPinFire = config("Pins list", "Show Fire pins", true, "Show Fire pins on drawed map");
showPinHouse = config("Pins list", "Show House pins", true, "Show House pins on drawed map");
showPinHammer = config("Pins list", "Show Hammer pins", true, "Show Hammer pins on drawed map");
showPinPin = config("Pins list", "Show Pin pins", true, "Show Pin pins on drawed map");
showPinPortal = config("Pins list", "Show Portal pins", true, "Show Portal pins on drawed map");
showPinBed = config("Pins list", "Show Bed pins", false, "Show Bed pins on drawed map");
showPinDeath = config("Pins list", "Show Death pins", false, "Show Death pins on drawed map");
showPinEpicLoot = config("Pins list", "Show Epic Loot pins", true, "Show Epic Loot pins on drawed map");
showLastDeathPin = config("Pins list", "Show Last Death pin", true, "Show pin where you died last time");
tablePartsSwap = config("Table", "Swap interaction behaviour on map table parts", false, "Make \"Read map\" part to open interactive map and \"Record discoveries\" part to generate map. +" +
"\nDoesn't work in Show On Interaction map mode [Not Synced with Server]", false);
localPath = Utils.GetSaveDataPath(FileHelpers.FileSource.Local);
cacheDirectory = Path.Combine(Paths.CachePath, pluginID);
configDirectory = Path.Combine(Paths.ConfigPath, pluginID);
InitTerminalCommands();
}
public void InitTerminalCommands()
{
new ConsoleCommand("repackpng", "Repack png file into nonhumanreadable format", delegate (ConsoleEventArgs args)
{
if (args.Length >= 2)
{
string filename = args.FullLine[(args[0].Length + 1)..].Trim();
if (Path.GetDirectoryName(filename).IsNullOrWhiteSpace())
filename = Path.Combine(configDirectory, filename);
string packedfilename = Path.ChangeExtension(filename, ".zpack");
File.WriteAllBytes(packedfilename, MapMaker.ExploredMapData.GetPackedImageData(File.ReadAllBytes(filename)));
args.Context.AddString($"Saved packed file {Path.GetFileName(packedfilename)}\n");
}
else
{
args.Context.AddString("Syntax: repackpng [filename]");
}
}, isCheat: false, isNetwork: false, onlyServer: false, isSecret: false, allowInDevBuild: false, () => new DirectoryInfo(configDirectory).GetFiles("*.png").Select(file => file.Name).ToList(), alwaysRefreshTabOptions: true);
}
ConfigEntry<T> config<T>(string group, string name, T defaultValue, ConfigDescription description, bool synchronizedSetting = true)
{
ConfigEntry<T> configEntry = Config.Bind(group, name, defaultValue, description);
SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry(configEntry);
syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
return configEntry;
}
ConfigEntry<T> config<T>(string group, string name, T defaultValue, string description, bool synchronizedSetting = true) => config(group, name, defaultValue, new ConfigDescription(description), synchronizedSetting);
public static void LogInfo(object message)
{
if (loggingEnabled.Value)
instance.Logger.LogInfo(message);
}
public static void LogWarning(object data)
{
if (loggingEnabled.Value)
instance.Logger.LogWarning(data);
}
public static void ShowMessage(string text, MessageHud.MessageType type = MessageHud.MessageType.Center)
{
// if someone doesn't want a message and cleared the value
if (text.IsNullOrWhiteSpace() || MessageHud.instance == null)
return;
MessageHud.instance.ShowMessage(type, text, 1);
}
public static void SetupConfigWatcher(bool enabled)
{
if (ZNet.instance == null || !ZNet.instance.IsServer())
return;
if (configFolderWatcher == null)
{
Directory.CreateDirectory(configDirectory);
configFolderWatcher = new FileSystemWatcher(configDirectory);
configFolderWatcher.Changed += new FileSystemEventHandler(ReadTextureFile);
configFolderWatcher.Created += new FileSystemEventHandler(ReadTextureFile);
configFolderWatcher.Deleted += new FileSystemEventHandler(ReadTextureFile);
configFolderWatcher.Renamed += new RenamedEventHandler(ReadTextureFile);
configFolderWatcher.IncludeSubdirectories = true;
configFolderWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
}
configFolderWatcher.EnableRaisingEvents = enabled;
ClearCustomTextures();
if (enabled)
ReadTextureFiles(initial: true);
}
private static void ClearCustomTextures()
{
customLayerExplored.AssignValueSafe("");
customLayerFog.AssignValueSafe("");
customLayerUnderfog.AssignValueSafe("");
customLayerOverfog.AssignValueSafe("");
}
private static void ReadTextureFiles(bool initial = false)
{
foreach (FileInfo file in new DirectoryInfo(configDirectory).EnumerateFiles("*", SearchOption.AllDirectories))
ReadCustomTexture(file.Name, file.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 (ZNet.instance == null || !ZNet.instance.IsServer())
return;
AssignCustomSyncedValue(customLayerExplored, initial, useCustomExploredLayer.Value && syncExploredLayerFromServer.Value ? MapMaker.GetTextureString(filename, fullname, layer: "explored") : "");
AssignCustomSyncedValue(customLayerFog, initial, useCustomFogLayer.Value && syncFogLayerFromServer.Value ? MapMaker.GetTextureString(filename, fullname, layer: "fog") : "");
AssignCustomSyncedValue(customLayerOverfog, initial, useCustomOverFogLayer.Value && syncOverFogLayerFromServer.Value ? MapMaker.GetTextureString(filename, fullname, layer: "overfog") : "");
AssignCustomSyncedValue(customLayerUnderfog, initial, useCustomUnderFogLayer.Value && syncUnderFogLayerFromServer.Value ? MapMaker.GetTextureString(filename, fullname, layer: "underfog") : "");
}
private static void AssignCustomSyncedValue(CustomSyncedValue<string> syncedValue, bool initial, string content)
{
if (content == null)
return;
if (content == "")
syncedValue.AssignValueIfChanged(content);
else if (initial)
syncedValue.AssignValueSafe(content);
else
syncedValue.AssignValueIfChanged(content);
}
[HarmonyPatch(typeof(MapTable), nameof(MapTable.OnRead), new Type[] { typeof(Switch), typeof(Humanoid), typeof(ItemDrop.ItemData), typeof(bool) })]
public static class MapTable_OnRead_ReadDiscoveriesInteraction
{
public static void Postfix(MapTable __instance, ItemDrop.ItemData item)
{
if (!modEnabled.Value)
return;
if (item != null)
return;
if (MapTable_OnWrite_RecordDiscoveriesInteraction.isCalled)
return;
if (!PrivateArea.CheckAccess(__instance.transform.position))
return;
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), nameof(MapTable.OnWrite))]
public static class MapTable_OnWrite_RecordDiscoveriesInteraction
{
public static bool isCalled = false;
public static void Prefix()
{
isCalled = true;
}
public static void Postfix(MapTable __instance, ItemDrop.ItemData item)
{
isCalled = false;
if (!modEnabled.Value)
return;
if (item != null)
return;
if (!PrivateArea.CheckAccess(__instance.transform.position))
return;
MapMaker.SavePlayerExploration();
if ((tablePartsSwap.Value || mapWindow.Value == MapWindow.ShowOnInteraction) && mapStorage.Value != MapStorage.LoadFromSharedFile)
MapMaker.GenerateMap();
else
MapViewer.ShowInteractiveMap();
}
}
[HarmonyPatch(typeof(Player), nameof(Player.Load))]
public static class Player_Load_DeleteDeprecatedData
{
private const string dataPrefix = "NomapPrinter_MapTexture_";
public static void Postfix(Player __instance)
{
__instance.m_customData.Where(data => data.Key.StartsWith(dataPrefix)).ToList().Do(data => __instance.m_customData.Remove(data.Key));
}
}
[HarmonyPatch(typeof(ZoneSystem), nameof(ZoneSystem.Start))]
public static class ZoneSystem_Start_CustomTexturesWatcherEnable
{
public static void Postfix() => SetupConfigWatcher(enabled: true);
}
[HarmonyPatch(typeof(ZoneSystem), nameof(ZoneSystem.OnDestroy))]
public static class ZoneSystem_OnDestroy_CustomTexturesWatcherDisable
{
public static void Postfix() => SetupConfigWatcher(enabled: false);
}
}
}