Skip to content

Commit b91557e

Browse files
committed
add count method
1 parent 31d15c5 commit b91557e

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/main/java/com/github/elebras1/flecs/World.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,21 @@ public long getComponentId(Class<?> componentClass) {
331331
return this.componentRegistry.getComponentId(componentClass);
332332
}
333333

334+
public int count(long componentId) {
335+
this.checkDestroyed();
336+
return flecs_h.ecs_count_id(this.worldSeg, componentId);
337+
}
338+
339+
public int count(Entity entity) {
340+
return count(entity.id());
341+
}
342+
343+
public int count(Class<?> componentClass) {
344+
this.checkDestroyed();
345+
long componentId = this.componentRegistry.getComponentId(componentClass);
346+
return flecs_h.ecs_count_id(this.worldSeg, componentId);
347+
}
348+
334349
public void deleteWith(Class<?> componentClass) {
335350
this.checkDestroyed();
336351
long componentId = this.componentRegistry.getComponentId(componentClass);

0 commit comments

Comments
 (0)