From 2a8f8c15f36a309eeb1bcdc7842881645d804bde Mon Sep 17 00:00:00 2001 From: Areloch Date: Sat, 18 Sep 2021 02:46:15 -0500 Subject: [PATCH] Shifted long-form check/fetch of sound asset's SFXProfile to a convenience function Fixed formatting on projectImporter.tscript file --- Engine/source/T3D/fx/precipitation.cpp | 8 +++--- Engine/source/T3D/fx/precipitation.h | 7 +++++ .../scripts/projectImporter.tscript | 26 +++++++++---------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Engine/source/T3D/fx/precipitation.cpp b/Engine/source/T3D/fx/precipitation.cpp index 91249fe2b..4356cd45f 100644 --- a/Engine/source/T3D/fx/precipitation.cpp +++ b/Engine/source/T3D/fx/precipitation.cpp @@ -189,7 +189,7 @@ bool PrecipitationData::preload( bool server, String &errorStr ) if( Parent::preload( server, errorStr) == false) return false; - if (!server && (mSoundAsset.isNull() || !mSoundAsset->getSfxProfile())) + if (!server && !getSFXProfile()) return false; return true; @@ -200,7 +200,6 @@ void PrecipitationData::packData(BitStream* stream) Parent::packData(stream); PACKDATA_SOUNDASSET(Sound); - //sfxWrite( stream, soundProfile ); PACKDATA_IMAGEASSET(Drop); @@ -218,7 +217,6 @@ void PrecipitationData::unpackData(BitStream* stream) Parent::unpackData(stream); UNPACKDATA_SOUNDASSET(Sound); - //sfxRead( stream, &soundProfile ); UNPACKDATA_IMAGEASSET(Drop); @@ -599,9 +597,9 @@ bool Precipitation::onNewDataBlock( GameBaseData *dptr, bool reload ) { SFX_DELETE( mAmbientSound ); - if ( mDataBlock->mSoundAsset && mDataBlock->mSoundAsset->getSfxProfile() ) + if ( mDataBlock->getSFXProfile()) { - mAmbientSound = SFX->createSource(mDataBlock->mSoundAsset->getSfxProfile(), &getTransform() ); + mAmbientSound = SFX->createSource(mDataBlock->getSFXProfile(), &getTransform() ); if ( mAmbientSound ) mAmbientSound->play(); } diff --git a/Engine/source/T3D/fx/precipitation.h b/Engine/source/T3D/fx/precipitation.h index 0bb06e0f2..cdef0c2a8 100644 --- a/Engine/source/T3D/fx/precipitation.h +++ b/Engine/source/T3D/fx/precipitation.h @@ -72,6 +72,13 @@ class PrecipitationData : public GameBaseData void onDropChanged() {} void onSplashChanged() {} + + SFXProfile* getSFXProfile() { + if (mSoundAsset.notNull()) + return mSoundAsset->getSfxProfile(); + else + return NULL; + } }; struct Raindrop diff --git a/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript b/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript index 073a7a6bf..039a71238 100644 --- a/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript +++ b/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript @@ -556,7 +556,7 @@ function processLegacyField(%line, %originalFieldName, %newFieldName) %targetFilename = sanitizeFilename(%value); if(isObject(%targetFilename)) - { + { if(%originalFieldName $= "soundProfile") { $ProjectImporter::assetQuery.clear(); @@ -568,14 +568,14 @@ function processLegacyField(%line, %originalFieldName, %newFieldName) } else { - //likely a material name, so handle it that way - %assetId = MaterialAsset::getAssetIdByMaterialName(%targetFilename); - } + //likely a material name, so handle it that way + %assetId = MaterialAsset::getAssetIdByMaterialName(%targetFilename); + } } else { if(!isFile(%targetFilename)) - { + { if(%originalFieldName $= "soundProfile") { $ProjectImporter::assetQuery.clear(); @@ -587,17 +587,17 @@ function processLegacyField(%line, %originalFieldName, %newFieldName) } else { - error("Legacy Project Importer - file described in line could not be found/is not valid"); - return %line; - } + error("Legacy Project Importer - file described in line could not be found/is not valid"); + return %line; + } } else { - $ProjectImporter::assetQuery.clear(); - %foundAssets = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %targetFilename); - if(%foundAssets != 0) - { - %assetId = $ProjectImporter::assetQuery.getAsset(0); + $ProjectImporter::assetQuery.clear(); + %foundAssets = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %targetFilename); + if(%foundAssets != 0) + { + %assetId = $ProjectImporter::assetQuery.getAsset(0); } } }