Search in sources :

Example 36 with Prefab

use of org.terasology.entitySystem.prefab.Prefab in project Terasology by MovingBlocks.

the class BaseEntityRefTest method setupClass.

@BeforeClass
public static void setupClass() throws Exception {
    context = new ContextImpl();
    ModuleManager moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManager();
    assetTypeManager.registerCoreAssetType(Prefab.class, (AssetFactory<Prefab, PrefabData>) PojoPrefab::new, "prefabs");
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    CoreRegistry.setContext(context);
}
Also used : PrefabData(org.terasology.entitySystem.prefab.PrefabData) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) ContextImpl(org.terasology.context.internal.ContextImpl) ModuleManager(org.terasology.engine.module.ModuleManager) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) BeforeClass(org.junit.BeforeClass)

Example 37 with Prefab

use of org.terasology.entitySystem.prefab.Prefab 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.entitySystem.prefab.PrefabData) ResourceUrn(org.terasology.assets.ResourceUrn) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) EntityRef(org.terasology.entitySystem.entity.EntityRef) Test(org.junit.Test)

Example 38 with Prefab

use of org.terasology.entitySystem.prefab.Prefab in project Terasology by MovingBlocks.

the class PojoEntityManagerTest method setup.

@Before
public void setup() {
    context.put(NetworkSystem.class, mock(NetworkSystem.class));
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    entityManager = (PojoEntityManager) context.get(EntityManager.class);
    PrefabData protoPrefab = new PrefabData();
    protoPrefab.addComponent(new StringComponent("Test"));
    prefab = Assets.generateAsset(new ResourceUrn("unittest:myprefab"), protoPrefab, Prefab.class);
}
Also used : PrefabData(org.terasology.entitySystem.prefab.PrefabData) StringComponent(org.terasology.entitySystem.stubs.StringComponent) NetworkSystem(org.terasology.network.NetworkSystem) ResourceUrn(org.terasology.assets.ResourceUrn) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) Before(org.junit.Before)

Example 39 with Prefab

use of org.terasology.entitySystem.prefab.Prefab in project Terasology by MovingBlocks.

the class PojoEntityPoolTest method setupClass.

@BeforeClass
public static void setupClass() throws Exception {
    context = new ContextImpl();
    ModuleManager moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManager();
    assetTypeManager.registerCoreAssetType(Prefab.class, (AssetFactory<Prefab, PrefabData>) PojoPrefab::new, "prefabs");
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    CoreRegistry.setContext(context);
}
Also used : PrefabData(org.terasology.entitySystem.prefab.PrefabData) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) ContextImpl(org.terasology.context.internal.ContextImpl) ModuleManager(org.terasology.engine.module.ModuleManager) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) BeforeClass(org.junit.BeforeClass)

Example 40 with Prefab

use of org.terasology.entitySystem.prefab.Prefab in project Terasology by MovingBlocks.

the class PojoPrefabManagerTest method setup.

@Before
public void setup() throws Exception {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    ModuleManager moduleManager = ModuleManagerFactory.create();
    ReflectFactory reflectFactory = new ReflectionReflectFactory();
    CopyStrategyLibrary copyStrategyLibrary = new CopyStrategyLibrary(reflectFactory);
    TypeSerializationLibrary lib = new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary);
    lib.add(Vector3f.class, new Vector3fTypeHandler());
    lib.add(Quat4f.class, new Quat4fTypeHandler());
    entitySystemLibrary = new EntitySystemLibrary(context, lib);
    componentLibrary = entitySystemLibrary.getComponentLibrary();
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManager();
    assetTypeManager.registerCoreAssetType(Prefab.class, (AssetFactory<Prefab, PrefabData>) PojoPrefab::new, "prefabs");
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    prefabManager = new PojoPrefabManager(context);
}
Also used : PojoPrefabManager(org.terasology.entitySystem.prefab.internal.PojoPrefabManager) PrefabData(org.terasology.entitySystem.prefab.PrefabData) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) ContextImpl(org.terasology.context.internal.ContextImpl) ModuleManager(org.terasology.engine.module.ModuleManager) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectFactory(org.terasology.reflection.reflect.ReflectFactory) Vector3fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Vector3fTypeHandler) EntitySystemLibrary(org.terasology.entitySystem.metadata.EntitySystemLibrary) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) Quat4fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Quat4fTypeHandler) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) Before(org.junit.Before)

Aggregations

Prefab (org.terasology.entitySystem.prefab.Prefab)49 PojoPrefab (org.terasology.entitySystem.prefab.internal.PojoPrefab)20 PrefabData (org.terasology.entitySystem.prefab.PrefabData)13 Test (org.junit.Test)11 ResourceUrn (org.terasology.assets.ResourceUrn)9 Component (org.terasology.entitySystem.Component)9 EntityRef (org.terasology.entitySystem.entity.EntityRef)9 ModuleAwareAssetTypeManager (org.terasology.assets.module.ModuleAwareAssetTypeManager)7 ContextImpl (org.terasology.context.internal.ContextImpl)6 ModuleManager (org.terasology.engine.module.ModuleManager)6 StringComponent (org.terasology.entitySystem.stubs.StringComponent)6 Command (org.terasology.logic.console.commandSystem.annotations.Command)6 ClientComponent (org.terasology.network.ClientComponent)6 Before (org.junit.Before)5 EntityBuilder (org.terasology.entitySystem.entity.EntityBuilder)5 NetworkComponent (org.terasology.network.NetworkComponent)5 BeforeClass (org.junit.BeforeClass)4 NetworkSystem (org.terasology.network.NetworkSystem)4 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)3 AssetManager (org.terasology.assets.management.AssetManager)2