예제 #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();
   }
 }
예제 #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();
  }
예제 #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);
 }
예제 #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;
 }
예제 #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();
    }
  }
예제 #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);
   }
 }
예제 #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);
   }
 }
예제 #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);
 }
예제 #9
0
 public void removeComponent(int componentTypeId) {
   SceneNodeComponent component = _components.get(ComponentType.findBaseType(componentTypeId));
   if (component != null && isSubtype(componentTypeId, component.componentType)) {
     component.destroy();
   }
 }
예제 #10
0
 public void removeComponent(SceneNodeComponent component) {
   SceneNodeComponent value = _components.get(component.baseComponentType);
   if (value == component) {
     component.destroy();
   }
 }
예제 #11
0
 public void addComponent(SceneNodeComponent component) {
   component.setParent(this);
 }