
//
// Asura_EffectVolume_Camera_EntityData.h
//
// Created by Emil Popovic - 19/12/2008
// 
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __ASURA_EFFECTVOLUME_CAMERA_ENTITYDATA_H__
#define __ASURA_EFFECTVOLUME_CAMERA_ENTITYDATA_H__

#include "Core/Asura_Maths.h"
#include "ChunkSystem/Asura_Chunk_Stream.h"

class Asura_EffectVolume_EntityParameters;

class Asura_EffectVolume_Camera_EntityData
{
public:

	void		Update( const Asura_Vector_3& xPosition );
	void		ReduceCurrentStrength( float fReduceStrength )	{ m_fCurrentStrength-=fReduceStrength; {if( m_fCurrentStrength<0.0f )	m_fCurrentStrength = 0.0f;} }
	float		GetCurrentStrength()		{return m_fCurrentStrength;}

	void		SetGuid( Asura_Guid	uGuid )	{ m_uGuid = uGuid; }
	Asura_Guid	GetGuid()					{ return m_uGuid;  }

	void		SetPriority( u_int uPriority )	{m_uPriority = uPriority;}

	bool		ReadFromChunkStream(Asura_Chunk_Stream& xStream);
	void		WriteToChunkStream	(Asura_Chunk_Stream& xStream) const;

	bool		IsKeepingAlive()	{return m_bKeepAlive;}

	// Use this function to order EntityData according to it's priority. So we can process object from lower priority to higher priority
	static int  CompareEntityDataPriority( Asura_EffectVolume_Camera_EntityData* const & pxLED, Asura_EffectVolume_Camera_EntityData* const & pxRED )	{ return pxLED->m_uPriority - pxRED->m_uPriority; }

	Asura_EffectVolume_Camera_EntityData();
	virtual ~Asura_EffectVolume_Camera_EntityData();

protected:

	void		UpdateCurrentStrength( bool bIsWithinVolume, bool bIsWithinTransitionVolume, const Asura_EffectVolume_EntityParameters* xData, const Asura_Vector_3& xPosition );

private:

	Asura_Guid	m_uGuid;
	u_int		m_uPriority;			// current priority of this object. This is actually a mirror of value from ClientEntity_VolumeEffect object. However, I need to have it here, because I will extensively use this value to order list of objects. And it will be very slow to each time find client entity and read the value from it.
	float		m_fCurrentStrength;
	bool		m_bKeepAlive;			// At the beginning the flag is true. Once the flag will become false, object is ready to be destroyed. (It is outside volume.)

	static const u_int s_uChunkVersion;	// The version used when reading/writing.
};


#endif //__ASURA_EFFECTVOLUME_CAMERA_ENTITYDATA_H__