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

◆ TakeAsAttachment()

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

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

1115 {
1116 EntityAI receiver_item;
1117 EntityAI slot_owner;
1118 int slot_id = -1;
1119
1120 SlotsIcon slots_icon;
1121 receiver.GetUserData(slots_icon);
1122 if( slots_icon )
1123 {
1124 receiver_item = slots_icon.GetEntity();
1125 slot_id = slots_icon.GetSlotID();
1126 slot_owner = slots_icon.GetSlotParent();
1127 }
1128
1129 EntityAI item = GetItemPreviewItem( w );
1130 if( !item )
1131 {
1132 return;
1133 }
1134
1135 ItemBase item_base = ItemBase.Cast( item );
1136 float stack_max = item_base.GetTargetQuantityMax(slot_id);
1137
1138 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
1139 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
1140 return;
1141
1142 EntityAI target_att_entity = m_Entity;
1143 Weapon_Base wpn;
1144 Magazine mag;
1145 if( Class.CastTo(wpn, target_att_entity ) && Class.CastTo(mag, item ) )
1146 {
1147 if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
1148 {
1149 player.GetWeaponManager().AttachMagazine( mag );
1150 }
1151 else if(player.GetWeaponManager().CanSwapMagazine( wpn, mag ))
1152 {
1153 player.GetWeaponManager().SwapMagazine( mag );
1154 }
1155 }
1156 else if( receiver_item )
1157 {
1158 if( receiver_item != item )
1159 {
1160 if( ( ItemBase.Cast( receiver_item ) ).CanBeCombined( ItemBase.Cast( item ) ) )
1161 {
1162 ( ItemBase.Cast( receiver_item ) ).CombineItemsClient( ItemBase.Cast( item ) );
1163 }
1164 else if( GameInventory.CanSwapEntitiesEx( receiver_item, item ) )
1165 {
1166 if( !receiver_item.GetInventory().CanRemoveEntity() )
1167 return;
1168 GetGame().GetPlayer().PredictiveSwapEntities( item, receiver_item );
1169 }
1170 }
1171 }
1172 else if( slot_owner && slot_owner.GetInventory().CanAddAttachmentEx( item, slot_id ) )
1173 {
1174 if( stack_max == 0 || stack_max >= item_base.GetQuantity() )
1175 {
1176 player.PredictiveTakeEntityToTargetAttachmentEx(slot_owner, item, slot_id);
1177 }
1178 else if( stack_max != 0 && stack_max < item_base.GetQuantity() )
1179 {
1180 item_base.SplitIntoStackMaxClient( slot_owner, slot_id );
1181 }
1182 }
1183 else if( slot_owner && slot_owner.GetInventory().CanAddAttachment( item ) )
1184 {
1185 if( stack_max == 0 || stack_max >= item_base.GetQuantity() )
1186 {
1187 player.PredictiveTakeEntityToTargetAttachment(slot_owner, item);
1188 }
1189 else if( stack_max != 0 && stack_max < item_base.GetQuantity() )
1190 {
1191 item_base.SplitIntoStackMaxClient( slot_owner, -1 );
1192 }
1193 }
1194 else if( target_att_entity.GetInventory().CanAddAttachment( item ) )
1195 {
1196 if( stack_max == 0 || stack_max >= item_base.GetQuantity() )
1197 {
1198 player.PredictiveTakeEntityToTargetAttachment(target_att_entity, item);
1199 }
1200 else if( stack_max != 0 && stack_max < item_base.GetQuantity() )
1201 {
1202 item_base.SplitIntoStackMaxClient( target_att_entity, -1 );
1203 }
1204 }
1205 else if( ( target_att_entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && ( !player.GetInventory().HasEntityInInventory( item ) || !m_Entity.GetInventory().HasEntityInCargo( item )) ) || player.GetHumanInventory().HasEntityInHands( item ) )
1206 {
1207 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( GetGame().GetPlayer() ), target_att_entity, item );
1208 }
1209 /*else if( !player.GetInventory().HasEntityInInventory( item ) || !target_att_entity.GetInventory().HasEntityInCargo( item ) )
1210 {
1211 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( GetGame().GetPlayer() ), target_att_entity, item );
1212 }*/
1213
1214 ItemManager.GetInstance().HideDropzones();
1215 ItemManager.GetInstance().SetIsDragging( false );
1216 }
class LogManager EntityAI
EntityAI m_Entity
Определения ActionDebug.c:11
class GP5GasMask extends MaskBase ItemBase
PlayerBase GetPlayer()
Определения ModifierBase.c:51
proto native DayZPlayer GetPlayer()
EntityAI GetItemPreviewItem(Widget w)
Определения HandsContainer.c:436
EntityAI GetEntity()
Определения SlotsIcon.c:365
EntityAI GetSlotParent()
Определения SlotsIcon.c:185
int GetSlotID()
Определения SlotsIcon.c:190
proto native CGame GetGame()

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

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