shroom
shroom copied to clipboard
+ Avatar - onStopMovementCallback
This lets queue walk command after walk with something like:
this.room.onTileClick = async (position) => {
this.ownAvatar.clearMovement();
const path = await this.findPath(position);
if (path.length > 0) {
this.queueAnimation(path, 0);
}
};
queueAnimation (waypoints, i) {
const waypoint = waypoints[i];
this.ownAvatar.onStopMovementCallback = undefined;
this.ownAvatar.walk(waypoint.roomX, waypoint.roomY, waypoint.roomZ, {direction: waypoint.direction});
i++;
if (typeof waypoints[i] !== "undefined") {
this.ownAvatar.onStopMovementCallback = (e) => {
this.queueAnimation(waypoints, i);
};
} else {
this.ownAvatar.onStopMovementCallback = undefined;
}
}
