//
// Asura_ServerEntity_FMVTrigger.h
//
// Created by Richard Rice - 12/6/2003
// 
// Copyright (C) 2003 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef __ASURA_SERVERENTITY_FMVTRIGGER_H__
#define __ASURA_SERVERENTITY_FMVTRIGGER_H__

#include "Core/Asura_String.h"
#include "Entity/Triggers/Asura_ServerEntity_Trigger.h"
#ifdef ASURA_TOOLS
#include "Entity/Asura_Entity_Classification.h"
#endif

//FMV trigger plays an FMV then sends the messages associated with OnTrigger
//Currently only really works when server and client are on the same machine.
//(But since we just need to get this working for PS2 at the moment , this isn't an issue)
class Asura_ServerEntity_FMVTrigger : public Asura_ServerEntity_Trigger
{
	public:
		Asura_ServerEntity_FMVTrigger();
		Asura_ServerEntity_FMVTrigger(Asura_Guid uGuid);
		Asura_ServerEntity_FMVTrigger(Asura_Guid uGuid,const char*& pcChunkBuffer);		//constructor from load

		static void CreateFromChunkBuffer(Asura_Guid uGuid, const char*& pcChunkBuffer);

	protected :	


		virtual void OnTrigger();
		virtual bool IsTriggered(){return false;}//Gets triggered when it recieves a trigger message instead
		virtual void Update();			// Added to implement the "Play on Start" functionality

		Asura_String m_xFMVName;
		union
		{
			unsigned int m_uFlags;
			struct
			{
				unsigned int m_bPC:1;
				unsigned int m_bPS2:1;
				unsigned int m_bXBox:1;
				unsigned int m_bGC:1;
				unsigned int m_bPSP:1;
				unsigned int m_bPS3:1;
				unsigned int m_bXBox360:1;
				unsigned int m_bWii:1;
				unsigned int m_bPlayAtStart:1;			// Does the FMV play when the level starts up?
				unsigned int m_bHasBeenTriggered:1;		// Has the level startup FMV played? This stops it being played again when loading from a checkpoint
			};
		};

		//virtual function overides for saving
		int GetChunkBufferSize();
		void FillInChunkBuffer(char*& chunkBuffer);

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

		#ifdef ASURA_TOOLS
		virtual bool CanBeIncludedInTemplate() const {return Classification == AsuraEntityClass_FMVTrigger;}
		#endif


		friend class Tools_Entity_FMVTrigger_Object;

    private:
        
        void PlatformProject_PlayFMV( void ) const;
};

#ifdef ASURA_TOOLS //defines for accessing bitfield elements in the tickboxes
#define ASURA_FMVTRIGGER_FLAG_PC 				0x00000001
#define ASURA_FMVTRIGGER_FLAG_PS2				0x00000002
#define ASURA_FMVTRIGGER_FLAG_XBOX 				0x00000004
#define ASURA_FMVTRIGGER_FLAG_GC 				0x00000008
#define ASURA_FMVTRIGGER_FLAG_PSP				0x00000010
#define ASURA_FMVTRIGGER_FLAG_PS3				0x00000020
#define ASURA_FMVTRIGGER_FLAG_XBOX360			0x00000040
#define ASURA_FMVTRIGGER_FLAG_WII				0x00000080
#define ASURA_FMVTRIGGER_FLAG_PLAY_AT_START		0x00000100
//#define ASURA_FMVTRIGGER_FLAD_START_FMV_PLAYED	0x00000200			// This is not used as a tick box but m_bHasBeenTriggered is in m_uFlags so
																		// This bitfield can't be used by something else
#endif




#endif //__ASURA_SERVERENTITY_FMVTRIGGER_H__
