mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
Now projectiles wont explode before they have been armed. Results in projectiles being able to collide with several objects before exploding.
This commit is contained in:
parent
66775714ef
commit
9bdeabf22c
1 changed files with 196 additions and 203 deletions
|
|
@ -95,14 +95,14 @@ ConsoleDocClass( ProjectileData,
|
||||||
"@endtsexample\n"
|
"@endtsexample\n"
|
||||||
|
|
||||||
"@ingroup gameObjects\n"
|
"@ingroup gameObjects\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
IMPLEMENT_CO_NETOBJECT_V1(Projectile);
|
IMPLEMENT_CO_NETOBJECT_V1(Projectile);
|
||||||
|
|
||||||
ConsoleDocClass( Projectile,
|
ConsoleDocClass( Projectile,
|
||||||
"@brief Base projectile class. Uses the ProjectileData class for properties of individual projectiles.\n"
|
"@brief Base projectile class. Uses the ProjectileData class for properties of individual projectiles.\n"
|
||||||
"@ingroup gameObjects\n"
|
"@ingroup gameObjects\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
IMPLEMENT_CALLBACK( ProjectileData, onExplode, void, ( Projectile* proj, Point3F pos, F32 fade ),
|
IMPLEMENT_CALLBACK( ProjectileData, onExplode, void, ( Projectile* proj, Point3F pos, F32 fade ),
|
||||||
( proj, pos, fade ),
|
( proj, pos, fade ),
|
||||||
|
|
@ -396,9 +396,9 @@ void ProjectileData::packData(BitStream* stream)
|
||||||
|
|
||||||
stream->write(impactForce);
|
stream->write(impactForce);
|
||||||
|
|
||||||
// stream->writeRangedU32(lifetime, 0, Projectile::MaxLivingTicks);
|
// stream->writeRangedU32(lifetime, 0, Projectile::MaxLivingTicks);
|
||||||
// stream->writeRangedU32(armingDelay, 0, Projectile::MaxLivingTicks);
|
// stream->writeRangedU32(armingDelay, 0, Projectile::MaxLivingTicks);
|
||||||
// stream->writeRangedU32(fadeDelay, 0, Projectile::MaxLivingTicks);
|
// stream->writeRangedU32(fadeDelay, 0, Projectile::MaxLivingTicks);
|
||||||
|
|
||||||
// [tom, 3/21/2007] Changing these to write all 32 bits as the previous
|
// [tom, 3/21/2007] Changing these to write all 32 bits as the previous
|
||||||
// code limited these to a max value of 4095.
|
// code limited these to a max value of 4095.
|
||||||
|
|
@ -455,9 +455,9 @@ void ProjectileData::unpackData(BitStream* stream)
|
||||||
lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
||||||
|
|
||||||
// [tom, 3/21/2007] See comment in packData()
|
// [tom, 3/21/2007] See comment in packData()
|
||||||
// lifetime = stream->readRangedU32(0, Projectile::MaxLivingTicks);
|
// lifetime = stream->readRangedU32(0, Projectile::MaxLivingTicks);
|
||||||
// armingDelay = stream->readRangedU32(0, Projectile::MaxLivingTicks);
|
// armingDelay = stream->readRangedU32(0, Projectile::MaxLivingTicks);
|
||||||
// fadeDelay = stream->readRangedU32(0, Projectile::MaxLivingTicks);
|
// fadeDelay = stream->readRangedU32(0, Projectile::MaxLivingTicks);
|
||||||
|
|
||||||
stream->read(&impactForce);
|
stream->read(&impactForce);
|
||||||
|
|
||||||
|
|
@ -1106,9 +1106,6 @@ void Projectile::simulate( F32 dt )
|
||||||
if ( isServerObject() && ( rInfo.object->getTypeMask() & csmStaticCollisionMask ) == 0 )
|
if ( isServerObject() && ( rInfo.object->getTypeMask() & csmStaticCollisionMask ) == 0 )
|
||||||
setMaskBits( BounceMask );
|
setMaskBits( BounceMask );
|
||||||
|
|
||||||
// Next order of business: do we explode on this hit?
|
|
||||||
if ( mCurrTick > mDataBlock->armingDelay || mDataBlock->armingDelay == 0 )
|
|
||||||
{
|
|
||||||
MatrixF xform( true );
|
MatrixF xform( true );
|
||||||
xform.setColumn( 3, rInfo.point );
|
xform.setColumn( 3, rInfo.point );
|
||||||
setTransform( xform );
|
setTransform( xform );
|
||||||
|
|
@ -1142,13 +1139,10 @@ void Projectile::simulate( F32 dt )
|
||||||
// onCollision will remain uncalled on the client however, therefore no client
|
// onCollision will remain uncalled on the client however, therefore no client
|
||||||
// specific code should be placed inside the function!
|
// specific code should be placed inside the function!
|
||||||
onCollision( rInfo.point, rInfo.normal, rInfo.object );
|
onCollision( rInfo.point, rInfo.normal, rInfo.object );
|
||||||
|
// Next order of business: do we explode on this hit?
|
||||||
|
if ( mCurrTick > mDataBlock->armingDelay || mDataBlock->armingDelay == 0 )
|
||||||
explode( rInfo.point, rInfo.normal, objectType );
|
explode( rInfo.point, rInfo.normal, objectType );
|
||||||
|
|
||||||
// break out of the collision check, since we've exploded
|
|
||||||
// we don't want to mess with the position and velocity
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( mDataBlock->isBallistic )
|
if ( mDataBlock->isBallistic )
|
||||||
{
|
{
|
||||||
// Otherwise, this represents a bounce. First, reflect our velocity
|
// Otherwise, this represents a bounce. First, reflect our velocity
|
||||||
|
|
@ -1169,7 +1163,6 @@ void Projectile::simulate( F32 dt )
|
||||||
newPosition = oldPosition = rInfo.point + rInfo.normal * 0.05f;
|
newPosition = oldPosition = rInfo.point + rInfo.normal * 0.05f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// re-enable the collision response on the source object now
|
// re-enable the collision response on the source object now
|
||||||
// that we are done processing the ballistic movement
|
// that we are done processing the ballistic movement
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue