Skip to content

Commit 4133152

Browse files
authored
changing handle_events in the ScriptHost trait to be a mut method (makspll#72)
changing handle_events in the ScriptHost trait to be a mut method, for flexibility in custom hosts.
1 parent 2296bb9 commit 4133152

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

bevy_mod_scripting_core/src/hosts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub trait ScriptHost: Send + Sync + 'static + Default + Resource {
8989
/// the main point of contact with the bevy world.
9090
/// Scripts are called with appropriate events in the event order
9191
fn handle_events<'a>(
92-
&self,
92+
&mut self,
9393
world_ptr: &mut World,
9494
events: &[Self::ScriptEvent],
9595
ctxs: impl Iterator<Item = (ScriptData<'a>, &'a mut Self::ScriptContext)>,

bevy_mod_scripting_core/src/systems.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub fn script_event_handler<H: ScriptHost, const MAX: u32, const MIN: u32>(world
164164

165165
let mut ctxts: ScriptContexts<H::ScriptContext> = world.remove_resource().unwrap();
166166

167-
let host: H = world.remove_resource().unwrap();
167+
let mut host: H = world.remove_resource().unwrap();
168168
let mut providers: APIProviders<H> = world.remove_resource().unwrap();
169169

170170
// we need a resource scope to be able to simultaneously access the contexts as well

languages/bevy_mod_scripting_lua/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<A: LuaArg> ScriptHost for LuaScriptHost<A> {
138138
}
139139

140140
fn handle_events<'a>(
141-
&self,
141+
&mut self,
142142
world: &mut World,
143143
events: &[Self::ScriptEvent],
144144
ctxs: impl Iterator<Item = (ScriptData<'a>, &'a mut Self::ScriptContext)>,

languages/bevy_mod_scripting_rhai/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<A: FuncArgs + Send + Clone + Sync + 'static> ScriptHost for RhaiScriptHost<
142142
}
143143

144144
fn handle_events<'a>(
145-
&self,
145+
&mut self,
146146
world: &mut World,
147147
events: &[Self::ScriptEvent],
148148
ctxs: impl Iterator<Item = (ScriptData<'a>, &'a mut Self::ScriptContext)>,

0 commit comments

Comments
 (0)