spawns material from any construction; 'player' parameter optional; 'main_part_name' is actually a PART_NAME!
1810 {
1811 string partName = mainPartName;
1812 int childCount =
g_Game.ConfigGetChildrenCount(cfgPath);
1813
1814 for (int i = 0; i < childCount; ++i)
1815 {
1816 string child_name;
1817 g_Game.ConfigGetChildName(cfgPath, i, child_name);
1818
1819
1820 string configPath;
1821 string type;
1822 string slot_name;
1823 configPath = cfgPath + " " + child_name + " " + "type";
1824 g_Game.ConfigGetText(configPath, type);
1825 configPath = cfgPath + " " + child_name + " " + "slot_name";
1826 g_Game.ConfigGetText(configPath, slot_name);
1827 configPath = cfgPath + " " + child_name + " " + "quantity";
1828 float quantity =
g_Game.ConfigGetFloat(configPath);
1829 configPath = cfgPath + " " + child_name + " " + "lockable";
1830 bool lockable =
g_Game.ConfigGetInt(configPath);
1831 configPath = cfgPath + " " + child_name + " " + "skipOnDismantle";
1832 bool skipOnDismantle =
g_Game.ConfigGetInt(configPath);
1833
1834 if (skipOnDismantle)
1835 continue;
1836
1837
1838 ItemBase attachment =
ItemBase.Cast(entity.FindAttachmentBySlotName(slot_name));
1839 int slot_id;
1840
1841
1842 if (lockable)
1843 {
1844 if (attachment)
1845 {
1846 InventoryLocation src = new InventoryLocation();
1847 attachment.GetInventory().GetCurrentInventoryLocation(src);
1848 if (LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] " +
Object.GetDebugName(entity) +
" DropNonUsableMaterials UNlocking slot=" + src.
GetSlot());
1849 entity.GetInventory().SetSlotLock(src.
GetSlot() ,
false);
1850
1851
1852 if (isBase)
1853 {
1854 if (
g_Game.IsMultiplayer() && player)
1855 {
1856 InventoryLocation dst = new InventoryLocation();
1857 GameInventory.SetGroundPosByOwner(player, src.
GetItem(), dst);
1858 player.ServerTakeToDst(src, dst);
1859 }
1860 else
1861 {
1862 entity.GetInventory().DropEntity(
InventoryMode.PREDICTIVE, entity, attachment);
1863 }
1864 }
1865 }
1866 }
1867 else
1868 {
1869 float pileHealth;
1870 float qtyCoef;
1871 vector destination = entity.GetPosition();
1872 vector playerPosition;
1873
1874 if (player)
1875 {
1876 playerPosition = player.GetPosition();
1877 destination = playerPosition;
1878 }
1879
1880 if (entity.MemoryPointExists("" + partName + "_materials"))
1881 {
1882 destination = entity.GetMemoryPointPos("" + partName + "_materials");
1883 destination =
g_Game.ObjectModelToWorld(entity, destination);
1884 }
1885 else if (entity.MemoryPointExists(partName))
1886 {
1887 destination = entity.GetMemoryPointPos(partName);
1888 destination =
g_Game.ObjectModelToWorld(entity, destination);
1889 }
1890 pileHealth = entity.GetHealth01(damagezoneName, "Health") * MiscGameplayFunctions.GetTypeMaxGlobalHealth(type);
1891 qtyCoef = 1 - (entity.GetHealthLevel(damagezoneName) * Construction.DECONSTURCT_MATERIAL_LOSS) - Construction.DECONSTURCT_MATERIAL_LOSS;
1892 quantity *= qtyCoef;
1893 quantity = Math.Max(Math.Floor(quantity),1);
1894
1895 if (player)
1896 {
1897 vector posHead = MiscGameplayFunctions.GetPlayerHeadPosition(PlayerBase.Cast(player));
1898 MiscGameplayFunctions.CreateItemBasePilesDispersed(type, posHead, destination, UAItemsSpreadRadius.NARROW, quantity, pileHealth, player);
1899 }
1900 else
1901 {
1902 MiscGameplayFunctions.CreateItemBasePilesEx(type, destination, quantity, pileHealth, true, throwPiles);
1903 }
1904 }
1905 }
1906 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
class GP5GasMask extends MaskBase ItemBase
proto native int GetSlot()
returns slot id if current type is Attachment
proto native EntityAI GetItem()
returns item of current inventory location