implemented weapons subsystem for units

This commit is contained in:
devZoGok
2024-01-20 15:50:35 +02:00
parent a956e754bf
commit e1dde2c90f
11 changed files with 167 additions and 123 deletions
+3 -3
View File
@@ -11,7 +11,7 @@ namespace battleship{
Unit *targUnit = order.targets[0].unit;
Vector3 targDir = (targUnit ? targUnit->getPos() : order.targets[0].pos) - pos;
if(targDir.getLength() > range){
if(targDir.getLength() > weapons[0]->getMaxRange()){
removeOrder(0);
return;
}
@@ -20,8 +20,8 @@ namespace battleship{
if(angleToTarg > .05)
rotateTurret(calculateRotation(targDir.norm(), angleToTarg, .1));
else if(canFire())
fire();
else
weapons[0]->fire(order);
Unit::attack(order);
}