components.rs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. use specs::prelude::*;
  2. use specs_derive::*;
  3. use rltk::{RGB};
  4. // COMPONENTS
  5. #[derive(Component, Debug)]
  6. pub struct AreaOfEffect {
  7. pub radius : i32
  8. }
  9. #[derive(Component, Debug)]
  10. pub struct Ranged {
  11. pub range : i32
  12. }
  13. #[derive(Component, Debug)]
  14. pub struct InflictsDamage {
  15. pub damage : i32
  16. }
  17. #[derive(Component, Debug)]
  18. pub struct Consumable {}
  19. #[derive(Component, Debug, Clone)]
  20. pub struct WantsToDropItem {
  21. pub item : Entity
  22. }
  23. #[derive(Component, Debug)]
  24. pub struct WantsToUseItem {
  25. pub item : Entity,
  26. pub target: Option<rltk::Point>
  27. }
  28. #[derive(Component, Debug, Clone)]
  29. pub struct WantsToPickupItem {
  30. pub collected_by : Entity,
  31. pub item : Entity
  32. }
  33. #[derive(Component, Debug, Clone)]
  34. pub struct InBackpack {
  35. pub owner : Entity
  36. }
  37. #[derive(Component, Debug)]
  38. pub struct Item {}
  39. #[derive(Component, Debug)]
  40. pub struct ProvidesHealing {
  41. pub heal_amount : i32
  42. }
  43. #[derive(Component, Debug)]
  44. pub struct SufferDamage {
  45. pub amount : Vec<i32>
  46. }
  47. impl SufferDamage {
  48. pub fn new_damage(store: &mut WriteStorage<SufferDamage>, victim: Entity, amount: i32) {
  49. if let Some(suffering) = store.get_mut(victim) {
  50. suffering.amount.push(amount);
  51. } else {
  52. let dmg = SufferDamage { amount : vec![amount] };
  53. store.insert(victim, dmg).expect("Unable to insert damage");
  54. }
  55. }
  56. }
  57. #[derive(Component, Debug, Clone)]
  58. pub struct WantsToMelee {
  59. pub target : Entity
  60. }
  61. #[derive(Component, Debug)]
  62. pub struct CombatStats {
  63. pub max_hp : i32,
  64. pub hp : i32,
  65. pub defense : i32,
  66. pub power : i32
  67. }
  68. #[derive(Component, Debug)]
  69. pub struct BlocksTile {}
  70. #[derive(Component, Debug)]
  71. pub struct Name {
  72. pub name : String
  73. }
  74. #[derive(Component, Debug)]
  75. pub struct Monster {}
  76. #[derive(Component)]
  77. pub struct Viewshed {
  78. pub visible_tiles : Vec<rltk::Point>,
  79. pub range : i32,
  80. pub dirty: bool
  81. }
  82. #[derive(Component)]
  83. pub struct Position {
  84. pub x: i32,
  85. pub y: i32,
  86. }
  87. #[derive(Component)]
  88. pub struct Renderable {
  89. pub glyph: rltk::FontCharType,
  90. pub fg: RGB,
  91. pub bg: RGB,
  92. pub render_order : i32
  93. }
  94. #[derive(Component, Debug)]
  95. pub struct Player {}