-
Notifications
You must be signed in to change notification settings - Fork 0
Game beautification #73
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
Conversation
player also starts with 1 copy of this note in their queue
Created puppet scenes Added WIP map icons Created BattleConfig
Created puppet scenes Added WIP map icons Created BattleConfig
steals 1 health from enemy
WalkthroughThe changes introduce new configuration files for texture importing across multiple assets and update resource import settings. New structures, enums, and classes related to songs, arrows, and battle configurations are added in the global namespace. Several scene files are created or modified to instantiate game objects using PackedScenes, adjust note and stage logic, and improve visual presentations with shader-based backgrounds. Input mappings and puppet-related scripts are also updated, while deprecated map grid management is removed from stage transitions. Changes
Sequence Diagram(s)sequenceDiagram
participant BD as BattleDirector
participant PS as PackedScene (PlayerPuppet)
participant ES as PackedScene (Boss1)
BD->>PS: Load("PlayerPuppet.tscn")
PS->>BD: Instantiate PlayerPuppet
BD->>ES: Load("Boss1.tscn")
ES->>BD: Instantiate Enemy Puppet
sequenceDiagram
participant SP as StageProducer
participant BC as BattleConfig
SP->>BC: Create BattleConfig instance during TransitionStage (Battle)
Note over SP,BC: MapGrid management removed.
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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.
Actionable comments posted: 5
🧹 Nitpick comments (14)
scenes/Puppets/scripts/PlayerStats.cs (1)
10-16: Consider implementing a more efficient note creation mechanism.The TODO comment indicates a known issue with using
.Clone(). Consider implementing a factory pattern or object pooling for better performance and memory management.- public Note[] CurNotes = new Note[] - { - Scribe.NoteDictionary[1].Clone(), - Scribe.NoteDictionary[1].Clone(), - Scribe.NoteDictionary[2].Clone(), - Scribe.NoteDictionary[3].Clone(), - }; //TODO: Get a better method than .Clone + private readonly NoteFactory _noteFactory = new(); + public Note[] CurNotes => new Note[] + { + _noteFactory.CreateNote(1), + _noteFactory.CreateNote(1), + _noteFactory.CreateNote(2), + _noteFactory.CreateNote(3), + };scenes/Puppets/Enemies/Boss1.tscn (1)
8-16: Consider adjusting particle effect parameters for better visual impact.The blood particle effect could be enhanced:
- Current turbulence strength (14.2) might be too high
- Scale is fixed (4.0) for both min and max
emission_point_count = 1078 gravity = Vector3(0, 98, 0) -scale_min = 4.0 -scale_max = 4.0 +scale_min = 3.0 +scale_max = 5.0 -turbulence_noise_strength = 14.2 +turbulence_noise_strength = 10.0scenes/Puppets/Enemies/EnemyPuppet.tscn (1)
13-17: Consider making health bar position configurable.The health bar's position is hardcoded with specific offset values. Consider making these values configurable through exported variables in the script for better reusability across different enemy types.
scenes/Puppets/PlayerPuppet.tscn (1)
16-20: Consider sharing health bar configuration.The health bar positioning is identical to EnemyPuppet.tscn. Consider creating a shared configuration or base scene to maintain consistency and reduce duplication.
scenes/ChartViewport/StarryNight.gdshader (1)
18-22: Consider optimizing star density calculation.The current implementation might cause performance issues on lower-end devices due to per-pixel random calculations. Consider:
- Using a noise texture instead of procedural randomization
- Adjusting the threshold (0.996) through a uniform variable for runtime customization
scenes/ChartViewport/ChartViewport.tscn (1)
35-41: Consider adjusting StarShader scale for better performance.The current scale (2.18) is an unusual value. Consider using a power of 2 for better GPU performance.
-scale = Vector2(2.18, 2.18) +scale = Vector2(2.0, 2.0)scenes/Maps/scripts/Cartographer.cs (1)
59-70: LGTM! Added distinct icons for different room types.The implementation improves visual clarity by using specific icons for Battle, Boss, and Chest rooms.
Consider caching the loaded textures to improve performance:
+private static readonly Texture2D BattleIcon = GD.Load<Texture2D>("res://scenes/Maps/assets/BattleIcon.png"); +private static readonly Texture2D BossIcon = GD.Load<Texture2D>("res://scenes/Maps/assets/BossIcon.png"); +private static readonly Texture2D ChestIcon = GD.Load<Texture2D>("res://scenes/Maps/assets/ChestIcon.png"); switch (room.Type) { case MapRooms.Battle: - newButton.Icon = (Texture2D)GD.Load("res://scenes/Maps/assets/BattleIcon.png"); + newButton.Icon = BattleIcon; break; case MapRooms.Boss: - newButton.Icon = (Texture2D)GD.Load("res://scenes/Maps/assets/BossIcon.png"); + newButton.Icon = BossIcon; break; case MapRooms.Chest: - newButton.Icon = (Texture2D)GD.Load("res://scenes/Maps/assets/ChestIcon.png"); + newButton.Icon = ChestIcon; break; }Globals/StageProducer.cs (2)
15-15: Consider implementing the hinted state machine.
You have a//TODO: State Machine kinda deal?comment. Converting theseStagesinto a proper state machine could better manage transitions and enforce consistency across possible states.
22-23: Add a brief comment for the Config field.
Declaring a staticBattleConfigis fine, but it might help future maintainers if you add a concise docstring clarifying its life cycle and usage.scenes/Puppets/scripts/PuppetTemplate.cs (3)
15-16: Maintain consistent naming conventions.
You have_healthBar(protected) andSprite(public). Consider standardizing naming (e.g.,_sprite, or making both public/protected) to keep code style uniform.
18-19: Parameterize default StartPos if needed.
The comment//158, 126suggests a specific position. If you often tweak these values, consider turning them into constants or default values with more clarity.
34-35: Check for null references before usage.
In_Ready(), ensureSpriteand_healthBarare not null. Currently, the code relies on them being assigned in the editor. Adding a quick null check or default fallback can improve robustness.Globals/FunkEngineNameSpace.cs (2)
129-154: Add XML documentation for the recursive path generation method.The method
GeneratePath_ruses a recursive algorithm for path generation. While there's an inline comment, consider adding XML documentation to better explain:
- The algorithm's purpose
- Parameters and their constraints
- Recursion termination conditions
+ /// <summary> + /// Recursively generates a path through the map grid starting from the given coordinates. + /// </summary> + /// <param name="x">Current X coordinate, must be within [0, width-1]</param> + /// <param name="y">Current Y coordinate, must be within [0, height-1]</param> + /// <param name="width">Grid width</param> + /// <param name="height">Grid height</param> private void GeneratePath_r(int x, int y, int width, int height)
96-101: Consider using List instead of Array for dynamic children collection.The
Childrenproperty uses array operations which create new arrays on each addition. UsingList<T>would be more efficient for dynamic collections.- public int[] Children { get; private set; } = Array.Empty<int>(); + private readonly List<int> _children = new(); + public IReadOnlyList<int> Children => _children; public void AddChild(int newIdx) { - if (Children.Contains(newIdx)) + if (_children.Contains(newIdx)) return; - Children = Children.Append(newIdx).ToArray(); + _children.Add(newIdx); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (7)
Classes/Notes/assets/heal_note.pngis excluded by!**/*.pngClasses/Notes/assets/quarter_note.pngis excluded by!**/*.pngClasses/Notes/assets/vampire_note.pngis excluded by!**/*.pngscenes/Maps/assets/BattleIcon.pngis excluded by!**/*.pngscenes/Maps/assets/BossIcon.pngis excluded by!**/*.pngscenes/Maps/assets/ChestIcon.pngis excluded by!**/*.pngscenes/Puppets/Enemies/assets/Enemy1EmissionShape.pngis excluded by!**/*.png
📒 Files selected for processing (26)
Classes/Notes/assets/heal_note.png.import(1 hunks)Classes/Notes/assets/quarter_note.png.import(1 hunks)Classes/Notes/assets/vampire_note.png.import(1 hunks)Globals/FunkEngineNameSpace.cs(3 hunks)Globals/Scribe.cs(1 hunks)Globals/StageProducer.cs(2 hunks)project.godot(1 hunks)scenes/BattleDirector/scripts/BattleDirector.cs(1 hunks)scenes/BattleDirector/scripts/NotePlacementBar.cs(1 hunks)scenes/ChartViewport/ChartManager.cs(0 hunks)scenes/ChartViewport/ChartViewport.tscn(2 hunks)scenes/ChartViewport/StarryNight.gdshader(1 hunks)scenes/Maps/assets/BattleIcon.png.import(1 hunks)scenes/Maps/assets/BossIcon.png.import(1 hunks)scenes/Maps/assets/ChestIcon.png.import(1 hunks)scenes/Maps/scripts/Cartographer.cs(3 hunks)scenes/NoteManager/note_manager.tscn(1 hunks)scenes/Puppets/Enemies/Boss1.tscn(1 hunks)scenes/Puppets/Enemies/EnemyPuppet.tscn(1 hunks)scenes/Puppets/Enemies/assets/Boss1EmissionShape.tres(1 hunks)scenes/Puppets/Enemies/assets/Enemy1.png.import(1 hunks)scenes/Puppets/Enemies/assets/Enemy1EmissionShape.png.import(1 hunks)scenes/Puppets/PlayerPuppet.tscn(1 hunks)scenes/Puppets/scripts/PlayerPuppet.cs(1 hunks)scenes/Puppets/scripts/PlayerStats.cs(1 hunks)scenes/Puppets/scripts/PuppetTemplate.cs(2 hunks)
💤 Files with no reviewable changes (1)
- scenes/ChartViewport/ChartManager.cs
✅ Files skipped from review due to trivial changes (9)
- Classes/Notes/assets/heal_note.png.import
- Classes/Notes/assets/vampire_note.png.import
- scenes/Puppets/Enemies/assets/Enemy1EmissionShape.png.import
- scenes/Maps/assets/BossIcon.png.import
- scenes/Maps/assets/ChestIcon.png.import
- Classes/Notes/assets/quarter_note.png.import
- scenes/Maps/assets/BattleIcon.png.import
- scenes/Puppets/Enemies/assets/Boss1EmissionShape.tres
- scenes/Puppets/Enemies/assets/Enemy1.png.import
🧰 Additional context used
🪛 GitHub Check: build
Globals/FunkEngineNameSpace.cs
[warning] 75-75:
The field 'MapGrid._curRoom' is assigned but its value is never used
[warning] 75-75:
The field 'MapGrid._curRoom' is assigned but its value is never used
🔇 Additional comments (19)
scenes/Puppets/scripts/PlayerPuppet.cs (1)
15-15: LGTM! Good separation of concerns.Moving visual configuration to the scene file and simplifying the initialization logic improves code organization.
scenes/Puppets/Enemies/Boss1.tscn (1)
46-49: Verify health bar visibility during gameplay.The health bar's position (32 units below the sprite) might be too far from the character model. Consider adjusting the offset for better visual feedback.
project.godot (1)
37-64: LGTM! Ergonomic alternative control scheme.The addition of X, C, Z, V keys provides an ergonomic alternative to WASD, forming a comfortable diamond pattern on the keyboard. This enhances player comfort while maintaining compatibility with existing controls.
scenes/Puppets/Enemies/EnemyPuppet.tscn (1)
6-9: LGTM! Well-structured scene setup.The scene follows Godot's best practices with proper node organization and exported paths.
scenes/Puppets/PlayerPuppet.tscn (1)
7-11: LGTM! Well-structured player puppet scene.The scene maintains consistency with the enemy puppet structure while adding player-specific configurations like StartPos.
scenes/ChartViewport/StarryNight.gdshader (1)
1-3: LGTM! Proper attribution and documentation.The shader includes clear attribution to the original author and source.
Globals/Scribe.cs (2)
48-58: LGTM! PlayerHeal note adds healing mechanic.The implementation is clean and follows the established pattern. The healing mechanic adds strategic depth to gameplay.
59-70: LGTM! PlayerVampire note introduces life-steal mechanic.Well-implemented dual-action note that combines healing and damage. This adds an interesting strategic element to the game.
scenes/BattleDirector/scripts/BattleDirector.cs (2)
74-76: LGTM! Improved Player instantiation using PackedScene.The change to use PackedScene improves modularity and follows Godot best practices.
82-84: LGTM! Improved Enemy instantiation using PackedScene.The change to use PackedScene for enemy instantiation aligns with the Player implementation and improves consistency.
scenes/ChartViewport/ChartViewport.tscn (1)
7-12: LGTM! Added configurable shader for dynamic background.The shader implementation with configurable parameters (colors, gradient, time scale) enhances visual appeal and allows for easy customization.
Globals/StageProducer.cs (1)
55-55: Verify repeated instantiation logic.
Each time you callTransitionStage(Stages.Battle), a newBattleConfigis created. Confirm this is intended and won't overwrite any persisted state unexpectedly.scenes/Puppets/scripts/PuppetTemplate.cs (2)
12-14: Watch for potential null references on _healthBar.
Exporting_healthBaris useful for editor assignment, but ensure you handle cases where it might not be assigned. This avoids runtime errors when calling_healthBar.SetHealth(...).
21-22: Good use of an exported InitScale.
This approach ensures easy adjustment from the editor without code changes. No further issues spotted here.scenes/NoteManager/note_manager.tscn (4)
24-26: Confirm input mapping synchronization.
Renaming this node to "arrowUp" and rotating it to-1.5708changes orientation. Double-check any input or collision logic expecting the old name/orientation.
30-30: Outline node rename appears consistent.
No functional issues. This helps keep node organization consistent for the new "arrowUp."
34-36: ArrowDown orientation reversed.
The flipped rotation suggests its role is swapped with arrowUp. Ensure notes or UI references are updated to prevent mismatches in your arrow input checks.
40-41: Uniform outline structure maintained.
Renaming the Outline node for arrowDown is consistent with the arrowUp approach. Looks good.Globals/FunkEngineNameSpace.cs (1)
18-18: Consider adding null checks for NoteChecker Node.The
Nodeproperty could potentially be null. Consider adding validation or using nullable reference types to make this explicit.- public NoteChecker Node; + public NoteChecker? Node;
| if (_noteQueue.Peek().Name == "PlayerQuarter") | ||
| _currentBarValue -= MaxValue / 4; | ||
| else | ||
| _currentBarValue = 0; | ||
|
|
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.
🛠️ Refactor suggestion
Replace string comparison with enum or constant.
Using string comparison for note types is fragile and error-prone. Consider:
- Using an enum or constant for note types
- Adding null checks for _noteQueue.Peek()
+private const string PLAYER_QUARTER_NOTE = "PlayerQuarter";
+private const float QUARTER_NOTE_RATIO = 0.25f;
if (_noteQueue.Peek()?.Name == PLAYER_QUARTER_NOTE)
- _currentBarValue -= MaxValue / 4;
+ _currentBarValue -= (int)(MaxValue * QUARTER_NOTE_RATIO);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (_noteQueue.Peek().Name == "PlayerQuarter") | |
| _currentBarValue -= MaxValue / 4; | |
| else | |
| _currentBarValue = 0; | |
| private const string PLAYER_QUARTER_NOTE = "PlayerQuarter"; | |
| private const float QUARTER_NOTE_RATIO = 0.25f; | |
| if (_noteQueue.Peek()?.Name == PLAYER_QUARTER_NOTE) | |
| _currentBarValue -= (int)(MaxValue * QUARTER_NOTE_RATIO); | |
| else | |
| _currentBarValue = 0; |
| if (_noteQueue.Peek().Name == "PlayerQuarter") | ||
| return _currentBarValue >= MaxValue / 4; | ||
|
|
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.
Add null safety check for note queue.
The current implementation might throw NullReferenceException if _noteQueue is empty.
+if (_noteQueue.Count == 0)
+ return false;
+
if (_noteQueue.Peek()?.Name == PLAYER_QUARTER_NOTE)
return _currentBarValue >= MaxValue / 4;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (_noteQueue.Peek().Name == "PlayerQuarter") | |
| return _currentBarValue >= MaxValue / 4; | |
| if (_noteQueue.Count == 0) | |
| return false; | |
| if (_noteQueue.Peek()?.Name == PLAYER_QUARTER_NOTE) | |
| return _currentBarValue >= MaxValue / 4; |
| new Note( | ||
| "PlayerQuarter", | ||
| "Basic note at a quarter of the cost", | ||
| GD.Load<Texture2D>("res://Classes/Notes/assets/quarter_note.png"), | ||
| null, | ||
| 1, | ||
| (director, note, timing) => | ||
| { | ||
| director.Enemy.TakeDamage((int)timing); | ||
| } | ||
| ), |
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.
💡 Verification agent
❓ Verification inconclusive
Consider adding cost validation for PlayerQuarter note.
While the implementation is correct, consider adding validation to ensure the quarter cost is properly enforced.
🏁 Script executed:
#!/bin/bash
# Search for cost validation in NotePlacementBar
ast-grep --pattern 'CanPlaceNote($_) {
$$$
if ($_ == "PlayerQuarter") {
$$$
}
$$$
}'Length of output: 98
Action Required: Add explicit cost validation for "PlayerQuarter" in the cost-checking logic.
Our initial search using the provided AST pattern did not locate any validation for "PlayerQuarter" in the expected cost validation routines (e.g., within the NotePlacementBar logic). It appears that the quarter cost is not being explicitly enforced at this point. Please confirm that this omission is unintentional and, if so, add the necessary cost validation (or a corresponding inline comment if it's deliberate).
- File: Globals/Scribe.cs (Lines 71-81 snippet remains unchanged)
- Action: Modify or enhance the cost validation logic (likely in NotePlacementBar or similar module) to ensure that the quarter cost for "PlayerQuarter" is properly enforced.
| public MapRooms RoomType { get; private set; } | ||
| public MapGrid.Room CurRoom { get; private set; } | ||
| public SongData CurSong { get; set; } | ||
| public int TodoEnemyAndChart; |
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.
🛠️ Refactor suggestion
Rename and document the TodoEnemyAndChart field.
The field name suggests incomplete implementation. Consider:
- Documenting the intended purpose
- Using a more descriptive name
- Adding XML documentation
Would you like me to help implement this feature or create an issue to track it?
| private int[,] _map; | ||
| private Room[] _rooms; | ||
| private int _curIdx = 0; | ||
| private int _curRoom = 0; |
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.
Remove unused field _curRoom.
The field _curRoom is assigned but never used, as flagged by static analysis.
- private int _curRoom = 0;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private int _curRoom = 0; |
🧰 Tools
🪛 GitHub Check: build
[warning] 75-75:
The field 'MapGrid._curRoom' is assigned but its value is never used
[warning] 75-75:
The field 'MapGrid._curRoom' is assigned but its value is never used
Summary by CodeRabbit
New Features
Improvements