58 lines
1.1 KiB
Rust
58 lines
1.1 KiB
Rust
|
use specs::{Component, NullStorage, VecStorage, World, WorldExt};
|
||
|
|
||
|
// Components
|
||
|
#[derive(Debug, Component, Clone, Copy)]
|
||
|
#[storage(VecStorage)]
|
||
|
pub struct Position {
|
||
|
pub x: u8,
|
||
|
pub y: u8,
|
||
|
pub z: u8,
|
||
|
}
|
||
|
|
||
|
impl Position {
|
||
|
pub fn new(x: u8, y: u8) -> Self {
|
||
|
Position { x, y, z: 0 }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[derive(Component)]
|
||
|
#[storage(VecStorage)]
|
||
|
pub struct Renderable {
|
||
|
pub path: String,
|
||
|
}
|
||
|
|
||
|
#[derive(Component)]
|
||
|
#[storage(VecStorage)]
|
||
|
pub struct Wall {}
|
||
|
|
||
|
#[derive(Component)]
|
||
|
#[storage(VecStorage)]
|
||
|
pub struct Player {}
|
||
|
|
||
|
#[derive(Component)]
|
||
|
#[storage(VecStorage)]
|
||
|
pub struct Box {}
|
||
|
|
||
|
#[derive(Component)]
|
||
|
#[storage(VecStorage)]
|
||
|
pub struct BoxSpot {}
|
||
|
|
||
|
#[derive(Component, Default)]
|
||
|
#[storage(NullStorage)]
|
||
|
pub struct Movable;
|
||
|
|
||
|
#[derive(Component, Default)]
|
||
|
#[storage(NullStorage)]
|
||
|
pub struct Immovable;
|
||
|
|
||
|
pub fn register_components(world: &mut World) {
|
||
|
world.register::<Position>();
|
||
|
world.register::<Renderable>();
|
||
|
world.register::<Player>();
|
||
|
world.register::<Wall>();
|
||
|
world.register::<Box>();
|
||
|
world.register::<BoxSpot>();
|
||
|
world.register::<Movable>();
|
||
|
world.register::<Immovable>();
|
||
|
}
|