A high performance, low memory usage, archetyped based EC framework/ECS library for C#.
Whaaaat?! Aren't there enough ECS libraries out there!
While Frent's implementation is an archetype based ECS, thats not why Frent was made. Frent is primarily an EC framework - Entity Component framework - that allows you to easily use composition for code reuse rather than inheritance with minimal boilerplate. Write components that include behavior, lifetime management, and events while enjoying all the performance benefits of an ECS.
Want to write systems anyways? Frent also has a Systems API that allows you to query entities in the style of an ECS.
Caution
Frent is still in beta and is not completely stable.
using Frent;
using Frent.Systems;
using Frent.Components;
using System.Numerics;
using World world = new World();
Entity entity = world.Create<Position, Velocity>(new(Vector2.Zero), new(Vector2.One));
//Call Update to run the update functions of your components
world.Update();
// Position is (1, 1)
Console.WriteLine(entity.Get<Position>());
// Alternatively, use a system
world.Query<Position, Velocity>()
.Delegate((ref Position p, ref Velocity v) => p.Value += v.Delta);
record struct Position(Vector2 Value);
record struct Velocity(Vector2 Delta) : IInitable, IComponent<Position>
{
// There is also IDestroyable
public void Init(Entity self) { }
public void Update(ref Position position) => position.Value += Delta;
}
Wanna learn more? Check out the docs!
There is also samples for Monogame, Unity and Godot.
Frent is a lot faster than most C# ECS implementations - Benchmark.
- Tiny entity struct the size of 8 bytes
- Up to 127 components per entity
-
struct
&class
as components - Pass in uniform data automatically e.g.,
deltaTime
- AOT Compatible & Zero reflection
- Non-Generic APIs
- Tags
- Command buffer
- Events on entity creation/deletion, component add/remove
- Automatic structual change management
-
EntityMarshal
andWorldMarshal
for even faster speeds! - Bulk operations
- Multithreading
- Comprehensive docs
- 100% Test coverage
- More samples, examples, & explanations!
Wanna help?
Report bugs, suggest APIs, and give general feedback. Just open an issue before starting a large feature.