monkeycar_area.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef __MONKEYCAR_AREA__
  2. #define __MONKEYCAR_AREA__
  3. //#include "monkeycar_person.h"
  4. //#include "monkeycar_bus.h"
  5. #include <mutex>
  6. #include <memory>
  7. #include "area.h"
  8. #include "fp_path.h"
  9. struct db_area
  10. {
  11. std::vector<point> m_point;
  12. double m_default_speed;
  13. };
  14. struct monkey_bus;
  15. struct monkey_person;
  16. struct monkey_area : area,std::enable_shared_from_this<monkey_area>
  17. {
  18. public:
  19. monkey_area(std::shared_ptr<db_area> dap,int area_id,int over_count_person,int over_time_person,double scale,int32_t ,int32_t);
  20. ~monkey_area()
  21. {}
  22. std::shared_ptr<monkey_person> find(uint32_t cardid);
  23. virtual void on_hover(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c);
  24. virtual void on_enter(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c);
  25. virtual void on_leave(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c);
  26. void on_card_leave(uint32_t cardid);
  27. void on_card_enter(const std::shared_ptr<card_location_base>&);
  28. void on_card_move(uint32_t cardid,const st_coord & st,uint64_t);
  29. inline double map(double x, double y)
  30. {
  31. return m_path.map(x,y);
  32. }
  33. inline point_2 map(double d)
  34. {
  35. return m_path.map(d);
  36. }
  37. inline double get_total_length()
  38. {
  39. return m_path.get_total_length();
  40. }
  41. double getScale()
  42. {
  43. return scale();
  44. }
  45. static uint64_t m_startTime;
  46. private:
  47. std::map<uint32_t ,std::shared_ptr<monkey_person>> card_map_;
  48. std::vector<std::shared_ptr<monkey_bus>> bus_;
  49. fp_path m_path;
  50. std::mutex m_mtx;
  51. };
  52. #endif