[F] OneKeyRetrySkip导致的一键跳关,不会设置TrackSkip Flag的问题#129
Conversation
审阅者指南(在小型 PR 上折叠显示)审阅者指南在执行单键重试/跳过时,为两位玩家都设置 TrackSkip 标志,使其行为与游戏的正常“跳过曲目”逻辑一致。 OneKeyRetrySkip 中 TrackSkip 标志设置的时序图sequenceDiagram
participant OneKeyRetrySkip
participant GamePlayManager
participant Player0Score
participant Player1Score
OneKeyRetrySkip->>GamePlayManager: SetSyncResult(0)
OneKeyRetrySkip->>GamePlayManager: GetGameScore(0)
GamePlayManager-->>OneKeyRetrySkip: GameScore0
OneKeyRetrySkip->>Player0Score: SetTrackSkip()
OneKeyRetrySkip->>GamePlayManager: GetGameScore(1)
GamePlayManager-->>OneKeyRetrySkip: GameScore1
OneKeyRetrySkip->>Player1Score: SetTrackSkip()
文件级别变更
提示与命令与 Sourcery 交互
自定义你的使用体验访问你的 控制面板 以:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideAdds setting of the TrackSkip flag for both players when performing a one-key retry/skip so that it matches the game’s normal track-skip behavior. Sequence diagram for TrackSkip flag setting in OneKeyRetrySkipsequenceDiagram
participant OneKeyRetrySkip
participant GamePlayManager
participant Player0Score
participant Player1Score
OneKeyRetrySkip->>GamePlayManager: SetSyncResult(0)
OneKeyRetrySkip->>GamePlayManager: GetGameScore(0)
GamePlayManager-->>OneKeyRetrySkip: GameScore0
OneKeyRetrySkip->>Player0Score: SetTrackSkip()
OneKeyRetrySkip->>GamePlayManager: GetGameScore(1)
GamePlayManager-->>OneKeyRetrySkip: GameScore1
OneKeyRetrySkip->>Player1Score: SetTrackSkip()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我在这里给出了一些高层次的反馈:
- 建议避免在循环中直接使用魔术数字
2,可以改用具名常量,或者从现有数据源推导玩家数量,这样以后玩家槽位配置变更时,就不需要修改这段逻辑。 - 可以在循环之前,将
Singleton<GamePlayManager>.Instance缓存在一个局部变量中,以避免重复的单例查找调用,同时也能让代码意图更清晰。
给 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- Consider avoiding the magic number `2` in the loop by using a named constant or deriving the player count from an existing source, so future changes in player slots don't require updating this logic.
- You can cache `Singleton<GamePlayManager>.Instance` in a local variable before the loop to avoid repeated singleton lookups and make the intent a bit clearer.帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据这些反馈持续改进为你提供的代码审查。
Original comment in English
Hey - I've left some high level feedback:
- Consider avoiding the magic number
2in the loop by using a named constant or deriving the player count from an existing source, so future changes in player slots don't require updating this logic. - You can cache
Singleton<GamePlayManager>.Instancein a local variable before the loop to avoid repeated singleton lookups and make the intent a bit clearer.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider avoiding the magic number `2` in the loop by using a named constant or deriving the player count from an existing source, so future changes in player slots don't require updating this logic.
- You can cache `Singleton<GamePlayManager>.Instance` in a local variable before the loop to avoid repeated singleton lookups and make the intent a bit clearer.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request updates the PostGameProcessUpdate method in OneKeyRetrySkip.cs to iterate through game scores and mark them as skipped. The review feedback suggests caching the GamePlayManager singleton instance in a local variable to improve code readability and performance, while also recommending a null check for safer access.
| for (int i = 0; i < 2; i++) | ||
| { | ||
| Singleton<GamePlayManager>.Instance.GetGameScore(i)?.SetTrackSkip(); | ||
| } |
There was a problem hiding this comment.
建议将 Singleton.Instance 缓存到局部变量中。虽然目前只有两次迭代,但缓存单例访问是更好的实践,且能提高代码的可读性。此外,建议在访问前对单例实例进行空检查(防御性编程),以防止在某些极端情况下出现 NullReferenceException。虽然第 58 行已经直接访问了该单例,但在新代码中遵循安全实践仍是推荐的。
var gamePlayManager = Singleton<GamePlayManager>.Instance;
for (int i = 0; i < 2; i++)
{
gamePlayManager?.GetGameScore(i)?.SetTrackSkip();
}
只是设置一个flag。
游戏官方的正常track skip逻辑是会设置这个flag的,所以我们也应该设一下
Summary by Sourcery
Bug Fixes:
Original summary in English
Summary by Sourcery
Bug Fixes: