From 7b395cc422e466759a83a37f3e3d960755e60cf4 Mon Sep 17 00:00:00 2001 From: Gad Wissberg Date: Tue, 27 Aug 2024 21:53:26 +0300 Subject: [PATCH] Added getters for the free objects in the pooled engine. --- .../badlogic/ashley/core/PooledEngine.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ashley/src/com/badlogic/ashley/core/PooledEngine.java b/ashley/src/com/badlogic/ashley/core/PooledEngine.java index 9269b01..0113837 100644 --- a/ashley/src/com/badlogic/ashley/core/PooledEngine.java +++ b/ashley/src/com/badlogic/ashley/core/PooledEngine.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2014 See AUTHORS file. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -85,6 +85,20 @@ public void clearPools () { componentPools.clear(); } + /** + * @return Number of free objects in the entity pool. + */ + public int getEntityPoolFree( ) { + return entityPool.getFree(); + } + + /** + * @return Number of free objects in the given component type pool. + */ + public int getComponentPoolFree(Class componentType) { + return componentPools.pools.get(componentType).getFree(); + } + @Override protected void removeEntityInternal (Entity entity) { super.removeEntityInternal(entity);