2021-10-25 15:26:39 -04:00
|
|
|
use rltk::RGB;
|
2021-10-22 10:05:06 -04:00
|
|
|
use specs::prelude::*;
|
|
|
|
use specs_derive::*;
|
|
|
|
|
|
|
|
#[derive(Component)]
|
|
|
|
pub struct Position {
|
|
|
|
pub x: i32,
|
|
|
|
pub y: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Component)]
|
|
|
|
pub struct Renderable {
|
|
|
|
pub glyph: rltk::FontCharType,
|
|
|
|
pub fg: RGB,
|
|
|
|
pub bg: RGB,
|
2021-11-04 09:54:38 -04:00
|
|
|
pub render_order: i32,
|
2021-10-22 10:05:06 -04:00
|
|
|
}
|
|
|
|
|
2021-11-05 14:32:14 -04:00
|
|
|
#[derive(Component, Debug, Default)]
|
2021-10-22 10:05:06 -04:00
|
|
|
pub struct Player {}
|
2021-10-25 15:26:39 -04:00
|
|
|
|
|
|
|
#[derive(Component)]
|
|
|
|
pub struct Viewshed {
|
|
|
|
pub visible_tiles: Vec<rltk::Point>,
|
|
|
|
pub range: i32,
|
2021-10-26 14:23:08 -04:00
|
|
|
pub dirty: bool,
|
2021-10-25 15:26:39 -04:00
|
|
|
}
|
2021-10-26 15:43:59 -04:00
|
|
|
|
2021-11-05 10:41:47 -04:00
|
|
|
impl Default for Viewshed {
|
|
|
|
fn default() -> Self {
|
|
|
|
Viewshed {
|
|
|
|
visible_tiles: Vec::new(),
|
|
|
|
range: 8,
|
|
|
|
dirty: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-05 14:32:14 -04:00
|
|
|
#[derive(Component, Debug, Default)]
|
2021-10-26 15:43:59 -04:00
|
|
|
pub struct Monster {}
|
|
|
|
|
2021-11-03 15:11:19 -04:00
|
|
|
#[derive(Component, Debug)]
|
2021-10-26 15:43:59 -04:00
|
|
|
pub struct Name {
|
|
|
|
pub name: String,
|
|
|
|
}
|
2021-10-29 11:11:17 -04:00
|
|
|
|
2021-11-05 10:41:47 -04:00
|
|
|
impl Name {
|
|
|
|
pub fn new<S: ToString>(s: S) -> Self {
|
|
|
|
Name {
|
|
|
|
name: s.to_string(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-05 14:32:14 -04:00
|
|
|
#[derive(Component, Debug, Default)]
|
2021-10-29 11:11:17 -04:00
|
|
|
pub struct BlocksTile {}
|
2021-10-29 15:15:22 -04:00
|
|
|
|
2021-11-03 15:11:19 -04:00
|
|
|
#[derive(Component, Debug)]
|
2021-10-29 15:15:22 -04:00
|
|
|
pub struct CombatStats {
|
|
|
|
pub max_hp: i32,
|
|
|
|
pub hp: i32,
|
|
|
|
pub defense: i32,
|
|
|
|
pub power: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Component, Debug, Clone)]
|
|
|
|
pub struct WantsToMelee {
|
|
|
|
pub target: Entity,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Component, Debug)]
|
|
|
|
pub struct SufferDamage {
|
|
|
|
pub amount: Vec<i32>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl SufferDamage {
|
|
|
|
pub fn new_damage(store: &mut WriteStorage<SufferDamage>, victim: Entity, amount: i32) {
|
|
|
|
if let Some(suffering) = store.get_mut(victim) {
|
|
|
|
suffering.amount.push(amount);
|
|
|
|
} else {
|
|
|
|
let dmg = SufferDamage {
|
|
|
|
amount: vec![amount],
|
|
|
|
};
|
|
|
|
store.insert(victim, dmg).expect("Unable to insert damage");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-03 15:11:19 -04:00
|
|
|
|
2021-11-05 14:32:14 -04:00
|
|
|
#[derive(Component, Debug, Default)]
|
2021-11-03 15:11:19 -04:00
|
|
|
pub struct Item {}
|
|
|
|
|
|
|
|
#[derive(Component, Debug)]
|
2021-11-04 15:06:04 -04:00
|
|
|
pub struct ProvidesHealing {
|
2021-11-03 15:11:19 -04:00
|
|
|
pub heal_amount: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Component, Debug, Clone)]
|
|
|
|
pub struct InBackpack {
|
|
|
|
pub owner: Entity,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Component, Debug, Clone)]
|
|
|
|
pub struct WantsToPickupItem {
|
|
|
|
pub collected_by: Entity,
|
|
|
|
pub item: Entity,
|
|
|
|
}
|
2021-11-03 15:59:23 -04:00
|
|
|
|
|
|
|
#[derive(Component, Debug)]
|
2021-11-04 15:06:04 -04:00
|
|
|
pub struct WantsToUseItem {
|
|
|
|
pub item: Entity,
|
2021-11-05 10:42:44 -04:00
|
|
|
pub target: Option<rltk::Point>,
|
2021-11-03 15:59:23 -04:00
|
|
|
}
|
2021-11-04 09:40:58 -04:00
|
|
|
|
|
|
|
#[derive(Component, Debug, Clone)]
|
|
|
|
pub struct WantsToDropItem {
|
|
|
|
pub item: Entity,
|
|
|
|
}
|
2021-11-04 15:06:04 -04:00
|
|
|
|
2021-11-05 14:32:14 -04:00
|
|
|
#[derive(Component, Debug, Default)]
|
2021-11-04 15:06:04 -04:00
|
|
|
pub struct Consumable {}
|
2021-11-05 10:42:44 -04:00
|
|
|
|
|
|
|
#[derive(Component, Debug)]
|
|
|
|
pub struct Ranged {
|
|
|
|
pub range: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Component, Debug)]
|
|
|
|
pub struct InflictsDamage {
|
|
|
|
pub damage: i32,
|
|
|
|
}
|
2021-11-05 13:12:22 -04:00
|
|
|
|
|
|
|
#[derive(Component, Debug)]
|
|
|
|
pub struct AreaOfEffect {
|
|
|
|
pub radius: i32,
|
|
|
|
}
|
2021-11-05 14:32:14 -04:00
|
|
|
|
|
|
|
#[derive(Component, Debug)]
|
|
|
|
pub struct Confusion {
|
|
|
|
pub turns: i32,
|
|
|
|
}
|