| 30 | std::vector<Bubble> Bubbles = {}; |
| 31 | |
| 32 | void SpawnBubble(const Vector3& pos, int roomNumber, float size, float amplitude) |
| 33 | { |
| 34 | constexpr auto GRAVITY_MAX = 12.0f; |
| 35 | constexpr auto GRAVITY_MIN = GRAVITY_MAX * (2 / 3.0f); |
| 36 | constexpr auto WAVE_VELOCITY_MAX = 1 / 8.0f; |
| 37 | constexpr auto WAVE_VELOCITY_MIN = WAVE_VELOCITY_MAX / 2; |
| 38 | |
| 39 | if (!TestEnvironment(ENV_FLAG_WATER, roomNumber)) |
| 40 | return; |
| 41 | |
| 42 | auto& bubble = GetNewEffect(Bubbles, BUBBLE_COUNT_MAX); |
| 43 | |
| 44 | size = std::min(size, BUBBLE_SIZE_MAX); |
| 45 | |
| 46 | bubble.SpriteIndex = SPR_BUBBLES; |
| 47 | bubble.Position = |
| 48 | bubble.PositionBase = pos; |
| 49 | bubble.RoomNumber = roomNumber; |
| 50 | bubble.Color = BUBBLE_COLOR_WHITE; |
| 51 | |
| 52 | bubble.Size = |
| 53 | bubble.SizeMax = Vector2(size); |
| 54 | bubble.SizeMin = bubble.Size * 0.7f; |
| 55 | |
| 56 | bubble.Amplitude = Random::GenerateDirection() * amplitude; |
| 57 | bubble.WavePeriod = Vector3::Zero; |
| 58 | bubble.WaveVelocity = Vector3( |
| 59 | Random::GenerateFloat(WAVE_VELOCITY_MIN, WAVE_VELOCITY_MAX), |
| 60 | Random::GenerateFloat(WAVE_VELOCITY_MIN, WAVE_VELOCITY_MAX), |
| 61 | Random::GenerateFloat(WAVE_VELOCITY_MIN, WAVE_VELOCITY_MAX)); |
| 62 | |
| 63 | bubble.Life = std::round(BUBBLE_LIFE_MAX * FPS); |
| 64 | bubble.OpacityStart = Random::GenerateFloat(BUBBLE_OPACTY_MIN, BUBBLE_OPACTY_MAX); |
| 65 | bubble.Gravity = Lerp(GRAVITY_MIN, GRAVITY_MAX, size / BUBBLE_SIZE_MAX); |
| 66 | bubble.OscillationPeriod = Random::GenerateFloat(0.0f, size); |
| 67 | bubble.OscillationVelocity = Lerp(BUBBLE_OSC_VELOCITY_MAX, BUBBLE_OSC_VELOCITY_MIN, size / BUBBLE_SIZE_MAX); |
| 68 | } |
| 69 | |
| 70 | void SpawnBubble(const Vector3& pos, int roomNumber, int flags) |
| 71 | { |
no test coverage detected