mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
soundasset augments: get<name>Profile methods, test for emptystring, initialize asset arrays
lightning provides a conversion sample (attempt. it's still yelling)
This commit is contained in:
parent
2181ce08c3
commit
dba0899887
3 changed files with 21 additions and 22 deletions
|
|
@ -262,6 +262,12 @@ public: \
|
||||||
Resource<SFXResource> get##name##Resource() \
|
Resource<SFXResource> get##name##Resource() \
|
||||||
{\
|
{\
|
||||||
return m##name;\
|
return m##name;\
|
||||||
|
}\
|
||||||
|
SFXProfile* get##name##Profile()\
|
||||||
|
{\
|
||||||
|
if (get##name() != StringTable->EmptyString() && m##name##Asset.notNull())\
|
||||||
|
return m##name##Asset->getSfxProfile();\
|
||||||
|
return NULL;\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DECLARE_SOUNDASSET_SETGET(className, name)\
|
#define DECLARE_SOUNDASSET_SETGET(className, name)\
|
||||||
|
|
@ -436,6 +442,8 @@ public: \
|
||||||
{\
|
{\
|
||||||
m##name[index] = NULL;\
|
m##name[index] = NULL;\
|
||||||
}\
|
}\
|
||||||
|
if(get##name(index) == StringTable->EmptyString())\
|
||||||
|
return true;\
|
||||||
\
|
\
|
||||||
if (m##name##Asset[index].notNull() && m##name##Asset[index]->getStatus() != SoundAsset::Ok)\
|
if (m##name##Asset[index].notNull() && m##name##Asset[index]->getStatus() != SoundAsset::Ok)\
|
||||||
{\
|
{\
|
||||||
|
|
@ -466,6 +474,12 @@ public: \
|
||||||
if(id >= sm##name##Count || id < 0)\
|
if(id >= sm##name##Count || id < 0)\
|
||||||
return ResourceManager::get().load( "" );\
|
return ResourceManager::get().load( "" );\
|
||||||
return m##name[id];\
|
return m##name[id];\
|
||||||
|
}\
|
||||||
|
SFXProfile* get##name##Profile(const U32& id)\
|
||||||
|
{\
|
||||||
|
if (get##name(id) != StringTable->EmptyString() && m##name##Asset[id].notNull())\
|
||||||
|
return m##name##Asset[id]->getSfxProfile();\
|
||||||
|
return NULL;\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DECLARE_SOUNDASSET_ARRAY_SETGET(className, name)\
|
#define DECLARE_SOUNDASSET_ARRAY_SETGET(className, name)\
|
||||||
|
|
@ -517,6 +531,7 @@ DefineEngineMethod(className, set##name, bool, (const char* map, S32 index), , a
|
||||||
m##name##Name[index] = StringTable->EmptyString(); \
|
m##name##Name[index] = StringTable->EmptyString(); \
|
||||||
m##name##AssetId[index] = StringTable->EmptyString(); \
|
m##name##AssetId[index] = StringTable->EmptyString(); \
|
||||||
m##name##Asset[index] = NULL;\
|
m##name##Asset[index] = NULL;\
|
||||||
|
m##name[index] = NULL;\
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS
|
#ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS
|
||||||
|
|
|
||||||
|
|
@ -302,11 +302,11 @@ bool LightningData::preload(bool server, String &errorStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (U32 j = 0; j < MaxThunders; j++) {
|
for (U32 j = 0; j < MaxThunders; j++) {
|
||||||
if (!getThunderProfile(j))
|
if (!getThunderSoundProfile(j))
|
||||||
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Cant get an sfxProfile for thunder.");
|
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Cant get an sfxProfile for thunder.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!getSFXProfile())
|
if(!getStrikeSoundProfile())
|
||||||
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from asset");
|
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from asset");
|
||||||
|
|
||||||
mNumStrikeTextures = 0;
|
mNumStrikeTextures = 0;
|
||||||
|
|
@ -584,7 +584,7 @@ void Lightning::scheduleThunder(Strike* newStrike)
|
||||||
if (t <= 0.03f) {
|
if (t <= 0.03f) {
|
||||||
// If it's really close, just play it...
|
// If it's really close, just play it...
|
||||||
U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1);
|
U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1);
|
||||||
SFX->playOnce(mDataBlock->getThunderProfile(thunder));
|
SFX->playOnce(mDataBlock->getThunderSoundProfile(thunder));
|
||||||
} else {
|
} else {
|
||||||
Thunder* pThunder = new Thunder;
|
Thunder* pThunder = new Thunder;
|
||||||
pThunder->tRemaining = t;
|
pThunder->tRemaining = t;
|
||||||
|
|
@ -651,7 +651,7 @@ void Lightning::advanceTime(F32 dt)
|
||||||
|
|
||||||
// Play the sound...
|
// Play the sound...
|
||||||
U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1);
|
U32 thunder = sgLightningRand.randI(0, mDataBlock->numThunders - 1);
|
||||||
SFX->playOnce(mDataBlock->getThunderProfile(thunder));
|
SFX->playOnce(mDataBlock->getThunderSoundProfile(thunder));
|
||||||
} else {
|
} else {
|
||||||
pThunderWalker = &((*pThunderWalker)->next);
|
pThunderWalker = &((*pThunderWalker)->next);
|
||||||
}
|
}
|
||||||
|
|
@ -735,9 +735,9 @@ void Lightning::processEvent(LightningStrikeEvent* pEvent)
|
||||||
MatrixF trans(true);
|
MatrixF trans(true);
|
||||||
trans.setPosition( strikePoint );
|
trans.setPosition( strikePoint );
|
||||||
|
|
||||||
if (mDataBlock->getSFXProfile())
|
if (mDataBlock->getStrikeSoundProfile())
|
||||||
{
|
{
|
||||||
SFX->playOnce(mDataBlock->getSFXProfile(), &trans );
|
SFX->playOnce(mDataBlock->getStrikeSoundProfile(), &trans );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,22 +92,6 @@ class LightningData : public GameBaseData
|
||||||
|
|
||||||
DECLARE_CONOBJECT(LightningData);
|
DECLARE_CONOBJECT(LightningData);
|
||||||
static void initPersistFields();
|
static void initPersistFields();
|
||||||
|
|
||||||
SFXProfile* getThunderProfile(U32 id)
|
|
||||||
{
|
|
||||||
if (mThunderSoundAsset[id] != NULL)
|
|
||||||
return mThunderSoundAsset[id]->getSfxProfile();
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SFXProfile* getSFXProfile() {
|
|
||||||
if (mStrikeSoundAsset.notNull())
|
|
||||||
return mStrikeSoundAsset->getSfxProfile();
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue