From 4133152f24c05c3696926050171680f098749454 Mon Sep 17 00:00:00 2001 From: LaserWitch <128329371+LaserWitch@users.noreply.github.com> Date: Sun, 3 Sep 2023 05:52:25 -0400 Subject: [PATCH] changing handle_events in the ScriptHost trait to be a mut method (#72) changing handle_events in the ScriptHost trait to be a mut method, for flexibility in custom hosts. --- bevy_mod_scripting_core/src/hosts.rs | 2 +- bevy_mod_scripting_core/src/systems.rs | 2 +- languages/bevy_mod_scripting_lua/src/lib.rs | 2 +- languages/bevy_mod_scripting_rhai/src/lib.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bevy_mod_scripting_core/src/hosts.rs b/bevy_mod_scripting_core/src/hosts.rs index 6e53a025..773de01f 100644 --- a/bevy_mod_scripting_core/src/hosts.rs +++ b/bevy_mod_scripting_core/src/hosts.rs @@ -89,7 +89,7 @@ pub trait ScriptHost: Send + Sync + 'static + Default + Resource { /// the main point of contact with the bevy world. /// Scripts are called with appropriate events in the event order fn handle_events<'a>( - &self, + &mut self, world_ptr: &mut World, events: &[Self::ScriptEvent], ctxs: impl Iterator, &'a mut Self::ScriptContext)>, diff --git a/bevy_mod_scripting_core/src/systems.rs b/bevy_mod_scripting_core/src/systems.rs index 14ccebd4..f77b95e4 100644 --- a/bevy_mod_scripting_core/src/systems.rs +++ b/bevy_mod_scripting_core/src/systems.rs @@ -164,7 +164,7 @@ pub fn script_event_handler(world let mut ctxts: ScriptContexts = world.remove_resource().unwrap(); - let host: H = world.remove_resource().unwrap(); + let mut host: H = world.remove_resource().unwrap(); let mut providers: APIProviders = world.remove_resource().unwrap(); // we need a resource scope to be able to simultaneously access the contexts as well diff --git a/languages/bevy_mod_scripting_lua/src/lib.rs b/languages/bevy_mod_scripting_lua/src/lib.rs index f75dd7fd..b2ef0617 100644 --- a/languages/bevy_mod_scripting_lua/src/lib.rs +++ b/languages/bevy_mod_scripting_lua/src/lib.rs @@ -138,7 +138,7 @@ impl ScriptHost for LuaScriptHost { } fn handle_events<'a>( - &self, + &mut self, world: &mut World, events: &[Self::ScriptEvent], ctxs: impl Iterator, &'a mut Self::ScriptContext)>, diff --git a/languages/bevy_mod_scripting_rhai/src/lib.rs b/languages/bevy_mod_scripting_rhai/src/lib.rs index e539c325..2ddf4d96 100644 --- a/languages/bevy_mod_scripting_rhai/src/lib.rs +++ b/languages/bevy_mod_scripting_rhai/src/lib.rs @@ -142,7 +142,7 @@ impl ScriptHost for RhaiScriptHost< } fn handle_events<'a>( - &self, + &mut self, world: &mut World, events: &[Self::ScriptEvent], ctxs: impl Iterator, &'a mut Self::ScriptContext)>,