#ifndef __AISTATEHPP__
#define __AISTATEHPP__

#include <windows.h>
#include "ai event.hpp"

enum STATETYPE {MOVE_STATE,SLEEP_STATE,GUARD_STATE,WANDER_STATE,EAT_STATE,PLAY_STATE,READ_STATE,
		WAIT_STATE,TALK_STATE,SELL_STATE,BUY_STATE,ATTACK_STATE,DANCE_STATE,TAICHI_STATE,
		FIGHT_STATE,WORK_STATE,PROTECT_STATE};

#define LASTMOVESIZE 10

typedef struct {
	double destX;
	double destY;
	double speed;
} MoveStateData;

typedef struct {
	bool snore;
} SleepStateData;

typedef struct {
	bool burp;
} EatStateData;

typedef struct {
	double guardPointX[2];
	double guardPointY[2];
	double speed;
	int militancy;
	double lookX;
	double lookY;
} GuardStateData;

typedef struct {
	double left;
	double top;
	double right;
	double bottom;
	double speed;
} WanderStateData;

typedef struct {
	double left;
	double top;
	double right;
	double bottom;
} PlayStateData;

typedef struct {
	UINT readWhat;
} ReadStateData;

typedef struct {
	UINT action;
} WaitStateData;

typedef struct {
	UINT with;
} TalkStateData;

typedef struct {
	UINT what;
} SellStateData;

typedef struct {
	UINT what;
} BuyStateData;

typedef struct {
	UINT how;
} AttackStateData;

typedef struct {
	UINT form;
	UINT with;
} DanceStateData;

typedef struct {
	UINT form;
	UINT with;
} TaichiStateData;

typedef struct {
	UINT form;
	UINT with;
} FightStateData;

typedef struct {
	UINT job;
} WorkStateData;

typedef struct {
	UINT job;
} ProtectStateData;

typedef union {
	MoveStateData moveData;
	SleepStateData sleepData;
	GuardStateData guardData;
	WanderStateData wanderData;
	EatStateData eatData;
	PlayStateData playData;
	ReadStateData readData;
	WaitStateData waitData;
	TalkStateData talkData;
	SellStateData sellData;
	BuyStateData buyData;
	AttackStateData attackData;
	DanceStateData danceData;
	TaichiStateData taichiData;
	FightStateData fightData;
	WorkStateData workData;
	ProtectStateData protectData;
} StateDataUnion;

typedef struct StateEntry{
	int stateID;
	STATETYPE stateType;
	StateDataUnion stateData;
	EventEntry *events;
	StateEntry *next,*prev;
} StateEntry;

class AIStateTable 
{
	friend class AI;
private:
	StateEntry *m_Root;
	StateEntry *m_CurrentState;

public:
	AIStateTable (void);
	~AIStateTable (void);

};

#endif