コード例 #1
0
  /**
   * Searches all active entities for the next one that holds the matching string at fieldofs (use
   * the FOFS() macro) in the structure.
   *
   * <p>Searches beginning at the edict after from, or the beginning if null null will be returned
   * if the end of the list is reached.
   */
  public static EntityIterator G_Find(EntityIterator from, EntityFilter eff, String s) {

    if (from == null) from = new EntityIterator(0);
    else from.i++;

    for (; from.i < num_edicts; from.i++) {
      from.o = g_edicts[from.i];
      if (from.o.classname == null) {
        Com.Printf("edict with classname = null" + from.o.index);
      }

      if (!from.o.inuse) continue;

      if (eff.matches(from.o, s)) return from;
    }

    return null;
  }
コード例 #2
0
  /** Returns entities that have origins within a spherical area. */
  public static EntityIterator findradius(EntityIterator from, float[] org, float rad) {
    float[] eorg = {0, 0, 0};
    int j;

    if (from == null) from = new EntityIterator(0);
    else from.i++;

    for (; from.i < num_edicts; from.i++) {
      from.o = g_edicts[from.i];
      if (!from.o.inuse) continue;

      if (from.o.solid == Constants.SOLID_NOT) continue;

      for (j = 0; j < 3; j++)
        eorg[j] = org[j] - (from.o.s.origin[j] + (from.o.mins[j] + from.o.maxs[j]) * 0.5f);

      if (Math3D.VectorLength(eorg) > rad) continue;
      return from;
    }

    return null;
  }