Fixed to meet tests

This commit is contained in:
Brychan Dempsey 2021-06-08 21:34:57 +12:00
parent 22a75f5559
commit 0b3553d46e
3 changed files with 10 additions and 5 deletions

View File

@ -34,9 +34,11 @@ class ComponentArray{
*/
protected Object getData(int entity){
try{
Object result = componentArray.get(entityComponentDataMap.get(entity));
if (result == null) ECS.writeErr("Attempted to retrieve non-existent data");
return result;
return componentArray.get(entityComponentDataMap.get(entity));
}
catch (NullPointerException ex){
ECS.writeErr("Attempted to retrieve non-existent data");
return null;
}
catch (IndexOutOfBoundsException e){
ECS.writeErr("Index out-of-bounds");

View File

@ -101,7 +101,7 @@ class ComponentManager{
while (result != -1){
Type key = indexComponentType.get(result);
componentArrays.get(key).moveData(sourceEntity, destinationEntity);
sourceRegistrations.nextSetBit(result);
result = sourceRegistrations.nextSetBit(result+1);
}
}

View File

@ -145,6 +145,10 @@ class EntityManager{
entityRegistrations.get(entity).clear(component);
return true;
}
catch (NullPointerException e){
ECS.writeErr("Entity not initialised");
return false;
}
catch (IndexOutOfBoundsException e)
{
return false;
@ -187,7 +191,6 @@ class EntityManager{
systemManager.entityRegistrationsChanged(newPos, getRegistrations(newPos));
// Invoke the change in the components
componentManager.moveAllComponentData(integer, newPos, getRegistrations(integer));
componentManager.entityDestroyed(integer);
}
for (int i = newSize; i < maxSize; i++) {
// Remove out-of-bounds data