fixed infinite submerging bug

This commit is contained in:
devZoGok
2022-09-17 10:14:29 +03:00
parent 11afaa32d3
commit c0aa67d5a9
3 changed files with 20 additions and 8 deletions
+12 -4
View File
@@ -247,14 +247,14 @@ namespace battleship{
for(int j = 0; j < map->getNumWaterBodies(); j++){
WaterBody w = map->getWaterBody(j);
if(w.isPointWithin(u->getPos()) && w.isPointWithin(targets[i].pos)){
targets[i].pos.y = -map->getBottom() + depth * fabs(w.pos.y - map->getBottom());
if(w.isPointWithin(u->getPos()) && w.isPointWithin(o.targets[i].pos)){
o.targets[i].pos.y = -map->getBottom() + depth * (w.pos.y - (-map->getBottom()));
break;
}
}
}
lineRenderer->addLine(u->getPos(), targets[i].pos, color);
lineRenderer->addLine(u->getPos(), o.targets[i].pos, color);
vector<LineRenderer::Line> lines = lineRenderer->getLines();
o.line = lines[lines.size() - 1];
@@ -375,9 +375,17 @@ namespace battleship{
issueOrder(Order::TYPE::PATROL, shiftPressed);
break;
case Bind::LAUNCH:
case Bind::LAUNCH:{
if(isPressed){
Map *map = Map::getSingleton();
Node *node = map->getNodeParent()->getChild(1);
bool visible = node->isVisible();
node->setVisible(!visible);
}
selectingGuidedMissileTarget = isPressed;
break;
}
case Bind::GROUP_0:
case Bind::GROUP_1:
case Bind::GROUP_2:
+1 -1
View File
@@ -48,7 +48,7 @@ namespace battleship{
std::vector<WaterBody> waterBodies;
//TODO replace hardcoded values
vb01::Vector3 size = vb01::Vector3(100, 20, 100);
float bottom = 14;
float bottom = 13;
Map(){}
void loadSkybox(gameBase::LuaManager*);
+7 -3
View File
@@ -167,7 +167,7 @@ namespace battleship{
}
else{
if(pos.getDistanceFrom(linDest) > destOffset){
float dist = pos.getDistanceFrom(pathPoints[0]);
float dist = pos.getDistanceFrom(linDest);
float movementAmmount = (speed > dist ? dist : speed);
advance(movementAmmount);
}
@@ -175,8 +175,12 @@ namespace battleship{
pathPoints.erase(pathPoints.begin());
if(fabs(pos.y - pathPoints[0].y) > destOffset){
float dist = pos.getDistanceFrom(pathPoints[0]);
float movementAmmount = -(speed > dist ? dist : speed);
float dist = pos.y - pathPoints[0].y;
float movementAmmount = (speed > fabs(dist) ? dist : speed);
if(dist > 0)
movementAmmount *= -1;
advance(movementAmmount, MoveDir::UP);
}
}