1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
use std::collections::HashMap;
use std::future::Future;
use std::sync::Arc;
use bevy_math::Vec2;
pub use layer::Layer;
pub use map::Map;
pub use property::Property;
pub use texture::Texture;
#[cfg(feature = "plugin")]
pub(crate) use texture::TexturePtr;
pub use tile_type::TileType;
mod layer;
mod map;
mod parse;
mod property;
mod texture;
mod tile_type;
/// Render order for tiles in layers.
#[derive(Debug, Clone, Copy)]
#[allow(missing_docs)]
pub enum RenderOrder {
RightDown,
RightUp,
LeftDown,
LeftUp,
}
/// A tileset
pub struct Tileset {
/// The global tile id of the first tile in this tileset.
pub first_gid: u32,
/// The source file of this tileset, or it's name if it's an embedded tileset.
pub source: String,
/// The tiles contained in this tileset.
pub tiles: Vec<Option<Tile>>,
/// The image that the tiles are taken from, or `None` if all tiles provide their own image.
pub image: Option<Texture>,
/// The size in pixels of tiles in this tileset
pub tile_size: Vec2,
}
/// A single tile description
pub struct Tile {
/// The image that this tile was taken from
pub image: Option<Texture>,
/// The top left UV coordinates of this tile within `image.
pub top_left: Vec2,
/// The bottom right UV coordinates of this tile within `image.
pub bottom_right: Vec2,
/// The width in pixels of this tile.
pub width: i32,
/// The height in pixels of this tile.
pub height: i32,
#[allow(missing_docs)]
pub animation: Vec<Frame>,
/// Custom properties defined on this tile.
pub properties: HashMap<String, Property>,
/// ObjectGroup attached to this tile
pub object_group: Vec<Object>,
}
/// Animation frame within a tile
pub struct Frame {
/// Global tile id of the animation frame.
pub tile: u32,
/// Duration in ms
pub duration: u32,
}
/// Object description
#[derive(Clone, Debug)]
pub struct Object {
/// Unique id for the object.
pub id: u32,
/// Custom properties defined on the object.
pub properties: HashMap<String, Property>,
/// Global tile id defining an optional sprite for this object.
pub tile: Option<u32>,
/// The shape of this object.
pub shape: Shape,
/// Custom name for the object
pub name: String,
/// Custom type for the object
pub ty: String,
/// left X coordinate in pixels where the object is positioned.
pub x: f32,
/// bottom Y coordinate in pixels where the object is positioned.
pub y: f32,
/// Width in pixels of the object.
pub width: f32,
/// Height in pixels of the object.
pub height: f32,
/// Rotation around (x,y) in degrees of the object.
pub rotation: f32,
/// Whether the object is visible. Invisible objects have their `Draw` component set to invisible.
pub visible: bool,
}
/// A shape.
#[derive(Clone, Debug)]
pub struct Shape {
/// Point defining the shape.
pub points: Vec<Vec2>,
/// Whether the last point should be connected to the first point.
pub closed: bool,
}