#ifndef SHAREDSTRUCTURES_H
#define SHAREDSTRUCTURES_H

#include "./../../../lib/glee/glee.h"
#include "math\Mathematics.h"
#include "illumination/tricol.h"
#include "../Render/SpaceStructures.h"

#include <string>

#include "texture\TextureSupport.h"

//forward declaration
enum ShipType;
enum MissileType;

struct MissileTarget;

///Auxiliary base structure to hold data recieved from server
struct MapObjectData
{
	unsigned long  id; /**< unique object identificator*/
};

///Auxiliary structure to hold data about stars in galaxy recieved from server
struct StarData : public MapObjectData
{
	ANALYTICAL_GEOMETRY::Point_3<double> position;		/**< actual position*/
};

///Auxiliary structure to hold data about Ships in waprs recieved from server
struct ShipWarpInfo: public MapObjectData
{
	bool inWarp;										/**< true if ship is in warp at this moment. */
	bool stateChange;									/**< true if warp->normal or normal->warp status was changed */
	ANALYTICAL_GEOMETRY::Point_3<double> position;		/**< actual position*/
	ANALYTICAL_GEOMETRY::Point_3<double> srcPosition;	/**< starting position*/
	ANALYTICAL_GEOMETRY::Point_3<double> dstPosition;	/**< destination position*/
	double speed;										/**< move speed*/

	ShipType type;
	string name;

};

///Auxiliary structure to hold data about Ships in galaxy recieved from server
struct ShipDataBasic : public MapObjectData
{
	ANALYTICAL_GEOMETRY::Point_3<double> position;		/**< actual position*/
	ANALYTICAL_GEOMETRY::Point_3<double> dstPosition;	/**< destination position*/
	double speed;										/**< move speed*/
	double acceleration;								/**< acceleration speed*/
	string name;										/**< name of the ship*/
	bool inWarp;										/**< Is ship in Warp flag */ 
	bool inBase;										/**< Is ship in Base flag */ 
};

///Auxiliary structure to hold more detailed data about Ships in galaxy recieved from server
struct ShipDataDetails : public ShipDataBasic
{
	ShipType type;										/**< type of ship*/
	unsigned int lifePercentage;						/**< lifes*/
	unsigned int shieldPercentage;						/**< shields*/
	bool isOrbiting;									/**< Flag if the ship is orbiting or not. */
	ANALYTICAL_GEOMETRY::Point_3<double> orbitPivot;	/**< Orbit pivot position if orbiting. */
	double orbitSpeed;									/**<Angular orbit speed if orbiting. */
	bool isMining;										/**< Flag if the ship is mining during orbiting. */

	MissileTarget enemyTarget;							/**< Enemy target data. */
};

//############################################################

///Auxiliary structure to hold data about Planets in galaxy recieved from server
struct PlanetData : public MapObjectData
{
	ANALYTICAL_GEOMETRY::Vector_3<double> axis;	/**< axis to rotate around*/
	ANALYTICAL_GEOMETRY::Point_3<double> pivot;	/**< pivot position*/
	double radius;			/**< distance from pivot*/
	double speed;			/**< speed of rotation*/
	double angle;			/**< actual rotation angle*/
	double objectSize;		/**< size of the planet*/
	string name;

	std::vector< MissileTarget > enemyTargetData; /**< contains enemy identifiers to attack. */
};


//############################################################

///Auxiliary structure to hold more detailed data about Planets in galaxy recieved from server
struct GenericPlanetData : public PlanetData
{
	CTriCol color;				/**< color of the planet*/

	std::string coronaTextureName; /**< corona sprite texture name */
	std::string textureName;	/**< texture name */
};

//############################################################


//forward declarations
enum BaselineType
{
	baseType0 = 0,
	baseType1 = 1,
	baseType2 = 2
};

enum PlanetType
{
	vulcanPlanet = 0,
	alienPlanet = 1,
	crystalPlanet = 2,
	desertPlanet = 3,
	greenPlanet = 4,
	frozenPlanet = 5,
	mountainPlanet = 6,
	starPlanet = 99
};

///Auxiliary structure to hold data recieved from server about base and planet surface, where the base is build.
struct BaselineData
{
	BaselineType baselineType;
	string materialName;
	string surfaceTexName;
	string cloudName;
	string skyboxName;
	string terrainScript;
};


///Synchronization interface which synchronize data recieved from server with other classes, which use this server data.
/**
*	Abstract client synchronisation interface, which synchronize 
*	data on client with data recieved from server
*/
class SynchronisationInterface
{
public:
	virtual void warpSynchronize( const ShipWarpInfo &shipWarpInfo )= 0; /**< Synchronize ships in warp  */
	virtual void shipSynchronizeMacro(const ShipDataBasic &shipData, bool useAlphaOffset = false  ) =0;	/**< Synchronize ships from macro map mode  */
	virtual void shipSynchronizeMicro(const ShipDataDetails &shipData ) =0;	/**< Synchronize ships micro map mode  */
	virtual void shipSynchronize(const ShipDataDetails &shipData ) =0; /**< Synchronize ships from macro & micro map mode  */


	virtual void spaceshipSynchronize( const ShipType shipType ) = 0;
	virtual void baselineSynchronize( const BaselineData &baselineData) =0;

	virtual void planetSynchronize( const GenericPlanetData &planetData)=0;


	virtual void starSynchronize(  const StarData &starData )= 0;

	/// add whatever we will need or should be usefull
};

#endif