本文整理汇总了C++中mapextras::MapCache::veinMaterialAt方法的典型用法代码示例。如果您正苦于以下问题:C++ MapCache::veinMaterialAt方法的具体用法?C++ MapCache::veinMaterialAt怎么用?C++ MapCache::veinMaterialAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapextras::MapCache
的用法示例。
在下文中一共展示了MapCache::veinMaterialAt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: maybeExplore
void maybeExplore(color_ostream& out, MapExtras::MapCache& cache, df::coord pt, set<df::coord>& jobLocations) {
if ( !Maps::isValidTilePos(pt) ) {
return;
}
df::map_block* block = Maps::getTileBlock(pt);
if (!block)
return;
if ( block->designation[pt.x&0xF][pt.y&0xF].bits.hidden )
return;
df::tiletype type = block->tiletype[pt.x&0xF][pt.y&0xF];
if ( ENUM_ATTR(tiletype, material, type) != df::enums::tiletype_material::MINERAL )
return;
if ( ENUM_ATTR(tiletype, shape, type) != df::enums::tiletype_shape::WALL )
return;
if ( block->designation[pt.x&0xF][pt.y&0xF].bits.dig != df::enums::tile_dig_designation::No )
return;
uint32_t xMax,yMax,zMax;
Maps::getSize(xMax,yMax,zMax);
if ( pt.x == 0 || pt.y == 0 || pt.x+1 == xMax*16 || pt.y+1 == yMax*16 )
return;
if ( jobLocations.find(pt) != jobLocations.end() ) {
return;
}
int16_t mat = cache.veinMaterialAt(pt);
if ( mat == -1 )
return;
if ( !digAll ) {
df::inorganic_raw* inorganic = world->raws.inorganics[mat];
if ( autodigMaterials.find(inorganic->id) == autodigMaterials.end() ) {
return;
}
}
block->designation[pt.x&0xF][pt.y&0xF].bits.dig = df::enums::tile_dig_designation::Default;
block->flags.bits.designated = true;
// *process_dig = true;
// *process_jobs = true;
}
示例2: vdig
DFhackCExport command_result vdig (Core * c, vector <string> & parameters)
{
uint32_t x_max,y_max,z_max;
bool updown = false;
for(int i = 0; i < parameters.size();i++)
{
if(parameters.size() && parameters[0]=="x")
updown = true;
else if(parameters[i] == "help" || parameters[i] == "?")
{
c->con.print("Designates a whole vein under the cursor for digging.\n"
"Options:\n"
"x - follow veins through z-levels with stairs.\n"
);
return CR_OK;
}
}
Console & con = c->con;
c->Suspend();
DFHack::Maps * Maps = c->getMaps();
DFHack::Gui * Gui = c->getGui();
// init the map
if(!Maps->Start())
{
con.printerr("Can't init map. Make sure you have a map loaded in DF.\n");
c->Resume();
return CR_FAILURE;
}
int32_t cx, cy, cz;
Maps->getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
Gui->getCursorCoords(cx,cy,cz);
while(cx == -30000)
{
con.printerr("Cursor is not active. Point the cursor at a vein.\n");
c->Resume();
return CR_FAILURE;
}
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1)
{
con.printerr("I won't dig the borders. That would be cheating!\n");
c->Resume();
return CR_FAILURE;
}
MapExtras::MapCache * MCache = new MapExtras::MapCache(Maps);
DFHack::t_designation des = MCache->designationAt(xy);
int16_t tt = MCache->tiletypeAt(xy);
int16_t veinmat = MCache->veinMaterialAt(xy);
if( veinmat == -1 )
{
con.printerr("This tile is not a vein.\n");
delete MCache;
c->Resume();
return CR_FAILURE;
}
con.print("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, des.whole);
stack <DFHack::DFCoord> flood;
flood.push(xy);
while( !flood.empty() )
{
DFHack::DFCoord current = flood.top();
flood.pop();
int16_t vmat2 = MCache->veinMaterialAt(current);
tt = MCache->tiletypeAt(current);
if(!DFHack::isWallTerrain(tt))
continue;
if(vmat2!=veinmat)
continue;
// found a good tile, dig+unset material
DFHack::t_designation des = MCache->designationAt(current);
DFHack::t_designation des_minus;
DFHack::t_designation des_plus;
des_plus.whole = des_minus.whole = 0;
int16_t vmat_minus = -1;
int16_t vmat_plus = -1;
bool below = 0;
bool above = 0;
if(updown)
{
if(MCache->testCoord(current-1))
{
below = 1;
des_minus = MCache->designationAt(current-1);
vmat_minus = MCache->veinMaterialAt(current-1);
}
if(MCache->testCoord(current+1))
{
above = 1;
des_plus = MCache->designationAt(current+1);
vmat_plus = MCache->veinMaterialAt(current+1);
}
}
//.........这里部分代码省略.........
示例3: vdig
command_result vdig (Core * c, vector <string> & parameters)
{
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
uint32_t x_max,y_max,z_max;
bool updown = false;
for(size_t i = 0; i < parameters.size();i++)
{
if(parameters.size() && parameters[0]=="x")
updown = true;
else
return CR_WRONG_USAGE;
}
Console & con = c->con;
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
return CR_FAILURE;
}
int32_t cx, cy, cz;
Maps::getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
Gui::getCursorCoords(cx,cy,cz);
while(cx == -30000)
{
con.printerr("Cursor is not active. Point the cursor at a vein.\n");
return CR_FAILURE;
}
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1)
{
con.printerr("I won't dig the borders. That would be cheating!\n");
return CR_FAILURE;
}
MapExtras::MapCache * MCache = new MapExtras::MapCache;
df::tile_designation des = MCache->designationAt(xy);
df::tiletype tt = MCache->tiletypeAt(xy);
int16_t veinmat = MCache->veinMaterialAt(xy);
if( veinmat == -1 )
{
con.printerr("This tile is not a vein.\n");
delete MCache;
return CR_FAILURE;
}
con.print("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, des.whole);
stack <DFHack::DFCoord> flood;
flood.push(xy);
while( !flood.empty() )
{
DFHack::DFCoord current = flood.top();
flood.pop();
int16_t vmat2 = MCache->veinMaterialAt(current);
tt = MCache->tiletypeAt(current);
if(!DFHack::isWallTerrain(tt))
continue;
if(vmat2!=veinmat)
continue;
// found a good tile, dig+unset material
df::tile_designation des = MCache->designationAt(current);
df::tile_designation des_minus;
df::tile_designation des_plus;
des_plus.whole = des_minus.whole = 0;
int16_t vmat_minus = -1;
int16_t vmat_plus = -1;
bool below = 0;
bool above = 0;
if(updown)
{
if(MCache->testCoord(current-1))
{
below = 1;
des_minus = MCache->designationAt(current-1);
vmat_minus = MCache->veinMaterialAt(current-1);
}
if(MCache->testCoord(current+1))
{
above = 1;
des_plus = MCache->designationAt(current+1);
vmat_plus = MCache->veinMaterialAt(current+1);
}
}
if(MCache->testCoord(current))
{
MCache->clearMaterialAt(current);
if(current.x < tx_max - 2)
{
flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z));
if(current.y < ty_max - 2)
{
flood.push(DFHack::DFCoord(current.x + 1, current.y + 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z));
}
if(current.y > 1)
{
//.........这里部分代码省略.........
示例4: df_probe
//.........这里部分代码省略.........
int bx = clip_range(block.region_pos.x + (offset % 3) - 1, 0, world->world_data->world_width-1);
int by = clip_range(block.region_pos.y + (offset / 3) - 1, 0, world->world_data->world_height-1);
auto biome = &world->world_data->region_map[bx][by];
int sav = biome->savagery;
int evi = biome->evilness;
int sindex = sav > 65 ? 2 : sav < 33 ? 0 : 1;
int eindex = evi > 65 ? 2 : evi < 33 ? 0 : 1;
int surr = sindex + eindex * 3;
const char* surroundings[] = { "Serene", "Mirthful", "Joyous Wilds", "Calm", "Wilderness", "Untamed Wilds", "Sinister", "Haunted", "Terrifying" };
// biome, geolayer
out << "biome: " << des.bits.biome << " (" <<
"region id=" << biome->region_id << ", " <<
surroundings[surr] << ", " <<
"savagery " << biome->savagery << ", " <<
"evilness " << biome->evilness << ")" << std::endl;
out << "geolayer: " << des.bits.geolayer_index
<< std::endl;
int16_t base_rock = mc.layerMaterialAt(cursor);
if(base_rock != -1)
{
out << "Layer material: " << dec << base_rock;
if(hasmats)
out << " / " << inorganic[base_rock].id
<< " / "
<< inorganic[base_rock].name
<< endl;
else
out << endl;
}
int16_t vein_rock = mc.veinMaterialAt(cursor);
if(vein_rock != -1)
{
out << "Vein material (final): " << dec << vein_rock;
if(hasmats)
out << " / " << inorganic[vein_rock].id
<< " / "
<< inorganic[vein_rock].name
<< endl;
else
out << endl;
}
MaterialInfo minfo(mc.baseMaterialAt(cursor));
if (minfo.isValid())
out << "Base material: " << minfo.getToken() << " / " << minfo.toString() << endl;
minfo.decode(mc.staticMaterialAt(cursor));
if (minfo.isValid())
out << "Static material: " << minfo.getToken() << " / " << minfo.toString() << endl;
// liquids
if(des.bits.flow_size)
{
if(des.bits.liquid_type == tile_liquid::Magma)
out <<"magma: ";
else out <<"water: ";
out << des.bits.flow_size << std::endl;
}
if(des.bits.flow_forbid)
out << "flow forbid" << std::endl;
if(des.bits.pile)
out << "stockpile?" << std::endl;
if(des.bits.rained)
out << "rained?" << std::endl;
if(des.bits.smooth)
示例5: colorTile
void colorTile(const df::tiletype_material& tileMat,MapExtras::MapCache& cache,const DFCoord& pos,screenTile& trg,bool isUndug=false)
{
t_matpair mat;
switch(tileMat)
{
case df::tiletype_material::ASHES:
trg.fg=COLOR_GREY;
trg.bold=false;
break;
case df::tiletype_material::CAMPFIRE:
trg.fg=COLOR_YELLOW;
trg.bold=true;
break;
case df::tiletype_material::SOIL:
mat=cache.baseMaterialAt(pos);
{
df::material* m=lookupMaterial(mat,trg);
if(m && isUndug)
{
trg.tile=m->tile;
}
break;
}
case df::tiletype_material::STONE:
case df::tiletype_material::LAVA_STONE:
mat=cache.baseMaterialAt(pos);
lookupMaterial(mat,trg);
break;
case df::tiletype_material::CONSTRUCTION:
mat=cache.staticMaterialAt(pos);
lookupMaterial(mat,trg,true);
break;
case df::tiletype_material::MINERAL:
mat.mat_index=cache.veinMaterialAt(pos);
mat.mat_type=0;//inorganic
{
df::material* m=lookupMaterial(mat,trg);
if(m && isUndug)
{
trg.tile=m->tile;
}
}
break;
case df::tiletype_material::FROZEN_LIQUID:
trg.fg=COLOR_CYAN;
trg.bold=true;
break;
case df::tiletype_material::PLANT:
case df::tiletype_material::GRASS_LIGHT: //MORE INFO IN MAP BLOCK EVENTS
trg.fg=COLOR_GREEN;
trg.bold=true;
break;
case df::tiletype_material::GRASS_DARK:
trg.fg=COLOR_GREEN;
trg.bold=false;
break;
case df::tiletype_material::GRASS_DRY:
trg.fg=COLOR_YELLOW;
trg.bold=true;
break;
case df::tiletype_material::GRASS_DEAD:
trg.fg=COLOR_BROWN;
trg.bold=false;
break;
case df::tiletype_material::DRIFTWOOD:
trg.fg=COLOR_WHITE;
trg.bold=true;
break;
case df::tiletype_material::MAGMA:
trg.fg=COLOR_RED;
trg.bold=true;
break;
case df::tiletype_material::POOL:
case df::tiletype_material::RIVER:
case df::tiletype_material::BROOK:
trg.fg=COLOR_BROWN;
trg.bold=false;
break;
}
}
示例6: df_probe
//.........这里部分代码省略.........
df::tiletype_special special = tileSpecial(tiletype);
df::tiletype_variant variant = tileVariant(tiletype);
con.print("%-10s: %4d %s\n","Class" ,shape,
ENUM_KEY_STR(tiletype_shape, shape));
con.print("%-10s: %4d %s\n","Material" ,
material, ENUM_KEY_STR(tiletype_material, material));
con.print("%-10s: %4d %s\n","Special" ,
special, ENUM_KEY_STR(tiletype_special, special));
con.print("%-10s: %4d %s\n" ,"Variant" ,
variant, ENUM_KEY_STR(tiletype_variant, variant));
con.print("%-10s: %s\n" ,"Direction",
tileDirection(tiletype).getStr());
con.print("\n");
con.print("temperature1: %d U\n",mc.temperature1At(cursor));
con.print("temperature2: %d U\n",mc.temperature2At(cursor));
// biome, geolayer
con << "biome: " << des.bits.biome << std::endl;
con << "geolayer: " << des.bits.geolayer_index
<< std::endl;
int16_t base_rock = mc.baseMaterialAt(cursor);
if(base_rock != -1)
{
con << "Layer material: " << dec << base_rock;
if(hasmats)
con << " / " << inorganic[base_rock].id
<< " / "
<< inorganic[base_rock].name
<< endl;
else
con << endl;
}
int16_t vein_rock = mc.veinMaterialAt(cursor);
if(vein_rock != -1)
{
con << "Vein material (final): " << dec << vein_rock;
if(hasmats)
con << " / " << inorganic[vein_rock].id
<< " / "
<< inorganic[vein_rock].name
<< endl;
else
con << endl;
}
// liquids
if(des.bits.flow_size)
{
if(des.bits.liquid_type == tile_liquid::Magma)
con <<"magma: ";
else con <<"water: ";
con << des.bits.flow_size << std::endl;
}
if(des.bits.flow_forbid)
con << "flow forbid" << std::endl;
if(des.bits.pile)
con << "stockpile?" << std::endl;
if(des.bits.rained)
con << "rained?" << std::endl;
if(des.bits.smooth)
con << "smooth?" << std::endl;
if(des.bits.water_salt)
con << "salty" << endl;
if(des.bits.water_stagnant)
con << "stagnant" << endl;