Beispiel #1
0
  private void update(List<Entity> moved, ComponentMapper<Mass> mm, ComponentMapper<Position> pm) {
    if (hasEntity()) {
      if (entity.isActive()) {
        VectorD2 p = pm.get(entity).vec;
        if (!contains(p)) {
          moved.add(entity);
          --size;
          this.mass = 0f;
          this.massVector.set(0f, 0f);
          entity = null;
        } else {
          mass = mm.get(entity).mass;
          massVector.set(p).mul(mass);
        }
      }
    } else if (hasChildren()) {
      bl.update(moved, mm, pm);
      br.update(moved, mm, pm);
      tl.update(moved, mm, pm);
      tr.update(moved, mm, pm);

      size = bl.size + br.size + tl.size + tr.size;

      mass = bl.mass + br.mass + tl.mass + tr.mass;

      massVector.set(0f, 0f);
      massVector.add(bl.massVector).add(br.massVector);
      massVector.add(tl.massVector).add(tr.massVector);
    }
  }
Beispiel #2
0
 public void update(ComponentMapper<Mass> mm, ComponentMapper<Position> pm) {
   List<Entity> moved = new ArrayList<Entity>();
   update(moved, mm, pm);
   for (Entity e : moved) {
     add(e, mm, pm);
   }
 }