//
//  Entity.h
//  GlobalGameJam15
//
//  Created by Cesar Parent on 24/01/2015.
//  Copyright (c) 2015 Cesar Parent. All rights reserved.
//

#ifndef __GlobalGameJam15__Entity__
#define __GlobalGameJam15__Entity__

#include <PixelKit/PixelKit.h>

using namespace PixelKit;

typedef enum
{
	kMotionUp,
	kMotionDown,
	kMotionLeft,
	kMotionRight,
	last
} EntityMotion;

class DungeonGame;

class Entity : public SpriteEmitter
{
public:
	Entity(std::string sprite);
	virtual ~Entity();
	
	virtual void move(EntityMotion direction);
	virtual void setTile(int x, int y);
	virtual Point<int> tile();
	virtual Point<int> targetTile();
	
	virtual void update(int timeInterval) override;
	
	virtual void didStartMotion(EntityMotion direction){};
	virtual void didFinishMotion(EntityMotion direction){};
	
	virtual Particle* emit(int timeInterval)
	{
		return nullptr;
	}
	
	virtual void setMoveController(DungeonGame* cont)
	{
		_moveController = cont;
	}
	
protected:
	
	static const Point<int> moves[4];
	
	Point<float> _targetPoint();
	
	Point<int> _tileLocation;
	Point<int> _targetMove;
	Point<int> _targetTile;
	bool _shouldMove;
	DungeonGame* _moveController;
};

#endif /* defined(__GlobalGameJam15__Entity__) */
