
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_ServerProjectile_Mine.h
// Author : Chris Wallace
// Date   : 25-Feb-2009
//
// Copyright (C) 2009 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE

#ifndef __AVP_SERVERPROJECTILE_MINE_H__
#define __AVP_SERVERPROJECTILE_MINE_H__

////////////////////////////////////////////////////////////////////////////////
// Include files...
////////////////////////////////////////////////////////////////////////////////

#include "Entity/PhysicalObject/Projectile/AVP_ServerProjectile_GenericProjectile.h"

////////////////////////////////////////////////////////////////////////////////
// Class        : AVP_ServerProjectile_Mine
// Author       : Chris Wallace
// Date         : 25-Feb-2009
//
// Description  : Class to handle the Mine
////////////////////////////////////////////////////////////////////////////////

class AVP_ServerActor_Predator;

class AVP_ServerProjectile_Mine : public AVP_ServerProjectile_GenericProjectile
{
public:
	// Public functions...
	static	AVP_ServerProjectile_Mine*	Create( const Asura_Message* pxMsg );

	// Overridden functions...
	virtual void	Launch	(const Asura_Vector_3& xPosition, const Asura_Matrix_3x3& xOrientation, const Asura_Vector_3& xVelocity, const Asura_Guid uGuidToIgnore, float fDamageMultiplier);

	virtual	void	Update			(void);
	virtual	bool	HandleMessage	(const Asura_Message* pxMessage);

	// Overridden chunk-handling functions...
	virtual	void	ReadFromChunkStream	(Asura_Chunk_Stream& xStream);
	virtual	void	WriteToChunkStream	(Asura_Chunk_Stream& xStream) const;
	virtual bool	CanBeSavedToChunk	(void) const	{ return(true); }

	// Legacy chunk handling, to be removed as soon as possible...
	virtual	bool	IsFilledFromChunkBuffer	(void) const	{ return(false); }

	u_int	GetMineState() const		{ return m_uMineState; }
	float	GetDetonationOffset() const	{ return m_fDetonationOffset; }

	// Static list accessors...
	static	AVP_ServerProjectile_Mine*							FindEntity	(const Asura_Guid uGuid)	{ return(s_xList.FindEntity(uGuid)); }
	static	const Asura_Hashed_List<AVP_ServerProjectile_Mine>*	GetList		(void)						{ return(&s_xList); }

	static void CreateFromChunkStream( Asura_Guid uGuid, Asura_Chunk_Stream& xStream );

protected:
	// Protected variables...

	// Protected functions...
	AVP_ServerProjectile_Mine          (const Asura_Guid uGuid);
	AVP_ServerProjectile_Mine          (const Asura_Guid uGuid, const Asura_Message* pxMsg);
	virtual ~AVP_ServerProjectile_Mine ();

	// Overridden entity update functions...
	virtual	void	MakeClientUpdateMessage	(void);

	virtual void	InitialiseFromBlueprint( const Asura_Blueprint& xBlueprint );


	// Overridden event functions...
	//virtual	void	OnCollision	(const Asura_LOS_InputData& xLOSInputData, const Asura_LOS_OutputData& xLOSOutputData);
	//virtual void	OnImpact( const Asura_Vector_3& xImpactPoint, const Asura_Vector_3& xImpactNormal = Asura_Maths::ZeroVector3 );
	virtual void OnEmbed( const Asura_Vector_3& xImpactPoint, const Asura_Vector_3& xImpactNormal );

private:

	enum
	{
		MINE_IN_FLIGHT,
		MINE_ARMING,
		MINE_ARMED,
		MINE_TRIGGERED,
	};

	// Private typedefs...
	typedef AVP_ServerProjectile_GenericProjectile PARENT;

	// Private variables...
	u_int		m_uMineState;
	static		Asura_Hashed_List<AVP_ServerProjectile_Mine>	s_xList;

	float		m_fStateTimer;
	float		m_fMineArmingTimer;
	float		m_fMineDetonateTimer;
	float		m_fTriggerRange;
	float		m_fDetonationOffset;

	// Private functions...
	void AttachToWall(void);

	AVP_ServerProjectile_Mine  (void);
	AVP_ServerProjectile_Mine  (const AVP_ServerProjectile_Mine& xOther);

	AVP_ServerProjectile_Mine&	operator=	(const AVP_ServerProjectile_Mine& xOther);

};   // End of class 'AVP_ServerProjectile_Mine'.


#endif   // ifndef __AVP_SERVERPROJECTILE_MINE_H__


/// End of file. ///
