diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp
index aa86e27a9..e842f73e4 100644
--- a/Engine/source/T3D/fx/explosion.cpp
+++ b/Engine/source/T3D/fx/explosion.cpp
@@ -230,7 +230,9 @@ ExplosionData::ExplosionData()
faceViewer = false;
- soundProfile = NULL;
+ INIT_SOUNDASSET(Sound);
+
+ //soundProfile = NULL;
particleEmitter = NULL;
particleEmitterId = 0;
@@ -308,7 +310,7 @@ ExplosionData::ExplosionData(const ExplosionData& other, bool temp_clone) : Game
faceViewer = other.faceViewer;
particleDensity = other.particleDensity;
particleRadius = other.particleRadius;
- soundProfile = other.soundProfile;
+ CLONE_SOUNDASSET(Sound);
particleEmitter = other.particleEmitter;
particleEmitterId = other.particleEmitterId; // -- for pack/unpack of particleEmitter ptr
explosionScale = other.explosionScale;
@@ -358,12 +360,6 @@ ExplosionData::~ExplosionData()
if (!isTempClone())
return;
- if (soundProfile && soundProfile->isTempClone())
- {
- delete soundProfile;
- soundProfile = 0;
- }
-
// particleEmitter, emitterList[*], debrisList[*], explosionList[*] will delete themselves
#ifdef TRACK_EXPLOSION_DATA_CLONES
@@ -399,8 +395,9 @@ void ExplosionData::initPersistFields()
"of the explosion." );
addField( "playSpeed", TypeF32, Offset(playSpeed, ExplosionData),
"Time scale at which to play the explosionShape ambient 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),
"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("emitter");
onlyKeepClearSubstitutions("particleEmitter");
- onlyKeepClearSubstitutions("soundProfile");
onlyKeepClearSubstitutions("subExplosion");
Parent::initPersistFields();
}
@@ -656,7 +652,8 @@ void ExplosionData::packData(BitStream* stream)
PACKDATA_SHAPEASSET(ExplosionShape);
- sfxWrite( stream, soundProfile );
+ PACKDATA_SOUNDASSET(Sound);
+
if (stream->writeFlag(particleEmitter))
stream->writeRangedU32(particleEmitter->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
@@ -759,7 +756,7 @@ void ExplosionData::unpackData(BitStream* stream)
UNPACKDATA_SHAPEASSET(ExplosionShape);
- sfxRead( stream, &soundProfile );
+ UNPACKDATA_SOUNDASSET(Sound);
if (stream->readFlag())
particleEmitterId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
@@ -861,12 +858,13 @@ bool ExplosionData::preload(bool server, String &errorStr)
{
if (Parent::preload(server, errorStr) == false)
return false;
-
+
+ if (!server && !getSFXProfile())
+ return false;
+
if( !server )
{
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 (Sim::findObject(particleEmitterId, particleEmitter) == false)
Con::errorf(ConsoleLogEntry::General, "Error, unable to load particle emitter for explosion datablock");
@@ -1384,7 +1382,7 @@ bool Explosion::explode()
resetWorldBox();
}
- SFXProfile* sound_prof = dynamic_cast(mDataBlock->soundProfile);
+ SFXProfile* sound_prof = dynamic_cast(mDataBlock->getSFXProfile());
if (sound_prof)
{
soundProfile_clone = sound_prof->cloneAndPerformSubstitutions(ss_object, ss_index);
diff --git a/Engine/source/T3D/fx/explosion.h b/Engine/source/T3D/fx/explosion.h
index a82d28644..ae01c4bee 100644
--- a/Engine/source/T3D/fx/explosion.h
+++ b/Engine/source/T3D/fx/explosion.h
@@ -42,6 +42,7 @@
#endif
#include "T3D/assets/ShapeAsset.h"
+#include "T3D/assets/SoundAsset.h"
class ParticleEmitter;
class ParticleEmitterData;
@@ -69,7 +70,17 @@ class ExplosionData : public GameBaseData {
S32 particleDensity;
F32 particleRadius;
- SFXTrack* soundProfile;
+ //SFXTrack* soundProfile;
+ DECLARE_SOUNDASSET(ExplosionData, Sound);
+ DECLARE_SOUNDASSET_SETGET(ExplosionData, Sound);
+
+ SFXProfile* getSFXProfile() {
+ if (mSoundAsset.notNull())
+ return mSoundAsset->getSfxProfile();
+ else
+ return NULL;
+ }
+
ParticleEmitterData* particleEmitter;
S32 particleEmitterId;
diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp
index e808fb406..20925ec58 100644
--- a/Engine/source/T3D/fx/lightning.cpp
+++ b/Engine/source/T3D/fx/lightning.cpp
@@ -238,7 +238,7 @@ void LightningStrikeEvent::process(NetConnection*)
//
LightningData::LightningData()
{
- strikeSound = NULL;
+ INIT_SOUNDASSET(StrikeSound);
for (S32 i = 0; i < MaxThunders; i++)
thunderSounds[i] = NULL;
@@ -260,8 +260,9 @@ LightningData::~LightningData()
//--------------------------------------------------------------------------
void LightningData::initPersistFields()
{
- addField( "strikeSound", TYPEID< SFXTrack >(), Offset(strikeSound, LightningData),
- "Sound profile to play when a lightning strike occurs." );
+
+ INITPERSISTFIELD_SOUNDASSET(StrikeSound, LightningData, "Sound to play when lightning STRIKES!");
+
addField( "thunderSounds", TYPEID< SFXTrack >(), Offset(thunderSounds, LightningData), MaxThunders,
"@brief List of thunder sound effects to play.\n\n"
"A random one of these sounds will be played shortly after each strike "
@@ -302,8 +303,8 @@ bool LightningData::preload(bool server, String &errorStr)
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid packet: %s", sfxErrorStr.c_str());
}
- if( !sfxResolve( &strikeSound, sfxErrorStr ) )
- Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid packet: %s", sfxErrorStr.c_str());
+ if(!getSFXProfile())
+ Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from asset");
mNumStrikeTextures = 0;
for (U32 i = 0; i < MaxTextures; i++)
@@ -338,7 +339,7 @@ void LightningData::packData(BitStream* stream)
for (i = 0; i < MaxTextures; i++)
stream->writeString(strikeTextureNames[i]);
- sfxWrite( stream, strikeSound );
+ PACKDATA_SOUNDASSET(StrikeSound);
}
void LightningData::unpackData(BitStream* stream)
@@ -359,7 +360,7 @@ void LightningData::unpackData(BitStream* stream)
for (i = 0; i < MaxTextures; i++)
strikeTextureNames[i] = stream->readSTString();
- sfxRead( stream, &strikeSound );
+ UNPACKDATA_SOUNDASSET(StrikeSound);
}
@@ -735,9 +736,9 @@ void Lightning::processEvent(LightningStrikeEvent* pEvent)
MatrixF trans(true);
trans.setPosition( strikePoint );
- if (mDataBlock->strikeSound)
+ if (mDataBlock->getSFXProfile())
{
- SFX->playOnce(mDataBlock->strikeSound, &trans );
+ SFX->playOnce(mDataBlock->getSFXProfile(), &trans );
}
}
@@ -1337,4 +1338,4 @@ void LightningBolt::update( F32 dt )
isFading = false;
elapsedTime = 0.0f;
}
-}
\ No newline at end of file
+}
diff --git a/Engine/source/T3D/fx/lightning.h b/Engine/source/T3D/fx/lightning.h
index 93a54ffc7..78ef4a20b 100644
--- a/Engine/source/T3D/fx/lightning.h
+++ b/Engine/source/T3D/fx/lightning.h
@@ -41,7 +41,8 @@
#include "gfx/gfxTextureHandle.h"
-
+#include "T3D/assets/ImageAsset.h"
+#include "T3D/assets/SoundAsset.h"
class ShapeBase;
class LightningStrikeEvent;
@@ -63,7 +64,10 @@ class LightningData : public GameBaseData
//-------------------------------------- Console set variables
public:
SFXTrack* thunderSounds[MaxThunders];
- SFXTrack* strikeSound;
+
+ DECLARE_SOUNDASSET(LightningData, StrikeSound);
+ DECLARE_SOUNDASSET_SETGET(LightningData, StrikeSound);
+
StringTableEntry strikeTextureNames[MaxTextures];
//-------------------------------------- load set variables
@@ -86,6 +90,14 @@ class LightningData : public GameBaseData
DECLARE_CONOBJECT(LightningData);
static void initPersistFields();
+
+ SFXProfile* getSFXProfile() {
+ if (mStrikeSoundAsset.notNull())
+ return mStrikeSoundAsset->getSfxProfile();
+ else
+ return NULL;
+ }
+
};
diff --git a/Engine/source/T3D/fx/splash.cpp b/Engine/source/T3D/fx/splash.cpp
index c6ac5582b..6af8a0c1a 100644
--- a/Engine/source/T3D/fx/splash.cpp
+++ b/Engine/source/T3D/fx/splash.cpp
@@ -67,8 +67,10 @@ ConsoleDocClass( Splash,
//--------------------------------------------------------------------------
SplashData::SplashData()
{
- soundProfile = NULL;
- soundProfileId = 0;
+ //soundProfile = NULL;
+ //soundProfileId = 0;
+
+ INIT_SOUNDASSET(Sound);
scale.set(1, 1, 1);
@@ -112,7 +114,8 @@ SplashData::SplashData()
//--------------------------------------------------------------------------
void SplashData::initPersistFields()
{
- addField("soundProfile", TYPEID< SFXProfile >(), Offset(soundProfile, SplashData), "SFXProfile effect to play.\n");
+ INITPERSISTFIELD_SOUNDASSET(Sound, SplashData, "Sound to play when splash, splashes.");
+
addField("scale", TypePoint3F, Offset(scale, SplashData), "The scale of this splashing effect, defined as the F32 points X, Y, Z.\n");
addField("emitter", TYPEID< ParticleEmitterData >(), Offset(emitterList, SplashData), NUM_EMITTERS, "List of particle emitters to create at the point of this Splash effect.\n");
addField("delayMS", TypeS32, Offset(delayMS, SplashData), "Time to delay, in milliseconds, before actually starting this effect.\n");
@@ -158,6 +161,8 @@ void SplashData::packData(BitStream* stream)
{
Parent::packData(stream);
+ PACKDATA_SOUNDASSET(Sound);
+
mathWrite(*stream, scale);
stream->write(delayMS);
stream->write(delayVariance);
@@ -212,6 +217,8 @@ void SplashData::unpackData(BitStream* stream)
{
Parent::unpackData(stream);
+ UNPACKDATA_SOUNDASSET(Sound);
+
mathRead(*stream, &scale);
stream->read(&delayMS);
stream->read(&delayVariance);
@@ -267,6 +274,9 @@ bool SplashData::preload(bool server, String &errorStr)
if (Parent::preload(server, errorStr) == false)
return false;
+ if (!server && !getSFXProfile())
+ return false;
+
if (!server)
{
S32 i;
@@ -667,6 +677,14 @@ void Splash::spawnExplosion()
{
if( !mDataBlock->explosion ) return;
+ /// could just play the explosion one, but explosion could be weapon specific,
+ /// splash sound could be liquid specific. food for thought.
+ SFXProfile* sound_prof = dynamic_cast(mDataBlock->getSFXProfile());
+ if (sound_prof)
+ {
+ SFX->playOnce(sound_prof, &getTransform());
+ }
+
Explosion* pExplosion = new Explosion;
pExplosion->onNewDataBlock(mDataBlock->explosion, false);
diff --git a/Engine/source/T3D/fx/splash.h b/Engine/source/T3D/fx/splash.h
index f90a72d3c..40c6838fc 100644
--- a/Engine/source/T3D/fx/splash.h
+++ b/Engine/source/T3D/fx/splash.h
@@ -34,6 +34,7 @@
#include "gfx/gfxTextureHandle.h"
#include "T3D/assets/ImageAsset.h"
+#include "T3D/assets/SoundAsset.h"
class ParticleEmitter;
class ParticleEmitterData;
@@ -91,8 +92,19 @@ class SplashData : public GameBaseData
};
public:
- AudioProfile* soundProfile;
- S32 soundProfileId;
+ //AudioProfile* soundProfile;
+ //S32 soundProfileId;
+
+ DECLARE_SOUNDASSET(SplashData, Sound);
+ DECLARE_SOUNDASSET_SETGET(SplashData, Sound);
+
+ /// this should probably be added as a function higher up to stop repeats.
+ SFXProfile* getSFXProfile() {
+ if (mSoundAsset.notNull())
+ return mSoundAsset->getSfxProfile();
+ else
+ return NULL;
+ }
ParticleEmitterData* emitterList[NUM_EMITTERS];
S32 emitterIDList[NUM_EMITTERS];