Search in sources :

Example 41 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class PojoEntityManagerTest method testPrefabPersistedRetainedCorrectly.

@Test
public void testPrefabPersistedRetainedCorrectly() {
    PrefabData protoPrefab = new PrefabData();
    protoPrefab.setPersisted(false);
    prefab = Assets.generateAsset(new ResourceUrn("unittest:nonpersistentPrefab"), protoPrefab, Prefab.class);
    EntityRef entity1 = entityManager.create(prefab);
    assertFalse(entity1.isPersistent());
}
Also used : PrefabData(org.terasology.engine.entitySystem.prefab.PrefabData) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Prefab(org.terasology.engine.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.engine.entitySystem.prefab.internal.PojoPrefab) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 42 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class PojoEventSystemTests method testChildEventReceivedByUnfilteredHandler.

@Test
public void testChildEventReceivedByUnfilteredHandler() {
    entity.addComponent(new IntegerComponent());
    TestEventHandler handler = new TestEventHandler();
    eventSystem.registerEvent(new ResourceUrn("test:childEvent"), TestChildEvent.class);
    eventSystem.registerEventHandler(handler);
    TestChildEvent event = new TestChildEvent();
    eventSystem.send(entity, event);
    assertEquals(1, handler.unfilteredEvents.size());
}
Also used : IntegerComponent(org.terasology.unittest.stubs.IntegerComponent) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Test(org.junit.jupiter.api.Test)

Example 43 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class PojoEventSystemTests method testChildEvent.

@Test
public void testChildEvent() {
    entity.addComponent(new IntegerComponent());
    TestEventHandler handler = new TestEventHandler();
    eventSystem.registerEvent(new ResourceUrn("test:childEvent"), TestChildEvent.class);
    eventSystem.registerEventHandler(handler);
    TestChildEvent event = new TestChildEvent();
    eventSystem.send(entity, event);
    assertEquals(1, handler.childEventReceived.size());
    assertEquals(1, handler.receivedList.size());
}
Also used : IntegerComponent(org.terasology.unittest.stubs.IntegerComponent) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Test(org.junit.jupiter.api.Test)

Example 44 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class FieldMetadataTest method testOwnsAnnotationCollectionProcessed.

@Test
public void testOwnsAnnotationCollectionProcessed() throws NoSuchMethodException {
    ComponentMetadata<org.terasology.engine.entitySystem.metadata.OwnedCollectionComponent> classMetadata = new ComponentMetadata<>(new ResourceUrn("unittest:OwnedCollectionComponent"), org.terasology.engine.entitySystem.metadata.OwnedCollectionComponent.class, factory, copyStrategyLibrary);
    ComponentFieldMetadata metadata = classMetadata.getField("items");
    assertTrue(metadata.isOwnedReference());
}
Also used : ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Test(org.junit.jupiter.api.Test)

Example 45 with ResourceUrn

use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.

the class BetweenChunkPropagationTest method setup.

@BeforeEach
@Override
public void setup() throws Exception {
    super.setup();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    regenRules = new SunlightRegenPropagationRules();
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager, true);
    CoreRegistry.put(BlockManager.class, blockManager);
    extraDataManager = new ExtraBlockDataManager();
    BlockFamilyDefinitionData solidData = new BlockFamilyDefinitionData();
    solidData.getBaseSection().setDisplayName("Stone");
    solidData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    solidData.getBaseSection().setTranslucent(false);
    solidData.setBlockFamily(SymmetricFamily.class);
    assetManager.loadAsset(new ResourceUrn("engine:stone"), solidData, BlockFamilyDefinition.class);
    solid = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:stone")));
    regenWorldView = new SunlightRegenWorldView(provider);
    lightWorldView = new SunlightWorldView(provider);
    lightRules = new SunlightPropagationRules(regenWorldView);
    sunlightPropagator = new StandardBatchPropagator(lightRules, lightWorldView);
    propagator = new SunlightRegenBatchPropagator(regenRules, regenWorldView, sunlightPropagator, lightWorldView);
}
Also used : BlockUri(org.terasology.engine.world.block.BlockUri) AssetManager(org.terasology.gestalt.assets.management.AssetManager) ExtraBlockDataManager(org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager) SunlightRegenWorldView(org.terasology.engine.world.propagation.light.SunlightRegenWorldView) SunlightPropagationRules(org.terasology.engine.world.propagation.light.SunlightPropagationRules) SunlightWorldView(org.terasology.engine.world.propagation.light.SunlightWorldView) BlockFamilyDefinitionData(org.terasology.engine.world.block.loader.BlockFamilyDefinitionData) NullWorldAtlas(org.terasology.engine.world.block.tiles.NullWorldAtlas) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) SunlightRegenPropagationRules(org.terasology.engine.world.propagation.light.SunlightRegenPropagationRules) BlockManagerImpl(org.terasology.engine.world.block.internal.BlockManagerImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)90 Test (org.junit.jupiter.api.Test)19 Name (org.terasology.gestalt.naming.Name)12 BeforeEach (org.junit.jupiter.api.BeforeEach)11 BlockFamilyDefinitionData (org.terasology.engine.world.block.loader.BlockFamilyDefinitionData)10 IOException (java.io.IOException)9 AssetManager (org.terasology.gestalt.assets.management.AssetManager)9 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)8 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)8 PrefabData (org.terasology.engine.entitySystem.prefab.PrefabData)7 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)7 BlockUri (org.terasology.engine.world.block.BlockUri)7 AssetDataFile (org.terasology.gestalt.assets.format.AssetDataFile)7 Texture (org.terasology.engine.rendering.assets.texture.Texture)5 BlockManagerImpl (org.terasology.engine.world.block.internal.BlockManagerImpl)5 BlockFamilyDefinition (org.terasology.engine.world.block.loader.BlockFamilyDefinition)5 NullWorldAtlas (org.terasology.engine.world.block.tiles.NullWorldAtlas)5 ExtraBlockDataManager (org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager)5 StringComponent (org.terasology.unittest.stubs.StringComponent)5 ByteBuffer (java.nio.ByteBuffer)4