|
@@ -56,15 +56,10 @@ pub fn world_from_file<P: AsRef<Path>>(w: &mut specs::World, path: P) {
|
|
|
let y = y as f32 * consts::TILE_SIZE;
|
|
|
let u = ((n - 1) % 32) as u8;
|
|
|
let v = ((n - u as u32 - 1) / 32) as u8;
|
|
|
- let blocking = if tilesets[0].tiles[(n-1) as usize].properties["pass"]
|
|
|
- == tiled::PropertyValue::BoolValue(false) {
|
|
|
- let mut h = w.write_resource::<World>();
|
|
|
- Some(Blocking::new_box(&mut h))
|
|
|
- } else {
|
|
|
- None
|
|
|
- };
|
|
|
+ let is_blocking = tilesets[0].tiles[(n-1) as usize].properties["pass"]
|
|
|
+ == tiled::PropertyValue::BoolValue(false);
|
|
|
let mut e = w
|
|
|
- .create_entity()
|
|
|
+ .create_entity_unchecked()
|
|
|
.with(Position { x, y })
|
|
|
.with(Sprite { u, v });
|
|
|
e = match phase {
|
|
@@ -73,14 +68,20 @@ pub fn world_from_file<P: AsRef<Path>>(w: &mut specs::World, path: P) {
|
|
|
DrawLayer::Decoration => e.with(Decoration),
|
|
|
};
|
|
|
|
|
|
- let e = if let Some(b) = blocking { e.with(b) } else { e };
|
|
|
+ let e = if is_blocking {
|
|
|
+ let mut h = w.write_resource::<World>();
|
|
|
+ let entity = e.entity;
|
|
|
+ e.with(Blocking::new_box(entity, &mut h))
|
|
|
+ } else {
|
|
|
+ e
|
|
|
+ };
|
|
|
e.build();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- w.create_entity_unchecked()
|
|
|
+ let e = w.create_entity_unchecked()
|
|
|
.with(Position {
|
|
|
x: 3.0 * consts::TILE_SIZE,
|
|
|
y: 3.0 * consts::TILE_SIZE,
|
|
@@ -91,10 +92,12 @@ pub fn world_from_file<P: AsRef<Path>>(w: &mut specs::World, path: P) {
|
|
|
.with(Controlled)
|
|
|
.with(Collision {
|
|
|
has_collision: false,
|
|
|
- })
|
|
|
- .with({
|
|
|
- let mut h = w.write_resource::<World>();
|
|
|
- Blocking::new_ball(&mut h)
|
|
|
- })
|
|
|
+ });
|
|
|
+
|
|
|
+ let entity = e.entity;
|
|
|
+ e.with({
|
|
|
+ let mut h = w.write_resource::<World>();
|
|
|
+ Blocking::new_ball(entity, &mut h)
|
|
|
+ })
|
|
|
.build();
|
|
|
}
|