| 669 | } |
| 670 | |
| 671 | void EnvironmentController::SpawnMeteorParticles(const ScriptInterfaceLevel& level) |
| 672 | { |
| 673 | // Clean up dead particles. |
| 674 | if (!Meteors.empty()) |
| 675 | { |
| 676 | Meteors.erase( |
| 677 | std::remove_if( |
| 678 | Meteors.begin(), Meteors.end(), |
| 679 | [](const MeteorParticle& part) |
| 680 | { |
| 681 | return !part.Active; |
| 682 | }), |
| 683 | Meteors.end()); |
| 684 | } |
| 685 | |
| 686 | if (level.GetStarfieldMeteorCount() == 0) |
| 687 | return; |
| 688 | |
| 689 | int density = level.GetStarfieldMeteorSpawnDensity(); |
| 690 | if (density > 0) |
| 691 | { |
| 692 | int newParticlesCount = 0; |
| 693 | |
| 694 | while (Meteors.size() < level.GetStarfieldMeteorCount()) |
| 695 | { |
| 696 | if (newParticlesCount > density) |
| 697 | break; |
| 698 | |
| 699 | auto horizontalDir = Random::GenerateDirection2D(); |
| 700 | |
| 701 | auto part = MeteorParticle(); |
| 702 | |
| 703 | part.Active = true; |
| 704 | part.Life = METEOR_PARTICLE_LIFE_MAX; |
| 705 | part.StartPosition = |
| 706 | part.Position = Random::GenerateDirectionInCone(-Vector3::UnitY, 40.0f) * BLOCK(1.5f); |
| 707 | part.Fade = 0.0f; |
| 708 | part.Color = Vector3( |
| 709 | Random::GenerateFloat(0.6f, 1.0f), |
| 710 | Random::GenerateFloat(0.6f, 1.0f), |
| 711 | Random::GenerateFloat(0.6f, 1.0f)); |
| 712 | |
| 713 | part.Direction = Random::GenerateDirectionInCone(Vector3(horizontalDir.x, 0, horizontalDir.y), 10.0f); |
| 714 | if (part.Direction.y < 0.0f) |
| 715 | part.Direction.y = -part.Direction.y; |
| 716 | |
| 717 | Meteors.push_back(part); |
| 718 | |
| 719 | newParticlesCount++; |
| 720 | } |
| 721 | } |
| 722 | } |
| 723 | } |
nothing calls this directly
no test coverage detected