components.rs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. use rltk::RGB;
  2. use specs::prelude::*;
  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 { delta_x: i32, delta_y: i32 },
  59. }
  60. #[derive(Component, Copy, Clone, Debug)]
  61. pub struct Seek {
  62. pub tgt_x: i32,
  63. pub tgt_y: i32,
  64. }