MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / destroyBlock

Method destroyBlock

source/game/StarWorldServer.cpp:1823–1898  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1821}
1822
1823List<ItemDescriptor> WorldServer::destroyBlock(TileLayer layer, Vec2I const& pos, bool genItems, bool destroyModFirst, bool updateNeighbors) {
1824 auto materialDatabase = Root::singleton().materialDatabase();
1825
1826 auto* tile = m_tileArray->modifyTile(pos);
1827 if (!tile)
1828 return {};
1829
1830 List<ItemDescriptor> drops;
1831
1832 if (layer == TileLayer::Background) {
1833 if (isRealMod(tile->backgroundMod) && destroyModFirst
1834 && !materialDatabase->modBreaksWithTile(tile->backgroundMod)) {
1835 if (genItems) {
1836 if (auto drop = materialDatabase->modItemDrop(tile->backgroundMod))
1837 drops.append(drop);
1838 }
1839 tile->backgroundMod = NoModId;
1840 } else {
1841 if (genItems) {
1842 if (auto drop = materialDatabase->materialItemDrop(tile->background))
1843 drops.append(drop);
1844 if (auto drop = materialDatabase->modItemDrop(tile->backgroundMod))
1845 drops.append(drop);
1846 }
1847 tile->background = EmptyMaterialId;
1848 tile->backgroundColorVariant = DefaultMaterialColorVariant;
1849 tile->backgroundHueShift = 0;
1850 tile->backgroundMod = NoModId;
1851 }
1852
1853 tile->backgroundDamage.reset();
1854
1855 } else {
1856 if (isRealMod(tile->foregroundMod) && destroyModFirst
1857 && !materialDatabase->modBreaksWithTile(tile->foregroundMod)) {
1858 if (genItems) {
1859 if (auto drop = materialDatabase->modItemDrop(tile->foregroundMod))
1860 drops.append(drop);
1861 }
1862 tile->foregroundMod = NoModId;
1863 } else {
1864 if (genItems) {
1865 if (auto drop = materialDatabase->materialItemDrop(tile->foreground))
1866 drops.append(drop);
1867 if (auto drop = materialDatabase->modItemDrop(tile->foregroundMod))
1868 drops.append(drop);
1869 }
1870 tile->foreground = EmptyMaterialId;
1871 tile->foregroundColorVariant = DefaultMaterialColorVariant;
1872 tile->foregroundHueShift = 0;
1873 tile->foregroundMod = NoModId;
1874 tile->updateCollision(CollisionKind::None);
1875 dirtyCollision(RectI::withSize(pos, {1, 1}));
1876 }
1877
1878 tile->foregroundDamage.reset();
1879 }
1880

Callers 1

moveBlockMethod · 0.80

Calls 12

singletonClass · 0.85
isRealModFunction · 0.85
materialDatabaseMethod · 0.80
modBreaksWithTileMethod · 0.80
modItemDropMethod · 0.80
materialItemDropMethod · 0.80
updateCollisionMethod · 0.80
blockInfoMethod · 0.80
modifyTileMethod · 0.45
appendMethod · 0.45
resetMethod · 0.45
visitLocationMethod · 0.45

Tested by

no test coverage detected