From 1e2f2d5e5b5320800b52a1f4ee23cf626c20c63a Mon Sep 17 00:00:00 2001 From: pro470 Date: Sat, 8 Feb 2025 03:30:37 +0100 Subject: [PATCH 1/2] feat: add recipient for specific language --- crates/bevy_mod_scripting_core/src/event.rs | 2 ++ crates/bevy_mod_scripting_core/src/handler.rs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/crates/bevy_mod_scripting_core/src/event.rs b/crates/bevy_mod_scripting_core/src/event.rs index 6a67fd93ce..5b29554eb8 100644 --- a/crates/bevy_mod_scripting_core/src/event.rs +++ b/crates/bevy_mod_scripting_core/src/event.rs @@ -122,6 +122,8 @@ pub enum Recipients { Script(ScriptId), /// The event is to be handled by all the scripts on the specified entity Entity(Entity), + /// The event is to be handled by all the scripts of one language + Language(crate::asset::Language), } /// A callback event meant to trigger a callback in a subset/set of scripts in the world with the given arguments diff --git a/crates/bevy_mod_scripting_core/src/handler.rs b/crates/bevy_mod_scripting_core/src/handler.rs index 2a627c70ca..d0c7d6cdf9 100644 --- a/crates/bevy_mod_scripting_core/src/handler.rs +++ b/crates/bevy_mod_scripting_core/src/handler.rs @@ -129,6 +129,11 @@ pub(crate) fn event_handler_internal { continue } + crate::event::Recipients::Language(target_language) + if *target_language != P::LANGUAGE => + { + continue + } _ => (), } let script = match res_ctxt.scripts.scripts.get(script_id) { From e3a899c9bc4ac5b20fec60f7f93f95c83bb764ba Mon Sep 17 00:00:00 2001 From: pro470 Date: Sat, 8 Feb 2025 16:36:02 +0100 Subject: [PATCH 2/2] fix: format the PR --- crates/bevy_mod_scripting_core/src/handler.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bevy_mod_scripting_core/src/handler.rs b/crates/bevy_mod_scripting_core/src/handler.rs index d0c7d6cdf9..660154f357 100644 --- a/crates/bevy_mod_scripting_core/src/handler.rs +++ b/crates/bevy_mod_scripting_core/src/handler.rs @@ -130,10 +130,10 @@ pub(crate) fn event_handler_internal - { - continue - } + if *target_language != P::LANGUAGE => + { + continue + } _ => (), } let script = match res_ctxt.scripts.scripts.get(script_id) {