Skip to content

Commit 0bdb879

Browse files
authored
Merge branch 'main' into hashmap_iter
2 parents 12865a8 + d38c3fd commit 0bdb879

File tree

20 files changed

+455
-157
lines changed

20 files changed

+455
-157
lines changed

.github/workflows/bevy_mod_scripting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
- name: Check if fork
8686
id: check-fork
8787
run: |
88-
if [ "${{ github.event_name }}" == "pull_request" && "${{ github.repository }}" != "${{ github.event.pull_request.head.repo.full_name }}" ]; then
88+
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.repository }}" != "${{ github.event.pull_request.head.repo.full_name }}" ]]; then
8989
echo "This is a forked repository."
9090
echo "is_fork=true" >> $GITHUB_OUTPUT
9191
else

assets/tests/add_system/added_systems_run_in_parallel.lua

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,51 +25,53 @@ digraph {
2525
node_0 [label="bevy_asset::assets::Assets<bevy_asset::folder::LoadedFolder>::asset_events"];
2626
node_1 [label="bevy_asset::assets::Assets<bevy_asset::assets::LoadedUntypedAsset>::asset_events"];
2727
node_2 [label="bevy_asset::assets::Assets<()>::asset_events"];
28-
node_3 [label="bevy_asset::assets::Assets<bevy_mod_scripting_asset::script_asset::ScriptAsset>::asset_events"];
29-
node_4 [label="bevy_mod_scripting_bindings::allocator::garbage_collector"];
30-
node_5 [label="bevy_mod_scripting_core::handler::script_error_logger"];
31-
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
32-
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
33-
node_8 [label="bevy_mod_scripting_core::pipeline::start::filter_script_attachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
34-
node_9 [label="bevy_mod_scripting_core::pipeline::start::filter_script_detachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
35-
node_10 [label="bevy_mod_scripting_core::pipeline::start::filter_script_modifications<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
36-
node_11 [label="bevy_mod_scripting_core::pipeline::start::process_attachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
37-
node_12 [label="bevy_mod_scripting_core::pipeline::start::process_detachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
38-
node_13 [label="bevy_mod_scripting_core::pipeline::start::process_asset_modifications<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
39-
node_14 [label="bevy_mod_scripting_core::pipeline::automatic_pipeline_runner<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
40-
node_15 [label="on_test_post_update"];
41-
node_16 [label="custom_system_a"];
42-
node_17 [label="custom_system_b"];
43-
node_18 [label="SystemSet AssetEvents"];
44-
node_19 [label="SystemSet GarbageCollection"];
45-
node_20 [label="SystemSet ListeningPhase"];
46-
node_21 [label="SystemSet MachineStartPhase"];
47-
node_22 [label="SystemSet ScriptSystem(custom_system_a)"];
48-
node_23 [label="SystemSet ScriptSystem(custom_system_b)"];
49-
node_0 -> node_18 [color=red, label="child of", arrowhead=diamond];
50-
node_1 -> node_18 [color=red, label="child of", arrowhead=diamond];
51-
node_2 -> node_18 [color=red, label="child of", arrowhead=diamond];
52-
node_3 -> node_18 [color=red, label="child of", arrowhead=diamond];
28+
node_3 [label="bevy_asset::assets::Assets<test_utils::test_data::TestAsset>::asset_events"];
29+
node_4 [label="bevy_asset::assets::Assets<bevy_mod_scripting_asset::script_asset::ScriptAsset>::asset_events"];
30+
node_5 [label="bevy_mod_scripting_bindings::allocator::garbage_collector"];
31+
node_6 [label="bevy_mod_scripting_core::handler::script_error_logger"];
32+
node_7 [label="script_integration_test_harness::dummy_before_post_update_system"];
33+
node_8 [label="script_integration_test_harness::dummy_post_update_system"];
34+
node_9 [label="bevy_mod_scripting_core::pipeline::start::filter_script_attachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
35+
node_10 [label="bevy_mod_scripting_core::pipeline::start::filter_script_detachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
36+
node_11 [label="bevy_mod_scripting_core::pipeline::start::filter_script_modifications<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
37+
node_12 [label="bevy_mod_scripting_core::pipeline::start::process_attachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
38+
node_13 [label="bevy_mod_scripting_core::pipeline::start::process_detachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
39+
node_14 [label="bevy_mod_scripting_core::pipeline::start::process_asset_modifications<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
40+
node_15 [label="bevy_mod_scripting_core::pipeline::automatic_pipeline_runner<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
41+
node_16 [label="on_test_post_update"];
42+
node_17 [label="custom_system_a"];
43+
node_18 [label="custom_system_b"];
44+
node_19 [label="SystemSet AssetEvents"];
45+
node_20 [label="SystemSet GarbageCollection"];
46+
node_21 [label="SystemSet ListeningPhase"];
47+
node_22 [label="SystemSet MachineStartPhase"];
48+
node_23 [label="SystemSet ScriptSystem(custom_system_a)"];
49+
node_24 [label="SystemSet ScriptSystem(custom_system_b)"];
50+
node_0 -> node_19 [color=red, label="child of", arrowhead=diamond];
51+
node_1 -> node_19 [color=red, label="child of", arrowhead=diamond];
52+
node_2 -> node_19 [color=red, label="child of", arrowhead=diamond];
53+
node_3 -> node_19 [color=red, label="child of", arrowhead=diamond];
5354
node_4 -> node_19 [color=red, label="child of", arrowhead=diamond];
54-
node_8 -> node_20 [color=red, label="child of", arrowhead=diamond];
55-
node_9 -> node_20 [color=red, label="child of", arrowhead=diamond];
56-
node_10 -> node_20 [color=red, label="child of", arrowhead=diamond];
55+
node_5 -> node_20 [color=red, label="child of", arrowhead=diamond];
56+
node_9 -> node_21 [color=red, label="child of", arrowhead=diamond];
57+
node_10 -> node_21 [color=red, label="child of", arrowhead=diamond];
5758
node_11 -> node_21 [color=red, label="child of", arrowhead=diamond];
58-
node_12 -> node_21 [color=red, label="child of", arrowhead=diamond];
59-
node_13 -> node_21 [color=red, label="child of", arrowhead=diamond];
60-
node_16 -> node_22 [color=red, label="child of", arrowhead=diamond];
59+
node_12 -> node_22 [color=red, label="child of", arrowhead=diamond];
60+
node_13 -> node_22 [color=red, label="child of", arrowhead=diamond];
61+
node_14 -> node_22 [color=red, label="child of", arrowhead=diamond];
6162
node_17 -> node_23 [color=red, label="child of", arrowhead=diamond];
62-
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
63-
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
64-
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
65-
node_8 -> node_10 [color=blue, label="runs before", arrowhead=normal];
63+
node_18 -> node_24 [color=red, label="child of", arrowhead=diamond];
64+
node_7 -> node_8 [color=blue, label="runs before", arrowhead=normal];
6665
node_9 -> node_10 [color=blue, label="runs before", arrowhead=normal];
67-
node_11 -> node_12 [color=blue, label="runs before", arrowhead=normal];
66+
node_9 -> node_10 [color=blue, label="runs before", arrowhead=normal];
67+
node_9 -> node_11 [color=blue, label="runs before", arrowhead=normal];
68+
node_10 -> node_11 [color=blue, label="runs before", arrowhead=normal];
6869
node_12 -> node_13 [color=blue, label="runs before", arrowhead=normal];
69-
node_15 -> node_16 [color=blue, label="runs before", arrowhead=normal];
70-
node_15 -> node_17 [color=blue, label="runs before", arrowhead=normal];
71-
node_20 -> node_21 [color=blue, label="runs before", arrowhead=normal];
72-
node_21 -> node_14 [color=blue, label="runs before", arrowhead=normal];
70+
node_13 -> node_14 [color=blue, label="runs before", arrowhead=normal];
71+
node_16 -> node_17 [color=blue, label="runs before", arrowhead=normal];
72+
node_16 -> node_18 [color=blue, label="runs before", arrowhead=normal];
73+
node_21 -> node_22 [color=blue, label="runs before", arrowhead=normal];
74+
node_22 -> node_15 [color=blue, label="runs before", arrowhead=normal];
7375
}
7476
]]
7577
assert_str_eq(dot_graph, expected_dot_graph, "Expected the schedule graph to match the expected graph")

assets/tests/add_system/added_systems_run_in_parallel.rhai

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,51 +24,53 @@ digraph {
2424
node_0 [label="bevy_asset::assets::Assets<bevy_asset::folder::LoadedFolder>::asset_events"];
2525
node_1 [label="bevy_asset::assets::Assets<bevy_asset::assets::LoadedUntypedAsset>::asset_events"];
2626
node_2 [label="bevy_asset::assets::Assets<()>::asset_events"];
27-
node_3 [label="bevy_asset::assets::Assets<bevy_mod_scripting_asset::script_asset::ScriptAsset>::asset_events"];
28-
node_4 [label="bevy_mod_scripting_bindings::allocator::garbage_collector"];
29-
node_5 [label="bevy_mod_scripting_core::handler::script_error_logger"];
30-
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
31-
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
32-
node_8 [label="bevy_mod_scripting_core::pipeline::start::filter_script_attachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
33-
node_9 [label="bevy_mod_scripting_core::pipeline::start::filter_script_detachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
34-
node_10 [label="bevy_mod_scripting_core::pipeline::start::filter_script_modifications<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
35-
node_11 [label="bevy_mod_scripting_core::pipeline::start::process_attachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
36-
node_12 [label="bevy_mod_scripting_core::pipeline::start::process_detachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
37-
node_13 [label="bevy_mod_scripting_core::pipeline::start::process_asset_modifications<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
38-
node_14 [label="bevy_mod_scripting_core::pipeline::automatic_pipeline_runner<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
39-
node_15 [label="on_test_post_update"];
40-
node_16 [label="custom_system_a"];
41-
node_17 [label="custom_system_b"];
42-
node_18 [label="SystemSet AssetEvents"];
43-
node_19 [label="SystemSet GarbageCollection"];
44-
node_20 [label="SystemSet ListeningPhase"];
45-
node_21 [label="SystemSet MachineStartPhase"];
46-
node_22 [label="SystemSet ScriptSystem(custom_system_a)"];
47-
node_23 [label="SystemSet ScriptSystem(custom_system_b)"];
48-
node_0 -> node_18 [color=red, label="child of", arrowhead=diamond];
49-
node_1 -> node_18 [color=red, label="child of", arrowhead=diamond];
50-
node_2 -> node_18 [color=red, label="child of", arrowhead=diamond];
51-
node_3 -> node_18 [color=red, label="child of", arrowhead=diamond];
27+
node_3 [label="bevy_asset::assets::Assets<test_utils::test_data::TestAsset>::asset_events"];
28+
node_4 [label="bevy_asset::assets::Assets<bevy_mod_scripting_asset::script_asset::ScriptAsset>::asset_events"];
29+
node_5 [label="bevy_mod_scripting_bindings::allocator::garbage_collector"];
30+
node_6 [label="bevy_mod_scripting_core::handler::script_error_logger"];
31+
node_7 [label="script_integration_test_harness::dummy_before_post_update_system"];
32+
node_8 [label="script_integration_test_harness::dummy_post_update_system"];
33+
node_9 [label="bevy_mod_scripting_core::pipeline::start::filter_script_attachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
34+
node_10 [label="bevy_mod_scripting_core::pipeline::start::filter_script_detachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
35+
node_11 [label="bevy_mod_scripting_core::pipeline::start::filter_script_modifications<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
36+
node_12 [label="bevy_mod_scripting_core::pipeline::start::process_attachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
37+
node_13 [label="bevy_mod_scripting_core::pipeline::start::process_detachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
38+
node_14 [label="bevy_mod_scripting_core::pipeline::start::process_asset_modifications<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
39+
node_15 [label="bevy_mod_scripting_core::pipeline::automatic_pipeline_runner<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
40+
node_16 [label="on_test_post_update"];
41+
node_17 [label="custom_system_a"];
42+
node_18 [label="custom_system_b"];
43+
node_19 [label="SystemSet AssetEvents"];
44+
node_20 [label="SystemSet GarbageCollection"];
45+
node_21 [label="SystemSet ListeningPhase"];
46+
node_22 [label="SystemSet MachineStartPhase"];
47+
node_23 [label="SystemSet ScriptSystem(custom_system_a)"];
48+
node_24 [label="SystemSet ScriptSystem(custom_system_b)"];
49+
node_0 -> node_19 [color=red, label="child of", arrowhead=diamond];
50+
node_1 -> node_19 [color=red, label="child of", arrowhead=diamond];
51+
node_2 -> node_19 [color=red, label="child of", arrowhead=diamond];
52+
node_3 -> node_19 [color=red, label="child of", arrowhead=diamond];
5253
node_4 -> node_19 [color=red, label="child of", arrowhead=diamond];
53-
node_8 -> node_20 [color=red, label="child of", arrowhead=diamond];
54-
node_9 -> node_20 [color=red, label="child of", arrowhead=diamond];
55-
node_10 -> node_20 [color=red, label="child of", arrowhead=diamond];
54+
node_5 -> node_20 [color=red, label="child of", arrowhead=diamond];
55+
node_9 -> node_21 [color=red, label="child of", arrowhead=diamond];
56+
node_10 -> node_21 [color=red, label="child of", arrowhead=diamond];
5657
node_11 -> node_21 [color=red, label="child of", arrowhead=diamond];
57-
node_12 -> node_21 [color=red, label="child of", arrowhead=diamond];
58-
node_13 -> node_21 [color=red, label="child of", arrowhead=diamond];
59-
node_16 -> node_22 [color=red, label="child of", arrowhead=diamond];
58+
node_12 -> node_22 [color=red, label="child of", arrowhead=diamond];
59+
node_13 -> node_22 [color=red, label="child of", arrowhead=diamond];
60+
node_14 -> node_22 [color=red, label="child of", arrowhead=diamond];
6061
node_17 -> node_23 [color=red, label="child of", arrowhead=diamond];
61-
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
62-
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
63-
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
64-
node_8 -> node_10 [color=blue, label="runs before", arrowhead=normal];
62+
node_18 -> node_24 [color=red, label="child of", arrowhead=diamond];
63+
node_7 -> node_8 [color=blue, label="runs before", arrowhead=normal];
6564
node_9 -> node_10 [color=blue, label="runs before", arrowhead=normal];
66-
node_11 -> node_12 [color=blue, label="runs before", arrowhead=normal];
65+
node_9 -> node_10 [color=blue, label="runs before", arrowhead=normal];
66+
node_9 -> node_11 [color=blue, label="runs before", arrowhead=normal];
67+
node_10 -> node_11 [color=blue, label="runs before", arrowhead=normal];
6768
node_12 -> node_13 [color=blue, label="runs before", arrowhead=normal];
68-
node_15 -> node_16 [color=blue, label="runs before", arrowhead=normal];
69-
node_15 -> node_17 [color=blue, label="runs before", arrowhead=normal];
70-
node_20 -> node_21 [color=blue, label="runs before", arrowhead=normal];
71-
node_21 -> node_14 [color=blue, label="runs before", arrowhead=normal];
69+
node_13 -> node_14 [color=blue, label="runs before", arrowhead=normal];
70+
node_16 -> node_17 [color=blue, label="runs before", arrowhead=normal];
71+
node_16 -> node_18 [color=blue, label="runs before", arrowhead=normal];
72+
node_21 -> node_22 [color=blue, label="runs before", arrowhead=normal];
73+
node_22 -> node_15 [color=blue, label="runs before", arrowhead=normal];
7274
}`;
7375

7476
assert_str_eq.call(dot_graph, expected_dot_graph, "Expected the schedule graph to match the expected graph");
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function on_test()
2+
local test_handle = create_test_asset(42, "TestAssetName")
3+
4+
assert(test_handle ~= nil, "Test asset handle should not be nil")
5+
assert(world.has_asset(test_handle) == true, "has_asset should return true")
6+
7+
local retrieved_asset = world.get_asset(test_handle, types.TestAsset)
8+
assert(retrieved_asset.value == 42, "Asset value should be 42")
9+
assert(retrieved_asset.name == "TestAssetName", "Asset name should be 'TestAssetName'")
10+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn on_test() {
2+
let test_handle = create_test_asset(42, "TestAssetName");
3+
4+
assert(test_handle != (), "Test asset handle should not be nil");
5+
assert(world.has_asset.call(test_handle) == true, "has_asset should return true");
6+
7+
let retrieved_asset = world.get_asset.call(test_handle, types.TestAsset);
8+
assert(retrieved_asset.value == 42, "Asset value should be 42");
9+
assert(retrieved_asset.name == "TestAssetName", "Asset name should be 'TestAssetName'");
10+
}

benches/benchmarks.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,22 +266,13 @@ fn conversion_benchmarks(criterion: &mut Criterion) {
266266

267267
fn script_load_benchmarks(criterion: &mut Criterion) {
268268
let mut group = criterion.benchmark_group("loading");
269-
let reload_probability = 0.5;
270269
// lua
271-
let plugin = make_test_lua_plugin();
272270
let content = include_str!("../assets/macro_benchmarks/loading/empty.lua");
273-
run_plugin_script_load_benchmark(plugin, "empty Lua", content, &mut group, reload_probability);
271+
run_plugin_script_load_benchmark(make_test_lua_plugin, "empty Lua", content, &mut group);
274272

275273
// rhai
276-
let plugin = make_test_rhai_plugin();
277274
let content = include_str!("../assets/macro_benchmarks/loading/empty.rhai");
278-
run_plugin_script_load_benchmark(
279-
plugin,
280-
"empty Rhai",
281-
content,
282-
&mut group,
283-
reload_probability,
284-
);
275+
run_plugin_script_load_benchmark(make_test_rhai_plugin, "empty Rhai", content, &mut group);
285276
}
286277

287278
pub fn benches() {

crates/bevy_mod_scripting_bindings/src/access_map.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ impl ReflectAccessId {
223223
ReflectBase::Resource(id) => Self::for_component_id(id),
224224
ReflectBase::Component(_, id) => Self::for_component_id(id),
225225
ReflectBase::Owned(id) => Self::for_allocation(id),
226+
ReflectBase::Asset(_, assets_resource_id) => Self::for_component_id(assets_resource_id),
226227
}
227228
}
228229
}

0 commit comments

Comments
 (0)