Skip to content

Commit

Permalink
Add EnableDynamicAutotiling
Browse files Browse the repository at this point in the history
  • Loading branch information
haath committed Dec 30, 2024
1 parent da1b015 commit a566896
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ pub(crate) fn apply_int_grid_autotiling(
(&IntGridLayerCellValues, &IntGridLayerAffectedLayers),
Changed<IntGridLayerCellValues>,
>,
layer_query: Query<(&LayerMetadata, &Parent)>,
layer_query: Query<(&LayerMetadata, &Parent), With<EnableDynamicAutotiling>>,
level_query: Query<&Parent, With<LevelIid>>,
project_query: Query<&LdtkProjectHandle>,
ldtk_project_assets: Res<Assets<LdtkProject>>,
Expand Down

0 comments on commit a566896

Please sign in to comment.