visibles<T extends GameComponent> method
Used to get visible "Components".
Implementation
@override
Iterable<T> visibles<T extends GameComponent>() {
final cached = _visibleComponentsCache[T];
final cachedFrame = _visibleComponentsCacheFrame[T];
if (cached != null && cachedFrame == _frameCounter) {
return cached.cast<T>();
}
// Rebuild cache for this type for the current frame.
final rebuilt = world.children
.whereType<T>()
.where((e) => e.isVisible)
.toList(growable: false);
_visibleComponentsCache[T] = rebuilt.cast<GameComponent>();
_visibleComponentsCacheFrame[T] = _frameCounter;
return rebuilt;
}