Implement auto loot
This commit is contained in:
@@ -13,6 +13,7 @@ namespace CykaRaider {
|
|||||||
|
|
||||||
public static ConfigEntry<int> lootTimeAdder;
|
public static ConfigEntry<int> lootTimeAdder;
|
||||||
public static ConfigEntry<float> maxStackMultiplier;
|
public static ConfigEntry<float> maxStackMultiplier;
|
||||||
|
public static ConfigEntry<bool> autoLoot;
|
||||||
|
|
||||||
public static ConfigEntry<bool> debugMode;
|
public static ConfigEntry<bool> debugMode;
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ namespace CykaRaider {
|
|||||||
debugMode = Config.Bind("General", "Debug Mode", false, new ConfigDescription("Debug Mode"));
|
debugMode = Config.Bind("General", "Debug Mode", false, new ConfigDescription("Debug Mode"));
|
||||||
lootTimeAdder = Config.Bind("General", "Loot Time Adder", 0, new ConfigDescription("Loot Time Adder"));
|
lootTimeAdder = Config.Bind("General", "Loot Time Adder", 0, new ConfigDescription("Loot Time Adder"));
|
||||||
maxStackMultiplier = Config.Bind("General", "Max Stack Multiplier", 1f, new ConfigDescription("Max Stack Multiplier"));
|
maxStackMultiplier = Config.Bind("General", "Max Stack Multiplier", 1f, new ConfigDescription("Max Stack Multiplier"));
|
||||||
|
autoLoot = Config.Bind("General", "Auto Loot", false, new ConfigDescription("Auto Loot"));
|
||||||
|
|
||||||
Logger.LogInfo("Cyka mod loaded");
|
Logger.LogInfo("Cyka mod loaded");
|
||||||
HarmonyFileLog.Enabled = true;
|
HarmonyFileLog.Enabled = true;
|
||||||
|
@@ -52,6 +52,9 @@
|
|||||||
<Reference Include="UnityEngine.CoreModule">
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
<HintPath>$(GAME_MANAGED)/UnityEngine.CoreModule.dll</HintPath>
|
<HintPath>$(GAME_MANAGED)/UnityEngine.CoreModule.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UI">
|
||||||
|
<HintPath>$(GAME_MANAGED)/UnityEngine.UI.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="XRL">
|
<Reference Include="XRL">
|
||||||
<HintPath>$(GAME_MANAGED)/Assembly-CSharp.dll</HintPath>
|
<HintPath>$(GAME_MANAGED)/Assembly-CSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace CykaRaider
|
namespace CykaRaider
|
||||||
{
|
{
|
||||||
@@ -23,18 +24,34 @@ namespace CykaRaider
|
|||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(DataHub), "GetFixedData")]
|
[HarmonyPatch(typeof(DataHub), "GetFixedData")]
|
||||||
static void xpMultiplier(DataHub __instance) {
|
static void maxStackMultiplier(DataHub __instance) {
|
||||||
for (int i = 0; i < __instance.itemDataDic.Count; i++) {
|
foreach (var itemData in __instance.itemDataDic) {
|
||||||
var itemData = __instance.itemDataDic[i];
|
if (itemData.Value.maxStack > 0) {
|
||||||
if (itemData.maxStack > 0) {
|
|
||||||
if (Main.debugMode.Value)
|
if (Main.debugMode.Value)
|
||||||
Console.WriteLine("CykaRaider: GetFixedData: Old maxStack {0}", itemData.maxStack);
|
Console.WriteLine("CykaRaider: GetFixedData: Old maxStack {0}", itemData.Value.maxStack);
|
||||||
itemData.maxStack = (int)(itemData.maxStack * Main.maxStackMultiplier.Value);
|
itemData.Value.maxStack = (int)(itemData.Value.maxStack * Main.maxStackMultiplier.Value);
|
||||||
if (Main.debugMode.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]
|
// [HarmonyPrefix]
|
||||||
// [HarmonyPatch(typeof(XRL.World.Parts.Experience), "HandleEvent")]
|
// [HarmonyPatch(typeof(XRL.World.Parts.Experience), "HandleEvent")]
|
||||||
// static void xpMultiplier(ref AwardedXPEvent E) {
|
// static void xpMultiplier(ref AwardedXPEvent E) {
|
||||||
|
Reference in New Issue
Block a user