build method
Implementation
Future<WorldBuildData> build() async {
try {
_tiledMap = await reader.readMap();
if (_tiledMap?.orientation != _mapOrientationSupported) {
throw Exception(
'Bonfire have only suport to $_mapOrientationSupported orientation.',
);
}
_tileWidthOrigin = _tiledMap?.tileWidth?.toDouble() ?? 0.0;
_tileHeightOrigin = _tiledMap?.tileHeight?.toDouble() ?? 0.0;
_tileWidth = forceTileSize?.x ?? _tileWidthOrigin;
_tileHeight = forceTileSize?.y ?? _tileHeightOrigin;
await _load(_tiledMap!);
} catch (e) {
onError?.call(e);
// ignore: avoid_print
print('(TiledWorldBuilder) Error: $e');
}
return Future.value(
WorldBuildData(
map: WorldMap(
_layers.where((e) => e.tiles.isNotEmpty).toList(),
tileSizeToUpdate: sizeToUpdate,
),
components: _components,
),
);
}