884 {
885 ItemManager.GetInstance().HideDropzones();
886 ItemManager.GetInstance().SetIsDragging(false);
887 string name = w.GetName();
888 name.Replace(
"PanelWidget",
"Render");
889 PlayerBase player = PlayerBase.Cast(
g_Game.GetPlayer() );
890
891 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
893 {
894 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
895 }
896
897 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(
name ));
898 if (selectedIpw == null)
899 {
900 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( "Render" ));
901 }
902 if (selectedIpw == null)
903 {
904 return;
905 }
906
907 InventoryItem targetEntity = InventoryItem.Cast(targetIpw.
GetItem());
908 InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.
GetItem());
909 if (!selectedEntity)
910 {
911 return;
912 }
913 int index;
914 InventoryLocation ilSrc;
915 InventoryLocation ilDst;
916 if (
m_Lock && targetEntity == selectedEntity)
917 {
918 index = player.GetHumanInventory().FindUserReservedLocationIndex(
m_Item);
919 ilSrc = new InventoryLocation();
920 ilDst = new InventoryLocation();
921
922 m_Item.GetInventory().GetCurrentInventoryLocation(ilSrc);
923 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
924
925 if (ilDst.
GetParent().GetInventory().LocationCanAddEntity(ilDst))
926 {
927
928 player.GetHumanInventory().ClearUserReservedLocation(
m_Item);
929 player.PredictiveTakeToDst(ilSrc, ilDst);
931 }
932 }
934 {
935 CargoContainer parentCargo = CargoContainer.Cast(
m_Parent);
936
937 float parentX;
938 float parentY;
939
940 parentCargo.GetRootWidget().GetScreenPos(parentX, parentY);
941
942 float iconSize = parentCargo.GetIconSize();
943 float spaceSize = parentCargo.GetSpaceSize();
944
945 int PosX = (
x-parentX) / (iconSize + spaceSize);
946 int PosY = (
y-parentY) / (iconSize + spaceSize);
947
949 CargoBase targetCargo = parent.GetInventory().GetCargo();
950
951 ilDst = new InventoryLocation();
952 ilDst.
SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
953
954 if (parent.GetInventory().LocationCanAddEntity(ilDst))
955 {
956 player.GetHumanInventory().ClearUserReservedLocation(
m_Item);
958
959 SplitItemUtils.TakeOrSplitToInventoryLocation(player, ilDst);
960 }
961 }
962 else
963 {
964 ilDst = new InventoryLocation();
965 static int testedFlags = InventoryCombinationFlags.COMBINE_QUANTITY2 | InventoryCombinationFlags.ADD_AS_CARGO | InventoryCombinationFlags.ADD_AS_ATTACHMENT | InventoryCombinationFlags.SWAP | InventoryCombinationFlags.FSWAP | InventoryCombinationFlags.SWAP_MAGAZINE;
966
967 int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
969 }
970 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
bool PerformCombination(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, InventoryLocation ilSwapDst=null)
proto native EntityAI GetParent()
returns parent of current inventory location
proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip)
based on Cargo.IsProxyCargo uses SetProxyCargo or SetCargo respectively