aboutsummaryrefslogtreecommitdiff
path: root/src/resources.rs
blob: 152a1494bfdaffa12bc4eeccd35d219a8a265ee6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::{collections::{BTreeMap, HashMap}, path::PathBuf};

use bevy::{ecs::world::CommandQueue, prelude::*, tasks::Task};
use multi_key_map::MultiKeyMap;
use occule::Codec;

use crate::payload::DirworldEntityPayload;

/// Root directory of the world
#[derive(Resource, Deref, DerefMut, Default)]
pub struct DirworldRootDir(pub Option<PathBuf>);

/// Current directory of the world
#[derive(Resource, Deref, DerefMut, Default)]
pub struct DirworldCurrentDir(pub Option<PathBuf>);

/// Running background tasks
#[derive(Default, Resource, Deref, DerefMut)]
pub struct DirworldTasks(pub BTreeMap<String, Task<Option<CommandQueue>>>);

#[derive(Debug, Default, Resource, Deref, DerefMut)]
pub(crate) struct DirworldObservers(pub MultiKeyMap<EntryType, Entity>);

#[derive(Default, Resource, Deref, DerefMut)]
pub(crate) struct DirworldCodecs(pub MultiKeyMap<String, Box<dyn Codec + Send + Sync>>);

#[derive(Debug, PartialEq, Eq, Hash)]
pub enum EntryType {
    File(Option<String>),
    Folder,
}

/// Structure containing payload data for cached (non-current) rooms
#[derive(Resource, Default, Debug, Deref, DerefMut)]
pub struct DirworldCache(pub HashMap<PathBuf, DirworldEntityPayload>);