-
Notifications
You must be signed in to change notification settings - Fork 1
/
Plugin.cs
48 lines (39 loc) · 1.52 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
using BepInEx;
using BepInEx.Configuration;
using Aki.Reflection.Patching;
using Aki.Reflection.Utils;
using System.Reflection;
using UnityEngine;
namespace AdjustableTraderRows
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{
// create config ent
public static ConfigEntry<int> configNumberInARow;
private void Awake()
{
// set up config
configNumberInARow = Config.Bind("General", "Traders In a Row", 4, new ConfigDescription("Number of traders in a single row", new AcceptableValueRange<int>(1, 16)));
// Plugin startup logic
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
new TraderRowsPatch().Enable();
}
public class TraderRowsPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return typeof(EFT.UI.TraderPanel).GetMethod("Update", PatchConstants.PrivateFlags);
}
[PatchPostfix]
private static void AdjustTraderRows()
{
var TradersContainer = GameObject.Find("Traders Container");
var TradeRectTrans = TradersContainer.RectTransform();
float DefaultSize = 177.25f;
float ResultRows = DefaultSize * (float)Plugin.configNumberInARow.Value;
TradeRectTrans.sizeDelta = new Vector2(ResultRows, 481f);
}
}
}
}