DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ UpdateInterval()

override void VicinityContainer::UpdateInterval ( )
inlineprotected

Allow view access of inventory if in free camera. Write access is elsewhere

Allow view access of inventory if in free camera. Write access is elsewhere

Adjust left cargo container scroller height depending on visible items in the vicinity

См. определение в файле VicinityContainer.c строка 341

342 {
343 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
344
345 if (!player)
346 return;
347
348 super.UpdateInterval();
349
350 EntityAI eai;
351 vector pos = player.GetPosition();
352 array<EntityAI> objects;
353
354 VicinityItemManager.GetInstance().Update( player.GetDeltaT() );
355 objects = VicinityItemManager.GetInstance().GetVicinityItems();
356
357 //GetItemsShowableInInventory
358 array<EntityAI> showable_items = new array<EntityAI>;
359 bool isUsedMicromanagment = false;
360 EntityAI selectesItem = ItemManager.GetInstance().GetSelectedItem();
361 int m_OldShowedItemIconsCount = m_ShowedItemIcons.Count();
362
363 if (selectesItem && ItemManager.GetInstance().IsMicromanagmentMode())
364 {
365 if (m_ShowedItemIcons.Find(selectesItem) != -1)
366 {
367 isUsedMicromanagment = true;
368 }
369 }
370 m_ShowedItemIcons.Clear();
371
372 GameInventory game_inventory = player.GetInventory();
373 for ( int i = 0; i < objects.Count(); i++ )
374 {
375 eai = objects.Get( i );
376 if ( eai == null || game_inventory.IsPlaceholderEntity( eai ) )
377 continue; // noproxy: ignore body placeholder
378
379 BaseBuildingBase base_building = BaseBuildingBase.Cast(eai);
380 if (base_building && !base_building.IsPlayerInside(player,""))
381 continue;
382
383 if (eai.IsInventoryVisible())
384 {
385 showable_items.Insert(eai);
386
387 if (!eai.DisableVicinityIcon())
388 {
389 m_ShowedItemIcons.Insert(eai);
390 }
391 }
392 }
393
394 if (isUsedMicromanagment && m_ShowedItemIcons.Find(selectesItem) == -1 )
395 {
396 //ItemManager.GetInstance().SetItemMicromanagmentMode(false);
397 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
398 isUsedMicromanagment = false;
399 }
400
401 //MW HOTFIX - old containers must be removed before new one are added (part of initialize are refreshed whole structure - need proper fix to avoid it)
402 map<EntityAI, ref Container> new_showed_items = new map<EntityAI, ref Container>;
403 Container con;
404
405 for ( i = 0; i < showable_items.Count(); i++ )
406 {
407 new_showed_items.Insert(showable_items[i],null);
408 }
409
410
411 bool need_update_focus = false;
412 for ( i = 0; i < m_ShowedItems.Count(); i++ )
413 {
414 EntityAI ent = m_ShowedItems.GetKey( i );
415 m_ShowedItems.GetElement( i ).UpdateInterval();
416 con = m_ShowedItems.GetElement( i );
417 if ( !new_showed_items.Contains( ent ) )
418 {
419 if ( selectesItem && selectesItem.GetHierarchyRoot() == ent)
420 {
421 //ItemManager.GetInstance().SetItemMicromanagmentMode(false);
422 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
423 }
424 GetMainWidget().Update();
425 if ( con.IsActive() )
426 need_update_focus = true;
427 Container.Cast( GetParent() ).Remove( con );
428 Remove( con );
429 }
430 else
431 {
432 UpdateHeader(ent,con,player); //squeezed here, the map is iterated over enough already..
433 }
434 }
436
437 bool accessInventory = PlayerBase.DEBUG_INVENTORY_ACCESS;
438 accessInventory |= FreeDebugCamera.GetInstance() && FreeDebugCamera.GetInstance().IsActive();
439
440
441 //map<EntityAI, ref Container> new_showed_items = new map<EntityAI, ref Container>;
442 new_showed_items.Clear();
444 for ( i = 0; i < showable_items.Count(); i++ )
445 {
446 EntityAI entity = showable_items.Get( i );
447 if ( entity )
448 {
449 if ( game_inventory && !m_ShowedItems.Contains( entity ) )
450 {
451 string config = "CfgVehicles " + entity.GetType() + " GUIInventoryAttachmentsProps";
452
453 if ( g_Game.ConfigIsExisting( config ) )
454 {
455 AttachmentCategoriesContainer ac = new AttachmentCategoriesContainer( m_Parent, -1 );
456 ac.SetEntity( entity );
457 new_showed_items.Insert( entity, ac );
458 showed_items_IDs.Insert( entity.GetID(), ac);
459 }
460 else if ( entity.GetSlotsCountCorrect() > 0 && entity.GetInventory().GetCargo() )
461 {
462 if ( entity.IsInherited( DayZInfected ) )
463 {
464 if ( entity.IsAlive() )
465 {
466 continue;
467 }
468 ZombieContainer zmb_cnt = new ZombieContainer( m_Parent, -1 );
469 zmb_cnt.SetEntity( entity );
470 new_showed_items.Insert( entity, zmb_cnt );
471 showed_items_IDs.Insert( entity.GetID(), zmb_cnt );
472 Container.Cast( GetParent() ).Insert( zmb_cnt );
473 }
474 else
475 {
476 ContainerWithCargoAndAttachments iwca = new ContainerWithCargoAndAttachments( this, -1 );
477 iwca.SetEntity( entity, false );
478 new_showed_items.Insert( entity, iwca );
479 showed_items_IDs.Insert( entity.GetID(), iwca );
480 }
481 }
482 else if ( entity.GetInventory().GetCargo() )
483 {
484 ContainerWithCargo iwc = new ContainerWithCargo( this, -1 );
485 iwc.SetEntity( entity, 0, false );
486 new_showed_items.Insert( entity, iwc );
487 showed_items_IDs.Insert( entity.GetID(), iwc );
488 iwc.UpdateInterval();
489 }
490 else if ( entity.GetSlotsCountCorrect() > 0 )
491 {
492 if ( entity.HasEnergyManager() )
493 {
494 ContainerWithElectricManager iwem = new ContainerWithElectricManager( this, -1 );
495 iwem.SetEntity( entity, false );
496 new_showed_items.Insert( entity, iwem );
497 showed_items_IDs.Insert( entity.GetID(), iwem );
498 }
499 else
500 {
501 if ( entity.IsInherited( PlayerBase ) )
502 {
504 if (accessInventory == false)
505 {
506 if ( entity.IsAlive() && ( !PlayerBase.Cast( entity ).IsUnconscious() && !PlayerBase.Cast( entity ).IsRestrained() ) )
507 {
508 continue;
509 }
510 }
511
512 PlayerContainer plyr_cnt = new PlayerContainer( m_Parent, false );
513 plyr_cnt.SetPlayer( PlayerBase.Cast( entity ) );
514 Container.Cast( GetParent() ).Insert( plyr_cnt );
515 ( Container.Cast( m_Parent ) ).Refresh();
516 new_showed_items.Insert( entity, plyr_cnt );
517 showed_items_IDs.Insert( entity.GetID(), plyr_cnt);
518 }
519 else
520 {
521 ContainerWithCargoAndAttachments iwcas = new ContainerWithCargoAndAttachments( this, -1 );
522 iwcas.SetEntity( entity, false );
523 new_showed_items.Insert( entity, iwcas );
524 showed_items_IDs.Insert( entity.GetID(), iwcas );
525 iwcas.UpdateInterval();
526 }
527 }
528 }
529 }
530 else
531 {
532 //TODO MW: remove old containers on one spot (hotfix)
533 con = m_ShowedItems.Get( entity );
534 if ( con )
535 {
536 if ( entity.IsInherited( PlayerBase ) )
537 {
539 if ( !accessInventory && entity.IsAlive() && ( !PlayerBase.Cast( entity ).IsUnconscious() && !PlayerBase.Cast( entity ).IsRestrained() ) )
540 {
541 GetMainWidget().Update();
542 if ( con.IsActive() )
543 need_update_focus = true;
544 Container.Cast( GetParent() ).Remove( con );
545 Remove( con );
546 continue;
547 }
548 }
549
550 if ( entity.IsInherited( BaseBuildingBase ) )
551 {
552 if ( !BaseBuildingBase.Cast(entity).IsPlayerInside(player,""))
553 {
554 GetMainWidget().Update();
555 if ( con.IsActive() )
556 need_update_focus = true;
557 Container.Cast( GetParent() ).Remove( con );
558 Remove( con );
559 continue;
560 }
561 }
562
563 new_showed_items.Insert( entity, m_ShowedItems.Get( entity ) );
564 showed_items_IDs.Insert( entity.GetID(), m_ShowedItemsIDs.Get( entity.GetID() ) );
565 }
566 }
567 }
568 }
569
570 map<CargoBase, ref Container> new_showed_cargos = new map<CargoBase, ref Container>;
571 auto cargoes = VicinityItemManager.GetInstance().GetVicinityCargos();
572 for ( i = 0; i < cargoes.Count(); i++ )
573 {
574 CargoBase cgo = cargoes.Get( i );
575 if ( cgo )
576 {
577 if (game_inventory && !m_ShowedCargos.Contains( cgo ) )
578 {
579 ContainerWithCargo pxc = new ContainerWithCargo( this, -1 );
580 pxc.SetEntity( cgo.GetCargoOwner(), cgo.GetOwnerCargoIndex(), false );
581 new_showed_cargos.Insert( cgo, pxc );
582 pxc.UpdateInterval();
583 }
584 else
585 {
586 if ( m_ShowedCargos.Get( cgo ) )
587 {
588 new_showed_cargos.Insert( cgo, m_ShowedCargos.Get( cgo ) );
589 }
590 }
591 }
592 }
593
594 for ( int ic = 0; ic < m_ShowedCargos.Count(); ic++ )
595 {
596 CargoBase cgo2 = m_ShowedCargos.GetKey( ic );
597 m_ShowedCargos.GetElement( ic ).UpdateInterval();
598 if ( !new_showed_cargos.Contains( cgo2 ) )
599 {
600 Container con2 = m_ShowedCargos.GetElement( ic );
601 if( con2.IsActive() )
602 need_update_focus = true;
603 GetMainWidget().Update();
604 Container.Cast( GetParent() ).Remove( con2 );
605 Remove( con2 );
606 }
607 }
608
609 m_ShowedItems = new_showed_items;
610 m_ShowedItemsIDs = showed_items_IDs;
611 m_ShowedCargos = new_showed_cargos;
612 //Because WTF (zombie container)
613 Container.Cast( GetParent() ).RecomputeOpenedContainers();
614 if (need_update_focus)
615 SetFirstActive();
616 //RecomputeOpenedContainers();
618 m_VicinityIconsContainer.ShowItemsInContainers( m_ShowedItemIcons );
619
620 if ( m_ShowedItemIcons.Count() != m_OldShowedItemIconsCount )
621 {
622 Inventory in = Inventory.Cast( GetRoot() );
623 if ( in )
624 in.UpdateConsoleToolbar();
625 }
626
627 #ifndef PLATFORM_CONSOLE
630 {
631 float width, height;
632 m_CargoScrollWidget.GetSize(width, height);
633 if (showable_items.Count() >= ITEMS_PER_COLUMN_MAX * 2)
634 {
636 }
637 else if (showable_items.Count() >= ITEMS_PER_COLUMN_MAX)
638 {
640 }
641 else
642 {
644 }
645 }
646 #endif
647 }
class LogManager EntityAI
void Inventory(LayoutHolder parent)
void BaseBuildingBase()
Определения BaseBuildingBase.c:1348
Entity m_Parent
Определения CachedEquipmentStorageBase.c:15
const string Container
Определения CentralEconomy.c:6
map
Определения ControlsXboxNew.c:4
DayZGame g_Game
Определения DayZGame.c:3942
void SetEntity(EntityAI entity)
Определения AttachmentCategoriesContainer.c:27
override bool IsPlayerInside(PlayerBase player, string selection)
Определения Fence.c:615
proto native EntityAI GetCargoOwner()
get the entity that owns the cargo
proto native int GetOwnerCargoIndex()
override void Remove(LayoutHolder container)
Определения CollapsibleContainer.c:79
void UpdateCollapseButtons()
Определения CollapsibleContainer.c:91
override void SetEntity(EntityAI entity, bool immedUpdate=true)
Определения ContainerWithElectricManager.c:11
override bool DisableVicinityIcon()
Определения 3_Game/DayZ/Entities/Man.c:888
proto native bool IsPlaceholderEntity(notnull Object e)
void SetPlayer(PlayerBase player)
Определения PlayerContainer.c:661
ScrollWidget m_CargoScrollWidget
Определения VicinityContainer.c:11
const int ITEMS_PER_COLUMN_MAX
Определения VicinityContainer.c:17
void UpdateHeader(EntityAI entity, Container cont, PlayerBase player)
Updates header dragability to be consistent with current 'icon' behaviour.
Определения VicinityContainer.c:730
ref VicinitySlotsContainer m_VicinityIconsContainer
Определения VicinityContainer.c:3
const float VICINITY_CARGO_SCROLLER_HEIGHT_MID
Определения VicinityContainer.c:19
ref map< int, ref Container > m_ShowedItemsIDs
Определения VicinityContainer.c:5
const float VICINITY_CARGO_SCROLLER_HEIGHT_MIN
Определения VicinityContainer.c:18
ref map< CargoBase, ref Container > m_ShowedCargos
Определения VicinityContainer.c:7
ref array< EntityAI > m_ShowedItemIcons
Определения VicinityContainer.c:6
ref map< EntityAI, ref Container > m_ShowedItems
Определения VicinityContainer.c:4
const float VICINITY_CARGO_SCROLLER_HEIGHT_MAX
Определения VicinityContainer.c:20
void SetEntity(EntityAI zombie_entity)
Определения ZombieContainer.c:37
proto void Insert(int index, string input)
Inserts a string into the n-th index, increasing the string length by the size of the input.
proto native Widget GetParent()
Get parent of the Effect.
Определения Effect.c:422

Перекрестные ссылки EntityAI::DisableVicinityIcon(), g_Game, CargoBase::GetCargoOwner(), ItemManager::GetInstance(), VicinityItemManager::GetInstance(), CargoBase::GetOwnerCargoIndex(), GetParent(), ItemManager::GetSelectedItem(), VicinityItemManager::GetVicinityCargos(), VicinityItemManager::GetVicinityItems(), Inventory(), ItemManager::IsMicromanagmentMode(), GameInventory::IsPlaceholderEntity(), BaseBuildingBase::IsPlayerInside(), ITEMS_PER_COLUMN_MAX, m_CargoScrollWidget, m_Parent, m_ShowedCargos, m_ShowedItemIcons, m_ShowedItems, m_ShowedItemsIDs, m_VicinityIconsContainer, Container::Refresh(), CollapsibleContainer::Remove(), AttachmentCategoriesContainer::SetEntity(), ContainerWithElectricManager::SetEntity(), ZombieContainer::SetEntity(), PlayerContainer::SetPlayer(), ItemManager::SetSelectedItemEx(), VicinityItemManager::Update(), CollapsibleContainer::UpdateCollapseButtons(), UpdateHeader(), VICINITY_CARGO_SCROLLER_HEIGHT_MAX, VICINITY_CARGO_SCROLLER_HEIGHT_MID и VICINITY_CARGO_SCROLLER_HEIGHT_MIN.