-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/rb 119 fix json #95
Conversation
WalkthroughThe changes primarily focus on refactoring the code to use template functions for retrieving data from JSON. This includes updates to the Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Files ignored due to filter (1)
- assets/Json/enemyData.json
Files selected for processing (4)
- src/Client/Systems/Graphic/ParallaxSystems.cpp (2 hunks)
- src/ECS/Json.cpp (2 hunks)
- src/ECS/Json.hpp (3 hunks)
- src/ECS/Systems/Systems.cpp (2 hunks)
Files skipped from review due to trivial changes (1)
- src/ECS/Json.cpp
Additional comments (Suppressed): 6
src/Client/Systems/Graphic/ParallaxSystems.cpp (2)
- 17-33: The new hunk has improved the way
Types::Position
,Types::Velocity
, andTypes::Rect
objects are constructed from the JSON data. The explicit type specification in thegetDataFromJson
function calls improves code clarity and type safety. However, theRegistry::getInstance().getComponents<Types::Rect>().insertBack((rect));
line seems to be inserting aTypes::Rect
object into the registry without associating it with any entity. This could lead to issues when trying to retrieve the component for a specific entity. Please verify if this is the intended behavior.- Registry::getInstance().getComponents<Types::Rect>().insertBack((rect)); + Registry::getInstance().getComponents<Types::Rect>().insert(id, rect);
- 51-57: The new hunk is identical to the old hunk. No changes have been made in this section. The code checks if the "copy" field exists in the JSON data and if it's true, it creates an additional parallax entity with an offset position. This logic seems to be correct and well-implemented.
src/ECS/Systems/Systems.cpp (2)
- 186-230: The new code has improved the type safety and clarity by explicitly specifying the data types in the function calls to
getDataFromJson
. However, there is a potential issue with theaddEntity
function call in the non-CLIENT build. In the CLIENT build, the entity id is stored in theid
variable, but in the non-CLIENT build, the entity id is not stored. This could lead to inconsistencies if the entity id is needed later in the non-CLIENT build. Please verify if this is the intended behavior.- Registry::getInstance().addEntity(); + std::size_t id = Registry::getInstance().addEntity();
- 386-392: The changes in this hunk are similar to the previous one, improving type safety and clarity by explicitly specifying the data types in the function calls to
getDataFromJson
. No issues are found in this hunk.src/ECS/Json.hpp (2)
9-12: The "Logger.hpp" header file has been added to
Json.hpp
. This is in line with the PR summary and is necessary for the newgetDataFromJson
function to log errors.36-37: The
getDataFromJson
function has been removed. This is in line with the PR summary and is replaced by a new templatedgetDataFromJson
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Files selected for processing (2)
- src/Client/Systems/Graphic/ParallaxSystems.cpp (2 hunks)
- src/ECS/Systems/Systems.cpp (2 hunks)
Additional comments (Suppressed): 4
src/Client/Systems/Graphic/ParallaxSystems.cpp (2)
17-32: The new hunk has improved the way
Position
,Velocity
, andRect
objects are constructed from JSON data. The explicit template arguments make the code more readable and less prone to errors. However, ensure that thegetDataFromJson
function can handle cases where the requested data is not present or is of a different type. Also, verify that theTypes::Position
,Types::Velocity
, andTypes::Rect
classes have appropriate constructors that can handle the data returned bygetDataFromJson
.50-56: The logic for checking the "copy" field in JSON data and creating an additional parallax entity if necessary remains the same. The use of
getDataFromJson<bool>
improves readability and makes the intention of the code clearer. Ensure that all JSON data used in the codebase includes the "copy" field where necessary, and that it is always of type bool.src/ECS/Systems/Systems.cpp (2)
186-231: The new code has improved the way JSON data is retrieved and used to initialize various components of the game entities. The
getDataFromJson
function is now a template function, which allows for more flexible data retrieval. This change has been propagated throughout the codebase, with explicit template arguments specified in all function calls. The code is more readable and maintainable now. However, ensure that the JSON data being retrieved contains the expected types and values.387-392: The
getDataFromJson
function is used to retrieve animation rectangle data from the JSON object. This is a good use of the new template function, as it allows for more flexible data retrieval. However, ensure that the JSON data being retrieved contains the expected types and values.
What is the current behavior? (link an issue based on the kind of change this pr introduce)
What is the new behavior (if this is a feature change)?
Other information:
Summary by CodeRabbit