8000 Components pulled from const entities are invalid · Issue #95 · alecthomas/entityx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Components pulled from const entities are invalid #95
Closed
@notlion

Description

@notlion

I noticed this when updating my code from 9e4314e. When entity.component() is called on a const Entity it looks like a new template instantiation is being created for the const version of the component. This causes the function to return an invalid ComponentHandle. I'm assuming this is a bug and not by design, since I expect you'd just want to return a const ComponentHandle<Component> in this case, not a ComponentHandle<const Component>.

I wrote a test to make sure this wasn't just happening in my own app:

TEST_CASE_METHOD(EntityManagerFixture, "TestConstComponentsNotInstantiatedTwice") {
  Entity a = em.create();
  a.assign<Position>(1, 2);

  const Entity b = a;

  REQUIRE(a.component<Position>().valid());
  REQUIRE(b.component<Position>().valid());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0