//
//  CollisionBody.h
//  PixelKit
//
//  Copyright (c) 2014 César Parent. All rights reserved.
//
#ifndef _COLLISIONBODY_H
#define _COLLISIONBODY_H

#include "includes.h"
#include "Point.h"

namespace PixelKit
{
	class Node;
	
	/*!
	 * @class PixelKit::CollisionBody
	 * @brief CollisionBody is used to represent the physical equivalent of a
	 * node. If a node must be notified of collisions, a CollisionBody is
	 * assigned to it.
	 */
	class CollisionBody : public SDL_Rect 
	{
	public:
		/*!
		 * @brief CollisionBody default constructor.
		 */
		CollisionBody(int x = 0, int y = 0, int w = 0, int h = 0);
		
		/*!
		 * @brief CollisionBody's destructor.
		 */
		~CollisionBody();
		
		/*!
		 * @brief Bitmask of the collision category CollisionBody belongs to.
		 */
		uint32_t categoryBitmask;
		
		/*!
		 * @brief Bitmask of the collision categories CollisionBody should
		 * collide with.
		 */
		uint32_t collisionBitmask;
		
		/*!
		 * @brief Move CollisionBody to its node's new position.
		 * @param x CollisionBody's Node's new X position
		 * @param y CollisionBody's Node's new X position
		 */
		void move(int x, int y);
		
		/*!
		 * @brief Check if CollisonBody interesects with another body
		 * @param body the body to check interesection with
		 * @return true if the two bodies intersect, false otherwise
		 */
		bool intersect(CollisionBody body);
		
		/*!
		 * @brief Set CollisionBody's horizontal scale factor
		 */
		void setXScale(float scale);
		
		/*!
		 * @brief Set CollisionBody's vertical scale factor
		 */
		void setYScale(float scale);
		
	private:
		Point<int> _offset;
		Point<int> _unscaledSize;
		Point<float> _scale;
		
	};
}

#endif