
#include <Animationrig.h>

namespace Animrig {
	// key
	AnimKey* AnimKey::createKeyFromLayerType(LayerType layertype, int frame_)
	{
		AnimKey *key = nullptr;
		switch (layertype)
		{
		case LayerType::AnimBlend4: key = new AnimBlend4Key(); break;
		case LayerType::AnimBlend1: key = new AnimBlend1Key(); break;
		case LayerType::SeekBlend4: key = new SeekBlend4Key(); break;
		case LayerType::SeekBlend1: key = new SeekBlend1Key(); break;
		case LayerType::Transform: key = new TransformKey(); break;
		case LayerType::Event: key = new EventKey(); break;
		case LayerType::Priority: key = new PriorityKey(); break;
		case LayerType::State: key = new StateKey(); break;
		case LayerType::PhysicsForce: key = new PhysicsForceKey(); break;
		}
		if (key == nullptr)
		{
			throw exception("CreateKeyFromLayerType : unsupport type.");
		}
		key->frame = frame_;
		return key;
	}
	// object
	AnimObject* AnimObject::createFromObjectType(ObjectType objecttype)
	{
		AnimObject *obj = nullptr;
		switch (objecttype)
		{
		case ObjectType::Null: obj = new NullObject(); break;
		case ObjectType::Spine: obj = new SpineObject(); break;
		}
		if (obj == nullptr)
		{
			throw exception("AddObject : unsupport object.");
		}
		return obj;
	}
}