Package org.terasology.entitySystem.entity

Examples of org.terasology.entitySystem.entity.EntityRef.addComponent()


    }

    @Test
    public void destroyingEntityInvalidatesEntityRefs() {
        EntityRef main = entityManager.create();
        main.addComponent(new StringComponent());

        EntityRef reference = entityManager.create();
        EntityRefComponent refComp = reference.addComponent(new EntityRefComponent());
        refComp.entityRef = entityManager.getEntitiesWith(StringComponent.class).iterator().next();
View Full Code Here


    public void destroyingEntityInvalidatesEntityRefs() {
        EntityRef main = entityManager.create();
        main.addComponent(new StringComponent());

        EntityRef reference = entityManager.create();
        EntityRefComponent refComp = reference.addComponent(new EntityRefComponent());
        refComp.entityRef = entityManager.getEntitiesWith(StringComponent.class).iterator().next();

        assertTrue(main.exists());
        entityManager.getEntitiesWith(StringComponent.class).iterator().next().destroy();
View Full Code Here

    }

    @Test
    public void testDeltaAddNewComponent() throws Exception {
        EntityRef entity = entityManager.create(prefab);
        entity.addComponent(new IntegerComponent(1));

        EntityData.Entity entityData = entitySerializer.serialize(entity);

        assertEquals(entity.getId(), entityData.getId());
        assertEquals(prefab.getName(), entityData.getParentPrefab());
View Full Code Here

    }

    @Test
    public void testDeltaLoadAddedComponent() throws Exception {
        EntityRef entity = entityManager.create("test:Test");
        entity.addComponent(new IntegerComponent(2));
        EntityData.Entity entityData = entitySerializer.serialize(entity);
        entityManager.clear();
        EntityRef loadedEntity = entitySerializer.deserialize(entityData);

        assertTrue(loadedEntity.exists());
View Full Code Here

    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;
    }

    @Override
View Full Code Here

                if (selectedTree != null && selectedInterpreter != null) {
                    EntityRef minion = selectedInterpreter.actor().minion();
                    minion.removeComponent(BehaviorComponent.class);
                    BehaviorComponent component = new BehaviorComponent();
                    component.tree = selectedTree;
                    minion.addComponent(component);
                    List<Interpreter> interpreter = behaviorSystem.getInterpreter();
                    selectEntity.setSelection(null);
                    for (Interpreter i : interpreter) {
                        if (i.actor().minion() == minion) {
                            selectEntity.setSelection(i);
View Full Code Here

                // 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);
            Optional<WorldConfigurator> ocf = worldGenerator.getConfigurator();
View Full Code Here

                Map<String, Component> params = ocf.get().getProperties();
                for (Map.Entry<String, Component> entry : params.entrySet()) {
                    Class<? extends Component> clazz = entry.getValue().getClass();
                    Component comp = config.getModuleConfig(generatorUri, entry.getKey(), clazz);
                    if (comp != null) {
                        worldEntity.addComponent(comp);
                        entry.setValue(comp);
                    } else {
                        worldEntity.addComponent(entry.getValue());
                    }
                }
View Full Code Here

                    Component comp = config.getModuleConfig(generatorUri, entry.getKey(), clazz);
                    if (comp != null) {
                        worldEntity.addComponent(comp);
                        entry.setValue(comp);
                    } else {
                        worldEntity.addComponent(entry.getValue());
                    }
                }

                // save the world config back to the world generator
                worldGenerator.setConfigurator(ocf.get());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.