all building in a paint-select row are now built

This commit is contained in:
devZoGok
2025-06-22 19:17:57 +03:00
parent 145e8b9c29
commit f2b386e5a2
2 changed files with 9 additions and 8 deletions
+8 -7
View File
@@ -722,16 +722,17 @@ namespace battleship{
if(orderPossible) issueOrder(Order::TYPE::HACK, vector<Order::Target>{Order::Target((Unit*)gameObjHoveredOn)}, shiftPressed);
}
else if((selectedUnits[0]->getUnitClass() == UnitClass::ENGINEER || selectedUnits[0]->getUnitClass() == UnitClass::FREEZER) && ufCtr->isPlacingOnSurface()){
castRayToTerrain();
GameObjectFrame gmObjFr = ufCtr->getGameObjectFrame(0);
targets.clear();
if(gmObjFr.status == GameObjectFrame::NOT_PLACEABLE) return;
for(int i = 0; i < ufCtr->getNumGameObjectFrames(); i++){
GameObjectFrame gmObjFr = ufCtr->getGameObjectFrame(i);
Unit *buildStruct = GameObjectFactory::createUnit(mainPlayer, gmObjFr.getId(), gmObjFr.getPos(), gmObjFr.getRot());
mainPlayer->addUnit(buildStruct);
targets[0].unit = buildStruct;
if(gmObjFr.status == GameObjectFrame::NOT_PLACEABLE) continue;
issueOrder(Order::TYPE::BUILD, targets, shiftPressed);
Unit *buildStruct = GameObjectFactory::createUnit(mainPlayer, gmObjFr.getId(), gmObjFr.getPos(), gmObjFr.getRot());
issueOrder(Order::TYPE::BUILD, vector<Order::Target>{Order::Target(buildStruct, gmObjFr.getPos())}, shiftPressed);
mainPlayer->addUnit(buildStruct);
}
buildableStructSelected = false;
}
+1 -1
View File
@@ -40,7 +40,7 @@ namespace battleship{
float hypothenuse = sqrt(width * width + length * length);
int numStructsInRow = int(lenRow / hypothenuse);
while(gameObjectFrames.size() > numStructsInRow)
while(gameObjectFrames.size() > numStructsInRow && gameObjectFrames.size() > 1)
removeGameObjectFrame(gameObjectFrames.size() - 1);
if(gameObjectFrames.size() < numStructsInRow){