Package org.terasology.entitySystem.entity

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


        for (NetData.RemoveEntityMessage removeEntity : message.getRemoveEntityList()) {
            int netId = removeEntity.getNetId();
            EntityRef entity = networkSystem.getEntity(netId);
            if (entity.exists()) {
                logger.info("Destroying entity: {}", entity);
                entity.destroy();
                networkSystem.unregisterClientNetworkEntity(netId);
            }
        }
    }
View Full Code Here


            EntityRef itemAt = InventoryUtils.getItemAt(entity, slot);
            removedCount += InventoryUtils.getStackCount(itemAt);

            if (destroyRemoved) {
                InventoryUtils.putItemIntoSlot(entity, EntityRef.NULL, slot);
                itemAt.destroy();
            } else {
                if (removed == null) {
                    InventoryUtils.putItemIntoSlot(entity, EntityRef.NULL, slot);
                    removed = itemAt;
                } else {
View Full Code Here

                if (removed == null) {
                    InventoryUtils.putItemIntoSlot(entity, EntityRef.NULL, slot);
                    removed = itemAt;
                } else {
                    InventoryUtils.putItemIntoSlot(entity, EntityRef.NULL, slot);
                    itemAt.destroy();
                }
            }
        }

        if (shrinkSlotNo > -1) {
View Full Code Here

        character.addComponent(new EntityRefComponent(someEntity));

        esm.waitForCompletionOfPreviousSaveAndStartSaving();
        esm.finishSavingAndShutdown();

        someEntity.destroy();
        entityManager.create(); // This causes the destroyed entity's id to be reused

        PlayerStore restored = esm.loadPlayerStore(PLAYER_ID);
        restored.restoreEntities();
        assertFalse(character.getComponent(EntityRefComponent.class).entityRef.exists());
View Full Code Here

                characterComp.controller = entity;
                character.saveComponent(characterComp);
                character.setOwner(entity);
                Location.attachChild(character, entity, new Vector3f(), new Quat4f(0, 0, 0, 1));
            } else {
                character.destroy();
                spawnPlayer(entity, getSafeSpawnPosition());
            }
        }
    }
View Full Code Here

    public void destroyEntity() {
        EntityRef entity = entityManager.create();

        entity.addComponent(new StringComponent());
        entity.addComponent(new IntegerComponent());
        entity.destroy();

        assertNull(entity.getComponent(StringComponent.class));
        assertNull(entity.getComponent(IntegerComponent.class));
    }
View Full Code Here

        EventSystem eventSystem = mock(EventSystem.class);

        EntityRef entity1 = entityManager.create();
        entity1.addComponent(new StringComponent());
        entityManager.setEventSystem(eventSystem);
        entity1.destroy();

        verify(eventSystem).send(entity1, BeforeDeactivateComponent.newInstance());
        verify(eventSystem).send(entity1, BeforeRemoveComponent.newInstance());
    }
View Full Code Here

    }

    @Test
    public void isLoadedFalseAfterDestroyed() {
        EntityRef entity = entityManager.create();
        entity.destroy();
        assertFalse(entity.isActive());
    }

    @Test
    public void isLoadedFalseAfterPersist() {
View Full Code Here

    public void destructionOfUnloadedEntitiesPrevented() {
        EntityRef entity = entityManager.create();
        int id = entity.getId();
        entityManager.deactivateForStorage(entity);
        assertTrue(entity.exists());
        entity.destroy();
        assertTrue(entity.exists());
        assertFalse(entityManager.getFreedIds().contains(id));
    }
}
View Full Code Here

    public void onActivateBlock(OnActivatedComponent event, EntityRef entity) {
        BlockComponent block = entity.getComponent(BlockComponent.class);
        EntityRef oldEntity = blockEntityLookup.put(new Vector3i(block.getPosition()), entity);
        // If this is a client, then an existing block entity may exist. Destroy it.
        if (oldEntity != null && !Objects.equal(oldEntity, entity)) {
            oldEntity.destroy();
        }
    }

    @ReceiveEvent(components = {BlockComponent.class})
    public void onDeactivateBlock(BeforeDeactivateComponent event, EntityRef entity) {
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.