use of org.terasology.engine.network.NetworkComponent in project Terasology by MovingBlocks.
the class PojoEntityRef method toString.
@Override
public String toString() {
Prefab parent = getParentPrefab();
StringBuilder builder = new StringBuilder();
builder.append("EntityRef{id = ");
builder.append(id);
NetworkComponent networkComponent = getComponent(NetworkComponent.class);
if (networkComponent != null) {
builder.append(", netId = ");
builder.append(networkComponent.getNetworkId());
}
if (parent != null) {
builder.append(", prefab = '");
builder.append(parent.getUrn());
builder.append("'");
}
builder.append("}");
return builder.toString();
}
use of org.terasology.engine.network.NetworkComponent in project Terasology by MovingBlocks.
the class NetworkOwnershipTest method testClientSentNetInitialForExistingNetworkEntityOnConnect.
@Test
public void testClientSentNetInitialForExistingNetworkEntityOnConnect() {
EntityRef entity = entityManager.create(new NetworkComponent());
networkSystem.registerNetworkEntity(entity);
connectClient();
assertTrue(entity.getComponent(NetworkComponent.class).getNetworkId() != 0);
verify(client).setNetInitial(entity.getComponent(NetworkComponent.class).getNetworkId());
}
use of org.terasology.engine.network.NetworkComponent in project Terasology by MovingBlocks.
the class NetworkOwnershipTest method testClientNoInitialEntityIfNotOwnedAndReplicateToOwner.
@Test
public void testClientNoInitialEntityIfNotOwnedAndReplicateToOwner() {
connectClient();
NetworkComponent netComp = new NetworkComponent();
netComp.replicateMode = NetworkComponent.ReplicateMode.OWNER;
EntityRef entity = entityManager.create(netComp);
networkSystem.registerNetworkEntity(entity);
assertTrue(entity.getComponent(NetworkComponent.class).getNetworkId() != 0);
verify(client, times(0)).setNetInitial(entity.getComponent(NetworkComponent.class).getNetworkId());
}
use of org.terasology.engine.network.NetworkComponent in project Terasology by MovingBlocks.
the class NetworkOwnershipTest method testClientSentNetInitialForNewNetworkEntity.
@Test
public void testClientSentNetInitialForNewNetworkEntity() {
connectClient();
EntityRef entity = entityManager.create(new NetworkComponent());
networkSystem.registerNetworkEntity(entity);
assertTrue(entity.getComponent(NetworkComponent.class).getNetworkId() != 0);
verify(client).setNetInitial(entity.getComponent(NetworkComponent.class).getNetworkId());
}
use of org.terasology.engine.network.NetworkComponent in project Terasology by MovingBlocks.
the class NetworkOwnershipTest method testClientSendInitialForRelevantOwnedItems.
@Test
public void testClientSendInitialForRelevantOwnedItems() {
EntityBuilder builder = entityManager.newBuilder();
NetworkComponent netCompA = builder.addComponent(new NetworkComponent());
netCompA.replicateMode = NetworkComponent.ReplicateMode.RELEVANT;
builder.setOwner(clientEntity);
EntityRef entityA = builder.build();
networkSystem.registerNetworkEntity(entityA);
connectClient();
verify(client, times(1)).setNetInitial(entityA.getComponent(NetworkComponent.class).getNetworkId());
}
Aggregations