// This file is part of ThriceBall.
//
// Author: Kai Hillenbrand (AnTeevY)
// © Copyright, 2009 by Kai Hillenbrand, http://www.anteevy.de

// --------------------------------------------------

#pragma once
#ifndef LEVEL_H
#define LEVEL_H

// extern includes
#include "tinyxml/tinyxml.h"

// intern includes
#include "renderer.h"
#include "objects/checkpoint.h"
#include "objects/platform.h"
#include "objects/gate.h"
#include "objects/jumppad.h"
#include "objects/drainer.h"
#include "objects/info.h"

// --------------------------------------------------

class CRenderer;
class CPlayer;
class CPlatform;
class CCheckpoint;
class CFrameListener;

class CLevel : public NxOgre::Callback
{
public:
	CLevel(CRenderer *renderer, NxOgre::Scene *scene, OGRE3DRenderSystem *rendersys);

	void restart();					// if player presses the restart key, restart level
	void nextCheckpoint();			// debug function, move ball to next checkpoint
	void loadLevel(String name);	// loads the level mesh, creates the sky and loads the content
	void movePlatforms();			// moves the moving platforms
	void onVolumeEvent(NxOgre::Volume* volume, NxOgre::Shape* volumeShape, NxOgre::RigidBody* rigidBody, 
		NxOgre::Shape* rigidBodyShape, unsigned int collisionEvent);	// event when falling

	// set functions
	void setCurCheckpoint(CCheckpoint *chkpnt){m_pCurCheckpoint = chkpnt;}

private:
	void loadLevelMesh();	// loads the visible and physical level mesh 
	void createSky();		// creates the environment
	void loadContent(bool actorsOnly);		// loads content

	// OGRE variables
	NxOgre::Scene *m_pScene;
	SceneManager *m_pSceneMgr;
	OGRE3DRenderSystem *m_pRenderSystem;
	NxOgre::Volume *m_pDeathVolume;
	NxOgre::Vec3 m_vStartPos;
	std::vector<OGRE3DBody*> m_vpActorList;
	
	// pointers to instances
	CRenderer *m_pRenderer;	
	CPlayer *m_pPlayer;
	std::vector<CPlatform*> m_vpPlatformList;		// vector of pointers to all moving platforms
	std::vector<CCheckpoint*> m_vpCheckpointList;	// vector of pointers to all checkpoints except finish
	CCheckpoint *m_pCurCheckpoint;

	// general variables
	String m_sLevelName;				// name of the level
	String m_sBackgroundName;			// name of the environment
	int m_iBallStartNum;				// the ball type the player starts with	
};

#endif