public static void PingRWR(Vessel v, Vector3 source, RWRThreatTypes type, float persistTime) { if (OnRadarPing != null) { OnRadarPing(v, source, type, persistTime); } }
public static void PingRWR(Vessel v, Vector3 source, RWRThreatTypes type, float persistTime) { if(OnRadarPing != null) { OnRadarPing(v, source, type, persistTime); } }
void PlayWarningSound(RWRThreatTypes type) { if (vessel.isActiveVessel) { switch (type) { case RWRThreatTypes.MissileLaunch: audioSource.Stop(); audioSource.clip = missileLaunchSound; audioSource.Play(); break; case RWRThreatTypes.MissileLock: if (audioSource.clip == missileLaunchSound && audioSource.isPlaying) { break; } audioSource.Stop(); audioSource.clip = (missileLockSound); audioSource.Play(); break; default: if (!audioSource.isPlaying) { audioSource.clip = (radarPingSound); audioSource.Play(); } break; } } }
void PlayWarningSound(RWRThreatTypes type, float sqrDistance = 0f) { if (vessel.isActiveVessel && audioSourceRepeatDelay <= 0f) { switch (type) { case RWRThreatTypes.MissileLaunch: if (audioSource.isPlaying) { break; } audioSource.clip = missileLaunchSound; audioSource.Play(); break; case RWRThreatTypes.Sonar: if (audioSource.isPlaying) { break; } audioSource.clip = sonarPing; audioSource.Play(); break; case RWRThreatTypes.Torpedo: case RWRThreatTypes.TorpedoLock: if (audioSource.isPlaying) { break; } torpedoPingPitch = Mathf.Lerp(1.5f, 1.0f, sqrDistance / (2000 * 2000)); //within 2km increase ping pitch audioSource.Stop(); audioSource.clip = torpedoPing; audioSource.pitch = torpedoPingPitch; audioSource.Play(); audioSourceRepeatDelay = audioSourceRepeatDelayTime; //set a min repeat delay to prevent too much audi pinging break; case RWRThreatTypes.MissileLock: if (audioSource.isPlaying) { break; } audioSource.clip = (missileLockSound); audioSource.Play(); audioSourceRepeatDelay = audioSourceRepeatDelayTime; //set a min repeat delay to prevent too much audi pinging break; default: if (!audioSource.isPlaying) { audioSource.clip = (radarPingSound); audioSource.Play(); audioSourceRepeatDelay = audioSourceRepeatDelayTime; //set a min repeat delay to prevent too much audi pinging } break; } } }
public static void PingRWR(Ray ray, float fov, RWRThreatTypes type, float persistTime) { foreach (var vessel in FlightGlobals.Vessels) { if (vessel.loaded) { Vector3 dirToVessel = vessel.transform.position - ray.origin; if (Vector3.Angle(ray.direction, dirToVessel) < fov / 2) { PingRWR(vessel, ray.origin, type, persistTime); } } } }
public static void PingRWR(Ray ray, float fov, RWRThreatTypes type, float persistTime) { foreach(var vessel in FlightGlobals.Vessels) { if(vessel.loaded) { Vector3 dirToVessel = vessel.transform.position - ray.origin; if(Vector3.Angle(ray.direction, dirToVessel) < fov / 2) { PingRWR(vessel, ray.origin, type, persistTime); } } } }
public static void PingRWR(Ray ray, float fov, RWRThreatTypes type, float persistTime) { using (var vessel = FlightGlobals.Vessels.GetEnumerator()) while (vessel.MoveNext()) { if (vessel.Current == null || !vessel.Current.loaded) { continue; } Vector3 dirToVessel = vessel.Current.transform.position - ray.origin; if (Vector3.Angle(ray.direction, dirToVessel) < fov / 2) { PingRWR(vessel.Current, ray.origin, type, persistTime); } } }
void ReceivePing(Vessel v, Vector3 source, RWRThreatTypes type, float persistTime) { if (rwrEnabled && vessel && v == vessel) { if (type == RWRThreatTypes.MissileLaunch) { StartCoroutine(LaunchWarningRoutine(new TargetSignatureData(Vector3.zero, RadarUtils.WorldToRadar(source, referenceTransform, displayRect, rwrDisplayRange), Vector3.zero, true, (float)type))); PlayWarningSound(type); return; } else if (type == RWRThreatTypes.MissileLock) { if (!BDArmorySettings.ALLOW_LEGACY_TARGETING && weaponManager && weaponManager.guardMode) { weaponManager.FireChaff(); } } int openIndex = -1; for (int i = 0; i < dataCount; i++) { if (pingsData[i].exists && ((Vector2)pingsData[i].position - RadarUtils.WorldToRadar(source, referenceTransform, displayRect, rwrDisplayRange)).sqrMagnitude < Mathf.Pow(20, 2)) { break; } if (!pingsData[i].exists && openIndex == -1) { openIndex = i; } } if (openIndex >= 0) { referenceTransform.rotation = Quaternion.LookRotation(vessel.ReferenceTransform.up, VectorUtils.GetUpDirection(transform.position)); pingsData[openIndex] = new TargetSignatureData(Vector3.zero, RadarUtils.WorldToRadar(source, referenceTransform, displayRect, rwrDisplayRange), Vector3.zero, true, (float)type); pingWorldPositions[openIndex] = source; StartCoroutine(PingLifeRoutine(openIndex, persistTime)); PlayWarningSound(type); } } }
void ReceivePing(Vessel v, Vector3 source, RWRThreatTypes type, float persistTime) { if (v == null) { return; } if (referenceTransform == null) { return; } if (weaponManager == null) { return; } if (rwrEnabled && vessel && v == vessel) { //if we are airborne or on land, no Sonar or SLW type weapons on the RWR! if ((type == RWRThreatTypes.Torpedo || type == RWRThreatTypes.TorpedoLock || type == RWRThreatTypes.Sonar) && (vessel.situation != Vessel.Situations.SPLASHED)) { // rwr stays silent... return; } if (type == RWRThreatTypes.MissileLaunch || type == RWRThreatTypes.Torpedo) { StartCoroutine( LaunchWarningRoutine(new TargetSignatureData(Vector3.zero, RadarUtils.WorldToRadar(source, referenceTransform, RwrDisplayRect, rwrDisplayRange), Vector3.zero, true, (float)type))); PlayWarningSound(type, (source - vessel.transform.position).sqrMagnitude); return; } else if (type == RWRThreatTypes.MissileLock) { if (weaponManager && weaponManager.guardMode) { weaponManager.FireChaff(); // TODO: if torpedo inbound, also fire accoustic decoys (not yet implemented...) } } int openIndex = -1; for (int i = 0; i < dataCount; i++) { if (pingsData[i].exists && ((Vector2)pingsData[i].position - RadarUtils.WorldToRadar(source, referenceTransform, RwrDisplayRect, rwrDisplayRange)).sqrMagnitude < 900f) //prevent ping spam { break; } if (!pingsData[i].exists && openIndex == -1) { openIndex = i; } } if (openIndex >= 0) { referenceTransform.rotation = Quaternion.LookRotation(vessel.ReferenceTransform.up, VectorUtils.GetUpDirection(transform.position)); pingsData[openIndex] = new TargetSignatureData(Vector3.zero, RadarUtils.WorldToRadar(source, referenceTransform, RwrDisplayRect, rwrDisplayRange), Vector3.zero, true, (float)type); // HACK! Evil misuse of signalstrength for the threat type! pingWorldPositions[openIndex] = source; StartCoroutine(PingLifeRoutine(openIndex, persistTime)); PlayWarningSound(type, (source - vessel.transform.position).sqrMagnitude); } } }
void ReceivePing(Vessel v, Vector3 source, RWRThreatTypes type, float persistTime) { if(rwrEnabled && vessel && v == vessel) { if(type == RWRThreatTypes.MissileLaunch) { StartCoroutine(LaunchWarningRoutine(new TargetSignatureData(Vector3.zero, RadarUtils.WorldToRadar(source, referenceTransform, displayRect, rwrDisplayRange), Vector3.zero, true, (float)type))); PlayWarningSound(type); return; } else if(type == RWRThreatTypes.MissileLock) { if(!BDArmorySettings.ALLOW_LEGACY_TARGETING && weaponManager && weaponManager.guardMode) { weaponManager.FireChaff(); } } int openIndex = -1; for(int i = 0; i < dataCount; i++) { if(pingsData[i].exists && ((Vector2)pingsData[i].position - RadarUtils.WorldToRadar(source, referenceTransform, displayRect, rwrDisplayRange)).sqrMagnitude < Mathf.Pow(20, 2)) { break; } if(!pingsData[i].exists && openIndex == -1) { openIndex = i; } } if(openIndex >= 0) { referenceTransform.rotation = Quaternion.LookRotation(vessel.ReferenceTransform.up, VectorUtils.GetUpDirection(transform.position)); pingsData[openIndex] = new TargetSignatureData(Vector3.zero, RadarUtils.WorldToRadar(source, referenceTransform, displayRect, rwrDisplayRange), Vector3.zero, true, (float)type); pingWorldPositions[openIndex] = source; StartCoroutine(PingLifeRoutine(openIndex, persistTime)); PlayWarningSound(type); } } }
void PlayWarningSound(RWRThreatTypes type) { if(vessel.isActiveVessel) { switch(type) { case RWRThreatTypes.MissileLaunch: audioSource.Stop(); audioSource.clip = missileLaunchSound; audioSource.Play(); break; case RWRThreatTypes.MissileLock: if(audioSource.clip == missileLaunchSound && audioSource.isPlaying) break; audioSource.Stop(); audioSource.clip = (missileLockSound); audioSource.Play(); break; default: if(!audioSource.isPlaying) { audioSource.clip = (radarPingSound); audioSource.Play(); } break; } } }