Krill 1.3.0
dotnet add package Krill --version 1.3.0
NuGet\Install-Package Krill -Version 1.3.0
<PackageReference Include="Krill" Version="1.3.0" />
<PackageVersion Include="Krill" Version="1.3.0" />
<PackageReference Include="Krill" />
paket add Krill --version 1.3.0
#r "nuget: Krill, 1.3.0"
#:package Krill@1.3.0
#addin nuget:?package=Krill&version=1.3.0
#tool nuget:?package=Krill&version=1.3.0
Krill
A zero-dependency, engine-agnostic, struct-based Entity-Component-System (ECS) for .NET.
Krill stores components in chunked, contiguous arrays. It offers generated overloads for up to four components. The hot loops iterate only the live slot range of each chunk.
Install
dotnet add package Krill
Krill targets net8.0 and has no dependencies.
Quick start
Define components as structs that implement IDataComponent.
using Krill;
public struct Position : IDataComponent
{
public float X;
public float Y;
}
public struct Velocity : IDataComponent
{
public float X;
public float Y;
}
Write a system. The system reads and writes components through a DataStore.
public sealed class MoveSystem : IEntitySystem
{
public void Tick(float delta, DataStore store)
{
store.QueryRef<Position, Velocity>(delta,
static (float dt, DataStore store, int entity,
ref Ref<Position> position, in Velocity velocity) =>
{
position.Write.X += velocity.X * dt;
position.Write.Y += velocity.Y * dt;
});
}
}
Create a world, add the system, and tick the world.
var world = new World();
world.AddSystem(new MoveSystem());
Entity entity = world.NewEntity();
entity.AddOrUpdate(new Position(), new Velocity { X = 10f, Y = 0f });
world.Tick(0.016f);
Main types
| Type | Role |
|---|---|
World |
Holds a DataStore and a set of systems. Tick runs the systems in order. |
DataStore |
Allocates entities and stores components in chunks. |
Entity |
A lightweight handle. It holds an entity id and its store. |
Uuid |
A stable identifier for an entity. It survives save and load. |
IDataComponent |
Marks a struct as a component. |
IEntitySystem |
A system. Tick receives the delta time and the store. |
Ref<T> |
A component reference. Write marks the component dirty. |
Queries
DataStore generates these query families for arity 1 to 4:
| Method | Purpose |
|---|---|
Query |
Read every matching entity. |
QueryRef |
Read and write every matching entity. |
QueryDirty |
Read entities with dirty components. |
QueryRefDirty |
Read and write entities with dirty components. |
QueryRemoved |
Read the last known data of removed components. |
QueryParallel |
Read with Parallel.For for large sets. |
QueryDirtyParallel |
Dirty variant of QueryParallel. |
Each family has a delegate overload and a struct-action overload. Use the struct-action overload in hot paths. It avoids a delegate allocation and lets the JIT inline the call.
The source generator that builds these APIs runs at build time. The generated
members are compiled into Krill.dll. Consumers do not need the generator.
Entity operations
Entity and DataStore expose generated overloads for 1 to 4 components:
entity.Add<Position>();
entity.AddOrUpdate(new Position { X = 1f }, new Velocity { Y = 2f });
entity.Remove<Velocity>();
bool has = entity.Has<Position>();
bool found = entity.TryGet(out Position position);
DataStore also offers non-generic operations by Type, a Find predicate
search, and dirty-state access through IsDirty, MarkDirty, and
ClearDirty.
Benchmarks
The benchmarks live in Krill.Benchmarks in the Swordfish Engine repository.
They cover query iteration and system ticks with BenchmarkDotNet.
License
Apache-2.0. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.3.0 | 99 | 11/20/2026 |