Repository navigation
0.7.1-pre
Pre-releaseyip! fennecs is now faster, tidier, and a little stricter. This pre-release re-encodes Entities around a 32-bit hot path with EntityRef, introduces Aspects, makes relations World-local, and teaches Remove<T> to use Wildcards.
⚠️ Breaking Changes
- Runner delegates pass
in EntityRefinstead ofin Entity. Implicitly typed (C# 14 or later) lambdas compile unchanged; explicitly typed ones need(in Entity e, ...)→(in EntityRef e, ...). - Cross-world relations throw
InvalidOperationExceptionat creation. EntitySpawneris nowEntityTemplate(World.Template());World.Entity()is obsolete.AddConflictandRemoveConflictmoved to thefennecsroot namespace - they now apply beyond Batches:Batch.AddConflict.Replace→AddConflict.Replace.- .NET 10 is the sole target framework.
🐾 32-bit Entity Hot Path & EntityRef
Archetypes now store a 32-bit entity index per row instead of the full 64-bit handle - half the memory bandwidth when iterating. Runners hand you an EntityRef: a ref struct pointing at the Entity's row, guaranteed alive, so Ref<C>, Has<C>, Add, Remove, and Despawn skip liveness checks and hit Archetype storage directly. It can't be stored or captured - converting to Entity (implicit) is the "keep me" operation.
stream.For((in entity, ref position, ref velocity) => // entity is an EntityRef
{
position.value += velocity.value * deltaTime;
if (position.value.Y < 0) entity.Despawn(); // deferred, as before
survivors.Add(entity); // implicit conversion to Entity
});Using a dead Entity now throws with a precise diagnosis (wrong World, already despawned, forged handle, ...). New limits: 2³⁰ Entities per World, 255 Worlds, 65,535 generations per index, 4,094 Component types.
🗄️ Aspects
An Aspect is a self-contained set of Archetypes within a World - its own contiguous component memory universe. The same Entity can have components stored across several Aspects, collapsing archetype fragmentation. Every World has World.Main, and delegates its whole query surface to it - existing code runs unchanged.
Visuals = AddAspect("visuals").Owns<Position>().Owns<Velocity>();
Game = AddAspect("game").Owns<CrewData>();
var entity = world.Spawn()
.Add(new Position(1, 2)) // stored in "visuals"
.Add(new CrewData(3)); // stored in "game"Queries stay within one Aspect (that's the point); reach across with entity.Ref<T>() inside the loop. Unowned types route to Main; ownership freezes at first use; StrictAspects = true makes ownership mandatory. Despawns and relation cleanup cascade across all Aspects. Profile first - Main is plenty for most games.
🌍 Relations are World-local
Creating a relation targeting an Entity from another World now throws at the call site - at every choke point (Add, Ensure, Batches, Templates), even in Deferred mode. Cross-world relations could never be cleaned up correctly; reads stay forgiving (Has<T>(foreignEntity) returns false). Use Aspects to segregate domains instead.
🃏 Remove<T>(Match) - Wildcards for Component Removal
Wildcard-aware removal on Entity, EntityRef, Batch, EntityTemplate, and Query:
entity.Remove<Owes>(Entity.Any); // all Owes relations, to anyone
entity.Remove<Bank>(Link.Any); // all Bank object links
entity.Remove<Owes>(Match.Target); // relations AND links (keeps plain)
entity.Remove<Owes>(Match.Any); // everything Owes
query.Batch().Remove<Attacking>(Entity.Any).Submit();One structural change no matter how many components are stripped. Throws if nothing matches - or pass RemoveConflict.Allow on Entity/EntityRef for an idempotent no-op instead:
entity.Remove<Owes>(Entity.Any, RemoveConflict.Allow); // debt jubilee, even for the debt-freeBatch conflict detection is wildcard-aware in both directions.
🦊 Also
EntityTemplatebatch spawning - spawns straight into the final Archetype with blitted data (10–100× faster for large batches), allocation-freeSpawn(Span<Entity>), compile-time-checkedNeeds<C>()values.- CRUD perf:
entity.Ref<T>()~40% faster,Has<T>()down to a single hash probe.
Full details in the documentation 🦊