jankuss / shroom

Room Rendering Engine for Retros
https://jankuss.github.io/shroom/docs
GNU Lesser General Public License v3.0
62 stars 28 forks source link

+ Avatar - onStopMovementCallback #136

Open tetreum opened 1 year ago

tetreum commented 1 year ago

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;
      }
    }

image