#ifndef _EGGLAYING_H__
#define _EGGLAYING_H__

#include "loadsnd.h"



// Chicken's animations
enum
{
	EGGLAYER_FEEDME,
	EGGLAYER_EATING,
	EGGLAYER_SWALLOW,
	EGGLAYER_LAY,
	EGGLAYER_RELIEF,
	EGGLAYER_IDLE,
	EGGLAYER_BREATH,
};





enum
{
	ELSTATION_CHICKENA,
	ELSTATION_BUNTY1,
	ELSTATION_BUNTY2,
	ELSTATION_CHICKENB,
	NUM_EL_STATIONS,
};



#define NUM_EL_EGGS 6

// chicken states


enum
{
	EL_LAYER1,
	EL_BUNTY,
	EL_LAYER2,
	NUM_EL_CHICKS,
};

typedef struct
{
	int state;
	int timer;
	int grainState;
	int grainActive[2];
	int grainPos[2];
	int sampleLoop;

	ACTOR *actor;

}EL_CHICKEN;

typedef struct
{
	short active;
	short chute;

	ACTOR *actor;

}EL_EGG;

enum
{
	EL_GRAIN_STOPPED,
	EL_GRAIN_STOPPING,
	EL_GRAIN_ACTIVE,
	EL_GRAIN_STARTING,
};


enum
{
	EL_FADEIN,
	EL_INTRO_BUGGER_OFF,
	EL_INTRO,
	EL_RUNNING,
	EL_FINISHING_SUCCEED,
	EL_FINISHING_FAIL,
	EL_BRONZE_SUCCESS,
	EL_SILVER_SUCCESS,
	EL_GOLD_SUCCESS,
	EL_FAILED,
	EL_FADEOUT,
};


#define EL_NUM_EGG_TEXTURES 5

typedef struct
{
	TextureType *egg[EL_NUM_EGG_TEXTURES];

	TextureType *chick[NUM_EL_CHICKS];
	TextureType *chickSel[NUM_EL_CHICKS];

	TextureType *layChick[NUM_EL_CHICKS];
	TextureType *fillChick[NUM_EL_CHICKS];

	TextureType *baskOff;
	TextureType *baskOn;

	TextureType *splat;

	TextureType *pipes;
	TextureType *pipeSel;

}EL_PANEL;



typedef struct
{
	long	frameCount;
	int		countdown;
	short	state;
	short   station;
	short   lastStation;

	short	cameraMoving;
	short	cameraMovingCount;
	short	cameraXRot;
	short	cameraYRot;

	short   startCameraXRot;
	short   startCameraYRot;
	int		framesForCamMove;
	
	short	cameraTargetYRot;
	short	ending;
	int		eggsFinished;


	TextureType *grain;

	EL_CHICKEN chicks[NUM_EL_CHICKS];
	EL_EGG eggs[NUM_EL_EGGS][2];
	EL_PANEL panel;
	TextureType *arrow;


	SfxSampleType *pSamples[NUM_EGGLAYING_SAMPLES];


}EGGLAYING_CTRL;


void elStart4();
void elStart2();
void elStart1();
void elStart();
void elEnd();
void elDraw();
void elCycle();

void elCamera();

void elInit();
void elPanel();
void elPanelCycle();
void elDrawPanel();


void elEggDraw();
void elEggStartRolling(int chute);
void elEggUpdate();

void elDrawIntroBuggerOff();
void elDrawIntro();
void elDrawFail();
void elDrawGoldSuccess();
void elDrawSilverSuccess();
void elDrawBronzeSuccess();

void elPrintDebug();
void egglayingFree();
void elReset();
void egglayingRestart();



#endif