Skip to content

Chore: Code cleanup for AssetBundleManager - #2

Open
SniffBakaSniff wants to merge 7 commits into
feat_AssetBundleManagerfrom
chore/code-cleanup
Open

SniffBakaSniff wants to merge 7 commits into
feat_AssetBundleManagerfrom
chore/code-cleanup

Conversation

@SniffBakaSniff

@SniffBakaSniff SniffBakaSniff commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Reloading an already loaded custom scene waits for unloading to finish before loading it again
  • Duplicate load requests are ignored, base gameplay scenes cannot be loaded as custom scenes, and failed loads clean up correctly
  • Players can spawn at CustomPlayerSpawn points nested deep inside custom scenes
  • Missing spawn points stop being searched after a fixed limit instead of running indefinitely
  • Player movement is restored even if placement fails, while menu and base-game visuals remain hidden and the player camera stays active
  • Level-time events now run through Unity's normal update cycle
  • Asset bundle loading rejects empty results, and the plugin version is updated to 1.1.1-dev-alpha

Impact

✅ 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:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

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:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

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.

See CHANGELOG.md [1.1.1-dev-alpha] for details.
Forgot to update the plugin version.
@codeant-ai

codeant-ai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 523a54a Oct 04, 2026 · 01:08 01:11
✅ Reviewed your PR f66345b Oct 04, 2026 · 01:05 01:07
✅ Reviewed your PR 5475abc Oct 04, 2026 · 00:55 00:57
✅ Reviewed your PR 9857fdb Oct 04, 2026 · 00:52 00:54
✅ Incremental review completed 24f73b4 Oct 04, 2026 · 00:45 00:45

@codeant-ai

codeant-ai Bot commented Oct 2, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Oct 2, 2026
Comment thread Events/EventManager.cs Outdated
Comment thread SceneManager/SceneLoadWaiter.cs
Comment thread SceneManager/SceneLoadWaiter.cs
Comment on lines +43 to 47
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);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

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 fix
👍 | 👎

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 24f73b4 — the returned AsyncOperation is passed to SceneLoadWaiter, which yields on _unloadOperation.isDone before requesting the reload or placing the player.

@codeant-ai

codeant-ai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

CodeAnt Nitpicks

No threshold-suppressed suggestions found in the latest review.

@Cyrusbye720

Copy link
Copy Markdown
Contributor

@CodeAnt-AI: review

Comment thread SceneManager/SceneLoadWaiter.cs
Comment thread SceneManager/SceneManager.cs Outdated
Comment thread SceneManager/SceneManager.cs
@Cyrusbye720

Copy link
Copy Markdown
Contributor

@CodeAnt-AI: review

Comment thread SceneManager/SceneLoadWaiter.cs
Comment thread SceneManager/SceneManager.cs Outdated
Comment on lines +32 to +35
if (UnityEngine.Object.FindAnyObjectByType<SceneLoadWaiter>() != null)
{
Logger.Log($"Scene load already in progress; ignoring duplicate request for '{sceneName}'.");
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

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 fix
👍 | 👎

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in f66345b — removed AddComponent() from Plugin.Load() and switched to an internal IsSceneLoading state flag on SceneManager.

@Cyrusbye720

Copy link
Copy Markdown
Contributor

@CodeAnt-AI: review

Comment thread SceneManager/SceneManager.cs
@Cyrusbye720

Copy link
Copy Markdown
Contributor

@CodeAnt-AI: review

Comment thread Plugin.cs
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")]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

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
👍 | 👎

Comment on lines +69 to +87
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

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
👍 | 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants