private void UpdateLegacyAircraftConfig(NetworkAircraft aircraft) { LegacyClientConfigFlags flags = new LegacyClientConfigFlags { EnginesRunning = true, BeaconLightsOn = true, NavLightsOn = true }; if (aircraft.GroundSpeed >= 50.0) { flags.StrobeLightsOn = true; flags.TaxiLightsOn = false; flags.LandingLightsOn = aircraft.CurrentPosition.Altitude <= 10000 ? true : false; } else if (aircraft.GroundSpeed > 0.0) { flags.TaxiLightsOn = true; flags.StrobeLightsOn = false; flags.LandingLightsOn = false; } else { flags.StrobeLightsOn = false; flags.LandingLightsOn = false; flags.TaxiLightsOn = false; } flags.OnGround = aircraft.CurrentPosition.Altitude == aircraft.PreviousPosition.Altitude; flags.GearDown = DeriveGearStatus(aircraft); UpdateLegacyAircraftConfig(aircraft, flags); }
private void UpdateLegacyAircraftConfig(NetworkAircraft aircraft, LegacyClientConfigFlags flags) { NetworkAircraftConfig temp = new NetworkAircraftConfig { Callsign = aircraft.Callsign, Timestamp = DateTime.Now, }; if (!aircraft.InitialConfigurationSet) { temp.GearDown = flags.GearDown; temp.OnGround = flags.OnGround; temp.Lights.TaxiOn = flags.TaxiLightsOn; temp.Lights.LandingOn = flags.LandingLightsOn; temp.Lights.BeaconOn = flags.BeaconLightsOn; temp.Lights.NavOn = flags.NavLightsOn; temp.Lights.StrobesOn = flags.StrobeLightsOn; temp.EnginesOn = flags.EnginesRunning; aircraft.InitialConfigurationSet = true; } else { if (flags.GearDown != aircraft.LastAppliedConfigFlags.GearDown) { temp.GearDown = flags.GearDown; } if (flags.OnGround != aircraft.LastAppliedConfigFlags.OnGround) { temp.OnGround = flags.OnGround; } if (flags.TaxiLightsOn != aircraft.LastAppliedConfigFlags.TaxiLightsOn) { temp.Lights.TaxiOn = flags.TaxiLightsOn; } if (flags.LandingLightsOn != aircraft.LastAppliedConfigFlags.LandingLightsOn) { temp.Lights.LandingOn = flags.LandingLightsOn; } if (flags.BeaconLightsOn != aircraft.LastAppliedConfigFlags.BeaconLightsOn) { temp.Lights.BeaconOn = flags.BeaconLightsOn; } if (flags.NavLightsOn != aircraft.LastAppliedConfigFlags.NavLightsOn) { temp.Lights.NavOn = flags.NavLightsOn; } if (flags.EnginesRunning != aircraft.LastAppliedConfigFlags.EnginesRunning) { temp.EnginesOn = flags.EnginesRunning; } } aircraft.LastAppliedConfigFlags = flags; if (temp.HasConfig) { XplaneConnect msg = new XplaneConnect { Type = XplaneConnect.MessageType.SurfaceUpdate, Timestamp = DateTime.Now, Data = temp }; XPlaneEventPosted?.Invoke(this, new ClientEventArgs <string>(msg.ToJSON())); Console.WriteLine($"Sending Legacy Config to the sim for: {aircraft.Callsign} - {msg.ToJSON()}"); } }