question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Different systems with the same family filter receive different entities.

See original GitHub issue
package in.zumikua.stg;

import com.badlogic.ashley.core.*;
import com.badlogic.ashley.utils.ImmutableArray;

public class Test {

    static public void main(String[] args) {
        Engine engine = new Engine();
        engine.addSystem(new SystemAddEntity());
        engine.addSystem(new SystemAttachComponent());
        engine.addSystem(new SystemC());
        engine.update(1);
    }

    static class A implements Component {

    }

    static class B implements Component {

    }

    static class SystemAddEntity extends EntitySystem {

        SystemAddEntity() {
            super(0);
        }

        boolean added = false;
        @Override
        public void update(float deltaTime) {
            super.update(deltaTime);
            if(!added) {
                getEngine().addEntity(new Entity().add(new A()));
                added = true;
            }
        }
    }

    static class SystemAttachComponent extends EntitySystem implements EntityListener {

        private ImmutableArray<Entity> entities;

        SystemAttachComponent() {
            super(1);
        }

        @Override
        public void addedToEngine(Engine engine) {
            super.addedToEngine(engine);
            engine.addEntityListener(Family.all(A.class).exclude(B.class).get(), this);
            entities = engine.getEntitiesFor(Family.all(A.class, B.class).get());
        }

        @Override
        public void update(float deltaTime) {
            super.update(deltaTime);
            System.out.println("SystemAttachComponent " + entities.size()); // outputs 0
        }

        @Override
        public void entityAdded(Entity entity) {
            entity.add(new B());
        }

        @Override
        public void entityRemoved(Entity entity) {

        }
    }

    static class SystemC extends EntitySystem {
        private ImmutableArray<Entity> entities;

        SystemC() {
            super(2);
        }

        @Override
        public void addedToEngine(Engine engine) {
            super.addedToEngine(engine);
            entities = engine.getEntitiesFor(Family.all(A.class, B.class).get());
        }

        @Override
        public void update(float deltaTime) {
            super.update(deltaTime);
            System.out.println("SystemC " + entities.size());  //outputs 1
        }
    }
}

With the above code, SystemAttachComponent receives zero entities, but SystemC receives one entity, is this a bug or an intended behavior?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mgsx-devcommented, Nov 5, 2020

@metaphore i’ll improve the javadoc, it’s a bit confusing indeed 😃

0reactions
ZumiKuacommented, Nov 9, 2020

Sorry for my late reply, I’m using 1.7.3, which is bundled with the newest(I guess) gdx-setup. Maybe gdx-setup needs to be updated? Anyway, thanks for your help ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity filters - ServiceNow Docs
Entity types enable you to find and create entities that match a set of filter conditions. Entity types include predefined entity filters that...
Read more >
Internet Service Provider Content Filtering
Every other year, the Division must request information from each Internet ... This service does the same filtering as OpenDNS Family shield but...
Read more >
Parental Control & Internet Filtering Device and App | Meet ...
Circle is the easiest parental control device and app to manage screen time across all your family's connected devices. Keep kids safe online:...
Read more >
How to filter a list based on another list using Linq?
Try this: var filtered = listOfAllVenues .Where(x=>!listOfBlockedVenues.Any(y=>y.VenueId == x.Id));. It will get all Venues where Id is not in blockedVenues ...
Read more >
A Survey of Blocking and Filtering Techniques for Entity ... - arXiv
Hence, Blocking and Filtering share the same goal, but are complementary, as they operate under different settings and assumptions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found