-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlugin.cs
57 lines (49 loc) · 2.03 KB
/
Plugin.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
using System;
using System.IO;
using System.Reflection;
using BepInEx;
using BepInEx.Logging;
using DrakiaXYZ.VersionChecker;
using EFT.InventoryLogic;
using EFT.UI;
using QuickWeaponRackAccess.Patches;
using SPT.Reflection.Utils;
namespace QuickWeaponRackAccess
{
// the version number here is generated on build and may have a warning if not yet built
[BepInPlugin("com.mpstark.QuickWeaponRackAccess", "QuickWeaponRackAccess", BuildInfo.Version)]
public class Plugin : BaseUnityPlugin
{
public const int TarkovVersion = 30626;
public static Plugin Instance;
public static ManualLogSource Log => Instance.Logger;
public static Inventory PlayerInventory => ClientAppUtils.GetMainApp().GetClientBackEndSession().Profile.Inventory;
public static string PluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public QuickWeaponRackComponent QuickWeaponRackComponent => _quickWeaponRackComponent;
private QuickWeaponRackComponent _quickWeaponRackComponent;
internal void Awake()
{
if (!VersionChecker.CheckEftVersion(Logger, Info, Config))
{
throw new Exception("Invalid EFT Version");
}
Instance = this;
DontDestroyOnLoad(this);
// patches
new InventoryScreenShowPatch().Enable();
new QuickFindAppropriatePlacePatch().Enable();
}
/// <summary>
/// Try attach the tab to the inventory screen, but only if hideout isn't upgraded
/// </summary>
public void TryAttachToInventoryScreen(InventoryScreen inventoryScreen)
{
// only attach if not already attached or hideout isn't upgraded
if (_quickWeaponRackComponent != null || !PlayerInventory.HideoutAreaStashes.ContainsKey(EFT.EAreaType.WeaponStand))
{
return;
}
_quickWeaponRackComponent = QuickWeaponRackComponent.AttachToInventoryScreen(inventoryScreen);
}
}
}