public async Task GetFiles() { try { await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { _storageItems.Clear(); IsFolderEmpty = false; }); IReadOnlyList <IStorageItem> items = null; #if WINDOWS_APP var queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, VLCFileExtensions.Supported); var fileQuery = BackStack.Last().CreateItemQueryWithOptions(queryOptions); items = await fileQuery.GetItemsAsync(); #else items = await BackStack.Last().GetItemsAsync(); #endif await App.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { StorageItems = new ObservableCollection <IStorageItem>(items); OnPropertyChanged("StorageItems"); }); } catch (Exception exception) { LogHelper.Log("Failed to index folders and files in " + BackStack.Last().DisplayName + "\n" + exception.ToString()); } await App.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { OnPropertyChanged("CanGoBack"); IsFolderEmpty = !StorageItems.Any(); }); }
private async Task UpdateItems() { if (IsLoading) { return; } IsLoading = true; var items = await _query.GetItemsAsync(); if (items.SequenceEqual(StorageItems, new GenericComparer <IStorageItem>(item => item.Name))) { IsLoading = false; return; } await DispatcherHelper.ExecuteOnUIThreadAsync(() => { StorageItems.Clear(); foreach (var item in items) { StorageItems.Add(item); } }); IsLoading = false; }
public override async Task GetFiles() { try { await DispatchHelper.InvokeInUIThread(CoreDispatcherPriority.Normal, () => { StorageItems.Clear(); IsFolderEmpty = false; IsLoadingFiles = true; }); var currentMedia = BackStack.Last().Media; if (currentMedia == null) { return; } var mediaList = await Locator.MediaLibrary.DiscoverMediaList(currentMedia); for (int i = 0; i < mediaList.count(); i++) { var media = mediaList.itemAtIndex(i); IVLCStorageItem storageItem = null; if (media.type() == MediaType.Directory) { storageItem = new VLCStorageFolder(media); } else if (media.type() == MediaType.File) { storageItem = new VLCStorageFile(media); } if (storageItem == null) { return; } await DispatchHelper.InvokeInUIThread(CoreDispatcherPriority.Normal, () => StorageItems.Add(storageItem)); } await DispatchHelper.InvokeInUIThread(CoreDispatcherPriority.Low, () => { OnPropertyChanged(nameof(StorageItems)); IsFolderEmpty = !StorageItems.Any(); IsLoadingFiles = false; }); } catch (Exception e) { Debug.WriteLine($"Exception when getting network files {e.ToString()}"); } }
public override async Task GetFiles() { try { await DispatchHelper.InvokeAsync(CoreDispatcherPriority.Normal, () => { StorageItems.Clear(); IsFolderEmpty = false; IsLoadingFiles = true; }); IReadOnlyList <IStorageItem> items = null; var queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, VLCFileExtensions.Supported); var fileQuery = (BackStack.Last().StorageItem as StorageFolder).CreateItemQueryWithOptions(queryOptions); items = await fileQuery.GetItemsAsync(); var vlcItems = new ObservableCollection <IVLCStorageItem>(); foreach (var storageItem in items) { if (storageItem.IsOfType(StorageItemTypes.File)) { var file = new VLCStorageFile(storageItem as StorageFile); vlcItems.Add(file); } else if (storageItem.IsOfType(StorageItemTypes.Folder)) { var folder = new VLCStorageFolder(storageItem as StorageFolder); vlcItems.Add(folder); } } await DispatchHelper.InvokeAsync(CoreDispatcherPriority.Low, () => { StorageItems = new ObservableCollection <IVLCStorageItem>(vlcItems); OnPropertyChanged(nameof(StorageItems)); IsFolderEmpty = !StorageItems.Any(); IsLoadingFiles = false; }); } catch (Exception exception) { LogHelper.Log("Failed to index folders and files in " + BackStack.Last().Name + "\n" + exception.ToString()); await DispatchHelper.InvokeAsync(CoreDispatcherPriority.Low, () => { IsFolderEmpty = !StorageItems.Any(); IsLoadingFiles = false; }); } }
public static void Revive() { if (health <= 0) { FillHealth(); FillOxygene(); FillEnergy(); inventoryUsables = new StorageUsables(inventoryUsablesSize); inventoryItems = new StorageItems(inventoryItemsSize); inventoryLiquids = new StorageLiquids(inventoryLiquidsSize); inventoryBuildings = new StorageBuildings(inventoryBuildingsSize); UsableSelected = Usable.Type.Laser; BuildingSelected = Building.Type.SolarPanel; PlayerMouvements.Teleport(World.spawn.x, World.spawn.y); PlayerMouvements.canMove = true; } }
/// <summary> /// Spawns an instance of the room from prototype and adds it to the cache. /// </summary> /// <param name="withEntities">Whether to also spawn contained entities</param> /// <param name="parent">The parent area instance ID</param> /// <returns>The instance ID of the spawned room. Will return null if the method is called from an instanced object.</returns> /// <remarks>Exits will all be null and must be fixed from prototype. Parent cannot be null. Adds new room to instanced area.</remarks> public override uint?Spawn(bool withEntities, uint parent) { if (CacheType != CacheType.Prototype) { return(null); } var parentContainer = DataAccess.Get <EntityContainer>(parent, CacheType.Instance); var parentArea = DataAccess.Get <Area>(parentContainer.InstanceParent, CacheType.Instance); if (parentContainer == null || parentArea == null) { throw new LocaleException("Parent cannot be null when spawning a room."); } Logger.Info(nameof(Room), nameof(Spawn), "Spawning room: " + Name + ": ProtoID=" + Prototype.ToString()); // Create new instance room and add to parent area var newRoom = DataAccess.Get <Room>(DataAccess.Add <Room>(new Room(), CacheType.Instance), CacheType.Instance); parentArea.Rooms.AddEntity(newRoom.Instance, newRoom, false); // Set remaining properties newRoom.Prototype = Prototype; CopyTo(newRoom); // Spawn contained entities if (withEntities) { newRoom.Animates = Animates.SpawnAsObject <EntityContainer>(!withEntities, (uint)newRoom.Instance); foreach (var animate in Animates.GetAllEntitiesAsObjects <EntityAnimate>()) { animate.Spawn(withEntities, (uint)newRoom.Animates.Instance); } newRoom.Items = Items.SpawnAsObject <EntityContainer>(!withEntities, (uint)newRoom.Instance); foreach (var item in Items.GetAllEntitiesAsObjects <EntityInanimate>()) { item.Spawn(withEntities, (uint)newRoom.Items.Instance); } newRoom.ShopItems = ShopItems.SpawnAsObject <EntityContainer>(!withEntities, (uint)newRoom.Instance); foreach (var item in ShopItems.GetAllEntitiesAsObjects <EntityInanimate>()) { item.Spawn(withEntities, (uint)newRoom.ShopItems.Instance); } newRoom.StorageItems = StorageItems.SpawnAsObject <EntityContainer>(!withEntities, (uint)newRoom.Instance); foreach (var item in StorageItems.GetAllEntitiesAsObjects <EntityInanimate>()) { item.Spawn(withEntities, (uint)newRoom.StorageItems.Instance); } } else { newRoom.Animates = Animates.SpawnAsObject <EntityContainer>(!withEntities, (uint)newRoom.Instance); newRoom.Items = Items.SpawnAsObject <EntityContainer>(!withEntities, (uint)newRoom.Instance); newRoom.ShopItems = ShopItems.SpawnAsObject <EntityContainer>(!withEntities, (uint)newRoom.Instance); newRoom.StorageItems = StorageItems.SpawnAsObject <EntityContainer>(!withEntities, (uint)newRoom.Instance); } Logger.Info(nameof(Room), nameof(Spawn), "Finished spawning room."); return(newRoom.Instance); }