Skip to content

CustomComponentLookups not working with structs? #19

@GetFunctional

Description

@GetFunctional

Hi,

I'm new to your framework and followed your guide from this page ( https://ecsrx.gitbook.io/project/performance/component-type-lookups ).

I created a Module for the Customlookups and added it to my application like this:

 protected override void LoadModules()
  {
        base.LoadModules();
        this.Container.LoadModule(new CustomComponentLookupsModule());
   }

When adding a component, that is a struct and was registered in the dictionary, to an entity via Blueprint I get an exception:

System.InvalidCastException
HResult=0x80004002
Message=Unable to cast object of type 'EcsRx.Components.ComponentPool1[GF.FriendsInSpace.Core.Components.EntityIdComponent]' to type 'EcsRx.Components.IComponentPool1[EcsRx.Components.IComponent]'.
Source=EcsRx
StackTrace:
at EcsRx.Components.Database.ComponentDatabase.GetPoolFor[T](Int32 componentTypeId)
at EcsRx.Components.Database.ComponentDatabase.Set[T](Int32 componentTypeId, Int32 allocationIndex, T component)
at EcsRx.Entities.Entity.AddComponents(IReadOnlyList`1 components)
at EcsRx.Extensions.IEntityExtensions.AddComponents(IEntity entity, IComponent[] components)

I can work around this when replacing the struct with a class. But it would be great if you could make it work again or if I made a mistake maybe you can offer a solution :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions