
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_ServerEntity_AcidDamage.h
// Author : Andy Tate
// Date   : 28-Feb-2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

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

#ifndef __AVP_SERVERENTITY_ACIDDAMAGE_H__
#define __AVP_SERVERENTITY_ACIDDAMAGE_H__

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

#include "Core/Asura_HashTree.h"
#include "Entity/Asura_Entity.h"


////////////////////////////////////////////////////////////////////////////////
// Forward class declarations...
////////////////////////////////////////////////////////////////////////////////

class Asura_Message;
class Asura_Volume;

class AVP_Message_AcidDamage_Create;
class AVP_ServerEntity_AcidDamage;


////////////////////////////////////////////////////////////////////////////////
// Class declaration...
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Class        : AVP_AcidDamage_VictimData
// Author       : Andy Tate
// Date         : 29-Feb-2008
//
// Description  : Class used to store data for an entity which is a victim of
//				  acid-damage.
////////////////////////////////////////////////////////////////////////////////

class AVP_AcidDamage_VictimData
{
public:
	// Public functions...
	AVP_AcidDamage_VictimData(const Asura_Guid uVictimGuid)
	: m_uVictimGuid(uVictimGuid)
	, m_fTimeSinceLastDamage(-1.0f)
	{
	}

	AVP_AcidDamage_VictimData(const AVP_AcidDamage_VictimData& xOther)
	: m_uVictimGuid(xOther.m_uVictimGuid)
	, m_fTimeSinceLastDamage(xOther.m_fTimeSinceLastDamage)
	{
	}

	//~AVP_AcidDamage_VictimData();

	bool	Update(const AVP_ServerEntity_AcidDamage& xAcidDamage, const bool bWithinVolume, const float fScale);


protected:
	// Protected variables...

	// Protected functions...


private:
	// Private variables...
	Asura_Guid	m_uVictimGuid;			// The GUID of the victim.
	float		m_fTimeSinceLastDamage;	// The time since this entity was last damaged by the acid.

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

	AVP_AcidDamage_VictimData&	operator=(const AVP_AcidDamage_VictimData& xOther);

};   // End of class 'AVP_AcidDamage_VictimData'.



////////////////////////////////////////////////////////////////////////////////
// Class        : AVP_ServerEntity_AcidDamage
// Author       : Andy Tate
// Date         : 28-Feb-2008
//
// Description  : Class used to the application of acid-damage to entities.
////////////////////////////////////////////////////////////////////////////////

class AVP_ServerEntity_AcidDamage : public Asura_Entity_Server
{
public:
	// Public typedefs...
	typedef Asura_Classified_List<AVP_ServerEntity_AcidDamage> AcidDamageList;

	// Public functions...
	static AVP_ServerEntity_AcidDamage*	Create(const Asura_Message* pxMessage);

	// Overridden functions...
	virtual bool	HandleMessage(const Asura_Message* pxMessage);
	virtual void	MakeCreateMessage(Asura_Guid uRequestingClient, bool bSendGuaranteed);
	virtual void	Update(void);

	virtual bool	GetHasCreateMessage(void) const	{ return(true); }

	// Accessor functions...
	void	GetPosition(Asura_Vector_3& xPosition) const	{ xPosition = m_xPosition; }
	void	GetSurfaceNormal(Asura_Vector_3& xNormal) const	{ xNormal = m_xSurfaceNormal; }

	float	GetTimeBetweenDamageApplications(void) const	{ return(m_fTimeBetweenDamageApplications); }
	float	GetAmountPerApplication(void) const				{ return(m_fAmountPerApplication); }

	static AVP_ServerEntity_AcidDamage*	FindEntity(const Asura_Guid uGuid)	{ return(s_xList.FindEntity(uGuid)); }
	static const AcidDamageList&		GetList(void)						{ return(s_xList); }


protected:
	// Protected variables...

	// Protected functions...
	AVP_ServerEntity_AcidDamage(const AVP_Message_AcidDamage_Create& xMessage);
	virtual ~AVP_ServerEntity_AcidDamage();

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


private:
	// Private typedefs...
	typedef Asura_Entity_Server PARENT;
	typedef Asura_TemplateHashTree<AVP_AcidDamage_VictimData> VictimTree;

	// Private variables...
	Asura_Guid		m_uSourceGuid;						// The GUID of the entity which created this pool.
	float			m_fTimeSinceCreation;				// The number of seconds since this entity was created.
	float			m_fPoolDuration;					// The amount of time the pool is to be present for before fading.
	float			m_fPoolFadeOutDuration;				// The amount of time taken for the pool to fade-out.
	float			m_fTimeBetweenDamageApplications;	// The time between applications of damage to any victim of this pool.
	float			m_fAmountPerApplication;			// The amount of damage per application to the victim.
	bool			m_bIsTrailMode;						// Is Acid Part of a trail

	Asura_Vector_3	m_xSurfaceNormal;					// The normal of the surface to generate the acid-damage on.
	Asura_Vector_3	m_xPosition;						// The position to generate the acid-damage at.

	Asura_Volume*	m_pxVolume;							// The volume over which the acid-damage will take effect.

	VictimTree		m_xVictimTree;						// Tree containing the individual victim data.


	// Static variables...
	static AcidDamageList	s_xList;	// Static list of all acid-damage server-entities.


	// Private functions...
	AVP_ServerEntity_AcidDamage(void);
	AVP_ServerEntity_AcidDamage(const AVP_ServerEntity_AcidDamage& xOther);

	AVP_ServerEntity_AcidDamage&	operator=(const AVP_ServerEntity_AcidDamage& xOther);

};   // End of class 'AVP_ServerEntity_AcidDamage'.


#endif   // ifndef __AVP_SERVERENTITY_ACIDDAMAGE_H__


/// End of file. ///
