Version License Discord QQ

# Auto Injections for [DragonECS](https://github.com/DCFApixels/DragonECS) | Languages: | [Русский](https://github.com/DCFApixels/DragonECS-AutoInjections/blob/main/README-RU.md) | [English(WIP)](https://github.com/DCFApixels/DragonECS-AutoInjections) | | :--- | :--- | :--- | The extension is designed to reduce the amount of code by simplifying dependency injection by doing injections automatically. > **NOTICE:** The project is a work in progress, API may change. > While the English version of the README is incomplete, you can view the [Russian version](https://github.com/DCFApixels/DragonECS-AutoInjections/blob/main/README-RU.md).
# Installation Versioning semantics - [Open](https://gist.github.com/DCFApixels/e53281d4628b19fe5278f3e77a7da9e8#file-dcfapixels_versioning_ru-md) ## Environment Requirements: + Dependency: [DragonECS](https://github.com/DCFApixels/DragonECS) + Minimum version of C# 7.3; Optional: + Game engines with C#: Unity, Godot, MonoGame, etc. Tested with: + **Unity:** Minimum version 2020.1.0; ## Unity Installation * ### Unity Package The framework can be installed as a Unity package by adding the Git URL [in the PackageManager](https://docs.unity3d.com/2023.2/Documentation/Manual/upm-ui-giturl.html) or manually adding it to `Packages/manifest.json`: ``` https://github.com/DCFApixels/DragonECS-AutoInjections.git ``` * ### Source Code The framework can also be added to the project as source code.
# Code Example ```csharp class VelocitySystemDI : IEcsRun { class Aspect : EcsAspectAuto { [ExcImplicit(typeof(FreezedTag))] [Inc] public EcsPool poses; [Inc] public EcsPool velocities; } [EcsInject] EcsDefaultWorld _world; [EcsInject] TimeService _time; public void Run() { foreach (var e in _world.Where(out Aspect a)) { a.poses.Get(e).position += a.velocities.Read(e).value * _time.DeltaTime; } } } ```
Same code but without AutoInjections ```csharp class VelocitySystem : IEcsRun, IEcsInject, IEcsInject { class Aspect : EcsAspect { public EcsPool poses; public EcsPool velocities; public Aspect(Builder b) { b.Exclude(); poses = b.Include(); velocities = b.Include(); } } EcsDefaultWorld _world; TimeService _time; public void Inject(EcsDefaultWorld obj) => _world = obj; public void Inject(TimeService obj) => _time = obj; public void Run() { foreach (var e in _world.Where(out Aspect a)) { a.poses.Get(e).position += a.velocities.Read(e).value * _time.DeltaTime; } } } ```