| 334 | } |
| 335 | |
| 336 | void Prefab::_loadFile( bool addFileNotify ) |
| 337 | { |
| 338 | AssertFatal( isServerObject(), "Prefab-bad" ); |
| 339 | |
| 340 | if ( mFilename == StringTable->EmptyString()) |
| 341 | return; |
| 342 | |
| 343 | if ( !Torque::FS::IsScriptFile( mFilename ) ) |
| 344 | { |
| 345 | Con::errorf( "Prefab::_loadFile() - file %s was not found.", mFilename ); |
| 346 | return; |
| 347 | } |
| 348 | |
| 349 | if ( sPrefabFileStack.contains(mFilename) ) |
| 350 | { |
| 351 | Con::errorf( |
| 352 | "Prefab::_loadFile - failed loading prefab file (%s). \n" |
| 353 | "File was referenced recursively by both a Parent and Child prefab.", mFilename ); |
| 354 | return; |
| 355 | } |
| 356 | |
| 357 | sPrefabFileStack.push_back(mFilename); |
| 358 | |
| 359 | String command = String::ToString( "exec( \"%s\" );", mFilename ); |
| 360 | Con::evaluate( command ); |
| 361 | |
| 362 | SimGroup *group; |
| 363 | if ( !Sim::findObject( Con::getVariable( "$ThisPrefab" ), group ) ) |
| 364 | { |
| 365 | Con::errorf( "Prefab::_loadFile() - file %s did not create $ThisPrefab.", mFilename ); |
| 366 | return; |
| 367 | } |
| 368 | |
| 369 | if ( addFileNotify ) |
| 370 | Torque::FS::AddChangeNotification( mFilename, this, &Prefab::_onFileChanged ); |
| 371 | |
| 372 | mChildGroup = group; |
| 373 | |
| 374 | Vector<SceneObject*> foundObjects; |
| 375 | mChildGroup->findObjectByType( foundObjects ); |
| 376 | |
| 377 | if ( !foundObjects.empty() ) |
| 378 | { |
| 379 | mWorldBox = Box3F::Invalid; |
| 380 | |
| 381 | for ( S32 i = 0; i < foundObjects.size(); i++ ) |
| 382 | { |
| 383 | SceneObject *child = foundObjects[i]; |
| 384 | mChildMap.insert( child->getId(), Transform( child->getTransform(), child->getScale() ) ); |
| 385 | smChildToPrefabMap.insert( child->getId(), getId() ); |
| 386 | |
| 387 | _updateChildTransform( child ); |
| 388 | |
| 389 | mWorldBox.intersect( child->getWorldBox() ); |
| 390 | } |
| 391 | |
| 392 | resetObjectBox(); |
| 393 | } |
nothing calls this directly
no test coverage detected