
///////////////////////////////////////////////////////////////////////////////
//
// File   : Asura_ServerEntity_Affector.h
// Author : Andy Tate
// Date   : 6-Dec-2006
//
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

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

#ifndef __ASURA_SERVERENTITY_AFFECTOR_H__
#define __ASURA_SERVERENTITY_AFFECTOR_H__

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

#include "Entity/Asura_Entity.h"

#if defined(ASURA_USE_AFFECTORS)

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

class Asura_Affector;

#if defined(ASURA_TOOLS)
class Tools_EntityTemplateInstance;
#endif	//defined(ASURA_TOOLS)


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

////////////////////////////////////////////////////////////////////////////////
// Class        : Asura_ServerEntity_Affector
// Author       : Andy Tate
// Date         : 6-Dec-2006
//
// Description  : Class to handle the server-side control of a single Affector.
////////////////////////////////////////////////////////////////////////////////

class Asura_ServerEntity_Affector : public Asura_Entity_Server
{
public:

	// override of HasClientEntities() - we don't have any.
	virtual bool HasClientEntities() const { return false; }

	// Public functions...
	static void	Create	(const Asura_Guid uGuid);
	static void	Create	(const Asura_Guid uGuid, Asura_Chunk_Stream& xStream);

	// Chunking functions...
	virtual	bool	IsFilledFromChunkBuffer		(void) const	{ return(false); }
	virtual bool	CanBeSavedToChunk			(void) const	{ return(true); }

//	virtual	int		GetChunkBufferSize			(void);
//	virtual	void	FillInChunkBuffer			(char*& pcChunkBuffer);
//	virtual	void	InitialiseFromChunkBuffer	(const char*& pcChunkBuffer);

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

#if defined(ASURA_TOOLS)
	virtual void	ApplyChangesForTemplateInstance(Tools_EntityTemplateInstance* pxInstance);
	virtual bool	CanBeIncludedInTemplate(void) const	{ return(true); }
#endif	//defined(ASURA_TOOLS)

	// Accessor functions...
	Asura_Affector*			GetAffector	(void);
	const Asura_Affector*	GetAffector	(void) const;

	// Static list functions...
	static Asura_ServerEntity_Affector*							FindEntity	(const Asura_Guid uGuid)	{ return(s_xList.FindEntity(uGuid)); }
	static Asura_Classified_List<Asura_ServerEntity_Affector>*	GetList		(void)						{ return(&s_xList); }

	static const u_int	uAFFECTOR_CHUNK_VERSION	= 2;

protected:
	// Protected variables...
	Asura_Handle	m_iAffectorHandle;		// The handle of the affector to use.

	// Protected functions...
	Asura_ServerEntity_Affector          (const Asura_Guid uGuid);
	virtual ~Asura_ServerEntity_Affector ();
	virtual	void OnEntityActivate();
	virtual	void OnEntityDeactivate();

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


private:
	// Private typedefs...
	typedef Asura_Entity_Server PARENT;

	// Private variables...
	static Asura_Classified_List<Asura_ServerEntity_Affector>	s_xList;

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

	Asura_ServerEntity_Affector&	operator=	(const Asura_ServerEntity_Affector& xOther);

};   // End of class 'Asura_ServerEntity_Affector'.

#endif	//defined(ASURA_USE_AFFECTORS)


#endif   // ifndef __ASURA_SERVERENTITY_AFFECTOR_H__


/// End of file. ///
