Exemplo n.º 1
0
//------------------------------------------------------------------------------
// Release one chaff bundle
//------------------------------------------------------------------------------
Chaff* SimpleStoresMgr::releaseOneChaff()
{
   Chaff* flyout = nullptr;
   Chaff* chaff = getNextChaff();
   if (chaff != nullptr) {
      flyout = static_cast<Chaff*>( releaseWeapon(chaff) );
   }
   return flyout;
}
Exemplo n.º 2
0
//------------------------------------------------------------------------------
// Release one SAM
//------------------------------------------------------------------------------
Sam* SimpleStoresMgr::releaseOneSam()
{
   Sam* flyout = nullptr;
   Sam* wpn = getNextSam();
   if (wpn != nullptr) {
      flyout = static_cast<Sam*>( releaseWeapon(wpn) );
   }
   return flyout;
}
Exemplo n.º 3
0
//------------------------------------------------------------------------------
// Release one Bomb
//------------------------------------------------------------------------------
Bomb* SimpleStoresMgr::releaseOneBomb()
{
   Bomb* flyout = nullptr;
   Bomb* wpn = getNextBomb();
   if (wpn != nullptr) {
      flyout = static_cast<Bomb*>( releaseWeapon(wpn) );
   }
   return flyout;
}
Exemplo n.º 4
0
//------------------------------------------------------------------------------
// Release one Missile
//------------------------------------------------------------------------------
Missile* SimpleStoresMgr::releaseOneMissile()
{
   Missile* flyout = nullptr;
   Missile* wpn = getNextMissile();
   if (wpn != nullptr) {
      flyout = static_cast<Missile*>( releaseWeapon(wpn) );
   }
   return flyout;
}
Exemplo n.º 5
0
//------------------------------------------------------------------------------
// Release one decoy
//------------------------------------------------------------------------------
Decoy* SimpleStoresMgr::releaseOneDecoy()
{
   Decoy* flyout = nullptr;
   Decoy* decoy = getNextDecoy();
   if (decoy != nullptr) {
      flyout = static_cast<Decoy*>( releaseWeapon(decoy) );
   }
   return flyout;
}
Exemplo n.º 6
0
//------------------------------------------------------------------------------
// Release one flare
//------------------------------------------------------------------------------
Flare* SimpleStoresMgr::releaseOneFlare()
{
   Flare* flyout = nullptr;
   Flare* flare = getNextFlare();
   if (flare != nullptr) {
      flyout = static_cast<Flare*>( releaseWeapon(flare) );
   }
   return flyout;
}
Exemplo n.º 7
0
// By station
Weapon* Stores::releaseWeapon(const unsigned int s)
{
   Weapon* flyout = 0;

   Weapon* wpn = getWeapon(s);
   if (wpn != 0) {
      flyout = releaseWeapon(wpn);
      wpn->unref();
   }

   return flyout;
}
Exemplo n.º 8
0
//------------------------------------------------------------------------------
// Manage the weapon release event
//------------------------------------------------------------------------------
bool SimpleStoresMgr::onWpnRelEvent(const base::Boolean* const sw)
{
   // Weapon release follows the switch or by default is true
   bool wpnRel = true;
   if (sw != nullptr) wpnRel = sw->getBoolean();

   if ( wpnRel && (isWeaponDeliveryMode(A2A) || isWeaponDeliveryMode(A2G)) ) {

      // A/A missiles and A/G bombs only ...

      Weapon* wpn = getCurrentWeapon();
      if (wpn != nullptr) {

         // release the weapon ---
         //  if successful, returns a pre-ref()'d pointer to the flyout weapon.
         Weapon* flyout = releaseWeapon(wpn);
         if (flyout != nullptr) {

            if (isWeaponDeliveryMode(A2A)) {

               // ---
               // Setup the guidance ...
               // ---
               Track* trk = getNextTarget();
               if (trk != nullptr) {
                  Player* tgt = trk->getTarget();

                  TrackManager* tm = nullptr;
                  RfSensor* sm = flyout->getSensor();
                  if (sm != nullptr) tm = sm->getTrackManager();

                  if (tm != nullptr) {
                     // Give a copy of the track to the weapon's track manager
                     Track* newTrk = trk->clone();
                     tm->clearTracksAndQueues();
                     tm->addTrack(newTrk);
                     flyout->setTargetTrack(newTrk,true);
                  }
                  else if (tgt != nullptr) {
                     // No sensor -- fake it and just track the target
                     flyout->setTargetPlayer(tgt,true);
                  }
                  else {
                     // no target track
                  }

                  trk->setWeaponReleased(true);
               }

            }


            // Set the weapon release timer
            setWeaponReleaseTimer(1.0);
         }

         if (flyout != nullptr) flyout->unref(); // unref() the flyout

         wpn->unref();
         wpn = nullptr;
      }

   }
   else {
      setWeaponReleaseTimer(0);
   }

   return true;
}