888 {
889 ItemManager.GetInstance().HideDropzones();
890 ItemManager.GetInstance().SetIsDragging(false);
891 string name = w.GetName();
892 name.Replace(
"PanelWidget",
"Render");
894
895 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
897 {
898 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
899 }
900
901 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(
name ));
902 if (selectedIpw == null)
903 {
904 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( "Render" ));
905 }
906 if (selectedIpw == null)
907 {
908 return;
909 }
910
911 InventoryItem targetEntity = InventoryItem.Cast(targetIpw.
GetItem());
912 InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.
GetItem());
913 if (!selectedEntity)
914 {
915 return;
916 }
917 int index;
918 InventoryLocation ilSrc;
919 InventoryLocation ilDst;
920 if (
m_Lock && targetEntity == selectedEntity)
921 {
922 index = player.GetHumanInventory().FindUserReservedLocationIndex(
m_Item);
923 ilSrc = new InventoryLocation();
924 ilDst = new InventoryLocation();
925
926 m_Item.GetInventory().GetCurrentInventoryLocation(ilSrc);
927 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
928
929 if (ilDst.
GetParent().GetInventory().LocationCanAddEntity(ilDst))
930 {
931
932 player.GetHumanInventory().ClearUserReservedLocation(
m_Item);
933 player.PredictiveTakeToDst(ilSrc, ilDst);
935 }
936 }
938 {
939 CargoContainer parentCargo = CargoContainer.Cast(
m_Parent);
940
941 float parentX;
942 float parentY;
943
944 parentCargo.GetRootWidget().GetScreenPos(parentX, parentY);
945
946 float iconSize = parentCargo.GetIconSize();
947 float spaceSize = parentCargo.GetSpaceSize();
948
949 int PosX = (
x-parentX) / (iconSize + spaceSize);
950 int PosY = (
y-parentY) / (iconSize + spaceSize);
951
953 CargoBase targetCargo = parent.GetInventory().GetCargo();
954
955 ilDst = new InventoryLocation();
956 ilDst.
SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
957
958 if (parent.GetInventory().LocationCanAddEntity(ilDst))
959 {
960 player.GetHumanInventory().ClearUserReservedLocation(
m_Item);
962
963 SplitItemUtils.TakeOrSplitToInventoryLocation(player, ilDst);
964 }
965 }
966 else
967 {
968 ilDst = new InventoryLocation();
969 static int testedFlags = InventoryCombinationFlags.COMBINE_QUANTITY2 | InventoryCombinationFlags.ADD_AS_CARGO | InventoryCombinationFlags.ADD_AS_ATTACHMENT | InventoryCombinationFlags.SWAP | InventoryCombinationFlags.FSWAP | InventoryCombinationFlags.SWAP_MAGAZINE;
970
971 int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
973 }
974 }
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
proto native CGame GetGame()