com.artemis.Entity.getComponentBits()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(175)

本文整理了Java中com.artemis.Entity.getComponentBits()方法的一些代码示例,展示了Entity.getComponentBits()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getComponentBits()方法的具体详情如下:
包路径:com.artemis.Entity
类名称:Entity
方法名:getComponentBits

Entity.getComponentBits介绍

[英]Returns a BitVector instance containing bits of the components the entity possesses.
[中]返回包含实体所拥有组件位的位向量实例。

代码示例

代码示例来源:origin: junkdog/artemis-odb

/**
 * Returns whether this Aspect would accept the given Entity.
 */
public boolean isInterested(Entity e){
  return isInterested(e.getComponentBits());
}

代码示例来源:origin: junkdog/artemis-odb

/**
 * Returns whether this Aspect would accept the given Entity.
 */
public boolean isInterested(Entity e){
  return isInterested(e.getComponentBits());
}

代码示例来源:origin: net.onedaybeard.artemis/artemis-odb

/**
 * Returns whether this Aspect would accept the given Entity.
 */
public boolean isInterested(Entity e){
  return isInterested(e.getComponentBits());
}

代码示例来源:origin: apotapov/gdx-artemis

/**
 * Clean up Components belonging to the Entity
 * @param e Entity to clear components for.
 */
public void removeComponentsOfEntity(Entity e) {
  Bits componentBits = e.getComponentBits();
  for (int i = componentBits.nextSetBit(0); i >= 0; i = componentBits.nextSetBit(i+1)) {
    removeComponent(e.id, i);
  }
  componentBits.clear();
}

代码示例来源:origin: apotapov/gdx-artemis

/**
 * Remove Component of specified class for a given Entity.
 * 
 * @param e Entity to remove the component for.
 * @param type Component class to remove.
 */
public void removeComponent(Entity e, Class<? extends Component> type) {
  int classIndex = getComponentClassIndex(type);
  if(e.getComponentBits().get(classIndex)) {
    e.getComponentBits().clear(classIndex);
    if (!componentsToDelete.containsKey(e)) {
      componentsToDelete.put(e, Pools.obtain(IntArray.class));
    }
    componentsToDelete.get(e).add(classIndex);
  }
}

代码示例来源:origin: apotapov/gdx-artemis

/**
 * Fills an array with Components belonging to the specified Entity.
 * 
 * @param e Entity to get Components with.
 * @param array Array of Components to fill.
 */
public void getComponents(Entity e, Array<Component> array) {
  Bits componentBits = e.getComponentBits();
  for (int i = componentBits.nextSetBit(0); i >= 0; i = componentBits.nextSetBit(i+1)) {
    array.add(componentsByType.get(i).get(e.id));
  }
}

代码示例来源:origin: apotapov/gdx-artemis

/**
 * Adds a Component bellonging to the specified Entity to the manager.
 * 
 * @param <T> Type of component
 * @param e Entity the component belongs to
 * @param component Component to add
 */
public <T extends Component> void addComponent(Entity e, T component) {
  int classIndex = getComponentClassIndex(component.getClass());
  @SuppressWarnings("unchecked")
  Array<T> components = (Array<T>) componentsByType.get(classIndex);
  if(components == null) {
    components = new SafeArray<T>();
    componentsByType.set(classIndex, components);
  }
  // clean up existing component belonging to the entity
  Component current = components.get(e.id);
  if (current != null && current != component) {
    Pools.free(current);
  }
  components.set(e.id, component);
  e.getComponentBits().set(classIndex);
}

代码示例来源:origin: apotapov/gdx-artemis

boolean interested = true; // possibly interested, let's try to prove it wrong.
Bits componentBits = e.getComponentBits();

相关文章