/******************************************************************************************
	CRTEST PS   (c) 1999-2001 ISL

	catapult.h:			Catapulty level 2 subgame code
******************************************************************************************/

#ifndef _CATAPULT_H_
#define _CATAPULT_H_


#define CAT_NUM_DRONES  5
#define CAT_NUM_FLOATERS  4



#include "loadsnd.h"


extern TextureType	*ripple;





 
enum
{
	CAT_STATE_FADEIN,
	CAT_STATE_RUNNING,
	CAT_STATE_INTRO,
	CAT_STATE_GOLD_SUCCESS,
	CAT_STATE_SILVER_SUCCESS,
	CAT_STATE_BRONZE_SUCCESS,
	CAT_STATE_FAIL,
	CAT_STATE_FINISH,
	CAT_STATE_FADEOUT,
};



enum
{
	CAT_DRONE_INACTIVE,
	CAT_DRONE_RUNTO_WAITING,
	CAT_DRONE_WAITING,
	CAT_DRONE_RUNNINGON,
	CAT_DRONE_JUMPINGON,
	CAT_DRONE_ONDEVICE,
	CAT_DRONE_LAUNCHING,
	CAT_DRONE_FLYING,
	CAT_DRONE_CRASHING,
	CAT_DRONE_LANDING,
	CAT_DRONE_LANDED,
	CAT_DRONE_FALLOFF,
	CAT_DRONE_JUMPINGOFF,
	CAT_DRONE_RUNNINGOFF,
};



typedef struct
{
	int state;

	int floater;
	int anim;
	int countUp;
	VECTOR vel;
	int	rotAim;

	int xRotState;
	int xRotSpeed;

	VECTOR target;

	PSIMODEL *model;
	ACTOR *actor;
	
	int sound;
	SfxSampleType* weeSample;

}catDroneStr;

typedef struct
{

	PSIMODEL *model;
	ACTOR *actor;
	VECTOR pos;
	VECTOR chickenPos;

	int yRot;
	int yTargetRot;
	long power;

	int animPos;

	int droneOnDevice;
	int nextDrone;

	PSIMODEL *winderModel;
	ACTOR	 *winderActor;

}catDeviceStr;


typedef struct
{
	PSIMODEL *model;
	ACTOR *actor;
	
	VECTOR pos;
	VECTOR vel;

	VECTOR chickenPos;
	VECTOR targetPos;

	int active;

	int point;
	int yRot;

	int yRotSpeed;
	int targetyRotSpeed;
	int wobble;

	int animPos;
	int droneOn;

}catFloaterStr;


typedef struct 
{

	VECTOR camPos;
	int camRotSpeed;
	int camDistToLookAt;

	long frameCount;
	int numChickensSaved;
	int state;
	int countdown;

	SfxSampleType *pSamples[NUM_CATAPULT_SAMPLES];


	catFloaterStr   floaters[CAT_NUM_FLOATERS];
	catDroneStr		drones[CAT_NUM_DRONES];
	catDeviceStr	device;

}catStr;



void catapultStart();
void catapultEnd();
void catapultExit();
void catapultPrintDebugText();
void catapultCycle();
void catapultDraw();
void catapultControls();



void catUpdateCamAim();

//void MoveCameraTowardsLookAtPoint(int delta);
void catFloaterUpdate();
void catDeviceUpdate();
void catDronesUpdate();
void catDroneLaunch();
int catFloaterCatchChicken(VECTOR *pos, int dist);
//void catDrawSpeedMeter();
//void catPrintChickenCount();
void catMakeActiveChickensRunOff();

void catDrawIntro();
void catDrawGoldSuccess();
void catDrawSilverSuccess();
void catDrawBronzeSuccess();
void catDrawFail();
void catapultFree();
void catapultReset();
void catapultRestart();

void catapultUpdateAnims();


#endif
