- Notifications
You must be signed in to change notification settings - Fork1
A simple, modern ECS built in Odin
License
NotificationsYou must be signed in to change notification settings
NateTheGreatt/YggECS
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
YggECS
is a high-performance Entity Component System (ECS) written in Odin. It implements modern features inspired byFlecs, focusing on speed and simplicity. Some design principles were also used in my TypeScript ECS librarybitECS.
The name is derived from Yggdrasil, the sacred tree of Norse mythology which binds the earth, heaven, and hell together.
🔥 Blazingly fast iteration
🧬 Archetypes with cache-friendly component storage
🔍 Powerful querying with a simple, declarative API
🔗 Relational entity modeling
- Observers
- Relation traversal for queries
- Query variables
- Add/removeComponent optimizations
import ecs"./ecs"Position ::distinct [2]f32Velocity ::distinct [2]f32Health ::distinctintContains ::struct { amount:int }Silver ::distinctstruct {}main ::proc () {using ecs world :=create_world()deferdelete_world(world) entity :=add_entity(world)add_component(world, entity, Position{0,0})add_component(world, entity, Velocity{1,1})add_component(world, entity,Health(100)) gold :=add_entity(world)add_component(world, item,pair(Contains{12}, gold))add_component(world, item,pair(Contains{58}, Silver))for archetypeinquery(world,has(Position),has(Velocity)) { positions :=get_table(world, archetype, Position, [2]f32) velocities :=get_table(world, archetype, Velocity, [2]f32)for eid,iin archetype.entities { positions[i] += velocities[i] } } entities_with_position_not_health :=query(world,has(Position),not(Health)) entities_containing_gold :=query(world,pair(Contains, gold))}