seeAndMoveToAlly method
void
seeAndMoveToAlly({
- required dynamic closeAlly(),
- VoidCallback? notObserved,
- VoidCallback? observed,
- double radiusVision = 32,
- double margin = 10,
- bool runOnlyVisibleInScreen = true,
Checks whether the ally is within range. If so, move to it.
Implementation
void seeAndMoveToAlly({
required Function(Ally) closeAlly,
VoidCallback? notObserved,
VoidCallback? observed,
double radiusVision = 32,
double margin = 10,
bool runOnlyVisibleInScreen = true,
}) {
if (runOnlyVisibleInScreen && !this.isVisible) return;
seeComponentType<Ally>(
radiusVision: radiusVision,
observed: (ally) {
observed?.call();
this.followComponent(
ally.first,
dtUpdate,
closeComponent: (comp) => closeAlly(comp as Ally),
margin: margin,
);
},
notObserved: () {
if (!this.isIdle) {
this.idle();
}
notObserved?.call();
},
);
}