Esempio n. 1
0
//------------------------------------------------------------------------------
// updateTOF -- update time of flight (TOF) and set the missed status
//------------------------------------------------------------------------------
void Bullet::updateTOF(const LCreal)
{
   // As long as we're active ...
   if (isMode(ACTIVE)) {

      // count the number of active bursts and remove aged bullet bursts.
      int n = 0;
      int nhits = 0;
      for (int i = 0; i < nbt; i++) {
         if (bursts[i].bStatus == Burst::ACTIVE) {
            n++;
            if ( bursts[i].bTof >= getMaxTOF() ) {
               bursts[i].bStatus = Burst::MISS;
            }
         }
         else if (bursts[i].bStatus == Burst::HIT) {
            nhits++;
         }
      }

      // If we have no active bursts .. we've detonated (so to speak)
      if (n == 0) {
         setMode(DETONATED);
         // final detonation results (hit or miss) are located with each burst ...
         if (nhits > 0) {
            setDetonationResults( DETONATE_ENTITY_IMPACT );
         }
         else {
            setDetonationResults( DETONATE_NONE );
         }
         // final time of flight (slave to the first burst)
         setTOF( bursts[0].bTof );
      }
   }
}
Esempio n. 2
0
//------------------------------------------------------------------------------
// updateTOF -- default time of flight
//------------------------------------------------------------------------------
void Effects::updateTOF(const LCreal dt)
{
   // As long as we're active ...
   if (isMode(ACTIVE)) {

      // update time of flight,
      setTOF( getTOF() + dt );

      // and check for the end of the flight
      if (getTOF() >= getMaxTOF()) {
         setMode(DETONATED);
         setDetonationResults(DETONATE_NONE);
         return;
      }
   }
}