private void updatePositions() { for (int i = 0; i < hammers.Count; i++) { DMSeismometerValues h = hammers.ElementAt(i).Value; if (h == null) { continue; } if (!h.Hammer) { h.removeAllSensors(); continue; } if (!h.Armed) { h.removeAllSensors(); continue; } if (h.ProtoPartRef == null) { h.removeAllSensors(); h.updateScore(); continue; } if (h.VesselRef == null) { h.removeAllSensors(); h.updateScore(); continue; } if (!h.VesselRef.LandedOrSplashed) { h.removeAllSensors(); h.updateScore(); continue; } for (int j = 0; j < seismometers.Count; j++) { DMSeismometerValues s = seismometers.ElementAt(j).Value; if (s == null) { continue; } if (s.Hammer) { removeSensors(h, s); continue; } if (!s.Armed) { removeSensors(h, s); continue; } if (s.ProtoPartRef == null) { removeSensors(h, s); continue; } if (s.VesselRef == null) { removeSensors(h, s); continue; } if (!s.VesselRef.LandedOrSplashed) { removeSensors(h, s); continue; } if (s.VesselRef == h.VesselRef) { removeSensors(h, s); continue; } double distance = Math.Abs((h.VesselRef.GetWorldPos3D() - s.VesselRef.GetWorldPos3D()).magnitude); if (distance > farPodMaxDistance + 1000) { removeSensors(h, s); continue; } else if (distance < farPodMaxDistance) { float angle = (float)DMUtils.bearing(h.VesselRef.latitude, h.VesselRef.longitude, s.VesselRef.latitude, s.VesselRef.longitude); h.addSensor(s.ID, new Vector2((float)distance, angle)); s.addSensor(h.ID, new Vector2()); } } h.updateScore(); } for (int j = 0; j < seismometers.Count; j++) { DMSeismometerValues s = seismometers.ElementAt(j).Value; if (s == null) { continue; } if (s.Hammer) { continue; } if (!s.Armed) { continue; } s.updateScore(); } }
public static void bearing(Vessel v, DMAnomalyObject a) { a.Bearing = DMUtils.bearing(v.latitude, v.longitude, a.Lat, a.Lon); }