Preliminary effort to add a full screen flash - #48
Conversation
…le in their clone-constructor.
…ight-weight already, anyway.
…d writing its values easier.
|
|
||
| AudioSource::AudioSource(const AudioSource &other) | ||
| : Cloneable<Component, AudioSource>{} | ||
| : Cloneable<Component, AudioSource>{other} |
There was a problem hiding this comment.
Unrelated bug-fix on AudioSource copy constructor.
|
|
||
| MusicFader::MusicFader(const MusicFader &other) | ||
| : Cloneable<Component, MusicFader>{} | ||
| : Cloneable<Component, MusicFader>{other} |
There was a problem hiding this comment.
Unrelated bug-fix on MusicFader copy constructor.
| class CheatSystem : public ICheatSystem { | ||
| public: | ||
| CheatSystem(const std::initializer_list<std::string_view> &scenePaths); | ||
| CheatSystem(std::initializer_list<std::string_view> scenePaths); |
There was a problem hiding this comment.
Unrelated bug-fix on CheatSystem list constructor.
| #include "Systems/Logging/ILoggingSystem.h" | ||
| #include "Utils.h" | ||
|
|
||
| using json = nlohmann::json; |
There was a problem hiding this comment.
Unrelated refactor of removing using from Stream
| virtual ~TweenCurve() = default; | ||
|
|
||
| template<class T> | ||
| void Set(float startValue, T begin, T end); |
There was a problem hiding this comment.
Defining set to allow re-using an existing TweenCurve instance to change its internal member values.
There was a problem hiding this comment.
Pull request overview
Adds initial infrastructure for a global full-screen flash effect by reusing the existing SpriteFader component and introducing a ScreenFlashSystem that locates and drives a dedicated ScreenFlash entity in scenes.
Changes:
- Extends
TweenCurveandSpriteFaderto support curve-driven fades and programmatic triggering. - Introduces
IScreenFlashSystem/ScreenFlashSystemand registers it inGameRass/Main.cpp. - Adds a
ScreenFlashentity asset and wires it into multiple scenes.
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Source/TweenCurve.h | Adds curve setter helpers and query APIs used by fade logic. |
| Source/TweenCurve.cpp | Fixes keyframe search ordering and adds duration/ending-value helpers. |
| Source/Systems/Cheat/CheatSystem.h | Adjusts ctor signature for initializer_list handling. |
| Source/Systems/Cheat/CheatSystem.cpp | Matches ctor signature change in implementation. |
| Source/Stream.h | Removes json alias usage in header, uses fully-qualified nlohmann::json. |
| Source/Components/SpriteFader.h | Expands SpriteFader to support curve-based fades and a Show() API. |
| Source/Components/SpriteFader.cpp | Implements curve-driven fade behavior, caching, and auto-disable support. |
| Source/Components/MusicFader.cpp | Fixes clone/copy construction to copy base state. |
| Source/Components/AudioSource.cpp | Fixes clone/copy construction to copy base state. |
| Source/Component.h | Changes SetEnabled signature to virtual void. |
| GameRass/Systems/ScreenFlash/ScreenFlashSystem.h | Declares system that finds a SpriteFader for screen flashing. |
| GameRass/Systems/ScreenFlash/ScreenFlashSystem.cpp | Implements scene bind/unbind and Show() forwarding to SpriteFader. |
| GameRass/Systems/ScreenFlash/IScreenFlashSystem.h | Adds global system interface for triggering flashes. |
| GameRass/Main.cpp | Registers ScreenFlashSystem as a global system. |
| GameRass/Assets/Scenes/VerticalSlicePuzzle.json | Adds ScreenFlash entity to scene contents. |
| GameRass/Assets/Scenes/VerticalSlicePlat.json | Adds ScreenFlash entity to scene contents. |
| GameRass/Assets/Scenes/Level4Puzzle.json | Adds ScreenFlash entity to scene contents. |
| GameRass/Assets/Scenes/Level2Puzzle.json | Adds ScreenFlash entity to scene contents. |
| GameRass/Assets/Scenes/Level2Plat.json | Adds ScreenFlash entity to scene contents. |
| GameRass/Assets/Scenes/Level1Puzzle.json | Adds ScreenFlash entity to scene contents. |
| GameRass/Assets/Scenes/Level1Plat.json | Adds ScreenFlash entity to scene contents. |
| GameRass/Assets/Entities/ScreenFlash.json | Introduces the flash overlay entity with Sprite + SpriteFader setup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Empty key frames | ||
| this->keyFrames.clear(); | ||
| this->keyFrames.reserve(keyFrames.size()); | ||
|
|
||
| // Populate it with the setter | ||
| std::for_each(begin, end, [this] (const KeyFrame &key) { | ||
| this->keyFrames.emplace_back(key); | ||
| }); |
| float TweenCurve::GetTotalDuration() const { | ||
| // Check if there are any keyframes | ||
| float toReturn = 0.0f; | ||
| if(keyFrames.size() == 0) { | ||
| // If not, return 0 | ||
| return toReturn; | ||
| } | ||
|
|
||
| // Sum the times of all keyframes | ||
| for(const KeyFrame &key : keyFrames) { | ||
| toReturn += key.time; | ||
| } | ||
| return toReturn; | ||
| } |
| inline virtual void SetEnabled(bool flag) { | ||
| isEnabled = flag; | ||
| } |
| // Author(s): main Steven Yacoub, secondary Taro Omiya, Niko Bekris | ||
| // Course: GAM541 | ||
| // Project: RASS | ||
| // Purpose: System providing custom memory allocation. |
| onSceneLoaded{this, &ScreenFlashSystem::OnSceneLoaded} | ||
| , onSceneUnloaded{this, &ScreenFlashSystem::OnSceneUnloaded} {} | ||
|
|
||
| ScreenFlashSystem::~ScreenFlashSystem() {} |
| void ScreenFlashSystem::Shutdown() { | ||
| if(!IGlobalEventsSystem::Get()) { | ||
| LOG_ERROR("{}: failed to initialize: no global events system", NameClass()); | ||
| return; | ||
| } | ||
|
|
||
| // Unbind to scene load/unload events | ||
| IGlobalEventsSystem::Get()->unbind(SceneChange::AfterInitialize, &onSceneLoaded); | ||
| IGlobalEventsSystem::Get()->unbind(SceneChange::BeforeShutdown, &onSceneUnloaded); | ||
| } |
Here's my preliminary, compiling effort to add in a full screen flash, using
SpriteFadercomponent. This adds aScreenFlashSystemto allow global access to aSpriteFaderinstance.Completely untested. I'm working on a new PR to actually test what I've added in, here, but wanted to keep the PR small for the time being.