Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

SimpleECS

> 编程语言
Open source

Probably the simplest to use ECS for C#

99 stars0 likes1 views
WebsiteGitHub

About

Probably the simplest to use ECS for C#

SimpleECS

A Simple and easy to use C# Entity Component System. Min C# Framework 4.7

Features:

  • No Dependencies, just build or drop in however you want
  • No setup or boilerplate like marking components or code generators
  • Archetype based = fast component iteration
  • Very simple and easy to use queries

Warning - This project is a very much a hobby project to learn more about ECS. Because of this, breaking API changes may occur as I tinker on the framework.

Entities

An Entity is simply an ID that associates a group of components together. To create an entity you first need to create a new world, then using that world create your entity with it's components as arguments.

…

Anything that can be put into a list can be a component. Only one component of each type can be associated with an entity, however there's nothing stopping you having a List or array as a component. Setting more than one component of the same type will simply overwrite the old one. The function can take up to 32 components, but entities themselves have no component limit. Due to how entities are structured, it's more efficient to set all components upfront during creation than adding them one at a time with entity.Set().

Manipulating entities is pretty simple

…

Component Callbacks

There are 2 component callbacks in SimpleECS, world.OnSet() and world.OnRemove().

OnSet

OnSet is invoked anytime a valid entity uses entity.Set(value). OnSet is also invoked on all components added during entity creation with world.CreateEntity(). OnSet is not invoked on the defaulted components created during archetype.CreateEntity(). On set has 3 overloads depending on how much information you need during the callback.

…

OnRemove

OnRemove is invoked anytime a valid entity removes that component. OnRemove is also invoked when an entity with that component is destroyed. OnRemove has 2 overloads depending on how much information you need during the callback.

csharp
// the callback is invoked whenever an entity in the world with the component removes the component or is destroyed
world.OnRemove((int val) => 
    Console.WriteLine($"an entity removed int {val}"));

// put the entity as the first paramter to get the invoking entity
world.OnRemove((Entity e, int val) => 
    Console.WriteLine($"{e} removed int {val}");
    
// like OnSet, OnRemove can be named and registered and unregistered
void IntRemoveCallback(int value)
{
    // do something
}

world.OnRemove(IntRemoveCallback);
world.OnRemove(IntRemoveCallback, false);

Queries

Queries let you iterate over entities based on specified components. You can specify up to 12 components to iterate over. Queries cache their results and only update when new archetypes are created or destroyed or their filter changes.

…

During query.Foreach, functions that cause structural changes to the ECS are cached and applied after iteration is complete. This is to prevent iterator invalidation. Some functions that cause structural changes are:

  • entity.Set()
  • entity.Remove()
  • entity.Transfer()
  • entity.Destroy()
  • archetype.CreateEntity()
  • archetype.Destroy()
  • world.CreateEntity()
  • world.Destroy()

Entities created during query.Foreach() will be invalid during the function. However you can still set or remove components on that entity, they will simply be applied when the Foreach function completes.

…

For maximum control over query iteration or a small performance boost, manual iteration is possible. When iterating manually though, make sure not to do any structural changes as this may invalidate iterators.

…

World

The world class is what manages all the underlying archetypes and their entities.

…

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#ecsentity-componententity-systemsgames

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言