forked from mpstark/SPT-DynamicMaps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
83 lines (72 loc) · 2.58 KB
/
Plugin.cs
File metadata and controls
83 lines (72 loc) · 2.58 KB
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
using System;
using System.Reflection;
using BepInEx;
using BepInEx.Logging;
using Comfort.Common;
using DrakiaXYZ.VersionChecker;
using DynamicMaps.Config;
using DynamicMaps.Patches;
using DynamicMaps.UI;
using EFT.UI;
using EFT.UI.Map;
namespace DynamicMaps
{
// the version number here is generated on build and may have a warning if not yet built
[BepInPlugin("com.mpstark.DynamicMaps", "DynamicMaps", BuildInfo.Version)]
[BepInDependency("com.SPT.custom")]
public class Plugin : BaseUnityPlugin
{
public const int TarkovVersion = 30626;
public static Plugin Instance;
public static ManualLogSource Log => Instance.Logger;
public static string Path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public ModdedMapScreen Map;
internal void Awake()
{
if (!VersionChecker.CheckEftVersion(Logger, Info, Config))
{
throw new Exception("Invalid EFT Version");
}
Settings.Init(Config);
Config.SettingChanged += (x, y) => Map?.ReadConfig();
Instance = this;
// patches
new BattleUIScreenShowPatch().Enable();
new CommonUIAwakePatch().Enable();
new MapScreenShowPatch().Enable();
new MapScreenClosePatch().Enable();
new GameWorldOnDestroyPatch().Enable();
new GameWorldUnregisterPlayerPatch().Enable();
new GameWorldRegisterLootItemPatch().Enable();
new GameWorldDestroyLootPatch().Enable();
new AirdropBoxOnBoxLandPatch().Enable();
new PlayerOnDeadPatch().Enable();
new PlayerInventoryThrowItemPatch().Enable();
}
/// <summary>
/// Attach to the map screen
/// </summary>
internal void TryAttachToMapScreen(MapScreen mapScreen)
{
if (Map != null)
{
return;
}
Log.LogInfo("Trying to attach to MapScreen");
// attach to common UI first to call awake and set things up, then attach to sleeping map screen
Map = ModdedMapScreen.Create(Singleton<CommonUI>.Instance.gameObject);
Map.transform.SetParent(mapScreen.transform);
}
/// <summary>
/// Attach the peek component
/// </summary>
internal void TryAttachToBattleUIScreen(EftBattleUIScreen battleUI)
{
if (Map == null)
{
return;
}
Map.TryAddPeekComponent(battleUI);
}
}
}