/**
  * Creates an entity system that uses the specified aspect as a matcher against entities.
  *
  * @param aspect to match against entities
  */
 public EntityProcessor(Aspect aspect) {
   actives = new Bag<Entity>();
   allSet = aspect.getAllSet();
   exclusionSet = aspect.getExclusionSet();
   oneSet = aspect.getOneSet();
   dummy =
       allSet.isEmpty()
           && oneSet
               .isEmpty(); // This system can't possibly be interested in any entity, so it must be
                           // "dummy"
 }
  @Test
  public void should_be_possible_to_re_add_texturecomponent_via_listener() throws Exception {
    final Entity enemy = createEnemy(Type.GREEN);
    createEnemyChangeEvent();

    world
        .getAspectSubscriptionManager()
        .get(Aspect.all(TextureRef.class).exclude(TextureComponent.class))
        .addSubscriptionListener(
            new EntitySubscription.SubscriptionListener() {
              @Override
              public void inserted(IntBag entities) {
                final int[] data = entities.getData();
                for (int i = 0; i < entities.size(); i++) {
                  world.getEntity(data[i]).edit().create(TextureComponent.class);
                }
              }

              @Override
              public void removed(IntBag entities) {}
            });

    world.process();
    assertThat(enemy.getComponent(TextureComponent.class)).isNotNull();
  }
Exemplo n.º 3
0
 public TextureRenderSystem(final float interval) {
   super(
       Aspect.getAspectForAll(TextureComponent.class, TransformComponent.class)
           .exclude(BackgroundComponent.class),
       interval);
   this.temp2 = new Vector2();
   this.temp2_1 = new Vector2();
 }
Exemplo n.º 4
0
  @Override
  protected void initialize() {
    EntityEdit swarm = world.createEntity().edit();
    swarm.create(Swarm.class);
    swarm.create(Bounds.class).setRadius(10);
    swarm.create(Pos.class);
    swarmId = swarm.getEntityId();
    // we can do about 10k in gwt
    createSwarm(100);
    // hmm consume speed/dmg taken based on swarm size && scale?
    // spread out swarm takes less dmg, but eats slowly,
    // compact swarms eats fast, but is vulnerable to dmg

    edibles =
        world.getAspectSubscriptionManager().get(Aspect.all(Pos.class, Edible.class, Bounds.class));
  }
Exemplo n.º 5
0
 public Scripts() {
   super(Aspect.all(ScriptComponent.class));
 }
 public PlayerControlSystem() {
   super(Aspect.all(PlayerControlled.class, Position.class));
 }
 public AttachmentSystem() {
   super(Aspect.all(Pos.class, Attached.class));
 }
 @SuppressWarnings("unchecked")
 public PlainPositionSystem2() {
   super(Aspect.getAspectForAll(PlainPosition.class));
 }
  public OptimizedSystemAdditional() {
    super(Aspect.getEmpty());

    setEnabled(true);
    begin();
  }
 public CostRenderSystem() {
   super(Aspect.getAspectForAll(Pos.class, Anim.class, Bounds.class, Buildable.class));
 }
 public ParticleSystem(SpriteBatch batch) {
   super(Aspect.all(Particle.class));
   this.batch = batch;
 }
  public IntOptimizedSystemAdditional() {
    super(Aspect.all());

    setEnabled(true);
    begin();
  }
Exemplo n.º 13
0
 public SomeSystem() {
   super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class));
 }
 public MapCollisionSystem() {
   super(Aspect.getAspectForAll(Physics.class, Pos.class, Bounds.class));
 }
 @SuppressWarnings("unchecked")
 public BombAttackerScriptingSystem(ScriptEngine engine) {
   super(Aspect.getAspectForAll(Script.class, BombAttacker.class, Velocity.class));
   this.engine = engine;
 }
Exemplo n.º 16
0
 @SuppressWarnings("unchecked")
 public SimpleExampleSystem(float interval) {
   super(Aspect.all(ModelComponent.class, KinematicObject.class), interval);
 }
Exemplo n.º 17
0
 public LocalCollisionSystem() {
   super(Aspect.all(BulletComponent.class));
 }
 @SuppressWarnings("unchecked")
 public PoliciesSystem() {
   super(Aspect.getAspectForAll(Policies.class));
 }
 public MovementSystem() {
   super(Aspect.all(Position.class, Velocity.class));
 }
Exemplo n.º 20
0
 public EntitiesCollector() {
   super(Aspect.all(Layer.class));
 }
Exemplo n.º 21
0
 @SuppressWarnings("unchecked")
 public HealingSystem(final float interval) {
   super(Aspect.getAspectForAll(Health.class), interval);
 }
Exemplo n.º 22
0
 @SuppressWarnings("unchecked")
 public ShapeRenderSystem(OrthographicCamera camera) {
   super(Aspect.getAspectForAll(Position.class).one(Circle.class, Rectangle.class));
   this.camera = camera;
 }
Exemplo n.º 23
0
 public TreeAttachSystem() {
   super(Aspect.getAspectForAll(TransformComponent.class));
   roots = new ArrayBag<>();
 }
  public HudRenderSystem(GameContainer container) {
    super(Aspect.getAspectFor());

    this.container = container;
    this.g = container.getGraphics();
  }
Exemplo n.º 25
0
 public SwarmSystem() {
   super(Aspect.all(Pos.class, Swarmer.class));
 }
Exemplo n.º 26
0
  public ShowerSystem() {

    super(
        Aspect.all(Shower.class, Pos.class, Bounds.class),
        Aspect.all(Ingredient.class, Pos.class, Bounds.class).exclude(SpawnProtected.class));
  }
Exemplo n.º 27
0
 public CameraSystem() {
   super(Aspect.getAspectForAll(Camera.class));
 }
 public BasicSystem() {
   super(Aspect.all(TestMarker.class));
 }
Exemplo n.º 29
0
 @SuppressWarnings("unchecked")
 public GlobalScriptSystem() {
   super(Aspect.getAspectForAll(ScriptComponent.class));
 }
 @SuppressWarnings("unchecked")
 public Es2() {
   super(Aspect.all(ComponentX.class).exclude(ComponentY.class));
 }