//
// Asura_MetaMusic_Zone.h
//
// Created by Richard Rice - 11/01/05
// 
// Copyright (C) 2005 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef __ASURA_METAMUSIC_ZONE_H__
#define __ASURA_METAMUSIC_ZONE_H__

#include "Core/Asura_Hash.h"
#include "Zone/Asura_Zone.h"

struct Asura_MetaMusic_Zone_Trigger
{
	void Initialise();
	bool IsUsed() const;

	int m_iNumNPCsToTrigger;
	float m_fMinimumTime;
	u_int m_uTriggerFlags;//uses flags from Asura_ServerEntity_MetaMusicTrigger
	Asura_Hash_ID m_uTrackID;
};

#define ASURA_METAMUSICZONE_FLAG_ACTIVE 0x00000001

class Asura_MetaMusic_Zone : public Asura_Zone
{
    friend class Tools_MetaMusicZone_Editor;

public:
    Asura_MetaMusic_Zone( const bool bCreatingFromChunkBuffer );

	virtual bool IsEnabled() const {return (m_uMetaMusicFlags & ASURA_METAMUSICZONE_FLAG_ACTIVE) != 0;}

	// loading/saving from/to a level

	virtual void ReadFromChunkStream(class Asura_Chunk_Stream& xStream);
#ifdef ASURA_TOOLS
	virtual void WriteToChunkStream(class Asura_Chunk_Stream& xStream);
#endif

	// loading/saving of in game state
	void ReadInGameDataFromChunkStream(class Asura_Chunk_Stream& xStream);
	void WriteInGameDataToChunkStream(class Asura_Chunk_Stream& xStream) const;

	//Trigger level is from 0 to 2. O is not triggered , and then 1 and 2 correspond
	//to the two entries in m_axTrigger array.
	int GetTriggerLevel(int iNumNPCs,int iPrevLevel,float fTimer) const;

	//iTriggerLevel should be 1 or 2
	void Trigger(int iTriggerLevel) const;

	void SetActive(bool bSet);


private:
	//two 'triggers' , so one can be used for tension ,and the other for action
	Asura_MetaMusic_Zone_Trigger m_axTrigger[2];

	u_int m_uMetaMusicFlags;

};



#endif //__ASURA_METAMUSIC_ZONE_H__
							   
