You are viewing a potentially older version of this package. View all versions.
Millzy-Boneject-2.0.0 icon

Boneject

A Dependency Injection implementation for BONELAB.

Date uploaded a year ago
Version 2.0.0
Download link Millzy-Boneject-2.0.0.zip
Downloads 1189
Dependency string Millzy-Boneject-2.0.0

This mod requires the following mods to function

LavaGang-MelonLoader-0.5.7 icon
LavaGang-MelonLoader

The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono

Preferred version: 0.5.7

README

Boneject

A BONELAB mod that provides a basic Ninject implementation and wrapper for use in the game. This can be useful for mods that do a lot of things with a lot of concrete dependencies; Ninject can manage those for you.

This project is still in active development, there are not as many locations as there could be. More will be added in time or as I need them. If you'd like to use Boneject in a location that it currently does not support, please DM me on Discord (Millzy#8418) and I can add it for you. Or if you prefer, open a PR to add it in on the GitHub repository.

This is installed, do I need it?

Probably! For the mods that do implement this, it will most likely be essential.

For Contributors

  1. Clone the project from the GitHub repository.
  2. Open Boneject.sln in your favourite IDE.
  3. Create a copy of Boneject.csproj.user.template and remove the .template suffix.
  4. In the same file, replace the comment between the <BonelabDir> tags with your BONELAB installation path. This will let Boneject build with your game's assemblies.
  5. Save the file.
  6. Make sure Ninject has been downloaded from Nuget.
  7. All set!

For Developers

If you are considering implementing Boneject in to your mod, by all means, give it a go! I found that after using a Dependency Injection framework for modding Unity games (at the time Zenject in BeatSaber) it is very tricky to go back afterwards.

Read the wiki to get started.

Credits

  • Auros - For creating SiraUtil, the inspiration for this project.
  • Danike - For creating BSIPA and it's Mod Init Injection system, that part of this project is based on.

CHANGELOG

v2.0.0

  • Removed MelonLoader and Ninject namespaces.
  • Removed VoidG114 context.
  • Added SceneBootstrapper context.

v1.2.0

  • Context is now dependent on the "host game object" rather than the current scene, modules and bindings will only unload when they should.
  • Fixed mod init injection breaking when trying to inject into two or more dependents.
  • Fixed incorrect ID.
  • Fixed issues caused by trying to load/bind and/or unload/unbind modules and bindings using bad indexing and comparisons (in other words, should be actually stable now)
  • Removed source generators.
  • Refactored codebase for readability and better practices.

v1.1.0

  • BuildInfo is now handled via properties in the (Boneject.csproj) project file and source generation.
  • Made Context.VoidG114 obsolete, since its basically useless. Will be removed in the next major.
  • Added the Context.VoidG114Menu, and the related base module and patch for the context.
  • Added the Context.Menu context, which is the result of the bitwise OR operation of Context.Startup and Context.VoidG114Menu.
  • SLZ.Bonelab.FadeAndDisableVolume is automatically bound to the Startup and VoidG114Menu modules.
  • Fixed uncaught KeyNotFoundException thrown when Boneject attempts to unload/unbind "non-preserved" modules/bindings.

v1.0.1

  • Gets bindings to register using an expression based method rather than a reflection based one. (should be faster)
  • Bindings are only bound to the active scene when loaded. (unless loading screens mess this up)
  • Ninject now fully handles mod init injection. (again, speed)

v1.0.0

  • Complete rewrite.
  • Added the capability for mods to have dependencies injected into their entrypoints at OnMelonInitialize, through the use of the InjectableMelonMod class and the Initialize attribute. "Mod Initialization Dependencies" can be added using the ModInitInjector.AddInjector() static method.
  • Re-arranged extension methods.
  • Entrypoints: App, Loading, Hub, Campaign, Player, Startup, VoidG114 all implemented.
  • Better module installation system.
  • Load instructions.
  • Proper documentation.

v0.3.0

  • Removed AsComponentOnNewGameObject<T> and AsComponentOnExistingGameObject<T> extension methods due to Ninject not injecting into constant bindings and not being able to access the Kernel to fix it.
  • Added BindComponentOnNewGameObject<T> and BindComponentOnExistingGameObject<T> extension methods to replace the aforementioned.

v0.2.0

  • Removed App location and its associated ModuleLoader and HarmonyPatch. This is due to the behaviour being different than desired. GlobalDependencies must now be added manually using the GlobalDependencies static class. Ninject can still handle their creation however.
  • Added a Game location, that should load in every level, except the two main menu levels. An instance of BonelabGameControl is automatically loaded into the Ninject Kernel before the modules are loaded.
  • Added a Loading location, its the loading screen basically. An instance of LoadingScene is automatically loaded into the Ninject Kernel before modules are loaded.
  • Added more logging messages.
  • Made it so that instances of the Ninject Kernel are limited to one per scene (in theory). Should help with compatibility with some future things.
  • Fixed a bug (logic error) where the Ninject Kernel would only be initialized when modules are loaded, preventing "automatically bound dependencies" from actually being bound to the Ninject Kernel.
  • Fixed a bug (another logic error) where global dependencies that are created by Ninject would not be updated in the global dependency dictionary. This may have been the problem causing the first issue, I can add the App location back if requested.

v0.1.0

  • Initial Release.