DayZ 1.27
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

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

323 {
324 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
325
326 if (!player)
327 return;
328
329 super.UpdateInterval();
330
331 EntityAI eai;
332 vector pos = player.GetPosition();
333 ref array<EntityAI> objects;
334
335 VicinityItemManager.GetInstance().Update( player.GetDeltaT() );
336 objects = VicinityItemManager.GetInstance().GetVicinityItems();
337
338 //GetItemsShowableInInventory
339 array<EntityAI> showable_items = new array<EntityAI>;
340 bool isUsedMicromanagment = false;
341 EntityAI selectesItem = ItemManager.GetInstance().GetSelectedItem();
342 int m_OldShowedItemIconsCount = m_ShowedItemIcons.Count();
343
344 if (selectesItem && ItemManager.GetInstance().IsMicromanagmentMode())
345 {
346 if (m_ShowedItemIcons.Find(selectesItem) != -1)
347 {
348 isUsedMicromanagment = true;
349 }
350 }
351 m_ShowedItemIcons.Clear();
352
353 GameInventory game_inventory = player.GetInventory();
354 for ( int i = 0; i < objects.Count(); i++ )
355 {
356 eai = objects.Get( i );
357 if ( eai == null || game_inventory.IsPlaceholderEntity( eai ) )
358 continue; // noproxy: ignore body placeholder
359
360 BaseBuildingBase base_building = BaseBuildingBase.Cast(eai);
361 if (base_building && !base_building.IsPlayerInside(player,""))
362 continue;
363
364 if (eai.IsInventoryVisible())
365 {
366 showable_items.Insert(eai);
367
368 if (!eai.DisableVicinityIcon())
369 {
370 m_ShowedItemIcons.Insert(eai);
371 }
372 }
373 }
374
375 if (isUsedMicromanagment && m_ShowedItemIcons.Find(selectesItem) == -1 )
376 {
377 //ItemManager.GetInstance().SetItemMicromanagmentMode(false);
378 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
379 isUsedMicromanagment = false;
380 }
381
382 //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)
383 ref map<EntityAI, ref Container> new_showed_items = new ref map<EntityAI, ref Container>;
384 Container con;
385
386 for ( i = 0; i < showable_items.Count(); i++ )
387 {
388 new_showed_items.Insert(showable_items[i],null);
389 }
390
391
392 bool need_update_focus = false;
393 for ( i = 0; i < m_ShowedItems.Count(); i++ )
394 {
395 EntityAI ent = m_ShowedItems.GetKey( i );
396 m_ShowedItems.GetElement( i ).UpdateInterval();
397 con = m_ShowedItems.GetElement( i );
398 if ( !new_showed_items.Contains( ent ) )
399 {
400 if ( selectesItem && selectesItem.GetHierarchyRoot() == ent)
401 {
402 //ItemManager.GetInstance().SetItemMicromanagmentMode(false);
403 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
404 }
405 GetMainWidget().Update();
406 if ( con.IsActive() )
407 need_update_focus = true;
408 Container.Cast( GetParent() ).Remove( con );
409 Remove( con );
410 }
411 else
412 {
413 UpdateHeader(ent,con,player); //squeezed here, the map is iterated over enough already..
414 }
415 }
417
418 bool accessInventory = PlayerBase.DEBUG_INVENTORY_ACCESS;
419 accessInventory |= FreeDebugCamera.GetInstance() && FreeDebugCamera.GetInstance().IsActive();
420
421
422 //ref map<EntityAI, ref Container> new_showed_items = new ref map<EntityAI, ref Container>;
423 new_showed_items.Clear();
424 ref map<int, ref Container> showed_items_IDs = new ref map<int, ref Container>;
425 for ( i = 0; i < showable_items.Count(); i++ )
426 {
427 EntityAI entity = showable_items.Get( i );
428 if ( entity )
429 {
430 if ( game_inventory && !m_ShowedItems.Contains( entity ) )
431 {
432 string config = "CfgVehicles " + entity.GetType() + " GUIInventoryAttachmentsProps";
433
434 if ( GetGame().ConfigIsExisting( config ) )
435 {
436 AttachmentCategoriesContainer ac = new AttachmentCategoriesContainer( m_Parent, -1 );
437 ac.SetEntity( entity );
438 new_showed_items.Insert( entity, ac );
439 showed_items_IDs.Insert( entity.GetID(), ac);
440 }
441 else if ( entity.GetSlotsCountCorrect() > 0 && entity.GetInventory().GetCargo() )
442 {
443 if ( entity.IsInherited( DayZInfected ) )
444 {
445 if ( entity.IsAlive() )
446 {
447 continue;
448 }
449 ZombieContainer zmb_cnt = new ZombieContainer( m_Parent, -1 );
450 zmb_cnt.SetEntity( entity );
451 new_showed_items.Insert( entity, zmb_cnt );
452 showed_items_IDs.Insert( entity.GetID(), zmb_cnt );
453 Container.Cast( GetParent() ).Insert( zmb_cnt );
454 }
455 else
456 {
457 ContainerWithCargoAndAttachments iwca = new ContainerWithCargoAndAttachments( this, -1 );
458 iwca.SetEntity( entity, false );
459 new_showed_items.Insert( entity, iwca );
460 showed_items_IDs.Insert( entity.GetID(), iwca );
461 }
462 }
463 else if ( entity.GetInventory().GetCargo() )
464 {
465 ContainerWithCargo iwc = new ContainerWithCargo( this, -1 );
466 iwc.SetEntity( entity, 0, false );
467 new_showed_items.Insert( entity, iwc );
468 showed_items_IDs.Insert( entity.GetID(), iwc );
469 iwc.UpdateInterval();
470 }
471 else if ( entity.GetSlotsCountCorrect() > 0 )
472 {
473 if ( entity.HasEnergyManager() )
474 {
475 ContainerWithElectricManager iwem = new ContainerWithElectricManager( this, -1 );
476 iwem.SetEntity( entity, false );
477 new_showed_items.Insert( entity, iwem );
478 showed_items_IDs.Insert( entity.GetID(), iwem );
479 }
480 else
481 {
482 if ( entity.IsInherited( PlayerBase ) )
483 {
485 if (accessInventory == false)
486 {
487 if ( entity.IsAlive() && ( !PlayerBase.Cast( entity ).IsUnconscious() && !PlayerBase.Cast( entity ).IsRestrained() ) )
488 {
489 continue;
490 }
491 }
492
493 PlayerContainer plyr_cnt = new PlayerContainer( m_Parent, false );
494 plyr_cnt.SetPlayer( PlayerBase.Cast( entity ) );
495 Container.Cast( GetParent() ).Insert( plyr_cnt );
496 ( Container.Cast( m_Parent ) ).Refresh();
497 new_showed_items.Insert( entity, plyr_cnt );
498 showed_items_IDs.Insert( entity.GetID(), plyr_cnt);
499 }
500 else
501 {
502 ContainerWithCargoAndAttachments iwcas = new ContainerWithCargoAndAttachments( this, -1 );
503 iwcas.SetEntity( entity, false );
504 new_showed_items.Insert( entity, iwcas );
505 showed_items_IDs.Insert( entity.GetID(), iwcas );
506 iwcas.UpdateInterval();
507 }
508 }
509 }
510 }
511 else
512 {
513 //TODO MW: remove old containers on one spot (hotfix)
514 con = m_ShowedItems.Get( entity );
515 if ( con )
516 {
517 if ( entity.IsInherited( PlayerBase ) )
518 {
520 if ( !accessInventory && entity.IsAlive() && ( !PlayerBase.Cast( entity ).IsUnconscious() && !PlayerBase.Cast( entity ).IsRestrained() ) )
521 {
522 GetMainWidget().Update();
523 if ( con.IsActive() )
524 need_update_focus = true;
525 Container.Cast( GetParent() ).Remove( con );
526 Remove( con );
527 continue;
528 }
529 }
530
531 if ( entity.IsInherited( BaseBuildingBase ) )
532 {
533 if ( !BaseBuildingBase.Cast(entity).IsPlayerInside(player,""))
534 {
535 GetMainWidget().Update();
536 if ( con.IsActive() )
537 need_update_focus = true;
538 Container.Cast( GetParent() ).Remove( con );
539 Remove( con );
540 continue;
541 }
542 }
543
544 new_showed_items.Insert( entity, m_ShowedItems.Get( entity ) );
545 showed_items_IDs.Insert( entity.GetID(), m_ShowedItemsIDs.Get( entity.GetID() ) );
546 }
547 }
548 }
549 }
550
551 ref map<CargoBase, ref Container> new_showed_cargos = new ref map<CargoBase, ref Container>;
552 auto cargoes = VicinityItemManager.GetInstance().GetVicinityCargos();
553 for ( i = 0; i < cargoes.Count(); i++ )
554 {
555 CargoBase cgo = cargoes.Get( i );
556 if ( cgo )
557 {
558 if (game_inventory && !m_ShowedCargos.Contains( cgo ) )
559 {
560 ContainerWithCargo pxc = new ContainerWithCargo( this, -1 );
561 pxc.SetEntity( cgo.GetCargoOwner(), cgo.GetOwnerCargoIndex(), false );
562 new_showed_cargos.Insert( cgo, pxc );
563 pxc.UpdateInterval();
564 }
565 else
566 {
567 if ( m_ShowedCargos.Get( cgo ) )
568 {
569 new_showed_cargos.Insert( cgo, m_ShowedCargos.Get( cgo ) );
570 }
571 }
572 }
573 }
574
575 for ( int ic = 0; ic < m_ShowedCargos.Count(); ic++ )
576 {
577 CargoBase cgo2 = m_ShowedCargos.GetKey( ic );
578 m_ShowedCargos.GetElement( ic ).UpdateInterval();
579 if ( !new_showed_cargos.Contains( cgo2 ) )
580 {
581 Container con2 = m_ShowedCargos.GetElement( ic );
582 if( con2.IsActive() )
583 need_update_focus = true;
584 GetMainWidget().Update();
585 Container.Cast( GetParent() ).Remove( con2 );
586 Remove( con2 );
587 }
588 }
589
590 m_ShowedItems = new_showed_items;
591 m_ShowedItemsIDs = showed_items_IDs;
592 m_ShowedCargos = new_showed_cargos;
593 //Because WTF (zombie container)
594 Container.Cast( GetParent() ).RecomputeOpenedContainers();
595 if (need_update_focus)
596 SetFirstActive();
597 //RecomputeOpenedContainers();
599 m_VicinityIconsContainer.ShowItemsInContainers( m_ShowedItemIcons );
600
601 if ( m_ShowedItemIcons.Count() != m_OldShowedItemIconsCount )
602 {
603 Inventory in = Inventory.Cast( GetRoot() );
604 if ( in )
605 in.UpdateConsoleToolbar();
606 }
607 }
class LogManager EntityAI
void Inventory(LayoutHolder parent)
Определения Inventory.c:74
void BaseBuildingBase()
Определения BaseBuildingBase.c:1328
const string Container
Определения CentralEconomy.c:6
map
Определения ControlsXboxNew.c:4
PlayerBase GetPlayer()
Определения ModifierBase.c:51
Widget m_Parent
Определения SizeToChild.c:92
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()
Определения Man.c:855
override bool IsInventoryVisible()
Определения Building.c:242
proto native bool IsPlaceholderEntity(notnull Object e)
void SetPlayer(PlayerBase player)
Определения PlayerContainer.c:661
void UpdateHeader(EntityAI entity, Container cont, PlayerBase player)
Updates header dragability to be consistent with current 'icon' behaviour.
Определения VicinityContainer.c:690
ref VicinitySlotsContainer m_VicinityIconsContainer
Определения VicinityContainer.c:3
ref map< int, ref Container > m_ShowedItemsIDs
Определения VicinityContainer.c:5
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
void SetEntity(EntityAI zombie_entity)
Определения ZombieContainer.c:37
proto native CGame GetGame()
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:407

Перекрестные ссылки EntityAI::DisableVicinityIcon(), CargoBase::GetCargoOwner(), GetGame(), ItemManager::GetInstance(), VicinityItemManager::GetInstance(), CargoBase::GetOwnerCargoIndex(), GetParent(), GetPlayer(), ItemManager::GetSelectedItem(), VicinityItemManager::GetVicinityCargos(), VicinityItemManager::GetVicinityItems(), Inventory(), EntityAI::IsInventoryVisible(), ItemManager::IsMicromanagmentMode(), GameInventory::IsPlaceholderEntity(), BaseBuildingBase::IsPlayerInside(), 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().