public void EnableRadar() { EnsureVesselRadarData(); radarEnabled = true; var mf = VesselModuleRegistry.GetMissileFire(vessel, true); if (mf != null && vesselRadarData != null) { vesselRadarData.weaponManager = mf; } UpdateToggleGuiName(); vesselRadarData.AddRadar(this); }
void RefreshFriendlies() { if (!weaponManager) { return; } friendlies = new List <IBDAIControl>(); using (var vs = BDATargetManager.LoadedVessels.GetEnumerator()) while (vs.MoveNext()) { if (vs.Current == null) { continue; } if (!vs.Current.loaded || vs.Current == vessel || VesselModuleRegistry.ignoredVesselTypes.Contains(vs.Current.vesselType)) { continue; } IBDAIControl pilot = VesselModuleRegistry.GetIBDAIControl(vs.Current, true); if (pilot == null) { continue; } MissileFire wm = VesselModuleRegistry.GetMissileFire(vs.Current, true); if (wm == null || wm.Team != weaponManager.Team) { continue; } friendlies.Add(pilot); } //TEMPORARY wingmen = new List <IBDAIControl>(); using (var fs = friendlies.GetEnumerator()) while (fs.MoveNext()) { if (fs.Current == null) { continue; } wingmen.Add(fs.Current); } }
public IEnumerator PerformanceTest() { var wait = new WaitForSeconds(0.1f); { // Note: this test has significant GC allocations due to the allocation of an intermediate list. int count = 0; int iters = 100000; var startTime = Time.realtimeSinceStartup; for (int i = 0; i < iters; ++i) { foreach (var mf in FlightGlobals.ActiveVessel.FindPartModulesImplementing <MissileFire>()) { ++count; } } Debug.Log($"DEBUG {FlightGlobals.ActiveVessel} has {count / iters} weapon managers, checked at {iters / (Time.realtimeSinceStartup - startTime)}/s via vessel.FindPartModulesImplementing<MissileFire>()"); } yield return(wait); { int count = 0; int iters = 100000; var startTime = Time.realtimeSinceStartup; for (int i = 0; i < iters; ++i) { if (FlightGlobals.ActiveVessel.FindPartModuleImplementing <MissileFire>() != null) { ++count; } } Debug.Log($"DEBUG {FlightGlobals.ActiveVessel} has {count / iters} weapon managers, checked at {iters / (Time.realtimeSinceStartup - startTime)}/s via vessel.FindPartModuleImplementing<MissileFire>()"); } yield return(wait); { int count = 0; int iters = 10000000; var startTime = Time.realtimeSinceStartup; for (int i = 0; i < iters; ++i) { foreach (var mf in VesselModuleRegistry.GetModules <MissileFire>(FlightGlobals.ActiveVessel)) { ++count; } } Debug.Log($"DEBUG {FlightGlobals.ActiveVessel} has {count / iters} weapon managers, checked at {iters / (Time.realtimeSinceStartup - startTime)}/s via VesselModuleRegistry.GetModules<MissileFire>(vessel)"); } yield return(wait); { int count = 0; int iters = 10000000; var startTime = Time.realtimeSinceStartup; for (int i = 0; i < iters; ++i) { foreach (var mf in VesselModuleRegistry.GetMissileFires(FlightGlobals.ActiveVessel)) { ++count; } } Debug.Log($"DEBUG {FlightGlobals.ActiveVessel} has {count / iters} weapon managers, checked at {iters / (Time.realtimeSinceStartup - startTime)}/s via VesselModuleRegistry.GetMissileFires(vessel)"); } yield return(wait); { int count = 0; int iters = 10000000; var startTime = Time.realtimeSinceStartup; for (int i = 0; i < iters; ++i) { if (VesselModuleRegistry.GetModule <MissileFire>(FlightGlobals.ActiveVessel) != null) { ++count; } } Debug.Log($"DEBUG {FlightGlobals.ActiveVessel} has {count / iters} weapon managers, checked at {iters / (Time.realtimeSinceStartup - startTime)}/s via VesselModuleRegistry.GetModule<MissileFire>(vessel)"); } yield return(wait); { int count = 0; int iters = 10000000; var startTime = Time.realtimeSinceStartup; for (int i = 0; i < iters; ++i) { if (VesselModuleRegistry.GetModule <MissileFire>(FlightGlobals.ActiveVessel, true) != null) { ++count; } } Debug.Log($"DEBUG {FlightGlobals.ActiveVessel} has {count / iters} weapon managers, checked at {iters / (Time.realtimeSinceStartup - startTime)}/s via VesselModuleRegistry.GetModule<MissileFire>(vessel, true)"); } yield return(wait); { int count = 0; int iters = 10000000; var startTime = Time.realtimeSinceStartup; for (int i = 0; i < iters; ++i) { if (VesselModuleRegistry.GetMissileFire(FlightGlobals.ActiveVessel) != null) { ++count; } } Debug.Log($"DEBUG {FlightGlobals.ActiveVessel} has {count / iters} weapon managers, checked at {iters / (Time.realtimeSinceStartup - startTime)}/s via VesselModuleRegistry.GetMissileFire(vessel)"); } yield return(wait); { int count = 0; int iters = 10000000; var startTime = Time.realtimeSinceStartup; for (int i = 0; i < iters; ++i) { if (VesselModuleRegistry.GetMissileFire(FlightGlobals.ActiveVessel, true) != null) { ++count; } } Debug.Log($"DEBUG {FlightGlobals.ActiveVessel} has {count / iters} weapon managers, checked at {iters / (Time.realtimeSinceStartup - startTime)}/s via VesselModuleRegistry.GetMissileFire(vessel, true)"); } BDACompetitionMode.Instance.competitionStatus.Add("VesselModuleRegistry performance test complete."); }