| 134 | } |
| 135 | |
| 136 | Particle* GetFreeParticle() |
| 137 | { |
| 138 | int partID = NO_VALUE; |
| 139 | |
| 140 | // Get first free available particle. |
| 141 | for (int i = 0; i < MAX_PARTICLES; i++) |
| 142 | { |
| 143 | const auto& part = Particles[i]; |
| 144 | if (!part.on) |
| 145 | { |
| 146 | partID = i; |
| 147 | break; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | // No free particles; get particle with shortest life. |
| 152 | float shortestLife = FLT_MAX; |
| 153 | if (partID == NO_VALUE) |
| 154 | { |
| 155 | for (int i = 0; i < MAX_PARTICLES; i++) |
| 156 | { |
| 157 | const auto& part = Particles[i]; |
| 158 | |
| 159 | if (part.life < shortestLife && part.dynamic == NO_VALUE && !(part.flags & SP_EXPLOSION)) |
| 160 | { |
| 161 | partID = i; |
| 162 | shortestLife = part.life; |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | auto& part = Particles[partID]; |
| 168 | part.SpriteSeqID = ID_DEFAULT_SPRITES; |
| 169 | part.SpriteID = 0; |
| 170 | part.fxObj = NO_VALUE; |
| 171 | part.blendMode = BlendMode::Additive; |
| 172 | part.extras = 0; |
| 173 | part.dynamic = NO_VALUE; |
| 174 | part.DisableInterpolation = true; |
| 175 | |
| 176 | return ∂ |
| 177 | } |
| 178 | |
| 179 | void SetSpriteSequence(Particle& particle, GAME_OBJECT_ID objectID) |
| 180 | { |
no outgoing calls
no test coverage detected