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

◆ TakeAsAttachment()

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

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

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