adrien-bon / bevy_ecs_tiled

Helpers for working with 2D tilemaps created with the Tiled map editor
MIT License
35 stars 8 forks source link

TiledClass break bevy native compoment. #37

Closed darkautism closed 1 month ago

darkautism commented 1 month ago
#[derive(TiledObject, Bundle, Default, Reflect, Debug)]
struct PlayerBundle {
    p:Player,
}

#[derive(TiledClass, Reflect, Debug, Default, Component)]
struct Player;

I register this type and I want create an system to spawn player when compoment spawn

.add_systems(Update, spawnplayer.run_if(any_with_component::<Player>))

Then the compiler was angry!

error[E0599]: the method `run_if` exists for fn item `fn(&mut Commands<'b, 'c>, Query<'d, 'e, &Transform, With<Player>>) {spawnplayer}`, but its trait bounds were not satisfied
  --> src/main.rs:21:42
   |
21 |         .add_systems(Update, spawnplayer.run_if(any_with_component::<Player>))
   |                                          ^^^^^^ method cannot be called due to unsatisfied trait bounds
   |
   = note: the following trait bounds were not satisfied:
           `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: IntoSystem<(), (), _>`    
           which is required by `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: bevy::prelude::IntoSystemConfigs<_>`
           `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: SystemSet`
           which is required by `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: bevy::prelude::IntoSystemSetConfigs`
           `&for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: IntoSystem<(), (), _>`   
           which is required by `&for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: bevy::prelude::IntoSystemConfigs<_>`
           `&for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: SystemSet`
           which is required by `&for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: bevy::prelude::IntoSystemSetConfigs`
           `&mut for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: IntoSystem<(), (), _>`
           which is required by `&mut for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: 
bevy::prelude::IntoSystemConfigs<_>`
           `&mut for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: SystemSet`
           which is required by `&mut for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut bevy::prelude::Commands<'b, 'c>, bevy::prelude::Query<'d, 'e, &'f bevy::prelude::Transform, bevy::prelude::With<Player>>) {spawnplayer}: 
bevy::prelude::IntoSystemSetConfigs`

What can i do?

darkautism commented 1 month ago

My fault, system param has some typo.