本文整理汇总了C++中MaterialInfo::findInorganic方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialInfo::findInorganic方法的具体用法?C++ MaterialInfo::findInorganic怎么用?C++ MaterialInfo::findInorganic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaterialInfo
的用法示例。
在下文中一共展示了MaterialInfo::findInorganic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: df_changevein
command_result df_changevein (color_ostream &out, vector <string> & parameters)
{
if (parameters.size() != 1)
return CR_WRONG_USAGE;
CoreSuspender suspend;
if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
return CR_FAILURE;
}
if (!cursor || cursor->x == -30000)
{
out.printerr("No cursor detected - please place the cursor over a mineral vein.\n");
return CR_FAILURE;
}
MaterialInfo mi;
if (!mi.findInorganic(parameters[0]))
{
out.printerr("No such material!\n");
return CR_FAILURE;
}
if (mi.inorganic->material.flags.is_set(material_flags::IS_METAL) ||
mi.inorganic->material.flags.is_set(material_flags::NO_STONE_STOCKPILE) ||
mi.inorganic->flags.is_set(inorganic_flags::SOIL_ANY))
{
out.printerr("Invalid material - you must select a type of stone or gem\n");
return CR_FAILURE;
}
df::map_block *block = Maps::getBlockAbs(cursor->x, cursor->y, cursor->z);
if (!block)
{
out.printerr("Invalid tile selected.\n");
return CR_FAILURE;
}
df::block_square_event_mineralst *mineral = NULL;
int tx = cursor->x % 16, ty = cursor->y % 16;
for (size_t j = 0; j < block->block_events.size(); j++)
{
df::block_square_event *evt = block->block_events[j];
if (evt->getType() != block_square_event_type::mineral)
continue;
mineral = (df::block_square_event_mineralst *)evt;
if (mineral->getassignment(tx, ty))
break;
mineral = NULL;
}
if (!mineral)
{
out.printerr("Selected tile does not contain a mineral vein.\n");
return CR_FAILURE;
}
mineral->inorganic_mat = mi.index;
return CR_OK;
}