|
|
@@ -24,6 +24,7 @@
|
|
|
#include "console/consoleTypes.h"
|
|
|
#include "core/color.h"
|
|
|
#include "console/engineAPI.h"
|
|
|
+#include "console/script.h"
|
|
|
|
|
|
extern bool gEditingMission;
|
|
|
IMPLEMENT_CO_DATABLOCK_V1(MissionMarkerData);
|
|
|
@@ -350,12 +351,30 @@ SpawnSphere::SpawnSphere()
|
|
|
mSphereWeight = 100.f;
|
|
|
mIndoorWeight = 100.f;
|
|
|
mOutdoorWeight = 100.f;
|
|
|
+ mSpawnIf.clear();
|
|
|
}
|
|
|
|
|
|
IMPLEMENT_CALLBACK( SpawnSphere, onAdd, void, ( U32 objectId ), ( objectId ),
|
|
|
"Called when the SpawnSphere is being created.\n"
|
|
|
"@param objectId The unique SimObjectId generated when SpawnSphere is created (%%this in script)\n" );
|
|
|
|
|
|
+bool SpawnSphere::testCondition()
|
|
|
+{
|
|
|
+ if (mSpawnIf.isEmpty())
|
|
|
+ return true; //we've got no tests to run so just do it
|
|
|
+
|
|
|
+ //test the mapper plugged in condition line
|
|
|
+ String resVar = getIdString() + String(".result");
|
|
|
+ Con::setBoolVariable(resVar.c_str(), false);
|
|
|
+ String command = resVar + "=" + mSpawnIf + ";";
|
|
|
+ Con::evaluatef(command.c_str());
|
|
|
+ if (Con::getBoolVariable(resVar.c_str()) == 1)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
bool SpawnSphere::onAdd()
|
|
|
{
|
|
|
if(!Parent::onAdd())
|
|
|
@@ -368,7 +387,7 @@ bool SpawnSphere::onAdd()
|
|
|
{
|
|
|
onAdd_callback( getId());
|
|
|
|
|
|
- if (mAutoSpawn)
|
|
|
+ if (mAutoSpawn && testCondition())
|
|
|
spawnObject();
|
|
|
}
|
|
|
|
|
|
@@ -484,6 +503,7 @@ void SpawnSphere::initPersistFields()
|
|
|
"Command to execute immediately after spawning an object. New object id is stored in $SpawnObject. Max 255 characters." );
|
|
|
addField( "autoSpawn", TypeBool, Offset(mAutoSpawn, SpawnSphere),
|
|
|
"Flag to spawn object as soon as SpawnSphere is created, true to enable or false to disable." );
|
|
|
+ addField("spawnIf", TypeRealString, Offset(mSpawnIf, SpawnSphere), "evaluation condition to spawn (true/false)");
|
|
|
addField( "spawnTransform", TypeBool, Offset(mSpawnTransform, SpawnSphere),
|
|
|
"Flag to set the spawned object's transform to the SpawnSphere's transform." );
|
|
|
endGroup( "Spawn" );
|