diff --git a/src/components/mod.rs b/src/components/mod.rs index 4b8fc057..4135bd54 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -38,6 +38,15 @@ pub struct IntGridCell { pub value: i32, } +/// [Component] added to any layer by default. +/// +/// It controls whether or not dynamic autotiling will be enabled for the layer. +/// That is, whether updates to the `IntGrid` values on the same or on different layers, will cause +/// the tiles on this layer to also be updated according to the autotling rules found in the [`LdtkProject`]. +#[derive(Component, Default, Debug, Reflect)] +#[reflect(Component)] +pub struct EnableDynamicAutotiling; + /// [`Component`] that indicates that an ldtk entity should be a child of the world, not their layer. /// /// For a more detailed explanation, please see the diff --git a/src/level.rs b/src/level.rs index b6895df9..d51d09ad 100644 --- a/src/level.rs +++ b/src/level.rs @@ -718,7 +718,8 @@ pub fn spawn_level( )) .insert(Visibility::default()) .insert(LayerMetadata::from(layer_instance)) - .insert(Name::new(layer_instance.identifier.to_owned())); + .insert(Name::new(layer_instance.identifier.to_owned())) + .insert(EnableDynamicAutotiling); commands.entity(ldtk_entity).add_child(layer_entity); diff --git a/src/systems.rs b/src/systems.rs index fdb1d6d3..5ca23a8a 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -298,7 +298,7 @@ pub(crate) fn apply_int_grid_autotiling( (&IntGridLayerCellValues, &IntGridLayerAffectedLayers), Changed, >, - layer_query: Query<(&LayerMetadata, &Parent)>, + layer_query: Query<(&LayerMetadata, &Parent), With>, level_query: Query<&Parent, With>, project_query: Query<&LdtkProjectHandle>, ldtk_project_assets: Res>,