bool HitBox::IsCollision(Vector2 offset, HitBox *pHitBox, Vector2 hitBoxOffset, CollisionParameter *pParam) const
{
    bool isCollision = false;
    Vector2 overlapCompensation = Vector2(0, 0);

    if (pHitBox != NULL)
    {
        for (unsigned int i = 0; i < collidableObjectList.size(); i++)
        {
            CollidableObject *pCollidableObject1 = collidableObjectList[i];

            for (unsigned int j = 0; j < pHitBox->collidableObjectList.size(); j++)
            {
                CollidableObject *pCollidableObject2 = pHitBox->collidableObjectList[j];
                CollisionParameter tempParam;

                if (CollisionExists(pCollidableObject1, offset + overlapCompensation, pCollidableObject2, hitBoxOffset, &tempParam)
                    && fabs(tempParam.OverlapDistance) > 0.0001)
                {
                    for (unsigned int k = 0; k < tempParam.OverlapEntryList.size(); k++)
                    {
                        pParam->OverlapEntryList.push_back(tempParam.OverlapEntryList[k]);
                    }

                    overlapCompensation += tempParam.OverlapAxis * tempParam.OverlapDistance;
                    isCollision = true;
                }
            }
        }
    }

    pParam->OverlapDistance = overlapCompensation.Length();
    pParam->OverlapAxis = overlapCompensation.Normalize();
    return isCollision;
}
void CollisionSystem::CollisionGroup::CheckForCollisions() {
	for(int a = 0; entityGroup1->getCount() > a; a++) {
		artemis::Entity* entity1 = entityGroup1->get(a);
		if(entity1->getComponent<CollisionComponent>()->isCollidable) {
			for(int b = 0; entityGroup2->getCount() > b; b++) {
				artemis::Entity* entity2 = entityGroup2->get(b);
				if(entity2->getComponent<CollisionComponent>()->isCollidable &&
						CollisionExists(entity1, entity2)) {
					handler->HandleCollision(entity1, entity2);
				}
			}
		}
	}
}
bool HitBox::ContainsPoint(Vector2 offset, Vector2 point) const
{
    bool isCollision = false;
    Vector2 overlapCompensation = Vector2(0, 0);
    CollidableObject *pCollidableObjectForPoint = CollidableObject::CreateRectangle(Vector2(0, 0), Vector2(1, 1));

    for (unsigned int i = 0; i < collidableObjectList.size(); i++)
    {
        CollidableObject *pCollidableObject = collidableObjectList[i];
        CollisionParameter tempParam;

        if (CollisionExists(pCollidableObject, offset + overlapCompensation, pCollidableObjectForPoint, point, &tempParam)
            && fabs(tempParam.OverlapDistance) > 0.0001)
        {
            overlapCompensation += tempParam.OverlapAxis * tempParam.OverlapDistance;
            isCollision = true;
        }
    }

    delete pCollidableObjectForPoint;
    return isCollision;
}