#ifndef _GAMEOBJECT_H_
#define _GAMEOBJECT_H_

#include "tnl.h"
#include "tnlNetBase.h"
#include "tnlGhostConnection.h"
#include "tnlNetInterface.h"
#include "tnlNetObject.h"
#include "tnlLog.h"
#include "tnlRPC.h"
#include "tnlString.h"
#include "tnlTypes.h"

#include "Position.h"

namespace DinastyOnline {
	namespace Network {
		class GameWorld;
	
		enum GameObjectType {
			UnknownType       = BIT(0),
			PlayerType          = BIT(1),
			BuildingType       = BIT(2),
			MarketType      = BIT(3),
			
			DeletedType       = BIT(31),
			//DamagableTypes    = PlayerType | BuildingType,
			AllObjectTypes    = 0xFFFFFFFF,
		};
	
		class GameObject : public TNL::NetObject {
			typedef TNL::NetObject Parent;
	
		protected:
			Position position;        ///< Position at which to render the player - computed during update().
			GameWorld *world;            ///< The game object this player is associated with
			TNL::U32 mObjectTypeMask;
			
		public:
			/// Player constructor
			GameObject();
	
			/// Player destructor removes the player from the game.
			~GameObject();
			
			virtual void idle(TNL::F32 timeDelta) = 0;
			
			Position getPosition() { return position; };
			
			TNL::U32 getObjectTypeMask() { return mObjectTypeMask; }
			
			/// onGhostAdd is called for every NetObject on the client after the ghost has
			/// been constructed and its initial unpackUpdate is called.  A return value of
			/// false from this function would indicate than an error had occured, notifying the
			/// network system that the connection should be terminated.
			virtual bool onGhostAdd(TNL::GhostConnection *theConnection);
	
			/// Adds this Player to the list of Player instances in the specified game.
			virtual void addToWorld(GameWorld *theWorld);
			
			void setScopeAlways();
	
		};
	}
}
#endif
