Chore: Code cleanup for AssetBundleManager - #2
SniffBakaSniff wants to merge 7 commits into
Conversation
See CHANGELOG.md [1.1.1-dev-alpha] for details.
Forgot to update the plugin version.
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
| if (existingScene.IsValid() && existingScene.isLoaded) | ||
| { | ||
| Logger.Log( | ||
| $"Scene '{sceneName}' is already loaded. " + | ||
| "Unloading before reloading." | ||
| ); | ||
|
|
||
| UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync( | ||
| existingScene | ||
| ); | ||
|
|
||
| // The next waiter will wait until the scene is gone | ||
| // before loading it again. | ||
| Logger.Log($"Scene '{sceneName}' is already loaded. Unloading before reloading."); | ||
| _ = UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(existingScene); | ||
| } |
There was a problem hiding this comment.
Suggestion: The scene is unloaded asynchronously, but the waiter immediately finds the still-loaded scene and places the player into it without requesting a replacement load.
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Race condition
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** SceneManager/SceneManager.cs
**Line:** 43:47
**Comment:**
*Race Condition: The scene is unloaded asynchronously, but the waiter immediately finds the still-loaded scene and places the player into it without requesting a replacement load.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
Addressed in 24f73b4 — the returned AsyncOperation is passed to SceneLoadWaiter, which yields on _unloadOperation.isDone before requesting the reload or placing the player.
CodeAnt NitpicksNo threshold-suppressed suggestions found in the latest review. |
|
@CodeAnt-AI: review |
|
@CodeAnt-AI: review |
| if (UnityEngine.Object.FindAnyObjectByType<SceneLoadWaiter>() != null) | ||
| { | ||
| Logger.Log($"Scene load already in progress; ignoring duplicate request for '{sceneName}'."); | ||
| return; |
There was a problem hiding this comment.
Suggestion: The startup SceneLoadWaiter has an empty scene name but remains alive, so this check rejects every later public scene-load request as a duplicate.
Assessment: 🔴 Critical · 🔁 Occurrence: Often · 🏷️ State/lifecycle
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** SceneManager/SceneManager.cs
**Line:** 32:35
**Comment:**
*State Lifecycle: The startup `SceneLoadWaiter` has an empty scene name but remains alive, so this check rejects every later public scene-load request as a duplicate.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
Addressed in f66345b — removed AddComponent() from Plugin.Load() and switched to an internal IsSceneLoading state flag on SceneManager.
…aiter, and track loading state
|
@CodeAnt-AI: review |
|
@CodeAnt-AI: review |
| namespace DeadshotModAPI; | ||
|
|
||
| [BepInPlugin("com.subaka.deadshotmodapi", "Deadshot Mod API", "v1.0.0-dev-alpha")] | ||
| [BepInPlugin("com.subaka.deadshotmodapi", "Deadshot Mod API", "v1.1.1-dev-alpha")] |
There was a problem hiding this comment.
Suggestion: The plugin metadata no longer matches the repository’s contract tests, which require Deadshot Mod Api and version 0.0.1; the metadata test now fails.
Assessment: 🟠 Major · 🔁 Occurrence: Often · 🏷️ Api mismatch
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** Plugin.cs
**Line:** 7:7
**Comment:**
*Api Mismatch: The plugin metadata no longer matches the repository’s contract tests, which require `Deadshot Mod Api` and version `0.0.1`; the metadata test now fails.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| if (!_sceneLoadRequested) | ||
| { | ||
| _sceneLoadRequested = true; | ||
| Logger.Log($"Loading custom scene: {_sceneName}"); | ||
|
|
||
| try | ||
| { | ||
| UnityEngine.SceneManagement.SceneManager.LoadScene(_sceneName, LoadSceneMode.Additive); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| _sceneLoadRequested = false; | ||
| Logger.Error($"Failed to load custom scene '{_sceneName}': {ex}"); | ||
| Destroy(gameObject); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| return; |
There was a problem hiding this comment.
Suggestion: If Unity cannot load the requested scene without throwing, _sceneLoadRequested stays true while the scene remains invalid. The waiter then polls forever and IsSceneLoading never resets.
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Resource leak
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** SceneManager/SceneLoadWaiter.cs
**Line:** 69:87
**Comment:**
*Resource Leak: If Unity cannot load the requested scene without throwing, `_sceneLoadRequested` stays true while the scene remains invalid. The waiter then polls forever and `IsSceneLoading` never resets.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
User description
What changed?
See CHANGELOG.md [1.1.1-dev-alpha] for details.
Why?
Most of the code was AI-generated and had become messy and difficult to maintain. This cleans up the code and improves the overall structure.
How was it tested?
Manual in-game testing.
CodeAnt-AI Description
Make custom-scene loading reliable and complete cleanly
What Changed
CustomPlayerSpawnpoints nested deep inside custom scenes1.1.1-dev-alphaImpact
✅ Fewer custom-scene reload failures✅ No lingering scene-load processes✅ Reliable spawning in nested scene layouts💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.