use of org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl in project Terasology by MovingBlocks.
the class ComponentMetadataTest method testOwnsReferencesPopulated.
@Test
public void testOwnsReferencesPopulated() {
Reflections reflections = new Reflections(getClass().getClassLoader());
EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, new TypeHandlerLibraryImpl(reflections));
ComponentLibrary lib = entitySystemLibrary.getComponentLibrary();
lib.register(new ResourceUrn("unittest:owner"), OwnerComponent.class);
ComponentMetadata<OwnerComponent> metadata = lib.getMetadata(OwnerComponent.class);
assertTrue(metadata.isReferenceOwner());
}
use of org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl in project Terasology by MovingBlocks.
the class PojoEventSystemTests method setup.
@BeforeEach
public void setup() {
ContextImpl context = new ContextImpl();
CoreRegistry.setContext(context);
Reflections reflections = new Reflections(getClass().getClassLoader());
TypeHandlerLibrary serializationLibrary = new TypeHandlerLibraryImpl(reflections);
EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, serializationLibrary);
compLibrary = entitySystemLibrary.getComponentLibrary();
entityManager = new PojoEntityManager();
entityManager.setComponentLibrary(entitySystemLibrary.getComponentLibrary());
entityManager.setPrefabManager(new PojoPrefabManager(context));
eventSystem = new EventSystemImpl(true);
entityManager.setEventSystem(eventSystem);
entity = entityManager.create();
}
use of org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl in project Terasology by MovingBlocks.
the class EventSystemReplayImplTest method setup.
@BeforeEach
public void setup() {
ContextImpl context = new ContextImpl();
CoreRegistry.setContext(context);
Reflections reflections = new Reflections(getClass().getClassLoader());
TypeHandlerLibrary serializationLibrary = new TypeHandlerLibraryImpl(reflections);
EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, serializationLibrary);
PojoEntityManager entityManager = new PojoEntityManager();
entityManager.setComponentLibrary(entitySystemLibrary.getComponentLibrary());
entityManager.setPrefabManager(new PojoPrefabManager(context));
NetworkSystem networkSystem = mock(NetworkSystem.class);
when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
recordAndReplayCurrentStatus = new RecordAndReplayCurrentStatus();
RecordedEventStore eventStore = new RecordedEventStore();
RecordAndReplayUtils recordAndReplayUtils = new RecordAndReplayUtils();
CharacterStateEventPositionMap characterStateEventPositionMap = new CharacterStateEventPositionMap();
DirectionAndOriginPosRecorderList directionAndOriginPosRecorderList = new DirectionAndOriginPosRecorderList();
ModuleManager moduleManager = mock(ModuleManager.class);
when(moduleManager.getEnvironment()).thenReturn(mock(ModuleEnvironment.class));
RecordAndReplaySerializer recordAndReplaySerializer = new RecordAndReplaySerializer(entityManager, eventStore, recordAndReplayUtils, characterStateEventPositionMap, directionAndOriginPosRecorderList, moduleManager, mock(TypeRegistry.class));
recordAndReplayCurrentStatus.setStatus(RecordAndReplayStatus.REPLAYING);
entity = entityManager.create();
Long id = entity.getId();
eventStore.add(new RecordedEvent(id, new AttackButton(), 1, 1));
eventStore.add(new RecordedEvent(id, new AttackButton(), 2, 2));
eventStore.add(new RecordedEvent(id, new AttackButton(), 3, 3));
List<Class<?>> selectedClassesToReplay = new ArrayList<>();
selectedClassesToReplay.add(InputEvent.class);
eventSystem = new EventSystemReplayImpl(entitySystemLibrary.getEventLibrary(), networkSystem, entityManager, eventStore, recordAndReplaySerializer, recordAndReplayUtils, selectedClassesToReplay, recordAndReplayCurrentStatus);
entityManager.setEventSystem(eventSystem);
handler = new TestEventHandler();
eventSystem.registerEventHandler(handler);
}
use of org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl in project Terasology by MovingBlocks.
the class ComponentSerializerTest method setup.
@BeforeEach
public void setup() {
context = new ContextImpl();
context.put(RecordAndReplayCurrentStatus.class, new RecordAndReplayCurrentStatus());
context.put(ModuleManager.class, moduleManager);
CoreRegistry.setContext(context);
Reflections reflections = new Reflections(getClass().getClassLoader());
TypeHandlerLibrary serializationLibrary = new TypeHandlerLibraryImpl(reflections);
serializationLibrary.addTypeHandler(Vector3f.class, new Vector3fTypeHandler());
serializationLibrary.addTypeHandler(Quaternionf.class, new QuaternionfTypeHandler());
NetworkSystem networkSystem = mock(NetworkSystem.class);
when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
context.put(NetworkSystem.class, networkSystem);
EntitySystemSetupUtil.addReflectionBasedLibraries(context);
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
EngineEntityManager entityManager = context.get(EngineEntityManager.class);
entityManager.getComponentLibrary().register(new ResourceUrn("test", "gettersetter"), GetterSetterComponent.class);
entityManager.getComponentLibrary().register(new ResourceUrn("test", "string"), StringComponent.class);
entityManager.getComponentLibrary().register(new ResourceUrn("test", "integer"), IntegerComponent.class);
ComponentLibrary componentLibrary = entityManager.getComponentLibrary();
componentSerializer = new ComponentSerializer(componentLibrary, serializationLibrary);
}
use of org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl in project Terasology by MovingBlocks.
the class ComponentMetadataTest method testStaticFieldsIgnored.
@Test
public void testStaticFieldsIgnored() {
Reflections reflections = new Reflections(getClass().getClassLoader());
EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, new TypeHandlerLibraryImpl(reflections));
ComponentLibrary lib = entitySystemLibrary.getComponentLibrary();
lib.register(new ResourceUrn("unittest:string"), StringComponent.class);
ComponentMetadata<StringComponent> metadata = lib.getMetadata(StringComponent.class);
assertNull(metadata.getField("STATIC_VALUE"));
}
Aggregations