| 498 | //---------------------------------------------------------------------------- |
| 499 | |
| 500 | void ProximityMine::explode() |
| 501 | { |
| 502 | // Make sure we don't explode twice |
| 503 | if ( mState == Exploded ) |
| 504 | { |
| 505 | return; |
| 506 | } |
| 507 | |
| 508 | mState = Exploded; |
| 509 | mStateTimeout = TickSec * gAutoDeleteTicks; // auto-delete on server N ticks after exploding |
| 510 | |
| 511 | // Move the explosion point slightly off the surface to avoid problems with radius damage |
| 512 | Point3F normal = getTransform().getUpVector(); |
| 513 | Point3F explodePos = getTransform().getPosition() + normal * mDataBlock->explosionOffset; |
| 514 | |
| 515 | if ( isServerObject() ) |
| 516 | { |
| 517 | // Do what the server needs to do, damage the surrounding objects, etc. |
| 518 | mDataBlock->onExplode_callback( this, explodePos ); |
| 519 | setMaskBits( ExplosionMask ); |
| 520 | |
| 521 | // Wait till the timeout to self delete. This gives the server object time |
| 522 | // to get ghosted to the client |
| 523 | } |
| 524 | else |
| 525 | { |
| 526 | // Client just plays the explosion effect at the right place |
| 527 | if ( mDataBlock->explosion ) |
| 528 | { |
| 529 | Explosion *pExplosion = new Explosion; |
| 530 | pExplosion->onNewDataBlock( mDataBlock->explosion, false ); |
| 531 | |
| 532 | MatrixF xform( true ); |
| 533 | xform.setPosition( explodePos ); |
| 534 | pExplosion->setTransform( xform ); |
| 535 | pExplosion->setInitialState( explodePos, normal ); |
| 536 | pExplosion->setCollideType( sTriggerCollisionMask ); |
| 537 | if ( pExplosion->registerObject() == false ) |
| 538 | { |
| 539 | Con::errorf( ConsoleLogEntry::General, "ProximityMine(%s)::explode: couldn't register explosion", |
| 540 | mDataBlock->getName() ); |
| 541 | delete pExplosion; |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | void ProximityMine::advanceTime( F32 dt ) |
| 548 | { |
no test coverage detected