/// @file ActionManager.h
#ifndef ACTIONMANAGER_H
#define ACTIONMANAGER_H
#include "Actor.h"
#include <vector>
using std::vector;
/**
	@brief GameCore 액션관리 클래스

	액터와 controlTable를 관리하는 클래스입니다.\n
	이 두가지는 END Core에서 실제 act를 하는데 무척 중요한 객체들입니다.
*/

class ActionManager {
public:
	~ActionManager(){
		setCurrentActorPocket(ActionManager::SECONDARY);
		clearCurrentActorPocket();
		setCurrentActorPocket(ActionManager::PRIMARY);
		clearCurrentActorPocket();
	}
	enum { PRIMARY = 0, SECONDARY };

	//Act에 필요한것들
	vector<Actor*> * pCurrentActorPocket;
	ControlTable aControlTable;
	DevicePocket aDevicePocket;

	//set current ActorPocket
	void setCurrentActorPocket(int _type){
		if( _type == PRIMARY ){
			pCurrentActorPocket = &prmActorPocket_;
		}else{
			pCurrentActorPocket = &sndActorPocket_;
		}
	}

	//Action Process
	void process(){
		for(itrActor_  = pCurrentActorPocket->begin();
			itrActor_ != pCurrentActorPocket->end(); itrActor_++){
			(*itrActor_)->process();
		}
	}

	//clear Current Actor Pocket
	void clearCurrentActorPocket(){
		for(itrActor_  = pCurrentActorPocket->begin();
			itrActor_ != pCurrentActorPocket->end(); itrActor_++){
			delete (*itrActor_);
		}
		pCurrentActorPocket->clear();
	}
private:
	vector<Actor*> prmActorPocket_;
	vector<Actor*> sndActorPocket_;
	vector<Actor*>::iterator itrActor_;
};
#endif