generated from 2ndbeam/bevy-template
feat: Derive traits
This commit is contained in:
parent
0a0eb14a6b
commit
ffdb5d94a8
11 changed files with 115 additions and 79 deletions
|
|
@ -1,13 +1,14 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use leafwing_input_manager::prelude::*;
|
use leafwing_input_manager::prelude::*;
|
||||||
use serde::{
|
use serde::{
|
||||||
|
Deserialize,
|
||||||
Serialize,
|
Serialize,
|
||||||
Deserialize
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod plugin;
|
pub mod plugin;
|
||||||
|
|
||||||
#[derive(Actionlike, PartialEq, Eq, Hash, Debug, Clone, Reflect, Serialize, Deserialize)]
|
#[derive(Actionlike, PartialEq, Eq, Hash, Debug, Clone, Reflect, Serialize, Deserialize)]
|
||||||
|
#[reflect(PartialEq, Hash, Debug, Clone, Serialize, Deserialize)]
|
||||||
pub enum InputAction {
|
pub enum InputAction {
|
||||||
#[actionlike(Axis)]
|
#[actionlike(Axis)]
|
||||||
Move,
|
Move,
|
||||||
|
|
@ -28,6 +29,7 @@ impl InputAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Actionlike, PartialEq, Eq, Hash, Debug, Clone, Reflect, Serialize, Deserialize)]
|
#[derive(Actionlike, PartialEq, Eq, Hash, Debug, Clone, Reflect, Serialize, Deserialize)]
|
||||||
|
#[reflect(PartialEq, Hash, Debug, Clone, Serialize, Deserialize)]
|
||||||
pub enum UiAction {
|
pub enum UiAction {
|
||||||
Rotate,
|
Rotate,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use std::{
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
reflect::GetTypeRegistration,
|
reflect::Reflectable,
|
||||||
};
|
};
|
||||||
use bevy_common_assets::toml::TomlAssetPlugin;
|
use bevy_common_assets::toml::TomlAssetPlugin;
|
||||||
use leafwing_input_manager::{
|
use leafwing_input_manager::{
|
||||||
|
|
@ -229,16 +229,16 @@ impl<Name> From<InputMap<Name>> for InputAsset<Name>
|
||||||
|
|
||||||
#[derive(Resource, Debug, Deref, DerefMut, Reflect, Clone, PartialEq, Eq)]
|
#[derive(Resource, Debug, Deref, DerefMut, Reflect, Clone, PartialEq, Eq)]
|
||||||
#[reflect(Resource, Debug, Clone, PartialEq)]
|
#[reflect(Resource, Debug, Clone, PartialEq)]
|
||||||
pub struct InputAssetHandle<T: Sized + Hash + Eq + Reflect + TypePath + Actionlike> (Option<Handle<InputAsset<T>>>);
|
pub struct InputAssetHandle<T: Sized + Hash + Eq + Reflectable + Actionlike> (Option<Handle<InputAsset<T>>>);
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct InputAssetPlugin<T: Sized + Hash + Eq + Reflect + TypePath + Actionlike + DeserializeOwned> {
|
pub struct InputAssetPlugin<T: Sized + Hash + Eq + Reflectable + Actionlike + DeserializeOwned> {
|
||||||
_phantom: PhantomData<T>,
|
_phantom: PhantomData<T>,
|
||||||
extensions: &'static [&'static str],
|
extensions: &'static [&'static str],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> InputAssetPlugin<T>
|
impl<T> InputAssetPlugin<T>
|
||||||
where T: Sized + Hash + Eq + Reflect + TypePath + Actionlike + DeserializeOwned {
|
where T: Sized + Hash + Eq + Reflectable + Actionlike + DeserializeOwned {
|
||||||
pub fn new(extensions: &'static [&'static str]) -> Self {
|
pub fn new(extensions: &'static [&'static str]) -> Self {
|
||||||
Self {
|
Self {
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
|
|
@ -248,7 +248,7 @@ impl<T> InputAssetPlugin<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Default for InputAssetPlugin<T>
|
impl<T> Default for InputAssetPlugin<T>
|
||||||
where T: Sized + Hash + Eq + Reflect + TypePath + Actionlike + DeserializeOwned {
|
where T: Sized + Hash + Eq + Reflectable + Actionlike + DeserializeOwned {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
|
|
@ -258,7 +258,7 @@ impl<T> Default for InputAssetPlugin<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Plugin for InputAssetPlugin<T>
|
impl<T> Plugin for InputAssetPlugin<T>
|
||||||
where T: Sized + Hash + Eq + Reflect + TypePath + Actionlike + DeserializeOwned + GetTypeRegistration {
|
where T: Sized + Hash + Eq + Reflectable + Actionlike + DeserializeOwned {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
InputManagerPlugin::<T>::default(),
|
InputManagerPlugin::<T>::default(),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ use std::mem::swap;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
#[derive(Component, Clone, Debug, Reflect)]
|
#[derive(Component, Clone, Debug, Reflect, PartialEq, Eq)]
|
||||||
|
#[reflect(Component, Clone, Debug, PartialEq)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
pub size: UVec2,
|
pub size: UVec2,
|
||||||
pub position: Option<UVec2>,
|
pub position: Option<UVec2>,
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,17 @@ use bevy::prelude::*;
|
||||||
|
|
||||||
pub mod item;
|
pub mod item;
|
||||||
|
|
||||||
#[derive(Component, Reflect, Default)]
|
/// Marker that this inventory will show up when UI is built
|
||||||
|
#[derive(Component, Reflect, Default, Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
#[reflect(Component, Clone, Default, Debug, PartialEq)]
|
||||||
|
pub struct ActiveInventory;
|
||||||
|
|
||||||
|
#[derive(Component, Reflect, Default, Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
#[reflect(Component, Clone, Default, Debug, PartialEq)]
|
||||||
pub struct Inventory {
|
pub struct Inventory {
|
||||||
pub size: UVec2,
|
pub size: UVec2,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Marker that this inventory will show up when UI is built
|
|
||||||
#[derive(Component, Reflect)]
|
|
||||||
pub struct ActiveInventory;
|
|
||||||
|
|
||||||
impl Inventory {
|
impl Inventory {
|
||||||
pub fn new(size: UVec2) -> Self {
|
pub fn new(size: UVec2) -> Self {
|
||||||
Self { size }
|
Self { size }
|
||||||
|
|
@ -58,6 +60,23 @@ impl Inventory {
|
||||||
self.can_fit(item_query, children.as_slice(), *size, queried_position)
|
self.can_fit(item_query, children.as_slice(), *size, queried_position)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn can_replace(
|
||||||
|
&self,
|
||||||
|
item_query: Query<&item::Item>,
|
||||||
|
contained_items: &[Entity],
|
||||||
|
replacable_item: Entity,
|
||||||
|
queried_item: &item::Item,
|
||||||
|
) -> bool {
|
||||||
|
let Some(position) = &queried_item.position else {
|
||||||
|
warn!("Trying to query rotated item without position");
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
let children = contained_items.iter()
|
||||||
|
.filter_map(|e| if e.ne(&&replacable_item) { Some(*e) } else { None })
|
||||||
|
.collect::<Vec<Entity>>();
|
||||||
|
self.can_fit(item_query, children.as_slice(), queried_item.size, *position)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn can_rotate(
|
pub fn can_rotate(
|
||||||
&self,
|
&self,
|
||||||
item_query: Query<&item::Item>,
|
item_query: Query<&item::Item>,
|
||||||
|
|
@ -79,23 +98,6 @@ impl Inventory {
|
||||||
self.can_fit(item_query, children.as_slice(), rotated_item.size, *position)
|
self.can_fit(item_query, children.as_slice(), rotated_item.size, *position)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn can_replace(
|
|
||||||
&self,
|
|
||||||
item_query: Query<&item::Item>,
|
|
||||||
contained_items: &[Entity],
|
|
||||||
replacable_item: Entity,
|
|
||||||
queried_item: &item::Item,
|
|
||||||
) -> bool {
|
|
||||||
let Some(position) = &queried_item.position else {
|
|
||||||
warn!("Trying to query rotated item without position");
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
let children = contained_items.iter()
|
|
||||||
.filter_map(|e| if e.ne(&&replacable_item) { Some(*e) } else { None })
|
|
||||||
.collect::<Vec<Entity>>();
|
|
||||||
self.can_fit(item_query, children.as_slice(), queried_item.size, *position)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_free_space_inner(
|
fn find_free_space_inner(
|
||||||
&self,
|
&self,
|
||||||
item_query: Query<&item::Item>,
|
item_query: Query<&item::Item>,
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,12 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const CRATE_CLOSED_ASSET: &'static str = "sprites/interactive/crate_closed.png";
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
const CRATE_CLOSED_ASSET: &'static str = "sprites/interactive/crate_closed.png";
|
||||||
|
|
||||||
|
#[derive(Component, Clone, Copy, Default, Reflect, Debug, PartialEq, Eq)]
|
||||||
|
#[reflect(Component, Clone, Default, Debug, PartialEq)]
|
||||||
#[require(Sprite, InteractiveObject, Inventory)]
|
#[require(Sprite, InteractiveObject, Inventory)]
|
||||||
pub struct Container;
|
pub struct Container;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,17 @@ use super::*;
|
||||||
const DOOR_OPENED_ASSET: &'static str = "sprites/interactive/door_opened.png";
|
const DOOR_OPENED_ASSET: &'static str = "sprites/interactive/door_opened.png";
|
||||||
const DOOR_CLOSED_ASSET: &'static str = "sprites/interactive/door_closed.png";
|
const DOOR_CLOSED_ASSET: &'static str = "sprites/interactive/door_closed.png";
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component, Clone, Copy, Reflect, PartialEq, Eq, Debug)]
|
||||||
|
#[reflect(Component, Clone, Default, PartialEq, Debug)]
|
||||||
#[require(Sprite, InteractiveObject)]
|
#[require(Sprite, InteractiveObject)]
|
||||||
pub struct Door(pub i8);
|
pub struct Door(pub i8);
|
||||||
|
|
||||||
|
impl Default for Door {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn on_door_interact(
|
fn on_door_interact(
|
||||||
event: On<InteractionEvent>,
|
event: On<InteractionEvent>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,20 @@ pub mod container;
|
||||||
pub mod door;
|
pub mod door;
|
||||||
pub mod systems;
|
pub mod systems;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
|
||||||
|
#[reflect(Component, Debug, PartialEq, Default, Clone)]
|
||||||
pub struct MayInteract;
|
pub struct MayInteract;
|
||||||
|
|
||||||
#[derive(Component, Default)]
|
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
|
||||||
|
#[reflect(Component, Debug, PartialEq, Default, Clone)]
|
||||||
pub struct InteractiveObject;
|
pub struct InteractiveObject;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
|
||||||
|
#[reflect(Component, Debug, PartialEq, Default, Clone)]
|
||||||
pub struct Locked;
|
pub struct Locked;
|
||||||
|
|
||||||
#[derive(EntityEvent)]
|
#[derive(EntityEvent, Reflect, Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
|
#[reflect(Event, Debug, PartialEq, Clone)]
|
||||||
pub struct InteractionEvent {
|
pub struct InteractionEvent {
|
||||||
pub entity: Entity,
|
pub entity: Entity,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
66
src/lib.rs
66
src/lib.rs
|
|
@ -1,37 +1,32 @@
|
||||||
use bevy::{
|
use bevy::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
ui_widgets::ScrollbarPlugin
|
ui_widgets::ScrollbarPlugin,
|
||||||
};
|
};
|
||||||
use bevy_rapier2d::{
|
use bevy_rapier2d::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
rapier::prelude::IntegrationParameters
|
rapier::prelude::IntegrationParameters,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod player;
|
|
||||||
pub mod layout;
|
|
||||||
pub mod input;
|
pub mod input;
|
||||||
pub mod inventory;
|
pub mod inventory;
|
||||||
pub mod ui;
|
pub mod layout;
|
||||||
|
pub mod player;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
pub mod ui;
|
||||||
|
|
||||||
pub const PIXELS_PER_METER: f32 = 16.0;
|
pub const PIXELS_PER_METER: f32 = 16.0;
|
||||||
|
|
||||||
pub struct ExpeditionPlugin;
|
pub struct ExpeditionPlugin;
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default, States)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default, States, Reflect)]
|
||||||
|
#[reflect(Clone, PartialEq, Debug, Default, Hash, State)]
|
||||||
pub enum GameState {
|
pub enum GameState {
|
||||||
#[default]
|
#[default]
|
||||||
Running,
|
Running,
|
||||||
Inventory,
|
Inventory,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_entity_name(names: Query<(Entity, &mut Name), Added<Name>>) {
|
|
||||||
for (entity, mut name) in names {
|
|
||||||
name.mutate(|name| name.insert_str(0, format!("{entity}: ").as_str()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn camera_bundle() -> impl Bundle {
|
fn camera_bundle() -> impl Bundle {
|
||||||
(
|
(
|
||||||
Camera2d,
|
Camera2d,
|
||||||
|
|
@ -50,6 +45,12 @@ fn camera_bundle() -> impl Bundle {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn insert_entity_name(names: Query<(Entity, &mut Name), Added<Name>>) {
|
||||||
|
for (entity, mut name) in names {
|
||||||
|
name.mutate(|name| name.insert_str(0, format!("{entity}: ").as_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn setup_global(mut commands: Commands) {
|
fn setup_global(mut commands: Commands) {
|
||||||
commands.spawn(camera_bundle());
|
commands.spawn(camera_bundle());
|
||||||
commands.spawn(ui::UiRoot::new());
|
commands.spawn(ui::UiRoot::new());
|
||||||
|
|
@ -57,34 +58,39 @@ fn setup_global(mut commands: Commands) {
|
||||||
|
|
||||||
impl Plugin for ExpeditionPlugin {
|
impl Plugin for ExpeditionPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
|
let rapier_init = RapierContextInitialization::InitializeDefaultRapierContext {
|
||||||
|
integration_parameters: IntegrationParameters {
|
||||||
|
length_unit: PIXELS_PER_METER,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
rapier_configuration: RapierConfiguration {
|
||||||
|
gravity: Vec2::ZERO,
|
||||||
|
physics_pipeline_active: true,
|
||||||
|
scaled_shape_subdivision: 10,
|
||||||
|
force_update_from_transform_changes: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
|
RapierDebugRenderPlugin::default(),
|
||||||
|
RapierPhysicsPlugin::<()>::default()
|
||||||
|
.with_custom_initialization(rapier_init),
|
||||||
|
ScrollbarPlugin,
|
||||||
input::plugin::InputAssetPlugin::<input::InputAction>::default(),
|
input::plugin::InputAssetPlugin::<input::InputAction>::default(),
|
||||||
input::plugin::InputAssetPlugin::<input::UiAction>::default(),
|
input::plugin::InputAssetPlugin::<input::UiAction>::default(),
|
||||||
ScrollbarPlugin,
|
|
||||||
RapierPhysicsPlugin::<()>::default()
|
|
||||||
.with_custom_initialization(RapierContextInitialization::InitializeDefaultRapierContext {
|
|
||||||
integration_parameters: IntegrationParameters {
|
|
||||||
length_unit: PIXELS_PER_METER,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
rapier_configuration: RapierConfiguration {
|
|
||||||
gravity: Vec2::ZERO,
|
|
||||||
physics_pipeline_active: true,
|
|
||||||
scaled_shape_subdivision: 10,
|
|
||||||
force_update_from_transform_changes: false,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
RapierDebugRenderPlugin::default(),
|
|
||||||
))
|
))
|
||||||
.init_state::<GameState>()
|
.init_state::<GameState>()
|
||||||
.insert_resource(ui::WindowSize::default())
|
.insert_resource(ui::WindowSize::default())
|
||||||
.add_systems(Startup, (player::systems::setup_player, setup_global, layout::systems::setup_world))
|
.add_systems(Startup, (
|
||||||
|
setup_global,
|
||||||
|
layout::systems::setup_world,
|
||||||
|
player::systems::setup_player,
|
||||||
|
))
|
||||||
.add_systems(Update, (
|
.add_systems(Update, (
|
||||||
|
insert_entity_name,
|
||||||
|
layout::systems::detect_interact_collisions,
|
||||||
player::systems::handle_input,
|
player::systems::handle_input,
|
||||||
ui::update_window_size,
|
ui::update_window_size,
|
||||||
ui::handle_input,
|
ui::handle_input,
|
||||||
insert_entity_name,
|
|
||||||
layout::systems::detect_interact_collisions,
|
|
||||||
))
|
))
|
||||||
.add_systems(OnEnter(GameState::Inventory), ui::inventory::systems::setup_ui_inventory)
|
.add_systems(OnEnter(GameState::Inventory), ui::inventory::systems::setup_ui_inventory)
|
||||||
.add_systems(OnExit(GameState::Inventory), ui::inventory::systems::clear_ui_inventory)
|
.add_systems(OnExit(GameState::Inventory), ui::inventory::systems::clear_ui_inventory)
|
||||||
|
|
|
||||||
|
|
@ -9,18 +9,23 @@ use crate::{
|
||||||
|
|
||||||
pub mod systems;
|
pub mod systems;
|
||||||
|
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Clone, Copy, Reflect, PartialEq, Debug)]
|
||||||
|
#[reflect(Component, Clone, Default, PartialEq, Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
// px/s
|
// px/s
|
||||||
speed: f32,
|
speed: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Player {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self { speed: PIXELS_PER_METER * 0.8 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn player_bundle(asset_server: &Res<AssetServer>) -> impl Bundle {
|
pub fn player_bundle(asset_server: &Res<AssetServer>) -> impl Bundle {
|
||||||
let image = asset_server.load("sprites/player/player.png");
|
let image = asset_server.load("sprites/player/player.png");
|
||||||
(
|
(
|
||||||
Player {
|
Player::default(),
|
||||||
speed: PIXELS_PER_METER * 0.8,
|
|
||||||
},
|
|
||||||
Sprite::from_image(image),
|
Sprite::from_image(image),
|
||||||
Transform::from_xyz(0f32, 0f32, 1f32),
|
Transform::from_xyz(0f32, 0f32, 1f32),
|
||||||
Action::default_input_map(),
|
Action::default_input_map(),
|
||||||
|
|
|
||||||
|
|
@ -14,29 +14,36 @@ pub mod bundles;
|
||||||
pub mod observers;
|
pub mod observers;
|
||||||
pub mod systems;
|
pub mod systems;
|
||||||
|
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
|
||||||
|
#[reflect(Component, Debug, PartialEq, Default, Clone)]
|
||||||
#[require(Node)]
|
#[require(Node)]
|
||||||
pub struct UiInventoryManager;
|
pub struct UiInventoryManager;
|
||||||
|
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Debug, PartialEq, Eq, Clone, Copy, Reflect)]
|
||||||
|
#[reflect(Component, Debug, PartialEq, Clone)]
|
||||||
#[require(Node)]
|
#[require(Node)]
|
||||||
pub struct UiInventory(pub Entity);
|
pub struct UiInventory(pub Entity);
|
||||||
|
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
|
||||||
|
#[reflect(Component, Debug, PartialEq, Default, Clone)]
|
||||||
#[require(Node, ImageNode)]
|
#[require(Node, ImageNode)]
|
||||||
pub struct UiInventorySlot(pub UVec2);
|
pub struct UiInventorySlot(pub UVec2);
|
||||||
|
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Debug, PartialEq, Eq, Clone, Copy, Reflect)]
|
||||||
|
#[reflect(Component, Debug, PartialEq, Clone)]
|
||||||
#[require(Node, ImageNode)]
|
#[require(Node, ImageNode)]
|
||||||
pub struct UiItem(pub Entity);
|
pub struct UiItem(pub Entity);
|
||||||
|
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
|
||||||
|
#[reflect(Component, Debug, PartialEq, Default, Clone)]
|
||||||
pub struct HoveredItem;
|
pub struct HoveredItem;
|
||||||
|
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
|
||||||
|
#[reflect(Component, Debug, PartialEq, Default, Clone)]
|
||||||
pub struct HoveredSlot;
|
pub struct HoveredSlot;
|
||||||
|
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Debug, PartialEq, Eq, Clone, Reflect)]
|
||||||
|
#[reflect(Component, Debug, PartialEq, Clone)]
|
||||||
pub struct DraggedItem(pub Item, pub UVec2);
|
pub struct DraggedItem(pub Item, pub UVec2);
|
||||||
|
|
||||||
fn ui_item_node_data(item: &Item) -> (Val, Val, Val, Val, UiTransform) {
|
fn ui_item_node_data(item: &Item) -> (Val, Val, Val, Val, UiTransform) {
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,9 @@ use crate::input::UiAction;
|
||||||
|
|
||||||
pub mod inventory;
|
pub mod inventory;
|
||||||
|
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Reflect, Debug, Default, PartialEq, Eq, Clone, Copy)]
|
||||||
#[require(Node)]
|
#[require(Node)]
|
||||||
|
#[reflect(Component, Debug, Default, PartialEq, Clone)]
|
||||||
pub struct UiRoot;
|
pub struct UiRoot;
|
||||||
|
|
||||||
#[derive(Resource, Deref, DerefMut, Default)]
|
#[derive(Resource, Deref, DerefMut, Default)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue