Skip to content

Add AssetBundleManager for loading mod AssetBundles - #20

Open
Segually wants to merge 1 commit into
eris-webserv:mainfrom
Segually:feature/asset-bundle-manager
Open

Segually wants to merge 1 commit into
eris-webserv:mainfrom
Segually:feature/asset-bundle-manager

Conversation

@Segually

@Segually Segually commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds AssetBundleManager, which lets mods ship plain (non-Addressables) AssetBundles and have the game load prefabs and sprites from them.

The game streams every runtime asset through ResourceControl's loaders using Addressables keys, so a plain bundle is invisible to it. This manager registers a bundle and patches the concrete loader entry points so that, when a requested key belongs to a registered bundle, the asset is served from that bundle instead.

Covered paths:

  • held items / hats / armor (AsyncInstantiateEquipment)
  • furniture (AsyncInstantiateHouseInterior)
  • placed/dropped world objects and 3D inventory-icon previews (AsyncInstantiateWorldObjectPrefab)
  • 2D inventory icons (LoadAndAssignSprite)

The synchronous AssetBundle APIs are stripped in this il2cpp build, so the manager stages the raw bytes to disk, loads with LoadFromFileAsync, and pre-loads assets with LoadAssetAsync. Mods only hand over the bytes.

AssetBundleManager.Instance
    .RegisterBundleFromEmbeddedResource(Assembly.GetExecutingAssembly(), "MyMod.Bundles.mybundle")
    .AddPrefab("Assets/Prefabs/MyItem.prefab", "MyMod:MyItem");

Changes

  • New Assets/Assets.Systems.cs (AssetBundleManager, ModBundle) and Assets/Assets.Patches.cs (Harmony patches).
  • Base.GamePlugin.cs: initialize AssetBundleManager in place of WorldPrefabManager.
  • Removes Items/Items.WorldPrefab.cs (WorldPrefabManager). AssetBundleManager covers the same AsyncInstantiateWorldObjectPrefab paths, so keeping both would patch the same methods twice. The doc comment in Gui.Systems.cs that referenced WorldPrefabManager now points at AssetBundleManager. Mods that call WorldPrefabManager.Register will need to move to the new API, so this is a breaking change worth a look.

Notes

  • Split out of a larger set of changes; the other PRs (creatures, interactables, .gitignore) are independent of this one. The only overlap is a one-line init registration in Base.GamePlugin.cs, which may need a trivial conflict resolution depending on merge order.
  • Builds cleanly on its own against current main.

🤖 Generated with Claude Code

Loads prefabs and sprites from plain AssetBundles and serves them through ResourceControl's loaders. Supersedes WorldPrefabManager, which is removed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Segually
Segually marked this pull request as ready for review October 1, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant