/*
 * Fires the beam and starts the warpaway
 */
void TemporalClass::Fire(TechnoClass *target) {

  if ( target ) {
    if ( target->SpawnManager )
      target->SpawnManager->DestroyAll();
    if ( target->CaptureManager )
      target->CaptureManager->ReleaseAll();
  }
  if ( this->OwnerUnit->TemporalImUsing ) {
    if ( this->OwnerUnit->TemporalImUsing->Victim )
      this->OwnerUnit->TemporalImUsing->LetGo();// Give up on earlier target I had
  }

  if ( this->CanWarpTarget(target) ) {
    if ( !this->OwnerUnit->TemporalTargettingMe ) {
      this->Victim = target;
      TemporalClass *targTemporal = target->TemporalTargettingMe;
      if ( targTemporal ) {            // Guys already temporal'ing my new target away
        this->PrevTemporal = targTemporal;
        this->NextTemporal = targTemporal->NextTemporal;
        targTemporal->NextTemporal = this;
        if ( this->NextTemporal )
          this->NextTemporal->PrevTemporal = this;
      }
      else {
        target->TemporalTargettingMe = this;
        this->WarpRemaining = 10 * this->Victim->GetType()->Strength;
        if ( this->Victim ) {
          if ( this->Victim->What_Am_I() == IS_VEHICLE ) {
            UnitClass *unitVictim;
            if ( this->Victim )
              unitVictim = this->Victim;
            else
              unitVictim = NULL;
            if ( unitVictim->UnitType->Harvester ) {
              if ( this->Victim->OwningPlayer == Player ) {
                dwXYZ *dwCoords = this->Victim->GetCoords();
                CoordStruct coords;
                coords.x = dwCoords->X / 256;
                coords.y = dwCoords->Y / 256;
                if ( RadarEventClass::Add(4, coords) )
                  VoxClass::PlayFromName("EVA_OreMinerUnderAttack", -1, -1);
              }
            }
          }
        }
        if ( this->Victim->What_Am_I() == IS_BUILDING ) {
          if ( !this->Victim->GetType()->Insignificant ) {
            if ( !this->Victim->IsUndeployable() ) {
              if ( this->Victim ) {
                  this->Victim->OwningPlayer->BuildingUnderAttack(this->Victim);
              }
              else {
                this->Victim->OwningPlayer->BuildingUnderAttack(NULL); // ?
              }
            }
          }
        }
      }
      this->Victim->IsBeingWarpedOut = 1;
      if ( this->Victim->GetType()->IsGattling) )
        this->Victim->ResetGattling(1);

      if ( this->Victim->What_Am_I() == IS_BUILDING ) {
        this->Victim->OwningPlayer->RecheckItems = 1;
        this->Victim->Disable_Before_Temporal();
        this->Victim->OwningPlayer->RecheckTechLevels = 1;
      }

      this->Victim->SetLayer(LAYER_GROUND);
      if ( this->Victim->TemporalImUsing ) {
        if ( this->Victim->TemporalImUsing->Victim )
          this->Victim->TemporalImUsing->LetGo(); // Unhooking my target's own temporal
      }
      if ( Player )
        this->Victim->Unselect();
    }
  }
}