Changes
HPQuery
and HPEQuery
, aswell as their parallel counterparts are now called InlineQuery
, InlineEntityQuery
e.g.
- Removed ref iterators since they are incredible slow and can not be inlined #39
- Proper documentation ( generated code is not documented however ) and code style enforcement.
- Performance improvements
New Features
- Classes can now be used as components :)
- Several new overloads for
Index, GetArray, GetSpan, GetFirst
to improve performance and reduce boilerplate code.
- Non generic set, get, has, add, remove operations for entities.
- Added enumerator for entity inside chunk enumration.
world.CountEntities
to... count entities which will be targeted by a query.
Non generic entity interaction :
var transform = (object)new Transform { X = 10, Y = 10 };
_entity.Set(transform);
var tramsformReference = (Transform)_entity.Get(typeof(Transform));
// Non generic additional methods
_entity.SetRange(...);
_entity.Has(...);
_entity.HasRange(...);
_entity.Get(...);
_entity.GetRange(...);
_entity.Add(...);
_entity.AddRange(...);
_entity.Remove(...);
_entity.RemoveRange(....);
Overloads for chunk & Chunk enumeration :
foreach (var chunk in _world.Query(in _queryDescription).GetChunkIterator())
{
var refs = chunk.GetFirst<Transform, Velocity>(); // or chunk.GetSpan<Transform, Velocity>(out var trans, out var velos);
foreach (var entity in chunk) // New iteration, automatically iterates backwards over all valid chunk entities.
{
ref var pos = ref Unsafe.Add(ref refs.t0, entity);
ref var vel = ref Unsafe.Add(ref refs.t1, entity);
pos.X += vel.X;
pos.Y += vel.Y;
}
}