1234 {
1236
1237 for ( int i = 0; i < child_count; i++ )
1238 {
1239 string child_name;
1241
1242
1243 string config_path;
1244 string type;
1245 string slot_name;
1246 config_path = cfg_path + " " + child_name + " " + "type";
1248 config_path = cfg_path + " " + child_name + " " + "slot_name";
1250 config_path = cfg_path + " " + child_name + " " + "quantity";
1252 config_path = cfg_path + " " + child_name + " " + "lockable";
1254
1255
1256 ItemBase attachment =
ItemBase.Cast( entity.FindAttachmentBySlotName( slot_name ) );
1257 int slot_id;
1258
1259
1260 if ( lockable )
1261 {
1262 if ( attachment )
1263 {
1264 InventoryLocation src = new InventoryLocation;
1265 attachment.GetInventory().GetCurrentInventoryLocation( src );
1266 if (LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] " +
Object.GetDebugName( entity) +
" DropNonUsableMaterials UNlocking slot=" + src.
GetSlot() );
1267 entity.GetInventory().SetSlotLock( src.
GetSlot() ,
false );
1268
1269
1270 if ( is_base )
1271 {
1272 if (
GetGame().IsMultiplayer() && player )
1273 {
1274 InventoryLocation dst = new InventoryLocation;
1275 GameInventory.SetGroundPosByOwner( player, src.
GetItem(), dst );
1276 player.ServerTakeToDst( src, dst );
1277 }
1278 else
1279 {
1280 entity.GetInventory().DropEntity(
InventoryMode.PREDICTIVE, entity, attachment );
1281 }
1282 }
1283 }
1284 }
1285 else
1286 {
1287 float pile_health;
1288 float qty_coef;
1289 vector destination = entity.GetPosition();
1290
1291 if ( entity.MemoryPointExists("" + main_part_name + "_materials") )
1292 {
1293 destination = entity.GetMemoryPointPos("" + main_part_name + "_materials");
1295 }
1296 else if ( entity.MemoryPointExists(main_part_name) )
1297 {
1298 destination = entity.GetMemoryPointPos(main_part_name);
1300 }
1301 pile_health = entity.GetHealth01(damagezone_name,"Health") * MiscGameplayFunctions.GetTypeMaxGlobalHealth(type);
1302 qty_coef = 1 - (entity.GetHealthLevel(damagezone_name) *
Construction.DECONSTURCT_MATERIAL_LOSS) -
Construction.DECONSTURCT_MATERIAL_LOSS;
1303 quantity *= qty_coef;
1304 quantity = Math.Max(Math.Floor(quantity),1);
1305
1306 if (player)
1307 {
1308 vector posHead;
1309 MiscGameplayFunctions.GetHeadBonePos(PlayerBase.Cast(player),posHead);
1310 MiscGameplayFunctions.CreateItemBasePilesDispersed(type,posHead,destination,UAItemsSpreadRadius.NARROW,quantity,pile_health,player);
1311 }
1312 else
1313 {
1314 MiscGameplayFunctions.CreateItemBasePiles(type,destination,quantity,pile_health,true);
1315 }
1316 }
1317 }
1318 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
void Construction(BaseBuildingBase parent)
class GP5GasMask extends MaskBase ItemBase
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native vector ObjectModelToWorld(Object obj, vector modelPos)
proto native int GetSlot()
returns slot id if current type is Attachment
proto native EntityAI GetItem()
returns item of current inventory location
proto native CGame GetGame()