Exemplo n.º 1
0
        public TargetSignatureData(Vessel v, float _signalStrength)
        {
            velocity       = v.srf_velocity;
            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;
        }
Exemplo n.º 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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
        void EnsureVesselJammer()
        {
            if (!vesselJammer || vesselJammer.vessel != vessel)
            {
                vesselJammer = vessel.gameObject.GetComponent <VesselECMJInfo>();
                if (!vesselJammer)
                {
                    vesselJammer = vessel.gameObject.AddComponent <VesselECMJInfo>();
                }
            }

            vesselJammer.DelayedCleanJammerList();
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
0
        public static void ScanInDirection(MissileFire myWpnManager, float directionAngle, Transform referenceTransform, float fov, Vector3 position, float minSignature, ref TargetSignatureData[] dataArray, float dataPersistTime, 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;

            int dataIndex = 0;

            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, dataPersistTime);

                    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);
                        }

                        while (dataIndex < dataArray.Length - 1)
                        {
                            if ((dataArray[dataIndex].exists && Time.time - dataArray[dataIndex].timeAcquired > dataPersistTime) || !dataArray[dataIndex].exists)
                            {
                                break;
                            }
                            dataIndex++;
                        }
                        if (dataIndex >= dataArray.Length)
                        {
                            break;
                        }
                        dataArray[dataIndex] = new TargetSignatureData(vessel, sig);
                        dataIndex++;
                        if (dataIndex >= dataArray.Length)
                        {
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 7
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);
                    }
                }
            }
        }
Exemplo n.º 8
0
		void EnsureVesselJammer()
		{
			if(!vesselJammer || vesselJammer.vessel != vessel)
			{
				vesselJammer = vessel.gameObject.GetComponent<VesselECMJInfo>();
				if(!vesselJammer)
				{
					vesselJammer = vessel.gameObject.AddComponent<VesselECMJInfo>();
				}
			}

			vesselJammer.DelayedCleanJammerList();
		}
Exemplo n.º 9
0
 void EnsureVesselJammer()
 {
     if(!vesselJammer)
     {
         vesselJammer = vessel.gameObject.GetComponent<VesselECMJInfo>();
         if(!vesselJammer)
         {
             vesselJammer = vessel.gameObject.AddComponent<VesselECMJInfo>();
         }
     }
 }