friflo/Friflo.Engine.ECS

Indexed component not found when adding component through EntityStore.CreateEntity

dvdking opened this issue · 3 comments

This test fails

    [Test]
    public static void Test_Index_ValueStructIndex()
    {
        var store   = new EntityStore();
        store.CreateEntity(new IndexedInt { value = 123 });
        
        var result = store.GetEntitiesWithComponentValue<IndexedInt, int>(123);
        AreEqual(1, result.Count);
    }

This does not fail

        var store   = new EntityStore();
        var entity1 = store.CreateEntity();
        entity1.AddComponent(new IndexedInt { value = 123 });
        var result = store.GetEntitiesWithComponentValue<IndexedInt, int>(123);
        AreEqual(1, result.Count);

batches fail too

        var store   = new EntityStore();
        var entity1 = store.CreateEntity();
        
        entity1.Batch().Add(new IndexedInt { value = 123 }).Apply();
        var result = store.GetEntitiesWithComponentValue<IndexedInt, int>(123);
        AreEqual(1, result.Count);

hey @dvdking

somebody tries this crazy stuff 👍🏼.
This is currently a known issue for all new Component Types.

That is the reason why these new types are only available in 3.0.0-preview releases.
Right now: AddComponent<>() and RemoveComponent<>() must be used.

I have to make adjustments in all extension methods in EntityExtensions and EntityStoreExtensions used in your first test.

Same for EntityBatch and CreateEntityBatch methods used in your last test.
Without your post I guess I would have missed those two for the final release.

Also the CommandBuffer needs adjustments.

thx for feedback!

Hi. Any news about supporting Indexed Components using CommandBuffers and EntityBatch ?