Package gwlpr.mapshard.entitysystem

Examples of gwlpr.mapshard.entitysystem.EntityManager


{
    @Test
    public void testEntityManager()
    {
        // create the entity manager
        EntityManager eMan = new EntityManager();
       
        // before adding any entities, try to retrieve some...
        Collection<Entity> ents = eMan.getEntitiesWith(Name.class, AgentIdentifiers.class, Position.class, Direction.class);
        assert ents.isEmpty();
       
        // now lets add some entities
        Name n1 = new Name();
        Name n2 = new Name();
        Name n3 = new Name();
        Name n4 = new Name();

        AgentIdentifiers a1 = new AgentIdentifiers();
        AgentIdentifiers a2 = new AgentIdentifiers();
        AgentIdentifiers a3 = new AgentIdentifiers();

        Position p1 = new Position();
        Position p2 = new Position();
       
        Direction d1 = new Direction();

        // register the entities
        Entity e1 = new Entity(eMan, n1, a1, p1, d1);
        Entity e2 = new Entity(eMan, n2, a2, p2);
        Entity e3 = new Entity(eMan, n3, a3);
        Entity e4 = new Entity(eMan, n4);
        Entity e5 = new Entity(eMan);

        // retrieve entities with specific components
        ents = eMan.getEntitiesWith(Name.class, AgentIdentifiers.class, Position.class, Direction.class);
        assert ents.size() == 1;
        assert ents.contains(e1);

        ents = eMan.getEntitiesWith(Name.class, AgentIdentifiers.class, Position.class);
        assert ents.size() == 2;
        assert ents.contains(e1);
        assert ents.contains(e2);

        ents = eMan.getEntitiesWith(Name.class, AgentIdentifiers.class);
        assert ents.size() == 3;
        assert ents.contains(e1);
        assert ents.contains(e2);
        assert ents.contains(e3);

        ents = eMan.getEntitiesWith(Name.class);
        assert ents.size() == 4;
        assert ents.contains(e1);
        assert ents.contains(e2);
        assert ents.contains(e3);
        assert ents.contains(e4);

        ents = eMan.getEntitiesWith();
        assert ents.isEmpty();

        // retrieve components of specific entities
        Name n = e1.get(Name.class); // e1 has a Name
        assert n == n1;
View Full Code Here


        WorldBean world = new WorldBean(mapEntity, instanceNum, region, language, isPvP, isOutpost);
       
        // create all the objects needed by controllers and systems
        EventAggregator eventAgg = thisContext.get().getEventAggregator();
        HandleRegistry<ClientBean> clientRegistry = new HandleRegistryNotificationDecorator<>(eventAgg);
        EntityManager entityManager = new EntityManager();
       
        // now lets do the server ticks:
        // there is two of them, one that updates the systems of the CES
        // and one thats used to pump out the state of the server in
        // discrete time intervalls
View Full Code Here

TOP

Related Classes of gwlpr.mapshard.entitysystem.EntityManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.