libgdx / ashley

A Java entity system inspired by Ash & Artemis.
Apache License 2.0
875 stars 144 forks source link

Unable to access hasComponent method on Entity #290

Closed Blunderchips closed 4 years ago

Blunderchips commented 4 years ago

Access on hasComponent method on Entity class has been left as default (protected) leaving it inaccessible. There is no reason for this method to be protected as it is already directly accessible using a ComponentMapper.

I require a quick and easy way to determine whether a given Entity has a certain Component(s) without needing to declare a new ComponentMappers for the sole purpose of calling hasComponent.

Ashley version: 1.8.2

mgsx-dev commented 4 years ago

hasComponent takes a ComponentType object as argument, not a Component class. And open this method would bypass component mapper concept (which is recommended for good performance). what you can do is : entity.getComponent(...) != null which cover your use case.

Blunderchips commented 4 years ago

Ok, thank you