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; }
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; }
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; }
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 ); } } }