Added initial support for bevy 0.16.0 (#39)
* Added initial support for bevy 0.16.0 * Removed unnecessary bevy feature * update version references --------- Co-authored-by: Jaroslaw Konik <konikjar@gmail.com>
This commit is contained in:
parent
ec84d9e740
commit
2c82a2fa0e
20 changed files with 33 additions and 30 deletions
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "bevy_scriptum"
|
||||
authors = ["Jaroslaw Konik <konikjar@gmail.com>"]
|
||||
version = "0.7.0"
|
||||
version = "0.8.0"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
|
@ -15,7 +15,7 @@ lua = ["mlua/luajit"]
|
|||
rhai = ["dep:rhai"]
|
||||
|
||||
[dependencies]
|
||||
bevy = { default-features = false, version = "0.15", features = ["bevy_asset"] }
|
||||
bevy = { default-features = false, version = "0.16", features = ["bevy_asset", "bevy_log"] }
|
||||
serde = "1.0.162"
|
||||
rhai = { version = "1.14.0", features = [
|
||||
"sync",
|
||||
|
|
|
|||
|
|
@ -189,6 +189,7 @@ The examples live in `examples` directory and their corresponding scripts live i
|
|||
|
||||
| bevy version | bevy_scriptum version |
|
||||
|--------------|-----------------------|
|
||||
| 0.16 | 0.8 |
|
||||
| 0.15 | 0.7 |
|
||||
| 0.14 | 0.6 |
|
||||
| 0.13 | 0.4-0.5 |
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ currently being supported with security updates.
|
|||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 0.7 | :white_check_mark: |
|
||||
| 0.8 | :white_check_mark: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
| bevy version | bevy_scriptum version |
|
||||
| ------------ | --------------------- |
|
||||
| 0.16 | 0.8 |
|
||||
| 0.15 | 0.7 |
|
||||
| 0.14 | 0.6 |
|
||||
| 0.13 | 0.4-0.5 |
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ Add the following to your `Cargo.toml`:
|
|||
|
||||
```toml
|
||||
[dependencies]
|
||||
bevy_scriptum = { version = "0.7", features = ["lua"] }
|
||||
bevy_scriptum = { version = "0.8", features = ["lua"] }
|
||||
```
|
||||
|
||||
or execute `cargo add bevy_scriptum --features lua` from your project directory.
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ Add the following to your `Cargo.toml`:
|
|||
|
||||
```toml
|
||||
[dependencies]
|
||||
bevy = "0.15"
|
||||
bevy_scriptum = { version = "0.7", features = ["lua"] }
|
||||
bevy = "0.16"
|
||||
bevy_scriptum = { version = "0.8", features = ["lua"] }
|
||||
```
|
||||
|
||||
If you need a different version of bevy you need to use a matching bevy_scriptum
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ Add the following to your `Cargo.toml`:
|
|||
|
||||
```toml
|
||||
[dependencies]
|
||||
bevy = "0.15"
|
||||
bevy_scriptum = { version = "0.7", features = ["rhai"] }
|
||||
bevy = "0.16"
|
||||
bevy_scriptum = { version = "0.8", features = ["rhai"] }
|
||||
```
|
||||
|
||||
If you need a different version of bevy you need to use a matching bevy_scriptum
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ To enable live reload it should be enough to enable `file-watcher` feature
|
|||
within bevy dependency in `Cargo.toml`
|
||||
|
||||
```
|
||||
bevy = { version = "0.15", features = ["file_watcher"] }
|
||||
bevy = { version = "0.16", features = ["file_watcher"] }
|
||||
```
|
||||
|
||||
## Init-teardown pattern for game development
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ fn main() {
|
|||
.add_systems(Update, call_lua_on_update_from_rust)
|
||||
.add_scripting::<LuaRuntime>(|runtime| {
|
||||
runtime.add_function(String::from("quit"), |mut exit: EventWriter<AppExit>| {
|
||||
exit.send(AppExit::Success);
|
||||
exit.write(AppExit::Success);
|
||||
});
|
||||
})
|
||||
.run();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ fn main() {
|
|||
.add_scripting::<LuaRuntime>(|builder| {
|
||||
builder.add_function(
|
||||
String::from("get_player_name"),
|
||||
|player_names: Query<&Name, With<Player>>| player_names.single().to_string(),
|
||||
|player_names: Query<&Name, With<Player>>| player_names.single().expect("Missing player_names").to_string(),
|
||||
);
|
||||
})
|
||||
.add_systems(Startup, startup)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,6 @@ fn print_entity_names_and_quit(query: Query<&Name>, mut exit: EventWriter<AppExi
|
|||
for e in &query {
|
||||
println!("{}", e);
|
||||
}
|
||||
exit.send(AppExit::Success);
|
||||
exit.write(AppExit::Success);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ fn main() {
|
|||
.add_systems(Update, call_rhai_on_update_from_rust)
|
||||
.add_scripting::<RhaiRuntime>(|runtime| {
|
||||
runtime.add_function(String::from("quit"), |mut exit: EventWriter<AppExit>| {
|
||||
exit.send(AppExit::Success);
|
||||
exit.write(AppExit::Success);
|
||||
});
|
||||
})
|
||||
.run();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ fn main() {
|
|||
.add_scripting::<RhaiRuntime>(|builder| {
|
||||
builder.add_function(
|
||||
String::from("get_player_name"),
|
||||
|player_names: Query<&Name, With<Player>>| player_names.single().to_string(),
|
||||
|player_names: Query<&Name, With<Player>>| player_names.single().expect("Missing player_names").to_string(),
|
||||
);
|
||||
})
|
||||
.add_systems(Startup, startup)
|
||||
|
|
|
|||
|
|
@ -36,6 +36,6 @@ fn print_entity_names_and_quit(query: Query<&Name>, mut exit: EventWriter<AppExi
|
|||
for e in &query {
|
||||
println!("{}", e);
|
||||
}
|
||||
exit.send(AppExit::Success);
|
||||
exit.write(AppExit::Success);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::marker::PhantomData;
|
|||
|
||||
use bevy::{
|
||||
asset::{io::Reader, Asset, AssetLoader, LoadContext},
|
||||
utils::ConditionalSendFuture,
|
||||
tasks::ConditionalSendFuture,
|
||||
};
|
||||
|
||||
/// A loader for script assets.
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@
|
|||
//!
|
||||
//! ```toml
|
||||
//! [dependencies]
|
||||
//! bevy_scriptum = { version = "0.7", features = ["lua"] }
|
||||
//! bevy_scriptum = { version = "0.8", features = ["lua"] }
|
||||
//! ```
|
||||
//!
|
||||
//! or execute `cargo add bevy_scriptum --features lua` from your project directory.
|
||||
|
|
@ -187,6 +187,7 @@
|
|||
//!
|
||||
//! | bevy version | bevy_scriptum version |
|
||||
//! |--------------|-----------------------|
|
||||
//! | 0.16 | 0.8 |
|
||||
//! | 0.15 | 0.7 |
|
||||
//! | 0.14 | 0.6 |
|
||||
//! | 0.13 | 0.4-0.5 |
|
||||
|
|
@ -258,7 +259,7 @@ use std::{
|
|||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use bevy::{app::MainScheduleOrder, ecs::schedule::ScheduleLabel, prelude::*};
|
||||
use bevy::{app::MainScheduleOrder, ecs::{component::Mutable, schedule::ScheduleLabel}, prelude::*};
|
||||
use callback::{Callback, IntoCallbackSystem};
|
||||
use systems::{init_callbacks, log_errors, process_calls};
|
||||
use thiserror::Error;
|
||||
|
|
@ -290,7 +291,7 @@ pub enum ScriptingError {
|
|||
pub trait Runtime: Resource + Default {
|
||||
type Schedule: ScheduleLabel + Debug + Clone + Eq + Hash + Default;
|
||||
type ScriptAsset: Asset + From<String> + GetExtensions;
|
||||
type ScriptData: Component;
|
||||
type ScriptData: Component<Mutability = Mutable>;
|
||||
type CallContext: Send + Clone;
|
||||
type Value: Send + Clone;
|
||||
type RawEngine;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use bevy::{
|
||||
asset::Asset,
|
||||
ecs::{component::Component, entity::Entity, schedule::ScheduleLabel, system::Resource},
|
||||
ecs::{component::Component, entity::Entity, schedule::ScheduleLabel, resource::Resource},
|
||||
math::Vec3,
|
||||
reflect::TypePath,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::fmt::Debug;
|
|||
|
||||
use bevy::{
|
||||
asset::Asset,
|
||||
ecs::{component::Component, entity::Entity, schedule::ScheduleLabel, system::Resource},
|
||||
ecs::{component::Component, entity::Entity, schedule::ScheduleLabel, resource::Resource},
|
||||
math::Vec3,
|
||||
reflect::TypePath,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use bevy::{prelude::*, utils::tracing};
|
||||
use bevy::{prelude::*, log::tracing};
|
||||
use std::{
|
||||
fmt::Display,
|
||||
sync::{Arc, Mutex},
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ fn call_script_on_update_from_rust<R: Runtime>(
|
|||
) where
|
||||
(): for<'a> FuncArgs<'a, R::Value, R>,
|
||||
{
|
||||
let (entity, mut script_data) = scripted_entities.single_mut();
|
||||
let (entity, mut script_data) = scripted_entities.single_mut().unwrap();
|
||||
scripting_runtime
|
||||
.call_fn("test_func", &mut script_data, entity, ())
|
||||
.unwrap();
|
||||
|
|
@ -83,7 +83,7 @@ macro_rules! scripting_tests {
|
|||
.to_string(),
|
||||
|mut scripted_entities: Query<(Entity, &mut <$runtime as Runtime>::ScriptData)>,
|
||||
scripting_runtime: ResMut<$runtime>| {
|
||||
let (entity, mut script_data) = scripted_entities.single_mut();
|
||||
let (entity, mut script_data) = scripted_entities.single_mut().unwrap();
|
||||
scripting_runtime
|
||||
.call_fn("test_func", &mut script_data, entity, vec![1])
|
||||
.unwrap();
|
||||
|
|
@ -178,7 +178,7 @@ macro_rules! scripting_tests {
|
|||
.to_string(),
|
||||
|mut scripted_entities: Query<(Entity, &mut <$runtime as Runtime>::ScriptData)>,
|
||||
scripting_runtime: ResMut<$runtime>| {
|
||||
let (entity, mut script_data) = scripted_entities.single_mut();
|
||||
let (entity, mut script_data) = scripted_entities.single_mut().unwrap();
|
||||
scripting_runtime
|
||||
.call_fn("test_func", &mut script_data, entity, vec![1])
|
||||
.unwrap();
|
||||
|
|
@ -203,7 +203,7 @@ macro_rules! scripting_tests {
|
|||
.to_string(),
|
||||
|mut scripted_entities: Query<(Entity, &mut <$runtime as Runtime>::ScriptData)>,
|
||||
scripting_runtime: ResMut<$runtime>| {
|
||||
let (entity, mut script_data) = scripted_entities.single_mut();
|
||||
let (entity, mut script_data) = scripted_entities.single_mut().unwrap();
|
||||
scripting_runtime
|
||||
.call_fn(
|
||||
"test_func",
|
||||
|
|
@ -239,7 +239,7 @@ macro_rules! scripting_tests {
|
|||
.to_string(),
|
||||
|mut scripted_entities: Query<(Entity, &mut <$runtime as Runtime>::ScriptData)>,
|
||||
scripting_runtime: ResMut<$runtime>| {
|
||||
let (entity, mut script_data) = scripted_entities.single_mut();
|
||||
let (entity, mut script_data) = scripted_entities.single_mut().unwrap();
|
||||
scripting_runtime
|
||||
.call_fn("test_func", &mut script_data, entity, vec![1, 2])
|
||||
.unwrap();
|
||||
|
|
@ -265,7 +265,7 @@ macro_rules! scripting_tests {
|
|||
.to_string(),
|
||||
|mut scripted_entities: Query<(Entity, &mut <$runtime as Runtime>::ScriptData)>,
|
||||
scripting_runtime: ResMut<$runtime>| {
|
||||
let (entity, mut script_data) = scripted_entities.single_mut();
|
||||
let (entity, mut script_data) = scripted_entities.single_mut().unwrap();
|
||||
let result =
|
||||
scripting_runtime.call_fn("test_func", &mut script_data, entity, ());
|
||||
assert!(result.is_err());
|
||||
|
|
@ -288,7 +288,7 @@ macro_rules! scripting_tests {
|
|||
.to_string(),
|
||||
|mut scripted_entities: Query<(Entity, &mut <$runtime as Runtime>::ScriptData)>,
|
||||
scripting_runtime: ResMut<$runtime>| {
|
||||
let (entity, mut script_data) = scripted_entities.single_mut();
|
||||
let (entity, mut script_data) = scripted_entities.single_mut().unwrap();
|
||||
let result =
|
||||
scripting_runtime.call_fn("does_not_exist", &mut script_data, entity, ());
|
||||
assert!(result.is_err());
|
||||
|
|
@ -368,7 +368,7 @@ macro_rules! scripting_tests {
|
|||
|
||||
app.world_mut()
|
||||
.run_system_once(|tagged: Query<&MyTag>| {
|
||||
tagged.single();
|
||||
tagged.single().unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue