Пример #1
0
scene::INodePtr Doom3EntityCreator::createEntity(const IEntityClassPtr& eclass) {
    scene::INodePtr node = getEntityForEClass(eclass);
    Entity* entity = Node_getEntity(node);
    assert(entity != NULL);

    entity->setKeyValue("classname", eclass->getName());

    // If this is not a worldspawn or unrecognised entity, generate a unique
    // name for it
    const std::string& eclassName = eclass->getName();

    if (!eclassName.empty() &&
            eclassName != "worldspawn" &&
            eclassName != "UNKNOWN_CLASS")
    {
        /* Clean up the name of the entity that is about the created
         * so that nothing bad can happen (for example, the colon character
         * seems to be causing problems in Doom 3 Scripting)
         */
        std::string entityName =
            boost::algorithm::replace_all_copy(eclassName, ":", "_") + "_1";

        entity->setKeyValue("name", entityName);
    }

    return node;
}
Пример #2
0
	void visit(const IEntityClassPtr& eclass)
	{
		if (boost::algorithm::starts_with(eclass->getName(), _prefix))
		{
			// We have a match, store the eclassptr
			_map[eclass->getName()] = eclass;
		}
	}
Пример #3
0
std::string EClassTreeBuilder::getInheritancePathRecursive(const IEntityClassPtr& eclass) {
	std::string returnValue;
	
	try {
		EntityClassAttribute attribute = eclass->getAttribute(INHERIT_KEY);
		
		// Don't use empty or derived "inherit" keys
		if (!attribute.value.empty() && !attribute.inherited) {
			
			// Get the inherited eclass first and resolve the path
			IEntityClassPtr parent = GlobalEntityClassManager().findClass(
				attribute.value
			);
			
			if (parent != NULL) {
				returnValue += getInheritancePathRecursive(parent);
			}
			else {
				globalErrorStream() << "EClassTreeBuilder: Cannot resolve inheritance path for " 
					<< eclass->getName() << std::endl;
			}
			
			returnValue += attribute.value + "/";
		}
	}
	catch (std::runtime_error&) {
		// no inherit key
	}
	
	return returnValue;
}
// Required visit function
void EntityClassTreePopulator::visit(const IEntityClassPtr& eclass)
{
	std::string folderPath = eclass->getAttribute(_folderKey).getValue();

    if (!folderPath.empty())
	{
        folderPath = "/" + folderPath;
	}

	// Create the folder to put this EntityClass in, depending on the value
	// of the DISPLAY_FOLDER_KEY.
    addPath(eclass->getModName() + folderPath + "/" + eclass->getName());
}
Пример #5
0
scene::INodePtr Doom3EntityCreator::getEntityForEClass(const IEntityClassPtr& eclass) {

    // Null entityclass check
    if (!eclass) {
        throw std::runtime_error(
            _("Doom3EntityCreator::getEntityForEClass(): "
              "cannot create entity for NULL entityclass.")
        );
    }

    // Otherwise create the correct entity subclass based on the entity class
    // parameters.
    scene::INodePtr returnValue;

    if (eclass->isLight()) {
        LightNodePtr node(new LightNode(eclass));
        node->construct();

        returnValue = node;
    }
    else if (!eclass->isFixedSize()) {
        // Variable size entity
        Doom3GroupNodePtr node(new Doom3GroupNode(eclass));
        node->construct();

        returnValue = node;
    }
    else if (!eclass->getAttribute("model").value.empty()) {
        // Fixed size, has model path
        EclassModelNodePtr node(new EclassModelNode(eclass));
        node->construct();

        returnValue = node;
    }
    else if (eclass->getName() == "speaker") {
        SpeakerNodePtr node(new SpeakerNode(eclass));
        node->construct();

        returnValue = node;
    }
    else {
        // Fixed size, no model path
        GenericEntityNodePtr node(new GenericEntityNode(eclass));
        node->construct();

        returnValue = node;
    }

    return returnValue;
}
	void visit(const IEntityClassPtr& eclass)
	{
		if (boost::algorithm::starts_with(eclass->getName(), _prefix))
		{
			// We have a match, create a new structure
			ConversationCommandInfoPtr commandInfo(new ConversationCommandInfo);

			// Fill the values from the found entityDef
			commandInfo->parseFromEntityClass(eclass);

			// Store the structure to the target map
			_map[commandInfo->name] = commandInfo;
		}
	}
Пример #7
0
void EClassTreeBuilder::visit(IEntityClassPtr eclass) {
	std::string fullPath;
	
	// Prefix mod name
	fullPath = eclass->getModName() + "/";
	
	// Prefix inheritance path (recursively)
	fullPath += getInheritancePathRecursive(eclass);
	
	// The entityDef name itself
	fullPath += eclass->getName();
	
	// Let the VFSTreePopulator do the insertion
	_treePopulator.addPath(fullPath);
}
Пример #8
0
// Required visit function
void EntityClassTreePopulator::visit(IEntityClassPtr e) {
    // Recursively create the folder to put this EntityClass in,
    // depending on the value of the DISPLAY_FOLDER_KEY. This may return
    // NULL if the key is unset, in which case we add the entity at
    // the top level.
    GtkTreeIter* parIter = addDisplayFolder(e);
    
    // Add the new class under the parent folder
    GtkTreeIter iter;
    gtk_tree_store_append(_store, &iter, parIter);
    gtk_tree_store_set(_store, &iter, 
                       NAME_COLUMN, e->getName().c_str(), 
                       ICON_COLUMN, GlobalUIManager().getLocalPixbuf(ENTITY_ICON),
                       DIR_FLAG_COLUMN, FALSE,
                       -1);
}