#include "pattern.h"
#include "gameframe.h"

Pattern::~Pattern()
{
}

void Pattern::start(Difficulty::Level _dif)
{
	dif = _dif;
}

void Pattern::spawn(spSprite s)
{
	auto frame = (GameFrame*) &getFrame();
	frame->spawn(s);
}

void Pattern::spawn(Sprite* s)
{
	spawn(spSprite(s));
}

PatternFactory::PatternFactory(String name, std::function<Pattern*()> f)
{
	get()[name] = f;
}

PatternMap& PatternFactory::get()
{
	if (!patterns) patterns = new PatternMap();
	return *patterns;
}

spSprite PatternFactory::create(String name)
{
	return spSprite(get()[name]());
}

PatternMap* PatternFactory::patterns = nullptr;
