#pragma once

#include "types.h"
#include "Sprite.h"
#include "gamebullet.h"

class GameFrame;

class Pattern : public Sprite {
public:
	virtual ~Pattern();

	void start(Difficulty::Level dif);

protected:
	Difficulty::Level getDifficulty() const { return dif; }

	void spawn(spSprite s);
	void spawn(Sprite* s);

private:
	Difficulty::Level dif;
};


typedef std::function<Pattern*()> PatternFunction;
typedef std::map<String, PatternFunction> PatternMap;

class PatternFactory {
public:
	PatternFactory(String name, PatternFunction f);

	static spSprite create(String name);

private:
	static PatternMap& get();
	static PatternMap* patterns;
};

#define REGISTER_PATTERN(name, T) static PatternFactory reg((name), [] () { return new T(); });
