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

Function spawnObject

Engine/source/console/simManager.cpp:399–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399SimObject *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
436SimGroup *getRootGroup()
437{

Callers 9

GameConnectionFunction · 0.85
spawn.csFile · 0.85
gameCore.csFile · 0.85
GameConnectionFunction · 0.85
spawn.csFile · 0.85
sim.cppFile · 0.85
onAddMethod · 0.85
spawnObjectMethod · 0.85
spawnPlayerMethod · 0.85

Calls 8

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

Tested by

no test coverage detected