import 'package:flutter/services.dart'; import 'package:wolf_3d_data/wolf_3d_data.dart'; class WolfMap { /// The fully parsed and decompressed levels from the game files. final List levels; final List textures; final List sprites; // A private constructor so we can only instantiate this from the async loader WolfMap._( this.levels, this.textures, this.sprites, ); /// Asynchronously loads the map files and parses them into a new WolfMap instance. static Future loadShareware() async { // 1. Load the binary data final mapHead = await rootBundle.load("assets/MAPHEAD.WL1"); final gameMaps = await rootBundle.load("assets/GAMEMAPS.WL1"); final vswap = await rootBundle.load("assets/VSWAP.WL1"); // 2. Parse the data using the parser we just built final parsedLevels = WLParser.parseMaps( mapHead, gameMaps, isShareware: true, ); final parsedTextures = WLParser.parseWalls(vswap); final parsedSprites = WLParser.parseSprites(vswap); // 3. Return the populated instance! return WolfMap._( parsedLevels, parsedTextures, parsedSprites, ); } /// Asynchronously loads the map files and parses them into a new WolfMap instance. static Future loadRetail() async { // 1. Load the binary data final mapHead = await rootBundle.load("assets/MAPHEAD.WL6"); final gameMaps = await rootBundle.load("assets/GAMEMAPS.WL6"); final vswap = await rootBundle.load("assets/VSWAP.WL6"); // 2. Parse the data using the parser we just built final parsedLevels = WLParser.parseMaps(mapHead, gameMaps); final parsedTextures = WLParser.parseWalls(vswap); final parsedSprites = WLParser.parseSprites(vswap); // 3. Return the populated instance! return WolfMap._( parsedLevels, parsedTextures, parsedSprites, ); } }