|
use bevy::ecs::{ bundle::Bundle, component::Component };
|
|
use bevy_ecs_ldtk::{ prelude::LdtkEntity, utils::LdtkSpriteSheetBundle };
|
|
|
|
use super::{ ColliderBundle, PredefinedPath };
|
|
use crate::components::animals::Animal;
|
|
|
|
|
|
#[derive(Clone, Eq, PartialEq, Debug, Default, Component)]
|
|
pub struct Cat {
|
|
name: String,
|
|
}
|
|
|
|
|
|
impl Cat {
|
|
|
|
fn new(name: String) -> Self {
|
|
|
|
Self { name }
|
|
}
|
|
}
|
|
|
|
|
|
impl Animal for Cat {
|
|
|
|
fn species() -> &'static str {
|
|
"Cat"
|
|
}
|
|
|
|
|
|
fn name(&self) -> &String {
|
|
&self.name
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
|
pub struct CatBundle {
|
|
#[sprite_sheet_bundle]
|
|
pub sprite_sheet_bundle: LdtkSpriteSheetBundle,
|
|
#[from_entity_instance]
|
|
pub collider_bundle: ColliderBundle,
|
|
pub cat: Cat,
|
|
}
|
|
|
|
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
|
pub struct CatPatrolBundle {
|
|
#[ldtk_entity]
|
|
pub cat: CatBundle,
|
|
#[ldtk_entity]
|
|
pub predefined_path: PredefinedPath,
|
|
}
|
|
|