getTile method

TileComponent getTile()

Implementation

TileComponent getTile() {
  if (animation == null) {
    if (collisions?.isNotEmpty == true) {
      final tile = TileWithCollision.fromSprite(
        sprite: sprite?.getSprite(),
        position: Vector2(x, y),
        size: Vector2(width, height),
        offsetX: offsetX,
        offsetY: offsetY,
        collisions: collisions,
        tileClass: tileClass,
        properties: properties,
        color: color,
      );
      _setOtherParams(tile);
      return tile;
    } else {
      final tile = TileComponent.fromSprite(
        sprite: sprite?.getSprite(),
        position: Vector2(x, y),
        size: Vector2(width, height),
        offsetX: offsetX,
        offsetY: offsetY,
        tileClass: tileClass,
        properties: properties,
        color: color,
      );
      _setOtherParams(tile);

      return tile;
    }
  } else {
    if (collisions?.isNotEmpty == true) {
      ControlledUpdateAnimation animationControlled =
          animation!.getSpriteControlledAnimation();
      final tile = TileWithCollision.withAnimation(
        animation: animationControlled,
        position: Vector2(x, y),
        size: Vector2(width, height),
        offsetX: offsetX,
        offsetY: offsetY,
        collisions: collisions,
        tileClass: tileClass,
        properties: properties,
      );
      _setOtherParams(tile);

      return tile;
    } else {
      ControlledUpdateAnimation animationControlled =
          animation!.getSpriteControlledAnimation();
      final tile = TileComponent.fromAnimation(
        animation: animationControlled,
        position: Vector2(x, y),
        size: Vector2(width, height),
        offsetX: offsetX,
        offsetY: offsetY,
        tileClass: tileClass,
        properties: properties,
      );
      _setOtherParams(tile);

      return tile;
    }
  }
}