| 406 | } |
| 407 | |
| 408 | SimObject *spawnObject(String spawnClass, String spawnDataBlock, String spawnName, |
| 409 | String spawnProperties, String spawnScript) |
| 410 | { |
| 411 | if (spawnClass.isEmpty()) |
| 412 | { |
| 413 | Con::errorf("Unable to spawn an object without a spawnClass"); |
| 414 | return NULL; |
| 415 | } |
| 416 | |
| 417 | String spawnString; |
| 418 | |
| 419 | spawnString += "$SpawnObject = new " + spawnClass + "(" + spawnName + ") { "; |
| 420 | |
| 421 | if (spawnDataBlock.isNotEmpty() && !spawnDataBlock.equal( "None", String::NoCase ) ) |
| 422 | spawnString += "datablock = " + spawnDataBlock + "; "; |
| 423 | |
| 424 | if (spawnProperties.isNotEmpty()) |
| 425 | spawnString += spawnProperties + " "; |
| 426 | |
| 427 | spawnString += "};"; |
| 428 | |
| 429 | // Evaluate our spawn string |
| 430 | Con::evaluate(spawnString.c_str()); |
| 431 | |
| 432 | // Get our spawnObject id |
| 433 | const char* spawnObjectId = Con::getVariable("$SpawnObject"); |
| 434 | |
| 435 | // Get the actual spawnObject |
| 436 | SimObject* spawnObject = findObject(spawnObjectId); |
| 437 | |
| 438 | // If we have a spawn script go ahead and execute it last |
| 439 | if (spawnScript.isNotEmpty()) |
| 440 | Con::evaluate(spawnScript.c_str(), true); |
| 441 | |
| 442 | return spawnObject; |
| 443 | } |
| 444 | |
| 445 | SimGroup *getRootGroup() |
| 446 | { |
no test coverage detected