#include "TargetHelperEntity.h"

#include "Engine/Engine.h"
#include "Engine/EntitySystem/EntitySystem.h"
#include "Engine/EntitySystem/Components/SpriteComponent.h"

void TargetHelperEntity::Init()
{
	/*m_pSpriteComponent = AddComponent<SpriteComponent>();
	sf::Texture* pBackgroundTexture = m_pBackground->SetSpriteByPath("../Assets/health_bg.png", true);

	const sf::Vector2u bgSize = pBackgroundTexture->getSize();
	const sf::Vector2u fillSize = pFillTexture->getSize();

	if (bgSize.x >= fillSize.x && bgSize.y >= fillSize.y)
	{
		sf::Vector2f diff = sf::Vector2f(static_cast<float>(bgSize.x - fillSize.x), static_cast<float>(bgSize.y - fillSize.y)) * 0.5f;

		m_pHealthFill->GetSprite().setOrigin(0.f, 0.f);
		m_pHealthFill->GetSprite().setPosition(sf::Vector2f(bgSize.x * -0.5f + diff.x, bgSize.y * -0.5f + diff.y));
		UpdateHealthColor();
	}
	else
	{
		std::cout << "Invalid healthbar texture setup! Background needs to be bigger than fill." << std::endl;
	}*/
}

void TargetHelperEntity::Update(float deltaSeconds)
{
	/*if (!m_pOwner)
		return;

	if (IDamageable* pDamageable = dynamic_cast<IDamageable*>(m_pOwner))
	{
		const float ratio = pDamageable->GetHealth() / pDamageable->GetMaxHealth();
		m_pHealthFill->GetSprite().setScale(sf::Vector2f(ratio, 1.f));
	}

	UpdateHealthColor();
	SetPosition(m_pOwner->GetPosition() + m_offset);*/
}

void TargetHelperEntity::SetOwnerEntity(Entity* pOwner)
{
	m_pOwner = pOwner;
}

void TargetHelperEntity::SetOffset(float offset)
{
	m_offset = offset;
}
