diff options
author | 2024-10-16 15:12:15 -0400 | |
---|---|---|
committer | 2024-10-16 20:19:07 -0400 | |
commit | 99c398cc127dbc83480f98fea8c76f7c19d4dce8 (patch) | |
tree | c4c311300ad4194217eb55b5f4c278694f6bcdc2 /src/lib.rs | |
parent | 4fc097045b0baf8a3a5626681149f4540f8305d7 (diff) |
Navigation Rewrite
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -6,8 +6,9 @@ use std::{ffi::OsStr, path::PathBuf}; use bevy::{ecs::system::IntoObserverSystem, prelude::*}; use bevy_scriptum::{runtimes::lua::LuaRuntime, BuildScriptingRuntime, ScriptingRuntimeBuilder}; -use events::{DirworldNavigationEvent, DirworldSpawn}; +use events::{DirworldChangeRoot, DirworldEnterRoom, DirworldLeaveRoom, DirworldNavigationEvent, DirworldSpawn}; use occule::Codec; +use resources::DirworldCache; use resources::{ DirworldCodecs, DirworldCurrentDir, DirworldObservers, DirworldRootDir, DirworldTasks, EntryType, @@ -31,6 +32,10 @@ pub mod commands; mod systems; +mod observers; + +mod utils; + /// Payload for dirworld entities pub mod payload; @@ -54,24 +59,27 @@ impl Plugin for DirworldPlugin { Update, (systems::remove_completed_tasks, lua_api::trigger_update), ) - .add_systems(PostUpdate, watcher::update) - .add_systems( - PreUpdate, - watcher::handle_changes, - ) + .add_systems(PostUpdate, (watcher::update, systems::sync_entity_transforms)) .add_scripting::<LuaRuntime>(|runtime| { let runtime = lua_api::register(runtime); if let Some(register_custom) = &self.register_custom_lua_api { (register_custom)(runtime); } }) - .add_event::<DirworldNavigationEvent>() + .init_resource::<DirworldCache>() .init_resource::<DirworldRootDir>() .init_resource::<DirworldCurrentDir>() .init_resource::<DirworldTasks>() .init_resource::<DirworldObservers>() .init_resource::<DirworldCodecs>() - .add_event::<DirworldWatcherEvent>(); + .add_event::<DirworldEnterRoom>() + .add_event::<DirworldLeaveRoom>() + .add_event::<DirworldChangeRoot>() + .add_event::<DirworldWatcherEvent>() + .observe(observers::navigate_to_room) + .observe(observers::handle_changes) + .observe(observers::change_root) + .observe(observers::navigate_from_room); } } |