|
@@ -230,7 +230,9 @@ ExplosionData::ExplosionData()
|
|
|
|
|
|
faceViewer = false;
|
|
faceViewer = false;
|
|
|
|
|
|
- soundProfile = NULL;
|
|
|
|
|
|
+ INIT_SOUNDASSET(Sound);
|
|
|
|
+
|
|
|
|
+ //soundProfile = NULL;
|
|
particleEmitter = NULL;
|
|
particleEmitter = NULL;
|
|
particleEmitterId = 0;
|
|
particleEmitterId = 0;
|
|
|
|
|
|
@@ -308,7 +310,7 @@ ExplosionData::ExplosionData(const ExplosionData& other, bool temp_clone) : Game
|
|
faceViewer = other.faceViewer;
|
|
faceViewer = other.faceViewer;
|
|
particleDensity = other.particleDensity;
|
|
particleDensity = other.particleDensity;
|
|
particleRadius = other.particleRadius;
|
|
particleRadius = other.particleRadius;
|
|
- soundProfile = other.soundProfile;
|
|
|
|
|
|
+ CLONE_SOUNDASSET(Sound);
|
|
particleEmitter = other.particleEmitter;
|
|
particleEmitter = other.particleEmitter;
|
|
particleEmitterId = other.particleEmitterId; // -- for pack/unpack of particleEmitter ptr
|
|
particleEmitterId = other.particleEmitterId; // -- for pack/unpack of particleEmitter ptr
|
|
explosionScale = other.explosionScale;
|
|
explosionScale = other.explosionScale;
|
|
@@ -358,12 +360,6 @@ ExplosionData::~ExplosionData()
|
|
if (!isTempClone())
|
|
if (!isTempClone())
|
|
return;
|
|
return;
|
|
|
|
|
|
- if (soundProfile && soundProfile->isTempClone())
|
|
|
|
- {
|
|
|
|
- delete soundProfile;
|
|
|
|
- soundProfile = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// particleEmitter, emitterList[*], debrisList[*], explosionList[*] will delete themselves
|
|
// particleEmitter, emitterList[*], debrisList[*], explosionList[*] will delete themselves
|
|
|
|
|
|
#ifdef TRACK_EXPLOSION_DATA_CLONES
|
|
#ifdef TRACK_EXPLOSION_DATA_CLONES
|
|
@@ -399,8 +395,9 @@ void ExplosionData::initPersistFields()
|
|
"of the explosion." );
|
|
"of the explosion." );
|
|
addField( "playSpeed", TypeF32, Offset(playSpeed, ExplosionData),
|
|
addField( "playSpeed", TypeF32, Offset(playSpeed, ExplosionData),
|
|
"Time scale at which to play the explosionShape <i>ambient</i> sequence." );
|
|
"Time scale at which to play the explosionShape <i>ambient</i> sequence." );
|
|
- addField( "soundProfile", TYPEID< SFXTrack >(), Offset(soundProfile, ExplosionData),
|
|
|
|
- "Non-looping sound effect that will be played at the start of the explosion." );
|
|
|
|
|
|
+
|
|
|
|
+ INITPERSISTFIELD_SOUNDASSET(Sound, ExplosionData, "Sound to play when this explosion explodes.");
|
|
|
|
+
|
|
addField( "faceViewer", TypeBool, Offset(faceViewer, ExplosionData),
|
|
addField( "faceViewer", TypeBool, Offset(faceViewer, ExplosionData),
|
|
"Controls whether the visual effects of the explosion always face the camera." );
|
|
"Controls whether the visual effects of the explosion always face the camera." );
|
|
|
|
|
|
@@ -523,7 +520,6 @@ void ExplosionData::initPersistFields()
|
|
onlyKeepClearSubstitutions("debris"); // subs resolving to "~~", or "~0" are OK
|
|
onlyKeepClearSubstitutions("debris"); // subs resolving to "~~", or "~0" are OK
|
|
onlyKeepClearSubstitutions("emitter");
|
|
onlyKeepClearSubstitutions("emitter");
|
|
onlyKeepClearSubstitutions("particleEmitter");
|
|
onlyKeepClearSubstitutions("particleEmitter");
|
|
- onlyKeepClearSubstitutions("soundProfile");
|
|
|
|
onlyKeepClearSubstitutions("subExplosion");
|
|
onlyKeepClearSubstitutions("subExplosion");
|
|
Parent::initPersistFields();
|
|
Parent::initPersistFields();
|
|
}
|
|
}
|
|
@@ -656,7 +652,8 @@ void ExplosionData::packData(BitStream* stream)
|
|
|
|
|
|
PACKDATA_SHAPEASSET(ExplosionShape);
|
|
PACKDATA_SHAPEASSET(ExplosionShape);
|
|
|
|
|
|
- sfxWrite( stream, soundProfile );
|
|
|
|
|
|
+ PACKDATA_SOUNDASSET(Sound);
|
|
|
|
+
|
|
if (stream->writeFlag(particleEmitter))
|
|
if (stream->writeFlag(particleEmitter))
|
|
stream->writeRangedU32(particleEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
|
|
stream->writeRangedU32(particleEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
|
|
|
|
|
|
@@ -759,7 +756,7 @@ void ExplosionData::unpackData(BitStream* stream)
|
|
|
|
|
|
UNPACKDATA_SHAPEASSET(ExplosionShape);
|
|
UNPACKDATA_SHAPEASSET(ExplosionShape);
|
|
|
|
|
|
- sfxRead( stream, &soundProfile );
|
|
|
|
|
|
+ UNPACKDATA_SOUNDASSET(Sound);
|
|
|
|
|
|
if (stream->readFlag())
|
|
if (stream->readFlag())
|
|
particleEmitterId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
|
particleEmitterId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
|
@@ -861,12 +858,13 @@ bool ExplosionData::preload(bool server, String &errorStr)
|
|
{
|
|
{
|
|
if (Parent::preload(server, errorStr) == false)
|
|
if (Parent::preload(server, errorStr) == false)
|
|
return false;
|
|
return false;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ if (!server && !getSFXProfile())
|
|
|
|
+ return false;
|
|
|
|
+
|
|
if( !server )
|
|
if( !server )
|
|
{
|
|
{
|
|
String sfxErrorStr;
|
|
String sfxErrorStr;
|
|
- if( !sfxResolve( &soundProfile, sfxErrorStr ) )
|
|
|
|
- Con::errorf(ConsoleLogEntry::General, "Error, unable to load sound profile for explosion datablock: %s", sfxErrorStr.c_str());
|
|
|
|
if (!particleEmitter && particleEmitterId != 0)
|
|
if (!particleEmitter && particleEmitterId != 0)
|
|
if (Sim::findObject(particleEmitterId, particleEmitter) == false)
|
|
if (Sim::findObject(particleEmitterId, particleEmitter) == false)
|
|
Con::errorf(ConsoleLogEntry::General, "Error, unable to load particle emitter for explosion datablock");
|
|
Con::errorf(ConsoleLogEntry::General, "Error, unable to load particle emitter for explosion datablock");
|
|
@@ -1384,7 +1382,7 @@ bool Explosion::explode()
|
|
resetWorldBox();
|
|
resetWorldBox();
|
|
}
|
|
}
|
|
|
|
|
|
- SFXProfile* sound_prof = dynamic_cast<SFXProfile*>(mDataBlock->soundProfile);
|
|
|
|
|
|
+ SFXProfile* sound_prof = dynamic_cast<SFXProfile*>(mDataBlock->getSFXProfile());
|
|
if (sound_prof)
|
|
if (sound_prof)
|
|
{
|
|
{
|
|
soundProfile_clone = sound_prof->cloneAndPerformSubstitutions(ss_object, ss_index);
|
|
soundProfile_clone = sound_prof->cloneAndPerformSubstitutions(ss_object, ss_index);
|