#include "enemyBullet.hpp"
#include "../world.hpp"

namespace game::entity {

EnemyBullet::EnemyBullet(World *world, const vec2f &position, const vec2f &enemyVelocity, float speed, float angle) :BasicBullet(world, position, speed, angle)
{
    this->Setup();

    this->velocity.x += enemyVelocity.x;
    this->body->SetLinearVelocity(this->velocity);
}

void EnemyBullet::Setup()
{
    b2CircleShape shape;
    shape.m_radius = 0.2;

    b2FixtureDef fixDef;
    fixDef.filter.categoryBits = TYPE_EBULLET;
    fixDef.filter.maskBits = TYPE_HERO | TYPE_WALL;
    fixDef.shape = &shape;
    fixDef.density = 1.0f;
    fixDef.userData = this;

    this->body->CreateFixture(&fixDef);
}

void EnemyBullet::Render() noexcept
{
    render::primitives2d::circle(this->position, vec2f{0.22, 0.22}, color::white, this->angle, 8);
    render::primitives2d::circle(this->position, vec2f{0.2, 0.2}, color::cyan, this->angle, 8);
    render::primitives2d::circle(this->position, vec2f{0.1, 0.1}, color::white, this->angle, 8);
}

}
