Exemplo n.º 1
0
 public <T extends SceneNodeComponent> void removeComponent(Class<T> componentType) {
   int typeId = ComponentType.findType(componentType);
   SceneNodeComponent component = _components.get(ComponentType.findBaseType(typeId));
   if (component != null && isSubtype(typeId, component.componentType)) {
     component.destroy();
   }
 }
Exemplo n.º 2
0
  public String appendDiagnostics(StringBuilder builder) {
    builder.append("\t");
    if (!isActive()) {
      builder.append("*");
    }
    builder.append(name == null ? "-" : name);

    builder.append("\n\tComponents [");
    for (SceneNodeComponent component : components) {
      builder.append("\n\t\t");
      if (!component.isActive()) {
        builder.append("*");
      }
      builder.append(component.getClass().getSimpleName());
    }
    builder.append("]");

    builder.append("\n\tChildren [");
    for (SceneNode child : _childNodes) {
      builder.append("\n\t\t");
      builder.append(child.appendDiagnostics(builder));
    }
    builder.append("]");

    return builder.toString();
  }
Exemplo n.º 3
0
 public <T extends SceneNodeComponent> boolean hasComponent(
     Class<T> type, boolean includeInactive) {
   int typeId = ComponentType.findType(type);
   SceneNodeComponent value = _components.get(ComponentType.findBaseType(typeId));
   return value != null
       && (includeInactive || value.isActive())
       && isSubtype(typeId, value.componentType);
 }
Exemplo n.º 4
0
 public <T extends SceneNodeComponent> T getComponent(int typeId, boolean includeInactive) {
   SceneNodeComponent value = _components.get(ComponentType.findBaseType(typeId));
   return value != null
           && (includeInactive || value.isActive())
           && isSubtype(typeId, value.componentType)
       ? Values.<T>cast(value)
       : null;
 }
Exemplo n.º 5
0
  public void removeComponent(SceneNodeComponent component, boolean destroy) {
    SceneNodeComponent value = _components.get(component.baseComponentType);
    if (value != component) {
      return;
    }

    if (destroy) {
      component.destroy();
    } else {
      component.unsetParent();
    }
  }
Exemplo n.º 6
0
 @Override
 protected void childRemoved(ManagedObject child) {
   if (child instanceof SceneNodeComponent) {
     SceneNodeComponent component = (SceneNodeComponent) child;
     component.scene = null;
     _components.remove(component.baseComponentType);
     _componentBits.clear(component.componentType);
   } else {
     SceneNode node = (SceneNode) child;
     node.scene = null;
     _childNodes.remove(node);
   }
 }
Exemplo n.º 7
0
 @Override
 protected final void childAdded(ManagedObject child) {
   if (child instanceof SceneNodeComponent) {
     SceneNodeComponent component = (SceneNodeComponent) child;
     int baseType = component.baseComponentType;
     if (_components.containsKey(baseType)) {
       throw new IllegalArgumentException(
           "Node already contains component: " + component.getClass().getName());
     }
     component.scene = scene;
     _components.put(baseType, component);
     _componentBits.set(component.componentType);
   } else {
     SceneNode node = (SceneNode) child;
     node.scene = scene;
     _childNodes.add(node);
   }
 }
Exemplo n.º 8
0
 public boolean hasComponent(int typeId, boolean includeInactive) {
   SceneNodeComponent value = _components.get(ComponentType.findBaseType(typeId));
   return value != null
       && (includeInactive || value.isActive())
       && isSubtype(typeId, value.componentType);
 }
Exemplo n.º 9
0
 public void removeComponent(int componentTypeId) {
   SceneNodeComponent component = _components.get(ComponentType.findBaseType(componentTypeId));
   if (component != null && isSubtype(componentTypeId, component.componentType)) {
     component.destroy();
   }
 }
Exemplo n.º 10
0
 public void removeComponent(SceneNodeComponent component) {
   SceneNodeComponent value = _components.get(component.baseComponentType);
   if (value == component) {
     component.destroy();
   }
 }
Exemplo n.º 11
0
 public void addComponent(SceneNodeComponent component) {
   component.setParent(this);
 }