@@ -38,8 +38,6 @@ internal sealed class MsfsPointController : BackgroundService, IPointStateListen
3838 private readonly int _disconnectedDelayMs ;
3939 private readonly int _errorBackoffMs ;
4040 private readonly double _spawnRadiusMeters ;
41- private readonly TimeSpan _proximitySweepInterval ;
42- private DateTime _nextProximitySweepUtc = DateTime . UtcNow ;
4341 private readonly bool _dynamicPruneEnabled ;
4442
4543 // Distance-based streaming config
@@ -118,7 +116,6 @@ public MsfsPointController(IEnumerable<ISimulatorConnector> connectors,
118116 _disconnectedDelayMs = options . DisconnectedDelayMs ;
119117 _errorBackoffMs = options . ErrorBackoffMs ;
120118 _spawnRadiusMeters = options . SpawnRadiusMeters ;
121- _proximitySweepInterval = TimeSpan . FromSeconds ( options . ProximitySweepSeconds ) ;
122119 _dynamicPruneEnabled = options . DynamicPruneEnabled ;
123120
124121 // Distance-based streaming config
@@ -229,11 +226,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
229226 {
230227 await Task . Delay ( _idleDelayMs , stoppingToken ) ;
231228 }
232- if ( DateTime . UtcNow >= _nextProximitySweepUtc )
233- {
234- _nextProximitySweepUtc = DateTime . UtcNow + _proximitySweepInterval ;
235- try { await ProximitySweepAsync ( stoppingToken ) ; } catch ( Exception ex ) { _logger . LogDebug ( ex , "ProximitySweep failed" ) ; }
236- }
229+ // Old proximity sweep removed - now handled by EvaluateAndScheduleActions
237230 if ( ( DateTime . UtcNow - _lastSummary ) > TimeSpan . FromSeconds ( 30 ) )
238231 {
239232 _lastSummary = DateTime . UtcNow ;
@@ -1226,49 +1219,6 @@ private async Task DespawnPointAsync(string pointId, CancellationToken ct)
12261219 _logger . LogInformation ( "[DespawnPoint] {id} removed={removed} activeLights={active}" , pointId , list . Count , TotalActiveLightCount ( ) ) ;
12271220 }
12281221
1229- // Perform ordering & pruning based on aircraft proximity.
1230- private Task ProximitySweepAsync ( CancellationToken ct )
1231- {
1232- var flight = _simManager . LatestState ;
1233- if ( flight == null ) return Task . CompletedTask ;
1234- // Build active point set via manager
1235- var activePointIds = new HashSet < string > ( StringComparer . Ordinal ) ;
1236- var mgr = GetManager ( ) ;
1237- if ( mgr != null )
1238- {
1239- foreach ( var o in mgr . ManagedObjects . Values )
1240- {
1241- if ( ! o . IsActive ) continue ;
1242- if ( TryGetUserPointAndSlot ( o , out var pid , out var _slot ) && pid != null )
1243- activePointIds . Add ( pid ) ;
1244- }
1245- }
1246- // Radius-based despawn removed: keep all previously spawned objects; rely on global caps for safety.
1247- // Identify spawn candidates
1248- var candidates = new List < ( PointState State , double Dist ) > ( ) ;
1249- foreach ( var kv in _latestStates )
1250- {
1251- var st = kv . Value ;
1252- if ( ! st . IsOn ) continue ;
1253- var dist = DistanceMeters ( flight . Latitude , flight . Longitude , st . Metadata . Latitude , st . Metadata . Longitude ) ;
1254- // Distance requirement removed; include all ON points (distance retained only for ordering)
1255- var ( objs , _) = GetPointObjects ( st . Metadata . Id ) ;
1256- var layouts = GetOrBuildLayouts ( st ) ;
1257- if ( objs . Count >= layouts . Count ) continue ;
1258- candidates . Add ( ( st , dist ) ) ;
1259- }
1260- if ( candidates . Count == 0 ) return Task . CompletedTask ;
1261- // Order by distance (closest first)
1262- foreach ( var c in candidates . OrderBy ( c => c . Dist ) )
1263- {
1264- if ( ct . IsCancellationRequested ) break ;
1265- if ( TotalActiveLightCount ( ) >= _maxObjects ) break ;
1266- _queue . Enqueue ( c . State ) ; // enqueue for ProcessAsync which will respect cap & rate
1267- }
1268- _logger . LogTrace ( "[ProximityEnqueue] added={count} queue={q}" , candidates . Count , _queue . Count ) ;
1269- return Task . CompletedTask ;
1270- }
1271-
12721222 private static double ? NormalizeHeading ( double headingDeg )
12731223 {
12741224 if ( double . IsNaN ( headingDeg ) || double . IsInfinity ( headingDeg ) ) return null ;
@@ -1538,7 +1488,6 @@ internal sealed class MsfsPointControllerOptions
15381488 public int ErrorBackoffMs { get ; init ; } = 200 ;
15391489 public int OverlapDespawnDelayMs { get ; init ; } = 1000 ;
15401490 public double SpawnRadiusMeters { get ; init ; } = 8000 ;
1541- public int ProximitySweepSeconds { get ; init ; } = 5 ;
15421491 public bool DynamicPruneEnabled { get ; init ; } = true ;
15431492
15441493 // Distance-based streaming parameters
0 commit comments