本文整理汇总了C++中ContentFeatures类的典型用法代码示例。如果您正苦于以下问题:C++ ContentFeatures类的具体用法?C++ ContentFeatures怎么用?C++ ContentFeatures使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContentFeatures类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deSerialize
void deSerialize(std::istream &is)
{
clear();
int version = readU8(is);
if(version != 1)
throw SerializationError("unsupported NodeDefinitionManager version");
u16 count = readU16(is);
std::istringstream is2(deSerializeLongString(is), std::ios::binary);
for(u16 n=0; n<count; n++){
u16 i = readU16(is2);
if(i > MAX_CONTENT){
errorstream<<"ContentFeatures::deSerialize(): "
<<"Too large content id: "<<i<<std::endl;
continue;
}
/*// Do not deserialize special types
if(i == CONTENT_IGNORE || i == CONTENT_AIR)
continue;*/
ContentFeatures *f = &m_content_features[i];
// Read it from the string wrapper
std::string wrapper = deSerializeString(is2);
std::istringstream wrapper_is(wrapper, std::ios::binary);
f->deSerialize(wrapper_is);
verbosestream<<"deserialized "<<f->name<<std::endl;
if(f->name != "")
addNameIdMapping(i, f->name);
}
}
示例2: serialize
void serialize(std::ostream &os, u16 protocol_version)
{
writeU8(os, 1); // version
u16 count = 0;
std::ostringstream os2(std::ios::binary);
for(u32 i=0; i<m_content_features.size(); i++)
{
if(i == CONTENT_IGNORE || i == CONTENT_AIR
|| i == CONTENT_UNKNOWN)
continue;
ContentFeatures *f = &m_content_features[i];
if(f->name == "")
continue;
writeU16(os2, i);
// Wrap it in a string to allow different lengths without
// strict version incompatibilities
std::ostringstream wrapper_os(std::ios::binary);
f->serialize(wrapper_os, protocol_version);
os2<<serializeString(wrapper_os.str());
assert(count + 1 > count); // must not overflow
count++;
}
writeU16(os, count);
os<<serializeLongString(os2.str());
}
示例3: content_nodedef_knob
void content_nodedef_knob(content_t nodeid, content_t source_node, ContentMaterialType material_type, const char* texture, const std::wstring desc)
{
ContentFeatures *features = &content_features(nodeid);
features->description = std::wstring(desc);
features->setAllTextures(texture);
features->param_type = CPT_LIGHT;
features->param2_type = CPT_FACEDIR_WALLMOUNT;
features->draw_type = CDT_NODEBOX;
features->is_ground_content = false;
features->solidness = 0;
features->light_propagates = true;
features->dug_item = std::string("MaterialItem2 ")+itos(nodeid)+" 1";
features->type = CMT_STONE;
features->hardness = 0.8;
features->climbable = true;
features->suffocation_per_second = 0;
if (material_type == CMT_WOOD) {
content_t recipe[9] = {
CONTENT_IGNORE, CONTENT_IGNORE, CONTENT_IGNORE,
source_node , source_node , CONTENT_IGNORE,
CONTENT_IGNORE, CONTENT_IGNORE, CONTENT_IGNORE
};
crafting::setRecipe(recipe, nodeid, 2);
}else{
crafting::set1To4Recipe(source_node,nodeid);
}
content_nodebox_knob(features);
features->setInventoryTextureNodeBox(nodeid,texture,texture,texture);
lists::add("craftguide",nodeid);
lists::add("creative",nodeid);
}
示例4: void
void CNodeDefManager::updateTextures(IGameDef *gamedef,
void (*progress_callback)(void *progress_args, u32 progress, u32 max_progress),
void *progress_callback_args)
{
#ifndef SERVER
infostream << "CNodeDefManager::updateTextures(): Updating "
"textures in node definitions" << std::endl;
Client *client = (Client *)gamedef;
ITextureSource *tsrc = client->tsrc();
IShaderSource *shdsrc = client->getShaderSource();
scene::IMeshManipulator *meshmanip =
RenderingEngine::get_scene_manager()->getMeshManipulator();
TextureSettings tsettings;
tsettings.readSettings();
u32 size = m_content_features.size();
for (u32 i = 0; i < size; i++) {
ContentFeatures *f = &(m_content_features[i]);
f->updateTextures(tsrc, shdsrc, meshmanip, client, tsettings);
progress_callback(progress_callback_args, i, size);
}
#endif
}
示例5: clear
void CNodeDefManager::deSerialize(std::istream &is)
{
clear();
int version = readU8(is);
if (version != 1)
throw SerializationError("unsupported NodeDefinitionManager version");
u16 count = readU16(is);
std::istringstream is2(deSerializeLongString(is), std::ios::binary);
ContentFeatures f;
for (u16 n = 0; n < count; n++) {
u16 i = readU16(is2);
// Read it from the string wrapper
std::string wrapper = deSerializeString(is2);
std::istringstream wrapper_is(wrapper, std::ios::binary);
f.deSerialize(wrapper_is);
// Check error conditions
if (i == CONTENT_IGNORE || i == CONTENT_AIR || i == CONTENT_UNKNOWN) {
warningstream << "NodeDefManager::deSerialize(): "
"not changing builtin node " << i << std::endl;
continue;
}
if (f.name.empty()) {
warningstream << "NodeDefManager::deSerialize(): "
"received empty name" << std::endl;
continue;
}
// Ignore aliases
u16 existing_id;
if (m_name_id_mapping.getId(f.name, existing_id) && i != existing_id) {
warningstream << "NodeDefManager::deSerialize(): "
"already defined with different ID: " << f.name << std::endl;
continue;
}
// All is ok, add node definition with the requested ID
if (i >= m_content_features.size())
m_content_features.resize((u32)(i) + 1);
m_content_features[i] = f;
addNameIdMapping(i, f.name);
verbosestream << "deserialized " << f.name << std::endl;
getNodeBoxUnion(f.selection_box, f, &m_selection_box_union);
fixSelectionBoxIntUnion();
}
}
示例6: serialize
void serialize(std::ostream &os)
{
u16 count = 0;
std::ostringstream tmp_os(std::ios::binary);
for(u16 i=0; i<=MAX_CONTENT; i++)
{
if(i == CONTENT_IGNORE || i == CONTENT_AIR)
continue;
ContentFeatures *f = &m_content_features[i];
if(f->name == "")
continue;
writeU16(tmp_os, i);
f->serialize(tmp_os);
count++;
}
writeU16(os, count);
os<<serializeLongString(tmp_os.str());
}
示例7: deSerialize
void deSerialize(std::istream &is)
{
clear();
u16 count = readU16(is);
std::istringstream tmp_is(deSerializeLongString(is), std::ios::binary);
for(u16 n=0; n<count; n++){
u16 i = readU16(tmp_is);
if(i > MAX_CONTENT){
errorstream<<"ContentFeatures::deSerialize(): "
<<"Too large content id: "<<i<<std::endl;
continue;
}
/*// Do not deserialize special types
if(i == CONTENT_IGNORE || i == CONTENT_AIR)
continue;*/
ContentFeatures *f = &m_content_features[i];
f->deSerialize(tmp_is);
if(f->name != "")
addNameIdMapping(i, f->name);
}
}
示例8: serialize
void serialize(std::ostream &os)
{
writeU8(os, 1); // version
u16 count = 0;
std::ostringstream os2(std::ios::binary);
for(u16 i=0; i<=MAX_CONTENT; i++)
{
if(i == CONTENT_IGNORE || i == CONTENT_AIR)
continue;
ContentFeatures *f = &m_content_features[i];
if(f->name == "")
continue;
writeU16(os2, i);
// Wrap it in a string to allow different lengths without
// strict version incompatibilities
std::ostringstream wrapper_os(std::ios::binary);
f->serialize(wrapper_os);
os2<<serializeString(wrapper_os.str());
count++;
}
writeU16(os, count);
os<<serializeLongString(os2.str());
}
示例9: content_mapnode_init
void content_mapnode_init()
{
// Read some settings
bool new_style_water = g_settings->getBool("new_style_water");
bool new_style_leaves = g_settings->getBool("new_style_leaves");
bool invisible_stone = g_settings->getBool("invisible_stone");
bool opaque_water = g_settings->getBool("opaque_water");
content_t i;
ContentFeatures *f = NULL;
i = CONTENT_STONE;
f = &content_features(i);
f->setAllTextures("stone.png");
f->setInventoryTextureCube("stone.png", "stone.png", "stone.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->often_contains_mineral = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 1";
setStoneLikeDiggingProperties(f->digging_properties, 1.0);
if(invisible_stone)
f->solidness = 0; // For debugging, hides regular stone
i = CONTENT_GRASS;
f = &content_features(i);
f->setAllTextures("mud.png^grass_side.png");
f->setTexture(0, "grass.png");
f->setTexture(1, "mud.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_GRASS_FOOTSTEPS;
f = &content_features(i);
f->setAllTextures("mud.png^grass_side.png");
f->setTexture(0, "grass_footsteps.png");
f->setTexture(1, "mud.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_MUD;
f = &content_features(i);
f->setAllTextures("mud.png");
f->setInventoryTextureCube("mud.png", "mud.png", "mud.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_SAND;
f = &content_features(i);
f->setAllTextures("sand.png");
f->setInventoryTextureCube("sand.png", "sand.png", "sand.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_GRAVEL;
f = &content_features(i);
f->setAllTextures("gravel.png");
f->setInventoryTextureCube("gravel.png", "gravel.png", "gravel.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.75);
i = CONTENT_SANDSTONE;
f = &content_features(i);
f->setAllTextures("sandstone.png");
f->setInventoryTextureCube("sandstone.png", "sandstone.png", "sandstone.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAND)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_CLAY;
f = &content_features(i);
f->setAllTextures("clay.png");
f->setInventoryTextureCube("clay.png", "clay.png", "clay.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("CraftItem lump_of_clay 4");
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_BRICK;
f = &content_features(i);
f->setAllTextures("brick.png");
f->setInventoryTextureCube("brick.png", "brick.png", "brick.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("CraftItem clay_brick 4");
setStoneLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_TREE;
f = &content_features(i);
f->setAllTextures("tree.png");
//.........这里部分代码省略.........
示例10: content_mapnode_init
void content_mapnode_init()
{
// Read some settings
bool new_style_water = g_settings.getBool("new_style_water");
bool new_style_leaves = g_settings.getBool("new_style_leaves");
bool invisible_stone = g_settings.getBool("invisible_stone");
content_t i;
ContentFeatures *f = NULL;
i = CONTENT_STONE;
f = &content_features(i);
f->setAllTextures("stone.png");
f->setInventoryTextureCube("stone.png", "stone.png", "stone.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 1";
setStoneLikeDiggingProperties(f->digging_properties, 1.0);
if(invisible_stone)
f->solidness = 0; // For debugging, hides regular stone
i = CONTENT_GRASS;
f = &content_features(i);
f->setAllTextures("mud.png^grass_side.png");
f->setTexture(0, "grass.png");
f->setTexture(1, "mud.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_GRASS_FOOTSTEPS;
f = &content_features(i);
f->setAllTextures("mud.png^grass_side.png");
f->setTexture(0, "grass_footsteps.png");
f->setTexture(1, "mud.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_MUD;
f = &content_features(i);
f->setAllTextures("mud.png");
f->setInventoryTextureCube("mud.png", "mud.png", "mud.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_SAND;
f = &content_features(i);
f->setAllTextures("sand.png");
f->setInventoryTextureCube("sand.png", "sand.png", "sand.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_GRAVEL;
f = &content_features(i);
f->setAllTextures("gravel.png");
f->setInventoryTextureCube("gravel.png", "gravel.png", "gravel.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.75);
i = CONTENT_SANDSTONE;
f = &content_features(i);
f->setAllTextures("sandstone.png");
f->setInventoryTextureCube("sandstone.png", "sandstone.png", "sandstone.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAND)+" 1";
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_CLAY;
f = &content_features(i);
f->setAllTextures("clay.png");
f->setInventoryTextureCube("clay.png", "clay.png", "clay.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("CraftItem lump_of_clay 4");
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_BRICK;
f = &content_features(i);
f->setAllTextures("brick.png");
f->setInventoryTextureCube("brick.png", "brick.png", "brick.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("CraftItem clay_brick 4");
setStoneLikeDiggingProperties(f->digging_properties, 1.0);
i = CONTENT_TREE;
f = &content_features(i);
f->setAllTextures("tree.png");
f->setTexture(0, "tree_top.png");
f->setTexture(1, "tree_top.png");
//.........这里部分代码省略.........
示例11: content_mapnode_plants
void content_mapnode_plants(bool repeat)
{
bool new_style_leaves = g_settings->getBool("new_style_leaves");
content_t i;
ContentFeatures *f = NULL;
i = CONTENT_TREE;
f = &content_features(i);
f->description = wgettext("Tree");
f->setAllTextures("tree.png");
f->setTexture(0, "tree_top.png");
f->setTexture(1, "tree_top.png");
f->setInventoryTextureCube("tree_top.png", "tree.png", "tree.png");
f->draw_type = CDT_TRUNKLIKE;
f->is_ground_content = true;
f->flammable = 2; // can be set on fire
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->cook_result = std::string("CraftItem lump_of_charcoal 1");
f->fuel_time = 30;
f->type = CMT_TREE;
f->hardness = 1.0;
f->ondig_special_drop = CONTENT_WOOD;
f->ondig_special_drop_count = 6;
f->ondig_special_tool = TT_AXE;
lists::add("creative",i);
lists::add("cooking",i);
i = CONTENT_APPLE_TREE;
f = &content_features(i);
f->description = wgettext("Apple Tree");
f->setAllTextures("apple_tree.png");
f->setTexture(0, "apple_tree_top.png");
f->setTexture(1, "apple_tree_top.png");
f->setInventoryTextureCube("apple_tree_top.png", "apple_tree.png", "apple_tree.png");
f->draw_type = CDT_TRUNKLIKE;
f->is_ground_content = true;
f->flammable = 2; // can be set on fire
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->cook_result = std::string("CraftItem lump_of_charcoal 1");
f->fuel_time = 30;
f->type = CMT_TREE;
f->hardness = 1.0;
f->ondig_special_drop = CONTENT_WOOD;
f->ondig_special_drop_count = 6;
f->ondig_special_tool = TT_AXE;
lists::add("creative",i);
lists::add("cooking",i);
i = CONTENT_JUNGLETREE;
f = &content_features(i);
f->description = wgettext("Jungle Tree");
f->setAllTextures("jungletree.png");
f->setTexture(0, "jungletree_top.png");
f->setTexture(1, "jungletree_top.png");
f->setInventoryTextureCube("jungletree_top.png", "jungletree.png", "jungletree.png");
f->draw_type = CDT_TRUNKLIKE;
//f->is_ground_content = true;
f->flammable = 2; // can be set on fire
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->cook_result = std::string("CraftItem lump_of_charcoal 1");
f->fuel_time = 30;
f->type = CMT_TREE;
f->hardness = 1.0;
f->ondig_special_drop = CONTENT_JUNGLEWOOD;
f->ondig_special_drop_count = 6;
f->ondig_special_tool = TT_AXE;
lists::add("creative",i);
i = CONTENT_CONIFER_TREE;
f = &content_features(i);
f->description = wgettext("Conifer Tree");
f->setAllTextures("conifer_tree.png");
f->setTexture(0, "conifer_tree_top.png");
f->setTexture(1, "conifer_tree_top.png");
f->setInventoryTextureCube("conifer_tree_top.png", "conifer_tree.png", "conifer_tree.png");
f->draw_type = CDT_TRUNKLIKE;
f->is_ground_content = true;
f->flammable = 2; // can be set on fire
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->cook_result = std::string("CraftItem lump_of_charcoal 1");
f->fuel_time = 25;
f->type = CMT_TREE;
f->hardness = 0.8;
f->ondig_special_drop = CONTENT_WOOD_PINE;
f->ondig_special_drop_count = 6;
f->ondig_special_tool = TT_AXE;
lists::add("creative",i);
lists::add("cooking",i);
i = CONTENT_YOUNG_TREE;
f = &content_features(i);
f->description = wgettext("Young Tree");
f->setAllTextures("tree.png");
f->setTexture(0, "tree_top.png");
f->setTexture(1, "tree_top.png");
f->draw_type = CDT_NODEBOX;
f->solidness = 0; // drawn separately, makes no faces
f->param_type = CPT_LIGHT;
f->light_propagates = true;
//.........这里部分代码省略.........
示例12: init_mapnode
/*
See mapnode.h for description.
*/
void init_mapnode()
{
if(g_texturesource == NULL)
{
dstream<<"INFO: Initial run of init_mapnode with "
"g_texturesource=NULL. If this segfaults, "
"there is a bug with something not checking for "
"the NULL value."<<std::endl;
}
else
{
dstream<<"INFO: Full run of init_mapnode with "
"g_texturesource!=NULL"<<std::endl;
}
/*// Read some settings
bool new_style_water = g_settings.getBool("new_style_water");
bool new_style_leaves = g_settings.getBool("new_style_leaves");*/
/*
Initialize content feature table
*/
#ifndef SERVER
/*
Set initial material type to same in all tiles, so that the
same material can be used in more stuff.
This is set according to the leaves because they are the only
differing material to which all materials can be changed to
get this optimization.
*/
u8 initial_material_type = MATERIAL_ALPHA_SIMPLE;
/*if(new_style_leaves)
initial_material_type = MATERIAL_ALPHA_SIMPLE;
else
initial_material_type = MATERIAL_ALPHA_NONE;*/
for(u16 i=0; i<MAX_CONTENT+1; i++)
{
ContentFeatures *f = &g_content_features[i];
// Re-initialize
f->reset();
for(u16 j=0; j<6; j++)
f->tiles[j].material_type = initial_material_type;
}
#endif
/*
Initially set every block to be shown as an unknown block.
Don't touch CONTENT_IGNORE or CONTENT_AIR.
*/
for(u16 i=0; i<MAX_CONTENT+1; i++)
{
if(i == CONTENT_IGNORE || i == CONTENT_AIR)
continue;
ContentFeatures *f = &g_content_features[i];
f->setAllTextures("unknown_block.png");
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
}
// Make CONTENT_IGNORE to not block the view when occlusion culling
content_features(CONTENT_IGNORE).solidness = 0;
/*
Initialize mapnode content
*/
content_mapnode_init();
}