#include "game/component.hpp" #include "game/entity.hpp" Entity* SpaceshipWeaponCmpt::ShootBullet(const Point& dir) { if (bulletAmount == 0) return nullptr; if (bulletAmount != InfBullet) { bulletAmount --; } Entity* bullet = CreateBullet(owner->Get()->groupIdx, damage, owner, maxSpeed); bullet->Use()->speed = Normalize(dir) * shootSpeed; bullet->Use()->position = owner->Get()->position; return bullet; } Entity* SpaceshipWeaponCmpt::ShootMissile(const Point& dir, Entity* target) { if (bulletAmount == 0) return nullptr; if (bulletAmount != InfBullet) { bulletAmount --; } Entity* bullet = CreateMissile(owner->Get()->groupIdx, damage, owner, maxSpeed, target); if (target) { bullet->Use()->rotation = Degrees(std::acos(Dot(dir, Normalize(target->Get()->position - owner->Get()->position)))); } bullet->Use()->speed = Normalize(dir) * shootSpeed; bullet->Use()->position = owner->Get()->position; Sounds["missile"]->Play(); return bullet; }