light_flash.cpp 637 B

123456789101112131415161718192021222324252627282930
  1. // Copyright (c) 2022-2023 the Dviglo project
  2. // Copyright (c) 2008-2023 the Urho3D project
  3. // License: MIT
  4. #include "light_flash.h"
  5. namespace Urho3D
  6. {
  7. void LightFlash::RegisterObject(Context* context)
  8. {
  9. context->RegisterFactory<LightFlash>();
  10. }
  11. LightFlash::LightFlash(Context* context)
  12. : GameObject(context)
  13. {
  14. duration = 2.0f;
  15. }
  16. void LightFlash::FixedUpdate(float timeStep)
  17. {
  18. Light* light = node_->GetComponent<Light>();
  19. light->SetBrightness(light->GetBrightness() * Max(1.0f - timeStep * 10.0f, 0.0f));
  20. // Call superclass to handle lifetime
  21. GameObject::FixedUpdate(timeStep);
  22. }
  23. } // namespace Urho3D