Skip to content

Commit 17cf228

Browse files
LaserWitchmakspll
andauthored
Bevy 0.12 migration (#93)
* Game of life lua example builds and runs on bevy 0.12 now. It doesn't work, but it does run! * Basic lua scripts may now be working at least aprt of the time. * migrate rhai parts, formatting etc * formatting * migrate rune * format * revert some changes * fix lint --------- Co-authored-by: makspll <makspl17@gmail.com>
1 parent 46dafba commit 17cf228

File tree

41 files changed

+906
-749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+906
-749
lines changed

Cargo.toml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_mod_scripting"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors = ["Maksymilian Mozolewski <makspl17@gmail.com>"]
55
edition = "2021"
66
license = "MIT"
@@ -63,18 +63,19 @@ rhai_script_api = ["bevy_script_api/rhai"]
6363
rune = ["bevy_mod_scripting_rune"]
6464

6565
[dependencies]
66-
bevy = { version = "0.11", default-features = false }
67-
bevy_mod_scripting_core = { path = "bevy_mod_scripting_core", version = "0.3.0" }
68-
bevy_mod_scripting_lua = { path = "languages/bevy_mod_scripting_lua", version = "0.3.0", optional = true }
69-
bevy_mod_scripting_rhai = { path = "languages/bevy_mod_scripting_rhai", version = "0.3.0", optional = true }
70-
bevy_mod_scripting_rune = { path = "languages/bevy_mod_scripting_rune", version = "0.3.0", optional = true }
71-
bevy_script_api = { path = "bevy_script_api", version = "0.3.0", optional = true }
66+
bevy = { version = "0.12", default-features = false }
67+
bevy_mod_scripting_core = { path = "bevy_mod_scripting_core", version = "0.4.0" }
68+
bevy_mod_scripting_lua = { path = "languages/bevy_mod_scripting_lua", version = "0.4.0", optional = true }
69+
bevy_mod_scripting_rhai = { path = "languages/bevy_mod_scripting_rhai", version = "0.4.0", optional = true }
70+
bevy_mod_scripting_rune = { path = "languages/bevy_mod_scripting_rune", version = "0.4.0", optional = true }
71+
bevy_script_api = { path = "bevy_script_api", version = "0.4.0", optional = true }
72+
7273

7374
[dev-dependencies]
74-
bevy = { version = "0.11" }
75+
bevy = { version = "0.12" }
7576
clap = { version = "4.1", features = ["derive"] }
7677
rand = "0.8.5"
77-
bevy_console = "0.8.0"
78+
bevy_console = "0.10.1"
7879
rhai-rand = "0.1"
7980

8081
[workspace]
@@ -108,12 +109,12 @@ codegen-units = 8
108109
[[example]]
109110
name = "console_integration_lua"
110111
path = "examples/lua/console_integration.rs"
111-
required-features = ["lua54", "lua_script_api"]
112+
required-features = ["lua54", "lua_script_api", "bevy/file_watcher"]
112113

113114
[[example]]
114115
name = "console_integration_rhai"
115116
path = "examples/rhai/console_integration.rs"
116-
required-features = ["rhai", "rhai_script_api"]
117+
required-features = ["rhai", "rhai_script_api", "bevy/file_watcher"]
117118

118119
[[example]]
119120
name = "complex_game_loop_lua"
@@ -123,12 +124,12 @@ required-features = ["lua54"]
123124
[[example]]
124125
name = "game_of_life_lua"
125126
path = "examples/lua/game_of_life.rs"
126-
required-features = ["lua54", "teal", "lua_script_api"]
127+
required-features = ["lua54", "teal", "lua_script_api", "bevy/file_watcher"]
127128

128129
[[example]]
129130
name = "game_of_life_rhai"
130131
path = "examples/rhai/game_of_life.rs"
131-
required-features = ["rhai", "rhai_script_api"]
132+
required-features = ["rhai", "rhai_script_api", "bevy/file_watcher"]
132133

133134
[[example]]
134135
name = "event_recipients_lua"

api_gen_config.toml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,11 @@ type="VisibleEntities"
390390
source="bevy_render"
391391

392392
[[types]]
393-
type="ComputedVisibility"
393+
type="InheritedVisibility"
394+
source="bevy_render"
395+
396+
[[types]]
397+
type="ViewVisibility"
394398
source="bevy_render"
395399

396400
[[types]]
@@ -469,20 +473,26 @@ source="bevy_render"
469473
## BEVY_ASSET
470474

471475
[[types]]
472-
type="AssetPathId"
476+
type="AssetIndex"
473477
source="bevy_asset"
474478

475-
[[types]]
476-
type="LabelId"
477-
source="bevy_asset"
479+
#Needs manual implementation? it's generic.
480+
#[[types]]
481+
#type="AssetId"
482+
#source="bevy_asset"
478483

479-
[[types]]
480-
type="SourcePathId"
481-
source="bevy_asset"
484+
#Not handled by reflection
485+
#[[types]]
486+
#type="StrongHandle"
487+
#source="bevy_asset"
482488

483-
[[types]]
484-
type="HandleId"
485-
source="bevy_asset"
489+
#[[types]]
490+
#type="Label"
491+
#source="bevy_asset"
492+
493+
#[[types]]
494+
#type="Handle"
495+
#source="bevy_asset"
486496

487497
## BEVY_MATH
488498
[[types]]
@@ -648,7 +658,7 @@ lua_methods=[
648658
.unwrap()
649659
.col_mut(idx))
650660
} else {
651-
Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"Mat3".into()})
661+
Err(ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()})
652662
}
653663
}
654664
})
@@ -679,7 +689,7 @@ lua_methods=[
679689
.unwrap()
680690
.col_mut(idx))
681691
} else {
682-
Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"Mat2".into()})
692+
Err(ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat2".into()})
683693
}
684694
}
685695
})
@@ -711,7 +721,7 @@ lua_methods=[
711721
.unwrap()
712722
.col_mut(idx))
713723
} else {
714-
Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"Mat3A".into()})
724+
Err(ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3A".into()})
715725
}
716726
}
717727
})
@@ -742,7 +752,7 @@ lua_methods=[
742752
.unwrap()
743753
.col_mut(idx))
744754
} else {
745-
Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"Mat4".into()})
755+
Err(ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat4".into()})
746756
}
747757
}
748758
})
@@ -774,7 +784,7 @@ lua_methods=[
774784
.unwrap()
775785
.col_mut(idx))
776786
} else {
777-
Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"DMat2".into()})
787+
Err(ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"DMat2".into()})
778788
}
779789
}
780790
})
@@ -805,7 +815,7 @@ lua_methods=[
805815
.unwrap()
806816
.col_mut(idx))
807817
} else {
808-
Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"DMat3".into()})
818+
Err(ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"DMat3".into()})
809819
}
810820
}
811821
})
@@ -836,7 +846,7 @@ lua_methods=[
836846
.unwrap()
837847
.col_mut(idx))
838848
} else {
839-
Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"DMat4".into()})
849+
Err(ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"DMat4".into()})
840850
}
841851
}
842852
})

bevy_api_gen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_api_gen"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors = ["Maksymilian Mozolewski <makspl17@gmail.com>"]
55
edition = "2021"
66
license = "MIT"

bevy_api_gen/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ pub(crate) fn generate_macros(
9797
let path_components = get_path(id, source).unwrap_or_else(|| {
9898
panic!("path not found for {:?} in {:?}", id, source.root)
9999
});
100-
//eprintln!("{:?}", path_components);
101100
let path_components = path_to_import(path_components, source);
102-
//eprintln!("{:?}", path_components);
103101

104102
let wrapper_name = format!("{WRAPPER_PREFIX}{}", item.name.as_ref().unwrap());
105103
let wrapped_type = item.name.as_ref().unwrap();
@@ -125,7 +123,8 @@ pub(crate) fn generate_macros(
125123
});
126124

127125
if !unmatched_types.is_empty() {
128-
panic!("Some types were not found in the given crates: {unmatched_types:#?}")
126+
//panic!("Some types were not found in the given crates: {unmatched_types:#?}")
127+
eprintln!("Some types were not found in the given crates: {unmatched_types:#?}")
129128
}
130129

131130
let mut writer = PrettyWriter::new();

bevy_event_priority/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_event_priority"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors = ["Maksymilian Mozolewski <makspl17@gmail.com>"]
55
edition = "2021"
66
license = "MIT"
@@ -21,5 +21,5 @@ name = "bevy_event_priority"
2121
path = "src/lib.rs"
2222

2323
[dependencies]
24-
bevy = { version = "0.11", default-features = false}
24+
bevy = { version = "0.12", default-features = false}
2525

bevy_mod_scripting_common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_mod_scripting_common"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors = ["Maksymilian Mozolewski <makspl17@gmail.com>"]
55
edition = "2021"
66
license = "MIT"

bevy_mod_scripting_core/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_mod_scripting_core"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors = ["Maksymilian Mozolewski <makspl17@gmail.com>"]
55
edition = "2021"
66
license = "MIT"
@@ -29,10 +29,10 @@ doc_always = []
2929

3030

3131
[dependencies]
32-
bevy = { version = "0.11", default-features = false, features=["bevy_asset","bevy_gltf","bevy_animation","bevy_core_pipeline","bevy_ui","bevy_pbr","bevy_render","bevy_text","bevy_sprite","filesystem_watcher"]}
33-
bevy_event_priority = {path = "../bevy_event_priority", version = "0.3.0" }
32+
bevy = { version = "0.12", default-features = false, features=["bevy_asset","bevy_gltf","bevy_animation","bevy_core_pipeline","bevy_ui","bevy_pbr","bevy_render","bevy_text","bevy_sprite"]}
33+
bevy_event_priority = {path = "../bevy_event_priority", version = "0.4.0" }
3434
thiserror = "1.0.31"
3535
paste = "1.0.7"
3636
parking_lot = "0.12.1"
37-
37+
anyhow ="1.0.75"
3838

bevy_mod_scripting_core/src/systems.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub fn script_remove_synchronizer<H: ScriptHost>(
9595
mut query: RemovedComponents<ScriptCollection<H::ScriptAsset>>,
9696
mut contexts: ResMut<ScriptContexts<H::ScriptContext>>,
9797
) {
98-
for v in query.iter() {
98+
for v in query.read() {
9999
// we know that this entity used to have a script component
100100
// ergo a script context must exist in ctxts, remove all scripts on the entity
101101
let script_ids = contexts
@@ -121,10 +121,10 @@ pub fn script_hot_reload_handler<H: ScriptHost>(
121121
mut contexts: ResMut<ScriptContexts<H::ScriptContext>>,
122122
mut event_writer: EventWriter<ScriptLoaded>,
123123
) {
124-
for e in events.iter() {
124+
for e in events.read() {
125125
let (handle, created) = match e {
126-
AssetEvent::Modified { handle } => (handle, false),
127-
AssetEvent::Created { handle } => (handle, true),
126+
AssetEvent::Modified { id } => (id, false),
127+
AssetEvent::Added { id } => (id, true),
128128
_ => continue,
129129
};
130130

@@ -137,7 +137,9 @@ pub fn script_hot_reload_handler<H: ScriptHost>(
137137
for script in &scripts.scripts {
138138
// the script could have well loaded in the same frame that it was added
139139
// in that case it will have a context attached and we do not want to reload it
140-
if script.handle() == handle && !(contexts.has_context(script.id()) && created) {
140+
if script.handle().id() == *handle
141+
&& !(contexts.has_context(script.id()) && created)
142+
{
141143
Script::<H::ScriptAsset>::reload_script::<H>(
142144
&mut host,
143145
script,

bevy_mod_scripting_derive/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_mod_scripting_derive"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors = ["Maksymilian Mozolewski <makspl17@gmail.com>"]
55
edition = "2021"
66
license = "MIT"
@@ -24,7 +24,7 @@ path = "src/lib.rs"
2424

2525

2626
[dependencies]
27-
bevy_mod_scripting_common = {path = "../bevy_mod_scripting_common", version = "0.3.0" }
27+
bevy_mod_scripting_common = {path = "../bevy_mod_scripting_common", version = "0.4.0" }
2828
paste = "1.0.7"
2929
syn = {version="1.0.57",features=["full","fold","extra-traits"]}
3030
quote = "1.0.8"

bevy_script_api/Cargo.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_script_api"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors = ["Maksymilian Mozolewski <makspl17@gmail.com>"]
55
edition = "2021"
66
license = "MIT"
@@ -13,26 +13,26 @@ readme = "readme.md"
1313

1414
[package.metadata.release]
1515
pre-release-replacements = [
16-
{file="Cargo.toml", search='^version\s*=\s*.*$', replace="version = \"{{version}}\"", exactly=1},
17-
{file="Cargo.toml", search='^(?P<h>bevy_mod_scripting_derive\s*=.*)version\s*=\s*".*"(?P<t>.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1},
18-
{file="Cargo.toml", search='^(?P<h>bevy_mod_scripting_core\s*=.*)version\s*=\s*".*"(?P<t>.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1},
19-
{file="Cargo.toml", search='^(?P<h>bevy_mod_scripting_lua\s*=.*)version\s*=\s*".*"(?P<t>.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1},
20-
{file="Cargo.toml", search='^(?P<h>bevy_mod_scripting_lua_derive\s*=.*)version\s*=\s*".*"(?P<t>.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1},
21-
{file="Cargo.toml", search='^(?P<h>bevy_mod_scripting_rhai\s*=.*)version\s*=\s*".*"(?P<t>.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1},
16+
{ file = "Cargo.toml", search='^version\s*=\s*.*$', replace="version = \"{{version}}\"", exactly=1},
17+
{ file = "Cargo.toml", search='^(?P<h>bevy_mod_scripting_derive\s*=.*)version\s*=\s*".*"(?P<t>.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1},
18+
{ file = "Cargo.toml", search='^(?P<h>bevy_mod_scripting_core\s*=.*)version\s*=\s*".*"(?P<t>.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1},
19+
{ file = "Cargo.toml", search='^(?P<h>bevy_mod_scripting_lua\s*=.*)version\s*=\s*".*"(?P<t>.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1},
20+
{ file = "Cargo.toml", search='^(?P<h>bevy_mod_scripting_lua_derive\s*=.*)version\s*=\s*".*"(?P<t>.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1},
21+
{ file = "Cargo.toml", search='^(?P<h>bevy_mod_scripting_rhai\s*=.*)version\s*=\s*".*"(?P<t>.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1},
2222
]
2323

2424
[features]
2525
lua = ["bevy_mod_scripting_lua","bevy_mod_scripting_lua_derive"]
2626
rhai = ["bevy_mod_scripting_rhai"]
2727

2828
[dependencies]
29-
bevy = { version = "0.11", default-features = false, features=["bevy_asset","bevy_gltf","bevy_animation","bevy_core_pipeline","bevy_ui","bevy_pbr","bevy_render","bevy_text","bevy_sprite","filesystem_watcher"]}
30-
bevy_mod_scripting_derive = { path="../bevy_mod_scripting_derive", version = "0.3.0" }
31-
bevy_mod_scripting_core = { path="../bevy_mod_scripting_core", version = "0.3.0" }
29+
bevy = { version = "0.12", default-features = false, features=["bevy_asset","bevy_gltf","bevy_animation","bevy_core_pipeline","bevy_ui","bevy_pbr","bevy_render","bevy_text","bevy_sprite"]}
30+
bevy_mod_scripting_derive = { path="../bevy_mod_scripting_derive", version = "0.4.0" }
31+
bevy_mod_scripting_core = { path="../bevy_mod_scripting_core", version = "0.4.0" }
3232
parking_lot="0.12.1"
3333
paste="1.0.7"
3434
thiserror="1.0.32"
3535
# lua
36-
bevy_mod_scripting_lua={path="../languages/bevy_mod_scripting_lua", version = "0.3.0", optional=true}
37-
bevy_mod_scripting_lua_derive={path="../languages/bevy_mod_scripting_lua_derive", version = "0.3.0", optional=true}
38-
bevy_mod_scripting_rhai={path="../languages/bevy_mod_scripting_rhai", version = "0.3.0", optional=true}
36+
bevy_mod_scripting_lua={path="../languages/bevy_mod_scripting_lua", version = "0.4.0", optional=true}
37+
bevy_mod_scripting_lua_derive={path="../languages/bevy_mod_scripting_lua_derive", version = "0.4.0", optional=true}
38+
bevy_mod_scripting_rhai={path="../languages/bevy_mod_scripting_rhai", version = "0.4.0", optional=true}

0 commit comments

Comments
 (0)