components.rs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. use specs::prelude::*;
  2. use rltk::RGB;
  3. #[derive(Component)]
  4. pub struct Position {
  5. pub x: i32,
  6. pub y: i32,
  7. }
  8. #[derive(Component)]
  9. pub struct Renderable {
  10. pub glyph: u8,
  11. pub fg: RGB,
  12. pub bg: RGB,
  13. }
  14. #[derive(Component, Debug)]
  15. pub struct Player;
  16. #[derive(Component)]
  17. pub struct Viewshed {
  18. pub visible_tiles: Vec<rltk::Point>,
  19. pub range: i32,
  20. pub dirty: bool,
  21. }
  22. #[derive(Component, Debug)]
  23. pub struct Monster;
  24. #[derive(Component, Debug)]
  25. pub struct Name {
  26. pub name: String,
  27. }
  28. #[derive(Component, Debug)]
  29. pub struct BlocksTile;
  30. #[derive(Component, Debug)]
  31. pub struct CombatStats {
  32. pub max_hp: i32,
  33. pub hp: i32,
  34. pub defense: i32,
  35. pub power: i32,
  36. }
  37. #[derive(Component, Debug)]
  38. pub struct WantsToMelee {
  39. pub target: Entity,
  40. }
  41. #[derive(Component, Debug)]
  42. pub struct SufferDamage {
  43. pub amount: i32,
  44. }
  45. #[derive(Component, Copy, Clone, Debug)]
  46. pub struct MoveEvent {
  47. pub destination: usize,
  48. pub tgt_x: i32,
  49. pub tgt_y: i32,
  50. }
  51. /// This type represents all the "low-level" actions we have available
  52. /// to us, corresponding directly to the set of actions we have bound
  53. /// on the keys
  54. #[derive(Component)]
  55. pub enum InputEvent {
  56. // attempt to move the player some amount in the given direction
  57. // (delta_x and delta_y should be -1, 0, or 1)
  58. PlayerMovement {
  59. delta_x: i32,
  60. delta_y: i32,
  61. },
  62. }