DayZ 1.30
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 foreach (EntityAI showableItem : showable_items)
406 {
407 new_showed_items.Insert(showableItem,null);
408 }
409
410 bool need_update_focus = false;
411 foreach (EntityAI ent, Container cont : m_ShowedItems)
412 {
413 cont.UpdateInterval();
414 if (!new_showed_items.Contains(ent))
415 {
416 if (selectesItem && selectesItem.GetHierarchyRoot() == ent)
417 {
418 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
419 }
420 GetMainWidget().Update();
421 if (cont.IsActive())
422 need_update_focus = true;
423 Container.Cast(GetParent()).Remove(cont);
424 Remove(cont);
425 }
426 else
427 {
428 UpdateHeader(ent, cont, player); //squeezed here, the map is iterated over enough already..
429 }
430 }
432
433 bool accessInventory = PlayerBase.DEBUG_INVENTORY_ACCESS;
434 accessInventory |= FreeDebugCamera.GetInstance() && FreeDebugCamera.GetInstance().IsActive();
435
436
437 //map<EntityAI, ref Container> new_showed_items = new map<EntityAI, ref Container>;
438 new_showed_items.Clear();
439 map<int, ref Container> showed_items_IDs = new map<int, ref Container>;
440 for ( i = 0; i < showable_items.Count(); i++ )
441 {
442 EntityAI entity = showable_items.Get( i );
443 if ( entity )
444 {
445 if ( game_inventory && !m_ShowedItems.Contains( entity ) )
446 {
447 string config = "CfgVehicles " + entity.GetType() + " GUIInventoryAttachmentsProps";
448
449 if ( g_Game.ConfigIsExisting( config ) )
450 {
451 AttachmentCategoriesContainer ac = new AttachmentCategoriesContainer( m_Parent, -1 );
452 ac.SetEntity( entity );
453 new_showed_items.Insert( entity, ac );
454 showed_items_IDs.Insert( entity.GetID(), ac);
455 }
456 else if ( entity.GetSlotsCountCorrect() > 0 && entity.GetInventory().GetCargo() )
457 {
458 if ( entity.IsInherited( DayZInfected ) )
459 {
460 if ( entity.IsAlive() )
461 {
462 continue;
463 }
464 ZombieContainer zmb_cnt = new ZombieContainer( m_Parent, -1 );
465 zmb_cnt.SetEntity( entity );
466 new_showed_items.Insert( entity, zmb_cnt );
467 showed_items_IDs.Insert( entity.GetID(), zmb_cnt );
468 Container.Cast( GetParent() ).Insert( zmb_cnt );
469 }
470 else
471 {
472 ContainerWithCargoAndAttachments iwca = new ContainerWithCargoAndAttachments( this, -1 );
473 iwca.SetEntity( entity, false );
474 new_showed_items.Insert( entity, iwca );
475 showed_items_IDs.Insert( entity.GetID(), iwca );
476 }
477 }
478 else if ( entity.GetInventory().GetCargo() )
479 {
480 ContainerWithCargo iwc = new ContainerWithCargo( this, -1 );
481 iwc.SetEntity( entity, 0, false );
482 new_showed_items.Insert( entity, iwc );
483 showed_items_IDs.Insert( entity.GetID(), iwc );
484 iwc.UpdateInterval();
485 }
486 else if ( entity.GetSlotsCountCorrect() > 0 )
487 {
488 if ( entity.HasEnergyManager() )
489 {
490 ContainerWithElectricManager iwem = new ContainerWithElectricManager( this, -1 );
491 iwem.SetEntity( entity, false );
492 new_showed_items.Insert( entity, iwem );
493 showed_items_IDs.Insert( entity.GetID(), iwem );
494 }
495 else
496 {
497 if ( entity.IsInherited( PlayerBase ) )
498 {
500 if (accessInventory == false)
501 {
502 if ( entity.IsAlive() && ( !PlayerBase.Cast( entity ).IsUnconscious() && !PlayerBase.Cast( entity ).IsRestrained() ) )
503 {
504 continue;
505 }
506 }
507
508 PlayerContainer plyr_cnt = new PlayerContainer( m_Parent, false );
509 plyr_cnt.SetPlayer( PlayerBase.Cast( entity ) );
510 Container.Cast( GetParent() ).Insert( plyr_cnt );
511 ( Container.Cast( m_Parent ) ).Refresh();
512 new_showed_items.Insert( entity, plyr_cnt );
513 showed_items_IDs.Insert( entity.GetID(), plyr_cnt);
514 }
515 else
516 {
517 ContainerWithCargoAndAttachments iwcas = new ContainerWithCargoAndAttachments( this, -1 );
518 iwcas.SetEntity( entity, false );
519 new_showed_items.Insert( entity, iwcas );
520 showed_items_IDs.Insert( entity.GetID(), iwcas );
521 iwcas.UpdateInterval();
522 }
523 }
524 }
525 }
526 else
527 {
528 //TODO MW: remove old containers on one spot (hotfix)
529 con = m_ShowedItems.Get( entity );
530 if ( con )
531 {
532 if ( entity.IsInherited( PlayerBase ) )
533 {
535 if ( !accessInventory && entity.IsAlive() && ( !PlayerBase.Cast( entity ).IsUnconscious() && !PlayerBase.Cast( entity ).IsRestrained() ) )
536 {
537 GetMainWidget().Update();
538 if ( con.IsActive() )
539 need_update_focus = true;
540 Container.Cast( GetParent() ).Remove( con );
541 Remove( con );
542 continue;
543 }
544 }
545
546 if ( entity.IsInherited( BaseBuildingBase ) )
547 {
548 if ( !BaseBuildingBase.Cast(entity).IsPlayerInside(player,""))
549 {
550 GetMainWidget().Update();
551 if ( con.IsActive() )
552 need_update_focus = true;
553 Container.Cast( GetParent() ).Remove( con );
554 Remove( con );
555 continue;
556 }
557 }
558
559 new_showed_items.Insert( entity, m_ShowedItems.Get( entity ) );
560 showed_items_IDs.Insert( entity.GetID(), m_ShowedItemsIDs.Get( entity.GetID() ) );
561 }
562 }
563 }
564 }
565
566 map<CargoBase, ref Container> new_showed_cargos = new map<CargoBase, ref Container>;
567 auto cargoes = VicinityItemManager.GetInstance().GetVicinityCargos();
568 for ( i = 0; i < cargoes.Count(); i++ )
569 {
570 CargoBase cgo = cargoes.Get( i );
571 if ( cgo )
572 {
573 if (game_inventory && !m_ShowedCargos.Contains( cgo ) )
574 {
575 ContainerWithCargo pxc = new ContainerWithCargo( this, -1 );
576 pxc.SetEntity( cgo.GetCargoOwner(), cgo.GetOwnerCargoIndex(), false );
577 new_showed_cargos.Insert( cgo, pxc );
578 pxc.UpdateInterval();
579 }
580 else
581 {
582 if ( m_ShowedCargos.Get( cgo ) )
583 {
584 new_showed_cargos.Insert( cgo, m_ShowedCargos.Get( cgo ) );
585 }
586 }
587 }
588 }
589
590 for ( int ic = 0; ic < m_ShowedCargos.Count(); ic++ )
591 {
592 CargoBase cgo2 = m_ShowedCargos.GetKey( ic );
593 m_ShowedCargos.GetElement( ic ).UpdateInterval();
594 if ( !new_showed_cargos.Contains( cgo2 ) )
595 {
596 Container con2 = m_ShowedCargos.GetElement( ic );
597 if( con2.IsActive() )
598 need_update_focus = true;
599 GetMainWidget().Update();
600 Container.Cast( GetParent() ).Remove( con2 );
601 Remove( con2 );
602 }
603 }
604
605 m_ShowedItems = new_showed_items;
606 m_ShowedItemsIDs = showed_items_IDs;
607 m_ShowedCargos = new_showed_cargos;
608 //Because WTF (zombie container)
609 Container.Cast( GetParent() ).RecomputeOpenedContainers();
610 if (need_update_focus)
611 SetFirstActive();
612 //RecomputeOpenedContainers();
614 m_VicinityIconsContainer.ShowItemsInContainers( m_ShowedItemIcons );
615
616 if ( m_ShowedItemIcons.Count() != m_OldShowedItemIconsCount )
617 {
618 Inventory in = Inventory.Cast( GetRoot() );
619 if ( in )
620 in.UpdateConsoleToolbar();
621 }
622
623 #ifndef PLATFORM_CONSOLE
626 {
627 float width, height;
628 m_CargoScrollWidget.GetSize(width, height);
629 if (showable_items.Count() >= ITEMS_PER_COLUMN_MAX * 2)
630 {
632 }
633 else if (showable_items.Count() >= ITEMS_PER_COLUMN_MAX)
634 {
636 }
637 else
638 {
640 }
641 }
642 #endif
643 }
class LogManager EntityAI
void Inventory(LayoutHolder parent)
void BaseBuildingBase()
Определения BaseBuildingBase.c:1326
Entity m_Parent
Определения CachedEquipmentStorageBase.c:17
const string Container
Определения CentralEconomy.c:6
DayZGame g_Game
Определения DayZGame.c:4074
void SetEntity(EntityAI entity)
Определения AttachmentCategoriesContainer.c:27
override bool IsPlayerInside(PlayerBase player, string selection)
Определения Fence.c:661
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:782
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:726
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.