//----------------------------------------------------------- // Function name: SimComponent::handlesConsoleMethod // Summary: //----------------------------------------------------------- bool DynamicConsoleMethodComponent::handlesConsoleMethod( const char *fname, S32 *routingId ) { // CodeReview: Host object is now given priority over components for method // redirection. [6/23/2007 Pat] // On this object? if( isMethod( fname ) ) { *routingId = -1; // -1 denotes method on object return true; } // on this objects components? S32 nI = 0; VectorPtr<SimComponent*> &componentList = lockComponentList(); for( SimComponentIterator nItr = componentList.begin(); nItr != componentList.end(); nItr++, nI++ ) { SimObject *pComponent = dynamic_cast<SimObject*>(*nItr); if( pComponent != NULL && pComponent->isMethod( fname ) ) { *routingId = -2; // -2 denotes method on component unlockComponentList(); return true; } } unlockComponentList(); return false; }
void SimSet::callOnChildren( const String &method, S32 argc, ConsoleValueRef argv[], bool executeOnChildGroups ) { // Prep the arguments for the console exec... // Make sure and leave args[1] empty. ConsoleValueRef args[21]; args[0] = method.c_str(); for (S32 i = 0; i < argc; i++) args[i + 2] = argv[i]; for( iterator i = begin(); i != end(); i++ ) { SimObject *childObj = static_cast<SimObject*>(*i); if( childObj->isMethod( method.c_str() ) ) Con::execute(childObj, argc + 2, args); if( executeOnChildGroups ) { SimSet* childSet = dynamic_cast<SimSet*>(*i); if ( childSet ) childSet->callOnChildren( method, argc, argv, executeOnChildGroups ); } } }