本文整理汇总了C++中MaterialInfo::decode方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialInfo::decode方法的具体用法?C++ MaterialInfo::decode怎么用?C++ MaterialInfo::decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaterialInfo
的用法示例。
在下文中一共展示了MaterialInfo::decode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: guess_job_material
static void guess_job_material(df::job *job, MaterialInfo &mat, df::dfhack_material_category &mat_mask)
{
using namespace df::enums::job_type;
if (job->job_type == PrepareMeal)
mat.decode(-1);
else
mat.decode(job);
mat_mask.whole = job->material_category.whole;
// Material from the job enum
const char *job_material = ENUM_ATTR(job_type, material, job->job_type);
if (job_material)
{
MaterialInfo info;
if (info.findBuiltin(job_material))
mat = info;
else
parseJobMaterialCategory(&mat_mask, job_material);
}
// Material from the job reagent
if (!mat.isValid() && !job->job_items.empty() &&
(job->job_items.size() == 1 ||
job->job_items[0]->item_type == item_type::PLANT))
{
mat.decode(job->job_items[0]);
switch (job->job_items[0]->item_type)
{
case item_type::WOOD:
mat_mask.bits.wood = mat_mask.bits.wood2 = true;
break;
default:
break;
}
}
}
示例2: getItemBaseValue
//.........这里部分代码省略.........
case item_type::FISH_RAW:
case item_type::EGG:
value = 2;
if (size_t(mat_type) < world->raws.creatures.all.size())
{
auto creature = world->raws.creatures.all[mat_type];
if (size_t(mat_subtype) < creature->caste.size())
{
auto caste = creature->caste[mat_subtype];
mat_type = caste->misc.bone_mat;
mat_subtype = caste->misc.bone_matidx;
}
}
break;
case item_type::VERMIN:
value = 0;
if (size_t(mat_type) < world->raws.creatures.all.size())
{
auto creature = world->raws.creatures.all[mat_type];
if (size_t(mat_subtype) < creature->caste.size())
value = creature->caste[mat_subtype]->misc.petvalue;
}
value /= 2;
if (!value)
return 1;
return value;
case item_type::PET:
if (size_t(mat_type) < world->raws.creatures.all.size())
{
auto creature = world->raws.creatures.all[mat_type];
if (size_t(mat_subtype) < creature->caste.size())
return creature->caste[mat_subtype]->misc.petvalue;
}
return 0;
case item_type::SEEDS:
case item_type::DRINK:
case item_type::POWDER_MISC:
case item_type::LIQUID_MISC:
case item_type::COIN:
case item_type::GLOB:
case item_type::ORTHOPEDIC_CAST:
value = 1;
break;
case item_type::THREAD:
value = 6;
break;
case item_type::CLOTH:
value = 7;
break;
case item_type::PANTS:
if (size_t(item_subtype) < world->raws.itemdefs.pants.size())
value = world->raws.itemdefs.pants[item_subtype]->value;
else
value = 10;
break;
case item_type::CATAPULTPARTS:
case item_type::BALLISTAPARTS:
case item_type::TRAPPARTS:
value = 30;
break;
case item_type::SIEGEAMMO:
case item_type::TRACTION_BENCH:
value = 20;
break;
case item_type::TRAPCOMP:
if (size_t(item_subtype) < world->raws.itemdefs.trapcomps.size())
value = world->raws.itemdefs.trapcomps[item_subtype]->value;
else
value = 10;
break;
case item_type::FOOD:
return 10;
// case item_type::ROCK:
default:
return 0;
case item_type::TOOL:
if (size_t(item_subtype) < world->raws.itemdefs.tools.size())
value = world->raws.itemdefs.tools[item_subtype]->value;
else
value = 10;
break;
}
MaterialInfo mat;
if (mat.decode(mat_type, mat_subtype))
value *= mat.material->material_value;
return value;
}