mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
parent
2bf2da74a0
commit
e16a66f363
4 changed files with 11 additions and 130 deletions
|
|
@ -110,55 +110,6 @@ ConsoleSetType(TypeSoundAssetId)
|
||||||
Con::warnf("(TypeAssetId) - Cannot set multiple args to a single asset.");
|
Con::warnf("(TypeAssetId) - Cannot set multiple args to a single asset.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// REFACTOR
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
IMPLEMENT_STRUCT(AssetPtr<SoundAsset>, AssetPtrSoundAsset, , "")
|
|
||||||
END_IMPLEMENT_STRUCT
|
|
||||||
|
|
||||||
ConsoleType(SoundAssetPtr, TypeSoundAssetPtrRefactor, AssetPtr<SoundAsset>, ASSET_ID_FIELD_PREFIX)
|
|
||||||
|
|
||||||
|
|
||||||
ConsoleGetType(TypeSoundAssetPtrRefactor)
|
|
||||||
{
|
|
||||||
// Fetch asset Id.
|
|
||||||
return (*((AssetPtr<SoundAsset>*)dptr)).getAssetId();
|
|
||||||
}
|
|
||||||
|
|
||||||
ConsoleSetType(TypeSoundAssetPtrRefactor)
|
|
||||||
{
|
|
||||||
// Was a single argument specified?
|
|
||||||
if (argc == 1)
|
|
||||||
{
|
|
||||||
// Yes, so fetch field value.
|
|
||||||
const char* pFieldValue = argv[0];
|
|
||||||
|
|
||||||
// Fetch asset pointer.
|
|
||||||
AssetPtr<SoundAsset>* pAssetPtr = dynamic_cast<AssetPtr<SoundAsset>*>((AssetPtrBase*)(dptr));
|
|
||||||
|
|
||||||
// Is the asset pointer the correct type?
|
|
||||||
if (pAssetPtr == NULL)
|
|
||||||
{
|
|
||||||
// No, so fail.
|
|
||||||
Con::warnf("(TypeSoundAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set asset.
|
|
||||||
pAssetPtr->setAssetId(pFieldValue);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Warn.
|
|
||||||
Con::warnf("(TypeSoundAssetPtr) - Cannot set multiple args to a single asset.");
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// REFACTOR END
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const String SoundAsset::mErrCodeStrings[] =
|
const String SoundAsset::mErrCodeStrings[] =
|
||||||
{
|
{
|
||||||
"BadProfile",
|
"BadProfile",
|
||||||
|
|
|
||||||
|
|
@ -180,9 +180,6 @@ protected:
|
||||||
DefineConsoleType(TypeSoundAssetPtr, SoundAsset)
|
DefineConsoleType(TypeSoundAssetPtr, SoundAsset)
|
||||||
DefineConsoleType(TypeSoundAssetId, String)
|
DefineConsoleType(TypeSoundAssetId, String)
|
||||||
|
|
||||||
DECLARE_STRUCT(AssetPtr<SoundAsset>)
|
|
||||||
DefineConsoleType(TypeSoundAssetPtrRefactor, AssetPtr<SoundAsset>)
|
|
||||||
|
|
||||||
#pragma region Singular Asset Macros
|
#pragma region Singular Asset Macros
|
||||||
|
|
||||||
//Singular assets
|
//Singular assets
|
||||||
|
|
@ -582,74 +579,5 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
#pragma region Refactor Asset Macros
|
|
||||||
|
|
||||||
#define DECLARE_SOUNDASSET_REFACTOR(className, name) \
|
|
||||||
private: \
|
|
||||||
AssetPtr<SoundAsset> m##name##Asset; \
|
|
||||||
public: \
|
|
||||||
void _set##name(StringTableEntry _in) { \
|
|
||||||
\
|
|
||||||
if (m##name##Asset.getAssetId() == _in) \
|
|
||||||
return; \
|
|
||||||
\
|
|
||||||
if (!AssetDatabase.isDeclaredAsset(_in)) \
|
|
||||||
{ \
|
|
||||||
StringTableEntry imageAssetId = StringTable->EmptyString(); \
|
|
||||||
AssetQuery query; \
|
|
||||||
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
|
||||||
if (foundAssetcount != 0) \
|
|
||||||
{ \
|
|
||||||
imageAssetId = query.mAssetList[0]; \
|
|
||||||
} \
|
|
||||||
m##name##Asset = imageAssetId; \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
m##name##Asset = _in; \
|
|
||||||
} \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
inline StringTableEntry _get##name(void) const { return m##name##Asset.getAssetId(); } \
|
|
||||||
AssetPtr<SoundAsset> get##name##Asset(void) { return m##name##Asset; } \
|
|
||||||
static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data)); return false; }
|
|
||||||
|
|
||||||
#define DECLARE_SOUNDASSET_NET_REFACTOR(className, name, profile, mask) \
|
|
||||||
private: \
|
|
||||||
AssetPtr<SoundAsset> m##name##Asset; \
|
|
||||||
public: \
|
|
||||||
void _set##name(StringTableEntry _in){ \
|
|
||||||
if(m##name##Asset.getAssetId() == _in) \
|
|
||||||
return; \
|
|
||||||
\
|
|
||||||
if(!AssetDatabase.isDeclaredAsset(_in)) \
|
|
||||||
{ \
|
|
||||||
StringTableEntry imageAssetId = StringTable->EmptyString(); \
|
|
||||||
AssetQuery query; \
|
|
||||||
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
|
||||||
if (foundAssetcount != 0) \
|
|
||||||
{ \
|
|
||||||
imageAssetId = query.mAssetList[0]; \
|
|
||||||
} \
|
|
||||||
m##name##Asset = imageAssetId; \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
m##name##Asset = _in; \
|
|
||||||
} \
|
|
||||||
setMaskBits(mask); \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
inline StringTableEntry _get##name(void) const { return m##name##Asset.getAssetId(); } \
|
|
||||||
AssetPtr<SoundAsset> get##name##Asset(void) { return m##name##Asset; } \
|
|
||||||
static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data)); return false;}
|
|
||||||
|
|
||||||
|
|
||||||
#define INITPERSISTFIELD_SSOUNDASSET_REFACTOR(name, consoleClass, docs) \
|
|
||||||
addProtectedField(assetText(name, Asset), TypeSoundAssetPtrRefactor, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.));
|
|
||||||
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
#endif // _ASSET_BASE_H_
|
#endif // _ASSET_BASE_H_
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,7 @@ U32 Projectile::smProjectileWarpTicks = 5;
|
||||||
afxMagicMissileData::afxMagicMissileData()
|
afxMagicMissileData::afxMagicMissileData()
|
||||||
{
|
{
|
||||||
INIT_ASSET(ProjectileShape);
|
INIT_ASSET(ProjectileShape);
|
||||||
|
INIT_ASSET(ProjectileSound);
|
||||||
|
|
||||||
/* From stock Projectile code...
|
/* From stock Projectile code...
|
||||||
explosion = NULL;
|
explosion = NULL;
|
||||||
|
|
@ -246,7 +247,7 @@ afxMagicMissileData::afxMagicMissileData(const afxMagicMissileData& other, bool
|
||||||
{
|
{
|
||||||
CLONE_ASSET(ProjectileShape);
|
CLONE_ASSET(ProjectileShape);
|
||||||
projectileShape = other.projectileShape; // -- TSShape loads using projectileShapeName
|
projectileShape = other.projectileShape; // -- TSShape loads using projectileShapeName
|
||||||
CLONE_ASSET_REFACTOR(ProjectileSound);
|
CLONE_ASSET(ProjectileSound);
|
||||||
splash = other.splash;
|
splash = other.splash;
|
||||||
splashId = other.splashId; // -- for pack/unpack of splash ptr
|
splashId = other.splashId; // -- for pack/unpack of splash ptr
|
||||||
lightDesc = other.lightDesc;
|
lightDesc = other.lightDesc;
|
||||||
|
|
@ -344,7 +345,7 @@ void afxMagicMissileData::initPersistFields()
|
||||||
endGroup("Particle Effects");
|
endGroup("Particle Effects");
|
||||||
|
|
||||||
addGroup("Sounds");
|
addGroup("Sounds");
|
||||||
INITPERSISTFIELD_SSOUNDASSET_REFACTOR(ProjectileSound, afxMagicMissileData, "sound for the projectile")
|
INITPERSISTFIELD_SOUNDASSET(ProjectileSound, afxMagicMissileData, "sound for the projectile");
|
||||||
endGroup("Sounds");
|
endGroup("Sounds");
|
||||||
|
|
||||||
addGroup("Light Emitter");
|
addGroup("Light Emitter");
|
||||||
|
|
@ -516,7 +517,7 @@ bool afxMagicMissileData::preload(bool server, String &errorStr)
|
||||||
Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId);
|
Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (mProjectileShapeAsset.isNull())
|
if (!isProjectileSoundValid())
|
||||||
{
|
{
|
||||||
//return false; -TODO: trigger asset download
|
//return false; -TODO: trigger asset download
|
||||||
}
|
}
|
||||||
|
|
@ -626,7 +627,7 @@ void afxMagicMissileData::packData(BitStream* stream)
|
||||||
DataBlockObjectIdLast);
|
DataBlockObjectIdLast);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PACKDATA_ASSET_REFACTOR(ProjectileSound)
|
PACKDATA_ASSET(ProjectileSound);
|
||||||
|
|
||||||
if ( stream->writeFlag(lightDesc != NULL))
|
if ( stream->writeFlag(lightDesc != NULL))
|
||||||
stream->writeRangedU32(lightDesc->getId(), DataBlockObjectIdFirst,
|
stream->writeRangedU32(lightDesc->getId(), DataBlockObjectIdFirst,
|
||||||
|
|
@ -732,7 +733,7 @@ void afxMagicMissileData::unpackData(BitStream* stream)
|
||||||
decalId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
decalId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
UNPACKDATA_ASSET_REFACTOR(ProjectileSound)
|
UNPACKDATA_ASSET(ProjectileSound);
|
||||||
|
|
||||||
if (stream->readFlag())
|
if (stream->readFlag())
|
||||||
lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
||||||
|
|
@ -1156,8 +1157,8 @@ bool afxMagicMissile::onNewDataBlock(GameBaseData* dptr, bool reload)
|
||||||
|
|
||||||
SFX_DELETE( mSound );
|
SFX_DELETE( mSound );
|
||||||
|
|
||||||
if (mDataBlock->getProjectileSoundAsset().notNull())
|
if (mDataBlock->getProjectileSound())
|
||||||
mSound = SFX->createSource(mDataBlock->getProjectileSoundAsset()->getSFXTrack());
|
mSound = SFX->createSource(mDataBlock->getProjectileSoundProfile());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1992,7 +1993,7 @@ void afxMagicMissile::get_launch_data(Point3F& pos, Point3F& vel)
|
||||||
|
|
||||||
void afxMagicMissile::updateSound()
|
void afxMagicMissile::updateSound()
|
||||||
{
|
{
|
||||||
if (mDataBlock->getProjectileSoundAsset().isNull())
|
if (!mDataBlock->isProjectileSoundValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( mSound )
|
if ( mSound )
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,8 @@ public:
|
||||||
SplashData* splash; // Water Splash Datablock
|
SplashData* splash; // Water Splash Datablock
|
||||||
S32 splashId; // Water splash ID
|
S32 splashId; // Water splash ID
|
||||||
|
|
||||||
DECLARE_SOUNDASSET_REFACTOR(afxMagicMissileData, ProjectileSound)
|
DECLARE_SOUNDASSET(afxMagicMissileData, ProjectileSound);
|
||||||
|
DECLARE_ASSET_SETGET(afxMagicMissileData, ProjectileSound);
|
||||||
|
|
||||||
LightDescription *lightDesc;
|
LightDescription *lightDesc;
|
||||||
S32 lightDescId;
|
S32 lightDescId;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue