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

Function UpdateHelicalLasers

TombEngine/Game/effects/Electricity.cpp:205–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203 }
204
205 void UpdateHelicalLasers()
206 {
207 constexpr auto LIFE_START_FADING = HELICAL_LASER_LIFE_MAX / 2;
208 constexpr auto LENGTH_LERP_ALPHA = 0.25f;
209
210 if (HelicalLasers.empty())
211 return;
212
213 for (auto& laser : HelicalLasers)
214 {
215 laser.StoreInterpolationData();
216
217 // Set to despawn.
218 laser.Life -= 1.0f;
219 if (laser.Life <= 0.0f)
220 continue;
221
222 // Update length.
223 laser.Length = Lerp(laser.Length, laser.LengthEnd, LENGTH_LERP_ALPHA);
224
225 // Update radius.
226 laser.Radius += 1 / 8.0f;
227
228 // Update opacity.
229 float alpha = laser.Life / LIFE_START_FADING;
230 laser.Opacity = Lerp(0.0f, 1.0f, alpha);
231
232 // Update orientation.
233 laser.Orientation2D += laser.Rotation;
234 }
235
236 // Despawn inactive effects.
237 HelicalLasers.erase(
238 std::remove_if(
239 HelicalLasers.begin(), HelicalLasers.end(),
240 [](const HelicalLaser& laser) { return (laser.Life <= 0.0f); }), HelicalLasers.end());
241 }
242
243 void UpdateElectricityArcs()
244 {

Callers 1

GamePhaseFunction · 0.85

Calls 6

LerpFunction · 0.85
emptyMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected