void Visuals::DrawDamageIndicator()
{
float CurrentTime = g_GlobalVars->curtime;
for (int i = 0; i < indicators.size(); i++) {
if (indicators[i].erase_time < CurrentTime) {
indicators.erase(indicators.begin() + i);
continue;
}
if (indicators[i].erase_time - 1.f < CurrentTime) {
indicators[i].col._CColor[3] = Utils::lerp(indicators[i].col._CColor[3], 0, 0.1f);
}
if (!indicators[i].initialized) {
indicators[i].position = indicators[i].player->GetHitboxPos(bone(indicators[i].hit_box));
if (!indicators[i].player->IsAlive()) {
indicators[i].position.z -= 39.f; //лично у меня из-за того что игрок умирает, весь его хитбокс прыгает вверх на 39.f
indicators[i].position.z += offset_if_kill;
} else {
indicators[i].position.z += offset_hit;
}
indicators[i].end_position = indicators[i].position + Vector(Utils::random(-range_offset_x, range_offset_x), Utils::random(-range_offset_x, range_offset_x), max_pos_y);
indicators[i].initialized = true;
}
if (indicators[i].initialized) {
indicators[i].position.z = Utils::lerp(indicators[i].position.z, indicators[i].end_position.z, speed);
indicators[i].position.x = Utils::lerp(indicators[i].position.x, indicators[i].end_position.x, speed);
indicators[i].position.y = Utils::lerp(indicators[i].position.y, indicators[i].end_position.y, speed);
indicators[i].last_update = CurrentTime;
}
Vector ScreenPosition;
if (Math::WorldToScreen(indicators[i].position, ScreenPosition)) {
Render::Get().RenderText("-" + std::to_string(indicators[i].damage), ScreenPosition.x, ScreenPosition.y, text_size, indicators[i].col, true);
}
}
}