module_area_entry_forbid.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include"module_area_entry_forbid.h"
  2. #include<memory>
  3. #include "event.h"
  4. #include "area.h"
  5. #include"area_business.h"
  6. #include"log.h"
  7. #include"common_tool.h"
  8. struct forbid_data:business_data
  9. {
  10. forbid_data()
  11. {
  12. }
  13. };
  14. void module_area_entry_forbid::on_enter(std::shared_ptr<card_location_base> card_ptr, int index)
  15. {
  16. auto area_hover_ptr = card_ptr->get_area_hover();
  17. if(!area_hover_ptr)
  18. {
  19. log_error("if(!area_hover_ptr)==true");
  20. return;
  21. }
  22. area_hover_ptr->m_data[index] = std::make_shared<forbid_data>();
  23. EVENT_TYPE ev_type = ET_CARD_AREA_FORBIDDEN_PERSON;
  24. if(card_ptr->is_vehicle())
  25. {
  26. ev_type = ET_CARD_AREA_FORBIDDEN_VEHICLE;
  27. }
  28. uint64_t id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
  29. event_tool::instance()->handle_event(OT_CARD, ev_type, id, 0, 0, true);
  30. }
  31. void module_area_entry_forbid::on_hover(std::shared_ptr<card_location_base> card_ptr, int index)
  32. {
  33. }
  34. void module_area_entry_forbid::on_leave(std::shared_ptr<card_location_base> card_ptr, int index)
  35. {
  36. auto area_hover_ptr = card_ptr->get_area_hover();
  37. if(!area_hover_ptr)
  38. {
  39. log_error("if(!area_hover_ptr)==true");
  40. return;
  41. }
  42. EVENT_TYPE ev_type = ET_CARD_AREA_FORBIDDEN_PERSON;
  43. if(card_ptr->is_vehicle())
  44. {
  45. ev_type = ET_CARD_AREA_FORBIDDEN_VEHICLE;
  46. }
  47. uint64_t id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
  48. event_tool::instance()->handle_event(OT_CARD, ev_type, id, 0, 0, false);
  49. area_hover_ptr->m_data[index] = std::make_shared<forbid_data>();
  50. }