Beispiel #1
0
void EntityClass_resolveInheritance( EntityClass* derivedClass ){
	if ( derivedClass->inheritanceResolved == false ) {
		derivedClass->inheritanceResolved = true;
		EntityClasses::iterator i = g_EntityClassDoom3_classes.find( derivedClass->m_parent.front().c_str() );
		if ( i == g_EntityClassDoom3_classes.end() ) {
			globalErrorStream() << "failed to find entityDef " << makeQuoted( derivedClass->m_parent.front().c_str() ) << " inherited by "  << makeQuoted( derivedClass->m_name.c_str() ) << "\n";
		}
		else
		{
			EntityClass* parentClass = ( *i ).second;
			EntityClass_resolveInheritance( parentClass );
			if ( !derivedClass->colorSpecified ) {
				derivedClass->colorSpecified = parentClass->colorSpecified;
				derivedClass->color = parentClass->color;
			}
			if ( !derivedClass->sizeSpecified ) {
				derivedClass->sizeSpecified = parentClass->sizeSpecified;
				derivedClass->mins = parentClass->mins;
				derivedClass->maxs = parentClass->maxs;
				derivedClass->fixedsize = parentClass->fixedsize;
			}

			for ( EntityClassAttributes::iterator j = parentClass->m_attributes.begin(); j != parentClass->m_attributes.end(); ++j )
			{
				EntityClass_insertAttribute( *derivedClass, ( *j ).first.c_str(), ( *j ).second );
			}
		}
	}
}
Beispiel #2
0
EntityClass* EntityClassDoom3_findOrInsert( const char *name, bool has_brushes ){
	ASSERT_NOTNULL( name );

	if ( string_empty( name ) ) {
		return g_EntityClassDoom3_bad;
	}

	EntityClasses::iterator i = g_EntityClassDoom3_classes.find( name );
	if ( i != g_EntityClassDoom3_classes.end()
	     //&& string_equal((*i).first, name)
		 ) {
		return ( *i ).second;
	}

	EntityClass* e = EntityClass_Create_Default( name, has_brushes );
	EntityClass* inserted = EntityClassDoom3_insertUnique( e );
	ASSERT_MESSAGE( inserted == e, "" );
	return inserted;
}
// Resolve inheritance for this class
void Doom3EntityClass::resolveInheritance(EntityClasses& classmap)
{
    // If we have already resolved inheritance, do nothing
    if (_inheritanceResolved)
        return;

    // Lookup the parent name and return if it is not set. Also return if the
    // parent name is the same as our own classname, to avoid infinite
    // recursion.
    std::string parName = getAttribute("inherit").getValue();
    if (parName.empty() || parName == _name)
        return;

    // Find the parent entity class
    EntityClasses::iterator pIter = classmap.find(parName);
    if (pIter != classmap.end())
    {
        // Recursively resolve inheritance of parent
        pIter->second->resolveInheritance(classmap);

        // Copy attributes from the parent to the child, including editor keys
        pIter->second->forEachClassAttribute(
            std::bind(&copyInheritedAttribute, this, std::placeholders::_1), true
        );

        // Set our parent pointer
        _parent = pIter->second.get();
    }
    else
    {
        rWarning() << "[eclassmgr] Entity class "
                              << _name << " specifies unknown parent class "
                              << parName << std::endl;
    }

    // Set the resolved flag
    _inheritanceResolved = true;

    if (!getAttribute("model").getValue().empty())
    {
        // We have a model path (probably an inherited one)
        setModelPath(getAttribute("model").getValue());
    }

    if (getAttribute("editor_light").getValue() == "1" || getAttribute("spawnclass").getValue() == "idLight")
    {
        // We have a light
        setIsLight(true);
    }

    if (getAttribute("editor_transparent").getValue() == "1")
    {
        _colourTransparent = true;
    }

    // (Re)set the colour
    const EntityClassAttribute& colourAttr = getAttribute("editor_color");

    if (!colourAttr.getValue().empty())
    {
        setColour(string::convert<Vector3>(colourAttr.getValue()));
    }
    else
    {
        // If no colour is set, assign the default entity colour to this class
        static Vector3 defaultColour = ColourSchemes().getColour("default_entity");
        setColour(defaultColour);
    }
}
Beispiel #4
0
// Resolve inheritance for this class
void Doom3EntityClass::resolveInheritance(EntityClasses& classmap)
{
	// If we have already resolved inheritance, do nothing
	if (_inheritanceResolved)
		return;
		
	// Lookup the parent name and return if it is not set. Also return if the
	// parent name is the same as our own classname, to avoid infinite
	// recursion.
	std::string parName = getAttribute("inherit").value;
	if (parName.empty() || parName == _name)
		return;

	// Find the parent entity class
	EntityClasses::iterator pIter = classmap.find(parName);
	if (pIter != classmap.end())
	{
		// Recursively resolve inheritance of parent
		pIter->second->resolveInheritance(classmap);

		// Copy attributes from the parent to the child, including editor keys
		AttributeCopyingVisitor visitor(*this);
		pIter->second->forEachClassAttribute(visitor, true);
	}
	else {
		globalWarningStream() << "[eclassmgr] Entity class "
				  << _name << " specifies parent "
				  << parName << " which is not found." << std::endl;
	} 

	// Set the resolved flag
	_inheritanceResolved = true;

	// Construct the inheritance list
	buildInheritanceChain();

	if (getAttribute("model").value != "") {
		// We have a model path (probably an inherited one)
		setModelPath(getAttribute("model").value);
	}

	if (getAttribute("editor_light").value == "1" || getAttribute("spawnclass").value == "idLight") {
		// We have a light
		setIsLight(true);
	}

	if (getAttribute("editor_transparent").value == "1")
	{
		_colourTransparent = true;
	}

	// (Re)set the colour
	const EntityClassAttribute& colourAttr = getAttribute("editor_color");

	if (!colourAttr.value.empty())
	{
		setColour(Vector3(colourAttr.value));
	}

	// Update the colour shader
	captureColour();
}