Пример #1
0
  /**
   * Create entity factory for entities with a predefined component composition.
   *
   * @param factory type to create.
   * @param <T> type to create. Should implement {@link EntityFactory}.
   * @return Implementation of EntityFactory.
   * @see EntityFactory for instructions about configuration.
   */
  @SuppressWarnings("unchecked")
  public <T extends EntityFactory> T createFactory(Class<?> factory) {
    if (!factory.isInterface())
      throw new MundaneWireException("Expected interface for type: " + factory);

    String impl = factory.getName() + "Impl";
    try {
      Class<?> implClass = ClassReflection.forName(impl);
      Constructor constructor = ClassReflection.getConstructor(implClass, World.class);
      return (T) constructor.newInstance(this);
    } catch (ReflectionException e) {
      throw new RuntimeException(e);
    }
  }
Пример #2
0
  @Override
  public boolean equals(Object obj) {
    if (this != obj) {

      if (!ClassReflection.isInstance(BitSet.class, obj)) {
        return false;
      }

      BitSet other = (BitSet) obj;

      int last = trimToSize(array);
      if (last != trimToSize(other.array)) {
        return false;
      }

      int index = 0;
      while ((index = nextSetWord(array, index)) != -1) {
        if (getWord(array, index) != getWord(other.array, index)) {
          return false;
        }
        index++;
      }
    }

    return true;
  }
Пример #3
0
    public TransmuterEntry(Bag<Class<? extends Component>> types) {
      try {
        for (Class<? extends Component> c : types) {
          if (ClassReflection.getAnnotation(c, Transient.class) != null) continue;

          componentTypes.add(c);
        }
      } catch (ReflectionException e) {
        throw new RuntimeException(e);
      }
    }