#include "regularGun.h"
#include "../entity/bullet.hpp"

#include "../world.hpp"

namespace game::equipment {

RegularGun::RegularGun() noexcept: Weapon(0.2, 10, 25)
{
    this->isAutoShoot = true;
};

void RegularGun::Update() noexcept
{
    if (!this->isAutoShoot) {
        this->reloadTime = 0;
    }

    Weapon::Update();

    this->isAutoShoot = false;
}

void RegularGun::Shoot(const vec2f &position, bool direction, World *world, bool forced) noexcept
{
    this->isAutoShoot = true;

    if (this->reloadTime > 0) {
        return;
    }

    float damage = this->damage;

    if (forced) {
        damage *= 2;
    }

    this->reloadTime = this->cooldown;

    if (direction) {
        new entity::Bullet(world, position, this->bulletSpeed, 180, damage);
    } else {
        new entity::Bullet(world, position, this->bulletSpeed, 0, damage);
    }
}


}
