MCPcopy Create free account
hub / github.com/DFHack/dfhack / getBaseMaterial

Method getBaseMaterial

library/modules/MapCache.cpp:884–1000  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

882}
883
884t_matpair MapExtras::BlockInfo::getBaseMaterial(df::tiletype tt, df::coord2d pos)
885{
886 using namespace df::enums::tiletype_material;
887
888 t_matpair rv(0,-1);
889 int x = pos.x, y = pos.y;
890
891 switch (tileMaterial(tt)) {
892 case NONE:
893 case AIR:
894 rv.mat_type = -1;
895 break;
896
897 case DRIFTWOOD:
898 case SOIL:
899 {
900 auto &biome = mblock->biomeInfoAt(pos);
901 rv.mat_index = biome.layer_stone[mblock->layerIndexAt(pos)];
902
903 if (getGroundType(rv.mat_index) == G_STONE)
904 {
905 int idx = biome.default_soil;
906 if (idx >= 0)
907 rv.mat_index = idx;
908 }
909
910 break;
911 }
912
913 case STONE:
914 {
915 auto &biome = mblock->biomeInfoAt(pos);
916 rv.mat_index = biome.layer_stone[mblock->layerIndexAt(pos)];
917
918 if (getGroundType(rv.mat_index) == G_SOIL)
919 {
920 int idx = biome.default_stone;
921 if (idx >= 0)
922 rv.mat_index = idx;
923 }
924
925 break;
926 }
927
928 case MINERAL:
929 rv.mat_index = veinmats[x][y];
930 break;
931
932 case LAVA_STONE:
933 rv.mat_index = mblock->biomeInfoAt(pos).lava_stone;
934 break;
935
936 case MUSHROOM:
937 case ROOT:
938 case TREE:
939 case PLANT:
940 rv.mat_type = MaterialInfo::PLANT_BASE;
941 if (auto plant = plants[block->map_pos + df::coord(x,y,0)])

Callers 1

ParseBasematsMethod · 0.80

Calls 2

tileMaterialFunction · 0.85
findFunction · 0.50

Tested by

no test coverage detected