Fixed to meet tests
This commit is contained in:
parent
22a75f5559
commit
0b3553d46e
@ -34,9 +34,11 @@ class ComponentArray{
|
|||||||
*/
|
*/
|
||||||
protected Object getData(int entity){
|
protected Object getData(int entity){
|
||||||
try{
|
try{
|
||||||
Object result = componentArray.get(entityComponentDataMap.get(entity));
|
return componentArray.get(entityComponentDataMap.get(entity));
|
||||||
if (result == null) ECS.writeErr("Attempted to retrieve non-existent data");
|
}
|
||||||
return result;
|
catch (NullPointerException ex){
|
||||||
|
ECS.writeErr("Attempted to retrieve non-existent data");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
catch (IndexOutOfBoundsException e){
|
catch (IndexOutOfBoundsException e){
|
||||||
ECS.writeErr("Index out-of-bounds");
|
ECS.writeErr("Index out-of-bounds");
|
||||||
|
@ -101,7 +101,7 @@ class ComponentManager{
|
|||||||
while (result != -1){
|
while (result != -1){
|
||||||
Type key = indexComponentType.get(result);
|
Type key = indexComponentType.get(result);
|
||||||
componentArrays.get(key).moveData(sourceEntity, destinationEntity);
|
componentArrays.get(key).moveData(sourceEntity, destinationEntity);
|
||||||
sourceRegistrations.nextSetBit(result);
|
result = sourceRegistrations.nextSetBit(result+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,10 @@ class EntityManager{
|
|||||||
entityRegistrations.get(entity).clear(component);
|
entityRegistrations.get(entity).clear(component);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
catch (NullPointerException e){
|
||||||
|
ECS.writeErr("Entity not initialised");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
catch (IndexOutOfBoundsException e)
|
catch (IndexOutOfBoundsException e)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -187,7 +191,6 @@ class EntityManager{
|
|||||||
systemManager.entityRegistrationsChanged(newPos, getRegistrations(newPos));
|
systemManager.entityRegistrationsChanged(newPos, getRegistrations(newPos));
|
||||||
// Invoke the change in the components
|
// Invoke the change in the components
|
||||||
componentManager.moveAllComponentData(integer, newPos, getRegistrations(integer));
|
componentManager.moveAllComponentData(integer, newPos, getRegistrations(integer));
|
||||||
componentManager.entityDestroyed(integer);
|
|
||||||
}
|
}
|
||||||
for (int i = newSize; i < maxSize; i++) {
|
for (int i = newSize; i < maxSize; i++) {
|
||||||
// Remove out-of-bounds data
|
// Remove out-of-bounds data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user