#ifndef __MAP_H__
#define __MAP_H__

#include <deque>
#include <algorithm>
#include "units.h"
#include "mapobject.h"

struct MapBullet
{
	Unit* bullet;
	bool enemyfire;
	Uint32 ticks;
	int target;
};

class Map
{
public:
	Map();
	~Map();
	void Init(float zzoom);
	void AddMainShip(Unit *object);
	void AddToObjects(MapObject *object);
	void AddToStations(Station *object);
	void AddToActiveObjects(Unit *object);
	void RemoveFromActiveObjects(int index);
	void AddToShootingObjects(Unit *object, int aishipindex);
	void AddToAIShootingObjects(Unit *object);
	void RemoveFromShootingObjects(int index);
	void DestroyObjects();
	void DisplayMinimap(int x, int y, int shipx, int shipy, int range);
	void DisplayOnScreenObjects(int x, int y, int w, int h);
	void CheckSectors(int sectorx, int sectory);
	int CheckCollisions(Unit *a);
	int CheckUnitCollisions(Unit *a);
	int CheckShipCollisions(Unit *a);
	void SpawnBullet(int x, int y, int speed, int angle, std::string img, std::string fpk, SDL_Surface *image, int aishipindex=-1, int slotid=0);
	void SpawnAIBullet(int x, int y, int speed, int angle, std::string img, std::string fpk, SDL_Surface *image, bool target=false);
	void MoveBullets();
	void MoveAI(int sx, int sy);
	void SetZoom(float szoom);
	void AddToAnimations(StaticAnim *anim);
	void RemoveFromActiveAnims(int index);
	void AddToUnits(Unit *unit);
	void RemoveFromUnits(int index);
	void SpawnAnim(int index, int x, int y);
	void Dock(int x, int y);
	int GetUnitX(int index);
	int GetUnitY(int index);
	void SetTarget(int index);
	void DisplayAITarget(int sx, int sy, int sw, int sh, TTF_Font *font, int targetx, int targety);
	int GetUnitImageW(int index);
	int GetUnitImageH(int index);
	int GetObjCount();
	int GetUnitCount();
	void SendPauseTime(Uint32 time);
	Unit *mainship;
private:
	std::deque<Unit*> units;
	std::deque<MapObject*> objects;
	std::deque<Station*> stations;
	std::deque<Unit*> actobjects;
	std::deque<MapBullet*> sobjects;
	std::deque<StaticAnim*> anims;
	std::deque<StaticAnim*> activeanims;
	int target;
	float zoom;
};

#endif /* __MAP_H__ */

