#pragma once
#include "Drawable.h"
#include <cassert>
#include <typeinfo>

void Drawable::Draw(Graphics& gfx, Logger& logger) const noexcept
{
	/*for (auto& b : binds)
	{
		b->Bind(gfx, logger);
	}*/
	gfx.DrawIndexed(pIndexBuffer->GetCount());
};

void Drawable::ExecuteBind(Graphics& gfx, Logger& logger) noexcept
{
	for (auto& b : binds)
	{
		b->Bind(gfx, logger);
	}
	for (auto& b : GetStaticBinds())
	{
		b->Bind(gfx, logger);
	}
};

void Drawable::AddBind(std::unique_ptr<Bindable> bind) noexcept
{
	binds.push_back(std::move(bind));
}

void Drawable::AddIndexBuffer(std::unique_ptr<IndexBuffer> ibuf) noexcept
{
	assert("Attempting to add index buffer a second time" && pIndexBuffer == nullptr);
	pIndexBuffer = ibuf.get();
	binds.push_back(std::move(ibuf));
}