#ifndef MAPUNIT_H
#define MAPUNIT_H

#include <stdint.h>

//stores creatures on the map and their properties.
//This can be used for player and enemy units.
#include <string>
#include "../graphics/AnimatedState.h"
using namespace std;

class MapUnit {
 public:
  MapUnit ();
  ~MapUnit ();

  void clear ();
  void setMapPosition (uint16_t posX, uint16_t posY);
  uint16_t getMapPositionX ();
  uint16_t getMapPositionY ();
  void moveToDestination (uint16_t destX, uint16_t destY, uint32_t startTime);
  void mapAction (uint32_t currentTime);
  void stopMoving (uint32_t currentTime);

  uint8_t backpedalHitRectangle (int leftSide, int rightSide, int topSide, int bottomSide, uint32_t currentTime, bool lockAngle);
  void moveWithTime (uint32_t travelTime);
  void calculateMoveWithTime (uint16_t & posX, uint16_t & posY, uint32_t travelTime);

  bool operator==(const MapUnit &other) const;

  const string & getResourceName();
  void setResourceName(const string &);

  string & getModifiableResourceName ();

  AnimatedState & getAnimatedState ();
 private:
  uint16_t mapPositionX, mapPositionY;
  uint16_t mapDestinationX, mapDestinationY;
  uint16_t mapStartX, mapStartY;
  uint32_t mapMovingStartTime, mapMovingTravelTime;
  bool mapMoving;
  uint8_t mapMovingAngle;
  uint8_t mapMovingSpeed;
  string resourceName;
  AnimatedState as;
};

#endif
