From 431f0b873ca8ee1abb60806e258a1f3668002cc4 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Sun, 29 Mar 2026 01:49:14 +0800 Subject: [PATCH] update readme --- README-RU.md | 14 ++++++------ README.md | 60 +++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 57 insertions(+), 17 deletions(-) diff --git a/README-RU.md b/README-RU.md index ffd539d..b7d9b36 100644 --- a/README-RU.md +++ b/README-RU.md @@ -81,7 +81,7 @@ https://github.com/DCFApixels/DragonECS-AutoInjections.git # Интеграция Добавьте вызов метода `AutoInject()` для Builder-а пайплайна. Пример: -```csharp +```c# _pipeline = EcsPipeline.New() .Inject(world) .Inject(_timeService) @@ -99,11 +99,11 @@ _pipeline = EcsPipeline.New() # Инъекция зависимостей Атрибут `[DI]` заменяет интерфейс `IEcsInject`, Поля, отмеченные этим атрибутом, автоматически получают зависимости, внедрённые в Pipeline. Пример: -```csharp +```c# [DI] EcsDefaultWorld _world; ``` Так же можно делать внедрение через свойство или метод: -```csharp +```c# EcsDefaultWorld _world; //Обязательно наличие set блока. @@ -137,7 +137,7 @@ EcsDefaultWorld _world; # Auto Runner-ы Для получения раннеров без добавления, есть атрибут `[BindWithRunner(type)]` и метод `GetRunnerAuto()`. -``` c# +```c# [BindWithRunner(typeof(DoSomethingProcessRunner))] interface IDoSomethingProcess : IEcsProcess { @@ -161,7 +161,7 @@ _pipeline.GetRunnerAuto().Do(); # Пример кода -```csharp +```c# class VelocitySystemDI : IEcsRun { class Aspect : EcsAspectAuto @@ -189,7 +189,7 @@ class VelocitySystemDI : IEcsRun
Тот же код но без AutoInjections -```csharp +```c# class VelocitySystem : IEcsRun, IEcsInject, IEcsInject { class Aspect : EcsAspect @@ -226,7 +226,7 @@ class VelocitySystem : IEcsRun, IEcsInject, IEcsInject Переданный тип должен иметь конструктор без параметров и быть либо того же типа, что и поле, либо производным от него. diff --git a/README.md b/README.md index 787e618..c6d9475 100644 --- a/README.md +++ b/README.md @@ -45,31 +45,71 @@ The extension is designed to reduce the amount of code by simplifying dependency
# Installation -Versioning semantics - [Open](https://gist.github.com/DCFApixels/e53281d4628b19fe5278f3e77a7da9e8#file-dcfapixels_versioning_ru-md) +Versioning semantics - [Open](https://gist.github.com/DCFApixels/af79284955bf40e9476cdcac79d7b098#file-dcfapixels_versioning-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. - +* Game engines with C#: Unity, Godot, MonoGame, etc. + Tested with: -+ **Unity:** Minimum version 2020.1.0; +* **Unity:** Minimum version 2021.2.0. ## Unity Installation * ### Unity Package -The package 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`: +The package supports installation as a Unity package by adding the Git URL [in the PackageManager](https://docs.unity3d.com/2023.2/Documentation/Manual/upm-ui-giturl.html): ``` https://github.com/DCFApixels/DragonECS-AutoInjections.git ``` +Or add the package entry to `Packages/manifest.json`: +``` +"com.dcfa_pixels.dragonecs-auto_injections": "https://github.com/DCFApixels/DragonECS-AutoInjections.git", +``` + * ### Source Code -The package can also be added to the project as source code. +The package source code can also be copied directly into the project. +
+# Integration +Add the AutoInject() call to the pipeline Builder. Example: +```c# +_pipeline = EcsPipeline.New() + .Inject(world) + .Inject(_timeService) + .Add(new TestSystem()) + .Add(new VelocitySystem()) + .Add(new ViewSystem()) + .AutoInject() // Done — automatic injections enabled + .BuildAndInit(); +``` + +> [!IMPORTANT] +> Ensure AutoInject() is called during initialization; otherwise nothing will work. + +# Dependency Injection +The `[DI]` attribute replaces the `IEcsInject` interface. Fields marked with this attribute automatically receive dependencies injected into the pipeline. Example: +```c# +[DI] EcsDefaultWorld _world; +``` +Injection can also be done via a property or method: +```c# +EcsDefaultWorld _world; + +//Обязательно наличие set блока. +[DI] EcsDefaultWorld World { set => _world = value; } + +//Количество аргументов должно быть равно 1. +[DI] void InjectWorld(EcsDefaultWorld world) => _world = world; +``` + +> Aggressive injection (without the `[DI]` attribute) is enabled by calling `.AutoInject(true)`. + # Code Example -```csharp +```c# class VelocitySystemDI : IEcsRun { class Aspect : EcsAspectAuto @@ -79,8 +119,8 @@ class VelocitySystemDI : IEcsRun [Inc] public EcsPool velocities; } - [EcsInject] EcsDefaultWorld _world; - [EcsInject] TimeService _time; + [DI] EcsDefaultWorld _world; + [DI] TimeService _time; public void Run() { @@ -94,7 +134,7 @@ class VelocitySystemDI : IEcsRun
Same code but without AutoInjections -```csharp +```c# class VelocitySystem : IEcsRun, IEcsInject, IEcsInject { class Aspect : EcsAspect