Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • microhacks/bevy-micro-ldtk
1 result
Show changes
Commits on Source (2)
...@@ -1701,7 +1701,7 @@ dependencies = [ ...@@ -1701,7 +1701,7 @@ dependencies = [
[[package]] [[package]]
name = "micro_ldtk" name = "micro_ldtk"
version = "0.9.0" version = "0.9.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bevy", "bevy",
......
[package] [package]
name = "micro_ldtk" name = "micro_ldtk"
version = "0.9.0" version = "0.9.1"
edition = "2021" edition = "2021"
authors = [ authors = [
...@@ -12,23 +12,25 @@ license = "Apache-2.0" ...@@ -12,23 +12,25 @@ license = "Apache-2.0"
[features] [features]
default = ["ldtk_1_5_3", "autotile"] default = ["ldtk_1_5_3", "autotile"]
ldtk_1_5_3 = ["_supports_intgridgroup"] ldtk_1_5_3 = ["_supports_ldtk", "_supports_intgridgroup", "_optional_tile_list"]
ldtk_1_4_1 = ["_supports_intgridgroup"] ldtk_1_4_1 = ["_supports_ldtk", "_supports_intgridgroup"]
ldtk_1_4_0 = ["_supports_intgridgroup"] ldtk_1_4_0 = ["_supports_ldtk", "_supports_intgridgroup"]
ldtk_1_3_0 = [] ldtk_1_3_0 = ["_supports_ldtk"]
ldtk_1_2_5 = [] ldtk_1_2_5 = ["_supports_ldtk"]
ldtk_1_2_4 = [] ldtk_1_2_4 = ["_supports_ldtk"]
ldtk_1_2_3 = [] ldtk_1_2_3 = ["_supports_ldtk"]
ldtk_1_2_2 = [] ldtk_1_2_2 = ["_supports_ldtk"]
ldtk_1_2_1 = [] ldtk_1_2_1 = ["_supports_ldtk"]
ldtk_1_2_0 = [] ldtk_1_2_0 = ["_supports_ldtk"]
ldtk_1_1_3 = [] ldtk_1_1_3 = ["_supports_ldtk"]
ldtk_1_1_2 = [] ldtk_1_1_2 = ["_supports_ldtk"]
ldtk_1_1_1 = [] ldtk_1_1_1 = ["_supports_ldtk"]
ldtk_1_1_0 = [] ldtk_1_1_0 = ["_supports_ldtk"]
ldtk_1_0_0 = [] ldtk_1_0_0 = ["_supports_ldtk"]
autotile = ["micro_autotile"] autotile = ["micro_autotile"]
_supports_intgridgroup = [] _supports_intgridgroup = []
_supports_ldtk = []
_optional_tile_list = []
no_panic = [] no_panic = []
[dependencies] [dependencies]
......
...@@ -45,6 +45,8 @@ pub use data_1_2_5::*; ...@@ -45,6 +45,8 @@ pub use data_1_2_5::*;
pub use data_1_3_0::*; pub use data_1_3_0::*;
#[cfg(any(feature = "ldtk_1_4_1", feature = "ldtk_1_4_0"))] #[cfg(any(feature = "ldtk_1_4_1", feature = "ldtk_1_4_0"))]
pub use data_1_4_0::*; pub use data_1_4_0::*;
#[cfg(any(feature = "ldtk_1_5_3"))]
pub use data_1_5_3::*;
use serde::Deserialize; use serde::Deserialize;
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
...@@ -272,7 +274,23 @@ impl AssetLoader for LdtkLevelLoader { ...@@ -272,7 +274,23 @@ impl AssetLoader for LdtkLevelLoader {
mod autotile_support { mod autotile_support {
use micro_autotile::{AutoRuleSet, AutoTileRule, TileMatcher, TileOutput, TileStatus}; use micro_autotile::{AutoRuleSet, AutoTileRule, TileMatcher, TileOutput, TileStatus};
use crate::ldtk::{AutoLayerRuleGroup, Project}; use crate::ldtk::{AutoLayerRuleDefinition, AutoLayerRuleGroup, Project};
#[cfg(feature = "_optional_tile_list")]
fn create_output(rule: &AutoLayerRuleDefinition) -> TileOutput {
TileOutput::Random(
rule.tile_rects_ids
.iter()
.flatten()
.map(|val| *val as usize)
.collect(),
)
}
#[cfg(not(feature = "_optional_tile_list"))]
fn create_output(rule: &AutoLayerRuleDefinition) -> TileOutput {
TileOutput::Random(rule.tile_ids.iter().map(|val| *val as usize).collect())
}
impl From<&AutoLayerRuleGroup> for AutoRuleSet { impl From<&AutoLayerRuleGroup> for AutoRuleSet {
fn from(value: &AutoLayerRuleGroup) -> Self { fn from(value: &AutoLayerRuleGroup) -> Self {
...@@ -280,19 +298,13 @@ mod autotile_support { ...@@ -280,19 +298,13 @@ mod autotile_support {
.rules .rules
.iter() .iter()
.filter_map(|rule| match rule.size { .filter_map(|rule| match rule.size {
1 => { 1 => Some(AutoTileRule {
let rule = AutoTileRule { chance: rule.chance as f32,
chance: rule.chance as f32, output: create_output(rule),
output: TileOutput::Random( matcher: TileMatcher::single_match(TileStatus::from_ldtk_value(
rule.tile_ids.iter().map(|val| *val as usize).collect(), rule.pattern[0],
), )),
matcher: TileMatcher::single_match(TileStatus::from_ldtk_value( }),
rule.pattern[0],
)),
};
Some(rule)
}
3 => { 3 => {
if rule.pattern.len() == 9 { if rule.pattern.len() == 9 {
let matcher = TileMatcher([ let matcher = TileMatcher([
...@@ -310,9 +322,7 @@ mod autotile_support { ...@@ -310,9 +322,7 @@ mod autotile_support {
let rule = AutoTileRule { let rule = AutoTileRule {
chance: rule.chance as f32, chance: rule.chance as f32,
matcher, matcher,
output: TileOutput::Random( output: create_output(rule),
rule.tile_ids.iter().map(|val| *val as usize).collect(),
),
}; };
Some(rule) Some(rule)
......
#[cfg(any( #[cfg(feature = "_supports_ldtk")]
feature = "ldtk_1_4_1",
feature = "ldtk_1_4_0",
feature = "ldtk_1_3_0",
feature = "ldtk_1_2_5",
feature = "ldtk_1_2_4",
feature = "ldtk_1_2_3",
feature = "ldtk_1_2_2",
feature = "ldtk_1_2_1",
feature = "ldtk_1_2_0",
feature = "ldtk_1_1_3",
feature = "ldtk_1_1_2",
feature = "ldtk_1_1_1",
feature = "ldtk_1_1_0",
feature = "ldtk_1_0_0",
))]
mod assets; mod assets;
mod camera; mod camera;
mod map_query; mod map_query;
mod pregen; mod pregen;
mod system; mod system;
#[cfg(any( #[cfg(feature = "_supports_ldtk")]
feature = "ldtk_1_4_1",
feature = "ldtk_1_4_0",
feature = "ldtk_1_3_0",
feature = "ldtk_1_2_5",
feature = "ldtk_1_2_4",
feature = "ldtk_1_2_3",
feature = "ldtk_1_2_2",
feature = "ldtk_1_2_1",
feature = "ldtk_1_2_0",
feature = "ldtk_1_1_3",
feature = "ldtk_1_1_2",
feature = "ldtk_1_1_1",
feature = "ldtk_1_1_0",
feature = "ldtk_1_0_0",
))]
pub mod ldtk; pub mod ldtk;
pub static mut LDTK_TILE_SCALE: AtomicU32 = AtomicU32::new(32); pub static mut LDTK_TILE_SCALE: AtomicU32 = AtomicU32::new(32);
...@@ -62,22 +32,7 @@ mod __plugin { ...@@ -62,22 +32,7 @@ mod __plugin {
pub struct MicroLDTKPlugin; pub struct MicroLDTKPlugin;
impl Plugin for MicroLDTKPlugin { impl Plugin for MicroLDTKPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
#[cfg(any( #[cfg(feature = "_supports_ldtk")]
feature = "ldtk_1_4_1",
feature = "ldtk_1_4_0",
feature = "ldtk_1_3_0",
feature = "ldtk_1_2_5",
feature = "ldtk_1_2_4",
feature = "ldtk_1_2_3",
feature = "ldtk_1_2_2",
feature = "ldtk_1_2_1",
feature = "ldtk_1_2_0",
feature = "ldtk_1_1_3",
feature = "ldtk_1_1_2",
feature = "ldtk_1_1_1",
feature = "ldtk_1_1_0",
feature = "ldtk_1_0_0",
))]
{ {
app.add_event::<super::system::LevelDataUpdated>() app.add_event::<super::system::LevelDataUpdated>()
.init_asset::<super::ldtk::Project>() .init_asset::<super::ldtk::Project>()
......