subs can only fire missiles when reemerged

This commit is contained in:
devZoGok
2025-06-01 10:12:47 +03:00
parent 692c917296
commit 90a11b6f58
6 changed files with 48 additions and 2 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ set(CONTROLLERS gameObjectFrameController.cpp cameraController.cpp)
set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp addTechnologyCommand.cpp toggleDebugCommand.cpp)
set(CORE gameManager.cpp game.cpp fxManager.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS})
set(PROJECTILES projectile.cpp missile.cpp cruiseMissile.cpp shell.cpp)
set(VEHICLES vehicle.cpp engineer.cpp resourceRover.cpp)
set(VEHICLES vehicle.cpp submarine.cpp engineer.cpp resourceRover.cpp)
set(STRUCTURES structure.cpp factory.cpp pointDefense.cpp extractor.cpp researchStruct.cpp)
set(UNITS gameObjectFactory.cpp unit.cpp ${STRUCTURES} ${VEHICLES})
set(CONTENT player.cpp trader.cpp pathfinder.cpp map.cpp gameObject.cpp gameObjectFrame.h resourceDeposit.cpp ${UNITS} ${PROJECTILES})
+3
View File
@@ -2,6 +2,7 @@
#include "player.h"
#include "factory.h"
#include "engineer.h"
#include "submarine.h"
#include "resourceRover.h"
#include "projectile.h"
#include "resourceDeposit.h"
@@ -44,6 +45,8 @@ namespace battleship{
return new Engineer(player, id, pos, rot, Unit::State::STAND_GROUND);
case UnitClass::RESOURCE_ROVER:
return new ResourceRover(player, id, pos, rot, Unit::State::STAND_GROUND);
case UnitClass::SUBMARINE:
return new Submarine(player, id, pos, rot, Unit::State::STAND_GROUND);
default:
return new Vehicle(player, id, pos, rot, Unit::State::STAND_GROUND);
}
+27
View File
@@ -0,0 +1,27 @@
#include "submarine.h"
#include "map.h"
#include <quad.h>
namespace battleship{
using namespace vb01;
using namespace std;
Submarine::Submarine(Player *player, int id, Vector3 pos, Quaternion rot, Unit::State state) : Vehicle(player, id, pos, rot, state){}
bool Submarine::validateLaunchOrder(){
if(!Unit::validateLaunchOrder()) return false;
vector<Node*> terrainNodes = Map::getSingleton()->getNodeParent()->getChildren();
for(int i = 1; i < terrainNodes.size(); i++){
Vector3 wbPos = terrainNodes[i]->getPosition();
Vector3 size = ((Quad*)terrainNodes[i]->getMesh(0))->getSize();
if(fabs(wbPos.x - pos.x) < .5 * size.x && fabs(wbPos.z - pos.z) < .5 * size.y && pos.y - wbPos.y > -.1)
return true;
}
return false;
}
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef SUBMARINE_H
#define SUBMARINE_H
#include "vehicle.h"
namespace battleship{
class Submarine : public Vehicle{
public:
Submarine(Player*, int, vb01::Vector3, vb01::Quaternion, Unit::State);
private:
bool validateLaunchOrder();
};
}
#endif
+1 -1
View File
@@ -769,7 +769,7 @@ namespace battleship{
case Order::TYPE::EJECT:
return !garrisonSlots.empty();
case Order::TYPE::LAUNCH:
return !getWeaponsByOrder(Order::TYPE::LAUNCH).empty();
return validateLaunchOrder();
case Order::TYPE::SUPPLY:
case Order::TYPE::LOAD:
case Order::TYPE::UNLOAD:
+1
View File
@@ -198,6 +198,7 @@ namespace battleship{
std::vector<Player*> getSelectingPlayers();
void removeOrder(int);
virtual bool validateLaunchOrder(){return !getWeaponsByOrder(Order::TYPE::LAUNCH).empty();}
virtual bool validateGarrisonOrder(Order){return false;}
virtual void targetUnitsAutomatically();
virtual void reinit();