| 269 | } |
| 270 | |
| 271 | void CEffect_Thunderbolt::OnFrame(shared_str id, float period, float duration) |
| 272 | { |
| 273 | ZoneScoped; |
| 274 | |
| 275 | BOOL enabled = !!(id.size()); |
| 276 | if (bEnabled != enabled) |
| 277 | { |
| 278 | bEnabled = enabled; |
| 279 | next_lightning_time = Device.fTimeGlobal + period + Random.randF(-period * 0.5f, period * 0.5f); |
| 280 | } |
| 281 | else if (bEnabled && (Device.fTimeGlobal > next_lightning_time)) |
| 282 | { |
| 283 | if (state == stIdle && !!(id.size())) |
| 284 | Bolt(id, period, duration); |
| 285 | } |
| 286 | if (state == stWorking) |
| 287 | { |
| 288 | if (current_time > life_time) |
| 289 | state = stIdle; |
| 290 | current_time += Device.fTimeDelta; |
| 291 | Fvector fClr; |
| 292 | int frame; |
| 293 | u32 uClr = current->color_anim->CalculateRGB(current_time / life_time, frame); |
| 294 | fClr.set(clampr(float(color_get_R(uClr) / 255.f), 0.f, 1.f), clampr(float(color_get_G(uClr) / 255.f), 0.f, 1.f), clampr(float(color_get_B(uClr) / 255.f), 0.f, 1.f)); |
| 295 | |
| 296 | lightning_phase = 1.5f * (current_time / life_time); |
| 297 | clamp(lightning_phase, 0.f, 1.f); |
| 298 | |
| 299 | CEnvironment& environment = g_pGamePersistent->Environment(); |
| 300 | |
| 301 | Fvector& sky_color = environment.CurrentEnv->sky_color; |
| 302 | sky_color.mad(fClr, environment.p_sky_color); |
| 303 | clamp(sky_color.x, 0.f, 1.f); |
| 304 | clamp(sky_color.y, 0.f, 1.f); |
| 305 | clamp(sky_color.z, 0.f, 1.f); |
| 306 | |
| 307 | environment.CurrentEnv->sun_color.mad(fClr, environment.p_sun_color); |
| 308 | environment.CurrentEnv->fog_color.mad(fClr, environment.p_fog_color); |
| 309 | |
| 310 | R_ASSERT(_valid(current_direction)); |
| 311 | g_pGamePersistent->Environment().CurrentEnv->sun_dir = current_direction; |
| 312 | VERIFY(g_pGamePersistent->Environment().CurrentEnv->sun_dir.y < 0, "Invalid sun direction settings while CEffect_Thunderbolt"); |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | void CEffect_Thunderbolt::Render(CBackend& cmd_list) |
| 317 | { |
nothing calls this directly
no test coverage detected