feat: Derive traits

This commit is contained in:
Alexey 2026-03-19 15:57:29 +03:00
commit ffdb5d94a8
11 changed files with 115 additions and 79 deletions

View file

@ -11,11 +11,12 @@ use crate::{
},
};
const CRATE_CLOSED_ASSET: &'static str = "sprites/interactive/crate_closed.png";
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)]
pub struct Container;

View file

@ -8,10 +8,17 @@ use super::*;
const DOOR_OPENED_ASSET: &'static str = "sprites/interactive/door_opened.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)]
pub struct Door(pub i8);
impl Default for Door {
fn default() -> Self {
Self(1)
}
}
fn on_door_interact(
event: On<InteractionEvent>,
mut commands: Commands,

View file

@ -4,16 +4,20 @@ pub mod container;
pub mod door;
pub mod systems;
#[derive(Component)]
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
#[reflect(Component, Debug, PartialEq, Default, Clone)]
pub struct MayInteract;
#[derive(Component, Default)]
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
#[reflect(Component, Debug, PartialEq, Default, Clone)]
pub struct InteractiveObject;
#[derive(Component)]
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
#[reflect(Component, Debug, PartialEq, Default, Clone)]
pub struct Locked;
#[derive(EntityEvent)]
#[derive(EntityEvent, Reflect, Clone, Copy, PartialEq, Eq, Debug)]
#[reflect(Event, Debug, PartialEq, Clone)]
pub struct InteractionEvent {
pub entity: Entity,
}