| 384 | } |
| 385 | |
| 386 | static void DoCurrent(ItemInfo* UPVItem, ItemInfo* laraItem) |
| 387 | { |
| 388 | auto* lara = GetLaraInfo(laraItem); |
| 389 | |
| 390 | Vector3i target; |
| 391 | |
| 392 | if (!lara->Context.WaterCurrentActive) |
| 393 | { |
| 394 | int absVel = abs(lara->Context.WaterCurrentPull.x); |
| 395 | int shift; |
| 396 | if (absVel > 16) |
| 397 | shift = 4; |
| 398 | else if (absVel > 8) |
| 399 | shift = 3; |
| 400 | else |
| 401 | shift = 2; |
| 402 | |
| 403 | lara->Context.WaterCurrentPull.x -= lara->Context.WaterCurrentPull.x >> shift; |
| 404 | |
| 405 | if (abs(lara->Context.WaterCurrentPull.x) < 4) |
| 406 | lara->Context.WaterCurrentPull.x = 0; |
| 407 | |
| 408 | absVel = abs(lara->Context.WaterCurrentPull.z); |
| 409 | if (absVel > 16) |
| 410 | shift = 4; |
| 411 | else if (absVel > 8) |
| 412 | shift = 3; |
| 413 | else |
| 414 | shift = 2; |
| 415 | |
| 416 | lara->Context.WaterCurrentPull.z -= lara->Context.WaterCurrentPull.z >> shift; |
| 417 | if (abs(lara->Context.WaterCurrentPull.z) < 4) |
| 418 | lara->Context.WaterCurrentPull.z = 0; |
| 419 | |
| 420 | if (lara->Context.WaterCurrentPull.x == 0 && lara->Context.WaterCurrentPull.z == 0) |
| 421 | return; |
| 422 | } |
| 423 | else |
| 424 | { |
| 425 | int sinkVal = lara->Context.WaterCurrentActive - 1; |
| 426 | target = g_Level.Sinks[sinkVal].Position; |
| 427 | |
| 428 | int angle = ((Geometry::GetOrientToPoint(laraItem->Pose.Position.ToVector3(), target.ToVector3()).y) / 16) & 4095; |
| 429 | |
| 430 | int dx = target.x - laraItem->Pose.Position.x; |
| 431 | int dz = target.z - laraItem->Pose.Position.z; |
| 432 | |
| 433 | int velocity = g_Level.Sinks[sinkVal].Strength; |
| 434 | dx = phd_sin(angle * 16) * velocity * BLOCK(1); |
| 435 | dz = phd_cos(angle * 16) * velocity * BLOCK(1); |
| 436 | |
| 437 | lara->Context.WaterCurrentPull.x += ((dx - lara->Context.WaterCurrentPull.x) / 16); |
| 438 | lara->Context.WaterCurrentPull.z += ((dz - lara->Context.WaterCurrentPull.z) / 16); |
| 439 | } |
| 440 | |
| 441 | lara->Context.WaterCurrentActive = 0; |
| 442 | UPVItem->Pose.Position.x += lara->Context.WaterCurrentPull.x / CLICK(1); |
| 443 | UPVItem->Pose.Position.z += lara->Context.WaterCurrentPull.z / CLICK(1); |
no test coverage detected