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