#pragma once

#include "vector2d.h"
#include "utils.h"
#include <map>

namespace Halley {

	namespace Collision {
		enum Mask {
			None,
			Player,
			Deadly,
			Collectible,
			Building,
			Rocket
		};

		typedef std::function<void(Sprite&)> Trigger;
		typedef std::pair<Mask, Trigger> TriggerPair;
		typedef std::vector<TriggerPair> TriggerMap;

		class Type {
		public:
			Type();

			Mask mask;
			float radius;
		};


		typedef std::pair<spSprite, Trigger> SpriteData;
		typedef std::vector<SpriteData> SpriteDataList;


		class Checker {
		public:
			void reset();
			void addTriggerMap(spSprite sprite, TriggerMap& map);
			void runCollisions(std::map<int, SpriteList>& objects);

		private:

			void runCollisions(SpriteDataList& triggers, SpriteList& objects);
			bool collides(Type& a, Type& b, Vector2f aPos, Vector2f bPos);

			std::map<Mask, SpriteDataList> triggers;
		};
	}
}
