本文整理汇总了C++中dfhack::Maps::getBlock方法的典型用法代码示例。如果您正苦于以下问题:C++ Maps::getBlock方法的具体用法?C++ Maps::getBlock怎么用?C++ Maps::getBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dfhack::Maps
的用法示例。
在下文中一共展示了Maps::getBlock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: df_flows
DFhackCExport command_result df_flows (Core * c, vector <string> & parameters)
{
uint32_t x_max,y_max,z_max;
DFHack::designations40d designations;
DFHack::Maps *Maps;
c->Suspend();
Maps = c->getMaps();
// init the map
if(!Maps->Start())
{
c->con.printerr("Can't init map.\n");
c->Resume();
return CR_FAILURE;
}
DFHack::t_blockflags bflags;
Maps->getSize(x_max,y_max,z_max);
// walk the map, count flowing tiles, magma, water
uint32_t flow1=0, flow2=0, flowboth=0, water=0, magma=0;
c->con.print("Counting flows and liquids ...\n");
for(uint32_t x = 0; x< x_max;x++)
{
for(uint32_t y = 0; y< y_max;y++)
{
for(uint32_t z = 0; z< z_max;z++)
{
if(Maps->getBlock(x,y,z))
{
Maps->ReadBlockFlags(x, y, z, bflags);
Maps->ReadDesignations(x, y, z, &designations);
if (bflags.bits.liquid_1)
flow1++;
if (bflags.bits.liquid_2)
flow2++;
if (bflags.bits.liquid_1 && bflags.bits.liquid_2)
flowboth++;
for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++)
{
if (designations[i][j].bits.liquid_type == DFHack::liquid_magma)
magma++;
if (designations[i][j].bits.liquid_type == DFHack::liquid_water)
water++;
}
}
}
}
}
c->con.print("Blocks with liquid_1=true: %d\n"
"Blocks with liquid_2=true: %d\n"
"Blocks with both: %d\n"
"Water tiles: %d\n"
"Magma tiles: %d\n"
,flow1, flow2, flowboth, water, magma
);
c->Resume();
return CR_OK;
}
示例2: cleanmap
DFhackCExport command_result cleanmap (Core * c, vector <string> & parameters)
{
const uint32_t water_idx = 6;
const uint32_t mud_idx = 12;
bool snow = false;
bool mud = false;
bool help = false;
for(int i = 0; i < parameters.size();i++)
{
if(parameters[i] == "snow")
snow = true;
else if(parameters[i] == "mud")
mud = true;
else if(parameters[i] == "help" ||parameters[i] == "?")
{
help = true;
}
}
if(help)
{
c->con.print("This command cleans the coverings from the map. Snow and mud are ignored by default.\n"
"Options:\n"
"snow - also remove snow\n"
"mud - also remove mud\n"
);
return CR_OK;
}
c->Suspend();
vector<DFHack::t_spattervein *> splatter;
DFHack::Maps *Mapz = c->getMaps();
// init the map
if(!Mapz->Start())
{
c->con << "Can't init map." << std::endl;
c->Resume();
return CR_FAILURE;
}
uint32_t x_max,y_max,z_max;
Mapz->getSize(x_max,y_max,z_max);
// walk the map
for(uint32_t x = 0; x< x_max;x++)
{
for(uint32_t y = 0; y< y_max;y++)
{
for(uint32_t z = 0; z< z_max;z++)
{
df_block * block = Mapz->getBlock(x,y,z);
if(block)
{
Mapz->SortBlockEvents(x,y,z,0,0,&splatter);
for(int i = 0; i < 16; i++)
for(int j = 0; j < 16; j++)
{
block->occupancy[i][j].bits.arrow_color = 0;
block->occupancy[i][j].bits.broken_arrows_variant = 0;
}
for(uint32_t i = 0; i < splatter.size(); i++)
{
DFHack::t_spattervein * vein = splatter[i];
// filter snow
if(!snow && vein->mat1 == water_idx && vein->matter_state == DFHack::state_powder)
continue;
// filter mud
if(!mud && vein->mat1 == mud_idx && vein->matter_state == DFHack::state_solid)
continue;
Mapz->RemoveBlockEvent(x,y,z,(t_virtual *) vein);
}
}
}
}
}
c->Resume();
return CR_OK;
}
示例3: autodump_main
//.........这里部分代码省略.........
else
{
it->second ++;
}
// iterator is valid here, we use it later to decrement the pile counter if the item is moved
// only dump the stuff marked for dumping and laying on the ground
if ( !itm->flags.dump
|| !itm->flags.on_ground
|| itm->flags.construction
|| itm->flags.hidden
|| itm->flags.in_building
|| itm->flags.in_chest
|| itm->flags.in_inventory
|| itm->flags.artifact1
)
continue;
if(!destroy) // move to cursor
{
// Change flags to indicate the dump was completed, as if by super-dwarfs
itm->flags.dump = false;
itm->flags.forbid = true;
// Don't move items if they're already at the cursor
if (pos_cursor == pos_item)
continue;
// Do we need to fix block-local item ID vector?
if(pos_item/16 != pos_cursor/16)
{
// yes...
cerr << "Moving from block to block!" << endl;
df_block * bl_src = Maps->getBlock(itm->x /16, itm->y/16, itm->z);
df_block * bl_tgt = Maps->getBlock(cx /16, cy/16, cz);
if(bl_src)
{
std::remove(bl_src->items.begin(), bl_src->items.end(),itm->id);
}
else
{
cerr << "No source block" << endl;
}
if(bl_tgt)
{
bl_tgt->items.push_back(itm->id);
}
else
{
cerr << "No target block" << endl;
}
}
// Move the item
itm->x = pos_cursor.x;
itm->y = pos_cursor.y;
itm->z = pos_cursor.z;
}
else // destroy
{
if (here && pos_item != pos_cursor)
continue;
itm->flags.garbage_colect = true;
// Cosmetic changes: make them disappear from view instantly