use of org.terasology.engine.entitySystem.entity.internal.OwnershipHelper in project Terasology by MovingBlocks.
the class OwnershipHelperTest method testListsOwnedEntities.
@Test
public void testListsOwnedEntities() {
EntityRef ownedEntity = entityManager.create();
OwnerComponent ownerComp = new OwnerComponent();
ownerComp.child = ownedEntity;
EntityRef ownerEntity = entityManager.create(ownerComp);
OwnershipHelper helper = new OwnershipHelper(entityManager.getComponentLibrary());
ArrayList<EntityRef> target = Lists.newArrayList(helper.listOwnedEntities(ownerEntity));
assertEquals(target.size(), 1);
assertEquals(target.get(0), ownedEntity);
}
use of org.terasology.engine.entitySystem.entity.internal.OwnershipHelper in project Terasology by MovingBlocks.
the class NetworkSystemImpl method connectToEntitySystem.
@Override
public void connectToEntitySystem(EngineEntityManager newEntityManager, EventLibrary newEventLibrary, BlockEntityRegistry blockEntityRegistry) {
if (this.entityManager != null) {
this.entityManager.unsubscribe(this);
}
this.entityManager = newEntityManager;
this.entityManager.subscribeForChanges(this);
this.blockManager = context.get(BlockManager.class);
this.ownershipHelper = new OwnershipHelper(newEntityManager.getComponentLibrary());
this.storageManager = context.get(StorageManager.class);
this.eventLibrary = newEventLibrary;
this.componentLibrary = entityManager.getComponentLibrary();
context.get(ComponentSystemManager.class).register(new NetworkEntitySystem(this), "engine:networkEntitySystem");
TypeHandlerLibrary typeHandlerLibrary = entityManager.getTypeSerializerLibrary().copy();
typeHandlerLibrary.addTypeHandler(EntityRef.class, new NetEntityRefTypeHandler(this, blockEntityRegistry));
// TODO: Add network override types here (that use id lookup tables)
eventSerializer = new EventSerializer(eventLibrary, typeHandlerLibrary);
entitySerializer = new NetworkEntitySerializer(newEntityManager, entityManager.getComponentLibrary(), typeHandlerLibrary);
entitySerializer.setComponentSerializeCheck(new NetComponentSerializeCheck());
if (mode == NetworkMode.CLIENT) {
entityManager.setEntityRefStrategy(new NetworkClientRefStrategy(this));
applySerializationTables();
}
if (server != null) {
server.connectToEntitySystem(newEntityManager, entitySerializer, eventSerializer, blockEntityRegistry);
}
}
Aggregations