Tests added, some function changes

Functions changed to return booleans
This commit is contained in:
Brychan Dempsey 2021-06-08 17:08:47 +12:00
parent b1efb9802d
commit 23abf57b6e

View File

@ -17,13 +17,14 @@ class ComponentManager{
Map<Type, Integer> componentPosIndex = new HashMap<>(); Map<Type, Integer> componentPosIndex = new HashMap<>();
int componentPos = 0; int componentPos = 0;
public void registerComponent(Type type){ public boolean registerComponent(Type type){
if (componentArrays.containsKey(type)){ if (componentArrays.containsKey(type)){
System.err.println("Component " + type.getTypeName() + " is already registered"); ECS.writeErr("Component " + type.getTypeName() + " is already registered");
return; return false;
} }
componentArrays.put(type, new ComponentArray()); componentArrays.put(type, new ComponentArray());
componentPosIndex.put(type, componentPos++); componentPosIndex.put(type, componentPos++);
return true;
} }
public void addComponentToEntity(Type componentName, Object componentData, int entity){ public void addComponentToEntity(Type componentName, Object componentData, int entity){