# Features

### Integration

Friflo.Engine.ECS enables you integration in any C# based Game Engine and any .NET enterprise application.

* **Unity** - ![new](/files/9tfDroSDsN7NRy9Lehwt) - Integration as nuget package. Tested 2022.3.20f1 (Mono & AOT/IL2CPP).\
  Use [NuGetForUnity](https://github.com/GlitchEnzo/NuGetForUnity) to install nuget package **Friflo.Engine.ECS**. 1.23.0 or higher. Usage in [Unity script example](broken://pages/mKN9gkyqTTaqm8A5amZs#unity-update-script).
* **.NET** - Supported target frameworks: **.NET Standard 2.1 .NET 5 .NET 6 .NET 7 .NET 8**. Supports **WASM / WebAssembly**.\
  Integration into a .NET project as nuget package see [nuget ⋅ Friflo.Engine.ECS](https://www.nuget.org/packages/Friflo.Engine.ECS/).
* **Godot** - Integration as nuget package. Tested with Godot 4.1.1.

### Performance

You want best ECS performance?\
You get it! 😊\
Without using unsafe code! 🔒

E.g Creating 1.000.000 entities with two components: 13 ms.\
Best ECS C++ implementation **pico\_ecs**: 45 ms\
See: [C++ ECS Benchmarks ⋅ Create Entities](https://github.com/abeimler/ecs_benchmark?tab=readme-ov-file#create-entities)

* Uses array buffers and cache query instances -> no memory allocations after buffers are large enough.
* High memory locality by storing components in continuous memory.
* Optimized for high L1 cache line hit rate.
* Best benchmark results at: [**Ecs.CSharp.Benchmark - GitHub**](https://github.com/Doraku/Ecs.CSharp.Benchmark).
* Processing components of large queries has the memory bandwidth as bottleneck. Either using multi threading or SIMD.\
  Alternative ECS implementations using C/C++, Rust, Zig or Mojo 🔥 cannot be faster due to the physical limits.

### ECS

* Developer friendly / OOP like API by exposing the [Entity API](https://github.com/friflo/Friflo.Engine-docs/blob/main/api/Entity.md) **struct** as the main interface.\
  Or compare the `Entity` API with other API's at [Engine-comparison.md](https://github.com/friflo/Friflo.Engine.ECS/blob/main/docs/Engine-comparison.md).\
  The typical alternative of an ECS implementations is providing a `World` class and using `int` parameters as entity `id`s.
* Record entity changes on arbitrary threads using [CommandBuffer](https://github.com/friflo/Friflo.Engine-docs/blob/main/api/CommandBuffer.md)'s.
* Build a **hierarchy of entities** typically used in Games and Game Editors.
* Support **multi threaded** component queries (systems).
* Support for **Vectorization (SIMD)** of components returned by queries.\
  Returned component arrays have padding elements at the end to enable SIMD processing without a [scalar remainder (epilogue) loop](https://llvm.org/docs/Vectorizers.html#epilogue-vectorization).\
  It is preferred over multi threading as it uses only one core providing the same performance as multi threading running on all cores.
* Minimize times required for GC collection by using struct types for entities and components.\
  GC.Collect(1) < 0.8 ms when using 10.000.000 entities.
* Support **tagging** of entities and use them as a filter in queries.
* Add scripts - similar to `MonoBehavior`'s - to entities in cases OOP is preferred.
* Support **observing entity changes** by event handlers triggered by adding / removing: components, tags, scripts and child entities.
* Reliability - no undefined behavior with only one exception:\
  Performing structural changes - adding/removing components/tags - while iterating a query result.\
  The solution is buffering structural changes with a CommandBuffer.

### Other

* Enable binding an entity hierarchy to a [TreeDataGrid - GitHub](https://github.com/AvaloniaUI/Avalonia.Controls.TreeDataGrid) in [AvaloniaUI - Website](https://avaloniaui.net/). Screenshot below:\
  ![](https://raw.githubusercontent.com/friflo/Friflo.Json.Fliox/main/Engine/docs/images/Friflo-Engine-Editor.png)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://friflo.gitbook.io/friflo.engine.ecs/project/package/features.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
