#ifndef _CONSTRUCTION_H__
#define _CONSTRUCTION_H__


#include "loadsnd.h"
	 


enum
{
	CON_SAWER,			   //0
	CON_HAMMER,			   //1
	CON_SPANNER,		   //2
	CON_NUM_TOOLS,		   //3
};						   


enum
{
	CON_GAMESTATE_FADEIN,	   //0
	CON_GAMESTATE_INTRO,	   //1
	CON_GAMESTATE_RUNNING,	   //2
	CON_GAMESTATE_ENDING,	   //3
	CON_GAMESTATE_OUTRO,	   //4
	CON_GAMESTATE_FADEOUT,	   //5
};							   
							   

enum
{
	CON_CAMSTATE_ARRIVED,	   //0
	CON_CAMSTATE_MOVING,	   //1
	
};


enum
{							 
	CON_TWEEDY_IDLE,		 //0
	CON_TWEEDY_WORKING,		 //1
	CON_TWEEDY_STOP_WORKING, //2
	CON_TWEEDY_SUSPICIOUS,	 //3
	CON_TWEEDY_ENDING,		 //4
};							 


typedef struct
{
	int state;
	int currentTool;
	ACTOR *actor;
	PSIMODEL *model;
	TextureType *overlay;				
}CON_MRTWEEDY_CAM;



enum
{
	CON_SQUARE,			   //0
	CON_CROSS,			   //1
	CON_CIRCLE,			   //2
	CON_NUM_BUTTONS,	   //3
};						   

#define CON_NUM_CHICK_FRAMES 2

enum
{
	CON_RHYTHM_STATE_OFF,				//0
	CON_RHYTHM_STATE_SHOWING,			//1
	CON_RHYTHM_STATE_COUNTING,			//2
	CON_RHYTHM_STATE_TESTING,			//3
	CON_RHYTHM_STATE_CHANGING,			//4
	CON_RHYTHM_STATE_STARTNEW,			//5
	CON_RHYTHM_STATE_PLACINGBUTTONS,	//6
};

#define CON_TIME_FOR_BAR 8000

typedef struct
{							  
	TextureType *buttons[CON_NUM_BUTTONS];
	TextureType *wrongButtons[CON_NUM_BUTTONS];
	TextureType *back;
//	TextureType *chick[CON_NUM_CHICK_FRAMES];

	ACTOR *actor; //chick
	PSIMODEL *model; //chick

	char currentButtons[8];
	signed char pressedButtons[8];

	int state;
	int currentRhythm;
	int posInBar; //CON_TIME_FOR_BAR 4000 == 4 beats
	int posOnWood;
	int currentBeat;
	int lastBeat;
	int numTimesPlayed;

}CON_RYTHM_DISPLAY;



typedef struct
{
	int state;
	int targetTool;
	int lastTool;
	int distBetweenCamPos;

	VECTOR pos;
	VECTOR garibPos;
}CON_CAMERA;


enum
{
	CON_TOOL_IDLE,				//0
	CON_TOOL_PREPARE,			//1
	CON_TOOL_HITTING,			//2
	CON_TOOL_STOPWORK,			//3
								
};

typedef struct
{
	int state;

	PSIMODEL *model;
	ACTOR *actor;
}CON_CHICKEN;




typedef struct
{
	int	gameState;

	
	CON_CAMERA cam;
	CON_CHICKEN tools[CON_NUM_TOOLS];
	CON_MRTWEEDY_CAM tweedy;
	CON_RYTHM_DISPLAY rhythm;

	long frameCount;
	long countDown;
	int numChickensSaved;

	int progress;

//	TextureType *progBar;
	TextureType *bronzeBar;
	TextureType *silverBar;
	TextureType *goldBar;
	TextureType *arrow;

	TextureType *tweedycEyesAnim[2];
	TextureType *tweedycEyesDummy;
	TextureAnimType *tweedycEyesBlinking;

	SfxSampleType *pSamples[NUM_CONSTRUCT_SAMPLES];


	int eyesTimer;

	int activeTool;

}CONSTRUCT_DATA;


void constructStart();
void constructEnd();
void constructDraw();
void constructCycle();
void constructControl();
void conUpdateCamera();
void conUpdateRhythm();
void conUpdateTools();
void conUpdateMrTweedy();
void conTweedyChangeTool();

void constructPrintDebugText();
void constructDebugMoveCamera();
void constructDebugMoveActor();

void conDrawRhythm();
void conDrawTweedy();
void conDrawChick();
void conDrawProgressBar();


void conDrawIntro();
void conDrawBronzeSuccess();
void conDrawSilverSuccess();
void conDrawGoldSuccess();
void conDrawFail();

void conPlaySound(short tweedy, short button);


#endif