aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
blob: f4bd7836e57b7dad6170f54fd433bdaf86e8ecb4 (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
36
37
#![warn(missing_docs)]

//! Plugin for bevy engine enabling interaction with and representation of the file system in the world.

use std::path::PathBuf;

use bevy::{asset::io::AssetSource, prelude::*};
use events::DirworldNavigationEvent;
use resources::{Dirworld, DirworldConfig};

/// Components used by this plugin
pub mod components;

/// Events used by this plugin
pub mod events;

/// Resources used by this plugin
pub mod resources;

/// Plugin which enables high-level interaction
pub struct DirworldPlugin {
    /// Root path of world
    pub path: PathBuf,
}

impl Plugin for DirworldPlugin {
    fn build(&self, app: &mut App) {
    info!("building");
        let path_string = self.path.to_string_lossy().to_string();
        app.insert_resource(DirworldConfig::new(self.path.clone()))
            .register_asset_source("dirworld", AssetSource::build()
                    .with_reader(AssetSource::get_default_reader(path_string.clone()))
                    .with_watcher(|_| None))
            .add_event::<DirworldNavigationEvent>()
            .init_resource::<Dirworld>();
    }
}