2020-04-06 21:20:53 +00:00
|
|
|
use super::Node;
|
2020-05-04 08:22:25 +00:00
|
|
|
use crate::{render::UI_PIPELINE_HANDLE, ColorMaterial, Rect, QUAD_HANDLE, sprite::Sprite};
|
2020-05-04 06:49:45 +00:00
|
|
|
use bevy_asset::Handle;
|
2020-04-06 23:15:59 +00:00
|
|
|
use bevy_derive::EntityArchetype;
|
2020-05-03 19:35:07 +00:00
|
|
|
use bevy_render::{mesh::Mesh, Renderable};
|
2020-04-06 21:20:53 +00:00
|
|
|
|
2020-05-03 19:35:07 +00:00
|
|
|
#[derive(EntityArchetype)]
|
2020-04-06 21:20:53 +00:00
|
|
|
#[module(meta = false)]
|
|
|
|
pub struct UiEntity {
|
|
|
|
pub node: Node,
|
2020-05-03 00:56:30 +00:00
|
|
|
pub rect: Rect,
|
2020-05-04 06:49:45 +00:00
|
|
|
pub mesh: Handle<Mesh>, // TODO: maybe abstract this out
|
|
|
|
pub material: Handle<ColorMaterial>,
|
2020-05-04 02:30:31 +00:00
|
|
|
pub renderable: Renderable,
|
2020-04-06 21:20:53 +00:00
|
|
|
}
|
2020-05-03 19:35:07 +00:00
|
|
|
|
|
|
|
impl Default for UiEntity {
|
|
|
|
fn default() -> Self {
|
|
|
|
UiEntity {
|
|
|
|
node: Default::default(),
|
|
|
|
rect: Default::default(),
|
|
|
|
mesh: QUAD_HANDLE,
|
2020-05-04 06:49:45 +00:00
|
|
|
material: Default::default(),
|
2020-05-04 02:30:31 +00:00
|
|
|
renderable: Renderable {
|
2020-05-04 06:49:45 +00:00
|
|
|
pipelines: vec![UI_PIPELINE_HANDLE],
|
2020-05-04 02:30:31 +00:00
|
|
|
..Default::default()
|
2020-05-04 06:49:45 +00:00
|
|
|
},
|
2020-05-03 19:35:07 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-04 06:49:45 +00:00
|
|
|
}
|
2020-05-04 08:22:25 +00:00
|
|
|
|
|
|
|
#[derive(EntityArchetype)]
|
|
|
|
#[module(meta = false)]
|
|
|
|
pub struct SpriteEntity {
|
|
|
|
pub sprite: Sprite,
|
|
|
|
pub rect: Rect,
|
|
|
|
pub mesh: Handle<Mesh>, // TODO: maybe abstract this out
|
|
|
|
pub material: Handle<ColorMaterial>,
|
|
|
|
pub renderable: Renderable,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for SpriteEntity {
|
|
|
|
fn default() -> Self {
|
|
|
|
SpriteEntity {
|
|
|
|
sprite: Default::default(),
|
|
|
|
rect: Default::default(),
|
|
|
|
mesh: QUAD_HANDLE,
|
|
|
|
material: Default::default(),
|
|
|
|
renderable: Renderable {
|
|
|
|
pipelines: vec![UI_PIPELINE_HANDLE],
|
|
|
|
..Default::default()
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|