mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
add conditional filter for missionmarker autospawn
This commit is contained in:
parent
9ec752b646
commit
cbf407bc10
2 changed files with 23 additions and 1 deletions
|
|
@ -24,6 +24,7 @@
|
||||||
#include "console/consoleTypes.h"
|
#include "console/consoleTypes.h"
|
||||||
#include "core/color.h"
|
#include "core/color.h"
|
||||||
#include "console/engineAPI.h"
|
#include "console/engineAPI.h"
|
||||||
|
#include "console/script.h"
|
||||||
|
|
||||||
extern bool gEditingMission;
|
extern bool gEditingMission;
|
||||||
IMPLEMENT_CO_DATABLOCK_V1(MissionMarkerData);
|
IMPLEMENT_CO_DATABLOCK_V1(MissionMarkerData);
|
||||||
|
|
@ -350,12 +351,30 @@ SpawnSphere::SpawnSphere()
|
||||||
mSphereWeight = 100.f;
|
mSphereWeight = 100.f;
|
||||||
mIndoorWeight = 100.f;
|
mIndoorWeight = 100.f;
|
||||||
mOutdoorWeight = 100.f;
|
mOutdoorWeight = 100.f;
|
||||||
|
mSpawnIf.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_CALLBACK( SpawnSphere, onAdd, void, ( U32 objectId ), ( objectId ),
|
IMPLEMENT_CALLBACK( SpawnSphere, onAdd, void, ( U32 objectId ), ( objectId ),
|
||||||
"Called when the SpawnSphere is being created.\n"
|
"Called when the SpawnSphere is being created.\n"
|
||||||
"@param objectId The unique SimObjectId generated when SpawnSphere is created (%%this in script)\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()
|
bool SpawnSphere::onAdd()
|
||||||
{
|
{
|
||||||
if(!Parent::onAdd())
|
if(!Parent::onAdd())
|
||||||
|
|
@ -368,7 +387,7 @@ bool SpawnSphere::onAdd()
|
||||||
{
|
{
|
||||||
onAdd_callback( getId());
|
onAdd_callback( getId());
|
||||||
|
|
||||||
if (mAutoSpawn)
|
if (mAutoSpawn && testCondition())
|
||||||
spawnObject();
|
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." );
|
"Command to execute immediately after spawning an object. New object id is stored in $SpawnObject. Max 255 characters." );
|
||||||
addField( "autoSpawn", TypeBool, Offset(mAutoSpawn, SpawnSphere),
|
addField( "autoSpawn", TypeBool, Offset(mAutoSpawn, SpawnSphere),
|
||||||
"Flag to spawn object as soon as SpawnSphere is created, true to enable or false to disable." );
|
"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),
|
addField( "spawnTransform", TypeBool, Offset(mSpawnTransform, SpawnSphere),
|
||||||
"Flag to set the spawned object's transform to the SpawnSphere's transform." );
|
"Flag to set the spawned object's transform to the SpawnSphere's transform." );
|
||||||
endGroup( "Spawn" );
|
endGroup( "Spawn" );
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,8 @@ class SpawnSphere : public MissionMarker
|
||||||
F32 mSphereWeight;
|
F32 mSphereWeight;
|
||||||
F32 mIndoorWeight;
|
F32 mIndoorWeight;
|
||||||
F32 mOutdoorWeight;
|
F32 mOutdoorWeight;
|
||||||
|
String mSpawnIf;
|
||||||
|
bool testCondition();
|
||||||
|
|
||||||
SimObject* spawnObject(String additionalProps = String::EmptyString);
|
SimObject* spawnObject(String additionalProps = String::EmptyString);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue