#ifndef __MONKEYCAR_AREA__
#define __MONKEYCAR_AREA__


//#include "monkeycar_person.h"
//#include "monkeycar_bus.h"
#include <mutex>
#include <memory>
#include "area.h"
#include "fp_path.h"

struct db_area 
{
	std::vector<point> m_point;
	double m_default_speed;
};


struct monkey_bus;
struct monkey_person;

struct monkey_area : area,std::enable_shared_from_this<monkey_area>
{
public:
	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);
	~monkey_area()
	{}
	std::shared_ptr<monkey_person> find(uint32_t cardid);


	virtual void on_hover(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c);
	virtual	void on_enter(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c);
	virtual	void on_leave(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c);
	void on_card_leave(uint32_t cardid);
	void on_card_enter(const std::shared_ptr<card_location_base>&);
	void on_card_move(uint32_t cardid,const st_coord & st,uint64_t);
	
	inline  double map(double x, double y)
	{
		return m_path.map(x,y);
	}
	inline point_2 map(double d)
	{
		return m_path.map(d);
	}
	inline double get_total_length()
	{
		return m_path.get_total_length();
	}
	double getScale()
	{
		return scale();
	}

	static  uint64_t m_startTime;
private:
	std::map<uint32_t ,std::shared_ptr<monkey_person>> card_map_;
	std::vector<std::shared_ptr<monkey_bus>> bus_;
	fp_path m_path;
	std::mutex  m_mtx;
};

#endif
