Committing player separately.

shapeBase is its own beast and will require a very critical look over once its up.
This commit is contained in:
marauder2k7 2021-09-29 11:41:57 +01:00
parent 3d7f092c52
commit d700ea4878
2 changed files with 56 additions and 80 deletions

View file

@ -189,6 +189,31 @@ PlayerData::ActionAnimationDef PlayerData::ActionAnimationList[NumTableActionAni
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
typedef PlayerData::Sounds playerSoundsEnum;
DefineEnumType(playerSoundsEnum);
ImplementEnumType(playerSoundsEnum, "enum types.\n"
"@ingroup PlayerData\n\n")
{PlayerData::Sounds::FootSoft, "FootSoft","..." },
{PlayerData::Sounds::FootHard, "FootHard","..." },
{PlayerData::Sounds::FootMetal, "FootMetal","..." },
{PlayerData::Sounds::FootSnow, "FootSnow","..." },
{PlayerData::Sounds::FootShallowSplash, "FootShallowSplash","..." },
{PlayerData::Sounds::FootWading, "FootWading","..." },
{PlayerData::Sounds::FootUnderWater, "FootUnderWater","..." },
{PlayerData::Sounds::FootBubbles, "FootBubbles","..." },
{PlayerData::Sounds::MoveBubbles, "MoveBubbles","..." },
{PlayerData::Sounds::WaterBreath, "WaterBreath","..." },
{PlayerData::Sounds::ImpactStart, "ImpactStart","..." },
{PlayerData::Sounds::ImpactHard, "ImpactHard","..." },
{PlayerData::Sounds::ImpactMetal, "ImpactMetal","..." },
{PlayerData::Sounds::ImpactSnow, "ImpactSnow","..." },
{PlayerData::Sounds::ImpactWaterEasy, "ImpactWaterEasy","..." },
{PlayerData::Sounds::ImpactWaterMedium, "ImpactWaterMedium","..." },
{PlayerData::Sounds::ImpactWaterHard, "ImpactWaterHard","..." },
{PlayerData::Sounds::ExitWater, "ExitWater","..." },
EndImplementEnumType;
//----------------------------------------------------------------------------
IMPLEMENT_CO_DATABLOCK_V1(PlayerData);
@ -397,7 +422,7 @@ PlayerData::PlayerData()
boxHeadFrontPercentage = 1;
for (S32 i = 0; i < MaxSounds; i++)
sound[i] = NULL;
INIT_SOUNDASSET_ARRAY(PlayerSound, i);
footPuffEmitter = NULL;
footPuffID = 0;
@ -449,9 +474,13 @@ bool PlayerData::preload(bool server, String &errorStr)
{
for( U32 i = 0; i < MaxSounds; ++ i )
{
String sfxErrorStr;
if( !sfxResolve( &sound[ i ], sfxErrorStr ) )
Con::errorf( "PlayerData::preload: %s", sfxErrorStr.c_str() );
if (getPlayerSound(i) != StringTable->EmptyString())
{
_setPlayerSound(getPlayerSound(i), i);
}
if (!getPlayerSoundProfile(i))
Con::errorf("PlayerData::Preload() - unable to find sfxProfile for asset %d %s", i, getPlayerSound(i));
}
}
@ -1022,63 +1051,7 @@ void PlayerData::initPersistFields()
addGroup( "Interaction: Sounds" );
addField( "FootSoftSound", TypeSFXTrackName, Offset(sound[FootSoft], PlayerData),
"@brief Sound to play when walking on a surface with Material footstepSoundId 0.\n\n" );
addField( "FootHardSound", TypeSFXTrackName, Offset(sound[FootHard], PlayerData),
"@brief Sound to play when walking on a surface with Material footstepSoundId 1.\n\n" );
addField( "FootMetalSound", TypeSFXTrackName, Offset(sound[FootMetal], PlayerData),
"@brief Sound to play when walking on a surface with Material footstepSoundId 2.\n\n" );
addField( "FootSnowSound", TypeSFXTrackName, Offset(sound[FootSnow], PlayerData),
"@brief Sound to play when walking on a surface with Material footstepSoundId 3.\n\n" );
addField( "FootShallowSound", TypeSFXTrackName, Offset(sound[FootShallowSplash], PlayerData),
"@brief Sound to play when walking in water and coverage is less than "
"footSplashHeight.\n\n"
"@see footSplashHeight\n" );
addField( "FootWadingSound", TypeSFXTrackName, Offset(sound[FootWading], PlayerData),
"@brief Sound to play when walking in water and coverage is less than 1, "
"but > footSplashHeight.\n\n"
"@see footSplashHeight\n" );
addField( "FootUnderwaterSound", TypeSFXTrackName, Offset(sound[FootUnderWater], PlayerData),
"@brief Sound to play when walking in water and coverage equals 1.0 "
"(fully underwater).\n\n" );
addField( "FootBubblesSound", TypeSFXTrackName, Offset(sound[FootBubbles], PlayerData),
"@brief Sound to play when walking in water and coverage equals 1.0 "
"(fully underwater).\n\n" );
addField( "movingBubblesSound", TypeSFXTrackName, Offset(sound[MoveBubbles], PlayerData),
"@brief Sound to play when in water and coverage equals 1.0 (fully underwater).\n\n"
"Note that unlike FootUnderwaterSound, this sound plays even if the "
"player is not moving around in the water.\n" );
addField( "waterBreathSound", TypeSFXTrackName, Offset(sound[WaterBreath], PlayerData),
"@brief Sound to play when in water and coverage equals 1.0 (fully underwater).\n\n"
"Note that unlike FootUnderwaterSound, this sound plays even if the "
"player is not moving around in the water.\n" );
addField( "impactSoftSound", TypeSFXTrackName, Offset(sound[ImpactSoft], PlayerData),
"@brief Sound to play after falling on a surface with Material footstepSoundId 0.\n\n" );
addField( "impactHardSound", TypeSFXTrackName, Offset(sound[ImpactHard], PlayerData),
"@brief Sound to play after falling on a surface with Material footstepSoundId 1.\n\n" );
addField( "impactMetalSound", TypeSFXTrackName, Offset(sound[ImpactMetal], PlayerData),
"@brief Sound to play after falling on a surface with Material footstepSoundId 2.\n\n" );
addField( "impactSnowSound", TypeSFXTrackName, Offset(sound[ImpactSnow], PlayerData),
"@brief Sound to play after falling on a surface with Material footstepSoundId 3.\n\n" );
addField( "impactWaterEasy", TypeSFXTrackName, Offset(sound[ImpactWaterEasy], PlayerData),
"@brief Sound to play when entering the water with velocity < "
"mediumSplashSoundVelocity.\n\n"
"@see mediumSplashSoundVelocity\n");
addField( "impactWaterMedium", TypeSFXTrackName, Offset(sound[ImpactWaterMedium], PlayerData),
"@brief Sound to play when entering the water with velocity >= "
"mediumSplashSoundVelocity and < hardSplashSoundVelocity.\n\n"
"@see mediumSplashSoundVelocity\n"
"@see hardSplashSoundVelocity\n");
addField( "impactWaterHard", TypeSFXTrackName, Offset(sound[ImpactWaterHard], PlayerData),
"@brief Sound to play when entering the water with velocity >= "
"hardSplashSoundVelocity.\n\n"
"@see hardSplashSoundVelocity\n");
addField( "exitingWater", TypeSFXTrackName, Offset(sound[ExitWater], PlayerData),
"@brief Sound to play when exiting the water with velocity >= exitSplashSoundVelocity.\n\n"
"@see exitSplashSoundVelocity\n");
INITPERSISTFIELD_SOUNDASSET_ENUMED(PlayerSound, playerSoundsEnum, PlayerData::Sounds::MaxSounds, PlayerData, "Sounds related to player interaction.");
endGroup( "Interaction: Sounds" );
@ -1303,8 +1276,8 @@ void PlayerData::packData(BitStream* stream)
stream->write(minImpactSpeed);
stream->write(minLateralImpactSpeed);
for( U32 i = 0; i < MaxSounds; i++)
sfxWrite( stream, sound[ i ] );
for (U32 i = 0; i < MaxSounds; i++)
PACKDATA_SOUNDASSET_ARRAY(PlayerSound, i);
mathWrite(*stream, boxSize);
mathWrite(*stream, crouchBoxSize);
@ -1484,8 +1457,8 @@ void PlayerData::unpackData(BitStream* stream)
stream->read(&minImpactSpeed);
stream->read(&minLateralImpactSpeed);
for( U32 i = 0; i < MaxSounds; i++)
sfxRead( stream, &sound[ i ] );
for (U32 i = 0; i < MaxSounds; i++)
UNPACKDATA_SOUNDASSET_ARRAY(PlayerSound, i);
mathRead(*stream, &boxSize);
mathRead(*stream, &crouchBoxSize);
@ -1932,11 +1905,11 @@ bool Player::onNewDataBlock( GameBaseData *dptr, bool reload )
SFX_DELETE( mMoveBubbleSound );
SFX_DELETE( mWaterBreathSound );
if ( mDataBlock->sound[PlayerData::MoveBubbles] )
mMoveBubbleSound = SFX->createSource( mDataBlock->sound[PlayerData::MoveBubbles] );
if ( mDataBlock->getPlayerSound(PlayerData::MoveBubbles) )
mMoveBubbleSound = SFX->createSource( mDataBlock->getPlayerSoundProfile(PlayerData::MoveBubbles) );
if ( mDataBlock->sound[PlayerData::WaterBreath] )
mWaterBreathSound = SFX->createSource( mDataBlock->sound[PlayerData::WaterBreath] );
if ( mDataBlock->getPlayerSound(PlayerData::WaterBreath) )
mWaterBreathSound = SFX->createSource( mDataBlock->getPlayerSoundProfile(PlayerData::WaterBreath) );
}
mObjBox.maxExtents.x = mDataBlock->boxSize.x * 0.5f;
@ -3300,7 +3273,7 @@ void Player::updateMove(const Move* move)
{
// exit-water splash sound happens for client only
if ( getSpeed() >= mDataBlock->exitSplashSoundVel && !isMounted() )
SFX->playOnce( mDataBlock->sound[PlayerData::ExitWater], &getTransform() );
SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ExitWater), &getTransform() );
}
}
@ -7060,17 +7033,17 @@ void Player::playFootstepSound( bool triggeredLeft, Material* contactMaterial, S
// Treading water.
if ( mWaterCoverage < mDataBlock->footSplashHeight )
SFX->playOnce( mDataBlock->sound[ PlayerData::FootShallowSplash ], &footMat );
SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootShallowSplash ), &footMat );
else
{
if ( mWaterCoverage < 1.0 )
SFX->playOnce( mDataBlock->sound[ PlayerData::FootWading ], &footMat );
SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootWading ), &footMat );
else
{
if ( triggeredLeft )
{
SFX->playOnce( mDataBlock->sound[ PlayerData::FootUnderWater ], &footMat );
SFX->playOnce( mDataBlock->sound[ PlayerData::FootBubbles ], &footMat );
SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootUnderWater ), &footMat );
SFX->playOnce( mDataBlock->getPlayerSoundProfile( PlayerData::FootBubbles ), &footMat );
}
}
}
@ -7092,7 +7065,7 @@ void Player::playFootstepSound( bool triggeredLeft, Material* contactMaterial, S
sound = 2;
if (sound>=0)
SFX->playOnce(mDataBlock->sound[sound], &footMat);
SFX->playOnce(mDataBlock->getPlayerSoundProfile(sound), &footMat);
}
}
@ -7123,7 +7096,7 @@ void Player:: playImpactSound()
sound = 2; // Play metal;
if (sound >= 0)
SFX->playOnce(mDataBlock->sound[PlayerData::ImpactStart + sound], &getTransform());
SFX->playOnce(mDataBlock->getPlayerSoundProfile(PlayerData::ImpactStart + sound), &getTransform());
}
}
}
@ -7277,11 +7250,11 @@ bool Player::collidingWithWater( Point3F &waterHeight )
void Player::createSplash( Point3F &pos, F32 speed )
{
if ( speed >= mDataBlock->hardSplashSoundVel )
SFX->playOnce( mDataBlock->sound[PlayerData::ImpactWaterHard], &getTransform() );
SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ImpactWaterHard), &getTransform() );
else if ( speed >= mDataBlock->medSplashSoundVel )
SFX->playOnce( mDataBlock->sound[PlayerData::ImpactWaterMedium], &getTransform() );
SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ImpactWaterMedium), &getTransform() );
else
SFX->playOnce( mDataBlock->sound[PlayerData::ImpactWaterEasy], &getTransform() );
SFX->playOnce( mDataBlock->getPlayerSoundProfile(PlayerData::ImpactWaterEasy), &getTransform() );
if( mDataBlock->splash )
{

View file

@ -35,6 +35,7 @@
#include "collision/boxConvex.h"
#endif
#include "T3D/assets/SoundAsset.h"
#include "T3D/gameBase/gameProcess.h"
class Material;
@ -218,7 +219,9 @@ struct PlayerData: public ShapeBaseData {
ExitWater,
MaxSounds
};
SFXTrack* sound[MaxSounds];
DECLARE_SOUNDASSET_ARRAY(PlayerData, PlayerSound, Sounds::MaxSounds);
DECLARE_SOUNDASSET_ARRAY_SETGET(PlayerData, PlayerSound);
Point3F boxSize; ///< Width, depth, height
Point3F crouchBoxSize;