use super::*;
use colored::ColoredString;
pub struct Context<'a, 'b> {
pub world: &'a mut World,
pub store: &'b Store,
pub loc: Point,
pub id: ComponentId,
}
#[derive(Clone, Copy, Eq, PartialEq)]
pub enum LifeCycle {
Alive,
Dead,
}
pub trait Action {
fn act<'a, 'b>(&mut self, context: Context<'a, 'b>) -> LifeCycle;
}
register_type!(Action);
pub trait Render {
fn render(&self) -> ColoredString;
}
register_type!(Render);
pub trait Hunger {
fn get(&self) -> i32;
fn set(&mut self, value: i32);
fn adjust(&mut self, delta: i32);
}
register_type!(Hunger);
pub trait Moveable {
fn random_move<'a, 'b>(&self, context: &Context<'a, 'b>) -> Option<Point>;
fn move_towards(&self, world: &World, store: &Store, loc: Point, dst: Point) -> Option<Point>;
}
register_type!(Moveable);
pub trait Fodder {
fn eat<'a, 'b>(&mut self, context: Context<'a, 'b>, percent: i32);
fn height(&self) -> u8;
}
register_type!(Fodder);
pub trait Prey {}
register_type!(Prey);
pub trait Predator {}
register_type!(Predator);
pub trait Animal {}
register_type!(Animal);