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

◆ TakeAsAttachment()

void ClosableContainer::TakeAsAttachment ( Widget w,
Widget receiver )
inlineprotected

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

598 {
599 ItemManager.GetInstance().HideDropzones();
600 ItemManager.GetInstance().SetIsDragging( false );
601 SlotsIcon slots_icon;
602 EntityAI receiver_item;
603 int slot_id = -1;
604 bool is_reserved = false;
605 EntityAI attached_entity;
606 receiver.GetUserData(slots_icon);
607 //string name = receiver.GetName();
608 //name.Replace("PanelWidget", "Render");
609
610 //ItemPreviewWidget receiver_iw = ItemPreviewWidget.Cast( receiver.FindAnyWidget(name) );
611 if( slots_icon )
612 {
613 receiver_item = slots_icon.GetEntity();
614 slot_id = slots_icon.GetSlotID();
615 attached_entity = slots_icon.GetSlotParent();
616 is_reserved = slots_icon.IsReserved();
617 }
618
619 EntityAI item = GetItemPreviewItem( w );
620 if( !item )
621 {
622 return;
623 }
624 ItemBase item_base = ItemBase.Cast( item );
625 InventoryLocation il = new InventoryLocation;
626 float stackable;
627
628 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
629 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
630 return;
631
632 EntityAI target_att_entity = m_Entity;
633 Weapon_Base wpn;
634 Magazine mag;
635 if( Class.CastTo(wpn, m_Entity ) && Class.CastTo(mag, item ) )
636 {
637 if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
638 {
639 player.GetWeaponManager().AttachMagazine( mag );
640 }
641 }
642 else if( receiver_item && !is_reserved )
643 {
644 if( ( ItemBase.Cast( receiver_item ) ).CanBeCombined( ItemBase.Cast( item ) ) )
645 {
646 ( ItemBase.Cast( receiver_item ) ).CombineItemsClient( ItemBase.Cast( item ) );
647 }
648 else if( GameInventory.CanSwapEntitiesEx( receiver_item, item ) )
649 {
650 if( !receiver_item.GetInventory().CanRemoveEntity() )
651 return;
652 g_Game.GetPlayer().PredictiveSwapEntities( receiver_item, item );
653 }
654 else if( receiver_item.GetInventory().CanAddAttachment( item ) )
655 {
656 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
657 }
658 }
659 else if( attached_entity && attached_entity.GetInventory().CanAddAttachmentEx( item, slot_id ) )
660 {
661 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, slot_id);
662 }
663 else if(attached_entity && attached_entity.GetInventory().CanAddAttachment(item))
664 {
665 attached_entity.GetInventory().FindFreeLocationFor(item,FindInventoryLocationType.ATTACHMENT,il);
666 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, il.GetSlot());
667 }
668 else if( m_Entity.GetInventory().CanAddAttachment(item) )
669 {
671 player.PredictiveTakeEntityToTargetAttachmentEx(m_Entity, item, il.GetSlot());
672 }
673 else if( m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !m_Entity.GetInventory().HasEntityInCargo( item ) )
674 {
675 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( g_Game.GetPlayer() ), m_Entity, item );
676 }
677 /*else if( !player.GetInventory().HasEntityInInventory( item ) || !m_Entity.GetInventory().HasEntityInCargo( item ) )
678 {
679 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( g_Game.GetPlayer() ), m_Entity, item );
680 }*/
681 }
class LogManager EntityAI
Entity m_Entity
Определения CachedEquipmentStorageBase.c:14
DayZGame g_Game
Определения DayZGame.c:3942
class GP5GasMask extends MaskBase ItemBase
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
EntityAI GetItemPreviewItem(Widget w)
Определения ContainerWithCargo.c:224
proto native GameInventory GetInventory()
proto native bool CanAddEntityInCargo(notnull EntityAI e, bool flip)
proto native bool HasEntityInCargo(notnull EntityAI e)
proto native bool CanAddAttachment(notnull EntityAI e)
Check if attachment can be added to any slot.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto native int GetSlot()
returns slot id if current type is Attachment
EntityAI GetEntity()
Определения SlotsIcon.c:365
EntityAI GetSlotParent()
Определения SlotsIcon.c:185
bool IsReserved()
Определения SlotsIcon.c:200
int GetSlotID()
Определения SlotsIcon.c:190

Перекрестные ссылки GameInventory::CanSwapEntitiesEx(), Class::CastTo(), g_Game, SlotsIcon::GetEntity(), ItemManager::GetInstance(), GetItemPreviewItem(), InventoryLocation::GetSlot(), SlotsIcon::GetSlotID(), SlotsIcon::GetSlotParent(), ItemManager::HideDropzones(), SlotsIcon::IsReserved(), m_Entity, ItemManager::SetIsDragging() и SplitItemUtils::TakeOrSplitToInventory().

Используется в OnDropReceivedFromHeader() и OnDropReceivedFromHeader2().