18 m_ClosableHeader.GetMainWidget().ClearFlags(
WidgetFlags.DRAGGABLE );
20 RecomputeOpenedContainers();
40 Man player =
GetGame().GetPlayer();
41 SlotsIcon focused_icon = GetFocusedSlotsIcon();
42 EntityAI focused_item = GetFocusedItem();
43 Container focused_cont = GetFocusedContainer();
46 if( selected_item && focused_item != selected_item)
48 if( selected_item.GetInventory().CanRemoveEntity() )
59 else if( !focused_item &&
m_Entity &&
m_Entity.GetInventory().CanAddAttachmentEx( selected_item, focused_icon.
GetSlotID() ) )
62 float quantity = selected_item.GetQuantity();
63 if( stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit() )
65 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Entity, selected_item, focused_icon.
GetSlotID() );
76 if (focused_item && focused_item.GetHierarchyParent() && focused_item.GetHierarchyParent().GetInventory().CanAddAttachment(selected_item))
79 focused_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
80 stack_max =
InventorySlots.GetStackMaxForSlotId( inv_loc.GetSlot() );
81 quantity = focused_item.GetQuantity();
82 if( focused_item.CanBeCombined(
ItemBase.Cast( selected_item ) ) )
84 focused_item.CombineItemsClient( selected_item,
true );
89 player.PredictiveSwapEntities( selected_item, focused_item );
94 if( focused_item.GetInventory().CanAddEntityInCargo( selected_item, selected_item.GetInventory().GetFlipCargo() ) )
106 if( focused_item && focused_item.GetInventory().CanRemoveEntity() && (!focused_icon || !focused_icon.
IsOutOfReach()) )
108 EntityAI item_in_hands =
GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
109 if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
113 player.PredictiveSwapEntities( item_in_hands, focused_item );
119 if( player.GetHumanInventory().CanAddEntityInHands( focused_item ) )
121 player.PredictiveTakeEntityToHands( focused_item );
133 if (CanTakeToInventory())
136 SlotsIcon focused_icon = GetFocusedSlotsIcon();
137 if( entity && !entity.IsLockedInSlot() && (!focused_icon || !focused_icon.
IsOutOfReach()) )
153 SlotsIcon focused_icon = GetFocusedSlotsIcon();
155 if (item && !item.IsLockedInSlot() && (focused_icon && !focused_icon.
IsOutOfReach()))
157 if (item.GetTargetQuantityMax() < item.GetQuantity())
158 item.SplitIntoStackMaxClient( null, -1 );
160 player.PhysicalPredictiveDropItem( item );
171 Man player =
GetGame().GetPlayer();
173 ItemBase selected_item =
ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
174 SlotsIcon focused_icon = GetFocusedSlotsIcon();
180 if( selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.
IsOutOfReach()) )
182 if( !prev_item &&
m_Entity.GetInventory().CanAddAttachmentEx( selected_item, selected_slot ) )
185 float quantity = selected_item.GetQuantity();
186 if( stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit() )
188 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Entity, selected_item, selected_slot );
193 selected_item.SplitIntoStackMaxClient(
m_Entity, selected_slot );
197 else if( selected_slot != -1 )
202 prev_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
203 stack_max =
InventorySlots.GetStackMaxForSlotId( inv_loc.GetSlot() );
204 quantity = prev_item.GetQuantity();
205 if( prev_item.CanBeCombined(
ItemBase.Cast( selected_item ) ) )
207 prev_item.CombineItemsClient( selected_item,
true );
212 player.PredictiveSwapEntities( selected_item, prev_item );
217 if( prev_item.GetInventory().CanAddEntityInCargo( selected_item, selected_item.GetInventory().GetFlipCargo() ) )
238 Man player =
GetGame().GetPlayer();
240 ItemBase selected_item =
ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
241 SlotsIcon focused_icon = GetFocusedSlotsIcon();
247 if( selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.
IsOutOfReach()) )
249 if(
m_Entity.GetInventory().CanAddAttachmentEx( selected_item, selected_slot ) )
252 float quantity = selected_item.GetQuantity();
253 if( stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit() )
262 else if( selected_slot != -1 )
267 prev_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
268 stack_max =
InventorySlots.GetStackMaxForSlotId( inv_loc.GetSlot() );
269 quantity = prev_item.GetQuantity();
270 if( prev_item.CanBeCombined(
ItemBase.Cast( selected_item ) ) )
289 return GetFocusedItem() != null && (!icon || !icon.
IsOutOfReach());
296 return item && ( !icon || !icon.
IsOutOfReach()) && item.CanBeSplit();
306 bool is_reserved =
false;
308 receiver.GetUserData(slots_icon);
309 float stackable = 0.0;
328 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
336 if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
338 player.GetWeaponManager().AttachMagazine( mag );
341 else if( receiver_item && !is_reserved )
343 if( (
ItemBase.Cast( receiver_item ) ).CanBeCombined(
ItemBase.Cast( item ) ) )
345 (
ItemBase.Cast( receiver_item ) ).CombineItemsClient(
ItemBase.Cast( item ) );
349 if( !receiver_item.GetInventory().CanRemoveEntity() )
351 GetGame().GetPlayer().PredictiveSwapEntities( receiver_item, item );
353 else if( receiver_item.GetInventory().CanAddAttachment( item ) )
355 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
358 else if( attached_entity && slot_id != -1 && attached_entity.GetInventory().CanAddAttachmentEx( item, slot_id ) )
361 stackable = item_base.GetTargetQuantityMax( slot_id );
363 if( stackable == 0 || stackable >= item_base.GetQuantity() )
365 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, slot_id);
367 else if( stackable != 0 && stackable < item_base.GetQuantity() )
369 item_base.SplitIntoStackMaxClient(
m_Entity, slot_id );
372 else if(attached_entity && slot_id == -1 && attached_entity.GetInventory().FindFreeLocationFor(item,
FindInventoryLocationType.ATTACHMENT,il))
375 stackable = item_base.GetTargetQuantityMax( il.GetSlot() );
377 if( stackable == 0 || stackable >= item_base.GetQuantity() )
379 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, il.GetSlot());
381 else if( stackable != 0 && stackable < item_base.GetQuantity() )
383 item_base.SplitIntoStackMaxClient(
m_Entity, il.GetSlot() );
395 for ( i = 1; i <
Count(); i++ )
399 Widget w =
Get( i ).GetMainWidget().FindAnyWidget(
"Cursor" + j );
420 string name = w.GetName();
421 name.Replace(
"PanelWidget",
"Render");
429 if( !iw || !iw.GetItem() || (iw.GetItem() ==
m_Entity) )
436 name = receiver.GetName();
437 name.Replace(
"PanelWidget",
"Render");
440 receiver_item =
ItemBase.Cast( receiver_iw.GetItem() );
443 receiver.GetUserData(slots_icon);
447 int stack_max =
InventorySlots.GetStackMaxForSlotId( receiver_item.GetInventory().GetSlotId(0) );
450 if( receiver_item.CanBeCombined(
ItemBase.Cast( iw.GetItem() ) ) )
468 else if( slots_icon && slots_icon.
GetSlotID() != -1 )
470 item =
ItemBase.Cast( iw.GetItem() );
472 if( item &&
m_Entity.GetInventory().CanAddAttachmentEx( item, slots_icon.
GetSlotID() ) )
512 target_entity = cargo.GetEntity() ;
515 target_cargo = target_entity.GetInventory().GetCargo();
520 if( target_cargo && target_entity )
522 c_x = target_cargo.GetHeight();
523 c_y = target_cargo.GetWidth();
528 if( c_x >
x && c_y >
y && target_entity.GetInventory().CanAddEntityInCargoEx( item, idx,
x,
y, item.GetInventory().GetFlipCargo() ) )
537 if( w.FindAnyWidget(
"Cursor") )
539 w.FindAnyWidget(
"Cursor").SetColor( color );
543 string name = w.GetName();
544 name.Replace(
"PanelWidget",
"Cursor" );
545 if( w.FindAnyWidget(
name ) )
547 w.FindAnyWidget(
name ).SetColor( color );
568 target_entity = cargo.GetEntity();
571 target_cargo = target_entity.GetInventory().GetCargo();
576 if( target_cargo && target_entity )
578 c_x = target_cargo.GetHeight();
579 c_y = target_cargo.GetWidth();
585 dst.SetCargoAuto(target_cargo, item,
x,
y, item.GetInventory().GetFlipCargo());
587 if( c_x >
x && c_y >
y && target_entity.GetInventory().LocationCanAddEntity(dst))
593 Icon icon = cargo.GetIcon( item );
610 string name = w.GetName();
611 name.Replace(
"PanelWidget",
"Render" );
622 return ipw.GetItem();
642 for (row = 0; row < row_count; row++)
646 for (col = 0; col < col_count; col++)
655 void RefreshSlot(
int row,
int column,
int slot_id,
string slot_name )
662 if (!
m_Entity.CanDisplayAttachmentSlot(slot_id_))
665 icon.GetMainWidget().Show(
false );
676 (
Container.Cast( cont.m_Parent ) ).Remove( cont );
678 icon.GetMainWidget().Show(
true);
682 icon.GetMainWidget().Show(
true );
693 if( cont && cont.GetEntity() != item)
696 (
Container.Cast( cont.m_Parent ) ).Remove( cont );
707 cont.SetEntity( item );
708 cont.SetSlotIcon( icon );
713 SetOpenForSlotIcon(cont.IsOpened(),icon);
723 bool draggable =
true;
724 bool can_be_removed = item.GetInventory().CanRemoveEntity();
725 bool in_hands_condition =
m_Entity.GetHierarchyRoot() ==
GetGame().GetPlayer();
737 if( !
m_Entity.CanReleaseAttachment( item ) )
742 if ((in_hands_condition || in_vicinity_condition) && can_be_removed)
770 string name = w.GetName();
771 name.Replace(
"PanelWidget",
"Render");
781 if (icon &&
m_Entity.GetInventory().GetSlotLock(iw.GetUserID()))
790 if (!item.GetInventory().CanRemoveEntity())
794 if (controlledPlayer.GetInventory().HasEntityInInventory(item) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
796 controlledPlayer.PredictiveTakeEntityToHands(item);
800 if (controlledPlayer.GetInventory().CanAddEntityToInventory(item) && item.GetInventory().CanRemoveEntity())
802 if (item.GetTargetQuantityMax() < item.GetQuantity())
803 item.SplitIntoStackMaxClient(controlledPlayer, -1);
809 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
811 if (item.GetTargetQuantityMax() < item.GetQuantity())
812 item.SplitIntoStackMaxHandsClient(controlledPlayer);
814 controlledPlayer.PredictiveTakeEntityToHands(item);
822 name.Replace(
"PanelWidget",
"Temperature");
823 w.FindAnyWidget(
name).Show(
false);
841 #ifdef DIAG_DEVELOPER
842 if (
g_Game.IsLeftCtrlDown())
843 ShowActionMenu(selectedItem);
846 if (CanSplitEx(selectedItem))
848 selectedItem.OnRightClick();
859 if (
g_Game.IsLeftCtrlDown())
864 if (controlledPlayer.CanDropEntity(selectedItem))
866 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
867 selectedItem.SplitIntoStackMaxClient(null, -1);
869 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
873 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, null ) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
889 void Init(
int attachments_categories_count,
int i,
string attachment_category,
string config_path_attachment_categories,
EntityAI entity,
int parent_m_Body_count )
899 m_RowConfigPath = config_path_attachment_categories +
" " + attachment_category +
" attachmentSlots";
900 string config_path_category_name = config_path_attachment_categories +
" " + attachment_category +
" name";
902 GetGame().ConfigGetText(config_path_category_name, categoryName);
908 int count = player_ghosts_slots2.Count();
912 for (
int j = 0; j < count; j++ )
914 string slotName = player_ghosts_slots2.Get(j);
920 GetGame().ConfigGetText(
path +
" ghostIcon", iconName);
928 slotsContainer.GetRootWidget().SetAlpha(0.7);
935 slotsContainer.GetRootWidget().SetSort(row);
964 super.UpdateInterval();
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
void MouseClick(Widget w, int x, int y, int button)
override void UpdateInterval()
override bool TransferItemToVicinity()
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
override bool IsItemWithQuantityActive()
override bool IsItemActive()
override bool CanCombineAmmo()
ref AttachmentsGroupContainer m_AttachmentsContainer
void Init(int attachments_categories_count, int i, string attachment_category, string config_path_attachment_categories, EntityAI entity, int parent_m_Body_count)
override void UnfocusAll()
void DoubleClick(Widget w, int x, int y, int button)
override bool TransferItem()
ref map< int, ref ContainerWithCargo > m_AttachmentCargos
string m_CategoryIdentifier
void AttachmentCategoriesRow(LayoutHolder parent, int sort=-1)
void RefreshSlot(int row, int column, int slot_id, string slot_name)
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
string GetCategoryIdentifier()
override bool CanCombine()
override bool EquipItem()
EntityAI GetItemPreviewItem(Widget w)
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
represents base for cargo storage for entities
Super root of all classes in Enforce script.
override bool InspectItem()
void ContainerWithCargo(LayoutHolder parent, int sort=-1)
script counterpart to engine's class Inventory
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
void RefreshPos(int row, int column)
provides access to slot configuration
EntityAI GetDraggedItem()
void ShowSourceDropzone(EntityAI item)
EntityAI GetSelectedItem()
void SetWidgetDraggable(Widget w, bool draggable)
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
SlotsIcon GetSlotIcon(int index)
void ClearRemainSelected()
ItemPreviewWidget GetRender()
void Init(EntityAI obj, bool reservation=false)
void SetSlotID(int slot_ID)
void SetSlotDisplayName(string text)
void SetContainer(Container container)
Widget GetMountedWidget()
Widget GetOutOfReachWidget()
Widget GetRadialIconPanel()
ImageWidget GetGhostSlot()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
FindInventoryLocationType
flags for searching locations in inventory