22 RecomputeOpenedContainers();
39 return ( ContainerWithCargo.Cast( GetFocusedContainer() ) != null );
44 return ( ContainerWithCargoAndAttachments.Cast( GetFocusedContainer() ) != null );
59 string type = entity.GetType();
60 if ( container.IsInherited( ContainerWithCargo ) )
62 if ( !serialized_types.Contains( type ) )
64 ContainerWithCargo item_with_cargo = ContainerWithCargo.Cast( container );
65 serialized_types.Insert( type, item_with_cargo.IsOpened() );
70 if ( serialized_types.Count() > 0 )
73 if ( file.
Open(
"inventory_state.save",
FileMode.APPEND ) )
75 file.
Write( serialized_types.Count() );
77 for ( i = 0; i < serialized_types.Count(); i++ )
79 file.
Write( serialized_types.GetKey( i ) );
80 file.
Write( serialized_types.GetElement( i ) );
97 string name = w.GetName();
127 string name = receiver.GetName();
186 string name = receiver.GetName();
205 bool equal_typed = item.GetType() == receiver_item.GetType();
206 if ( !receiver_item.IsInherited(
ItemBase ) || item == null )
213 if ( !item.GetInventory().CanRemoveEntity() )
216 if ( (
ItemBase.Cast( receiver_item ) ).CanBeCombined(
ItemBase.Cast( item ) ) )
224 receiver_item.GetInventory().GetCurrentInventoryLocation( il1 );
225 item.GetInventory().GetCurrentInventoryLocation( il2 );
229 player.PredictiveSwapEntities( item, receiver_item );
234 PrepareOwnedTooltip(item);
239 menu.RefreshQuickbar();
265 string name = w.GetName();
285 if (player.CanDropEntity(item))
290 if (itemBase.GetTargetQuantityMax() < itemBase.GetQuantity())
291 itemBase.SplitIntoStackMaxClient(null, -1);
293 player.PhysicalPredictiveDropItem(itemBase);
300 menu.RefreshQuickbar();
311 super.UpdateInterval();
314 vector pos = player.GetPosition();
326 for (
int i = 0; i < objects.Count(); i++ )
328 eai = objects.Get( i );
338 showable_items.Insert( eai );
352 for ( i = 0; i < showable_items.Count(); i++ )
354 new_showed_items.Insert(showable_items[i],null);
358 bool need_update_focus =
false;
364 if ( !new_showed_items.Contains( ent ) )
366 GetMainWidget().Update();
367 if ( con.IsActive() )
368 need_update_focus =
true;
381 new_showed_items.Clear();
383 for ( i = 0; i < showable_items.Count(); i++ )
385 EntityAI entity = showable_items.Get( i );
390 string config =
"CfgVehicles " + entity.GetType() +
" GUIInventoryAttachmentsProps";
392 if (
GetGame().ConfigIsExisting( config ) )
396 new_showed_items.Insert( entity, ac );
397 showed_items_IDs.Insert( entity.GetID(), ac);
399 else if ( entity.GetSlotsCountCorrect() > 0 && entity.GetInventory().GetCargo() )
403 if ( entity.IsAlive() )
409 new_showed_items.Insert( entity, zmb_cnt );
410 showed_items_IDs.Insert( entity.GetID(), zmb_cnt );
415 ContainerWithCargoAndAttachments iwca =
new ContainerWithCargoAndAttachments(
this, -1 );
416 iwca.SetEntity( entity,
false );
417 new_showed_items.Insert( entity, iwca );
418 showed_items_IDs.Insert( entity.GetID(), iwca );
421 else if ( entity.GetInventory().GetCargo() )
423 ContainerWithCargo iwc =
new ContainerWithCargo(
this, -1 );
424 iwc.SetEntity( entity, 0,
false );
425 new_showed_items.Insert( entity, iwc );
426 showed_items_IDs.Insert( entity.GetID(), iwc );
427 iwc.UpdateInterval();
429 else if ( entity.GetSlotsCountCorrect() > 0 )
431 if ( entity.HasEnergyManager() )
435 new_showed_items.Insert( entity, iwem );
436 showed_items_IDs.Insert( entity.GetID(), iwem );
442 if ( !
PlayerBase.DEBUG_INVENTORY_ACCESS && entity.IsAlive() && ( !
PlayerBase.Cast( entity ).IsUnconscious() && !
PlayerBase.Cast( entity ).IsRestrained() ) )
451 new_showed_items.Insert( entity, plyr_cnt );
452 showed_items_IDs.Insert( entity.GetID(), plyr_cnt);
456 ContainerWithCargoAndAttachments iwcas =
new ContainerWithCargoAndAttachments(
this, -1 );
457 iwcas.SetEntity( entity,
false );
458 new_showed_items.Insert( entity, iwcas );
459 showed_items_IDs.Insert( entity.GetID(), iwcas );
460 iwcas.UpdateInterval();
473 if ( !
PlayerBase.DEBUG_INVENTORY_ACCESS && entity.IsAlive() && ( !
PlayerBase.Cast( entity ).IsUnconscious() && !
PlayerBase.Cast( entity ).IsRestrained() ) )
475 GetMainWidget().Update();
476 if ( con.IsActive() )
477 need_update_focus =
true;
488 GetMainWidget().Update();
489 if ( con.IsActive() )
490 need_update_focus =
true;
497 new_showed_items.Insert( entity,
m_ShowedItems.Get( entity ) );
498 showed_items_IDs.Insert( entity.GetID(),
m_ShowedItemsIDs.Get( entity.GetID() ) );
506 for ( i = 0; i < cargoes.Count(); i++ )
513 ContainerWithCargo pxc =
new ContainerWithCargo(
this, -1 );
515 new_showed_cargos.Insert( cgo, pxc );
516 pxc.UpdateInterval();
532 if ( !new_showed_cargos.Contains( cgo2 ) )
535 if( con2.IsActive() )
536 need_update_focus =
true;
537 GetMainWidget().Update();
548 if (need_update_focus)
558 in.UpdateConsoleToolbar();
566 w.GetUserData(slots_icon);
617 w.GetScreenSize(
x,
y );
618 if ( w == GetMainWidget() )
620 GetMainWidget().Update();
628 if ( w == GetMainWidget() )
630 GetMainWidget().Update();
638 super.CollapseButtonOnMouseButtonDown(w);
662 if (item.HasQuantity() && item.CanBeSplit())
void Inventory(LayoutHolder parent)
InventoryLocationType
types of Inventory Location
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
protected Widget m_Parent
void SetEntity(EntityAI entity)
override bool IsPlayerInside(PlayerBase player, string selection)
represents base for cargo storage for entities
proto native int GetOwnerCargoIndex()
proto native EntityAI GetCargoOwner()
get the entity that owns the cargo
override bool IsDisplayable()
protected ref CollapsibleHeader m_CollapsibleHeader
override void Remove(LayoutHolder container)
void UpdateCollapseButtons()
static ColorManager GetInstance()
void SetColor(Widget w, int color)
override Header GetHeader()
override EntityAI GetFocusedItem()
override void SetEntity(EntityAI entity, bool immedUpdate=true)
override bool IsInventoryVisible()
Serializer API implementation for File IO. See Serializer for more info. usage:
proto native void Close()
proto native bool Open(string path, FileMode mode=FileMode.READ)
script counterpart to engine's class Inventory
proto native bool IsPlaceholderEntity(notnull Object e)
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
proto native int GetType()
returns type of InventoryLocation
void ShowSourceDropzone(EntityAI item)
void SetWidgetDraggable(Widget w, bool draggable)
void SetDefaultHeaderOpenState(string type, bool is_opened)
bool EvaluateContainerDragabilityDefault(EntityAI entity)
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
void SetPlayer(PlayerBase player)
proto bool Write(void value_out)
ref map< int, ref Container > m_ShowedItemsIDs
ref map< EntityAI, ref Container > m_ShowedItems
override bool OnChildAdd(Widget w, Widget child)
protected bool m_IsProcessing
void OnDropReceivedFromIcon(Widget w, int x, int y, Widget receiver)
void DraggingOverIcon(Widget w, int x, int y, Widget receiver)
bool IsItemWithCategoriesActive()
const float DISTANCE_TO_ENTITIES
void ToggleContainer(Widget w, EntityAI item)
override void UpdateInterval()
bool IsItemWithAttachmentsActive()
void OnDropReceivedFromEmptySpace(Widget w, int x, int y, Widget receiver)
void UpdateHeader(EntityAI entity, Container cont, PlayerBase player)
Updates header dragability to be consistent with current 'icon' behaviour.
void OnLeftPanelDropReceived(Widget w, int x, int y, Widget receiver)
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
VicinitySlotsContainer GetVicinityIconsContainer()
ref VicinitySlotsContainer m_VicinityIconsContainer
override bool CanOpenCloseContainerEx(EntityAI focusedEntity)
override bool OnChildRemove(Widget w, Widget child)
void ToggleContainer(notnull Container conta)
void VicinityContainer(LayoutHolder parent, int sort=-1)
const float DISTANCE_TO_THE_REST
override void ExpandCollapseContainer()
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
ref map< CargoBase, ref Container > m_ShowedCargos
override void CollapseButtonOnMouseButtonDown(Widget w)
ref array< EntityAI > m_ShowedItemIcons
bool IsContainerWithCargoActive()
bool IsVicinityContainerIconsActive()
void TraverseShowedItems()
override bool SplitItem()
array< EntityAI > GetVicinityItems()
static VicinityItemManager GetInstance()
void Update(float delta_time)
array< CargoBase > GetVicinityCargos()
void ShowItemsInContainers(array< EntityAI > items)
void SetEntity(EntityAI zombie_entity)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.