Changed the check from number of players on server to the game being single player.
import org.terasology.logic.characters.CharacterComponent;
import org.terasology.logic.characters.events.PlayerDeathEvent;
import org.terasology.network.ClientComponent;
-import org.terasology.network.ClientInfoComponent;
+import org.terasology.network.NetworkMode;
+import org.terasology.network.NetworkSystem;
import org.terasology.registry.CoreRegistry;
import org.terasology.registry.In;
import org.terasology.rendering.nui.NUIManager;
private Time time;
@In
private EntityManager entityManager;
+ @In
+ private NetworkSystem networkSystem;
@Override
public void initialise() {
@@ -61,25 +64,16 @@ public void initialise() {
nuiManager.getHUD().addHUDElement("toolbar");
}
- //TODO
- //Implement this function in a separate file for reusabitility
- private int getPlayerCount() {
- int playerCount=entityManager.getCountOfEntitiesWith(ClientInfoComponent.class);
- return playerCount;
- }
-
@ReceiveEvent(components = ClientComponent.class)
public void onTogglePause(PauseButton event, EntityRef entity) {
if (event.getState() == ButtonState.DOWN) {
nuiManager.toggleScreen("engine:pauseMenu");
event.consume();
}
- if(getPlayerCount()==1)
- {
+ if (networkSystem.getMode() == NetworkMode.NONE) {
if (nuiManager.isOpen("engine:pauseMenu")) {
time.setPaused(true);
- }
- else{
+ } else {
time.setPaused(false);
}
}
