Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Inspiaaa committed Apr 24, 2022
1 parent f92f08f commit 59fac08
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BlitzEcs

BlitzEcs is a lightning-fast, memory-efficient, sparse set based ECS (Entity Component System) framework written in C# for making games. It is bare bones, can be easily integrated into existing systems / games, and can be used side by side with object oriented design to allow for a hybrid approach.
BlitzEcs is a lightning-fast, memory-efficient, sparse set based ECS (Entity Component System) library written in C# for making games. It is bare bones, can be easily integrated into existing systems / games, and can be used side by side with object oriented design to allow for a hybrid approach.

## Why use BlitzEcs?

Expand All @@ -21,13 +21,15 @@ BlitzEcs is a lightning-fast, memory-efficient, sparse set based ECS (Entity Com

- No runtime code generation required (can be used with AOT compilation)

- Sparse set based => adding and removing components is extremely lightweight.

- Pure C# code

- No external dependencies

## Quick overview

#### Importing the framework:
#### Importing BlitzEcs:

```csharp
using BlitzEcs;
Expand Down Expand Up @@ -310,6 +312,37 @@ world.SetDestroyHandler<Transform>(destroyHandler);
world.SetDestroyHandler<Velocity>(destroyHandler);
```

#### Caching queries

To improve the performance of queries you can also cache them. This means that they don't have to fetch a list of entities to iterate over each time, but rather that this list of entities is kept updated. When a component is added / removed, the hot queries (i.e. cached queries) are informed about this change and are automatically updated.

If you have a query, e.g.

```csharp
var query = new Query<Transform, Velocity>(world);
query.Exc<EnemyTeam>();
```

then you can cache it:

```csharp
world.Cache(query);
```

The query can simply be used like a normal query afterwards, e.g.

```csharp
query.ForEach((ref Transform transform, ref Velocity velocity) => {
// ...
});
```

Sometimes you can even reuse the same query instance between multiple systems. The `GetCached` method either caches the query and returns it or returns an already cached query:

```csharp
var query = world.GetCached(new Query<Transform>(world));
```

## Credits

This project is greatly inspired by [Byteron/ecs](https://github.com/Byteron/ecs).

0 comments on commit 59fac08

Please sign in to comment.