Beispiel #1
0
  public Facet removeComponent(int entity, Facet component) {
    Facet result = null;

    if (0 < entity && null != component && life.isActive()) {
      synchronized (linkLock) {
        result = entityComponentLinks.get(entity).remove(component.getClass());
      }
    }

    return result;
  }
Beispiel #2
0
  public Facet linkComponent(int entity, Facet component) {
    Facet result = null;

    if (0 < entity && null != component && life.isActive()) {
      // Validate

      synchronized (linkLock) {
        Map<Class<? extends Facet>, Facet> entityComponents = entityComponentLinks.get(entity);

        if (entityComponents == null) {
          entityComponents = new HashMap<>(16);
          entityComponentLinks.put(entity, entityComponents);
        }

        result = entityComponents.put(component.getClass(), component);
      }
    }

    return result;
  }