예제 #1
0
 public TargetSignatureData(CMFlare flare, float _signalStrength)
 {
     velocity       = flare.velocity;
     geoPos         = VectorUtils.WorldPositionToGeoCoords(flare.transform.position, FlightGlobals.currentMainBody);
     exists         = true;
     acceleration   = Vector3.zero;
     timeAcquired   = Time.time;
     signalStrength = _signalStrength;
     targetInfo     = null;
     vesselJammer   = null;
     team           = BDArmorySettings.BDATeams.None;
     pingPosition   = Vector2.zero;
     orbital        = false;
     orbit          = null;
     lockedByRadar  = null;
     vessel         = null;
 }
예제 #2
0
 public TargetSignatureData(Vector3 _velocity, Vector3 _position, Vector3 _acceleration, bool _exists, float _signalStrength)
 {
     velocity       = _velocity;
     geoPos         = VectorUtils.WorldPositionToGeoCoords(_position, FlightGlobals.currentMainBody);
     acceleration   = _acceleration;
     exists         = _exists;
     timeAcquired   = Time.time;
     signalStrength = _signalStrength;
     targetInfo     = null;
     vesselJammer   = null;
     team           = BDArmorySettings.BDATeams.None;
     pingPosition   = Vector2.zero;
     orbital        = false;
     orbit          = null;
     lockedByRadar  = null;
     vessel         = null;
 }
예제 #3
0
        public TargetSignatureData(Vessel v, float _signalStrength)
        {
            /*
             * if(v.situation == Vessel.Situations.SUB_ORBITAL || v.situation == Vessel.Situations.ESCAPING || v.situation == Vessel.Situations.SUB_ORBITAL)
             * {
             *      velocity = v.obt_velocity;
             *      orbit = v.orbit;
             *      orbital = true;
             * }
             * else
             * {
             */
            orbital  = false;
            orbit    = null;
            velocity = v.srf_velocity;
            //}
            vessel         = v;
            geoPos         = VectorUtils.WorldPositionToGeoCoords(v.CoM, v.mainBody);
            acceleration   = v.acceleration;
            exists         = true;
            timeAcquired   = Time.time;
            signalStrength = _signalStrength;

            targetInfo = v.gameObject.GetComponent <TargetInfo> ();

            team = BDArmorySettings.BDATeams.None;
            if (targetInfo)
            {
                team = targetInfo.team;
            }
            else
            {
                foreach (var mf in v.FindPartModulesImplementing <MissileFire>())
                {
                    team = BDATargetManager.BoolToTeam(mf.team);
                    break;
                }
            }

            vesselJammer = v.gameObject.GetComponent <VesselECMJInfo>();

            pingPosition = Vector2.zero;

            lockedByRadar = null;
        }
예제 #4
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            part.force_activate();

            //setup anim
            if (!string.IsNullOrEmpty(deployAnimationName))
            {
                hasDeployAnimation = true;
                deployAnimState    = Misc.SetUpSingleAnimation(deployAnimationName, part);
                if (state == StartState.Editor)
                {
                    Events["EditorToggleAnimation"].guiActiveEditor = true;
                }
            }

            if (HighLogic.LoadedSceneIsFlight)
            {
                foreach (var tur in part.FindModulesImplementing <ModuleTurret>())
                {
                    if (tur.turretID == turretID)
                    {
                        turret = tur;
                        break;
                    }
                }

                attachedRadar = part.FindModuleImplementing <ModuleRadar>();
                if (attachedRadar)
                {
                    hasAttachedRadar = true;
                }

                finalTransform = part.FindModelTransform(finalTransformName);

                UpdateMissileChildren();

                if (!autoReturn)
                {
                    Events["ReturnTurret"].guiActive = true;
                }
            }
        }
예제 #5
0
        void UnlinkRadar(ModuleRadar mr)
        {
            if(mr && mr.vessel)
            {
                RemoveRadar(mr);
                externalRadars.Remove(mr);
                mr.RemoveExternalVRD(this);

                bool noMoreExternalRadar = true;
                foreach(var rad in externalRadars)
                {
                    if(rad.vessel == mr.vessel)
                    {
                        noMoreExternalRadar = false;
                        break;
                    }
                }

                if(noMoreExternalRadar)
                {
                    externalVRDs.Remove(mr.vesselRadarData);
                }
            }
            else
            {
                externalRadars.RemoveAll(r => r == null);
            }
        }
예제 #6
0
        public void AddRadarContact(ModuleRadar radar, TargetSignatureData contactData, bool _locked)
        {
            RadarDisplayData rData = new RadarDisplayData();
            rData.vessel = contactData.vessel;

            if(rData.vessel == vessel)
            {
                return;
            }

            rData.signalPersistTime = radar.signalPersistTime;
            rData.detectedByRadar = radar;
            rData.locked = _locked;
            rData.targetData = contactData;
            rData.pingPosition = UpdatedPingPosition(contactData.position, radar);

            if(_locked)
            {
                radar.UpdateLockedTargetInfo(contactData);
            }

            bool dontOverwrite = false;

            int replaceIndex = -1;
            for(int i = 0; i < displayedTargets.Count; i++)
            {
                if(displayedTargets[i].vessel == rData.vessel)
                {
                    if(displayedTargets[i].locked && !_locked)
                    {
                        dontOverwrite = true;
                        break;
                    }

                    replaceIndex = i;
                    break;
                }
            }

            if(replaceIndex >= 0)
            {
                displayedTargets[replaceIndex] = rData;
                //UpdateLockedTargets();
                return;
            }
            else if(dontOverwrite)
            {
                //UpdateLockedTargets();
                return;
            }
            else
            {
                displayedTargets.Add(rData);
                UpdateLockedTargets();
                return;
            }
        }
예제 #7
0
        public void AddRadar(ModuleRadar mr)
        {
            if(availableRadars.Contains(mr))
            {
                return;
            }

            availableRadars.Add(mr);
            rCount = availableRadars.Count;
            //UpdateDataLinkCapability();
            linkCapabilityDirty = true;
        }
예제 #8
0
 void UnlinkRadar()
 {
     linked = false;
     linkedRadar = null;
     linkedVesselID = string.Empty;
     if(locked)
     {
         UnlockTarget();
     }
 }
예제 #9
0
 public void UnlockAllTargetsOfRadar(ModuleRadar radar)
 {
     //radar.UnlockTarget();
     displayedTargets.RemoveAll(t => t.detectedByRadar == radar);
     UpdateLockedTargets();
 }
예제 #10
0
 public void RemoveRadar(ModuleRadar mr)
 {
     availableRadars.Remove(mr);
     rCount = availableRadars.Count;
     RemoveDataFromRadar(mr);
     //UpdateDataLinkCapability();
     linkCapabilityDirty = true;
 }
예제 #11
0
        public void LinkToRadar(ModuleRadar mr)
        {
            if(!mr)
            {
                return;
            }

            if(externalRadars.Contains(mr))
            {
                return;
            }

            externalRadars.Add(mr);
            AddRadar(mr);

            mr.AddExternalVRD(this);
            /*
            linkedRadar = mr;
            linkedVesselID = mr.vessel.id.ToString();
            linked = true;
            if(mr.locked)
            {
                locked = true;
                lockedTarget = mr.lockedTarget;
            }
            */
            //CloseLinkRadarWindow();
        }
예제 #12
0
        public static void UpdateRadarLock(MissileFire myWpnManager, float directionAngle, Transform referenceTransform, float fov, Vector3 position, float minSignature, ModuleRadar radar, bool pingRWR, RadarWarningReceiver.RWRThreatTypes rwrType, bool radarSnapshot)
        {
            Vector3d geoPos        = VectorUtils.WorldPositionToGeoCoords(position, FlightGlobals.currentMainBody);
            Vector3  forwardVector = referenceTransform.forward;
            Vector3  upVector      = referenceTransform.up;      //VectorUtils.GetUpDirection(position);
            Vector3  lookDirection = Quaternion.AngleAxis(directionAngle, upVector) * forwardVector;

            foreach (var vessel in BDATargetManager.LoadedVessels)
            {
                if (vessel == null)
                {
                    continue;
                }
                if (!vessel.loaded)
                {
                    continue;
                }

                if (myWpnManager)
                {
                    if (vessel == myWpnManager.vessel)
                    {
                        continue;                                                   //ignore self
                    }
                }
                else if ((vessel.transform.position - position).sqrMagnitude < 3600)
                {
                    continue;
                }

                Vector3 vesselDirection = Vector3.ProjectOnPlane(vessel.CoM - position, upVector);

                if (Vector3.Angle(vesselDirection, lookDirection) < fov / 2)
                {
                    if (TerrainCheck(referenceTransform.position, vessel.transform.position))
                    {
                        continue;                                                                                          //blocked by terrain
                    }
                    float sig = float.MaxValue;
                    if (radarSnapshot && minSignature > 0)
                    {
                        sig = GetModifiedSignature(vessel, position);
                    }

                    RadarWarningReceiver.PingRWR(vessel, position, rwrType, radar.signalPersistTime);

                    float detectSig = sig;

                    VesselECMJInfo vesselJammer = vessel.GetComponent <VesselECMJInfo>();
                    if (vesselJammer)
                    {
                        sig       *= vesselJammer.rcsReductionFactor;
                        detectSig += vesselJammer.jammerStrength;
                    }

                    if (detectSig > minSignature)
                    {
                        if (vessel.vesselType == VesselType.Debris)
                        {
                            vessel.gameObject.AddComponent <TargetInfo>();
                        }
                        else if (myWpnManager != null)
                        {
                            BDATargetManager.ReportVessel(vessel, myWpnManager);
                        }

                        //radar.vesselRadarData.AddRadarContact(radar, new TargetSignatureData(vessel, detectSig), false);
                        radar.ReceiveContactData(new TargetSignatureData(vessel, detectSig), false);
                    }
                }
            }
        }
예제 #13
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            part.force_activate();

            //setup anim
            if(!string.IsNullOrEmpty(deployAnimationName))
            {
                hasDeployAnimation = true;
                deployAnimState = Misc.SetUpSingleAnimation(deployAnimationName, part);
                if(state == StartState.Editor)
                {
                    Events["EditorToggleAnimation"].guiActiveEditor = true;
                }
            }

            if(HighLogic.LoadedSceneIsFlight)
            {
                foreach(var tur in part.FindModulesImplementing<ModuleTurret>())
                {
                    if(tur.turretID == turretID)
                    {
                        turret = tur;
                        break;
                    }
                }

                attachedRadar = part.FindModuleImplementing<ModuleRadar>();
                if(attachedRadar) hasAttachedRadar = true;

                finalTransform = part.FindModelTransform(finalTransformName);

                UpdateMissileChildren();

                if(!autoReturn)
                {
                    Events["ReturnTurret"].guiActive = true;
                }
            }
        }
예제 #14
0
        void UpdateRadarTarget()
        {
            targetAcquired = false;

            float angleToTarget = Vector3.Angle(radarTarget.position-transform.position,transform.forward);
            if(radarTarget.exists)
            {
                if((radarTarget.predictedPosition-transform.position).sqrMagnitude > Mathf.Pow(activeRadarRange, 2) || angleToTarget > maxOffBoresight*0.75f)
                {
                    if(radar
                        && radar.lockedTarget.exists
                        && (radarTarget.predictedPosition-radar.lockedTarget.predictedPosition).sqrMagnitude<Mathf.Pow(100,2)
                        && (radar.transform.position-transform.position).sqrMagnitude < Mathf.Pow(activeRadarRange,2))
                    {
                        targetAcquired = true;
                        radarTarget = radar.lockedTarget;
                        targetPosition = radarTarget.predictedPosition;
                        targetVelocity = radarTarget.velocity;
                        targetAcceleration = radarTarget.acceleration;
                        //radarTarget.signalStrength =
                        return;
                    }
                    else
                    {
                        Debug.Log ("Radar guidance failed. Out of range and no data feed.");
                        radarTarget = TargetSignatureData.noTarget;
                        legacyTargetVessel = null;
                        return;
                    }
                }
                else
                {
                    radar = null;

                    if(angleToTarget > maxOffBoresight)
                    {
                        Debug.Log ("Radar guidance failed.  Target is out of active seeker gimbal limits.");
                        radarTarget = TargetSignatureData.noTarget;
                        legacyTargetVessel = null;
                        return;
                    }
                    else
                    {
                        if(scannedTargets == null) scannedTargets = new TargetSignatureData[5];
                        TargetSignatureData.ResetTSDArray(ref scannedTargets);
                        Ray ray = new Ray(transform.position,radarTarget.predictedPosition-transform.position);
                        bool pingRWR = Time.time - lastRWRPing > 0.4f;
                        if(pingRWR) lastRWRPing = Time.time;
                        RadarUtils.ScanInDirection(ray, lockedSensorFOV, 100, ref scannedTargets, 0.4f, pingRWR, RadarWarningReceiver.RWRThreatTypes.MissileLock);
                        for(int i = 0; i < scannedTargets.Length; i++)
                        {
                            if(scannedTargets[i].exists && (scannedTargets[i].predictedPosition-radarTarget.predictedPosition).sqrMagnitude < Mathf.Pow(20,2))
                            {
                                radarTarget = scannedTargets[i];
                                targetAcquired = true;
                                targetPosition = radarTarget.predictedPosition + (radarTarget.velocity*Time.fixedDeltaTime);
                                targetVelocity = radarTarget.velocity;
                                targetAcceleration = radarTarget.acceleration;

                                if(!activeRadar)
                                {
                                    activeRadar = true;
                                    RadarWarningReceiver.PingRWR(ray, lockedSensorFOV, RadarWarningReceiver.RWRThreatTypes.MissileLaunch, 2f);
                                    Debug.Log ("Pitbull! Radar missile has gone active.  Radar sig strength: "+radarTarget.signalStrength.ToString("0.0"));
                                }
                                return;
                            }
                        }
                        radarTarget = TargetSignatureData.noTarget;

                    }
                }
            }

            if(!radarTarget.exists)
            {
                legacyTargetVessel = null;
            }
        }
예제 #15
0
        void LinkToRadar(ModuleRadar mr)
        {
            if(!mr)
            {
                return;
            }

            linkedRadar = mr;
            linkedVesselID = mr.vessel.id.ToString();
            linked = true;
            if(mr.locked)
            {
                locked = true;
                lockedTarget = mr.lockedTarget;
            }
            CloseLinkRadarWindow();
        }
예제 #16
0
 Vector2 UpdatedPingPosition(Vector3 worldPosition, ModuleRadar radar)
 {
     if(omniDisplay)
     {
         return RadarUtils.WorldToRadar(worldPosition, referenceTransform, radarRect, rIncrements[rangeIndex]);
     }
     else
     {
         return RadarUtils.WorldToRadarRadial(worldPosition, referenceTransform, radarRect, rIncrements[rangeIndex], radar.directionalFieldOfView / 2);
     }
 }
예제 #17
0
        public void BeginWaitForUnloadedLinkedRadar(ModuleRadar mr, string vesselID)
        {
            UnlinkDisabledRadar(mr);

            if(waitingForVessels.Contains(vesselID))
            {
                return;
            }

            waitingForVessels.Add(vesselID);
            SaveExternalVRDVessels();
            StartCoroutine(RecoverUnloadedLinkedVesselRoutine(vesselID));
        }
예제 #18
0
        public static void UpdateRadarLock(Ray ray, Vector3 predictedPos, float fov, float minSignature, ModuleRadar radar, bool pingRWR, bool radarSnapshot, float dataPersistTime, bool locked, int lockIndex, Vessel lockedVessel)
        {
            RadarWarningReceiver.RWRThreatTypes rwrType = radar.rwrType;
            //Vessel lockedVessel = null;
            float closestSqrDist = 100;

            if (lockedVessel == null)
            {
                foreach (var vessel in BDATargetManager.LoadedVessels)
                {
                    if (vessel == null)
                    {
                        continue;
                    }
                    if (!vessel.loaded)
                    {
                        continue;
                    }
                    //if(vessel.Landed) continue;

                    Vector3 vectorToTarget = vessel.transform.position - ray.origin;
                    if ((vectorToTarget).sqrMagnitude < 10)
                    {
                        continue;                                                        //ignore self
                    }
                    if (Vector3.Dot(vectorToTarget, ray.direction) < 0)
                    {
                        continue;                                                                    //ignore behind ray
                    }
                    if (Vector3.Angle(vessel.CoM - ray.origin, ray.direction) < fov / 2)
                    {
                        float sqrDist = Vector3.SqrMagnitude(vessel.CoM - predictedPos);
                        if (sqrDist < closestSqrDist)
                        {
                            closestSqrDist = sqrDist;
                            lockedVessel   = vessel;
                        }
                    }
                }
            }

            if (lockedVessel != null)
            {
                if (TerrainCheck(ray.origin, lockedVessel.transform.position))
                {
                    radar.UnlockTargetAt(lockIndex, true);                     //blocked by terrain
                    return;
                }

                float sig = float.MaxValue;
                if (radarSnapshot)
                {
                    sig = GetModifiedSignature(lockedVessel, ray.origin);
                }

                if (pingRWR && sig > minSignature * 0.66f)
                {
                    RadarWarningReceiver.PingRWR(lockedVessel, ray.origin, rwrType, dataPersistTime);
                }

                if (sig > minSignature)
                {
                    //radar.vesselRadarData.AddRadarContact(radar, new TargetSignatureData(lockedVessel, sig), locked);
                    radar.ReceiveContactData(new TargetSignatureData(lockedVessel, sig), locked);
                }
                else
                {
                    radar.UnlockTargetAt(lockIndex, true);
                    return;
                }
            }
            else
            {
                radar.UnlockTargetAt(lockIndex, true);
            }
        }
예제 #19
0
 public void RemoveDataFromRadar(ModuleRadar radar)
 {
     displayedTargets.RemoveAll(t => t.detectedByRadar == radar);
     UpdateLockedTargets();
 }
예제 #20
0
        public static void UpdateRadarLock(MissileFire myWpnManager, float directionAngle, Transform referenceTransform, float fov, Vector3 position, float minSignature, ModuleRadar radar, bool pingRWR, RadarWarningReceiver.RWRThreatTypes rwrType, bool radarSnapshot)
        {
            Vector3d geoPos = VectorUtils.WorldPositionToGeoCoords(position, FlightGlobals.currentMainBody);
            Vector3 forwardVector = referenceTransform.forward;
            Vector3 upVector = referenceTransform.up;//VectorUtils.GetUpDirection(position);
            Vector3 lookDirection = Quaternion.AngleAxis(directionAngle, upVector) * forwardVector;

            foreach(var vessel in BDATargetManager.LoadedVessels)
            {
                if(vessel == null) continue;
                if(!vessel.loaded) continue;

                if(myWpnManager)
                {
                    if(vessel == myWpnManager.vessel) continue; //ignore self
                }
                else if((vessel.transform.position - position).sqrMagnitude < 3600) continue;

                Vector3 vesselDirection = Vector3.ProjectOnPlane(vessel.CoM - position, upVector);

                if(Vector3.Angle(vesselDirection, lookDirection) < fov / 2)
                {
                    if(TerrainCheck(referenceTransform.position, vessel.transform.position)) continue; //blocked by terrain

                    float sig = float.MaxValue;
                    if(radarSnapshot && minSignature > 0) sig = GetModifiedSignature(vessel, position);

                    RadarWarningReceiver.PingRWR(vessel, position, rwrType, radar.signalPersistTime);

                    float detectSig = sig;

                    VesselECMJInfo vesselJammer = vessel.GetComponent<VesselECMJInfo>();
                    if(vesselJammer)
                    {
                        sig *= vesselJammer.rcsReductionFactor;
                        detectSig += vesselJammer.jammerStrength;
                    }

                    if(detectSig > minSignature)
                    {
                        if(vessel.vesselType == VesselType.Debris)
                        {
                            vessel.gameObject.AddComponent<TargetInfo>();
                        }
                        else if(myWpnManager != null)
                        {
                            BDATargetManager.ReportVessel(vessel, myWpnManager);
                        }

                        //radar.vesselRadarData.AddRadarContact(radar, new TargetSignatureData(vessel, detectSig), false);
                        radar.ReceiveContactData(new TargetSignatureData(vessel, detectSig), false);
                    }
                }
            }
        }
예제 #21
0
 public void UnlinkDisabledRadar(ModuleRadar mr)
 {
     RemoveRadar(mr);
     externalRadars.Remove(mr);
     SaveExternalVRDVessels();
 }
예제 #22
0
        public static void UpdateRadarLock(Ray ray, Vector3 predictedPos, float fov, float minSignature, ModuleRadar radar, bool pingRWR, bool radarSnapshot, float dataPersistTime, bool locked, int lockIndex, Vessel lockedVessel)
        {
            RadarWarningReceiver.RWRThreatTypes rwrType = radar.rwrType;
            //Vessel lockedVessel = null;
            float closestSqrDist = 100;

            if(lockedVessel == null)
            {
                foreach(var vessel in BDATargetManager.LoadedVessels)
                {
                    if(vessel == null) continue;
                    if(!vessel.loaded) continue;
                    //if(vessel.Landed) continue;

                    Vector3 vectorToTarget = vessel.transform.position - ray.origin;
                    if((vectorToTarget).sqrMagnitude < 10) continue; //ignore self

                    if(Vector3.Dot(vectorToTarget, ray.direction) < 0) continue; //ignore behind ray

                    if(Vector3.Angle(vessel.CoM - ray.origin, ray.direction) < fov / 2)
                    {
                        float sqrDist = Vector3.SqrMagnitude(vessel.CoM - predictedPos);
                        if(sqrDist < closestSqrDist)
                        {
                            closestSqrDist = sqrDist;
                            lockedVessel = vessel;
                        }
                    }
                }
            }

            if(lockedVessel != null)
            {
                if(TerrainCheck(ray.origin, lockedVessel.transform.position))
                {
                    radar.UnlockTargetAt(lockIndex, true); //blocked by terrain
                    return;
                }

                float sig = float.MaxValue;
                if(radarSnapshot) sig = GetModifiedSignature(lockedVessel, ray.origin);

                if(pingRWR && sig > minSignature * 0.66f)
                {
                    RadarWarningReceiver.PingRWR(lockedVessel, ray.origin, rwrType, dataPersistTime);
                }

                if(sig > minSignature)
                {
                    //radar.vesselRadarData.AddRadarContact(radar, new TargetSignatureData(lockedVessel, sig), locked);
                    radar.ReceiveContactData(new TargetSignatureData(lockedVessel, sig), locked);
                }
                else
                {
                    radar.UnlockTargetAt(lockIndex, true);
                    return;
                }
            }
            else
            {
                radar.UnlockTargetAt(lockIndex, true);
            }
        }
예제 #23
0
        bool CheckRadarForLock(ModuleRadar radar, RadarDisplayData radarTarget)
        {
            if(!radar) return false;

            return
                (
                radar.canLock
                && (!radar.locked || radar.currentLocks < radar.maxLocks)
                && radarTarget.targetData.signalStrength > radar.minLockedSignalThreshold
                && (radar.omnidirectional || Vector3.Angle(radar.transform.up, radarTarget.targetData.predictedPosition-radar.transform.position) < radar.directionalFieldOfView/2)
            );
        }
예제 #24
0
        void UpdateRadarTarget()
        {
            targetAcquired = false;

            float angleToTarget = Vector3.Angle(radarTarget.position-transform.position,transform.forward);
            if(radarTarget.exists)
            {
                if(!activeRadar && ((radarTarget.predictedPosition - transform.position).sqrMagnitude > Mathf.Pow(activeRadarRange, 2) || angleToTarget > maxOffBoresight * 0.75f))
                {
                    if(radar
                       && radar.lockedTarget.exists
                       && (radarTarget.predictedPosition - radar.lockedTarget.predictedPosition).sqrMagnitude < Mathf.Pow(100, 2)
                       )
                    {
                        targetAcquired = true;
                        radarTarget = radar.lockedTarget;
                        targetPosition = radarTarget.predictedPosition;
                        targetVelocity = radarTarget.velocity;
                        targetAcceleration = radarTarget.acceleration;
                        //radarTarget.signalStrength =
                        return;
                    }
                    else
                    {
                        Debug.Log("Radar guidance failed. Out of range and no data feed.");
                        radarTarget = TargetSignatureData.noTarget;
                        legacyTargetVessel = null;
                        return;
                    }
                }
                else
                {
                    radar = null;

                    if(angleToTarget > maxOffBoresight)
                    {
                        Debug.Log("Radar guidance failed.  Target is out of active seeker gimbal limits.");
                        radarTarget = TargetSignatureData.noTarget;
                        legacyTargetVessel = null;
                        return;
                    }
                    else
                    {
                        if(scannedTargets == null) scannedTargets = new TargetSignatureData[5];
                        TargetSignatureData.ResetTSDArray(ref scannedTargets);
                        Ray ray = new Ray(transform.position, radarTarget.predictedPosition - transform.position);
                        bool pingRWR = Time.time - lastRWRPing > 0.4f;
                        if(pingRWR) lastRWRPing = Time.time;
                        bool radarSnapshot = (snapshotTicker > 20);
                        if(radarSnapshot)
                        {
                            snapshotTicker = 0;
                        }
                        else
                        {
                            snapshotTicker++;
                        }
                        RadarUtils.ScanInDirection(ray, lockedSensorFOV, activeRadarMinThresh, ref scannedTargets, 0.4f, pingRWR, RadarWarningReceiver.RWRThreatTypes.MissileLock, radarSnapshot);
                        float sqrThresh = radarLOALSearching ? Mathf.Pow(500, 2) : Mathf.Pow(40, 2);

                        if(radarLOAL && radarLOALSearching && !radarSnapshot)
                        {
                            //only scan on snapshot interval
                        }
                        else
                        {
                            for(int i = 0; i < scannedTargets.Length; i++)
                            {
                                if(scannedTargets[i].exists && (scannedTargets[i].predictedPosition - radarTarget.predictedPosition).sqrMagnitude < sqrThresh)
                                {
                                    radarTarget = scannedTargets[i];
                                    targetAcquired = true;
                                    radarLOALSearching = false;
                                    targetPosition = radarTarget.predictedPosition + (radarTarget.velocity * Time.fixedDeltaTime);
                                    targetVelocity = radarTarget.velocity;
                                    targetAcceleration = radarTarget.acceleration;

                                    if(!activeRadar && Time.time - timeFired > 1)
                                    {
                                        if(locksCount == 0)
                                        {
                                            RadarWarningReceiver.PingRWR(ray, lockedSensorFOV, RadarWarningReceiver.RWRThreatTypes.MissileLaunch, 2f);
                                            Debug.Log("Pitbull! Radar missile has gone active.  Radar sig strength: " + radarTarget.signalStrength.ToString("0.0"));
                                        }
                                        else if(locksCount > 2)
                                        {
                                            guidanceActive = false;
                                            checkMiss = true;
                                            if(BDArmorySettings.DRAW_DEBUG_LABELS)
                                            {
                                                Debug.Log("Radar missile reached max re-lock attempts.");
                                            }
                                        }
                                        locksCount++;
                                    }
                                    activeRadar = true;
                                    return;
                                }
                            }
                        }

                        if(radarLOAL)
                        {
                            radarLOALSearching = true;
                            targetAcquired = true;
                            targetPosition = radarTarget.predictedPosition + (radarTarget.velocity * Time.fixedDeltaTime);
                            targetVelocity = radarTarget.velocity;
                            targetAcceleration = Vector3.zero;
                            activeRadar = false;
                        }
                        else
                        {
                            radarTarget = TargetSignatureData.noTarget;
                        }

                    }
                }
            }
            else if(radarLOAL && radarLOALSearching)
            {
                if(scannedTargets == null) scannedTargets = new TargetSignatureData[5];
                TargetSignatureData.ResetTSDArray(ref scannedTargets);
                Ray ray = new Ray(transform.position, transform.forward);
                bool pingRWR = Time.time - lastRWRPing > 0.4f;
                if(pingRWR) lastRWRPing = Time.time;
                bool radarSnapshot = (snapshotTicker > 6);
                if(radarSnapshot)
                {
                    snapshotTicker = 0;
                }
                else
                {
                    snapshotTicker++;
                }
                RadarUtils.ScanInDirection(ray, lockedSensorFOV*3, activeRadarMinThresh*2, ref scannedTargets, 0.4f, pingRWR, RadarWarningReceiver.RWRThreatTypes.MissileLock, radarSnapshot);
                float sqrThresh = Mathf.Pow(300, 2);

                float smallestAngle = 360;
                TargetSignatureData lockedTarget = TargetSignatureData.noTarget;

                for(int i = 0; i < scannedTargets.Length; i++)
                {
                    if(scannedTargets[i].exists && (scannedTargets[i].predictedPosition - radarTarget.predictedPosition).sqrMagnitude < sqrThresh)
                    {
                        float angle = Vector3.Angle(scannedTargets[i].predictedPosition - transform.position, transform.forward);
                        if(angle < smallestAngle)
                        {
                            lockedTarget = scannedTargets[i];
                            smallestAngle = angle;
                        }

                        activeRadar = true;
                        return;
                    }
                }

                if(lockedTarget.exists)
                {
                    radarTarget = lockedTarget;
                    targetAcquired = true;
                    radarLOALSearching = false;
                    targetPosition = radarTarget.predictedPosition + (radarTarget.velocity * Time.fixedDeltaTime);
                    targetVelocity = radarTarget.velocity;
                    targetAcceleration = radarTarget.acceleration;

                    if(!activeRadar && Time.time - timeFired > 1)
                    {
                        RadarWarningReceiver.PingRWR(new Ray(transform.position, radarTarget.predictedPosition - transform.position), lockedSensorFOV, RadarWarningReceiver.RWRThreatTypes.MissileLaunch, 2f);
                        Debug.Log("Pitbull! Radar missile has gone active.  Radar sig strength: " + radarTarget.signalStrength.ToString("0.0"));
                    }
                    return;
                }
                else
                {
                    targetAcquired = true;
                    targetPosition = transform.position + (startDirection * 500);
                    targetVelocity = Vector3.zero;
                    targetAcceleration = Vector3.zero;
                    radarLOALSearching = true;
                    return;
                }
            }

            if(!radarTarget.exists)
            {
                legacyTargetVessel = null;
            }
        }