Package org.terasology.entitySystem.entity

Examples of org.terasology.entitySystem.entity.EntityManager


                return new PojoPrefab(uri, data);
            }
        });
        NetworkSystem networkSystem = mock(NetworkSystem.class);
        when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
        EntityManager em = new EntitySystemBuilder().build(moduleManager.getEnvironment(), networkSystem, new ReflectionReflectFactory());
        prefabManager = new PojoPrefabManager();
    }
View Full Code Here


        return "Linking world";
    }

    @Override
    public boolean step() {
        EntityManager entityManager = CoreRegistry.get(EntityManager.class);
        WorldRenderer worldRenderer = CoreRegistry.get(WorldRenderer.class);

        EntityRef worldEntity = entityManager.create();
        worldEntity.addComponent(new WorldComponent());
        worldRenderer.getChunkProvider().setWorldEntity(worldEntity);
        return true;
    }
View Full Code Here

        return "Creating World Entity...";
    }

    @Override
    public boolean step() {
        EntityManager entityManager = CoreRegistry.get(EntityManager.class);
        WorldRenderer worldRenderer = CoreRegistry.get(WorldRenderer.class);

        Iterator<EntityRef> worldEntityIterator = entityManager.getEntitiesWith(WorldComponent.class).iterator();
        // TODO: Move the world renderer bits elsewhere
        if (worldEntityIterator.hasNext()) {
            EntityRef worldEntity = worldEntityIterator.next();
            worldRenderer.getChunkProvider().setWorldEntity(worldEntity);

            // get the world generator config from the world entity
            // replace the world generator values from the components in the world entity
            WorldGenerator worldGenerator = CoreRegistry.get(WorldGenerator.class);
            Optional<WorldConfigurator> ocf = worldGenerator.getConfigurator();

            if (ocf.isPresent()) {
                Map<String, Component> params = ocf.get().getProperties();
                for (Map.Entry<String, Component> entry : params.entrySet()) {
                    Class<? extends Component> clazz = entry.getValue().getClass();
                    Component comp = worldEntity.getComponent(clazz);
                    if (comp != null) {
                        entry.setValue(comp);
                    }
                }
                // save the world config back to the world generator
                worldGenerator.setConfigurator(ocf.get());
            }
        } else {
            EntityRef worldEntity = entityManager.create();
            worldEntity.addComponent(new WorldComponent());
            worldRenderer.getChunkProvider().setWorldEntity(worldEntity);

            // transfer all world generation parameters from Config to WorldEntity
            WorldGenerator worldGenerator = CoreRegistry.get(WorldGenerator.class);
View Full Code Here

    protected WorldTime getWorldTime() {
        return worldTime;
    }

    protected EntityRef getWorldEntity() {
        EntityManager entityManager = CoreRegistry.get(EntityManager.class);
        for (EntityRef entity : entityManager.getEntitiesWith(WorldComponent.class)) {
            return entity;
        }
        return EntityRef.NULL;
    }
View Full Code Here

        DefaultRenderingProcess.getInstance().beginRenderLightGeometryStencilPass();
        Material program = Assets.getMaterial("engine:prog.simple");
        program.enable();
        program.setCamera(camera);
        EntityManager entityManager = CoreRegistry.get(EntityManager.class);
        for (EntityRef entity : entityManager.getEntitiesWith(LightComponent.class, LocationComponent.class)) {
            LocationComponent locationComponent = entity.getComponent(LocationComponent.class);
            LightComponent lightComponent = entity.getComponent(LightComponent.class);

            final Vector3f worldPosition = locationComponent.getWorldPosition();
            renderLightComponent(lightComponent, worldPosition, program, camera, true);
        }
        DefaultRenderingProcess.getInstance().endRenderLightGeometryStencilPass();

        /*
         * LIGHT GEOMETRY PASS
         */
        DefaultRenderingProcess.getInstance().beginRenderLightGeometry();
        program = Assets.getMaterial("engine:prog.lightGeometryPass");
        for (EntityRef entity : entityManager.getEntitiesWith(LightComponent.class, LocationComponent.class)) {
            LocationComponent locationComponent = entity.getComponent(LocationComponent.class);
            LightComponent lightComponent = entity.getComponent(LightComponent.class);

            final Vector3f worldPosition = locationComponent.getWorldPosition();
            renderLightComponent(lightComponent, worldPosition, program, camera, false);
View Full Code Here

        return "Loading Entities";
    }

    @Override
    public boolean step() {
        EntityManager em = CoreRegistry.get(EntityManager.class);
        boolean entityCreated = false;
        for (EntityRef entity : em.getAllEntities()) {
            entityCreated = true;
            logger.error("Entity created before load: {}", entity.toFullDescription());
        }
        if (entityCreated) {
            throw new IllegalStateException("Entity creation detected during component system initialisation, game load aborting");
View Full Code Here

TOP

Related Classes of org.terasology.entitySystem.entity.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.