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
6913fb2c
Verified
Commit
6913fb2c
authored
1 year ago
by
Louis
Browse files
Options
Downloads
Patches
Plain Diff
apply clippy suggestions
parent
54a96c57
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/ldtk/mod.rs
+1
-1
1 addition, 1 deletion
src/ldtk/mod.rs
src/map_query.rs
+1
-1
1 addition, 1 deletion
src/map_query.rs
src/pregen.rs
+1
-1
1 addition, 1 deletion
src/pregen.rs
src/system/types.rs
+21
-36
21 additions, 36 deletions
src/system/types.rs
with
24 additions
and
39 deletions
src/ldtk/mod.rs
+
1
−
1
View file @
6913fb2c
...
...
@@ -153,7 +153,7 @@ mod test {
let
project
=
Project
::
from_bytes
(
project_data
)
.expect
(
"Failed to parse project file"
);
for
layer
in
project
.defs.layers
.iter
()
{
for
auto_rule_group
in
layer
.auto_rule_groups
.iter
()
{}
for
_
auto_rule_group
in
layer
.auto_rule_groups
.iter
()
{}
}
}
}
This diff is collapsed.
Click to expand it.
src/map_query.rs
+
1
−
1
View file @
6913fb2c
...
...
@@ -8,7 +8,7 @@ use bevy::prelude::*;
use
crate
::
assets
::
LevelIndex
;
use
crate
::
ldtk
::
EntityInstance
;
use
crate
::
system
::
ActiveLevel
;
use
crate
::{
get_ldtk_tile_scale
,
LdtkLayer
,
LdtkLevel
};
use
crate
::{
LdtkLayer
,
LdtkLevel
};
#[derive(SystemParam)]
pub
struct
MapQuery
<
'w
,
's
>
{
...
...
This diff is collapsed.
Click to expand it.
src/pregen.rs
+
1
−
1
View file @
6913fb2c
use
bevy
::
prelude
::{
Handle
,
Image
,
TextureAtlas
};
use
bevy
::
prelude
::{
Image
,
TextureAtlas
};
use
bevy
::
render
::
render_resource
::
TextureFormat
;
use
bevy
::
render
::
texture
::
TextureFormatPixelInfo
;
...
...
This diff is collapsed.
Click to expand it.
src/system/types.rs
+
21
−
36
View file @
6913fb2c
...
...
@@ -5,7 +5,7 @@ use std::path::Path;
use
bevy
::
math
::{
IVec2
,
Rect
,
UVec2
,
Vec2
};
use
num_traits
::
AsPrimitive
;
use
quadtree_rs
::
area
::
{
Area
,
AreaBuilder
}
;
use
quadtree_rs
::
area
::
AreaBuilder
;
use
quadtree_rs
::
point
::
Point
;
use
quadtree_rs
::
Quadtree
;
use
serde
::{
Deserialize
,
Serialize
};
...
...
@@ -148,7 +148,7 @@ impl LdtkLevel {
self
.properties
.get
(
&
name
.to_string
())
}
pub
fn
property_or_null
(
&
self
,
name
:
impl
ToString
)
->
&
Value
{
self
.property
(
name
)
.unwrap_or
_else
(||
&
Value
::
Null
)
self
.property
(
name
)
.unwrap_or
(
&
Value
::
Null
)
}
pub
fn
get_indexer
(
&
self
)
->
Indexer
{
Indexer
::
new
(
px_to_grid
(
self
.level.px_wid
),
px_to_grid
(
self
.level.px_hei
))
...
...
@@ -170,10 +170,10 @@ impl From<Level> for LdtkLevel {
let
fields
=
std
::
mem
::
take
(
&
mut
value
.field_instances
);
for
field
in
fields
{
properties
.insert
(
field
.identifier
,
field
.value
.unwrap_or
_else
(||
Value
::
Null
));
properties
.insert
(
field
.identifier
,
field
.value
.unwrap_or
(
Value
::
Null
));
}
let
level_width
=
value
.px_wid
;
let
_
level_width
=
value
.px_wid
;
let
level_height
=
value
.px_hei
;
let
mut
level
=
Self
{
...
...
@@ -196,14 +196,14 @@ impl From<Level> for LdtkLevel {
for
field
in
entity
.field_instances
.iter
()
{
properties
.insert
(
field
.identifier
.clone
(),
field
.value
.as_ref
()
.unwrap_or
_else
(||
&
Value
::
Null
)
.clone
(),
field
.value
.as_ref
()
.unwrap_or
(
&
Value
::
Null
)
.clone
(),
);
}
let
width
=
entity
.width
;
let
_
width
=
entity
.width
;
let
height
=
entity
.height
;
let
left_x
=
entity
.px
[
0
];
let
bottom_y
=
level_height
-
(
entity
.px
[
1
]
+
height
);
let
_
left_x
=
entity
.px
[
0
];
let
_
bottom_y
=
level_height
-
(
entity
.px
[
1
]
+
height
);
let
size
=
IVec2
::
new
(
entity
.width
as
i32
,
entity
.height
as
i32
);
let
position
=
IVec2
::
new
(
level
.level.px_wid
as
i32
,
level
.level.px_hei
as
i32
)
...
...
@@ -216,15 +216,12 @@ impl From<Level> for LdtkLevel {
collides
:
true
,
};
match
AreaBuilder
::
default
()
if
let
Ok
(
point
)
=
AreaBuilder
::
default
()
.anchor
(
Point
::
from
((
position
.x
as
i64
,
position
.y
as
i64
)))
.dimensions
((
size
.x
as
i64
,
size
.y
as
i64
))
.build
()
{
Ok
(
point
)
=>
{
collider_quads
.insert
(
point
,
entity
);
}
Err
(
_
)
=>
{}
collider_quads
.insert
(
point
,
entity
);
}
}
}
...
...
@@ -424,7 +421,7 @@ fn convert_map_types(map: &Map<String, Value>) -> HashMap<String, Value> {
impl
Properties
{
pub
fn
as_string
(
&
self
,
name
:
impl
ToString
)
->
Option
<
String
>
{
self
.get
(
&
name
.to_string
())
.and_then
(|
value
|
match
value
{
Value
::
String
(
value
)
=>
Some
(
format!
(
"{}"
,
value
)),
Value
::
String
(
value
)
=>
Some
(
value
.to_string
(
)),
Value
::
Bool
(
value
)
=>
Some
(
format!
(
"{}"
,
value
)),
Value
::
Number
(
value
)
=>
Some
(
format!
(
"{}"
,
value
)),
_
=>
None
,
...
...
@@ -492,17 +489,11 @@ impl Properties {
}
}
pub
fn
is_null
(
&
self
,
name
:
impl
ToString
)
->
bool
{
match
self
.0
.get
(
&
name
.to_string
())
{
Some
(
Value
::
Null
)
=>
true
,
_
=>
false
,
}
matches!
(
self
.0
.get
(
&
name
.to_string
()),
Some
(
Value
::
Null
))
}
pub
fn
is_null_or_undefined
(
&
self
,
name
:
impl
ToString
)
->
bool
{
match
self
.0
.get
(
&
name
.to_string
())
{
None
|
Some
(
Value
::
Null
)
=>
true
,
_
=>
false
,
}
matches!
(
self
.0
.get
(
&
name
.to_string
()),
None
|
Some
(
Value
::
Null
))
}
pub
fn
is_null_or_falsy
(
&
self
,
name
:
impl
ToString
)
->
bool
{
...
...
@@ -607,24 +598,18 @@ impl WorldLayer {
}
pub
fn
for_each_tile
(
&
self
,
mut
cb
:
impl
FnMut
(
i64
,
i64
,
&
WorldTile
))
{
match
&
self
.layer_data
{
LayerType
::
GidTiles
(
map
)
=>
{
map
.iter
()
.for_each
(|(
pos
,
tile
)|
{
cb
(
pos
.0
,
pos
.1
,
tile
);
});
}
_
=>
{}
if
let
LayerType
::
GidTiles
(
map
)
=
&
self
.layer_data
{
map
.iter
()
.for_each
(|(
pos
,
tile
)|
{
cb
(
pos
.0
,
pos
.1
,
tile
);
});
}
}
pub
fn
for_each_tile_mut
(
&
mut
self
,
mut
cb
:
impl
FnMut
(
i64
,
i64
,
&
mut
WorldTile
))
{
match
&
mut
self
.layer_data
{
LayerType
::
GidTiles
(
map
)
=>
{
map
.iter_mut
()
.for_each
(|(
pos
,
tile
)|
{
cb
(
pos
.0
,
pos
.1
,
tile
);
});
}
_
=>
{}
if
let
LayerType
::
GidTiles
(
map
)
=
&
mut
self
.layer_data
{
map
.iter_mut
()
.for_each
(|(
pos
,
tile
)|
{
cb
(
pos
.0
,
pos
.1
,
tile
);
});
}
}
...
...
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