309 lines
16 KiB
C#
309 lines
16 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Harmony.XUiC_BackpackWindowPatches
|
|
{
|
|
internal class XUiC_BackpackWindowPatches
|
|
{
|
|
[HarmonyPatch(typeof(XUiC_BackpackWindow))]
|
|
[HarmonyPatch("GetBindingValue")]
|
|
public class GetBindingValuePatch
|
|
{
|
|
public static bool Prefix(ref XUiC_BackpackWindow __instance, ref bool __result, ref string value, string bindingName,
|
|
CachedStringFormatter<int> ___currencyFormatter
|
|
)
|
|
{
|
|
if (bindingName != null)
|
|
{
|
|
if (bindingName == "numRows")
|
|
{
|
|
int numRows = 10;
|
|
|
|
if (GameManager.Instance.gameStateManager.IsGameStarted())
|
|
{
|
|
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
|
|
|
if (primaryPlayer != null)
|
|
{
|
|
float additionalRows = primaryPlayer.Buffs.GetCustomVar("$BackpackCapacityIncrease");
|
|
if (additionalRows > 0)
|
|
{
|
|
numRows = numRows + (int)additionalRows;
|
|
}
|
|
}
|
|
}
|
|
|
|
value = numRows.ToString();
|
|
|
|
__result = true;
|
|
return false;
|
|
}
|
|
if (bindingName == "currencyamount")
|
|
{
|
|
value = "0";
|
|
if (XUi.IsGameRunning() && __instance.xui != null && __instance.xui.PlayerInventory != null)
|
|
{
|
|
value = ___currencyFormatter.Format(__instance.xui.PlayerInventory.CurrencyAmount);
|
|
}
|
|
__result = true;
|
|
return false;
|
|
}
|
|
if (bindingName == "currencyicon")
|
|
{
|
|
value = TraderInfo.CurrencyItem;
|
|
__result = true;
|
|
return false;
|
|
}
|
|
if (bindingName == "lootingorvehiclestorage")
|
|
{
|
|
bool flag = __instance.xui.vehicle != null && __instance.xui.vehicle.GetVehicle().HasStorage();
|
|
bool flag2 = __instance.xui.lootContainer != null && __instance.xui.lootContainer.EntityId == -1;
|
|
bool flag3 = __instance.xui.lootContainer != null && GameManager.Instance.World.GetEntity(__instance.xui.lootContainer.EntityId) is global::EntityDrone;
|
|
bool flag4 = __instance.xui.lootContainer != null && GameManager.Instance.World.GetEntity(__instance.xui.lootContainer.EntityId) is EntityNPCRebirth;
|
|
|
|
//Log.Out("XUiC_BackpackWindowRebirth-GetBindingValue __instance.xui.lootContainer != null: " + (__instance.xui.lootContainer != null));
|
|
|
|
value = (flag || flag2 || flag3 || flag4).ToString();
|
|
|
|
if (__instance.xui.lootContainer != null)
|
|
{
|
|
//Log.Out("XUiC_BackpackWindowRebirth-GetBindingValue __instance.xui.lootContainer.entityId: " + __instance.xui.lootContainer.entityId);
|
|
|
|
//Log.Out("XUiC_BackpackWindowRebirth-GetBindingValue __instance.xui.lootContainer.lootListName: " + __instance.xui.lootContainer.lootListName);
|
|
if (__instance.xui.lootContainer.lootListName == "FuriousRamsayLootGatherer")
|
|
{
|
|
value = "false";
|
|
}
|
|
}
|
|
|
|
__result = true;
|
|
return false;
|
|
}
|
|
if (bindingName == "quickstack")
|
|
{
|
|
value = (!__instance.xui.playerUI.windowManager.IsWindowOpen("creative") && __instance.xui.lootContainer == null && __instance.xui.vehicle == null).ToString();
|
|
|
|
string optionQoL = RebirthVariables.customQualityOfLife;
|
|
|
|
if (optionQoL == "none")
|
|
{
|
|
value = "false";
|
|
}
|
|
|
|
__result = true;
|
|
return false;
|
|
}
|
|
if (bindingName == "moveVehicle")
|
|
{
|
|
value = "false";
|
|
|
|
if (GameManager.Instance.gameStateManager.IsGameStarted())
|
|
{
|
|
string optionQoL = RebirthVariables.customQualityOfLife;
|
|
|
|
if (optionQoL == "none" || optionQoL == "quickstackonly")
|
|
{
|
|
value = "false";
|
|
}
|
|
else
|
|
{
|
|
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
|
|
|
if (primaryPlayer != null)
|
|
{
|
|
ProgressionValue progressionValue = primaryPlayer.Progression.GetProgressionValue("perkPackMule");
|
|
|
|
if (!__instance.xui.playerUI.windowManager.IsWindowOpen("creative") && __instance.xui.lootContainer == null && __instance.xui.vehicle == null && progressionValue.calculatedLevel >= 5)
|
|
{
|
|
int minMax = 50;
|
|
List<Entity> entitiesInBounds = primaryPlayer.world.GetEntitiesInBounds(typeof(global::EntityVehicleRebirth), BoundsUtils.BoundsForMinMax(primaryPlayer.position.x - minMax, primaryPlayer.position.y - 50, primaryPlayer.position.z - minMax, primaryPlayer.position.x + minMax, primaryPlayer.position.y + 30, primaryPlayer.position.z + minMax), new List<Entity>());
|
|
if (entitiesInBounds.Count > 0)
|
|
{
|
|
|
|
for (int x = 0; x < entitiesInBounds.Count; x++)
|
|
{
|
|
global::EntityVehicleRebirth entityVehicle = (global::EntityVehicleRebirth)entitiesInBounds[x];
|
|
|
|
if (entityVehicle != null)
|
|
{
|
|
//Log.Out("RebirthUtilities-DumpVehicleDown VEHICLE: " + entityVehicle.EntityClass.entityClassName);
|
|
|
|
PersistentPlayerData playerData = primaryPlayer.world.GetGameManager().GetPersistentPlayerList().GetPlayerData(entityVehicle.GetOwner());
|
|
|
|
if (playerData.EntityId == primaryPlayer.entityId)
|
|
{
|
|
value = "true";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
__result = true;
|
|
return false;
|
|
}
|
|
if (bindingName == "moveFollower")
|
|
{
|
|
value = "false";
|
|
|
|
if (GameManager.Instance.gameStateManager.IsGameStarted())
|
|
{
|
|
string optionQoL = RebirthVariables.customQualityOfLife;
|
|
|
|
if (optionQoL == "none" || optionQoL == "quickstackonly")
|
|
{
|
|
value = "false";
|
|
}
|
|
else
|
|
{
|
|
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
|
|
|
if (primaryPlayer != null)
|
|
{
|
|
ProgressionValue progressionValue = primaryPlayer.Progression.GetProgressionValue("perkPackMule");
|
|
|
|
if (!__instance.xui.playerUI.windowManager.IsWindowOpen("creative") && __instance.xui.lootContainer == null && __instance.xui.vehicle == null && progressionValue.calculatedLevel >= 3)
|
|
{
|
|
int minMax = 30;
|
|
List<Entity> entitiesInBounds = primaryPlayer.world.GetEntitiesInBounds(typeof(EntityNPCRebirth), BoundsUtils.BoundsForMinMax(primaryPlayer.position.x - minMax, primaryPlayer.position.y - 30, primaryPlayer.position.z - minMax, primaryPlayer.position.x + minMax, primaryPlayer.position.y + 30, primaryPlayer.position.z + minMax), new List<Entity>());
|
|
if (entitiesInBounds.Count > 0)
|
|
{
|
|
for (int x = 0; x < entitiesInBounds.Count; x++)
|
|
{
|
|
EntityNPCRebirth entityFollower = (EntityNPCRebirth)entitiesInBounds[x];
|
|
|
|
if (entityFollower != null)
|
|
{
|
|
float hidden = entityFollower.Buffs.GetCustomVar("$FR_NPC_Hidden");
|
|
float respawned = entityFollower.Buffs.GetCustomVar("$FR_NPC_Respawn");
|
|
|
|
if (hidden == 0 && respawned == 0 && !entityFollower.HasAnyTags(FastTags<TagGroup.Global>.Parse("noinventory")) && entityFollower.LeaderUtils.Owner != null && entityFollower.LeaderUtils.Owner.entityId == primaryPlayer.entityId)
|
|
{
|
|
value = "true";
|
|
__result = true;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
OwnedEntityData[] ownedEntities = primaryPlayer.GetOwnedEntities();
|
|
|
|
for (int j = 0; j < ownedEntities.Length; j++)
|
|
{
|
|
//Log.Out("DroneManagerPatches-RemoveAllVehiclesFromMap ___dronesActive.Count: " + ___dronesActive.Count);
|
|
|
|
EntityDrone entityFollower = primaryPlayer.world.GetEntity(ownedEntities[j].entityId) as EntityDrone;
|
|
|
|
if (entityFollower != null)
|
|
{
|
|
value = "true";
|
|
__result = true;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
__result = true;
|
|
return false;
|
|
}
|
|
if (bindingName == "creativewindowopen")
|
|
{
|
|
value = __instance.xui.playerUI.windowManager.IsWindowOpen("creative").ToString();
|
|
__result = true;
|
|
return false;
|
|
}
|
|
if (bindingName == "userlockmode")
|
|
{
|
|
value = __instance.UserLockMode.ToString();
|
|
__result = true;
|
|
return false;
|
|
}
|
|
}
|
|
__result = false;
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(XUiC_BackpackWindow))]
|
|
[HarmonyPatch("TryGetMoveDestinationInventory")]
|
|
public class TryGetMoveDestinationInventoryPatch
|
|
{
|
|
public static bool Prefix(ref XUiC_BackpackWindow __instance, ref bool __result, out IInventory _dstInventory)
|
|
{
|
|
_dstInventory = null;
|
|
XUiM_AssembleItem assembleItem = __instance.xui.AssembleItem;
|
|
if (((assembleItem != null) ? assembleItem.CurrentItem : null) != null)
|
|
{
|
|
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 1");
|
|
__result = false;
|
|
return false;
|
|
}
|
|
bool flag = __instance.xui.vehicle != null && __instance.xui.vehicle.GetVehicle().HasStorage();
|
|
bool flag2 = __instance.xui.lootContainer != null && __instance.xui.lootContainer.EntityId == -1;
|
|
bool flag3 = __instance.xui.lootContainer != null && GameManager.Instance.World.GetEntity(__instance.xui.lootContainer.EntityId) is global::EntityDrone;
|
|
bool flag4 = __instance.xui.lootContainer != null && GameManager.Instance.World.GetEntity(__instance.xui.lootContainer.EntityId) is EntityNPCRebirth;
|
|
|
|
if (!flag && !flag2 && !flag3 && !flag4)
|
|
{
|
|
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 2");
|
|
__result = false;
|
|
return false;
|
|
}
|
|
if (flag && __instance.xui.FindWindowGroupByName(XUiC_VehicleStorageWindowGroup.ID).GetChildByType<XUiC_VehicleContainer>() == null)
|
|
{
|
|
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 3");
|
|
__result = false;
|
|
return false;
|
|
}
|
|
if (flag3)
|
|
{
|
|
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 4");
|
|
_dstInventory = __instance.xui.lootContainer;
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 5");
|
|
IInventory inventory2;
|
|
if (!flag2 & !flag4)
|
|
{
|
|
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 6");
|
|
IInventory inventory = __instance.xui.vehicle.bag;
|
|
inventory2 = inventory;
|
|
}
|
|
else if (flag4)
|
|
{
|
|
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 7");
|
|
IInventory inventory = null;
|
|
inventory2 = inventory;
|
|
|
|
EntityNPCRebirth entity = GameManager.Instance.World.GetEntity(__instance.xui.lootContainer.EntityId) as EntityNPCRebirth;
|
|
if (entity != null)
|
|
{
|
|
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 8");
|
|
inventory2 = entity.lootContainer;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 9");
|
|
IInventory inventory = __instance.xui.lootContainer;
|
|
inventory2 = inventory;
|
|
}
|
|
_dstInventory = inventory2;
|
|
}
|
|
__result = true;
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|