MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / GetFreeParticle

Function GetFreeParticle

TombEngine/Game/effects/effects.cpp:136–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136Particle* 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 &part;
177}
178
179void SetSpriteSequence(Particle& particle, GAME_OBJECT_ID objectID)
180{

Callers 15

SpawnSpearGuardianEffectFunction · 0.85
SpawnSwordGuardianEffectFunction · 0.85
SpawnSpeedboatBoatMistFunction · 0.85
TriggerPendulumFlameFunction · 0.85
SpawnSophiaSparksFunction · 0.85
TriggerTonyFlameFunction · 0.85
TriggerFireBallFlameFunction · 0.85
SpawnSummonSmokeFunction · 0.85
SpawnShivaSmokeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected