Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Bevy Micro LDTK
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Micro LDTK
Commits
dec7660f
Verified
Commit
dec7660f
authored
1 year ago
by
Louis
Browse files
Options
Downloads
Patches
Plain Diff
Handle version difference in autorule tile ids
parent
f474f397
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cargo.toml
+17
-15
17 additions, 15 deletions
Cargo.toml
src/ldtk/mod.rs
+27
-17
27 additions, 17 deletions
src/ldtk/mod.rs
src/lib.rs
+3
-50
3 additions, 50 deletions
src/lib.rs
with
47 additions
and
82 deletions
Cargo.toml
+
17
−
15
View file @
dec7660f
...
...
@@ -12,23 +12,25 @@ license = "Apache-2.0"
[features]
default
=
[
"ldtk_1_5_3"
,
"autotile"
]
ldtk_1_5_3
=
[
"_supports_
intgridgroup
"
]
ldtk_1_4_1
=
[
"_supports_intgridgroup"
]
ldtk_1_4_0
=
[
"_supports_intgridgroup"
]
ldtk_1_3_0
=
[]
ldtk_1_2_5
=
[]
ldtk_1_2_4
=
[]
ldtk_1_2_3
=
[]
ldtk_1_2_2
=
[]
ldtk_1_2_1
=
[]
ldtk_1_2_0
=
[]
ldtk_1_1_3
=
[]
ldtk_1_1_2
=
[]
ldtk_1_1_1
=
[]
ldtk_1_1_0
=
[]
ldtk_1_0_0
=
[]
ldtk_1_5_3
=
[
"_supports_
ldtk"
,
"_supports_intgridgroup"
,
"_optional_tile_list
"
]
ldtk_1_4_1
=
[
"_supports_ldtk"
,
"_supports_intgridgroup"
]
ldtk_1_4_0
=
[
"_supports_ldtk"
,
"_supports_intgridgroup"
]
ldtk_1_3_0
=
[
"_supports_ldtk"
]
ldtk_1_2_5
=
[
"_supports_ldtk"
]
ldtk_1_2_4
=
[
"_supports_ldtk"
]
ldtk_1_2_3
=
[
"_supports_ldtk"
]
ldtk_1_2_2
=
[
"_supports_ldtk"
]
ldtk_1_2_1
=
[
"_supports_ldtk"
]
ldtk_1_2_0
=
[
"_supports_ldtk"
]
ldtk_1_1_3
=
[
"_supports_ldtk"
]
ldtk_1_1_2
=
[
"_supports_ldtk"
]
ldtk_1_1_1
=
[
"_supports_ldtk"
]
ldtk_1_1_0
=
[
"_supports_ldtk"
]
ldtk_1_0_0
=
[
"_supports_ldtk"
]
autotile
=
[
"micro_autotile"
]
_supports_intgridgroup
=
[]
_supports_ldtk
=
[]
_optional_tile_list
=
[]
no_panic
=
[]
[dependencies]
...
...
This diff is collapsed.
Click to expand it.
src/ldtk/mod.rs
+
27
−
17
View file @
dec7660f
...
...
@@ -45,6 +45,8 @@ pub use data_1_2_5::*;
pub
use
data_1_3_0
::
*
;
#[cfg(any(feature
=
"ldtk_1_4_1"
,
feature
=
"ldtk_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
;
#[derive(thiserror::Error,
Debug)]
...
...
@@ -272,7 +274,23 @@ impl AssetLoader for LdtkLevelLoader {
mod
autotile_support
{
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
{
fn
from
(
value
:
&
AutoLayerRuleGroup
)
->
Self
{
...
...
@@ -280,19 +298,13 @@ mod autotile_support {
.rules
.iter
()
.filter_map
(|
rule
|
match
rule
.size
{
1
=>
{
let
rule
=
AutoTileRule
{
chance
:
rule
.chance
as
f32
,
output
:
TileOutput
::
Random
(
rule
.tile_ids
.iter
()
.map
(|
val
|
*
val
as
usize
)
.collect
(),
),
matcher
:
TileMatcher
::
single_match
(
TileStatus
::
from_ldtk_value
(
rule
.pattern
[
0
],
)),
};
Some
(
rule
)
}
1
=>
Some
(
AutoTileRule
{
chance
:
rule
.chance
as
f32
,
output
:
create_output
(
rule
),
matcher
:
TileMatcher
::
single_match
(
TileStatus
::
from_ldtk_value
(
rule
.pattern
[
0
],
)),
}),
3
=>
{
if
rule
.pattern
.len
()
==
9
{
let
matcher
=
TileMatcher
([
...
...
@@ -310,9 +322,7 @@ mod autotile_support {
let
rule
=
AutoTileRule
{
chance
:
rule
.chance
as
f32
,
matcher
,
output
:
TileOutput
::
Random
(
rule
.tile_ids
.iter
()
.map
(|
val
|
*
val
as
usize
)
.collect
(),
),
output
:
create_output
(
rule
),
};
Some
(
rule
)
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
3
−
50
View file @
dec7660f
#[cfg(any(
feature
=
"ldtk_1_5_3"
,
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"
,
))]
#[cfg(feature
=
"_supports_ldtk"
)]
mod
assets
;
mod
camera
;
mod
map_query
;
mod
pregen
;
mod
system
;
#[cfg(any(
feature
=
"ldtk_1_5_3"
,
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"
,
))]
#[cfg(feature
=
"_supports_ldtk"
)]
pub
mod
ldtk
;
pub
static
mut
LDTK_TILE_SCALE
:
AtomicU32
=
AtomicU32
::
new
(
32
);
...
...
@@ -64,22 +32,7 @@ mod __plugin {
pub
struct
MicroLDTKPlugin
;
impl
Plugin
for
MicroLDTKPlugin
{
fn
build
(
&
self
,
app
:
&
mut
App
)
{
#[cfg(any(
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"
,
))]
#[cfg(feature
=
"_supports_ldtk"
)]
{
app
.add_event
::
<
super
::
system
::
LevelDataUpdated
>
()
.init_asset
::
<
super
::
ldtk
::
Project
>
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment