`ComponentParticle` fails with `CircleComponent`
Current bug behavior
When using a CircleComponent with ComponentParticle, an exceptions gets raised for CircleComponent._centerOffset not being initialized. This happens because components added to ComponentParticle are not really part of the component tree. This mean they never get correctly loaded and mounted. ComponentParticle only makes sure to invoke the render and update method of the component that it encapsulates, essentially skipping all the standard component lifecycle processing.
Expected behavior
CircleComponent, should work with ComponentParticle. Ideally any kind of component should working with ComponentParticle.
Steps to reproduce
Adding following code to any game should reproduce the problem.
await add(
ParticleSystemComponent(
particle: ComponentParticle(component: CircleComponent(radius: 2)),
),
);
Flutter doctor output
Output of: flutter doctor -v
N.A.
More environment information
Flame version: 1.14.0 Platform affected: All
Log information
════════ Exception caught by rendering library ═════════════════════════════════
The following LateError was thrown during paint():
LateInitializationError: Field '_centerOffset@1199492026' has not been initialized.
More information
I can only think of converting the Particle class into a Component to make it work properly for all components. This sounds like a big change and I probably won't have enough time to working on this, so reporting this issue.
But there are more such component-like classes which I think need to be streamlined. EffectController is one such example where they need to be ticked every frame.
Hmm, good catch. I don't think we'd want to convert particle to a real component since they are much heavier and you might have thousands of particles. Not sure what a good solution here could be.