本文整理汇总了C++中mapextras::MapCache::staticMaterialAt方法的典型用法代码示例。如果您正苦于以下问题:C++ MapCache::staticMaterialAt方法的具体用法?C++ MapCache::staticMaterialAt怎么用?C++ MapCache::staticMaterialAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapextras::MapCache
的用法示例。
在下文中一共展示了MapCache::staticMaterialAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: df_probe
//.........这里部分代码省略.........
"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)
out << "smooth?" << std::endl;
if(des.bits.water_salt)
out << "salty" << endl;
if(des.bits.water_stagnant)
out << "stagnant" << endl;
#define PRINT_FLAG( FIELD, BIT ) out.print("%-16s= %c\n", #BIT , ( FIELD.bits.BIT ? 'Y' : ' ' ) )
PRINT_FLAG( des, hidden );
PRINT_FLAG( des, light );
PRINT_FLAG( des, outside );
PRINT_FLAG( des, subterranean );
PRINT_FLAG( des, water_table );
PRINT_FLAG( des, rained );
PRINT_FLAG( occ, monster_lair);
示例3: drawBuffer
void Offscreen::drawBuffer( rect2d window,int z,std::vector<screenTile>& buffer )
{
if(!df::global::world)
return;
//TODO static array of images for each tiletype
MapExtras::MapCache cache;
int w=window.second.x-window.first.x;
int h=window.second.y-window.first.y;
rect2d localWindow=mkrect_wh(0,0,w+1,h+1);
if(buffer.size()!=w*h)
buffer.resize(w*h);
//basic tiletype stuff here
for(int x=window.first.x;x<window.second.x;x++) //todo, make it by block, minimal improvement over cache prob though
for(int y=window.first.y;y<window.second.y;y++)
{
DFCoord coord(x,y,z);
df::tiletype tt=cache.tiletypeAt(coord);
df::tiletype_shape shape = ENUM_ATTR(tiletype,shape,tt);
df::tiletype_shape_basic basic_shape = ENUM_ATTR(tiletype_shape, basic_shape, shape);
t_matpair mat=cache.staticMaterialAt(coord);
df::tiletype_material tileMat= ENUM_ATTR(tiletype,material,tt);
df::tile_designation d=cache.designationAt(coord);
df::tile_occupancy o=cache.occupancyAt(coord);
df::tiletype_special sp=ENUM_ATTR(tiletype,special,tt);
int wx=x-window.first.x;
int wy=y-window.first.y;
screenTile& curTile=buffer[wx*h+wy];
if(d.bits.hidden)
{
curTile.tile=0;
continue;
}
if(shape==df::tiletype_shape::EMPTY || shape==df::tiletype_shape::RAMP_TOP)
{
//empty,liquids and '.' for other stuff...
DFCoord coord2(x,y,z-1);
df::tiletype tt2=cache.tiletypeAt(coord2);
df::tiletype_shape shape2 = ENUM_ATTR(tiletype,shape,tt);
df::tiletype_material tileMat2= ENUM_ATTR(tiletype,material,tt2);
df::tile_designation d2=cache.designationAt(coord2);
df::tiletype_special sp2=ENUM_ATTR(tiletype,special,tt2);
bool unDug2= (sp2!=df::tiletype_special::SMOOTH && shape2==df::tiletype_shape::WALL);
if (d2.bits.flow_size>0)
{
if(shape!=df::tiletype_shape::RAMP_TOP) //don't show liquid amount on ramp tops
curTile.tile='0'+d2.bits.flow_size; //TODO lookup setting for this
else
curTile.tile=tilePics[tt];
curTile.fg=(d2.bits.liquid_type)?(COLOR_RED):(COLOR_BLUE);
continue;
}
else if(shape2==df::tiletype_shape::EMPTY)
{
curTile.tile=178; //look up settings
curTile.fg=COLOR_CYAN;
continue;
}
else
{
if(shape==df::tiletype_shape::RAMP_TOP)
curTile.tile=tilePics[tt];
else
curTile.tile='.';
colorTile(tileMat2,cache,coord2,curTile,unDug2);
continue;
}
}
bool inliquid=false;
bool unDug= (sp!=df::tiletype_special::SMOOTH && shape==df::tiletype_shape::WALL);
if (d.bits.flow_size>0)
{
curTile.tile='0'+d.bits.flow_size;
curTile.fg=(d.bits.liquid_type)?(COLOR_RED):(COLOR_BLUE);
curTile.bold=true;
inliquid=true;
}
if(!inliquid && shape!=df::tiletype_shape::RAMP_TOP)
{
curTile.tile=tilePics[tt];
colorTile(tileMat,cache,coord,curTile,unDug);
if(!unDug)
{
curTile.bg=0;
}
}
else
{
if(shape==df::tiletype_shape::RAMP || shape==df::tiletype_shape::BROOK_BED || shape==df::tiletype_shape::RAMP_TOP)
curTile.tile=tilePics[tt];
if(!inliquid)
colorTile(tileMat,cache,coord,curTile,true);
}
}
//plants
for(int bx=window.first.x/16;bx<=window.second.x/16;bx++) //blocks have items by id. So yeah each item a search would be slow
for(int by=window.first.y/16;by<=window.second.y/16;by++)
//.........这里部分代码省略.........