More scripting functions to control particles
This commit is contained in:
parent
eda00e12f9
commit
1ceb05c2cb
@ -195,13 +195,18 @@ namespace Scripting
|
||||
* @{
|
||||
*/
|
||||
|
||||
// TODO: adjust all signatures to type "void*" parameters if possible
|
||||
/** Stop particle emission */
|
||||
void stop(/** \cond DOXYGEN_IGNORE */ void *memory /** \endcond */)
|
||||
{
|
||||
((TrackObjectPresentationParticles*)memory)->stop();
|
||||
}
|
||||
|
||||
/** Stop particle emission */
|
||||
void stopIn(float delay, /** \cond DOXYGEN_IGNORE */ void *memory /** \endcond */)
|
||||
{
|
||||
((TrackObjectPresentationParticles*)memory)->stopIn(delay);
|
||||
}
|
||||
|
||||
/** Play the specified sound once */
|
||||
void setEmissionRate(float rate /** \cond DOXYGEN_IGNORE */, void *memory /** \endcond */)
|
||||
{
|
||||
@ -259,6 +264,7 @@ namespace Scripting
|
||||
|
||||
// Particle Emitter
|
||||
r = engine->RegisterObjectMethod("ParticleEmitter", "void stop()", asFUNCTION(ParticleEmitter::stop), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ParticleEmitter", "void stopIn(float)", asFUNCTION(ParticleEmitter::stopIn), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ParticleEmitter", "void setEmissionRate(float)", asFUNCTION(ParticleEmitter::setEmissionRate), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
|
||||
// Sound Effect
|
||||
|
@ -787,6 +787,9 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles(
|
||||
bool auto_emit = true;
|
||||
xml_node.get("auto_emit", &auto_emit);
|
||||
|
||||
m_delayed_stop = false;
|
||||
m_delayed_stop_time = 0.0;
|
||||
|
||||
try
|
||||
{
|
||||
ParticleKind* kind = ParticleKindManager::get()->getParticles(path);
|
||||
@ -846,6 +849,16 @@ void TrackObjectPresentationParticles::update(float dt)
|
||||
{
|
||||
m_emitter->update(dt);
|
||||
}
|
||||
|
||||
if (m_delayed_stop)
|
||||
{
|
||||
if (m_delayed_stop_time < 0.0f)
|
||||
{
|
||||
m_delayed_stop = false;
|
||||
stop();
|
||||
}
|
||||
m_delayed_stop_time -= dt;
|
||||
}
|
||||
} // update
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -867,6 +880,12 @@ void TrackObjectPresentationParticles::stop()
|
||||
}
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
void TrackObjectPresentationParticles::stopIn(double delay)
|
||||
{
|
||||
m_delayed_stop = true;
|
||||
m_delayed_stop_time = delay;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
void TrackObjectPresentationParticles::setRate(float rate)
|
||||
{
|
||||
if (m_emitter != NULL)
|
||||
|
@ -313,6 +313,8 @@ private:
|
||||
ParticleEmitter* m_emitter;
|
||||
LODNode* m_lod_emitter_node;
|
||||
std::string m_trigger_condition;
|
||||
bool m_delayed_stop;
|
||||
double m_delayed_stop_time;
|
||||
|
||||
public:
|
||||
TrackObjectPresentationParticles(const XMLNode& xml_node,
|
||||
@ -322,6 +324,7 @@ public:
|
||||
virtual void update(float dt) OVERRIDE;
|
||||
void triggerParticles();
|
||||
void stop();
|
||||
void stopIn(double delay);
|
||||
void setRate(float rate);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the trigger condition for this object. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user