/// <summary> /// Forcefully updates a vessel position /// </summary> public void ForceUpdateVesselPosition(Guid vesselId) { if (CurrentVesselUpdate.TryGetValue(vesselId, out var posUpdate)) { posUpdate.UpdateVesselWithPositionData(); } }
/// <summary> /// Gets the latest received ref body of a vessel /// </summary> public int GetLatestVesselRefBody(Guid vesselId) { return(TargetVesselUpdate.TryGetValue(vesselId, out var vesselPosition) ? vesselPosition.BodyIndex : CurrentVesselUpdate.TryGetValue(vesselId, out vesselPosition) ? vesselPosition.BodyIndex : int.MinValue); }
/// <summary> /// Gets the latest received position of a vessel /// </summary> public double[] GetLatestVesselPosition(Guid vesselId) { return(TargetVesselUpdate.TryGetValue(vesselId, out var vesselPosition) ? vesselPosition.LatLonAlt : CurrentVesselUpdate.TryGetValue(vesselId, out vesselPosition) ? vesselPosition.LatLonAlt : null); }
/// <summary> /// Gets the latest received position of a vessel /// </summary> public double[] GetLatestVesselPosition(Guid vesselId) { if (CurrentVesselUpdate.TryGetValue(vesselId, out var vesselPos)) { var fullData = new double[vesselPos.LatLonAlt.Length + vesselPos.Orbit.Length]; vesselPos.LatLonAlt.CopyTo(fullData, 0); vesselPos.Orbit.CopyTo(fullData, vesselPos.LatLonAlt.Length); return(fullData); } return(null); }
/// <summary> /// Read and apply position updates from other vessels /// </summary> private void HandleVesselUpdates() { if (PositionUpdateSystemReady) { foreach (var vesselId in UpdatedVesselIds.Keys) { if (CurrentVesselUpdate.TryGetValue(vesselId, out VesselPositionUpdate currentUpdate)) { //NOTE: ApplyVesselUpdate must run in FixedUpdate as it's updating the physics of the vessels currentUpdate.ApplyVesselUpdate(); } UpdatedVesselIds.TryRemove(vesselId, out var _); } } }