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