MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / spawnObject

Function spawnObject

Engine/source/console/simManager.cpp:408–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406}
407
408SimObject *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
445SimGroup *getRootGroup()
446{

Callers 4

sim.cppFile · 0.85
onAddMethod · 0.85
spawnObjectMethod · 0.85
spawnPlayerMethod · 0.85

Calls 8

evaluateFunction · 0.85
getVariableFunction · 0.85
errorfFunction · 0.70
findObjectFunction · 0.70
isEmptyMethod · 0.45
isNotEmptyMethod · 0.45
equalMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected