Search in sources :

Example 1 with NetworkMode

use of org.terasology.engine.network.NetworkMode in project Terasology by MovingBlocks.

the class AutoCreateSystem method postBegin.

@Override
public void postBegin() {
    Set<Prefab> existingGlobals = Sets.newHashSet();
    NetworkMode mode = networkSystem.getMode();
    for (EntityRef entity : entityManager.getEntitiesWith(AutoCreateComponent.class)) {
        existingGlobals.add(entity.getParentPrefab());
    }
    for (Prefab prefab : prefabManager.listPrefabs(AutoCreateComponent.class)) {
        AutoCreateComponent comp = prefab.getComponent(AutoCreateComponent.class);
        if (!existingGlobals.contains(prefab) && (comp.createClientSide || mode.isAuthority())) {
            entityManager.create(prefab);
        }
    }
}
Also used : NetworkMode(org.terasology.engine.network.NetworkMode) Prefab(org.terasology.engine.entitySystem.prefab.Prefab) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef)

Example 2 with NetworkMode

use of org.terasology.engine.network.NetworkMode in project Terasology by MovingBlocks.

the class DiscordRPCSystem method setPartyState.

private void setPartyState() {
    final NetworkMode networkMode = networkSystem.getMode();
    String mode = "Playing Online";
    if (networkMode == NetworkMode.DEDICATED_SERVER) {
        mode = "Hosting";
    } else if (networkMode == NetworkMode.NONE) {
        mode = "Playing Solo";
        DiscordRPCSubSystem.setPartyInfo(1, 1);
    }
    DiscordRPCSubSystem.setState(mode);
    if (networkMode != NetworkMode.NONE) {
        /* The player is playing online or hosting a game */
        DiscordRPCSubSystem.setPartyInfo(onlinePlayers, 99);
    }
}
Also used : NetworkMode(org.terasology.engine.network.NetworkMode)

Aggregations

NetworkMode (org.terasology.engine.network.NetworkMode)2 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)1 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)1