#ifndef __ENTITIES
#define __ENTITIES

#include "vectors.h"
#include "fileio.h"

enum{
	kRenderTypeNone=0,
	kRenderTypeModel,
	kRenderTypeCar,
	kRenderTypeGhost
};

enum{
	kPhysicsTypeNone=0,
	kPhysicsTypeCar,
	kPhysicsTypeSolid,
	kPhysicsTypeGhost
};

enum{
	kPhysicsNone=0,
	kPhysicsLocal,
	kPhysicsRemote
};

enum{
	kControlTypeNone=0,
	kControlTypeUserInput,
	kControlTypeAIInput
};

enum{
	kPathTypeCircular=0,
	kPathTypeSin
};

typedef struct{
	tVector3 tfr,tfl,trl,trr,bfr,bfl,brl,brr;
} tCollBox;


enum{
	kLightTypeDot=0,
	kLightTypeSpot,
	kLightTypeDotRefelective,
	kLightTypeDirectionlessDot,
	kLightTypeDirectionlessDotReflective,
	kLightTypeSpecularDot
};

typedef struct{
	tVector3 pos,dir,rgb;		
	float size,radius;	
	int type;
	int onFlags;
	int offFlags;	
} tLightDefinition;

typedef struct{
	int model;
	int shadowModel;
	float maxCollRadius;
	int numCollBoxes;
	int numColors;
	int sparks;
	int randomColor;
	tCollBox *coll;
	tVector3 massCenter;
	int movable,followPath,pathType,liquid,particleStick;
	tFileRef particle;
	tFileRef sound;
	int numSounds;
	float particleAmount,particleSize;
	float pathSize,pathVelo;
	float mass,inertia;
	int numLights;
	tLightDefinition *lights;
} tSolidEntityPhysics;

#define kNumAvgRVelos 32
typedef struct{
	void *next,*prev;
	tVector3 pos,velo,oldPos,netVelo,collVelo,netPos,accel;
	tMatrix3 dir,rVelo,oldDir,netDir,netRVelo;
	tMatrix3 lastRVelos[kNumAvgRVelos];
	tVector3 lastVelos[kNumAvgRVelos];
	tVector3 lastAccel[kNumAvgRVelos];
	tVector3 remoteCameraPos;
	int renderType,renderData;
	int physicsType,physicsData,physicsMachine;
	int untouchable;
	int controlType;
	void *soundSource;
	int id;
	int lastFrame;
	int lastRoadIndex;
	int lastActivity;
	int lastPacketSent;
	tVector3 lastVeloSent;
	tVector3 lastRZSent;
	tVector3 lastDirZSent;
	int lastPacketSaved;
	tVector3 lastVeloSaved;
	tVector3 lastRZSaved;
	tVector3 lastDirZSaved;
	float zDist;
	void *physics;
	void *regData;
} tGameEntity;

extern tGameEntity *gFirstEntity,*gCameraEntity,*gViewedEntity;

void EntityResetCount();
tGameEntity *EntityNew(tGameEntity *prev);

#endif