//===========================================================================//
// File:	NetMovement.hpp				
// Contents : All movement messages and rewind capabilites				
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 01/06/1999  JSE  Inital coding
//---------------------------------------------------------------------------//
// Copyright (C) 1998, Microsoft Corp.										 //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//



#pragma once

#include "NetConstants.hpp"
#include "NetUpdateManager.hpp"
#include "MechAnimationState.hpp"

namespace MechWarrior4 
{

	class MWEntityManager;
	class Mech;

	void NetMovementSecurityCheckStart();
	void NetMovementSecurityCheckStop();
	

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	
	class MechPositionUpdate
	{
	public:

		enum {
			XPositionUpdateEntryID = 0,
			YAboveTerrainUpdateEntryID,
			ZPositionUpdateUpdateEntryID,
			CurrentRotationUpdateEntryID,
			CurrentTorsoPitchUpdateEntryID,
			CurrentTorsoYawUpdateEntryID,
			CurrentSpeedUpdateEntryID,
			CurrentXVelocityEntryID,
			CurrentYVelocityEntryID,
			CurrentZVelocityEntryID,
			RotationDemandUpdateEntryID,
			SpeedDemandUpdateEntryID,
			TorsoPichDemandUpdateEntryID,
			TorsoYawDemandUpdateEntryID,
			ViewDemandUpdateEntryID,
			UpdateEntryCount
		};

		enum {
			UpdateType = UpdateManager::MechPositionUpdateID
		};

		enum {
			DrivingState = 0,
			JumpingState,
			FallingState
		};

		static void Decode(Entity *entity, MemoryStream *memory_stream, Time till, Scalar packet_latency, int connection, int debug_level, int bandwidth, Scalar rate);
		static void Skip(MemoryStream *memory_stream, int size, Time till, int connection, int debug_level, int bandwidth);
		static void Encode(Entity *entity,  DynamicMemoryStream *memory_stream, int connection, int debug_level, int bandwidth);
		static int SizeFunction(Entity *entity){return -1;};
		static int MaxSize(Entity *entity, int debug_level, int bandwidth);
		static bool MaintainActiveFlagFunction(Entity *entity,Point3D cull_location);

		static int GetUpdateEntryCount(){return UpdateEntryCount;};
		static int GetUpdateEntryType(){return UpdateType;};

	};

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	
	class MechAnimationUpdate
	{
	public:
		
		enum {
			CurrentSimulationStateUpdateEntryID = 0,
			AnimationStateUpdateEntryID,
			TransitionStateUpdateEntryID,
			CurrentPositionUpdateEntryID,
			TranisitonPositionUpdateEntryID,
			NewPositionUpdateEntryID,
			UpdateEntryCount
		};

		enum {
			UpdateType = UpdateManager::MechAnimationUpdateID
		};




		static void Decode(Entity *entity, MemoryStream *memory_stream, Time till, Scalar packet_latency, int connection, int debug_level, int bandwidth, Scalar rate);
		static void Skip(MemoryStream *memory_stream, int size, Time till, int connection, int debug_level, int bandwidth);
		static void Encode(Entity *entity, DynamicMemoryStream *memory_stream, int connection, int debug_level, int bandwidth);
		static int SizeFunction(Entity *entity){return -1;};
		static int MaxSize(Entity *entity, int debug_level, int bandwidth);
		static bool MaintainActiveFlagFunction(Entity *entity,Point3D cull_location){return true;}

		static int GetUpdateEntryCount(){return UpdateEntryCount;};
		static int GetUpdateEntryType(){return UpdateType;};
	};

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	

	class MechMovemntUpdate
	{
	public:

		enum {
			
			UpdateEntryCount = 0
		};

		enum {
			UpdateType = UpdateManager::MechMovemntUpdateID
		};

		static void Decode(Entity *entity, MemoryStream *memory_stream, Time till, Scalar packet_latency, int connection, int debug_level, int bandwidth, Scalar rate);
		static void Skip(MemoryStream *memory_stream, int size, Time till, int connection, int debug_level, int bandwidth);
		static void Encode(Entity *entity, DynamicMemoryStream *memory_stream, int connection, int debug_level, int bandwidth);
		static int SizeFunction(Entity *entity){return -1;};
		static int MaxSize(Entity *entity, int debug_level, int bandwidth);
		static bool MaintainActiveFlagFunction(Entity *entity,Point3D cull_location);

		static int GetUpdateEntryCount(){return UpdateEntryCount;};
		static int GetUpdateEntryType(){return UpdateType;};
	};




	
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// this one is special and doesn't go thru the standerd encode and decode process

	class MechFirstPersonPositionUpdate
	{
	public:

		enum {
			UpdateEntryCount = 0
		};

		enum {
			UpdateType = UpdateManager::MechFirstPersonPositionUpdateID
		};


		static void Decode(Entity *entity, MemoryStream *memory_stream, Time till, Scalar packet_latency, int connection, int debug_level, int bandwidth, Scalar rate){STOP(("NOT SUPPORTED"));};
		static void Skip(MemoryStream *memory_stream, Time till, int connection, int debug_level, int bandwidth){STOP(("NOT SUPPORTED"));};
		static void Encode(Entity *entity, DynamicMemoryStream *memory_stream, int connection, int debug_level, int bandwidth){STOP(("NOT SUPPORTED"));};
		static int SizeFunction(Entity *entity){return -1;};
		static int MaxSize(Entity *entity, int debug_level, int bandwidth){return 0;};
		static bool MaintainActiveFlagFunction(Entity *entity,Point3D cull_location){return true;}

		static int GetUpdateEntryCount(){return UpdateEntryCount;};
		static int GetUpdateEntryType(){return UpdateType;};
	};

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	

	class MechFirstPersonControlUpdate
	{
	public:

		enum {
			UpdateEntryCount = 0
		};

		enum {
			UpdateType = UpdateManager::MechFirstPersonControlUpdateID
		};

		static void Decode(Entity *entity, MemoryStream *memory_stream, Time till, Scalar packet_latency, int connection, int debug_level, int bandwidth, Scalar rate){STOP(("NOT SUPPORTED"));};
		static void Skip(MemoryStream *memory_stream, Time till, int connection, int debug_level, int bandwidth){STOP(("NOT SUPPORTED"));};
		static void Encode(Entity *entity, DynamicMemoryStream *memory_stream, int connection, int debug_level, int bandwidth){STOP(("NOT SUPPORTED"));};
		static int SizeFunction(Entity *entity){return -1;};
		static int MaxSize(Entity *entity, int debug_level, int bandwidth){return 0;};
		static bool MaintainActiveFlagFunction(Entity *entity,Point3D cull_location){return true;}

		static int GetUpdateEntryCount(){return UpdateEntryCount;};
		static int GetUpdateEntryType(){return UpdateType;};
	};



};