Upload from upload_mods.ps1
This commit is contained in:
55
Harmony/Harmony_Bag.cs
Normal file
55
Harmony/Harmony_Bag.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
namespace Harmony.EntityPlayerRebirth
|
||||
{
|
||||
internal class BagPatches
|
||||
{
|
||||
public static int numSlots = 50;
|
||||
|
||||
public static MethodInfo checkBagAssigned = AccessTools.Method(typeof(Bag), "checkBagAssigned", new Type[] { typeof(int) });
|
||||
public static MethodInfo onBackpackChanged = AccessTools.Method(typeof(Bag), "onBackpackChanged", new Type[] { });
|
||||
|
||||
[HarmonyPatch(typeof(Bag))]
|
||||
[HarmonyPatch("GetSlots")]
|
||||
public class GetSlots
|
||||
{
|
||||
private static bool Prefix(Bag __instance, ref ItemStack[] __result, ref global::EntityAlive ___entity, ref ItemStack[] ___items)
|
||||
{
|
||||
if (___entity.Spawned)
|
||||
{
|
||||
float additionalRows = ___entity.Buffs.GetCustomVar("$BackpackCapacityIncrease");
|
||||
if (additionalRows > 0)
|
||||
{
|
||||
numSlots = numSlots + (int)additionalRows;
|
||||
}
|
||||
}
|
||||
|
||||
checkBagAssigned.Invoke(__instance, new object[] { numSlots });
|
||||
|
||||
__result = ___items;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Bag))]
|
||||
[HarmonyPatch("SetSlots")]
|
||||
public class SetSlots
|
||||
{
|
||||
private static bool Prefix(Bag __instance, ItemStack[] _slots, ref global::EntityAlive ___entity, ref ItemStack[] ___items, ref XUiEvent_BackpackItemsChangedInternal ___OnBackpackItemsChangedInternal)
|
||||
{
|
||||
if (___entity.Spawned)
|
||||
{
|
||||
float additionalRows = ___entity.Buffs.GetCustomVar("$BackpackCapacityIncrease");
|
||||
if (additionalRows > 0)
|
||||
{
|
||||
numSlots = numSlots + (int)additionalRows;
|
||||
}
|
||||
}
|
||||
|
||||
checkBagAssigned.Invoke(__instance, new object[] { numSlots });
|
||||
___items = _slots;
|
||||
onBackpackChanged.Invoke(__instance, new object[] { });
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user