aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <silas@exvacuum.dev>2024-06-17 19:37:21 -0400
committerLibravatar Silas Bartha <silas@exvacuum.dev>2024-06-17 19:37:21 -0400
commit462d6c5aaa2281bf875e04d5e2c3241a13256836 (patch)
tree742112db5e0c5554ba0c7a55ea48d3f0cba30dc9
parentebc3ccfea4027a3eb0c80f6a3d64b6425d32d1ef (diff)
Mon Jun 17 07:37:21 PM EDT 2024
-rw-r--r--Cargo.toml3
-rw-r--r--src/components.rs6
-rw-r--r--src/lib.rs7
3 files changed, 14 insertions, 2 deletions
diff --git a/Cargo.toml b/Cargo.toml
index df73011..86079f9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bevy_dirworld"
-version = "0.1.0"
+version = "0.1.1"
edition = "2021"
[dependencies]
@@ -8,6 +8,7 @@ anyhow = "1.0.83"
[dependencies.bevy]
version = "0.13"
+features = ["file_watcher"]
[dependencies.bevy_rapier3d]
version = "0.26"
diff --git a/src/components.rs b/src/components.rs
index 69a5cde..bea87f2 100644
--- a/src/components.rs
+++ b/src/components.rs
@@ -1,5 +1,11 @@
+use std::path::PathBuf;
+
use bevy::prelude::*;
/// A tooltip on an object, which can be displayed.
#[derive(Component)]
pub struct Tooltip(pub String);
+
+/// A marker component for entities spawned by dirworld handlers, i.e. they should be removed when the room changes.
+#[derive(Component)]
+pub struct DirworldEntity(pub PathBuf);
diff --git a/src/lib.rs b/src/lib.rs
index 6b46502..f4bd783 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,7 +4,7 @@
use std::path::PathBuf;
-use bevy::prelude::*;
+use bevy::{asset::io::AssetSource, prelude::*};
use events::DirworldNavigationEvent;
use resources::{Dirworld, DirworldConfig};
@@ -25,7 +25,12 @@ pub struct DirworldPlugin {
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>();
}