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
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue