コード例 #1
0
   S32 script_simobject_find(const char* classname, const char* name)
   {
      SimObject *object;
      if( Sim::findObject( name, object ) )
      {
         // if we specified a classname do type checking
         if (classname && dStrlen(classname))
         {
            AbstractClassRep* ocr = object->getClassRep();
            while (ocr)
            {
               if (!dStricmp(ocr->getClassName(), classname))
                  return object->getId();
               ocr = ocr->getParentClass();
            }

         }

         // invalid type
         return 0;
      }

      // didn't find object
      return 0;
   }
コード例 #2
0
ファイル: field.cpp プロジェクト: souxiaosou/OmniEngine.Net
void GuiInspectorField::resetData()
{
   if( !mField )
      return;
      
   SimObject* inspectObject = getInspector()->getInspectObject();
   
   SimObject* tempObject = static_cast< SimObject* >( inspectObject->getClassRep()->create() );
   setData( tempObject->getDataField( mField->pFieldname, mFieldArrayIndex ) );
   delete tempObject;
}
コード例 #3
0
ファイル: group.cpp プロジェクト: AlkexGas/Torque3D
AbstractClassRep* GuiInspectorGroup::findCommonAncestorClass()
{
   AbstractClassRep* classRep = getInspector()->getInspectObject( 0 )->getClassRep();
   const U32 numInspectObjects = getInspector()->getNumInspectObjects();
   
   for( U32 i = 1; i < numInspectObjects; ++ i )
   {
      SimObject* object = getInspector()->getInspectObject( i );
      while( !object->getClassRep()->isClass( classRep ) )
      {
         classRep = classRep->getParentClass();
         AssertFatal( classRep, "GuiInspectorGroup::findcommonAncestorClass - Walked above ConsoleObject!" );
      }
   }
      
   return classRep;
}
コード例 #4
0
void TamlBinaryReader::parseChildren( Stream& stream, TamlCallbacks* pCallbacks, SimObject* pSimObject, const U32 versionId )
{
    // Debug Profiling.
    PROFILE_SCOPE(TamlBinaryReader_ParseChildren);

    // Sanity!
    AssertFatal( pSimObject != NULL, "Taml: Cannot parse children on a NULL object." );

    // Fetch children count.
    U32 childrenCount;
    stream.read( &childrenCount );

    // Finish if no children.
    if ( childrenCount == 0 )
        return;

    // Fetch the Taml children.
    TamlChildren* pChildren = dynamic_cast<TamlChildren*>( pSimObject );

    // Is this a sim set?
    if ( pChildren == NULL )
    {
        // No, so warn.
        Con::warnf("Taml: Child element found under parent but object cannot have children." );
        return;
    }

    // Fetch any container child class specifier.
    AbstractClassRep* pContainerChildClass = pSimObject->getClassRep()->getContainerChildClass( true );

    // Iterate children.
    for ( U32 index = 0; index < childrenCount; ++ index )
    {
        // Parse child element.
        SimObject* pChildSimObject = parseElement( stream, versionId );

        // Finish if child failed.
        if ( pChildSimObject == NULL )
            return;

        // Do we have a container child class?
        if ( pContainerChildClass != NULL )
        {
            // Yes, so is the child object the correctly derived type?
            if ( !pChildSimObject->getClassRep()->isClass( pContainerChildClass ) )
            {
                // No, so warn.
                Con::warnf("Taml: Child element '%s' found under parent '%s' but object is restricted to children of type '%s'.",
                    pChildSimObject->getClassName(),
                    pSimObject->getClassName(),
                    pContainerChildClass->getClassName() );

                // NOTE: We can't delete the object as it may be referenced elsewhere!
                pChildSimObject = NULL;

                // Skip.
                continue;
            }
        }

        // Add child.
        pChildren->addTamlChild( pChildSimObject );

        // Find Taml callbacks for child.
        TamlCallbacks* pChildCallbacks = dynamic_cast<TamlCallbacks*>( pChildSimObject );

        // Do we have callbacks on the child?
        if ( pChildCallbacks != NULL )
        {
            // Yes, so perform callback.
            mpTaml->tamlAddParent( pChildCallbacks, pSimObject );
        }
    }
}