public Map PrepareMap(string uid) { LoadScreen.Display(); if (!AvailableMaps.ContainsKey(uid)) { throw new InvalidDataException("Invalid map uid: {0}".F(uid)); } var map = new Map(AvailableMaps[uid].Path); // Reinit all our assets LoadInitialAssets(); foreach (var pkg in Manifest.Packages) { FileSystem.Mount(pkg); } // Mount map package so custom assets can be used. TODO: check priority. FileSystem.Mount(FileSystem.OpenPackage(map.Path, int.MaxValue)); Rules.LoadRules(Manifest, map); SpriteLoader = new SpriteLoader(Rules.TileSets[map.Tileset].Extensions, SheetBuilder); SequenceProvider.Initialize(Manifest.Sequences, map.Sequences); return(map); }
public Map PrepareMap(string uid) { LoadScreen.Display(); if (!AvailableMaps.ContainsKey(uid)) { throw new InvalidDataException("Invalid map uid: {0}".F(uid)); } var map = new Map(AvailableMaps[uid].Path); LoadTranslations(map); // Reinit all our assets InitializeLoaders(); FileSystem.LoadFromManifest(Manifest); // Mount map package so custom assets can be used. TODO: check priority. FileSystem.Mount(FileSystem.OpenPackage(map.Path, null, int.MaxValue)); Rules.LoadRules(Manifest, map); SpriteLoader = new SpriteLoader(Rules.TileSets[map.Tileset].Extensions, SheetBuilder); // TODO: Don't load the sequences for assets that are not used in this tileset. Maybe use the existing EditorTilesetFilters. SequenceProvider.Initialize(Manifest.Sequences, map.Sequences); VoxelProvider.Initialize(Manifest.VoxelSequences, map.VoxelSequences); return(map); }
public void StartGameAndLoadSecondMap() { // validate and set game settings bool didSet = UpdateGameSettings(); if (didSet == false) { // do not start game with invalid settings UserMessage = $"NOTE: Cannot apply custom game settings - {UserMessage}"; } Process.Start(SessionPath.ToSessionExe); if (LoadSecondMapIsChecked == false) { return; // do not continue as the second map does not need to be loaded } Task loadTask = Task.Factory.StartNew(() => { MapListItem mapToLoadNext = SecondMapToLoad; if (mapToLoadNext == null) { mapToLoadNext = AvailableMaps.Where(m => m.MapName == CurrentlyLoadedMapName).FirstOrDefault(); } int timeToWaitInMilliseconds = 20000; if (MapSwitcher is UnpackedMapSwitcher) { // wait longer for unpacked games to load since they load slower timeToWaitInMilliseconds = 25000; } System.Threading.Thread.Sleep(timeToWaitInMilliseconds); // wait few seconds before loading the next map to let the game finish loading LoadSelectedMap(mapToLoadNext); }); loadTask.ContinueWith((result) => { if (result.IsFaulted) { Logger.Warn(result.Exception.GetBaseException(), "failed to load second map"); return; } }); }
/// <inheritdoc/> /// <summary> /// Loads and lists all the available maps models from the cloud /// </summary> public async Task Initialize() { if (IsInitialized) { return; } var library = await ConnectionManager.API.GetLibrary <MapDetailData>(); var assetService = new AssetService(); var mapsInDatabase = assetService.List(BundleConfig.BundleTypes.Environment); var cachedMaps = mapsInDatabase as AssetModel[] ?? mapsInDatabase.ToArray(); foreach (var mapDetailData in library) { var newMap = new MapMetaData(mapDetailData.Id, mapDetailData.Name, mapDetailData.AssetGuid) { assetModel = cachedMaps.FirstOrDefault(cachedMap => cachedMap.AssetGuid == mapDetailData.AssetGuid) }; AvailableMaps.Add(newMap); } IsInitialized = true; Debug.Log($"{GetType().Name} scenario editor extension has been initialized."); }
public Map FindMapByUid(string uid) { return(AvailableMaps.ContainsKey(uid) ? AvailableMaps[uid] : null); }