From 99c398cc127dbc83480f98fea8c76f7c19d4dce8 Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Wed, 16 Oct 2024 15:12:15 -0400 Subject: Navigation Rewrite --- src/lib.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 2bfbc57..cf56ccf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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::(|runtime| { let runtime = lua_api::register(runtime); if let Some(register_custom) = &self.register_custom_lua_api { (register_custom)(runtime); } }) - .add_event::() + .init_resource::() .init_resource::() .init_resource::() .init_resource::() .init_resource::() .init_resource::() - .add_event::(); + .add_event::() + .add_event::() + .add_event::() + .add_event::() + .observe(observers::navigate_to_room) + .observe(observers::handle_changes) + .observe(observers::change_root) + .observe(observers::navigate_from_room); } } -- cgit v1.2.3