/*
    Copyright (C) 2004  Erik Hjortsberg

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef WORLDDIMEENTITY_H
#define WORLDDIMEENTITY_H


namespace EmberOgre {

namespace Environment {
class Environment;
class Foliage;
}

class EmberEntity;
class TerrainGenerator;

class WorldEmberEntity : public EmberEntity {
public:


	WorldEmberEntity(const std::string& id, Eris::TypeInfo* ty, Eris::View* vw, Ogre::SceneManager* sceneManager, TerrainGenerator* terrainGenerator);
	virtual ~WorldEmberEntity();

	virtual void adjustPositionForContainedNode(EmberEntity* const entity, const Ogre::Vector3& position);

protected:
	virtual const Ogre::Vector3& getOffsetForContainedNode(const Ogre::Vector3& position, EmberEntity* const entity);
	TerrainGenerator* mTerrainGenerator;
	
    virtual void init(const Atlas::Objects::Entity::RootEntity &ge, bool fromCreateOp);

	virtual void onMoved();
	
	virtual void onAttrChanged(const std::string& str, const Atlas::Message::Element& v);
	
// 	virtual void onTalk(const Atlas::Objects::Operation::RootOperation& talk);
//	virtual void setContainer(Entity *pr);
	virtual void onVisibilityChanged(bool vis);
	virtual void onLocationChanged(Eris::Entity *oldLocation);

	void addArea(TerrainArea* area);
	
	/**
	 *    Extracts terrain updates from the element and updates the terrain.
	 * @param v 
	 */
	void updateTerrain(const Atlas::Message::Element& terrain);
	
		
	Environment::Foliage* mFoliage;
	
	Environment::Environment* mEnvironment;
};

}

#endif // WORLDDIMEENTITY_H
