Line data Source code
1 : import 'dart:ui'; 2 : 3 : import '../particles/particle.dart'; 4 : import 'component.dart'; 5 : 6 : /// Base container for [Particle] instances to be attach 7 : /// to a [Component] tree. Could be added either to BaseGame 8 : /// or an implementation of BaseComponent. 9 : /// Proxies [Component] lifecycle hooks to nested [Particle]. 10 : class ParticleComponent extends Component { 11 : Particle particle; 12 : 13 0 : ParticleComponent({ 14 : required this.particle, 15 : }); 16 : 17 : /// This [ParticleComponent] will be removed by the BaseGame. 18 0 : @override 19 0 : bool get shouldRemove => particle.shouldRemove; 20 : 21 : /// Returns progress of the child [Particle]. 22 : /// 23 : /// Could be used by external code if needed. 24 0 : double get progress => particle.progress; 25 : 26 : /// Passes rendering chain down to the inset 27 : /// [Particle] within this [Component]. 28 0 : @override 29 : void render(Canvas canvas) { 30 0 : particle.render(canvas); 31 : } 32 : 33 : /// Passes update chain to child [Particle]. 34 0 : @override 35 : void update(double dt) { 36 0 : super.update(dt); 37 0 : particle.update(dt); 38 : } 39 : }