Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bevy_mod_scripting_core::{
AddContextInitializer, StoreDocumentation,
bindings::{ReflectReference, function::from::{Ref, Mut, Val}},
};
use crate::*;
use crate::{*, namespaced_register::NamespaceBuilder};
pub struct BevyCoreScriptingPlugin;
impl ::bevy::app::Plugin for BevyCoreScriptingPlugin {
fn build(&self, app: &mut ::bevy::prelude::App) {
Expand All @@ -20,10 +20,7 @@ impl ::bevy::app::Plugin for BevyCoreScriptingPlugin {
_self: Ref<bevy::core::prelude::Name>,
other: Ref<bevy::core::prelude::Name>|
{
let output: bool = ::bevy::core::prelude::Name::eq(
_self.into(),
other.into(),
)
let output: bool = ::bevy::core::prelude::Name::eq(&_self, &other)
.into();
output
},
Expand All @@ -32,7 +29,7 @@ impl ::bevy::app::Plugin for BevyCoreScriptingPlugin {
"clone",
|_self: Ref<bevy::core::prelude::Name>| {
let output: Val<bevy::core::prelude::Name> = ::bevy::core::prelude::Name::clone(
_self.into(),
&_self,
)
.into();
output
Expand Down
179 changes: 85 additions & 94 deletions crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_ecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,38 @@ use bevy_mod_scripting_core::{
AddContextInitializer, StoreDocumentation,
bindings::{ReflectReference, function::from::{Ref, Mut, Val}},
};
use crate::*;
use crate::{*, namespaced_register::NamespaceBuilder};
pub struct BevyEcsScriptingPlugin;
impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
fn build(&self, app: &mut ::bevy::prelude::App) {
let mut world = app.world_mut();
NamespaceBuilder::<::bevy::ecs::entity::Entity>::new(world)
.overwrite_script_function(
"clone",
|_self: Ref<bevy::ecs::entity::Entity>| {
let output: Val<bevy::ecs::entity::Entity> = ::bevy::ecs::entity::Entity::clone(
&_self,
)
.into();
output
},
)
.overwrite_script_function(
"eq",
|
_self: Ref<bevy::ecs::entity::Entity>,
other: Ref<bevy::ecs::entity::Entity>|
{
let output: bool = ::bevy::ecs::entity::Entity::eq(&_self, &other)
.into();
output
},
)
.overwrite_script_function(
"from_raw",
|index: u32| {
let output: Val<bevy::ecs::entity::Entity> = ::bevy::ecs::entity::Entity::from_raw(
index.into(),
index,
)
.into();
output
Expand All @@ -35,7 +56,7 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
"from_bits",
|bits: u64| {
let output: Val<bevy::ecs::entity::Entity> = ::bevy::ecs::entity::Entity::from_bits(
bits.into(),
bits,
)
.into();
output
Expand All @@ -58,30 +79,6 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
.into();
output
},
)
.overwrite_script_function(
"eq",
|
_self: Ref<bevy::ecs::entity::Entity>,
other: Ref<bevy::ecs::entity::Entity>|
{
let output: bool = ::bevy::ecs::entity::Entity::eq(
_self.into(),
other.into(),
)
.into();
output
},
)
.overwrite_script_function(
"clone",
|_self: Ref<bevy::ecs::entity::Entity>| {
let output: Val<bevy::ecs::entity::Entity> = ::bevy::ecs::entity::Entity::clone(
_self.into(),
)
.into();
output
},
);
NamespaceBuilder::<::bevy::ecs::world::OnAdd>::new(world);
NamespaceBuilder::<::bevy::ecs::world::OnInsert>::new(world);
Expand All @@ -95,8 +92,8 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
other: Ref<bevy::ecs::component::ComponentId>|
{
let output: bool = ::bevy::ecs::component::ComponentId::eq(
_self.into(),
other.into(),
&_self,
&other,
)
.into();
output
Expand All @@ -106,27 +103,7 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
"clone",
|_self: Ref<bevy::ecs::component::ComponentId>| {
let output: Val<bevy::ecs::component::ComponentId> = ::bevy::ecs::component::ComponentId::clone(
_self.into(),
)
.into();
output
},
)
.overwrite_script_function(
"new",
|index: usize| {
let output: Val<bevy::ecs::component::ComponentId> = ::bevy::ecs::component::ComponentId::new(
index.into(),
)
.into();
output
},
)
.overwrite_script_function(
"index",
|_self: Val<bevy::ecs::component::ComponentId>| {
let output: usize = ::bevy::ecs::component::ComponentId::index(
_self.into(),
&_self,
)
.into();
output
Expand All @@ -136,52 +113,38 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
"assert_receiver_is_total_eq",
|_self: Ref<bevy::ecs::component::ComponentId>| {
let output: () = ::bevy::ecs::component::ComponentId::assert_receiver_is_total_eq(
_self.into(),
)
.into();
output
},
);
NamespaceBuilder::<::bevy::ecs::component::Tick>::new(world)
.overwrite_script_function(
"assert_receiver_is_total_eq",
|_self: Ref<bevy::ecs::component::Tick>| {
let output: () = ::bevy::ecs::component::Tick::assert_receiver_is_total_eq(
_self.into(),
&_self,
)
.into();
output
},
)
.overwrite_script_function(
"eq",
|
_self: Ref<bevy::ecs::component::Tick>,
other: Ref<bevy::ecs::component::Tick>|
{
let output: bool = ::bevy::ecs::component::Tick::eq(
_self.into(),
other.into(),
"new",
|index: usize| {
let output: Val<bevy::ecs::component::ComponentId> = ::bevy::ecs::component::ComponentId::new(
index,
)
.into();
output
},
)
.overwrite_script_function(
"clone",
|_self: Ref<bevy::ecs::component::Tick>| {
let output: Val<bevy::ecs::component::Tick> = ::bevy::ecs::component::Tick::clone(
"index",
|_self: Val<bevy::ecs::component::ComponentId>| {
let output: usize = ::bevy::ecs::component::ComponentId::index(
_self.into(),
)
.into();
output
},
)
);
NamespaceBuilder::<::bevy::ecs::component::Tick>::new(world)
.overwrite_script_function(
"new",
|tick: u32| {
let output: Val<bevy::ecs::component::Tick> = ::bevy::ecs::component::Tick::new(
tick.into(),
tick,
)
.into();
output
Expand All @@ -198,10 +161,7 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
.overwrite_script_function(
"set",
|_self: Mut<bevy::ecs::component::Tick>, tick: u32| {
let output: () = ::bevy::ecs::component::Tick::set(
_self.into(),
tick.into(),
)
let output: () = ::bevy::ecs::component::Tick::set(&mut_self, tick)
.into();
output
},
Expand All @@ -221,18 +181,39 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
.into();
output
},
);
NamespaceBuilder::<::bevy::ecs::component::ComponentTicks>::new(world)
)
.overwrite_script_function(
"clone",
|_self: Ref<bevy::ecs::component::ComponentTicks>| {
let output: Val<bevy::ecs::component::ComponentTicks> = ::bevy::ecs::component::ComponentTicks::clone(
_self.into(),
"eq",
|
_self: Ref<bevy::ecs::component::Tick>,
other: Ref<bevy::ecs::component::Tick>|
{
let output: bool = ::bevy::ecs::component::Tick::eq(&_self, &other)
.into();
output
},
)
.overwrite_script_function(
"assert_receiver_is_total_eq",
|_self: Ref<bevy::ecs::component::Tick>| {
let output: () = ::bevy::ecs::component::Tick::assert_receiver_is_total_eq(
&_self,
)
.into();
output
},
)
.overwrite_script_function(
"clone",
|_self: Ref<bevy::ecs::component::Tick>| {
let output: Val<bevy::ecs::component::Tick> = ::bevy::ecs::component::Tick::clone(
&_self,
)
.into();
output
},
);
NamespaceBuilder::<::bevy::ecs::component::ComponentTicks>::new(world)
.overwrite_script_function(
"is_added",
|
Expand All @@ -241,7 +222,7 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
this_run: Val<bevy::ecs::component::Tick>|
{
let output: bool = ::bevy::ecs::component::ComponentTicks::is_added(
_self.into(),
&_self,
last_run.into(),
this_run.into(),
)
Expand All @@ -257,7 +238,7 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
this_run: Val<bevy::ecs::component::Tick>|
{
let output: bool = ::bevy::ecs::component::ComponentTicks::is_changed(
_self.into(),
&_self,
last_run.into(),
this_run.into(),
)
Expand All @@ -282,19 +263,29 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
change_tick: Val<bevy::ecs::component::Tick>|
{
let output: () = ::bevy::ecs::component::ComponentTicks::set_changed(
_self.into(),
&mut_self,
change_tick.into(),
)
.into();
output
},
)
.overwrite_script_function(
"clone",
|_self: Ref<bevy::ecs::component::ComponentTicks>| {
let output: Val<bevy::ecs::component::ComponentTicks> = ::bevy::ecs::component::ComponentTicks::clone(
&_self,
)
.into();
output
},
);
NamespaceBuilder::<::bevy::ecs::identifier::Identifier>::new(world)
.overwrite_script_function(
"clone",
|_self: Ref<bevy::ecs::identifier::Identifier>| {
let output: Val<bevy::ecs::identifier::Identifier> = ::bevy::ecs::identifier::Identifier::clone(
_self.into(),
&_self,
)
.into();
output
Expand Down Expand Up @@ -334,7 +325,7 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
"from_bits",
|value: u64| {
let output: Val<bevy::ecs::identifier::Identifier> = ::bevy::ecs::identifier::Identifier::from_bits(
value.into(),
value,
)
.into();
output
Expand All @@ -347,8 +338,8 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
other: Ref<bevy::ecs::identifier::Identifier>|
{
let output: bool = ::bevy::ecs::identifier::Identifier::eq(
_self.into(),
other.into(),
&_self,
&other,
)
.into();
output
Expand All @@ -359,7 +350,7 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
"clone",
|_self: Ref<bevy::ecs::entity::EntityHash>| {
let output: Val<bevy::ecs::entity::EntityHash> = ::bevy::ecs::entity::EntityHash::clone(
_self.into(),
&_self,
)
.into();
output
Expand All @@ -374,7 +365,7 @@ impl ::bevy::app::Plugin for BevyEcsScriptingPlugin {
let output: Val<
bevy::ecs::removal_detection::RemovedComponentEntity,
> = ::bevy::ecs::removal_detection::RemovedComponentEntity::clone(
_self.into(),
&_self,
)
.into();
output
Expand Down
Loading