bool HoverVehicle::onNewDataBlock(GameBaseData* dptr, bool reload) { mDataBlock = dynamic_cast<HoverVehicleData*>(dptr); if (!mDataBlock || !Parent::onNewDataBlock(dptr,reload)) return false; if (isGhost()) { // Create the sounds ahead of time. This reduces runtime // costs and makes the system easier to understand. SFX_DELETE( mEngineSound ); SFX_DELETE( mFloatSound ); SFX_DELETE( mJetSound ); if ( mDataBlock->sound[HoverVehicleData::EngineSound] ) mEngineSound = SFX->createSource( mDataBlock->sound[HoverVehicleData::EngineSound], &getTransform() ); if ( !mDataBlock->sound[HoverVehicleData::FloatSound] ) mFloatSound = SFX->createSource( mDataBlock->sound[HoverVehicleData::FloatSound], &getTransform() ); if ( mDataBlock->sound[HoverVehicleData::JetSound] ) mJetSound = SFX->createSource( mDataBlock->sound[HoverVehicleData::JetSound], &getTransform() ); } // Todo: Uncomment if this is a "leaf" class scriptOnNewDataBlock(); return true; }
void FlyingVehicle::onRemove() { SFX_DELETE( mJetSound ); SFX_DELETE( mEngineSound ); scriptOnRemove(); removeFromScene(); Parent::onRemove(); }
void SFXEmitter::onRemove() { SFX_DELETE( mSource ); removeFromScene(); Parent::onRemove(); }
void TheoraTexture::_reset() { // Stop the async streams. if( mAsyncState != NULL ) mAsyncState->stop(); // Delete the playback queue. if( mPlaybackQueue ) SAFE_DELETE( mPlaybackQueue ); // Kill the sound source. if( mSFXSource != NULL ) { mSFXSource->stop(); SFX_DELETE( mSFXSource ); mSFXSource = NULL; } mLastFrameNumber = 0; mNumDroppedFrames = 0; mCurrentFrame = NULL; mAsyncState = NULL; mIsPaused = false; mPlaybackTimer.reset(); }
SFXEmitter::~SFXEmitter() { mLocalProfile._unregisterSignals(); if( mSource ) SFX_DELETE( mSource ); }
bool FlyingVehicle::onNewDataBlock(GameBaseData* dptr, bool reload) { mDataBlock = dynamic_cast<FlyingVehicleData*>(dptr); if (!mDataBlock || !Parent::onNewDataBlock(dptr,reload)) return false; // Sounds if ( isGhost() ) { // Create the sounds ahead of time. This reduces runtime // costs and makes the system easier to understand. SFX_DELETE( mJetSound ); SFX_DELETE( mEngineSound ); if ( mDataBlock->sound[FlyingVehicleData::EngineSound] ) mEngineSound = SFX->createSource( mDataBlock->sound[FlyingVehicleData::EngineSound], &getTransform() ); if ( mDataBlock->sound[FlyingVehicleData::JetSound] ) mJetSound = SFX->createSource( mDataBlock->sound[FlyingVehicleData::JetSound], &getTransform() ); } // Jet Sequences for (S32 i = 0; i < JetAnimCount; i++) { TSShape const* shape = mShapeInstance->getShape(); mJetSeq[i] = shape->findSequence(sJetSequence[i]); if (mJetSeq[i] != -1) { if (i == BackActivate || i == BottomActivate) { mJetThread[i] = mShapeInstance->addThread(); mShapeInstance->setSequence(mJetThread[i],mJetSeq[i],0); mShapeInstance->setTimeScale(mJetThread[i],0); } } else mJetThread[i] = 0; } scriptOnNewDataBlock(); return true; }
bool Projectile::onNewDataBlock( GameBaseData *dptr, bool reload ) { mDataBlock = dynamic_cast<ProjectileData*>( dptr ); if ( !mDataBlock || !Parent::onNewDataBlock( dptr, reload ) ) return false; if ( isGhost() ) { // Create the sound ahead of time. This reduces runtime // costs and makes the system easier to understand. SFX_DELETE( mSound ); if ( mDataBlock->sound ) mSound = SFX->createSource( mDataBlock->sound ); } return true; }
void Projectile::onRemove() { if( !mParticleEmitter.isNull() ) { mParticleEmitter->deleteWhenEmpty(); mParticleEmitter = NULL; } if( !mParticleWaterEmitter.isNull() ) { mParticleWaterEmitter->deleteWhenEmpty(); mParticleWaterEmitter = NULL; } SFX_DELETE( mSound ); removeFromScene(); Parent::onRemove(); }
void SFXEmitter::_update() { AssertFatal( isClientObject(), "SFXEmitter::_update() - This shouldn't happen on the server!" ); // Store the playback status so we // we can restore it. SFXStatus prevState = mSource ? mSource->getStatus() : SFXStatusNull; // Make sure all the settings are valid. mDescription.validate(); const MatrixF &transform = getTransform(); const VectorF &velocity = getVelocity(); // Did we change the source? if( mDirty.test( Profile | Filename | Is3D | IsLooping | IsStreaming | FadeInTime | FadeOutTime | Channel ) ) { SFX_DELETE( mSource ); // Do we have a profile? if( mProfile ) { mSource = SFX->createSource( mProfile, &transform, &velocity ); AssertFatal( mSource != NULL, "SFXEmitter::_update() - failed to create source!" ); // If we're supposed to play when the emitter is // added to the scene then also restart playback // when the profile changes. prevState = mPlayOnAdd ? SFXStatusPlaying : prevState; // Force an update of properties set on the local description. mDirty.set( AllDirtyMask ); } // Else take the local profile else { // Clear the resource and buffer to force a // reload if the filename changed. if( mDirty.test( Filename ) ) { mLocalProfile.mResource = NULL; mLocalProfile.mBuffer = NULL; } if( !mLocalProfile.mFilename.isEmpty() ) { mSource = SFX->createSource( &mLocalProfile, &transform, &velocity ); AssertFatal( mSource != NULL, "SFXEmitter::_update() - failed to create source!" ); prevState = mPlayOnAdd ? SFXStatusPlaying : prevState; } } mDirty.clear( Profile | Filename | Is3D | IsLooping | IsStreaming | FadeInTime | FadeOutTime | Channel ); } // Cheat if the editor is open and the looping state // is toggled on a local profile sound. It makes the // editor feel responsive and that things are working. if ( gEditingMission && !mProfile && mPlayOnAdd && mDirty.test( IsLooping ) ) prevState = SFXStatusPlaying; // The rest only applies if we have a source. if( mSource ) { // Set the volume irrespective of the profile. if( mDirty.test( Volume ) ) mSource->setVolume( mDescription.mVolume ); if( mDirty.test( Pitch ) ) mSource->setPitch( mDescription.mPitch ); // Skip these 3d only settings. if( mDescription.mIs3D ) { if( mDirty.test( Transform ) ) { mSource->setTransform( transform ); mSource->setVelocity( velocity ); } if( mDirty.test( ReferenceDistance | MaxDistance ) ) { mSource->setMinMaxDistance( mDescription.mReferenceDistance, mDescription.mMaxDistance ); } if( mDirty.test( ConeInsideAngle | ConeOutsideAngle | ConeOutsideVolume ) ) { mSource->setCone( F32( mDescription.mConeInsideAngle ), F32( mDescription.mConeOutsideAngle ), mDescription.mConeOutsideVolume ); } mDirty.clear( Transform | ReferenceDistance | MaxDistance | ConeInsideAngle | ConeOutsideAngle | ConeOutsideVolume ); } // Restore the pre-update playback state. if ( prevState == SFXStatusPlaying ) mSource->play(); mDirty.clear( Volume | Pitch | Transform ); } }