init method
bool
init(
- CoreContext core
)
inherited
Implementation
@override
bool init(CoreContext core) {
this.core = core;
_clearLayerControllers();
for (final layer in stateMachine.layers) {
layerControllers.add(LayerController(
this,
layer,
core: core,
onLayerStateChange: _onStateChange,
));
}
// Make sure triggers are all reset.
advanceInputs();
// Initialize all events.
HashMap<Shape, _HitShape> hitShapeLookup = HashMap<Shape, _HitShape>();
for (final event in stateMachine.listeners) {
if (event is StateMachineListener) {
// Resolve target on this artboard instance.
var node = core.resolve<Node>(event.targetId);
if (node == null) {
continue;
}
node.forAll((component) {
if (component is Shape) {
var hitShape = hitShapeLookup[component];
if (hitShape == null) {
hitShapeLookup[component] = hitShape = _HitShape(component, this);
}
hitShape.events.add(event);
}
// Keep iterating so we find all shapes.
return true;
});
}
}
hitShapeLookup.values.toList().forEach(hitComponents.add);
_artboard = core as RuntimeArtboard;
if (_artboard != null) {
for (final nestedArtboard in _artboard!.activeNestedArtboards) {
if (nestedArtboard.hasNestedStateMachine) {
hitComponents.add(_HitNestedArtboard(nestedArtboard, this));
}
}
}
_sortHittableComponents();
return super.init(core);
}