private void CreateNewAIAircraft(TrafficPositionReportMessage trafficPositionReportMessage) { uint counter; lock (AICounterLock) { counter = AICounter++; } AICounterToCallsignMap.Add(counter, trafficPositionReportMessage.Sender); try { // TODO: OnGround + airspeed var initpos = new SIMCONNECT_DATA_INITPOSITION() { Altitude = trafficPositionReportMessage.TrueAltitude, Bank = -trafficPositionReportMessage.BankAngle, Heading = trafficPositionReportMessage.Heading, Latitude = trafficPositionReportMessage.Latitude, Longitude = trafficPositionReportMessage.Longitude, Pitch = -trafficPositionReportMessage.Pitch, OnGround = 1, Airspeed = 0 }; simconnect.AICreateNonATCAircraft(GetRepaintTitle(), trafficPositionReportMessage.Sender, initpos, (SIMCONNECT_EVENTS)((uint)SIMCONNECT_EVENTS.EVENTID_SETAIAC + counter)); // simconnect.AICreateSimulatedObject(GetRepaintTitle(), initpos, (SIMCONNECT_EVENTS)((uint)SIMCONNECT_EVENTS.EVENTID_SETAIAC + counter)); var aiplane = new AIPlane(trafficPositionReportMessage.Sender); aiplane.SetTargetWaypoint(CreateWaypointFromTrafficPositionReportMsg(trafficPositionReportMessage)); aiplane.AICounter = counter; CallsignToAIPlaneMap.Add(aiplane.Callsign, aiplane); } catch (COMException e) { Logger.Error("SimConnectInterface.CreateNewAIAircraft: " + e); } }