mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
fixed ability to fire cruise missiles
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ namespace battleship{
|
||||
using namespace std;
|
||||
using namespace vb01;
|
||||
|
||||
CruiseMissile::CruiseMissile(Unit *unit, Vector3 tp, Vector3 pos, Quaternion rot) : Projectile(unit, 0, pos, rot), targetPoint(tp), flightStage(FlightStage::ASCENT){
|
||||
CruiseMissile::CruiseMissile(Unit *unit, int id, Vector3 tp, Vector3 pos, Quaternion rot) : Projectile(unit, id, pos, rot), targetPoint(tp), flightStage(FlightStage::ASCENT){
|
||||
Vector3 unitDir = unit->getDirVec();
|
||||
Vector3 leftDir = unit->getLeftVec();
|
||||
Vector3 targDir = (Vector3(targetPoint.x, pos.y, targetPoint.z) - pos).norm();
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
namespace battleship{
|
||||
class CruiseMissile : public Projectile{
|
||||
public:
|
||||
CruiseMissile(Unit*, vb01::Vector3, vb01::Vector3, vb01::Quaternion);
|
||||
CruiseMissile(Unit*, int, vb01::Vector3, vb01::Vector3, vb01::Quaternion);
|
||||
void update();
|
||||
private:
|
||||
enum class FlightStage{ASCENT, CRUISE, DESCENT};
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace battleship{
|
||||
case ProjectileClass::SHELL:
|
||||
return new Shell(unit, id, pos, rot);
|
||||
case ProjectileClass::CRUISE_MISSILE:
|
||||
return new CruiseMissile(unit, targetPos, pos, rot);
|
||||
return new CruiseMissile(unit, id, targetPos, pos, rot);
|
||||
case ProjectileClass::MISSILE:
|
||||
return new Missile(unit, id, targetPos, pos, rot);
|
||||
default:
|
||||
|
||||
@@ -566,15 +566,7 @@ namespace battleship{
|
||||
}
|
||||
|
||||
void Unit::launch(Order order){
|
||||
for(Weapon *weapon : weapons){
|
||||
Vector3 targPos = Vector3(order.targets[0].pos.x, pos.y, order.targets[0].pos.z);
|
||||
|
||||
if(weapon->getProjectileId() == 0 && weapon->getMinRange() < targPos.getDistanceFrom(pos)){
|
||||
weapon->fire(order);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
getWeaponsByOrder(Order::TYPE::LAUNCH)[0]->fire(order);
|
||||
removeOrder(0);
|
||||
}
|
||||
|
||||
@@ -796,7 +788,7 @@ namespace battleship{
|
||||
if(w->getOrderType() == type)
|
||||
weaps.push_back(w);
|
||||
|
||||
return weapons;
|
||||
return weaps;
|
||||
}
|
||||
|
||||
void Unit::receiveOrder(Order order, bool add) {
|
||||
|
||||
Reference in New Issue
Block a user