struct WorldManager2D{
	WorldManager2D();
	~WorldManager2D();
	void del();
	void Create();
	void Load(C Str &world);
	void update(C Vec2 &at);
	void Draw();
	C PathWorld &path()C{ return pw; }
	void  ActiveRange(int _ActiveRange);
	int ActiveRange(){ return actRng; }
	Int AreaSize()C{ return m_areasize; }
	Int HMRes(){ return m_areasize + 1; }

	Vec2  areaToWorld(C VecI2 &xz)C{ return                                      xz*AreaSize(); } // convert Area  Coordinates to World Position in meters
	VecI2 worldToArea(C Vec2  &xz)C{ return                                Floor(xz / AreaSize()); } // convert World Position    to Area  Coordinates
	RectI worldToArea(C Rect  &rect)C{ return RectI(worldToArea(rect.min), worldToArea(rect.max)); } // convert World Position    to Area  Coordinates

	Area2D *GetArea(C VecI &v);
	bool changed;
	VecI2 CurPos;
	Str worldname;
	
	void CheckAreas();

	Material matA, matB, matC;
	Memb<Area2D*>Cached_areas;
	Memb<Area2D*>Active_areas;
	Memb<Area2D*>Unloading_areas;
	Grid<Area2D> m_grid;//Areas
private:

	int actRng;
	int m_areasize;
	Flt m_last_update;
	PathWorld pw;
	PathSettings ps;
	
	Image gr; Image grNrm;
	Image dr; Image drNrm;
	Thread thread_x;
}extern World2D;