Implement auto loot
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System;
|
||||
using HarmonyLib;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace CykaRaider
|
||||
{
|
||||
@@ -23,18 +24,34 @@ namespace CykaRaider
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DataHub), "GetFixedData")]
|
||||
static void xpMultiplier(DataHub __instance) {
|
||||
for (int i = 0; i < __instance.itemDataDic.Count; i++) {
|
||||
var itemData = __instance.itemDataDic[i];
|
||||
if (itemData.maxStack > 0) {
|
||||
static void maxStackMultiplier(DataHub __instance) {
|
||||
foreach (var itemData in __instance.itemDataDic) {
|
||||
if (itemData.Value.maxStack > 0) {
|
||||
if (Main.debugMode.Value)
|
||||
Console.WriteLine("CykaRaider: GetFixedData: Old maxStack {0}", itemData.maxStack);
|
||||
itemData.maxStack = (int)(itemData.maxStack * Main.maxStackMultiplier.Value);
|
||||
Console.WriteLine("CykaRaider: GetFixedData: Old maxStack {0}", itemData.Value.maxStack);
|
||||
itemData.Value.maxStack = (int)(itemData.Value.maxStack * Main.maxStackMultiplier.Value);
|
||||
if (Main.debugMode.Value)
|
||||
Console.WriteLine("CykaRaider: GetFixedData: New maxStack {0}", itemData.maxStack);
|
||||
Console.WriteLine("CykaRaider: GetFixedData: New maxStack {0}", itemData.Value.maxStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(MyBagControl), "GetAllButtonShow")]
|
||||
static void autoLoot(MyBagControl __instance) {
|
||||
if (Main.autoLoot.Value) {
|
||||
if (Main.debugMode.Value)
|
||||
Console.WriteLine("CykaRaider: autoLoot: AutoLoot is enabled");
|
||||
var trav = Traverse.Create(__instance);
|
||||
var button = trav.Field("getAll_BT").GetValue<Button>();
|
||||
button.onClick.Invoke();
|
||||
if (Main.debugMode.Value)
|
||||
Console.WriteLine("CykaRaider: autoLoot: Button clicked");
|
||||
__instance.BeClosed();
|
||||
if (Main.debugMode.Value)
|
||||
Console.WriteLine("CykaRaider: autoLoot: Bag closed");
|
||||
}
|
||||
}
|
||||
// [HarmonyPrefix]
|
||||
// [HarmonyPatch(typeof(XRL.World.Parts.Experience), "HandleEvent")]
|
||||
// static void xpMultiplier(ref AwardedXPEvent E) {
|
||||
|
||||
Reference in New Issue
Block a user